Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions instrumentation/jmx-metrics/library/README.md
Original file line number Diff line number Diff line change
@@ -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 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);
Comment on lines +34 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this does not conform to our usual practices. @SylvainJuge any plans to make this similar to our other library instrumentations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean exactly here ? Is it packaging the JMX metrics feature to be similar to other library components in the instrumentation repository ? For example support for auto-configuration or fitting an "idiomatic way" to setup and initialize ?

For example, there is currently no way to properly shut-down or disable the feature at runtime, which could be problematic in some case if we want to provide the ability to automatically re-connect to a remote JVM (which is not the case when executed locally within the JVM).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other library instrumentations use have Telemetry/TelemetryBuilder as public api classes that users should interact with, idk if the same pattern would work here. Our library instrumentations provide minimal public api, this module has a bunch of public classes, are all of these intended to serve as the public api? If not you could move them to an internal package. The main package is io.opentelemetry.instrumentation.jmx.engine which does not match what other library insrumentations use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```
50 changes: 50 additions & 0 deletions instrumentation/lettuce/lettuce-5.1/library/README.md
Original file line number Diff line number Diff line change
@@ -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();
```
103 changes: 103 additions & 0 deletions instrumentation/netty/netty-4.1/library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
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);

Bootstrap bootstrap = new Bootstrap();
bootstrap.group(new NioEventLoopGroup())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if that matters but NioEventLoopGroup has been deprecated in netty 4.2

.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline()
.addLast(new HttpClientCodec())
.addLast(clientTelemetry.createRequestHandler())
.addLast(clientTelemetry.createResponseHandler());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use createCombinedHandler() to create both

}
});

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.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
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 = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();

ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ch.pipeline()
.addLast(new HttpServerCodec())
.addLast(serverTelemetry.createRequestHandler())
.addLast(serverTelemetry.createResponseHandler());
}
});

bootstrap.bind(8080).sync();
```
52 changes: 52 additions & 0 deletions instrumentation/oshi/library/README.md
Original file line number Diff line number Diff line change
@@ -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
}
});
```
49 changes: 49 additions & 0 deletions instrumentation/quartz-2.0/library/README.md
Original file line number Diff line number Diff line change
@@ -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 INTERNAL spans for each job execution.

## 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
```