Fix metro latest dep test
MODIFY
instrumentation/jaxws/jaxws-2.0-metro-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/metro/MetroJaxWsTracer.java
instrumentation/jaxws/jaxws-2.0-metro-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/metro/MetroJaxWsTracer.java
@@ -14,11 +14,14 @@ import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.servlet.ServletContextPath;
import io.opentelemetry.instrumentation.api.tracer.BaseTracer;
-import io.opentelemetry.javaagent.instrumentation.metro.TracingPropertySet.ThrowableHolder;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.handler.MessageContext;
public class MetroJaxWsTracer extends BaseTracer {
+ private static final String CONTEXT_KEY = "TracingPropertySet.Context";
+ private static final String SCOPE_KEY = "TracingPropertySet.Scope";
+ private static final String THROWABLE_KEY = "TracingPropertySet.Throwable";
+
private static final MetroJaxWsTracer TRACER = new MetroJaxWsTracer();
public static MetroJaxWsTracer tracer() {
@@ -33,7 +36,8 @@ public class MetroJaxWsTracer extends BaseTracer {
Scope scope = context.makeCurrent();
// store context and scope
- packet.addSatellite(new TracingPropertySet(context, scope));
+ packet.invocationProperties.put(CONTEXT_KEY, context);
+ packet.invocationProperties.put(SCOPE_KEY, scope);
Span serverSpan = getCurrentServerSpan();
if (serverSpan != null) {
@@ -61,15 +65,13 @@ public class MetroJaxWsTracer extends BaseTracer {
}
public void end(Packet packet, Throwable throwable) {
- Scope scope = (Scope) packet.get(TracingPropertySet.SCOPE_KEY);
+ Scope scope = (Scope) packet.invocationProperties.remove(SCOPE_KEY);
if (scope != null) {
scope.close();
- Context context = (Context) packet.get(TracingPropertySet.CONTEXT_KEY);
+ Context context = (Context) packet.invocationProperties.remove(CONTEXT_KEY);
if (throwable == null) {
- ThrowableHolder throwableHolder =
- (ThrowableHolder) packet.get(TracingPropertySet.THROWABLE_KEY);
- throwable = throwableHolder.getThrowable();
+ throwable = (Throwable) packet.invocationProperties.remove(THROWABLE_KEY);
}
if (throwable != null) {
tracer().endExceptionally(context, throwable);
@@ -79,6 +81,10 @@ public class MetroJaxWsTracer extends BaseTracer {
}
}
+ public void storeThrowable(Packet packet, Throwable throwable) {
+ packet.invocationProperties.put(THROWABLE_KEY, throwable);
+ }
+
@Override
protected String getInstrumentationName() {
return "io.opentelemetry.javaagent.metro";

MODIFY
instrumentation/jaxws/jaxws-2.0-metro-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/metro/SoapFaultBuilderInstrumentation.java
instrumentation/jaxws/jaxws-2.0-metro-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/metro/SoapFaultBuilderInstrumentation.java
package io.opentelemetry.javaagent.instrumentation.metro;
+import static io.opentelemetry.javaagent.instrumentation.metro.MetroJaxWsTracer.tracer;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.sun.xml.ws.api.message.Packet;
import com.sun.xml.ws.api.pipe.Fiber;
-import io.opentelemetry.javaagent.instrumentation.metro.TracingPropertySet.ThrowableHolder;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
import java.util.Map;
import net.bytebuddy.asm.Advice;
@@ -42,10 +42,17 @@ public class SoapFaultBuilderInstrumentation implements TypeInstrumentation {
if (throwable == null) {
return;
}
- Packet request = Fiber.current().getPacket();
- ThrowableHolder throwableHolder =
- (ThrowableHolder) request.get(TracingPropertySet.THROWABLE_KEY);
- throwableHolder.setThrowable(throwable);
+ Packet request = null;
+ // we expect this to be called with attached fiber
+ // if fiber is not attached current() throws IllegalStateException
+ try {
+ request = Fiber.current().getPacket();
+ } catch (IllegalStateException ignore) {
+ // fiber not available
+ }
+ if (request != null) {
+ tracer().storeThrowable(request, throwable);
+ }
}
}
}

DELETE
instrumentation/jaxws/jaxws-2.0-metro-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/metro/TracingPropertySet.java
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.instrumentation.metro;
-
-import com.sun.xml.ws.api.PropertySet;
-import io.opentelemetry.context.Context;
-import io.opentelemetry.context.Scope;
-
-public class TracingPropertySet extends PropertySet {
- public static final String CONTEXT_KEY = "TracingPropertySet.Context";
- public static final String SCOPE_KEY = "TracingPropertySet.Scope";
- public static final String THROWABLE_KEY = "TracingPropertySet.Throwable";
-
- private static final PropertyMap model;
-
- static {
- model = parse(TracingPropertySet.class);
- }
-
- private final Context context;
- private final Scope scope;
- private final ThrowableHolder throwableHolder;
-
- TracingPropertySet(Context context, Scope scope) {
- this.context = context;
- this.scope = scope;
- this.throwableHolder = new ThrowableHolder();
- }
-
- @Property(CONTEXT_KEY)
- public Context getContext() {
- return context;
- }
-
- @Property(SCOPE_KEY)
- public Scope getScope() {
- return scope;
- }
-
- @Property(THROWABLE_KEY)
- public ThrowableHolder getThrowableHolder() {
- return throwableHolder;
- }
-
- @Override
- protected PropertyMap getPropertyMap() {
- return model;
- }
-
- public static class ThrowableHolder {
- private Throwable throwable;
-
- public void setThrowable(Throwable throwable) {
- this.throwable = throwable;
- }
-
- public Throwable getThrowable() {
- return throwable;
- }
- }
-}

Fix metro latest dep test (#2388)