opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Turn off metric programmatically with environment variable

Open pallavibhingarkar opened this issue 11 months ago • 3 comments

We have requirement to turn off certain metric based on some environment variable which may include metric name to be turned off.

We are looking for best way to do that.

Currently we are using http for metric instrumentation.

pallavibhingarkar avatar Jan 27 '25 07:01 pallavibhingarkar

hi @pallavibhingarkar! have you looked at using metric views with declarative configuration? e.g. https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/declarative-configuration

trask avatar Jan 27 '25 19:01 trask

➕ to @trask's advice. Views are the idiomatic way to turn off specific metrics. And we don't plan on adding additional environment variables, especially for concepts like views which cannot be easily / intuitively flattened to an environment variable based scheme.

Declarative config is the answer, and a stable specification is in sight. A stable java implementation would follow sometime after.

jack-berg avatar Jan 27 '25 21:01 jack-berg

Labeled as "blocked:spec", but should probably close because this gives the impression that its just a matter of spec work to get this done. The changes that standard environment variables are added for this are exceedingly low so should probably close.

jack-berg avatar Jan 27 '25 21:01 jack-berg