opentelemetry-java-instrume.../instrumentation/apache-dbcp-2.0/library
Mateusz Rzeszutek 65ee9510f5
Rename the `instrumentation-api-semconv` module into `instrumentation-api-incubator` (#9985)
2023-12-04 08:28:10 +01:00
..
src Rename the `instrumentation-api-semconv` module into `instrumentation-api-incubator` (#9985) 2023-12-04 08:28:10 +01:00
README.md Introduce markdown lint check (#7175) 2022-11-16 20:48:42 -08:00
build.gradle.kts Implement Apache DBCP2 datasource metrics (#6175) 2022-06-15 15:00:46 -07:00

README.md

Library Instrumentation for Apache DBCP version 2.0 and higher

Provides OpenTelemetry instrumentation for Apache DBCP.

Quickstart

Add these dependencies to your project

Replace OPENTELEMETRY_VERSION with the latest release.

For Maven, add to your pom.xml dependencies:

<dependencies>
  <dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-apache-dbcp-2.0</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>
</dependencies>

For Gradle, add to your dependencies:

implementation("io.opentelemetry.instrumentation:opentelemetry-apache-dbcp-2.0:OPENTELEMETRY_VERSION")

Usage

The instrumentation library allows registering BasicDataSourceMXBean instances for collecting OpenTelemetry-based metrics. A non-null name of the data source must be explicitly provided.

ApacheDbcpTelemetry apacheDbcpTelemetry;

void configure(OpenTelemetry openTelemetry, BasicDataSourceMXBean dataSource, String dataSourceName) {
  apacheDbcpTelemetry = ApacheDbcpTelemetry.create(openTelemetry);
  apacheDbcpTelemetry.registerMetrics(dataSource, dataSourceName);
}

void destroy(BasicDataSourceMXBean dataSource) {
  apacheDbcpTelemetry.unregisterMetrics(dataSource);
}