open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Service name resolution using `spring.application.name` doesn't support multi-document properties
Nobody has claimed this yet.
- 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.propertiesset 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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