🚀 Feature: Ollama instrumentation missing inference metadata attributes in spans

Open
#4,192 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@krishna231122-del is already working on this.

Since Jun 15, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
ollama, python

Research direction

Locate the Ollama instrumentation response-attribute extraction path and review how prompt and evaluation token metadata is attached to spans. Add the four duration fields as span attributes alongside the existing response metadata, then run the relevant Ollama instrumentation tests and verify the exported spans contain them.

Written by the indexing model from the issue text.

Description

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!

Dominant language
Python
Stars
7.5k
Forks
1.2k
Avg merge
2d 6h
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from traceloop/openllmetry

All issues in traceloop/openllmetry

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.