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

Allow disabling by data type (metrics, logs, traces)

Open jefchien opened this issue 10 months ago • 4 comments

Is your feature request related to a problem? Please describe.

Similar to https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/9481

The Java Agent allows suppressing specific library instrumentation using environment variables or system properties as is very well documented here: https://opentelemetry.io/docs/instrumentation/java/automatic/agent-config/#suppressing-specific-agent-instrumentation

Currently, you can either disable each individual exporter or disable the auto-instrumentation as a whole (otel.instrumentation.common.default.enabled=false). This means it doesn't support the use case of wanting auto-instrumentation for one data type, but more granular control for another.

In my use case, I'm trying to retain auto-instrumentation for traces, but only enable one instrumentation (jmx) for metrics. With the current setup, if I enable the metrics exporter, I get a ton of extra metrics that will need to be filtered out by the collector.

Describe the solution you'd like

Add a feature flag that allows users to disable by data type.

Describe alternatives you've considered

Only alternative would be something similar to a Sampler for the metrics. Does that exist? Could metrics be filtered by instrumentation scope?

Additional context

No response

jefchien avatar Apr 08 '24 18:04 jefchien

Only alternative would be something similar to a Sampler for the metrics. Does that exist? Could metrics be filtered by instrumentation scope?

Yes! Check out metric views: https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/incubator#view-file-configuration

trask avatar Apr 10 '24 03:04 trask

I am trying to disable tracing from one framework but keep the metrics enabled. would this be possible through the metric view? Or would I need a custom Sampler as suggested here? I was hoping there'd be some configuration-based option, e.g. OTEL_INSTRUMENTATION_<FRAMEWORK>_TRACING_ENABLED: 'false'

bcarter97 avatar Apr 20 '24 18:04 bcarter97

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.

github-actions[bot] avatar Apr 27 '24 19:04 github-actions[bot]

Hi @bcarter97! Can you open a separate issue for your question / use case since it's different from the one on this issue?

trask avatar May 01 '24 04:05 trask

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed automatically if there is no response from the author within 7 additional days from this comment.

github-actions[bot] avatar May 08 '24 05:05 github-actions[bot]

In case anyone else is trying to do this, the metric view worked. Followed the discussion from https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions/10284 and ended up with

- selector:
    meter_name: io.opentelemetry.jmx
  view:
    aggregation: default
- selector:
    instrument_name: "*"
  view:
    aggregation: drop

which drops all metrics except for those produced by the JMX Metric Insight instrumentation. Thanks @trask!

jefchien avatar Jun 17 '24 17:06 jefchien