Skip to content

[Feature]: Implement MetricProducer #2505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
divergentdave opened this issue Jan 10, 2025 · 2 comments
Open

[Feature]: Implement MetricProducer #2505

divergentdave opened this issue Jan 10, 2025 · 2 comments
Labels
enhancement New feature or request triage:todo Needs to be traiged.

Comments

@divergentdave
Copy link
Contributor

Related Problems?

This was removed in #2105 to reduce scope prior to 1.0.

Describe the solution you'd like:

I wanted to file a feature request for the eventual re-implementation of this part of the spec, and share my use case for it.

I'm using MetricProducer from opentelemetry_sdk v0.24.1 to adapt runtime metrics from the Tokio async runtime library, and to export them alongside application-defined metrics that use the OpenTelemetry SDK in a more traditional way. My main reason for using a MetricProducer is that it lets me create a HistogramDataPoint from already-aggregated histogram counter values produced by the Tokio library. Each Tokio worker thread has an array of histogram counters representing different buckets, and these counters are incremented during performance-sensitive operations by the library. When MetricProducer::produce() is called, my implementation reads those per-thread bucket counts, and outputs a HistogramDataPoint. I cannot use SDK histogram instruments, because Tokio does not expose the elapsed time underlying this histogram to user code, only the already-aggregated histogram, and the only API that SDK histogram instruments provide is record().

For reference, here's the source: https://github.com/divviup/janus/blob/e21f8663ad33902b03f5cf627b9cb6223646ad1f/aggregator/src/metrics/tokio_runtime.rs

Considered Alternatives

No response

Additional Context

MetricProducer is defined in the specification.

@RDruon
Copy link

RDruon commented Apr 24, 2025

Hello,

We are really interested in this implementation of this part of the spec. Similar to @divergentdave we plan to rely on OpenTelemetry to re-export metrics from other source into OpenTelemetry format.
The current main pain point is the histogram part where we get already computed histogram but want to re-export them into OpenTelemetry histogram. It seems the MetricProducer perfectly fit into this use case.

@cijothomas is there any plan to put back this part of the spec into scope?

@cijothomas
Copy link
Member

Yes this was only removed to keep scope in control for Metrics SDK stable release. We are almost ready to declare Metrics SDK stable. @fraillt has some changes being worked on related to Export structures, and will impact producer implementation.
Once this is done, we can re-add Producer support back.
(If anyone has bandwidth to contribute, we are happy to help reviews etc. Please wait 1-3 weeks when we expect to close the pending discussion and declare Metrics Sdk stable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage:todo Needs to be traiged.
Projects
None yet
Development

No branches or pull requests

3 participants