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 to true when the SDK is enabled)
  • quarkus.otel.metrics.enabled — metrics (defaults to false)
  • quarkus.otel.logs.enabled — logging (defaults to false)
Each signal is only active when both its own flag and the top-level 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 Details

    • OpenTelemetrySdkBuildItem

      public OpenTelemetrySdkBuildItem(boolean tracingBuildTimeEnabled, boolean metricsBuildTimeEnabled, boolean loggingBuildTimeEnabled, io.quarkus.runtime.RuntimeValue<Boolean> runtimeEnabled)
  • Method Details

    • isTracingBuildTimeEnabled

      public boolean isTracingBuildTimeEnabled()
      Returns:
      true if OpenTelemetry Tracing is enabled at build time
    • isMetricsBuildTimeEnabled

      public boolean isMetricsBuildTimeEnabled()
      Returns:
      true if OpenTelemetry Metrics is enabled at build time
    • isLoggingBuildTimeEnabled

      public boolean isLoggingBuildTimeEnabled()
      Returns:
      true if OpenTelemetry Logging is enabled at build time
    • isRuntimeEnabled

      public io.quarkus.runtime.RuntimeValue<Boolean> 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)