open-telemetry / open-telemetry/opentelemetry-java-instrumentation

Service name resolution using `spring.application.name` doesn't support multi-document properties

Open
#13,206 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs triage
Dominant language
Java
Stars
2.6k
Forks
1.2k
Avg merge
2d 18h
Merged PRs (30d)
228

Description

Describe the bug

SpringBootServiceNameDetector supports resolving service name from application.properties but is not aware of Spring Boot's support for multi-document properties - see Working With Multi-Document Files section of Spring Boot's reference manual. Multi-document properties allow the same configuration property to be present multiple times inside application.properties and the actual resolved value is dependent on some condition, for example:

spring.main.banner-mode=off
#---
spring.config.activate.on-profile=product1
spring.application.name=product1-backend
#---
spring.config.activate.on-profile=product2
spring.application.name=product2-backend

With such application.properties, SpringBootServiceNameDetector will always resolve service name to product2-backend regardless of the currently active profile.

Relevant documentation does not mention this being a known limitation.

Note that this might also affect application.yaml but I didn't confirm.

Steps to reproduce
  • any Spring Boot application with application.properties set up like above
  • Java agent instrumentation without explicitly provided service name
Expected behavior

Resolved service name would be the one actually in use taking account conditions.

Actual behavior

Resolved service name doesn't take into account conditions and resolves service name from last occurrence of spring.application.name in application.properties.

Javaagent or library instrumentation version

v2.12.0

Environment

n/r

Additional context

n/a

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 at SpringBootServiceNameDetector and reproduce the issue with the multi-document application.properties example using different active profiles. Verify that service-name resolution follows the active profile rather than the last occurrence, and check whether application.yaml is covered if the detector handles it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.