Browse Source

JaxWS: replace common singleton with factory (#5960)

* JaxWS: replace common singleton with factory

* address review comments
Lauri Tulmin 2 years ago
parent
commit
dc829b59d3

+ 22 - 0
instrumentation/jaxws/jaxws-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/JaxWsSingletons.java

@@ -0,0 +1,22 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.jaxws.v2_0;
+
+import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
+import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsInstrumenterFactory;
+import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsRequest;
+
+public final class JaxWsSingletons {
+
+  private static final Instrumenter<JaxWsRequest, Void> INSTANCE =
+      JaxWsInstrumenterFactory.createInstrumenter("io.opentelemetry.jaxws-2.0");
+
+  public static Instrumenter<JaxWsRequest, Void> instrumenter() {
+    return INSTANCE;
+  }
+
+  private JaxWsSingletons() {}
+}

+ 1 - 1
instrumentation/jaxws/jaxws-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/WebServiceProviderInstrumentation.java

@@ -8,7 +8,7 @@ package io.opentelemetry.javaagent.instrumentation.jaxws.v2_0;
 import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
 import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
 import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
-import static io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsSingletons.instrumenter;
+import static io.opentelemetry.javaagent.instrumentation.jaxws.v2_0.JaxWsSingletons.instrumenter;
 import static net.bytebuddy.matcher.ElementMatchers.isMethod;
 import static net.bytebuddy.matcher.ElementMatchers.isPublic;
 import static net.bytebuddy.matcher.ElementMatchers.named;

+ 22 - 0
instrumentation/jaxws/jaxws-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/v2_0/WebServiceProviderSingletons.java

@@ -0,0 +1,22 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.jaxws.v2_0;
+
+import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
+import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsInstrumenterFactory;
+import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsRequest;
+
+public final class WebServiceProviderSingletons {
+
+  private static final Instrumenter<JaxWsRequest, Void> INSTANCE =
+      JaxWsInstrumenterFactory.createInstrumenter("io.opentelemetry.jaxws-2.0");
+
+  public static Instrumenter<JaxWsRequest, Void> instrumenter() {
+    return INSTANCE;
+  }
+
+  private WebServiceProviderSingletons() {}
+}

+ 29 - 0
instrumentation/jaxws/jaxws-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/common/JaxWsInstrumenterFactory.java

@@ -0,0 +1,29 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.jaxws.common;
+
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import io.opentelemetry.instrumentation.api.config.ExperimentalConfig;
+import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
+import io.opentelemetry.instrumentation.api.instrumenter.code.CodeAttributesExtractor;
+import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
+
+public final class JaxWsInstrumenterFactory {
+
+  public static Instrumenter<JaxWsRequest, Void> createInstrumenter(String instrumentationName) {
+    JaxWsCodeAttributesGetter codeAttributesGetter = new JaxWsCodeAttributesGetter();
+
+    return Instrumenter.<JaxWsRequest, Void>builder(
+            GlobalOpenTelemetry.get(),
+            instrumentationName,
+            CodeSpanNameExtractor.create(codeAttributesGetter))
+        .addAttributesExtractor(CodeAttributesExtractor.create(codeAttributesGetter))
+        .setEnabled(ExperimentalConfig.get().controllerTelemetryEnabled())
+        .newInstrumenter();
+  }
+
+  private JaxWsInstrumenterFactory() {}
+}

+ 0 - 37
instrumentation/jaxws/jaxws-common/library/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/common/JaxWsSingletons.java

@@ -1,37 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.instrumentation.jaxws.common;
-
-import io.opentelemetry.api.GlobalOpenTelemetry;
-import io.opentelemetry.instrumentation.api.config.ExperimentalConfig;
-import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
-import io.opentelemetry.instrumentation.api.instrumenter.code.CodeAttributesExtractor;
-import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
-
-public class JaxWsSingletons {
-  private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jaxws-common";
-
-  private static final Instrumenter<JaxWsRequest, Void> INSTRUMENTER;
-
-  static {
-    JaxWsCodeAttributesGetter codeAttributesGetter = new JaxWsCodeAttributesGetter();
-
-    INSTRUMENTER =
-        Instrumenter.<JaxWsRequest, Void>builder(
-                GlobalOpenTelemetry.get(),
-                INSTRUMENTATION_NAME,
-                CodeSpanNameExtractor.create(codeAttributesGetter))
-            .addAttributesExtractor(CodeAttributesExtractor.create(codeAttributesGetter))
-            .setEnabled(ExperimentalConfig.get().controllerTelemetryEnabled())
-            .newInstrumenter();
-  }
-
-  public static Instrumenter<JaxWsRequest, Void> instrumenter() {
-    return INSTRUMENTER;
-  }
-
-  private JaxWsSingletons() {}
-}

+ 1 - 1
instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/jws/v1_1/JwsAnnotationsInstrumentation.java

@@ -10,7 +10,7 @@ import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.
 import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperMethod;
 import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
 import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.methodIsDeclaredByType;
-import static io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsSingletons.instrumenter;
+import static io.opentelemetry.javaagent.instrumentation.jaxws.jws.v1_1.JwsSingletons.instrumenter;
 import static net.bytebuddy.matcher.ElementMatchers.inheritsAnnotation;
 import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
 import static net.bytebuddy.matcher.ElementMatchers.isMethod;

+ 22 - 0
instrumentation/jaxws/jaxws-jws-api-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxws/jws/v1_1/JwsSingletons.java

@@ -0,0 +1,22 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.instrumentation.jaxws.jws.v1_1;
+
+import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
+import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsInstrumenterFactory;
+import io.opentelemetry.javaagent.instrumentation.jaxws.common.JaxWsRequest;
+
+public final class JwsSingletons {
+
+  private static final Instrumenter<JaxWsRequest, Void> INSTANCE =
+      JaxWsInstrumenterFactory.createInstrumenter("io.opentelemetry.jws-1.1");
+
+  public static Instrumenter<JaxWsRequest, Void> instrumenter() {
+    return INSTANCE;
+  }
+
+  private JwsSingletons() {}
+}