Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
}

tasks {
withType<Test>().configureEach {
test {
jvmArgs("-Dotel.instrumentation.servlet.experimental.capture-request-parameters=test-parameter")
// required on jdk17
jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public List<TypeInstrumentation> typeInstrumentations() {
@SuppressWarnings("unused")
public static class Tomcat7AttachResponseAdvice {

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
public static void attachResponse(
@Advice.Argument(2) Response response, @Advice.Return boolean success) {

Expand Down
1 change: 1 addition & 0 deletions instrumentation/tomcat/tomcat-jdbc/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ semantic_conventions:
- DATABASE_POOL_METRICS
configurations:
- name: otel.semconv-stability.opt-in
declarative_name: general.semconv_stability.opt_in
description: >
Opt-in to emit stable semantic conventions instead of the old
experimental semantic conventions. Accepts a comma-separated list of semantic convention
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.extendsClass;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static io.opentelemetry.javaagent.instrumentation.twilio.v6_6.TwilioSingletons.instrumenter;
import static io.opentelemetry.javaagent.instrumentation.twilio.v6_6.TwilioSingletons.spanName;
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down Expand Up @@ -83,7 +82,7 @@ private AdviceScope(Context context, Scope scope, String spanName) {
@Nullable
public static AdviceScope start(Object target, String methodName) {
Context parentContext = Context.current();
String spanName = spanName(target, methodName);
String spanName = TwilioSingletons.spanName(target, methodName);
if (!instrumenter().shouldStart(parentContext, spanName)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Supplier;
import javax.annotation.Nullable;

/**
* Undertow's {@code io.undertow.server.HttpServerExchange} uses {@code
Expand All @@ -33,6 +34,7 @@
public final class KeyHolder {
private static final ConcurrentMap<Class<?>, Object> contextKeys = new ConcurrentHashMap<>();

@Nullable
public static Object get(Class<?> keyType) {
return contextKeys.get(keyType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import io.undertow.server.ExchangeCompletionListener;
import io.undertow.server.HttpServerExchange;

public class EndSpanListener implements ExchangeCompletionListener {
class EndSpanListener implements ExchangeCompletionListener {
private final Context context;

public EndSpanListener(Context context) {
EndSpanListener(Context context) {
this.context = context;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

package io.opentelemetry.javaagent.instrumentation.vertx.httpclient.v3_0;

import io.opentelemetry.instrumentation.api.util.VirtualField;
import static io.opentelemetry.javaagent.instrumentation.vertx.httpclient.v3_0.VertxClientSingletons.REQUEST_INFO;

import io.opentelemetry.javaagent.instrumentation.vertx.httpclient.common.v3_0.AbstractVertxHttpAttributesGetter;
import io.vertx.core.http.HttpClientRequest;
import javax.annotation.Nullable;

final class Vertx3HttpAttributesGetter extends AbstractVertxHttpAttributesGetter {

private static final VirtualField<HttpClientRequest, VertxRequestInfo> requestInfoField =
VirtualField.find(HttpClientRequest.class, VertxRequestInfo.class);

@Override
public String getUrlFull(HttpClientRequest request) {
String uri = request.uri();
// Uri should be relative, but it is possible to misuse vert.x api and pass an absolute uri
// where relative is expected.
if (!isAbsolute(uri)) {
VertxRequestInfo requestInfo = requestInfoField.get(request);
VertxRequestInfo requestInfo = REQUEST_INFO.get(request);
if (requestInfo != null) {
uri = absoluteUri(requestInfo, uri);
}
Expand All @@ -32,7 +30,7 @@ public String getUrlFull(HttpClientRequest request) {
@Nullable
@Override
public String getServerAddress(HttpClientRequest request) {
VertxRequestInfo requestInfo = requestInfoField.get(request);
VertxRequestInfo requestInfo = REQUEST_INFO.get(request);
if (requestInfo == null) {
return null;
}
Expand All @@ -42,7 +40,7 @@ public String getServerAddress(HttpClientRequest request) {
@Nullable
@Override
public Integer getServerPort(HttpClientRequest request) {
VertxRequestInfo requestInfo = requestInfoField.get(request);
VertxRequestInfo requestInfo = REQUEST_INFO.get(request);
if (requestInfo == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static <T> Handler<T> wrap(@Nullable Handler<T> handler) {

@Override
public void handle(T t) {
try (Scope ignore = context.makeCurrent()) {
try (Scope ignored = context.makeCurrent()) {
delegate.handle(t);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static io.opentelemetry.javaagent.instrumentation.vertx.httpclient.v5_0.VertxClientSingletons.CONTEXTS;
import static io.opentelemetry.javaagent.instrumentation.vertx.httpclient.v5_0.VertxClientSingletons.instrumenter;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
import static net.bytebuddy.matcher.ElementMatchers.isPrivate;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
Expand Down Expand Up @@ -60,8 +59,7 @@ public ElementMatcher<TypeDescription> typeMatcher() {
@Override
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
isMethod().and(nameStartsWith("end").or(named("sendHead"))),
getClass().getName() + "$EndRequestAdvice");
nameStartsWith("end").or(named("sendHead")), getClass().getName() + "$EndRequestAdvice");

transformer.applyAdviceToMethod(
named("handleException"), getClass().getName() + "$HandleExceptionAdvice");
Expand All @@ -72,7 +70,7 @@ public void transform(TypeTransformer transformer) {
getClass().getName() + "$HandleResponseAdvice");

transformer.applyAdviceToMethod(
isMethod().and(isPrivate()).and(nameStartsWith("write").or(nameStartsWith("connected"))),
isPrivate().and(nameStartsWith("write").or(nameStartsWith("connected"))),
getClass().getName() + "$MountContextAdvice");

transformer.applyAdviceToMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -34,15 +35,20 @@ class VertxHttpClientTest extends AbstractHttpClientTest<Future<HttpClientReques
@RegisterExtension
static final InstrumentationExtension testing = HttpClientInstrumentationExtension.forAgent();

private final HttpClient httpClient = buildClient();
private final Vertx vertx = Vertx.vertx(new VertxOptions());
private final HttpClient httpClient = buildClient(vertx);

private static HttpClient buildClient() {
Vertx vertx = Vertx.vertx(new VertxOptions());
private static HttpClient buildClient(Vertx vertx) {
HttpClientOptions clientOptions =
new HttpClientOptions().setConnectTimeout(Math.toIntExact(CONNECTION_TIMEOUT.toMillis()));
return vertx.createHttpClient(clientOptions);
}

@AfterAll
void closeVertx() {
vertx.close();
}

@Override
public Future<HttpClientRequest> buildRequest(
String method, URI uri, Map<String, String> headers) {
Expand Down
Loading