@CompileStatic class OpenTelemetryConfigOnApplicationEnvironmentPreparedListener extends Object implements ApplicationListener<ApplicationEnvironmentPreparedEvent>
OpenTelemetry configurer triggered before application context is created (on ApplicationEnvironmentPreparedEvent
).
Current implementation uses otel.java.disabled.resource.providers
system property to disable io.opentelemetry.instrumentation.resources.ProcessResourceProvider
. It only
does that when properties management.tracing.enabled
and grafana.otlp.enabled
are either not set (implicitly assumed) or explicitly set to true
.
Problem with ProcessResourceProvider
is that it generates to much information sent with each metric, log and trace. In some cases that can cause failure while sending observability
data to the OTEL backend (Grafana for our case). More specifically, ProcessResourceProvider
collects and sends the application classpath (beside other things). As the classpath tends
to be quite large, we can end up with failures.
Some related resources:
Implementation note: As this class manipulates system properties, it uses ApplicationEnvironmentPreparedEvent
that is published before application context is created. For this reason
class is not marked as Spring component, but rather is configured as a listener in the application itself (see the source of BookingQuerySideViewApplication
). Alternatively, we could
do the same thing via META-INF/spring.factories
file, but we chose explicit listener configuration at the application since we believe it is more obvious.
Constructor and description |
---|
OpenTelemetryConfigOnApplicationEnvironmentPreparedListener() |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
onApplicationEvent(ApplicationEnvironmentPreparedEvent event) |