|
13 | 13 | import static java.util.logging.Level.SEVERE;
|
14 | 14 | import static net.bytebuddy.matcher.ElementMatchers.any;
|
15 | 15 |
|
16 |
| -import io.opentelemetry.api.GlobalOpenTelemetry; |
17 | 16 | import io.opentelemetry.context.Context;
|
18 | 17 | import io.opentelemetry.context.ContextStorage;
|
19 | 18 | import io.opentelemetry.context.Scope;
|
20 |
| -import io.opentelemetry.extension.noopapi.NoopOpenTelemetry; |
21 | 19 | import io.opentelemetry.instrumentation.api.config.Config;
|
22 | 20 | import io.opentelemetry.instrumentation.api.internal.EmbeddedInstrumentationProperties;
|
23 | 21 | import io.opentelemetry.javaagent.bootstrap.AgentClassLoader;
|
@@ -64,7 +62,6 @@ public class AgentInstaller {
|
64 | 62 | private static final Logger logger = Logger.getLogger(AgentInstaller.class.getName());
|
65 | 63 |
|
66 | 64 | static final String JAVAAGENT_ENABLED_CONFIG = "otel.javaagent.enabled";
|
67 |
| - static final String JAVAAGENT_NOOP_CONFIG = "otel.javaagent.experimental.use-noop-api"; |
68 | 65 |
|
69 | 66 | // This property may be set to force synchronous AgentListener#afterAgent() execution: the
|
70 | 67 | // condition for delaying the AgentListener initialization is pretty broad and in case it covers
|
@@ -110,23 +107,14 @@ private static void installBytebuddyAgent(
|
110 | 107 |
|
111 | 108 | // If noop OpenTelemetry is enabled, autoConfiguredSdk will be null and AgentListeners are not
|
112 | 109 | // called
|
113 |
| - AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = null; |
114 |
| - if (config.getBoolean(JAVAAGENT_NOOP_CONFIG, false)) { |
115 |
| - logger.info("Tracing and metrics are disabled because noop is enabled."); |
116 |
| - GlobalOpenTelemetry.set(NoopOpenTelemetry.getInstance()); |
117 |
| - } else { |
118 |
| - autoConfiguredSdk = installOpenTelemetrySdk(config); |
119 |
| - } |
| 110 | + AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = installOpenTelemetrySdk(config); |
120 | 111 |
|
121 |
| - ConfigProperties sdkConfig = EmptyConfigProperties.INSTANCE; |
122 |
| - if (autoConfiguredSdk != null) { |
123 |
| - sdkConfig = autoConfiguredSdk.getConfig(); |
124 |
| - InstrumentationConfig.internalInitializeConfig(new ConfigPropertiesBridge(sdkConfig)); |
125 |
| - copyNecessaryConfigToSystemProperties(sdkConfig); |
| 112 | + ConfigProperties sdkConfig = autoConfiguredSdk.getConfig(); |
| 113 | + InstrumentationConfig.internalInitializeConfig(new ConfigPropertiesBridge(sdkConfig)); |
| 114 | + copyNecessaryConfigToSystemProperties(sdkConfig); |
126 | 115 |
|
127 |
| - for (BeforeAgentListener agentListener : loadOrdered(BeforeAgentListener.class)) { |
128 |
| - agentListener.beforeAgent(autoConfiguredSdk); |
129 |
| - } |
| 116 | + for (BeforeAgentListener agentListener : loadOrdered(BeforeAgentListener.class)) { |
| 117 | + agentListener.beforeAgent(autoConfiguredSdk); |
130 | 118 | }
|
131 | 119 |
|
132 | 120 | AgentBuilder agentBuilder =
|
@@ -180,9 +168,7 @@ private static void installBytebuddyAgent(
|
180 | 168 | ResettableClassFileTransformer resettableClassFileTransformer = agentBuilder.installOn(inst);
|
181 | 169 | ClassFileTransformerHolder.setClassFileTransformer(resettableClassFileTransformer);
|
182 | 170 |
|
183 |
| - if (autoConfiguredSdk != null) { |
184 |
| - runAfterAgentListeners(agentListeners, autoConfiguredSdk); |
185 |
| - } |
| 171 | + runAfterAgentListeners(agentListeners, autoConfiguredSdk); |
186 | 172 | }
|
187 | 173 |
|
188 | 174 | private static void copyNecessaryConfigToSystemProperties(ConfigProperties config) {
|
|
0 commit comments