quarkusio/quarkus · error · IllegalStateException

OpenTelemetry instance not found

Error message

OpenTelemetry instance not found

What it means

The Micrometer-OpenTelemetry bridge creates the MeterRegistry from an OpenTelemetry instance obtained via injected reference. If no OpenTelemetry bean is available in the container (unsatisfied dependency), the bridge cannot function and throws IllegalStateException. This indicates the OTel extension/bean is missing at runtime.

Source

Thrown at extensions/micrometer-opentelemetry/runtime/src/main/java/io/quarkus/micrometer/opentelemetry/runtime/MicrometerOtelBridgeRecorder.java:28

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Metrics;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.micrometer.v1_5.OpenTelemetryMeterRegistry;
import io.quarkus.arc.SyntheticCreationalContext;
import io.quarkus.runtime.annotations.Recorder;

@Recorder
public class MicrometerOtelBridgeRecorder {

    public Function<SyntheticCreationalContext<MeterRegistry>, MeterRegistry> createBridge() {
        return new Function<>() {
            @Override
            public MeterRegistry apply(SyntheticCreationalContext<MeterRegistry> context) {
                Instance<OpenTelemetry> openTelemetry = context.getInjectedReference(new TypeLiteral<>() {
                });

                if (openTelemetry.isUnsatisfied()) {
                    throw new IllegalStateException("OpenTelemetry instance not found");
                }

                MeterRegistry meterRegistry = OpenTelemetryMeterRegistry.builder(openTelemetry.get())
                        .setPrometheusMode(false)
                        .setMicrometerHistogramGaugesEnabled(true)
                        // The time unit should be seconds according to the OpenTelemetry documentation
                        .setBaseTimeUnit(TimeUnit.SECONDS)
                        .setClock(Clock.SYSTEM)
                        .build();
                Metrics.addRegistry(meterRegistry);
                return meterRegistry;
            }
        };
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add the quarkus-opentelemetry extension (io.quarkus:quarkus-opentelemetry) to the application
  2. Verify the OTel SDK is active — check quarkus.otel.* configuration so the OpenTelemetry bean is produced
  3. Check the build for exclusions/conditions that suppress the OpenTelemetry bean production
  4. If bridging is optional, remove quarkus-micrometer-opentelemetry so Micrometer uses default registries

Example fix

// before (pom.xml): only micrometer-opentelemetry
<dependency><groupId>io.quarkus</groupId><artifactId>quarkus-micrometer-opentelemetry</artifactId></dependency>
// after: also add the OTel extension
<dependency><groupId>io.quarkus</groupId><artifactId>quarkus-opentelemetry</artifactId></dependency>
Defensive patterns

Strategy: try-catch

Validate before calling

// in a synthetic bean / extension check
boolean otelPresent = Arc.container() != null
    && Arc.container().instance(OpenTelemetry.class).isAvailable();
if (!otelPresent) { throw new IllegalStateException("Add io.quarkus:quarkus-opentelemetry"); }

Type guard

null

Try / catch

try {
    MeterRegistry registry = recorder.apply(context);
} catch (IllegalStateException e) {
    throw new IllegalStateException("Micrometer-OTel bridge requires an OpenTelemetry bean; add the quarkus-opentelemetry extension", e);
}

Prevention

When it happens

Trigger: quarkus-micrometer-opentelemetry is on the classpath and a MeterRegistry is created, but no OpenTelemetry bean exists — e.g. the quarkus-opentelemetry extension is absent or its runtime bean was not produced.

Common situations: Adding the micrometer-opentelemetry dependency without adding quarkus-opentelemetry; disabling the OTel extension via build properties; custom builds where the OpenTelemetry producer was removed or made conditional.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/b6ff4fb74d524e0b. Report an issue: GitHub.