Package io.quarkus.deployment.builditem
Class OpenTelemetrySdkBuildItem
java.lang.Object
io.quarkus.builder.item.BuildItem
io.quarkus.builder.item.SimpleBuildItem
io.quarkus.deployment.builditem.OpenTelemetrySdkBuildItem
public final class OpenTelemetrySdkBuildItem
extends io.quarkus.builder.item.SimpleBuildItem
Indicates that the OpenTelemetry SDK is present and carries the build-time enabled state
for each telemetry signal (tracing, metrics, logging) and a check if the OTel SDK is enabled at runtime.
This can be used to decide if OTel instrumentation needs to be instantiated, or activated.
Produced by the OpenTelemetry extension's deployment module. Other extensions should consume
it as an Optional so they still work when the OpenTelemetry extension is not on the
classpath.
The build-time flags reflect the following configuration properties:
quarkus.otel.traces.enabled— tracing (defaults totruewhen the SDK is enabled)quarkus.otel.metrics.enabled— metrics (defaults tofalse)quarkus.otel.logs.enabled— logging (defaults tofalse)
quarkus.otel.enabled flag are true.
Usage example
@BuildStep
void configureTracing(Optional<OpenTelemetrySdkBuildItem> otelSdk, ...) {
if (otelSdk.isPresent() && otelSdk.get().isTracingBuildTimeEnabled()) {
// register tracing integration
}
}
The convenience method isOtelSdkEnabled(Optional) extracts the runtime-enabled
RuntimeValue when the build item is present:
Optional<RuntimeValue<Boolean>> runtimeEnabled = OpenTelemetrySdkBuildItem.isOtelSdkEnabled(otelSdk);
-
Constructor Summary
ConstructorsConstructorDescriptionOpenTelemetrySdkBuildItem(boolean tracingBuildTimeEnabled, boolean metricsBuildTimeEnabled, boolean loggingBuildTimeEnabled, io.quarkus.runtime.RuntimeValue<Boolean> runtimeEnabled) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanisOtelSdkEnabled(Optional<OpenTelemetrySdkBuildItem> buildItem) io.quarkus.runtime.RuntimeValue<Boolean> True if the OpenTelemetry SDK is enabled at build and runtime.boolean
-
Constructor Details
-
OpenTelemetrySdkBuildItem
public OpenTelemetrySdkBuildItem(boolean tracingBuildTimeEnabled, boolean metricsBuildTimeEnabled, boolean loggingBuildTimeEnabled, io.quarkus.runtime.RuntimeValue<Boolean> runtimeEnabled)
-
-
Method Details
-
isTracingBuildTimeEnabled
public boolean isTracingBuildTimeEnabled()- Returns:
trueif OpenTelemetry Tracing is enabled at build time
-
isMetricsBuildTimeEnabled
public boolean isMetricsBuildTimeEnabled()- Returns:
trueif OpenTelemetry Metrics is enabled at build time
-
isLoggingBuildTimeEnabled
public boolean isLoggingBuildTimeEnabled()- Returns:
trueif OpenTelemetry Logging is enabled at build time
-
isRuntimeEnabled
True if the OpenTelemetry SDK is enabled at build and runtime. -
isOtelSdkEnabled
public static Optional<io.quarkus.runtime.RuntimeValue<Boolean>> isOtelSdkEnabled(Optional<OpenTelemetrySdkBuildItem> buildItem)
-