Skip to content

🚀 Feature: Ollama instrumentation missing inference metadata attributes in spans #4192

Description

@Saptami191

Which component is this feature for?

Ollama Instrumentation

🔖 Feature description

Ollama responses expose useful inference duration metadata such as:

  • total_duration
  • load_duration
  • prompt_eval_duration
  • eval_duration

However, these values are currently not propagated into exported tracing span attributes.

From reviewing the current instrumentation implementation, token-related metadata such as prompt_eval_count and eval_count already appear to be handled correctly, but duration-related telemetry fields are not currently attached to spans.

The Ollama API response contains richer performance telemetry data that could improve observability quality.

🎤 Why is this feature needed ?

These duration metrics are useful for debugging and performance analysis.

For example:

  • load_duration helps identify cold start/model loading overhead
  • eval_duration helps analyze inference latency
  • prompt_eval_duration helps measure prompt processing cost
  • total_duration provides useful end-to-end execution timing insight

During local testing, these values were available in the Ollama API response but were not included in exported span attributes.

This makes it harder to analyze inference bottlenecks and distinguish model loading overhead from evaluation latency through observability tooling.

✌️ How do you aim to achieve this?

Extract the duration-related fields from the Ollama response payload and attach them as span attributes during instrumentation.

Example candidate attributes:

llm.ollama.total_duration
llm.ollama.load_duration
llm.ollama.prompt_eval_duration
llm.ollama.eval_duration

The existing response attribute extraction path already handles token metadata, so duration metrics could likely be added alongside the current response attribute handling logic.

🔄️ Additional Information

Example observed Ollama response:

{
  "total_duration": 115588345200,
  "load_duration": 53118691900,
  "prompt_eval_count": 11,
  "prompt_eval_duration": 48132531100,
  "eval_count": 26,
  "eval_duration": 13506373700
}

Current exported spans do not appear to include the duration-related response fields.

During investigation, token usage attributes appeared to already be propagated correctly, but the duration-related response fields were not attached to spans.

Image

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions