Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ def set_model_response_attributes(span, token_histogram, llm_request_type, respo
)
_set_span_attribute(span, GenAIAttributes.GEN_AI_SYSTEM, "Ollama")

_set_span_attribute(
span,
"llm.ollama.total_duration",
response.get("total_duration"),
)

_set_span_attribute(
span,
"llm.ollama.load_duration",
response.get("load_duration"),
)

_set_span_attribute(
span,
"llm.ollama.prompt_eval_duration",
response.get("prompt_eval_duration"),
)

_set_span_attribute(
span,
"llm.ollama.eval_duration",
response.get("eval_duration"),
)

if (
token_histogram is not None
and isinstance(input_tokens, int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def test_ollama_generation_legacy(
GenAIAttributes.GEN_AI_USAGE_OUTPUT_TOKENS
) + ollama_span.attributes.get(GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS)

assert ollama_span.attributes.get("llm.ollama.total_duration") > 0

assert ollama_span.attributes.get("llm.ollama.load_duration") > 0

assert ollama_span.attributes.get("llm.ollama.prompt_eval_duration") > 0

assert ollama_span.attributes.get("llm.ollama.eval_duration") > 0

logs = log_exporter.get_finished_logs()
assert (
len(logs) == 0
Expand Down Expand Up @@ -162,6 +170,14 @@ def test_ollama_streaming_generation_legacy(
GenAIAttributes.GEN_AI_USAGE_OUTPUT_TOKENS
) + ollama_span.attributes.get(GenAIAttributes.GEN_AI_USAGE_INPUT_TOKENS)

assert ollama_span.attributes.get("llm.ollama.total_duration") > 0

assert ollama_span.attributes.get("llm.ollama.load_duration") > 0

assert ollama_span.attributes.get("llm.ollama.prompt_eval_duration") > 0

assert ollama_span.attributes.get("llm.ollama.eval_duration") > 0

logs = log_exporter.get_finished_logs()
assert (
len(logs) == 0
Expand Down