io.quarkus.micrometer.runtime.export.exemplars.OpenTelemetryExemplarContextUnwrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-micrometer Show documentation
Show all versions of quarkus-micrometer Show documentation
Instrument the runtime and your application with dimensional metrics using Micrometer.
package io.quarkus.micrometer.runtime.export.exemplars;
import java.util.function.Function;
import jakarta.enterprise.context.Dependent;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.quarkus.opentelemetry.runtime.QuarkusContextStorage;
@Dependent
public class OpenTelemetryExemplarContextUnwrapper implements OpenTelemetryContextUnwrapper {
@Override
public R executeInContext(Function
methodReference, P parameter, io.vertx.core.Context requestContext) {
if (requestContext == null) {
return methodReference.apply(parameter);
}
Context newContext = QuarkusContextStorage.getContext(requestContext);
if (newContext == null) {
return methodReference.apply(parameter);
}
io.opentelemetry.context.Context oldContext = QuarkusContextStorage.INSTANCE.current();
try (Scope scope = QuarkusContextStorage.INSTANCE.attach(newContext)) {
return methodReference.apply(parameter);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy