-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix vertx otel sdk reload in devmode
- Loading branch information
Showing
15 changed files
with
328 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...io/quarkus/opentelemetry/deployment/tracing/instrumentation/InstrumentationProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package io.quarkus.opentelemetry.deployment.tracing.instrumentation; | ||
|
||
import static io.quarkus.bootstrap.classloading.QuarkusClassLoader.isClassPresentAtRuntime; | ||
import static javax.interceptor.Interceptor.Priority.LIBRARY_AFTER; | ||
|
||
import java.util.Optional; | ||
import java.util.function.BooleanSupplier; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
|
||
import io.quarkus.arc.deployment.AdditionalBeanBuildItem; | ||
import io.quarkus.deployment.Capabilities; | ||
import io.quarkus.deployment.Capability; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.BuildSteps; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.deployment.builditem.AdditionalIndexedClassesBuildItem; | ||
import io.quarkus.deployment.builditem.LaunchModeBuildItem; | ||
import io.quarkus.opentelemetry.deployment.tracing.TracerEnabled; | ||
import io.quarkus.opentelemetry.runtime.tracing.intrumentation.InstrumentationRecorder; | ||
import io.quarkus.opentelemetry.runtime.tracing.intrumentation.grpc.GrpcTracingClientInterceptor; | ||
import io.quarkus.opentelemetry.runtime.tracing.intrumentation.grpc.GrpcTracingServerInterceptor; | ||
import io.quarkus.opentelemetry.runtime.tracing.intrumentation.reactivemessaging.ReactiveMessagingTracingDecorator; | ||
import io.quarkus.opentelemetry.runtime.tracing.intrumentation.restclient.OpenTelemetryClientFilter; | ||
import io.quarkus.runtime.LaunchMode; | ||
import io.quarkus.vertx.core.deployment.VertxOptionsConsumerBuildItem; | ||
|
||
@BuildSteps(onlyIf = TracerEnabled.class) | ||
public class InstrumentationProcessor { | ||
static class MetricsExtensionAvailable implements BooleanSupplier { | ||
private static final boolean IS_MICROMETER_EXTENSION_AVAILABLE = isClassPresentAtRuntime( | ||
"io.quarkus.micrometer.runtime.binder.vertx.VertxHttpServerMetrics"); | ||
|
||
@Override | ||
public boolean getAsBoolean() { | ||
Config config = ConfigProvider.getConfig(); | ||
if (IS_MICROMETER_EXTENSION_AVAILABLE) { | ||
if (config.getOptionalValue("quarkus.micrometer.enabled", Boolean.class).orElse(true)) { | ||
Optional<Boolean> httpServerEnabled = config | ||
.getOptionalValue("quarkus.micrometer.binder.http-server.enabled", Boolean.class); | ||
if (httpServerEnabled.isPresent()) { | ||
return httpServerEnabled.get(); | ||
} else { | ||
return config.getOptionalValue("quarkus.micrometer.binder-enabled-default", Boolean.class).orElse(true); | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
static class GrpcExtensionAvailable implements BooleanSupplier { | ||
private static final boolean IS_GRPC_EXTENSION_AVAILABLE = isClassPresentAtRuntime( | ||
"io.quarkus.grpc.runtime.GrpcServerRecorder"); | ||
|
||
@Override | ||
public boolean getAsBoolean() { | ||
return IS_GRPC_EXTENSION_AVAILABLE; | ||
} | ||
} | ||
|
||
@BuildStep(onlyIf = GrpcExtensionAvailable.class) | ||
void grpcTracers(BuildProducer<AdditionalBeanBuildItem> additionalBeans) { | ||
additionalBeans.produce(new AdditionalBeanBuildItem(GrpcTracingServerInterceptor.class)); | ||
additionalBeans.produce(new AdditionalBeanBuildItem(GrpcTracingClientInterceptor.class)); | ||
} | ||
|
||
@BuildStep | ||
void registerRestClientClassicProvider( | ||
Capabilities capabilities, | ||
BuildProducer<AdditionalIndexedClassesBuildItem> additionalIndexed, | ||
BuildProducer<AdditionalBeanBuildItem> additionalBeans) { | ||
if (capabilities.isPresent(Capability.REST_CLIENT) && capabilities.isMissing(Capability.REST_CLIENT_REACTIVE)) { | ||
additionalIndexed.produce(new AdditionalIndexedClassesBuildItem(OpenTelemetryClientFilter.class.getName())); | ||
additionalBeans.produce(new AdditionalBeanBuildItem(OpenTelemetryClientFilter.class)); | ||
} | ||
} | ||
|
||
@BuildStep | ||
void registerReactiveMessagingMessageDecorator( | ||
Capabilities capabilities, | ||
BuildProducer<AdditionalBeanBuildItem> additionalBeans) { | ||
if (capabilities.isPresent(Capability.SMALLRYE_REACTIVE_MESSAGING)) { | ||
additionalBeans.produce(new AdditionalBeanBuildItem(ReactiveMessagingTracingDecorator.class)); | ||
} | ||
} | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.STATIC_INIT) | ||
VertxOtelBuildItem httpVertxOtelItem(InstrumentationRecorder recorder, | ||
LaunchModeBuildItem launchMode) { | ||
if (launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT || launchMode.getLaunchMode() == LaunchMode.TEST) { | ||
return new VertxOtelBuildItem(recorder.createDevModeInstrumenterVertxTracers()); | ||
} | ||
return new VertxOtelBuildItem(recorder.createRuntimeInstrumenterVertxTracers()); | ||
} | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
VertxOptionsConsumerBuildItem vertxTracingOptions(InstrumentationRecorder recorder, | ||
VertxOtelBuildItem httpVertxOtelItem) { | ||
return new VertxOptionsConsumerBuildItem( | ||
recorder.getVertxTracingOptions(httpVertxOtelItem.getInstrumenterVertxTracers()), | ||
LIBRARY_AFTER); | ||
} | ||
|
||
@BuildStep(onlyIfNot = MetricsExtensionAvailable.class) | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
VertxOptionsConsumerBuildItem vertxTracingMetricsOptions(InstrumentationRecorder recorder) { | ||
return new VertxOptionsConsumerBuildItem(recorder.getVertxTracingMetricsOptions(), LIBRARY_AFTER + 1); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/io/quarkus/opentelemetry/deployment/tracing/instrumentation/VertxOtelBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.quarkus.opentelemetry.deployment.tracing.instrumentation; | ||
|
||
import java.util.List; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
import io.quarkus.opentelemetry.runtime.tracing.intrumentation.vertx.InstrumenterVertxTracer; | ||
import io.quarkus.runtime.RuntimeValue; | ||
|
||
public final class VertxOtelBuildItem extends SimpleBuildItem { | ||
private RuntimeValue<List<InstrumenterVertxTracer<?, ?>>> instrumenterVertxTracers; | ||
|
||
public VertxOtelBuildItem(RuntimeValue<List<InstrumenterVertxTracer<?, ?>>> instrumenterVertxTracers) { | ||
this.instrumenterVertxTracers = instrumenterVertxTracers; | ||
} | ||
|
||
public RuntimeValue<List<InstrumenterVertxTracer<?, ?>>> getInstrumenterVertxTracers() { | ||
return instrumenterVertxTracers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.