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 disabled-by-default metrics using an advisory parameter. #4391

Open
dashpole opened this issue Jan 30, 2025 · 3 comments
Open

Support disabled-by-default metrics using an advisory parameter. #4391

dashpole opened this issue Jan 30, 2025 · 3 comments
Labels
spec:metrics Related to the specification/metrics directory

Comments

@dashpole
Copy link
Contributor

What are you trying to achieve?

As an instrumentation author, I would like to record metrics that are disabled by default. Today, I need to add configuration to my instrumentation library to support enabling or disabling metrics.

As an end-user, I would like to be able to use a View (or other similar mechanism) to enable default-disabled metrics--ideally in a way that is compatible with the file-based SDK configuration so I can enable such metrics at runtime.

Proposed solution

I propose adding a new advisory parameter to the metrics Instrument API: "DefaultDisabled" (naming depends on the outcome of #4344). If this parameter is provided on instrument creation, the SDK will use the DropAggregation by default instead of the standard default.

A user could enable this metric by changing the Aggregation of the metric stream from DropAggregation to the DefaultAggregation.

This is very similar to the approach taken by the Attributes advisory parameter, in that it allows instrumentation authors to provide verbose telemetry using the instrument API, but specify a different default for how it is aggregated on instrument creation.

Alternatives considered

  • We could take a more general approach, and support a "DefaultAggregation" advisory parameter. This would allow something like measuring using histogram instrument, but defaulting to aggregating as a gauge. I'm not convinced those kinds of use-cases exist, though.

Additional context.

This came up in the context of open-telemetry/opentelemetry-go-contrib#6321 (comment).

@dashpole dashpole added the spec:metrics Related to the specification/metrics directory label Jan 30, 2025
@dashpole
Copy link
Contributor Author

cc @MrAlias

@cijothomas
Copy link
Member

cijothomas commented Jan 31, 2025

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterconfigurator
Could the instrumentation's Meter (Scope) name be used to disable it by the end user? (No need of Views)

(Agree this is not something the instrumentation author can control.)

@trask
Copy link
Member

trask commented Jan 31, 2025

I really like the idea of having a standard way to implement disabled-by-default metrics.

We have several of these in Java instrumentation, and each one currently needs to have its own config property for users to be able to enable it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec:metrics Related to the specification/metrics directory
Projects
None yet
Development

No branches or pull requests

3 participants