Open nirga opened 1 month ago
@nirga
Yes there doesn't seem a very powerful way to configure metrics in the sdk as of today (except for [views](https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples/metrics/views but the configuration options are limited). A couple of questions:
@lzchen thanks!
@nirga
Hmm, not sure I understand the difference? I want the enriched attributes to be available when the metrics "leave" the service.
I'm wondering if you can achieve this desired behavior by using a custom exporter and enrich the metrics data with the attributes you want prior to export.
@lzchen the problem is that I need the context which contains the attributes to enrich - and in the exporter I no longer have the context of the specific execution where the metric was recorded.
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 intoon_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