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

PrometheusReporter set incorrect tags #118

Open
ayanyuk-syberry opened this issue Mar 9, 2023 · 1 comment
Open

PrometheusReporter set incorrect tags #118

ayanyuk-syberry opened this issue Mar 9, 2023 · 1 comment

Comments

@ayanyuk-syberry
Copy link

PrometheusReporter set incorrect tags when tags map returns keyset and values not in same order as it stored in map
e.g.

    CollectorRegistry registry = CollectorRegistry.defaultRegistry;
    HTTPServer httpServer = new HTTPServer(new InetSocketAddress(9098), registry);
    PrometheusReporter reporter = PrometheusReporter.builder().registry(registry).build();

    Map<String, String> tags = new HashMap<>();
    tags.put("WorkflowType", "WorkflowType");
    tags.put("Domain", "Domain");
    tags.put("TaskList", "TaskList");
    Scope scope = new RootScopeBuilder().reporter(reporter)
        .reportEvery(Duration.ofSeconds(1));

    Counter counter = scope.tagged(tags).counter("counter");
    while (true) {
      counter.inc(1);
      Thread.sleep(500);
    }

if check metrics on localhost:9098 it looks like this

HELP test_metric test_metric summary
TYPE test_metric summary
HELP counter_total counter counter
TYPE counter_total counter
counter_total{WorkflowType="Domain",TaskList="WorkflowType",Domain="TaskList",} 50.0
HELP counter_created counter counter
TYPE counter_created gauge
counter_created{WorkflowType="Domain",TaskList="WorkflowType",Domain="TaskList",} 1.678364275361E9

tags for counter are incorrect. It looks like the problem is here

.labelNames(collectionToStringArray(finalTags.keySet()))

scope.tagged() put tags in immutableMap and immutable map returns keyset in order ("WorkflowType", "TaskList", "Domain")
but values() order is ["Domain","WorkflowType","TaskList"]

Could you please have a look? Thanks in advance.

versions:
com.uber.m3:tally-core:0.13.0
com.uber.m3:tally-prometheus:0.13.0
io.prometheus:simpleclient:0.16.0
io.prometheus:simpleclient_httpserver:0.16.0

@ayanyuk-syberry
Copy link
Author

@SokolAndrey @justinjc could you please check this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant