Skip to content
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

Provide capability to define histogram bounds when constructing histogram itself #2755

Closed
tomkerkhove opened this issue Dec 20, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@tomkerkhove
Copy link
Contributor

Feature Request

Is your feature request related to a problem?

We want to assign different histogram buckets when creating the histogram itself, not when building the metric provider.

Describe the solution you'd like:

Provide the capability to define histogram bounds when constructing histogram itself, instead of using views on the metric provider definition.

Describe alternatives you've considered.

Change an existing view, but that doesn't seem to be possible as well.

Additional Context

N/A

@tomkerkhove tomkerkhove added the enhancement New feature or request label Dec 20, 2021
@alanwest
Copy link
Member

The current API for creating histograms matches the current specification. See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#histogram-creation.

The idea is that it is up to the application developer to define the boundaries that make sense in the context of their application using the metric SDK's view API.

However, there is a proposed "hint" API which would enable library authors to provide default histogram bounds for the instruments their library creates. This hint API would be slated for .NET 7 if the specification for it is ready by then. See: dotnet/runtime#62027. Specifically:

Add "hints" in Metric API to provide things like histogram bounds, recommended tags etc. (OTel spec dependency). P1 If the specs get ready, we may consider it at that time.

@tomkerkhove
Copy link
Contributor Author

Thanks for sharing, that would be helpful indeed.

As of today, as far as I know you can only add views as following:

var meterProvider = Sdk.CreateMeterProviderBuilder()
                       .AddMeter("Sample.*")
                       .AddOtlpExporter(options=>
                       {
                          options.Endpoint = new Uri(collectorUri);
                       })
                       .AddView("<name>", new ExplicitBucketHistogramConfiguration { Boundaries = histogramBoundaries })
                       .Build();

Is there a way to add more view once it has been constructed like this or is this the only supported method for now?

@alanwest
Copy link
Member

Is there a way to add more view once it has been constructed like this or is this the only supported method for now?

No way to add a view once you've built your meter provider. This is the only way.

@tomkerkhove
Copy link
Contributor Author

I'd love to re-open this as this is pretty important imo

@cijothomas
Copy link
Member

I'd love to re-open this as this is pretty important imo

Unfortunately, .NET can't add this feature, as the spec is pending and need to wait for it to stabilize

@alanwest
Copy link
Member

This issue was closed, but for visibility a new issue was opened to track this #5166. The underlying support from .NET is being considered for the .NET 9 timeframe dotnet/runtime#63650.

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

No branches or pull requests

3 participants