Skip to content

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

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

Open
vpavic opened this issue Feb 4, 2025 · 1 comment
Labels
bug Something isn't working needs triage New issue that requires triage

Comments

@vpavic
Copy link

vpavic commented Feb 4, 2025

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

@vpavic vpavic added bug Something isn't working needs triage New issue that requires triage labels Feb 4, 2025
@laurit
Copy link
Contributor

laurit commented Feb 5, 2025

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

Agent needs to figure out the application name before any of the spring code is run so getting the application name from the spring properties/yaml is best effort. We can not fully replicate how spring does this. In contrast this should work with the spring starter as the starter can ask from spring for the value of spring.application.name.
I think the best option for this issue would be to update the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

2 participants