open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.88k stars 822 forks source link

Dropwizard Metric name to attributes transformer #10048

Open philsttr opened 9 months ago

philsttr commented 9 months ago

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

DropWizard Metrics does not natively support tags/attributes.

However, a common workaround for users of DropWizard Metrics is to encode tag name/value pairs in the metric name. For example, have a DropWizard Metric with the following name:

metricName[tag:value,othertag:othervalue]

Unfortunately, the OpenTelemetry DropWizard instrumentation uses the DropWizard metric name as-is, and does not provide a mechanism to decode the metric name into name + attributes. This produces low-quality data, which is why the dropwizard-metrics instrumentation is disabled by default.

Describe the solution you'd like

It would be nice if the OpenTelemetry DropWizard Metrics instrumentation had pluggable support for decomposing DropWizard Metric names into name + attributes. Otel could also provide some out-of-the-box implementations for common encodings such as the one mentioned in the example above.

For comparison, this approach has been implemented in dropwizard-metrics-newrelic.

This solution would allow applications currently instrumented with DropWizard metrics with names containing encoded tag name/values to be able to report these metrics via OpenTelemetry, and produce high quality data.

Describe alternatives you've considered

None, other than not using DropWizard Metrics

Additional context

No response

laurit commented 8 months ago

We'd welcome a contribution for this

ryanprayogo commented 2 weeks ago

@philsttr In the otel world, what is the mechanism for one to supply a custom/pluggable name/attribute customizer (similar to the newrelic one)?

Looking into other examples, it seems like one can only configure basic settings through AgentInstrumentationConfig (eg, in Micrometer)

I'm interested in contributing for this issue.