Skip to content

Commit b0d6bc6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into heya/implement-database-stable-semconv
2 parents 5ea4be5 + f235209 commit b0d6bc6

File tree

14 files changed

+121
-34
lines changed

14 files changed

+121
-34
lines changed

instrumentation/couchbase/couchbase-3.1.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1_6/CouchbaseClient316Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void setup() {
4747
.withEnabledServices(CouchbaseService.KV)
4848
.withBucket(new BucketDefinition("test"))
4949
.withLogConsumer(new Slf4jLogConsumer(logger))
50+
.withStartupAttempts(5)
5051
.withStartupTimeout(Duration.ofMinutes(2));
5152
couchbase.start();
5253

instrumentation/couchbase/couchbase-3.1/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v3_1/CouchbaseClient31Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void setup() {
4747
.withEnabledServices(CouchbaseService.KV)
4848
.withBucket(new BucketDefinition("test"))
4949
.withLogConsumer(new Slf4jLogConsumer(logger))
50+
.withStartupAttempts(5)
5051
.withStartupTimeout(Duration.ofMinutes(2));
5152
couchbase.start();
5253

instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/springdata/AbstractCouchbaseSpringRepositoryTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import com.couchbase.client.java.view.DesignDocument;
1515
import io.opentelemetry.api.trace.SpanKind;
1616
import io.opentelemetry.instrumentation.couchbase.AbstractCouchbaseTest;
17+
import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
1718
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
1819
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
1920
import java.util.Collections;
2021
import org.junit.jupiter.api.AfterAll;
21-
import org.junit.jupiter.api.AfterEach;
2222
import org.junit.jupiter.api.BeforeAll;
2323
import org.junit.jupiter.api.Test;
2424
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -30,6 +30,8 @@ public abstract class AbstractCouchbaseSpringRepositoryTest extends AbstractCouc
3030
@RegisterExtension
3131
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
3232

33+
@RegisterExtension static final AutoCleanupExtension cleanup = AutoCleanupExtension.create();
34+
3335
private ConfigurableApplicationContext applicationContext;
3436
private TestRepository repository;
3537

@@ -64,11 +66,10 @@ void setUp() {
6466
repository = applicationContext.getBean(TestRepository.class);
6567
}
6668

67-
@AfterEach
68-
void cleanUpTest() {
69+
private void cleanUpTest() {
6970
testing.clearData();
7071
repository.deleteAll();
71-
testing.waitForTraces(1);
72+
testing.waitForTraces(2);
7273
}
7374

7475
@AfterAll
@@ -103,6 +104,7 @@ void emptyRepo() {
103104
void save() {
104105
TestDocument document = new TestDocument();
105106
TestDocument result = repository.save(document);
107+
cleanup.deferCleanup(this::cleanUpTest);
106108

107109
assertThat(result).isEqualTo(document);
108110

@@ -124,6 +126,7 @@ void saveAndRetrieve() {
124126
repository.save(document);
125127
return findById(repository, "1");
126128
});
129+
cleanup.deferCleanup(this::cleanUpTest);
127130

128131
assertThat(result).isEqualTo(document);
129132

@@ -149,6 +152,7 @@ void saveAndUpdate() {
149152
document.setData("other data");
150153
repository.save(document);
151154
});
155+
cleanup.deferCleanup(this::cleanUpTest);
152156

153157
testing.waitAndAssertTraces(
154158
trace ->

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpClientInstrumentationTest.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class PekkoHttpClientInstrumentationTest
4343
HttpClientInstrumentationExtension.forAgent()
4444

4545
val system: ActorSystem = ActorSystem.create()
46-
implicit val materializer: ActorMaterializer =
47-
ActorMaterializer.create(system)
46+
val materializer: ActorMaterializer = ActorMaterializer.create(system)
4847

4948
override def buildRequest(
5049
method: String,

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpServerRouteTest.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import org.apache.pekko.http.scaladsl.server.Directives.{
2525
pathPrefix,
2626
pathSingleSlash
2727
}
28-
import org.apache.pekko.stream.ActorMaterializer
2928
import org.assertj.core.api.Assertions.assertThat
3029
import org.junit.jupiter.api.extension.RegisterExtension
3130
import org.junit.jupiter.api.{AfterAll, Test, TestInstance}
@@ -42,7 +41,6 @@ class PekkoHttpServerRouteTest {
4241
private val client: WebClient = WebClient.of()
4342

4443
implicit val system: ActorSystem = ActorSystem("my-system")
45-
implicit val materializer: ActorMaterializer = ActorMaterializer()
4644

4745
private def buildAddress(port: Int): URI = try
4846
new URI("http://localhost:" + port + "/")

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestAsyncWebServer.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import org.apache.pekko.http.scaladsl.Http
1010
import org.apache.pekko.http.scaladsl.Http.ServerBinding
1111
import org.apache.pekko.http.scaladsl.model.HttpMethods.GET
1212
import org.apache.pekko.http.scaladsl.model._
13-
import org.apache.pekko.stream.ActorMaterializer
1413
import io.opentelemetry.instrumentation.testing.junit.http.{
1514
AbstractHttpServerTest,
1615
ServerEndpoint
@@ -22,7 +21,6 @@ import scala.concurrent.{Await, ExecutionContextExecutor, Future}
2221

2322
object PekkoHttpTestAsyncWebServer {
2423
implicit val system: ActorSystem = ActorSystem("my-system")
25-
implicit val materializer: ActorMaterializer = ActorMaterializer()
2624
// needed for the future flatMap/onComplete in the end
2725
implicit val executionContext: ExecutionContextExecutor = system.dispatcher
2826
val asyncHandler: HttpRequest => Future[HttpResponse] = {

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestServerSourceWebServer.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ import org.apache.pekko.http.scaladsl.Http
1313
import org.apache.pekko.http.scaladsl.Http.ServerBinding
1414
import org.apache.pekko.http.scaladsl.model.StatusCodes.Found
1515
import org.apache.pekko.http.scaladsl.server.Directives._
16-
import org.apache.pekko.stream.ActorMaterializer
1716
import org.apache.pekko.stream.scaladsl.Sink
1817

19-
import scala.concurrent.Await
18+
import scala.concurrent.{Await, ExecutionContext}
2019

2120
object PekkoHttpTestServerSourceWebServer {
22-
implicit val system = ActorSystem("my-system")
23-
implicit val materializer = ActorMaterializer()
21+
implicit val system: ActorSystem = ActorSystem("my-system")
2422
// needed for the future flatMap/onComplete in the end
25-
implicit val executionContext = system.dispatcher
23+
implicit val executionContext: ExecutionContext = system.dispatcher
2624

2725
var route = get {
2826
concat(

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestSyncWebServer.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,19 @@ import org.apache.pekko.http.scaladsl.Http
1010
import org.apache.pekko.http.scaladsl.Http.ServerBinding
1111
import org.apache.pekko.http.scaladsl.model.HttpMethods.GET
1212
import org.apache.pekko.http.scaladsl.model._
13-
import org.apache.pekko.stream.ActorMaterializer
1413
import io.opentelemetry.instrumentation.testing.junit.http.{
1514
AbstractHttpServerTest,
1615
ServerEndpoint
1716
}
1817
import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint._
1918

2019
import java.util.function.Supplier
21-
import scala.concurrent.Await
20+
import scala.concurrent.{Await, ExecutionContext}
2221

2322
object PekkoHttpTestSyncWebServer {
24-
implicit val system = ActorSystem("my-system")
25-
implicit val materializer = ActorMaterializer()
23+
implicit val system: ActorSystem = ActorSystem("my-system")
2624
// needed for the future flatMap/onComplete in the end
27-
implicit val executionContext = system.dispatcher
25+
implicit val executionContext: ExecutionContext = system.dispatcher
2826
val syncHandler: HttpRequest => HttpResponse = {
2927
case HttpRequest(GET, uri: Uri, _, _, _) => {
3028
val endpoint = ServerEndpoint.forPath(uri.path.toString())

instrumentation/pekko/pekko-http-1.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/PekkoHttpTestWebServer.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ import org.apache.pekko.http.scaladsl.Http
1313
import org.apache.pekko.http.scaladsl.Http.ServerBinding
1414
import org.apache.pekko.http.scaladsl.model.StatusCodes.Found
1515
import org.apache.pekko.http.scaladsl.server.Directives._
16-
import org.apache.pekko.stream.ActorMaterializer
1716

18-
import scala.concurrent.Await
17+
import scala.concurrent.{Await, ExecutionContext}
1918

2019
object PekkoHttpTestWebServer {
21-
implicit val system = ActorSystem("my-system")
22-
implicit val materializer = ActorMaterializer()
20+
implicit val system: ActorSystem = ActorSystem("my-system")
2321
// needed for the future flatMap/onComplete in the end
24-
implicit val executionContext = system.dispatcher
22+
implicit val executionContext: ExecutionContext = system.dispatcher
2523

2624
var route = get {
2725
concat(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.javaagent.instrumentation.ratpack;
7+
8+
import static net.bytebuddy.matcher.ElementMatchers.named;
9+
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
10+
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
11+
12+
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
13+
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
14+
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
15+
import net.bytebuddy.asm.Advice;
16+
import net.bytebuddy.description.type.TypeDescription;
17+
import net.bytebuddy.matcher.ElementMatcher;
18+
import org.reactivestreams.Subscriber;
19+
20+
public class ExecutionBoundPublisherInstrumentation implements TypeInstrumentation {
21+
22+
@Override
23+
public ElementMatcher<TypeDescription> typeMatcher() {
24+
return namedOneOf(
25+
"ratpack.exec.internal.ExecutionBoundPublisher",
26+
"ratpack.exec.internal.DefaultExecution$ExecutionBoundPublisher");
27+
}
28+
29+
@Override
30+
public void transform(TypeTransformer transformer) {
31+
transformer.applyAdviceToMethod(
32+
named("subscribe").and(takesArgument(0, named("org.reactivestreams.Subscriber"))),
33+
this.getClass().getName() + "$SubscribeAdvice");
34+
}
35+
36+
@SuppressWarnings("unused")
37+
public static class SubscribeAdvice {
38+
39+
@Advice.OnMethodEnter(suppress = Throwable.class)
40+
public static <T> void wrap(
41+
@Advice.Argument(value = 0, readOnly = false) Subscriber<T> subscriber) {
42+
subscriber = new TracingSubscriber<>(subscriber, Java8BytecodeBridge.currentContext());
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)