Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get Micrometer custom metrics #5292

Closed
irizzant opened this issue Feb 1, 2022 · 20 comments · Fixed by #8334
Closed

Cannot get Micrometer custom metrics #5292

irizzant opened this issue Feb 1, 2022 · 20 comments · Fixed by #8334
Labels
bug Something isn't working

Comments

@irizzant
Copy link

irizzant commented Feb 1, 2022

Describe the bug
I have a Java application instrumented to create custom Micrometer metrics.
The very same Java application uses the OpenTelemetry Java Instrumentation agent to collect metrics using the Prometheus exporter.

I can see Micrometer metrics and OpenTelemetry metrics being exported just fine, but I cannot see Micrometer metrics exported via OpenTelemetry Prometheus exporter.

It's my understanding that from 1.10 the agent should export Micrometer metrics but maybe I get this wrong.

Agent is configured like this:

-Dotel.service.name=webportal
-Dotel.exporter.otlp.endpoint=http://tempo.tempo.svc.cluster.local:4317
-Dotel.traces.exporter=otlp
-Dotel.exporter.otlp.compression=gzip
-Dotel.metrics.exporter=prometheus

Querying port 9464 produces OTEL metrics like the following:

http_client_duration_sum{http_flavor="1.1",http_method="GET",http_status_code="200",http_url="http://localhost:8080/webtng/ediMonitorREST_1_0_0/status",} 301.605403 1643730489470
http_client_duration_bucket{http_flavor="1.1",http_method="GET",http_status_code="200",http_url="http://localhost:8080/webtng/ediMonitorREST_1_0_0/status",le="5.0",} 0.0 1643730489470
http_client_duration_bucket{http_flavor="1.1",http_method="GET",http_status_code="200",http_url="http://localhost:8080/webtng/ediMonitorREST_1_0_0/status",le="10.0",} 0.0 1643730489470
http_client_duration_bucket{http_flavor="1.1",http_method="GET",http_status_code="200",http_url="http://localhost:8080/webtng/ediMonitorREST_1_0_0/status",le="25.0",} 0.0 1643730489470

Querying the Mircometer port I get the following:

edimonitor_inmessage_incorrect_total{application="edimonitor",edimonitorinstance="0",edimonitorjob="JOB",} 0.0

but I cannot find the latter metrics inside the former ones.

Steps to reproduce

  1. instrument a Java application with custom Java Micrometer metrics
  2. auto-instrument a Java application with OTEL agent
  3. enable Prometheus exporter for OTEL
  4. verify that Micrometer metrics are exported via OTEL agent

What did you expect to see?
Metrics from Micrometer reported in the Prometheus exporter endpoint

What did you see instead?
Metrics from Micrometer are not reported in the Prometheus exporter endpoint

What version are you using?
1.10.1

Environment
Compiler: (e.g., "AdoptOpenJDK 11.0.6")
OS: (e.g., "Ubuntu 20.04")
Runtime (if different from JDK above): (e.g., "Oracle JRE 8u251")
OS (if different from OS compiled on): (e.g., "Windows Server 2019")

Additional context
Add any other context about the problem here.

@irizzant irizzant added the bug Something isn't working label Feb 1, 2022
@mateuszrzeszutek
Copy link
Member

Hey @irizzant ,
We're currently only instrumenting the global micrometer registry (Metrics.globalRegistry). Are you using it within your application? Or are you setting up a custom one?
Also, please take a look at #5200 -- could you check whether the registry you're using contains the OpenTelemetryMeterRegistry?

@irizzant
Copy link
Author

irizzant commented Feb 1, 2022

Thank you very much for the hint @mateuszrzeszutek , I'm indeed using

PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
        prometheusRegistry.config()
                .meterFilter(new PrometheusRenameFilter())
                .pauseDetector(new ClockDriftPauseDetector(Duration.of(100, ChronoUnit.MILLIS), Duration.of(100, ChronoUnit.MILLIS)));

without registering it to the global registry. I'm testing the #5200 version right now...

@irizzant
Copy link
Author

irizzant commented Feb 1, 2022

Ok @mateuszrzeszutek, after testing the solution it looks like:

PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
        prometheusRegistry.config()
                .meterFilter(new PrometheusRenameFilter())
                .pauseDetector(new ClockDriftPauseDetector(Duration.of(100, ChronoUnit.MILLIS), Duration.of(100, ChronoUnit.MILLIS)));
Metrics.globalRegistry.add(prometheusRegistry);

plus registering the custom metrics to the global registry only, allowed me to get the custom metrics from both OTEL Prometheus exporter and the Micrometer endpoint.

Thank you very much for your help

@irizzant irizzant closed this as completed Feb 1, 2022
@irizzant irizzant reopened this Feb 2, 2022
@irizzant
Copy link
Author

irizzant commented Feb 2, 2022

Sorry @mateuszrzeszutek I may have talked too soon.

I found that metrics exposed by OTEL go under different names than the Micrometer ones.

E.g from the Micrometer endpoint I have

edimonitor_job_executiontime_seconds_bucket

which comes from Timer.builder("edimonitor.job.executiontime"), but this metric in OTEL becomes:

edimonitor_job_executiontime_bucket

Also some other metrics are not available at all.

E.g. In Micrometer

edimonitor_job_executiontime_seconds_max

and in OTEL the above is not defined at all.

Is it possible that some metrics coming from Micrometer Timer and LongTaskTimer are named differently or not available at all?

@mateuszrzeszutek
Copy link
Member

Is it possible that some metrics coming from Micrometer Timer and LongTaskTimer are named differently or not available at all?

Yes, that might be the case. Micrometer Timer and LongTaskTimer are translated into OTel DoubleHistogram - OTel metrics API does not have a concept of a timer (yet).

The Micrometer PrometheusMeterRegistry adds the _seconds suffix to the instrument name when it notices it is a timer (link) - the OTel Prometheus exporter just sees a histogram, it does not know wether it's used as a timer or just a plain histogram - so it cannot arbitrarily change names of the exported metric data.

You could probably fix that in your application by registering a custom naming convention that adds _seconds to Timer meters in Metrics.globalRegistry

E.g. In Micrometer

edimonitor_job_executiontime_seconds_max

and in OTEL the above is not defined at all.

I skipped the max measurement when I was working on the micrometer bridge, but now that I think of it the decaying max function used by micrometer does sound useful. Thanks for catching that! I'll fix that and add a max measurement to timers/histograms.

@irizzant
Copy link
Author

irizzant commented Feb 3, 2022

Yes, that might be the case. Micrometer Timer and LongTaskTimer are translated into OTel DoubleHistogram - OTel metrics API does not have a concept of a timer (yet).

Didn't know that, thanks for clarifying @mateuszrzeszutek

You could probably fix that in your application by registering a custom naming convention that adds _seconds to Timer meters in Metrics.globalRegistry

That worked, now I can see OTEL metric

edimonitor_job_executiontime_seconds_bucket

but the problem is now that I get totally different bucket values than Micrometer's!

These are the ones from OTEL:

edimonitor_job_executiontime_seconds_count{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_sum{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN"} 143.410563 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="5.0"} 0.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="10.0"} 0.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="25.0"} 0.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="50.0"} 0.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="75.0"} 0.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="100.0"} 0.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="250.0"} 1.0 1643895869.018 # {span_id="df2ae40ac4b6a168",trace_id="9553152e14cc76816bca4b3598504b69"} 143.410563 1643895839.379
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="500.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="750.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="1000.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="2500.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="5000.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="7500.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="10000.0"} 1.0 1643895869.018
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="+Inf"} 1.0 1643895869.018

and these are the ones from Micrometer:

# HELP edimonitor_job_executiontime_seconds_seconds The execution time for a job
# TYPE edimonitor_job_executiontime_seconds_seconds histogram
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="2400.0",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="2565.527131476",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="2932.031007401",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="3298.534883326",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="3665.038759251",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="4031.542635176",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="4398.046511104",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="5864.062014805",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="7200.0",} 1.0
edimonitor_job_executiontime_seconds_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="+Inf",} 1.0
edimonitor_job_executiontime_seconds_seconds_count{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",} 1.0
edimonitor_job_executiontime_seconds_seconds_sum{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",} 0.143410563

As you can see in OTEL I no longer have only one value returned but I have 2, and the bucket values are different than I had in Micrometer.

I skipped the max measurement when I was working on the micrometer bridge, but now that I think of it the decaying max function used by micrometer does sound useful. Thanks for catching that! I'll fix that and add a max measurement to timers/histograms.

That would be great thanks

@mateuszrzeszutek
Copy link
Member

mateuszrzeszutek commented Feb 3, 2022

Oh, I got one thing wrong in my previous post - the base time unit used in the Micrometer-Otel bridge is milliseconds, not seconds - so your measurements are not actually _seconds. I think that needs to be made configurable, so that you can choose seconds as the base unit - I'll add that too.

but the problem is now that I get totally different bucket values than Micrometer's!

It looks like the default OTel buckets for histograms are overriding the micrometer ones. Can you share a fragment of code that shows how you're registering the timer?
This will be a bit more challenging to fix I guess, but first let's try to figure out what's actually happening here.

@irizzant
Copy link
Author

irizzant commented Feb 3, 2022

It looks like the default OTel buckets for histograms are overriding the micrometer ones. Can you share a fragment of code that shows how you're registering the timer?

Let me try to sum up the steps:

  1. I configure the global registry and Prometheus registry with common tags and the "_seconds" suffix you suggested
        prometheusMeterRegistry.config().commonTags("edimonitorinstance", instance, "application", "edimonitor");

        Metrics.globalRegistry.config()
                .commonTags("edimonitorinstance", instance, "application", "edimonitor")
                .meterFilter(new MeterFilter() {
                    @Override
                    public Id map(Id id) {
                        if (id.getType() == Type.TIMER || id.getType() == Type.LONG_TASK_TIMER) {
                            return id.withName(id.getName() + "_seconds");
                        }
                        return id;
                    }
                });

        PrometheusRegistryProvider.setPrometheusMeterRegistry(prometheusMeterRegistry);
  1. I add the Timer and LongTaskTimer metrics, also configuring the pre-defined buckets:
runningJobExecutionTime = LongTaskTimer.builder("edimonitor.job.running.executiontime")
                    .description("The execution time for a running job")
                    .tags(EDI_MONITOR_JOB, context.getJobDetail().getKey().getName())
                    .publishPercentiles(0.5, 0.99)
                    .register(Metrics.globalRegistry);

            jobExecutionTime = Timer.builder("edimonitor.job.executiontime")
                    .description("The execution time for a job")
                    .tags(EDI_MONITOR_JOB, context.getJobDetail().getKey().getName())
                    .publishPercentileHistogram()
                    .minimumExpectedValue(Duration.of(40, ChronoUnit.MINUTES))
                    .maximumExpectedValue(Duration.of(2, ChronoUnit.HOURS))
                    .register(Metrics.globalRegistry);

Oh, I got one thing wrong in my previous post - the base time unit used in the Micrometer-Otel bridge is milliseconds, not seconds - so your measurements are not actually _seconds. I think that needs to be made configurable, so that you can choose seconds as the base unit - I'll add that too

What I see here is that OTEL is returning 2 values for the same metric:
edimonitor_outmessage_processed_total{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN"} 0.0 1643905334.100

I would have expected a single value 0.0 instead it adds 1643905334.100.
It looks like these double value is added for all the metrics, also for counters.

@mateuszrzeszutek
Copy link
Member

Thanks for the example! I'll try to figure something out for your use case.

I would have expected a single value 0.0 instead it adds 1643905334.100.
It looks like these double value is added for all the metrics, also for counters.

I think that's just the timestamp - Micrometer PrometheusMeterRegistry doesn't set this, the OTel Prometheus exporter does. I wouldn't worry about that one.

@irizzant
Copy link
Author

irizzant commented Feb 3, 2022

I think that's just the timestamp - Micrometer PrometheusMeterRegistry doesn't set this, the OTel Prometheus exporter does. I wouldn't worry about that one.

@mateuszrzeszutek The problem is that with OTEL metrics I cannot render the heatmap in Grafana correctly.
Suppose I run a single job from my application, I get the following in Grafana.
It doesn't make sense though, because I ran a single job and I expect a single bucket to be populated, not multiple.

Here are the values I pull from the bucket:

edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="5.0"} 0.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="10.0"} 0.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="25.0"} 1.0 1643908484.378 # {span_id="78d225a996f5de61",trace_id="19d5b9c6ed34a0e3276d93974e177f5c"} 17.123938 1643908153.355
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="50.0"} 1.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="75.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="100.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="250.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="500.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="750.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="1000.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="2500.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="5000.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="7500.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="10000.0"} 2.0 1643908484.378
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="IVAN",le="+Inf"} 2.0 1643908484.378

And here is the heatmap:
image

@trask
Copy link
Member

trask commented May 3, 2022

@irizzant can you summarize any remaining issue(s) after updating to 1.13.1? thx!

@irizzant
Copy link
Author

irizzant commented May 5, 2022

Hi @trask
I run some other tests with 1.13.1.

The problem I mentioned here seems to be fixed.

For a single job run I now get:

# TYPE edimonitor_job_executiontime_seconds histogram
# HELP edimonitor_job_executiontime_seconds The execution time for a job
edimonitor_job_executiontime_seconds_count{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_sum{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST"} 69.234476 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="5.0"} 0.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="10.0"} 0.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="25.0"} 0.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="50.0"} 0.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="75.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="100.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="250.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="500.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="750.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="1000.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="2500.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="5000.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="7500.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="10000.0"} 1.0 1651755373294
edimonitor_job_executiontime_seconds_bucket{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST",le="+Inf"} 1.0 1651755373294

which looks correct.

I noticed for LongTaskTimer now I get a gauge:

# TYPE edimonitor_job_running_executiontime_seconds_duration gauge
# HELP edimonitor_job_running_executiontime_seconds_duration The execution time for a running job
edimonitor_job_running_executiontime_seconds_duration{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST"} 0.0 1651755373294

can you just confirm if this is expected?

The only issue I still see is that the buckets configured in the application are not taken into consideration by the instrumentation.
In the app I define the following:

jobExecutionTime = Timer.builder("edimonitor.job.executiontime")
                    .description("The execution time for a job")
                    .tags(EDI_MONITOR_JOB, context.getJobDetail().getKey().getName())
                    .publishPercentileHistogram()
                    .minimumExpectedValue(Duration.of(40, ChronoUnit.MINUTES))
                    .maximumExpectedValue(Duration.of(2, ChronoUnit.HOURS))
                    .register(Metrics.globalRegistry);

and the resulting buckets are the ones I have listed above

@trask
Copy link
Member

trask commented Jun 26, 2022

I noticed for LongTaskTimer now I get a gauge ... can you just confirm if this is expected?

based on the tests:

https://github.com/open-telemetry/opentelemetry-java/blob/31be1dcc3fa73d4c11818bdf7c868281b9554dc9/micrometer1-shim/src/test/java/io/opentelemetry/micrometer1shim/LongTaskTimerTest.java#L53-L56

it looks like LongTaskTimer duration should be a DoubleSum instead of a Gauge.

The only issue I still see is that the buckets configured in the application are not taken into consideration by the instrumentation

ya, I don't see any handling of minimumExpectedValue and maximumExpectedValue in https://github.com/open-telemetry/opentelemetry-java/tree/main/micrometer1-shim, so this is what I would expect for now

@mateuszrzeszutek
Copy link
Member

The only issue I still see is that the buckets configured in the application are not taken into consideration by the instrumentation

ya, I don't see any handling of minimumExpectedValue and maximumExpectedValue in https://github.com/open-telemetry/opentelemetry-java/tree/main/micrometer1-shim, so this is what I would expect for now

As it is now, it is impossible to configure histogram buckets through metrics API, this has to be done through SDK views. The metric Hint API would solve that problem, but I don't think that any actual work on its spec has started.

@irizzant
Copy link
Author

it looks like LongTaskTimer duration should be a DoubleSum instead of a Gauge.

ok so that is something to be checked as well.

@trask
Copy link
Member

trask commented Jun 27, 2022

it looks like LongTaskTimer duration should be a DoubleSum instead of a Gauge.

ok so that is something to be checked as well.

where are you seeing that it's a Gauge? thx

@irizzant
Copy link
Author

As I wrote above:

# TYPE edimonitor_job_running_executiontime_seconds_duration gauge
# HELP edimonitor_job_running_executiontime_seconds_duration The execution time for a running job
edimonitor_job_running_executiontime_seconds_duration{application="edimonitor",edimonitorinstance="0",edimonitorjob="TEST"} 0.0 1651755373294

This is the metrics output I get, the comment states it's a Gauge

@trask
Copy link
Member

trask commented Jun 29, 2022

hey @irizzant, I looked into it and I think that this behavior is correct.

LongTaskTimer maps to OpenTelemetry DoubleSum, but OpenTelemetry DoubleSum can be either monotonic or non-monotonic.

Monotonic DoubleSum are mapped to Prometheus counters, while non-monotonic DoubleSum are mapped to Prometheus gauges.

@irizzant
Copy link
Author

Hi @trask thanks for confirming, so this should be the only remaining issue:

As it is now, it is impossible to configure histogram buckets through metrics API, this has to be done through SDK views. The metric Hint API would solve that problem, but I don't think that any actual work on its spec has started.

@patel-prakash
Copy link

patel-prakash commented Apr 27, 2023

Thanks @irizzant. your example resolved my doubts & I can send my custom metrics to open telemetry. I have directly sent my custom metrics to global registry & it showed up in the open telemetry metrics. Example code

Timer.builder("Test Metrics") .tags(Tags.of(Tag.of("Tag -1", "A"), Tag.of("Tag-2", "B"))) .register(Metrics.globalRegistry)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants