- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1k
 
Library readmes - batch 2 #14631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Library readmes - batch 2 #14631
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            2 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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-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); | ||
| ``` | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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(); | ||
| ``` | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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(); | ||
| ``` | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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 | ||
| } | ||
| }); | ||
| ``` | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | 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 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 | ||
| ``` | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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/TelemetryBuilderas 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 isio.opentelemetry.instrumentation.jmx.enginewhich does not match what other library insrumentations use.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#14674