Class SpringBootServiceNameDetector
java.lang.Object
io.opentelemetry.instrumentation.spring.resources.SpringBootServiceNameDetector
- All Implemented Interfaces:
io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider,io.opentelemetry.sdk.autoconfigure.spi.Ordered,io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
@AutoService(io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider.class)
public class SpringBootServiceNameDetector
extends Object
implements io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider
A ResourceProvider that will attempt to guess the application name for a Spring Boot service.
When successful, it will return a Resource that has the service name attribute populated with the
name of the Spring Boot application. It uses the following strategies, and the first successful
strategy wins:
- Check for the SPRING_APPLICATION_NAME environment variable
- Check for spring.application.name system property
- Check for application.properties file on the classpath
- Check for application.properties in the current working dir
- Check for application.yml on the classpath
- Check for application.yml in the current working dir
- Check for --spring.application.name program argument (not jvm arg) via ProcessHandle
- Check for --spring.application.name program argument via sun.java.command system property
Note: The spring starter already includes provider in io.opentelemetry.instrumentation.spring.autoconfigure.resources.SpringResourceProvider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.opentelemetry.sdk.resources.ResourcecreateResource(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties config) intorder()booleanshouldApply(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties config, io.opentelemetry.sdk.resources.Resource resource)
-
Constructor Details
-
SpringBootServiceNameDetector
public SpringBootServiceNameDetector()
-
-
Method Details
-
createResource
public io.opentelemetry.sdk.resources.Resource createResource(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties config) - Specified by:
createResourcein interfaceio.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
-
shouldApply
public boolean shouldApply(io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties config, io.opentelemetry.sdk.resources.Resource resource) - Specified by:
shouldApplyin interfaceio.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider
-
order
public int order()- Specified by:
orderin interfaceio.opentelemetry.sdk.autoconfigure.spi.Ordered
-