Library readmes - batch 2 (#14631)

This commit is contained in:
Jay DeLuca 2025-09-16 03:24:13 -04:00 committed by GitHub
parent fbc58a15b7
commit 17a0bde1f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 303 additions and 0 deletions

View File

@ -0,0 +1,47 @@
# Library Instrumentation for JMX Metrics
Provides OpenTelemetry instrumentation for [Java Management Extensions (JMX)](https://docs.oracle.com/javase/tutorial/jmx/).
This instrumentation collects JMX-based metrics and exports them as OpenTelemetry metrics.
## Quickstart
### Add these dependencies to your project
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-jmx-metrics).
For Maven, add to your `pom.xml` dependencies:
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jmx-metrics</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
```
For Gradle, add to your dependencies:
```kotlin
implementation("io.opentelemetry.instrumentation:opentelemetry-jmx-metrics:OPENTELEMETRY_VERSION")
```
### Usage
```java
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.jmx.engine.JmxMetricInsight;
import io.opentelemetry.instrumentation.jmx.engine.MetricConfiguration;
// Get an OpenTelemetry instance
OpenTelemetry openTelemetry = ...;
JmxMetricInsight jmxMetricInsight = JmxMetricInsight.createService(openTelemetry, 5000);
// Configure your JMX metrics
MetricConfiguration config = new MetricConfiguration();
jmxMetricInsight.startLocal(config);
```

View File

@ -0,0 +1,50 @@
# Library Instrumentation for Lettuce version 5.1 and higher
Provides OpenTelemetry instrumentation for [Lettuce](https://lettuce.io/), enabling database client
spans and metrics.
## Quickstart
### Add these dependencies to your project
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-lettuce-5.1).
For Maven, add to your `pom.xml` dependencies:
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-lettuce-5.1</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
```
For Gradle, add to your dependencies:
```kotlin
implementation("io.opentelemetry.instrumentation:opentelemetry-lettuce-5.1:OPENTELEMETRY_VERSION")
```
### Usage
```java
import io.lettuce.core.RedisClient;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.resource.ClientResources;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.lettuce.v5_1.LettuceTelemetry;
// Get an OpenTelemetry instance
OpenTelemetry openTelemetry = ...;
LettuceTelemetry lettuceTelemetry = LettuceTelemetry.create(openTelemetry);
ClientResources clientResources = ClientResources.builder()
.tracing(lettuceTelemetry.newTracing())
.build();
RedisClient redisClient = RedisClient.create(clientResources, "redis://localhost:6379");
StatefulRedisConnection<String, String> connection = redisClient.connect();
```

View File

@ -0,0 +1,105 @@
# Library Instrumentation for Netty version 4.1 and higher
Provides OpenTelemetry instrumentation for [Netty](https://netty.io/), enabling HTTP client and
server spans and metrics.
## Quickstart
### Add these dependencies to your project
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-netty-4.1).
For Maven, add to your `pom.xml` dependencies:
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-netty-4.1</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
```
For Gradle, add to your dependencies:
```kotlin
implementation("io.opentelemetry.instrumentation:opentelemetry-netty-4.1:OPENTELEMETRY_VERSION")
```
### Usage
#### HTTP Client
```java
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpClientCodec;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.netty.v4_1.NettyClientTelemetry;
// Get an OpenTelemetry instance
OpenTelemetry openTelemetry = ...;
NettyClientTelemetry clientTelemetry = NettyClientTelemetry.create(openTelemetry);
EventLoopGroup eventLoopGroup = ...; // Use appropriate EventLoopGroup for your platform
Class<? extends Channel> channelClass = ...; // Use appropriate Channel class for your platform
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(eventLoopGroup)
.channel(channelClass)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline()
.addLast(new HttpClientCodec())
.addLast(clientTelemetry.createCombinedHandler())
.addLast(new YourClientHandler()); // Your application handler
}
});
Channel channel = bootstrap.connect("localhost", 8080).sync().channel();
NettyClientTelemetry.setChannelContext(channel, Context.current());
```
#### HTTP Server
```java
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.netty.v4_1.NettyServerTelemetry;
// Get an OpenTelemetry instance
OpenTelemetry openTelemetry = ...;
NettyServerTelemetry serverTelemetry = NettyServerTelemetry.create(openTelemetry);
EventLoopGroup bossGroup = ...; // Use appropriate EventLoopGroup for your platform
EventLoopGroup workerGroup = ...; // Use appropriate EventLoopGroup for your platform
Class<? extends ServerChannel> serverChannelClass = ...; // Use appropriate ServerChannel class for your platform
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(bossGroup, workerGroup)
.channel(serverChannelClass)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline()
.addLast(new HttpServerCodec())
.addLast(serverTelemetry.createCombinedHandler())
.addLast(new YourServerHandler()); // Your application handler
}
});
bootstrap.bind(8080).sync();
```

View File

@ -0,0 +1,52 @@
# Library Instrumentation for OSHI version 5.3.1 and higher
Provides OpenTelemetry instrumentation for [OSHI](https://github.com/oshi/oshi).
This instrumentation collects system metrics such as memory usage, network I/O, and disk operations.
## Quickstart
### Add these dependencies to your project
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-oshi).
For Maven, add to your `pom.xml` dependencies:
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-oshi</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
```
For Gradle, add to your dependencies:
```kotlin
implementation("io.opentelemetry.instrumentation:opentelemetry-oshi:OPENTELEMETRY_VERSION")
```
### Usage
```java
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.oshi.SystemMetrics;
import java.util.List;
// Get an OpenTelemetry instance
OpenTelemetry openTelemetry = ...;
List<AutoCloseable> observables = SystemMetrics.registerObservers(openTelemetry);
// The observers will automatically collect and export system metrics
// Close the observables when shutting down your application
observables.forEach(observable -> {
try {
observable.close();
} catch (Exception e) {
// Handle exception
}
});
```

View File

@ -0,0 +1,49 @@
# Library Instrumentation for Quartz version 2.0 and higher
Provides OpenTelemetry instrumentation for [Quartz Scheduler](https://www.quartz-scheduler.org/),
enabling job execution spans.
## Quickstart
### Add these dependencies to your project
Replace `OPENTELEMETRY_VERSION` with the [latest release](https://central.sonatype.com/artifact/io.opentelemetry.instrumentation/opentelemetry-quartz-2.0).
For Maven, add to your `pom.xml` dependencies:
```xml
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-quartz-2.0</artifactId>
<version>OPENTELEMETRY_VERSION</version>
</dependency>
</dependencies>
```
For Gradle, add to your dependencies:
```kotlin
implementation("io.opentelemetry.instrumentation:opentelemetry-quartz-2.0:OPENTELEMETRY_VERSION")
```
### Usage
```java
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.quartz.v2_0.QuartzTelemetry;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
// Get an OpenTelemetry instance
OpenTelemetry openTelemetry = ...;
QuartzTelemetry quartzTelemetry = QuartzTelemetry.create(openTelemetry);
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
quartzTelemetry.configure(scheduler);
scheduler.start();
// Schedule your jobs - they will now be traced with OpenTelemetry
```