open-telemetry / opentelemetry-java-examples

https://opentelemetry.io
Apache License 2.0
194 stars 115 forks source link

Unable to send custom metrics using otel Java Agent. #407

Open rahul-narkhede opened 3 months ago

rahul-narkhede commented 3 months ago

I have a java servlet application running via otel agent in tomcat server. I can see the traces and default metrics created by application coming into my collector and eventually into datadog.

However, I wanted to add some custom metric Histograms. So, I created the meter object using GlobalOpenTelemetry

Meter meter = GlobalOpenTelemetry.getMeter("")
LongHistogram myhistogram =  meter.histogramBuilder(...)
....

When I set the -Dotel.metrics.exporter=otlp,logging , I can see the metric value logged on my console, but nothing shows up on collector or datadog.

Any help in this matter is appreciated.

VigneshGanesan-meesho commented 2 months ago

@rahul-narkhede any fix for this. Running into the same problem

jaydeluca commented 1 month ago

do you have the otlp exporter added as a dependency?

implementation("io.opentelemetry:opentelemetry-exporter-otlp")