question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better support for metrics in multi-services environments

See original GitHub issue

Is your feature request related to a problem?

Described in https://github.com/elastic/apm/issues/65 - when service_name is not configured, the agent automatically discover service names. In servlet containers, this may result with multiple service names - one per webapp. However, metrics are still only visible in the context of the default servlet container service name (which is some generic name, depending on the traced framework).

Describe the solution you’d like

As described in the concluding comment of https://github.com/elastic/apm/issues/65, we are going to solve this by sending each metricset with all relevant service names.

With @tobiasstadler’s latest contributions to APM Server and the Java agent, we have everything in place to resolve this issue in this manner.

Some low-level guidelines:

  • The metrics should not be sent to the default generic JVM service name anymore when there’s at least one service name override for a specific class loader (co.elastic.apm.agent.impl.ElasticApmTracer#serviceNameByClassLoader)
  • This is all true for inherent agent metrics (JVM metrics and JMX). The way to decide which service names are relevant is to look into the class-loader–>service-name registry.
  • For Micrometer metrics, handling should be a bit different (and better be handled in a separate PR):
    1. query the class-loader–>service-name map with the Micrometer classes class loader and if a service.name is found - use it
    2. query the class-loader–>service-name map with the context class loader of the thread doing the metric registration/update and if a service.name is found - use it
    3. If a mapped service.name was not found based on class loader lookup - send metrics to all service names in the map

Describe alternatives you’ve considered

The major alternative discussed is to send each metricset once with an array of all related service names. If the current approach turns out problematic, we can try this one instead.

Tasks

  • elastic/apm-agent-java#2233
  • elastic/apm-agent-java#1726

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
felixbarnycommented, Nov 29, 2021

should we send the service.version as well within metricsets in order to consider this done?

Yes, I think so. #2233 is already a good step towards resolving this issue but I think it’s only really complete with #1726.

1reaction
tobiasstadlercommented, Nov 24, 2021

@eyalkoren Right now there is only one service.version per JVM, but I implemented sending the service.version in #1726 (when there can actually be more than one).

But you are right that right now the service.version will get lost if more than one service.name is “discovered”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple service names per process and process-global metrics
When implementing support for multiple service_names (elastic/apm-server#1175) ... Better support for metrics in multi-services environments ...
Read more >
Improving Service Desk Metrics Helps IT Better Align With ...
This data-backed blueprint will help organizations improve the metrics their service desk is measured by to align IT with strategic business ...
Read more >
Create a Cognitive Services resource in the Azure portal
Multi-service resource: Access multiple Azure Cognitive Services with a single key and endpoint. Consolidates billing from the services you use.
Read more >
A Service Mesh for Kubernetes, Part I: Top-line service metrics
The services must mesh ; Baseline resilience: retry budgets, deadlines, circuit-breaking. ; Top-line service metrics: success rates, request ...
Read more >
Developing Performance Metrics in a Service Organization
Developing Performance Metrics in a Service Organization Managers in service companies often find that one of the biggest challenges they face is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found