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

Support exemplars in Metrics #2527

Closed
6 tasks done
cijothomas opened this issue Oct 27, 2021 · 8 comments
Closed
6 tasks done

Support exemplars in Metrics #2527

cijothomas opened this issue Oct 27, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request metrics Metrics signal related
Milestone

Comments

@cijothomas
Copy link
Member

cijothomas commented Oct 27, 2021

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar

First stable release (1.9.0)

Future release

@cijothomas cijothomas added enhancement New feature or request metrics Metrics signal related release:required-for-ga labels Oct 27, 2021
@cijothomas cijothomas added this to the 1.3.0 milestone Nov 16, 2021
@cijothomas cijothomas modified the milestones: 1.3.0, 1.4.0 Apr 20, 2022
@cijothomas
Copy link
Member Author

Have reviewed this in detail, and concluded the changes are non-trivial, and will not be part of 1.4.0 (Nov 2022) release. We expect to add beta support for this, shortly after 1.4.0 has shipped, with the goal of making it stable by 1.5.0 (no ETA for stable yet, but 3-4 months after 1.4.0)

@cijothomas
Copy link
Member Author

Update:
1.5.0-alpha.1 added basic exemplar support. See https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/metrics/customizing-the-sdk#exemplars

E2E Example/Demo - https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/metrics/exemplars

Basic implementation only, more coming in then next few weeks.

@alanwest alanwest modified the milestones: 1.5.0, 1.6.0 Apr 20, 2023
@alanwest alanwest modified the milestones: 1.6.0, 1.7.0 Jun 6, 2023
@cijothomas cijothomas removed this from the 1.7.0 milestone Oct 25, 2023
@cijothomas
Copy link
Member Author

Removing from 1.7.0 milestone. The spec is still experimental, so this feature remains experimental here as well. Will update the issue here once we get a firmer grasp of ETA for stability.

Meanwhile, please continue sharing feedback on the Exemplar feature!

@vishweshbankwar vishweshbankwar added this to the 1.9.0 milestone Mar 12, 2024
@CodeBlanch CodeBlanch assigned CodeBlanch and unassigned cijothomas Mar 13, 2024
@CodeBlanch CodeBlanch added the needs-spec-change Issues which require the OpenTelemetry Specification to clarify or define behavior label Mar 13, 2024
@CodeBlanch
Copy link
Member

I just updated the description for the plan @cijothomas and I have worked out for 1.9.0 and releasing Exemplars stable. We decided to stay close to what the spec has defined.

Users who want to turn on Exemplars can do so using the spec-defined SetExemplarFilter mechanism. If enabled, the SDK will use all the spec-defined default ExemplarReservoirs.

We feel the cost for enabling Exemplars for all metrics is too high and they are most useful for histograms. We want to enable the scenario of turning on Exemplars just for histograms. What we are going to do is introduce an experimental envvar for this. See the details below for why we decided to go this route. The key point is it will work in stable builds and doesn't require an API which would require a prerelease build.

We have decided NOT to expose ExemplarReservoir or the configuration via the View API in the first release. This will only be available in prerelease builds. We want to gather feedback first on the use cases to make sure what is being exposed will meet the needs of users. It also seems likely the default reservoirs may change so we were hesitant to expose those initially.

Details

The main design we considered was this:

  • Set SDK ExemplarFilterType default to: TraceBased (spec-compliant)
  • Set the default ExemplarReservoir to NoopExemplarReservoir or SimpleFixedSizeExemplarReservoir(0) (deviates from the spec-defined defaults)
  • Allow users to use the View API to set ExemplarReservoir to SimpleFixedSizeExemplarReservoir, AlignedHistogramBucketExemplarReservoir, or something custom (spec-compliant).

This is a pretty big deviation from the spec. It forces users to use the View API to enable Exemplars individually for any metric where they are needed. It also requires a lot of API to be exposed publicly. There is also a concern that if users were to enable Exemplars via something like AlignedHistogramBucketExemplarReservoir and then the spec comes up with a better default algorithm, users would have to update their code to take advantage of that in future releases. ExemplarReservoir is a more advanced API. For users who want to selectively enable/disable Exemplars forcing that into the ExemplarReservoir seemed heavy-handed. We felt it better to work through the spec to enable such scenarios in well-defined APIs.

We feel the spec API is good at enabling or disabling Exemplars for everything. The only core use case we felt was not represented is enabling Exemplars for just histograms. There isn't a good way to do this via the spec. Our current thinking is this API would be useful:

meterProviderBuilder.SetExemplarFilter(InstrumentType.Histogram, ExemplarFilterType.TraceBased)

But we would need to expose that experimentally which would only be available in pre-release builds. We're going to go with an experimental envvar for histograms to get close in a way that will work in stable builds.

@CodeBlanch CodeBlanch removed the needs-spec-change Issues which require the OpenTelemetry Specification to clarify or define behavior label May 21, 2024
@prajon84
Copy link

@CodeBlanch : Does it mean that exemplars can be turned on by SetExemplarFilter(ExemplarFilterType.TraceBased), but only for histogram metrics with release 1.9.0 ?

@cijothomas
Copy link
Member Author

@CodeBlanch : Does it mean that exemplars can be turned on by SetExemplarFilter(ExemplarFilterType.TraceBased), but only for histogram metrics with release 1.9.0 ?

SetExemplarFilter(ExemplarFilterType.TraceBased) will enable for all instruments, not just histograms.

@prajon84
Copy link

Well, Do you have any example with counter metrics? I do not see any relevant example

@cijothomas
Copy link
Member Author

You can run the getting started doc : https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/docs/metrics/getting-started-console/Program.cs
and do SetExemplarFilter(ExemplarFilterType.AlwaysOn). This should print the exemplars for counters on the console.

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

No branches or pull requests

5 participants