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

Prevent kafka `client-id` from being emitted

Open naumaan123 opened this issue 1 year ago • 6 comments

I have a spring boot app auto configured with opentelemetry, and am using kafka to send some messages. I am attempting to prevent some attributes/metrics from being emitted such as client-id and kafka.producer.io_ratio. Here is a sample of a properties file

otel.experimental.resource.disabled-keys=client-id,kafka.producer.io_ratio

I am not getting the expected results. I may have a fundamental misunderstanding of this prop as it seems to work for some other attributes, can someone point out what im doing wrong? I also tried creating a view-config.yml file and had the below

- selector:
       instrument_name: kafka.producer.io_ratio
     views:
       aggregation: drop

but this seemed to disable all sorts of tracing and the entire kafka metrics.

naumaan123 avatar Oct 10 '24 16:10 naumaan123

hi @naumaan123,

otel.experimental.resource.disabled-keys=client-id,kafka.producer.io_ratio

this won't work because those are metric attributes (as opposed to resource attributes)

here's some links that may help:

  • https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions/12395
  • https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/javaagent

trask avatar Oct 10 '24 17:10 trask

Thanks for the links, this is close to what im looking for. For the view configs to disable metrics, whats the appropriate system property to set, these 3 seem to be setup similarly if i want to disable specific metrics from kafka for example

otel.config.file otel.experimental.config.file otel.experimental.metrics.view-config

naumaan123 avatar Oct 11 '24 04:10 naumaan123

Best case for now is to use otel.experimental.metrics.view-config. Documentation available here.

We're actively working towards stringing the final pieces together that would allow you to use otel.experimental.config.file in the java agent. Documentation available here. This is currently blocked on this PR, and should be available in the upcoming release of opentelemetry-java-instrumentation.

jack-berg avatar Oct 11 '24 22:10 jack-berg

Appreciate the followup. It seems like otel.experimental.metrics.view-config doesn't allow removing/excluding attribute_keys, only the declarative configuration, am i reading that correcting?

naumaan123 avatar Oct 11 '24 22:10 naumaan123

No it does support that. The example from the docs is setting the list of attributes to retain. Any not in that set are excluded. The declarative config solution is more expressive, supporting both disallow and allow lists, but they achieve the same affect.

jack-berg avatar Oct 11 '24 22:10 jack-berg

Gotcha. I guess for me that would be overly complex since i simply want to filter out a single attribute and kafka has tons id have to account for. This is a legacy ssytem im working in so i dont want to accidentally drop attributes that are being used. Ill likely wait until the declaritive configuration is ready. Thanks!

naumaan123 avatar Oct 11 '24 23:10 naumaan123

Closing as declarative config is now available in the java agent.

jack-berg avatar Dec 19 '25 16:12 jack-berg