Skip to content

Commit e04116b

Browse files
committed
Merge branch 'main' of github.com:jaydeluca/opentelemetry-java-instrumentation into more-metadata-5
2 parents 2bba657 + 44fe94e commit e04116b

File tree

28 files changed

+1220
-240
lines changed

28 files changed

+1220
-240
lines changed

conventions/src/main/kotlin/otel.java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ codenarc {
437437
checkstyle {
438438
configFile = rootProject.file("buildscripts/checkstyle.xml")
439439
// this version should match the version of google_checks.xml used as basis for above configuration
440-
toolVersion = "12.1.0"
440+
toolVersion = "12.1.1"
441441
maxWarnings = 0
442442
}
443443

instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,31 @@ There are two options for capturing traces, either using interceptors or wrappin
3131

3232
#### Using interceptors
3333

34-
The Kafka clients API provides a way to "intercept" messages before they are sent to the brokers as well as messages received from the broker before being passed to the application.
35-
The OpenTelemetry instrumented Kafka library provides two interceptors to be configured to add tracing information automatically.
36-
The interceptor class has to be set in the properties bag used to create the Kafka client.
34+
The Kafka clients API provides a way to intercept messages before they are sent to the brokers as well as messages received from the broker before being passed to the application.
3735

38-
Use the `TracingProducerInterceptor` for the producer in order to create a "send" span automatically, each time a message is sent.
36+
To intercept messages and emit telemetry for a `KafkaProducer`:
3937

4038
```java
41-
props.setProperty(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingProducerInterceptor.class.getName());
39+
KafkaTelemetry telemetry = KafkaTelemetry.create(openTelemetry);
40+
41+
Map<String, Object> props = new HashMap<>();
42+
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
43+
props.putAll(telemetry.producerInterceptorConfigProperties());
44+
45+
Producer<String, String> producer = new KafkaProducer<>(props);
4246
```
4347

44-
Use the `TracingConsumerInterceptor` for the consumer in order to create a "receive" span automatically, each time a message is received.
48+
To intercept messages and emit telemetry for a `KafkaConsumer`:
4549

4650
```java
47-
props.setProperty(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingConsumerInterceptor.class.getName());
51+
KafkaTelemetry telemetry = KafkaTelemetry.create(openTelemetry);
52+
53+
Map<String, Object> props = new HashMap<>();
54+
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
55+
props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-group");
56+
props.putAll(telemetry.consumerInterceptorConfigProperties());
57+
58+
Consumer<String, String> consumer = new KafkaConsumer<>(props);
4859
```
4960

5061
#### Wrapping clients

instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/build.gradle.kts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,32 @@ tasks {
2222
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
2323
}
2424

25-
val testReceiveSpansDisabled by registering(Test::class) {
25+
test {
26+
filter {
27+
excludeTestsMatching("*Deprecated*")
28+
}
29+
}
30+
31+
val testDeprecated by registering(Test::class) {
2632
testClassesDirs = sourceSets.test.get().output.classesDirs
2733
classpath = sourceSets.test.get().runtimeClasspath
2834
filter {
29-
includeTestsMatching("InterceptorsSuppressReceiveSpansTest")
30-
includeTestsMatching("WrapperSuppressReceiveSpansTest")
35+
includeTestsMatching("*DeprecatedInterceptorsTest")
3136
}
32-
include("**/InterceptorsSuppressReceiveSpansTest.*", "**/WrapperSuppressReceiveSpansTest.*")
37+
systemProperty("otel.instrumentation.messaging.experimental.receive-telemetry.enabled", "true")
38+
systemProperty("otel.instrumentation.messaging.experimental.capture-headers", "Test-Message-Header")
3339
}
3440

35-
test {
41+
val testDeprecatedSuppressReceiveSpans by registering(Test::class) {
42+
testClassesDirs = sourceSets.test.get().output.classesDirs
43+
classpath = sourceSets.test.get().runtimeClasspath
3644
filter {
37-
excludeTestsMatching("InterceptorsSuppressReceiveSpansTest")
38-
excludeTestsMatching("WrapperSuppressReceiveSpansTest")
45+
includeTestsMatching("*DeprecatedInterceptorsSuppressReceiveSpansTest")
3946
}
40-
jvmArgs("-Dotel.instrumentation.messaging.experimental.receive-telemetry.enabled=true")
41-
systemProperty("otel.instrumentation.messaging.experimental.capture-headers", "Test-Message-Header")
4247
}
4348

4449
check {
45-
dependsOn(testReceiveSpansDisabled)
50+
dependsOn(testDeprecated, testDeprecatedSuppressReceiveSpans)
4651
}
4752
}
4853

0 commit comments

Comments
 (0)