prometheus / prometheus/client_java

Issue when using @Timed annotation with prometheus-metrics-instrumentation-dropwizard

Open
#1,321 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.3k
Forks
833
Avg merge
2d 16h
Merged PRs (30d)
86

Description

@Timed annotation, which can be annotated on the methods generates dropwizard metrics with .total as a suffix.

This is not compatible with prometheus-metrics-instrumentation-dropwizard to export dropwizard metrics.

Since the io.prometheus.metrics.instrumentation.dropwizard.DropwizardExports class has a method fromSnapshotAndCount which sanitizes the metric name withPrometheusNaming.sanitizeMetricName(dropwizardName).

As a result it causes duplicate metric name exception when prometheus endpoint is invoked.

Original reference here:
https://github.com/dropwizard/dropwizard/issues/10030 #

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with io.prometheus.metrics.instrumentation.dropwizard.DropwizardExports, especially fromSnapshotAndCount and its call to sanitizeMetricName. Reproduce the duplicate metric name exception by exporting metrics from a method annotated with @Timed and invoking the Prometheus endpoint. Done means Dropwizard metrics with the .total suffix export without duplicate-name errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, prometheus
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.