Skip to content

Commit 6bc5ca5

Browse files
jaydelucamznet
authored andcommitted
Last batch of library readmes (open-telemetry#14832)
1 parent ed27f25 commit 6bc5ca5

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Library Instrumentation for AWS SDK for Java version 1.11 and higher
2+
3+
Provides OpenTelemetry instrumentation for the [AWS SDK for Java](https://aws.amazon.com/sdk-for-java/).
4+
5+
## Quickstart
6+
7+
### Add these dependencies to your project
8+
9+
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-aws-sdk-1.11).
10+
11+
For Maven, add to your `pom.xml` dependencies:
12+
13+
```xml
14+
<dependencies>
15+
<dependency>
16+
<groupId>io.opentelemetry.instrumentation</groupId>
17+
<artifactId>opentelemetry-aws-sdk-1.11</artifactId>
18+
<version>OPENTELEMETRY_VERSION</version>
19+
</dependency>
20+
</dependencies>
21+
```
22+
23+
For Gradle, add to your dependencies:
24+
25+
```kotlin
26+
implementation("io.opentelemetry.instrumentation:opentelemetry-aws-sdk-1.11:OPENTELEMETRY_VERSION")
27+
```
28+
29+
### Usage
30+
31+
The instrumentation library provides a `RequestHandler2` that can be added to any AWS SDK v1
32+
client builder to provide spans and context propagation.
33+
34+
```java
35+
import com.amazonaws.services.s3.AmazonS3;
36+
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
37+
import io.opentelemetry.api.OpenTelemetry;
38+
import io.opentelemetry.instrumentation.awssdk.v1_11.AwsSdkTelemetry;
39+
40+
public class AwsSdkConfiguration {
41+
42+
// Use this to create instrumented AWS SDK clients.
43+
public AmazonS3 createS3Client(OpenTelemetry openTelemetry) {
44+
return AmazonS3ClientBuilder.standard()
45+
.withRequestHandlers(
46+
AwsSdkTelemetry.builder(openTelemetry)
47+
.build()
48+
.newRequestHandler())
49+
.build();
50+
}
51+
52+
// This pattern works for all AWS SDK v1 client builders (S3, SQS, DynamoDB, etc.).
53+
}
54+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Library Instrumentation for Spring Integration version 4.1 and higher
2+
3+
Provides OpenTelemetry instrumentation for [Spring Integration](https://spring.io/projects/spring-integration),
4+
enabling producer and consumer messaging spans for Spring Integration.
5+
6+
## Quickstart
7+
8+
### Add these dependencies to your project
9+
10+
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-spring-integration-4.1).
11+
12+
For Maven, add to your `pom.xml` dependencies:
13+
14+
```xml
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.opentelemetry.instrumentation</groupId>
18+
<artifactId>opentelemetry-spring-integration-4.1</artifactId>
19+
<version>OPENTELEMETRY_VERSION</version>
20+
</dependency>
21+
</dependencies>
22+
```
23+
24+
For Gradle, add to your dependencies:
25+
26+
```kotlin
27+
implementation("io.opentelemetry.instrumentation:opentelemetry-spring-integration-4.1:OPENTELEMETRY_VERSION")
28+
```
29+
30+
### Usage
31+
32+
The instrumentation library provides a `ChannelInterceptor` implementation that can be added
33+
to your Spring Integration message channels to provide spans and context propagation.
34+
35+
```java
36+
import io.opentelemetry.api.OpenTelemetry;
37+
import io.opentelemetry.instrumentation.spring.integration.v4_1.SpringIntegrationTelemetry;
38+
import org.springframework.messaging.support.ChannelInterceptor;
39+
40+
public class SpringIntegrationConfiguration {
41+
42+
// Use this ChannelInterceptor for intercepting Spring Integration message channels.
43+
public ChannelInterceptor createInterceptor(OpenTelemetry openTelemetry) {
44+
return SpringIntegrationTelemetry.builder(openTelemetry)
45+
.build()
46+
.newChannelInterceptor();
47+
}
48+
49+
// Apply the interceptor to your message channels in your Spring configuration.
50+
}
51+
```
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Library Instrumentation for Spring Kafka version 2.7 and higher
2+
3+
Provides OpenTelemetry instrumentation for [Spring Kafka](https://spring.io/projects/spring-kafka),
4+
enabling consumer and producer messaging spans.
5+
6+
## Quickstart
7+
8+
### Add these dependencies to your project
9+
10+
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-spring-kafka-2.7).
11+
12+
For Maven, add to your `pom.xml` dependencies:
13+
14+
```xml
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.opentelemetry.instrumentation</groupId>
18+
<artifactId>opentelemetry-spring-kafka-2.7</artifactId>
19+
<version>OPENTELEMETRY_VERSION</version>
20+
</dependency>
21+
</dependencies>
22+
```
23+
24+
For Gradle, add to your dependencies:
25+
26+
```kotlin
27+
implementation("io.opentelemetry.instrumentation:opentelemetry-spring-kafka-2.7:OPENTELEMETRY_VERSION")
28+
```
29+
30+
### Usage
31+
32+
The instrumentation library provides interceptors that can be added to Spring Kafka message
33+
listener containers and producers to provide spans and context propagation.
34+
35+
```java
36+
import io.opentelemetry.api.OpenTelemetry;
37+
import io.opentelemetry.instrumentation.kafkaclients.v2_6.KafkaTelemetry;
38+
import io.opentelemetry.instrumentation.spring.kafka.v2_7.SpringKafkaTelemetry;
39+
import org.springframework.boot.autoconfigure.kafka.DefaultKafkaProducerFactoryCustomizer;
40+
import org.springframework.context.annotation.Bean;
41+
import org.springframework.context.annotation.Configuration;
42+
import org.springframework.kafka.config.ContainerCustomizer;
43+
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
44+
45+
@Configuration
46+
public class KafkaInstrumentationConfig {
47+
48+
// Instrument Kafka producers
49+
@Bean
50+
public DefaultKafkaProducerFactoryCustomizer producerInstrumentation(
51+
OpenTelemetry openTelemetry) {
52+
KafkaTelemetry kafkaTelemetry = KafkaTelemetry.create(openTelemetry);
53+
return producerFactory -> producerFactory.addPostProcessor(kafkaTelemetry::wrap);
54+
}
55+
56+
// Instrument Kafka consumers
57+
@Bean
58+
public ContainerCustomizer<String, String, ConcurrentMessageListenerContainer<String, String>>
59+
listenerCustomizer(OpenTelemetry openTelemetry) {
60+
SpringKafkaTelemetry springKafkaTelemetry = SpringKafkaTelemetry.create(openTelemetry);
61+
return container -> {
62+
container.setRecordInterceptor(springKafkaTelemetry.createRecordInterceptor());
63+
container.setBatchInterceptor(springKafkaTelemetry.createBatchInterceptor());
64+
};
65+
}
66+
}
67+
```

0 commit comments

Comments
 (0)