open-telemetry / open-telemetry/opentelemetry-python

Allow providing a "MetricProcessor", similar to a SpanProcessor

Open
#4,230 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request metrics sdk
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Is your feature request related to a problem?

I'm maintaining OpenLLMetry and we have an SDK that wraps the instrumentations and enriches them with different properties. For traces, we use the SpanProcessor to tap into on_start and add attributes to relevant spans. We want to do something similar for metrics (add some attributes), so ideally, we'd love to have a way to do that before a metric is added / aggregated on the OpenTelemetry SDK level.

Describe the solution you'd like

I'd imagine something on the level of the consume_measurement - potentially allowing to specify a callback / attribute enrichments, or overriding the consumer.

Describe alternatives you've considered

I couldn't find any other way to add attributes to a metric after it's recorded.

Additional Context

No response

Would you like to implement a fix?

Yes

Contributor guide

Open the contributing guide

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.

Research direction

Start by comparing the existing SpanProcessor behavior with the metric SDK path around consume_measurement. Determine where a processor, callback, or attribute-enrichment hook could run before measurements are added or aggregated. Done means the SDK exposes a documented way to enrich metric attributes before aggregation, with coverage for the new behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.