# Tomcat DBCP

<!-- llms-txt-link: /llms.txt -->

> OpenTelemetry Java agent instrumentation

This instrumentation enables database connection pool metrics for Tomcat DBCP.
The auto-instrumentation registers metrics when the connection pool is initialized (`BasicDataSource.startPoolMaintenance()`) or when `BasicDataSource.preRegister(...)` is invoked during MBean registration, whichever comes first, and unregisters them when the `BasicDataSource` is closed. JMX registration is not required. When a JMX `ObjectName` is available, its `name` property is used as the pool name; if the property is absent, the full `ObjectName` is used. Otherwise, the JDBC URL and connection properties are used to derive `server.address[:server.port][/db.namespace]`. If neither server address nor database namespace is available, `tomcat-dbcp` is used. A pool registered as an MBean after it has already started switches from the derived name to the `ObjectName`-based name.

- **Name**: `tomcat-dbcp-8.0`
- **Scope**: `io.opentelemetry.tomcat-dbcp-8.0`
- **Target versions**: `org.apache.tomcat:tomcat-dbcp:[8.0.3,)`
- **Library**: https://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.html

## Telemetry

- **Metrics**: `db.client.connections.idle.max`, `db.client.connections.idle.min`, `db.client.connections.max`, `db.client.connections.usage`, `db.client.connection.count`, `db.client.connection.idle.max`, `db.client.connection.idle.min`, `db.client.connection.max`

## Configuration

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `otel.semconv-stability.opt-in` | list |  | Opt-in to emit stable semantic conventions instead of the old experimental semantic conventions. Accepts a comma-separated list of semantic convention groups (e.g., `database`, `http`, `messaging`). Use `<group>/dup` to emit both old and new conventions simultaneously. Stable semantic conventions will become the default in version 3.0 of the agent. |

## Data

- **JSON**: [/data/javaagent/instrumentations/tomcat-dbcp-8.0/tomcat-dbcp-8.0-f7b9710322ef.json](/data/javaagent/instrumentations/tomcat-dbcp-8.0/tomcat-dbcp-8.0-f7b9710322ef.json)
- **Explore**: [/java-agent/instrumentation/tomcat-dbcp-8.0](/java-agent/instrumentation/tomcat-dbcp-8.0)
