-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add instrumentation for JAX-RS 3.0 (#6136)
* Add instrumentation for JAX-RS 3.0 * set min java version to 11 for jax-rs 3.0 * exclude broken version * fix muzzle range * include correct api * fix muzzle * fix muzzle * remove generics * share test code
- Loading branch information
Showing
88 changed files
with
3,311 additions
and
717 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
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
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
161 changes: 0 additions & 161 deletions
161
...gent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/HandlerData.java
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
...rc/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/Jaxrs2HandlerData.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,60 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.jaxrs.v2_0; | ||
|
||
import io.opentelemetry.javaagent.instrumentation.jaxrs.HandlerData; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.AnnotatedElement; | ||
import java.lang.reflect.Method; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.function.Supplier; | ||
import javax.ws.rs.HttpMethod; | ||
import javax.ws.rs.Path; | ||
|
||
public class Jaxrs2HandlerData extends HandlerData { | ||
|
||
private static final ClassValue<Map<Method, String>> serverSpanNames = | ||
new ClassValue<Map<Method, String>>() { | ||
@Override | ||
protected Map<Method, String> computeValue(Class<?> type) { | ||
return new ConcurrentHashMap<>(); | ||
} | ||
}; | ||
|
||
public Jaxrs2HandlerData(Class<?> target, Method method) { | ||
super(target, method); | ||
} | ||
|
||
/** | ||
* Returns the span name given a JaxRS annotated method. Results are cached so this method can be | ||
* called multiple times without significantly impacting performance. | ||
* | ||
* @return The result can be an empty string but will never be {@code null}. | ||
*/ | ||
@Override | ||
public String getServerSpanName() { | ||
Map<Method, String> classMap = serverSpanNames.get(target); | ||
String spanName = classMap.get(method); | ||
if (spanName == null) { | ||
spanName = super.getServerSpanName(); | ||
classMap.put(method, spanName); | ||
} | ||
|
||
return spanName; | ||
} | ||
|
||
@Override | ||
protected Class<? extends Annotation> getHttpMethodAnnotation() { | ||
return HttpMethod.class; | ||
} | ||
|
||
@Override | ||
protected Supplier<String> getPathAnnotation(AnnotatedElement annotatedElement) { | ||
Path path = annotatedElement.getAnnotation(Path.class); | ||
return path != null ? path::value : null; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ava/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/Jaxrs2RequestContextHelper.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,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.jaxrs.v2_0; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.javaagent.instrumentation.jaxrs.HandlerData; | ||
import io.opentelemetry.javaagent.instrumentation.jaxrs.JaxrsConstants; | ||
import io.opentelemetry.javaagent.instrumentation.jaxrs.RequestContextHelper; | ||
import javax.ws.rs.container.ContainerRequestContext; | ||
|
||
public final class Jaxrs2RequestContextHelper { | ||
public static Context createOrUpdateAbortSpan( | ||
Instrumenter<HandlerData, Void> instrumenter, | ||
ContainerRequestContext requestContext, | ||
HandlerData handlerData) { | ||
|
||
if (handlerData == null) { | ||
return null; | ||
} | ||
|
||
requestContext.setProperty(JaxrsConstants.ABORT_HANDLED, true); | ||
return RequestContextHelper.createOrUpdateAbortSpan(instrumenter, handlerData); | ||
} | ||
|
||
private Jaxrs2RequestContextHelper() {} | ||
} |
15 changes: 0 additions & 15 deletions
15
...t/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/JaxrsConstants.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.