From fd34e4413a348826590de055c4792930e36fd292 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 15 Apr 2024 11:44:02 +0300 Subject: [PATCH 1/2] Introduce markers for static and runtime init recorder methods These are meant to replace the comments found in various recorder methods --- .../quarkus/runtime/annotations/RuntimeInit.java | 14 ++++++++++++++ .../io/quarkus/runtime/annotations/StaticInit.java | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 core/runtime/src/main/java/io/quarkus/runtime/annotations/RuntimeInit.java create mode 100644 core/runtime/src/main/java/io/quarkus/runtime/annotations/StaticInit.java diff --git a/core/runtime/src/main/java/io/quarkus/runtime/annotations/RuntimeInit.java b/core/runtime/src/main/java/io/quarkus/runtime/annotations/RuntimeInit.java new file mode 100644 index 0000000000000..9f57f399efdc6 --- /dev/null +++ b/core/runtime/src/main/java/io/quarkus/runtime/annotations/RuntimeInit.java @@ -0,0 +1,14 @@ +package io.quarkus.runtime.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marker annotation used to indicate that a recorder method is called during the runtime init phase + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.METHOD) +public @interface RuntimeInit { +} diff --git a/core/runtime/src/main/java/io/quarkus/runtime/annotations/StaticInit.java b/core/runtime/src/main/java/io/quarkus/runtime/annotations/StaticInit.java new file mode 100644 index 0000000000000..90a3793ec2963 --- /dev/null +++ b/core/runtime/src/main/java/io/quarkus/runtime/annotations/StaticInit.java @@ -0,0 +1,14 @@ +package io.quarkus.runtime.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marker annotation used to indicate that a recorder method is called during the static init phase + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.METHOD) +public @interface StaticInit { +} From 43e92f32c35c045eec94661d2fa923de1edb8926 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 15 Apr 2024 11:48:04 +0300 Subject: [PATCH 2/2] Replace comments about recorder method execution with markers --- .../opentelemetry/runtime/OpenTelemetryRecorder.java | 10 ++++++---- .../opentelemetry/runtime/tracing/TracerRecorder.java | 5 +++-- .../intrumentation/InstrumentationRecorder.java | 4 +++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java index 6598d2a15f0ac..0967428012cb2 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/OpenTelemetryRecorder.java @@ -20,6 +20,8 @@ import io.quarkus.arc.SyntheticCreationalContext; import io.quarkus.opentelemetry.runtime.config.runtime.OTelRuntimeConfig; import io.quarkus.runtime.annotations.Recorder; +import io.quarkus.runtime.annotations.RuntimeInit; +import io.quarkus.runtime.annotations.StaticInit; import io.quarkus.runtime.configuration.DurationConverter; import io.smallrye.config.ConfigValue; import io.smallrye.config.SmallRyeConfig; @@ -30,23 +32,23 @@ public class OpenTelemetryRecorder { public static final String OPEN_TELEMETRY_DRIVER = "io.opentelemetry.instrumentation.jdbc.OpenTelemetryDriver"; - /* STATIC INIT */ + @StaticInit public void resetGlobalOpenTelemetryForDevMode() { GlobalOpenTelemetry.resetForTest(); GlobalEventEmitterProvider.resetForTest(); } - /* RUNTIME INIT */ + @RuntimeInit public void eagerlyCreateContextStorage() { ContextStorage.get(); } - /* RUNTIME INIT */ + @RuntimeInit public void storeVertxOnContextStorage(Supplier vertx) { QuarkusContextStorage.vertx = vertx.get(); } - /* RUNTIME INIT */ + @RuntimeInit public Function, OpenTelemetry> opentelemetryBean( OTelRuntimeConfig oTelRuntimeConfig) { return new Function<>() { diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java index a0d5486ba0a3d..393aa22568fb1 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/TracerRecorder.java @@ -9,6 +9,7 @@ import io.opentelemetry.semconv.ResourceAttributes; import io.quarkus.arc.runtime.BeanContainer; import io.quarkus.runtime.annotations.Recorder; +import io.quarkus.runtime.annotations.StaticInit; @Recorder public class TracerRecorder { @@ -16,7 +17,7 @@ public class TracerRecorder { public static final Set dropNonApplicationUriTargets = new HashSet<>(); public static final Set dropStaticResourceTargets = new HashSet<>(); - /* STATIC INIT */ + @StaticInit public void setAttributes( BeanContainer beanContainer, String quarkusVersion, @@ -35,7 +36,7 @@ public void setAttributes( .getAttributes()); } - /* STATIC INIT */ + @StaticInit public void setupSampler( List dropNonApplicationUris, List dropStaticResources) { diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java index debb921c7350b..11873ab929225 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/InstrumentationRecorder.java @@ -19,6 +19,7 @@ import io.quarkus.opentelemetry.runtime.tracing.intrumentation.vertx.SqlClientInstrumenterVertxTracer; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.Recorder; +import io.quarkus.runtime.annotations.RuntimeInit; import io.vertx.core.VertxOptions; import io.vertx.core.metrics.MetricsOptions; import io.vertx.core.tracing.TracingOptions; @@ -34,7 +35,7 @@ public InstrumentationRecorder(RuntimeValue config) { this.config = config; } - /* RUNTIME INIT */ + @RuntimeInit public Consumer getVertxTracingOptions() { TracingOptions tracingOptions = new TracingOptions() .setFactory(FACTORY); @@ -42,6 +43,7 @@ public Consumer getVertxTracingOptions() { } /* RUNTIME INIT */ + @RuntimeInit public void setupVertxTracer(BeanContainer beanContainer, boolean sqlClientAvailable, boolean redisClientAvailable, final String semconvStability) { OpenTelemetry openTelemetry = beanContainer.beanInstance(OpenTelemetry.class);