Skip to content

Commit a928021

Browse files
committed
Merge branch 'main' into feat/jdbc-txn-instrumentation
2 parents 7bccecd + 7e3d81f commit a928021

File tree

34 files changed

+736
-265
lines changed

34 files changed

+736
-265
lines changed

.fossa.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ targets:
724724
- type: gradle
725725
path: ./
726726
target: ':instrumentation:opensearch:opensearch-rest-1.0:javaagent'
727+
- type: gradle
728+
path: ./
729+
target: ':instrumentation:opensearch:opensearch-rest-3.0:javaagent'
727730
- type: gradle
728731
path: ./
729732
target: ':instrumentation:opensearch:opensearch-rest-common:javaagent'

.github/renovate.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
'io.opentelemetry.contrib:opentelemetry-aws-resources',
3333
'io.opentelemetry.contrib:opentelemetry-aws-xray-propagator',
3434
'io.opentelemetry.contrib:opentelemetry-gcp-resources',
35+
'io.opentelemetry.contrib:opentelemetry-cloudfoundry-resources',
3536
'io.opentelemetry.contrib:opentelemetry-baggage-processor',
3637
'io.opentelemetry.proto:opentelemetry-proto',
3738
'io.opentelemetry.semconv:opentelemetry-semconv',

dependencyManagement/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ val DEPENDENCIES = listOf(
8585
"org.spockframework:spock-core:2.4-M6-groovy-4.0",
8686
"org.spockframework:spock-junit4:2.4-M6-groovy-4.0",
8787

88-
"io.r2dbc:r2dbc-proxy:1.1.5.RELEASE",
88+
"io.r2dbc:r2dbc-proxy:1.1.6.RELEASE",
8989
"ch.qos.logback:logback-classic:1.3.15", // 1.4+ requires Java 11+
9090
"com.github.stefanbirkner:system-lambda:1.2.1",
9191
"com.github.stefanbirkner:system-rules:1.19.0",
@@ -106,6 +106,7 @@ val DEPENDENCIES = listOf(
106106
"io.opentelemetry.contrib:opentelemetry-aws-resources:${otelContribVersion}",
107107
"io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:${otelContribVersion}",
108108
"io.opentelemetry.contrib:opentelemetry-gcp-resources:${otelContribVersion}",
109+
"io.opentelemetry.contrib:opentelemetry-cloudfoundry-resources:${otelContribVersion}",
109110
"io.opentelemetry.contrib:opentelemetry-baggage-processor:${otelContribVersion}",
110111
"io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha",
111112
"io.opentelemetry:opentelemetry-extension-annotations:1.18.0", // deprecated, no longer part of bom

instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpAsyncClientInstrumentation.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ private void cancelDelegate() {
264264

265265
@Nullable
266266
private HttpResponse getResponseFromHttpContext() {
267+
if (httpContext instanceof HttpCoreContext) {
268+
return ((HttpCoreContext) httpContext).getResponse();
269+
}
267270
return (HttpResponse) httpContext.getAttribute(HttpCoreContext.HTTP_RESPONSE);
268271
}
269272
}

instrumentation/mongo/mongo-common/testing/src/main/java/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public abstract class AbstractMongoClientTest<T> {
5252
@BeforeAll
5353
void setup() {
5454
mongodb =
55-
new GenericContainer<>("mongo:4.0")
55+
new GenericContainer<>("mongo:4.2")
5656
.withExposedPorts(27017)
5757
.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("mongodb")));
5858
mongodb.start();

instrumentation/opensearch/opensearch-rest-1.0/javaagent/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ muzzle {
66
pass {
77
group.set("org.opensearch.client")
88
module.set("opensearch-rest-client")
9-
versions.set("[1.0,)")
9+
versions.set("[1.0,3.0)")
1010
assertInverse.set(true)
1111
}
1212

@@ -26,14 +26,17 @@ dependencies {
2626

2727
implementation(project(":instrumentation:opensearch:opensearch-rest-common:javaagent"))
2828

29+
testInstrumentation(project(":instrumentation:opensearch:opensearch-rest-3.0:javaagent"))
2930
testInstrumentation(project(":instrumentation:apache-httpclient:apache-httpclient-4.0:javaagent"))
3031
testInstrumentation(project(":instrumentation:apache-httpasyncclient-4.1:javaagent"))
3132

3233
testImplementation("org.apache.logging.log4j:log4j-core:2.18.0")
3334
testImplementation("org.apache.logging.log4j:log4j-api:2.18.0")
3435
testImplementation("org.apache.commons:commons-lang3:3.12.0")
3536
testImplementation("commons-io:commons-io:2.11.0")
36-
testImplementation("org.opensearch:opensearch-testcontainers:2.0.0")
37+
testImplementation(project(":instrumentation:opensearch:opensearch-rest-common:testing"))
38+
39+
latestDepTestLibrary("org.opensearch.client:opensearch-rest-client:2.+") // see opensearch-rest-3.0 module
3740
}
3841

3942
tasks {

instrumentation/opensearch/opensearch-rest-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/v1_0/OpenSearchRestInstrumentationModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
99
import static java.util.Collections.singletonList;
10+
import static net.bytebuddy.matcher.ElementMatchers.not;
1011

1112
import com.google.auto.service.AutoService;
1213
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
@@ -23,7 +24,9 @@ public OpenSearchRestInstrumentationModule() {
2324
@Override
2425
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
2526
// class introduced in 1.0.0
26-
return hasClassesNamed("org.opensearch.client.RestClient$InternalRequest");
27+
return hasClassesNamed("org.opensearch.client.RestClient$InternalRequest")
28+
// class introduced in 3.0.0
29+
.and(not(hasClassesNamed("org.opensearch.client.http.HttpUriRequestProducer")));
2730
}
2831

2932
@Override

instrumentation/opensearch/opensearch-rest-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/v1_0/OpenSearchRestSingletons.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,33 @@
88
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
99
import io.opentelemetry.javaagent.instrumentation.opensearch.rest.OpenSearchRestInstrumenterFactory;
1010
import io.opentelemetry.javaagent.instrumentation.opensearch.rest.OpenSearchRestRequest;
11+
import io.opentelemetry.javaagent.instrumentation.opensearch.rest.OpenSearchRestResponse;
12+
import java.net.InetAddress;
1113
import org.opensearch.client.Response;
1214

1315
public final class OpenSearchRestSingletons {
1416

15-
private static final Instrumenter<OpenSearchRestRequest, Response> INSTRUMENTER =
17+
private static final Instrumenter<OpenSearchRestRequest, OpenSearchRestResponse> INSTRUMENTER =
1618
OpenSearchRestInstrumenterFactory.create("io.opentelemetry.opensearch-rest-1.0");
1719

18-
public static Instrumenter<OpenSearchRestRequest, Response> instrumenter() {
20+
public static Instrumenter<OpenSearchRestRequest, OpenSearchRestResponse> instrumenter() {
1921
return INSTRUMENTER;
2022
}
2123

24+
public static OpenSearchRestResponse convertResponse(Response response) {
25+
return new OpenSearchRestResponse() {
26+
27+
@Override
28+
public int getStatusCode() {
29+
return response.getStatusLine().getStatusCode();
30+
}
31+
32+
@Override
33+
public InetAddress getAddress() {
34+
return response.getHost().getAddress();
35+
}
36+
};
37+
}
38+
2239
private OpenSearchRestSingletons() {}
2340
}

instrumentation/opensearch/opensearch-rest-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/v1_0/RestClientInstrumentation.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
package io.opentelemetry.javaagent.instrumentation.opensearch.rest.v1_0;
77

88
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
9+
import static io.opentelemetry.javaagent.instrumentation.opensearch.rest.v1_0.OpenSearchRestSingletons.convertResponse;
10+
import static io.opentelemetry.javaagent.instrumentation.opensearch.rest.v1_0.OpenSearchRestSingletons.instrumenter;
911
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
1012
import static net.bytebuddy.matcher.ElementMatchers.named;
1113
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@@ -59,11 +61,11 @@ public static void onEnter(
5961

6062
Context parentContext = currentContext();
6163
otelRequest = OpenSearchRestRequest.create(request.getMethod(), request.getEndpoint());
62-
if (!OpenSearchRestSingletons.instrumenter().shouldStart(parentContext, otelRequest)) {
64+
if (!instrumenter().shouldStart(parentContext, otelRequest)) {
6365
return;
6466
}
6567

66-
context = OpenSearchRestSingletons.instrumenter().start(parentContext, otelRequest);
68+
context = instrumenter().start(parentContext, otelRequest);
6769
scope = context.makeCurrent();
6870
}
6971

@@ -80,7 +82,7 @@ public static void stopSpan(
8082
}
8183
scope.close();
8284

83-
OpenSearchRestSingletons.instrumenter().end(context, otelRequest, response, throwable);
85+
instrumenter().end(context, otelRequest, convertResponse(response), throwable);
8486
}
8587
}
8688

@@ -97,20 +99,21 @@ public static void onEnter(
9799

98100
Context parentContext = currentContext();
99101
otelRequest = OpenSearchRestRequest.create(request.getMethod(), request.getEndpoint());
100-
if (!OpenSearchRestSingletons.instrumenter().shouldStart(parentContext, otelRequest)) {
102+
if (!instrumenter().shouldStart(parentContext, otelRequest)) {
101103
return;
102104
}
103105

104-
context = OpenSearchRestSingletons.instrumenter().start(parentContext, otelRequest);
106+
context = instrumenter().start(parentContext, otelRequest);
105107
scope = context.makeCurrent();
106108

107109
responseListener =
108110
new RestResponseListener(
109111
responseListener,
110112
parentContext,
111-
OpenSearchRestSingletons.instrumenter(),
113+
instrumenter(),
112114
context,
113-
otelRequest);
115+
otelRequest,
116+
OpenSearchRestSingletons::convertResponse);
114117
}
115118

116119
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
@@ -126,7 +129,7 @@ public static void stopSpan(
126129
scope.close();
127130

128131
if (throwable != null) {
129-
OpenSearchRestSingletons.instrumenter().end(context, otelRequest, null, throwable);
132+
instrumenter().end(context, otelRequest, null, throwable);
130133
}
131134
// span ended in RestResponseListener
132135
}

instrumentation/opensearch/opensearch-rest-1.0/javaagent/src/test/java/OpenSearchRestTest.java

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)