Open grouzen opened 4 months ago
Hi @grouzen What do you think can we use OpenTelemetryMeterRegistry and DistributionSummary.Builder for this issue?
I have researched some libraries and find this OpenTelemetryMeterRegistry It has DistributionSummary, but methods for building OpenTelemetryMeterRegistry are not flexible. I will try to create a PR with method builder taking OpenTelemetry Meter
Hi @IvanFinochenko! Sorry, don't have enough time at the moment to check this. Regarding OpenTelemetryMeterRegistry - I don't think we need it since we maintain our own registry for our instruments. We just need to "copy" the way they map DistributedSummary to OTEL Histogram. The problem is the parts of the mapping algorithm are scattered all over the micrometer's codebase so it is tricky to understand it as a whole.
@IvanFinochenko
We need to implement https://github.com/zio/zio-telemetry/blob/series/2.x/opentelemetry/src/main/scala/zio/telemetry/opentelemetry/metrics/internal/OtelMetricListener.scala#L40.
For this, we need to use registry.getHistogram
and transform the payload of the ZIO Metrics Summary into OTEL Metrics Histogram. Hope it makes sense.
@IvanFinochenko, we could do a pairing session in Discord, for example, if you want.
@grouzen it is a good idea. I need a little more time to dive deeper under hood of micrometer and I'll write you.
So I also took a look at this and I found following things:
I personally see 2 solutions
Currently in zio-telemetry metrics are added directly to Java API counterparts. Instead of doing that we could utilize MetricProducer to instead pull metrics from inside ZIO-Metrics.
From my understanding OTEL is like a consorcium of companies that does telemetry stuff. If they decided that summary metric is deprecated, should we still have it?
@andrzejressel Hey! I want to clarify this one. From your reply, I understood you are talking about adding support for OTEL Summary, which is legacy. This particular issue is about mapping ZIO metrics Summary to OTEL Histogram because OTEL Summary is deprecated, as stated above. That's precisely what the micrometer library does internally. It also avoids dealing with OTEL Summary and uses quite complex logic to map summaries to histograms for the OTEL case.
This functionality wasn't implemented in https://github.com/zio/zio-telemetry/pull/801 as it is tricky to do.
As a reference you can look at the https://github.com/micrometer-metrics/micrometer library. It does exactly this for OTEL integration.