# DB
- [General Database Attributes](#general-database-attributes)
- [Deprecated Database Attributes](#deprecated-database-attributes)
- [Deprecated Database Metrics](#deprecated-database-metrics)
## General Database Attributes
This group defines the attributes used to describe telemetry in the context of databases.
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `db.client.connection.pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation SHOULD use a combination of parameters that would make the name unique, for example, combining attributes `server.address`, `server.port`, and `db.namespace`, formatted as `server.address:server.port/db.namespace`. Instrumentations that generate connection pool name following different patterns SHOULD document it. | `myDataSource` |  |
| `db.client.connection.state` | string | The state of a connection in the pool | `idle` |  |
| `db.collection.name` | string | The name of a collection (table, container) within the database. [1] | `public.users`; `customers` |  |
| `db.namespace` | string | The name of the database, fully qualified within the server address and port. [2] | `customers`; `test.users` |  |
| `db.operation.batch.size` | int | The number of queries included in a batch operation. [3] | `2`; `3`; `4` |  |
| `db.operation.name` | string | The name of the operation or command being executed. [4] | `findAndModify`; `HMSET`; `SELECT` |  |
| `db.operation.parameter.` | string | A database operation parameter, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [5] | `someval`; `55` |  |
| `db.query.parameter.` | string | A database query parameter, with `` being the parameter name, and the attribute value being a string representation of the parameter value. [6] | `someval`; `55` |  |
| `db.query.summary` | string | Low cardinality representation of a database query text. [7] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` |  |
| `db.query.text` | string | The database query being executed. [8] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` |  |
| `db.response.returned_rows` | int | Number of rows returned by the operation. | `10`; `30`; `1000` |  |
| `db.response.status_code` | string | Database response status code. [9] | `102`; `ORA-17002`; `08P01`; `404` |  |
| `db.stored_procedure.name` | string | The name of a stored procedure within the database. [10] | `GetCustomer` |  |
| `db.system.name` | string | The database management system (DBMS) product as identified by the client instrumentation. [11] | `other_sql`; `softwareag.adabas`; `actian.ingres` |  |
**[1] `db.collection.name`:** It is RECOMMENDED to capture the value as provided by the application
without attempting to do any case normalization.
The collection name SHOULD NOT be extracted from `db.query.text`,
when the database system supports cross-table queries in non-batch operations.
For batch operations, if the individual operations are known to have the same
collection name then that collection name SHOULD be used.
**[2] `db.namespace`:** If a database system has multiple namespace components, they SHOULD be concatenated (potentially using database system specific conventions) from most general to most specific namespace component, and more specific namespaces SHOULD NOT be captured without the more general namespaces, to ensure that "startswith" queries for the more general namespaces will be valid.
Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system.
It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
**[3] `db.operation.batch.size`:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`.
**[4] `db.operation.name`:** It is RECOMMENDED to capture the value as provided by the application
without attempting to do any case normalization.
The operation name SHOULD NOT be extracted from `db.query.text`,
when the database system supports cross-table queries in non-batch operations.
If spaces can occur in the operation name, multiple consecutive spaces
SHOULD be normalized to a single space.
For batch operations, if the individual operations are known to have the same operation name
then that operation name SHOULD be used prepended by `BATCH `,
otherwise `db.operation.name` SHOULD be `BATCH` or some other database
system specific term if more applicable.
**[5] `db.operation.parameter`:** `db.query.text` parameters SHOULD be captured using `db.query.parameter.` instead of `db.operation.parameter.`.
**[6] `db.query.parameter`:** If a query parameter has no name and instead is referenced only by index, then `` SHOULD be the 0-based index.
`db.query.parameter.` SHOULD match up with the parameterized placeholders present in `db.query.text`.
`db.query.parameter.` SHOULD NOT be captured on batch operations.
**[7] `db.query.summary`:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries.
Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](/docs/database/database-spans.md#generating-a-summary-of-the-query-text) section.
**[8] `db.query.text`:** For sanitization see [Sanitization of `db.query.text`](/docs/database/database-spans.md#sanitization-of-dbquerytext).
For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable.
Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk.
**[9] `db.response.status_code`:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes.
Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system.
**[10] `db.stored_procedure.name`:** It is RECOMMENDED to capture the value as provided by the application
without attempting to do any case normalization.
For batch operations, if the individual operations are known to have the same
stored procedure name then that stored procedure name SHOULD be used.
**[11] `db.system.name`:** The actual DBMS may differ from the one identified by the client. For example, when using PostgreSQL client libraries to connect to a CockroachDB, the `db.system.name` is set to `postgresql` based on the instrumentation's best knowledge.
---
`db.client.connection.state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `idle` | idle |  |
| `used` | used |  |
---
`db.system.name` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `actian.ingres` | [Actian Ingres](https://www.actian.com/databases/ingres/) |  |
| `aws.dynamodb` | [Amazon DynamoDB](https://aws.amazon.com/pm/dynamodb/) |  |
| `aws.redshift` | [Amazon Redshift](https://aws.amazon.com/redshift/) |  |
| `azure.cosmosdb` | [Azure Cosmos DB](https://learn.microsoft.com/azure/cosmos-db) |  |
| `cassandra` | [Apache Cassandra](https://cassandra.apache.org/) |  |
| `clickhouse` | [ClickHouse](https://clickhouse.com/) |  |
| `cockroachdb` | [CockroachDB](https://www.cockroachlabs.com/) |  |
| `couchbase` | [Couchbase](https://www.couchbase.com/) |  |
| `couchdb` | [Apache CouchDB](https://couchdb.apache.org/) |  |
| `derby` | [Apache Derby](https://db.apache.org/derby/) |  |
| `elasticsearch` | [Elasticsearch](https://www.elastic.co/elasticsearch) |  |
| `firebirdsql` | [Firebird](https://www.firebirdsql.org/) |  |
| `gcp.spanner` | [Google Cloud Spanner](https://cloud.google.com/spanner) |  |
| `geode` | [Apache Geode](https://geode.apache.org/) |  |
| `h2database` | [H2 Database](https://h2database.com/) |  |
| `hbase` | [Apache HBase](https://hbase.apache.org/) |  |
| `hive` | [Apache Hive](https://hive.apache.org/) |  |
| `hsqldb` | [HyperSQL Database](https://hsqldb.org/) |  |
| `ibm.db2` | [IBM Db2](https://www.ibm.com/db2) |  |
| `ibm.informix` | [IBM Informix](https://www.ibm.com/products/informix) |  |
| `ibm.netezza` | [IBM Netezza](https://www.ibm.com/products/netezza) |  |
| `influxdb` | [InfluxDB](https://www.influxdata.com/) |  |
| `instantdb` | [Instant](https://www.instantdb.com/) |  |
| `intersystems.cache` | [InterSystems Caché](https://www.intersystems.com/products/cache/) |  |
| `mariadb` | [MariaDB](https://mariadb.org/) |  |
| `memcached` | [Memcached](https://memcached.org/) |  |
| `microsoft.sql_server` | [Microsoft SQL Server](https://www.microsoft.com/sql-server) |  |
| `mongodb` | [MongoDB](https://www.mongodb.com/) |  |
| `mysql` | [MySQL](https://www.mysql.com/) |  |
| `neo4j` | [Neo4j](https://neo4j.com/) |  |
| `opensearch` | [OpenSearch](https://opensearch.org/) |  |
| `oracle.db` | [Oracle Database](https://www.oracle.com/database/) |  |
| `other_sql` | Some other SQL database. Fallback only. |  |
| `postgresql` | [PostgreSQL](https://www.postgresql.org/) |  |
| `redis` | [Redis](https://redis.io/) |  |
| `sap.hana` | [SAP HANA](https://www.sap.com/products/technology-platform/hana/what-is-sap-hana.html) |  |
| `sap.maxdb` | [SAP MaxDB](https://maxdb.sap.com/) |  |
| `softwareag.adabas` | [Adabas (Adaptable Database System)](https://documentation.softwareag.com/?pf=adabas) |  |
| `sqlite` | [SQLite](https://www.sqlite.org/) |  |
| `teradata` | [Teradata](https://www.teradata.com/) |  |
| `trino` | [Trino](https://trino.io/) |  |
## Deprecated Database Attributes
Describes deprecated database attributes.
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `db.cassandra.consistency_level` | string | Deprecated, use `cassandra.consistency.level` instead. | `all`; `each_quorum`; `quorum` | 
Replaced by `cassandra.consistency.level`. |
| `db.cassandra.coordinator.dc` | string | Deprecated, use `cassandra.coordinator.dc` instead. | `us-west-2` | 
Replaced by `cassandra.coordinator.dc`. |
| `db.cassandra.coordinator.id` | string | Deprecated, use `cassandra.coordinator.id` instead. | `be13faa2-8574-4d71-926d-27f16cf8a7af` | 
Replaced by `cassandra.coordinator.id`. |
| `db.cassandra.idempotence` | boolean | Deprecated, use `cassandra.query.idempotent` instead. | | 
Replaced by `cassandra.query.idempotent`. |
| `db.cassandra.page_size` | int | Deprecated, use `cassandra.page.size` instead. | `5000` | 
Replaced by `cassandra.page.size`. |
| `db.cassandra.speculative_execution_count` | int | Deprecated, use `cassandra.speculative_execution.count` instead. | `0`; `2` | 
Replaced by `cassandra.speculative_execution.count`. |
| `db.cassandra.table` | string | Deprecated, use `db.collection.name` instead. | `mytable` | 
Replaced by `db.collection.name`. |
| `db.connection_string` | string | Deprecated, use `server.address`, `server.port` attributes instead. | `Server=(localdb)\v11.0;Integrated Security=true;` | 
Replaced by `server.address` and `server.port`. |
| `db.cosmosdb.client_id` | string | Deprecated, use `azure.client.id` instead. | `3ba4827d-4422-483f-b59f-85b74211c11d` | 
Replaced by `azure.client.id`. |
| `db.cosmosdb.connection_mode` | string | Deprecated, use `azure.cosmosdb.connection.mode` instead. | `gateway`; `direct` | 
Replaced by `azure.cosmosdb.connection.mode`. |
| `db.cosmosdb.consistency_level` | string | Deprecated, use `cosmosdb.consistency.level` instead. | `Eventual`; `ConsistentPrefix`; `BoundedStaleness`; `Strong`; `Session` | 
Replaced by `azure.cosmosdb.consistency.level`. |
| `db.cosmosdb.container` | string | Deprecated, use `db.collection.name` instead. | `mytable` | 
Replaced by `db.collection.name`. |
| `db.cosmosdb.operation_type` | string | Deprecated, no replacement at this time. | `batch`; `create`; `delete` | 
No replacement at this time. |
| `db.cosmosdb.regions_contacted` | string[] | Deprecated, use `azure.cosmosdb.operation.contacted_regions` instead. | `["North Central US", "Australia East", "Australia Southeast"]` | 
Replaced by `azure.cosmosdb.operation.contacted_regions`. |
| `db.cosmosdb.request_charge` | double | Deprecated, use `azure.cosmosdb.operation.request_charge` instead. | `46.18`; `1.0` | 
Replaced by `azure.cosmosdb.operation.request_charge`. |
| `db.cosmosdb.request_content_length` | int | Deprecated, use `azure.cosmosdb.request.body.size` instead. | | 
Replaced by `azure.cosmosdb.request.body.size`. |
| `db.cosmosdb.status_code` | int | Deprecated, use `db.response.status_code` instead. | `200`; `201` | 
Replaced by `db.response.status_code`. |
| `db.cosmosdb.sub_status_code` | int | Deprecated, use `azure.cosmosdb.response.sub_status_code` instead. | `1000`; `1002` | 
Replaced by `azure.cosmosdb.response.sub_status_code`. |
| `db.elasticsearch.cluster.name` | string | Deprecated, use `db.namespace` instead. | `e9106fc68e3044f0b1475b04bf4ffd5f` | 
Replaced by `db.namespace`. |
| `db.elasticsearch.node.name` | string | Deprecated, use `elasticsearch.node.name` instead. | `instance-0000000001` | 
Replaced by `elasticsearch.node.name`. |
| `db.elasticsearch.path_parts.` | string | Deprecated, use `db.operation.parameter` instead. | `db.elasticsearch.path_parts.index=test-index`; `db.elasticsearch.path_parts.doc_id=123` | 
Replaced by `db.operation.parameter`. |
| `db.instance.id` | string | Deprecated, no general replacement at this time. For Elasticsearch, use `db.elasticsearch.node.name` instead. | `mysql-e26b99z.example.com` | 
Deprecated, no general replacement at this time. For Elasticsearch, use `db.elasticsearch.node.name` instead. |
| `db.jdbc.driver_classname` | string | Removed, no replacement at this time. | `org.postgresql.Driver`; `com.microsoft.sqlserver.jdbc.SQLServerDriver` | 
Removed as not used. |
| `db.mongodb.collection` | string | Deprecated, use `db.collection.name` instead. | `mytable` | 
Replaced by `db.collection.name`. |
| `db.mssql.instance_name` | string | Deprecated, SQL Server instance is now populated as a part of `db.namespace` attribute. | `MSSQLSERVER` | 
Deprecated, no replacement at this time. |
| `db.name` | string | Deprecated, use `db.namespace` instead. | `customers`; `main` | 
Replaced by `db.namespace`. |
| `db.operation` | string | Deprecated, use `db.operation.name` instead. | `findAndModify`; `HMSET`; `SELECT` | 
Replaced by `db.operation.name`. |
| `db.redis.database_index` | int | Deprecated, use `db.namespace` instead. | `0`; `1`; `15` | 
Replaced by `db.namespace`. |
| `db.sql.table` | string | Deprecated, use `db.collection.name` instead, but only if not extracting the value from `db.query.text`. | `mytable` | 
Replaced by `db.collection.name`, but only if not extracting the value from `db.query.text`. |
| `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | 
Replaced by `db.query.text`. |
| `db.system` | string | Deprecated, use `db.system.name` instead. | `other_sql`; `adabas`; `cache` | 
Replaced by `db.system.name`. |
| `db.user` | string | Deprecated, no replacement at this time. | `readonly_user`; `reporting_user` | 
No replacement at this time. |
---
`db.cassandra.consistency_level` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `all` | all |  |
| `any` | any |  |
| `each_quorum` | each_quorum |  |
| `local_one` | local_one |  |
| `local_quorum` | local_quorum |  |
| `local_serial` | local_serial |  |
| `one` | one |  |
| `quorum` | quorum |  |
| `serial` | serial |  |
| `three` | three |  |
| `two` | two |  |
---
`db.cosmosdb.connection_mode` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `direct` | Direct connection. |  |
| `gateway` | Gateway (HTTP) connection. |  |
---
`db.cosmosdb.consistency_level` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `BoundedStaleness` | bounded_staleness |  |
| `ConsistentPrefix` | consistent_prefix |  |
| `Eventual` | eventual |  |
| `Session` | session |  |
| `Strong` | strong |  |
---
`db.cosmosdb.operation_type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `batch` | batch |  |
| `create` | create |  |
| `delete` | delete |  |
| `execute` | execute |  |
| `execute_javascript` | execute_javascript |  |
| `head` | head |  |
| `head_feed` | head_feed |  |
| `invalid` | invalid |  |
| `patch` | patch |  |
| `query` | query |  |
| `query_plan` | query_plan |  |
| `read` | read |  |
| `read_feed` | read_feed |  |
| `replace` | replace |  |
| `upsert` | upsert |  |
---
`db.system` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `adabas` | Adabas (Adaptable Database System) |  |
| `cassandra` | Apache Cassandra |  |
| `clickhouse` | ClickHouse |  |
| `cockroachdb` | CockroachDB |  |
| `cosmosdb` | Microsoft Azure Cosmos DB |  |
| `couchbase` | Couchbase |  |
| `couchdb` | CouchDB |  |
| `db2` | IBM Db2 |  |
| `derby` | Apache Derby |  |
| `dynamodb` | Amazon DynamoDB |  |
| `edb` | EnterpriseDB |  |
| `elasticsearch` | Elasticsearch |  |
| `filemaker` | FileMaker |  |
| `firebird` | Firebird |  |
| `geode` | Apache Geode |  |
| `h2` | H2 |  |
| `hanadb` | SAP HANA |  |
| `hbase` | Apache HBase |  |
| `hive` | Apache Hive |  |
| `hsqldb` | HyperSQL DataBase |  |
| `influxdb` | InfluxDB |  |
| `informix` | Informix |  |
| `ingres` | Ingres |  |
| `instantdb` | InstantDB |  |
| `interbase` | InterBase |  |
| `intersystems_cache` | InterSystems Caché |  |
| `mariadb` | MariaDB (This value has stability level RELEASE CANDIDATE) |  |
| `maxdb` | SAP MaxDB |  |
| `memcached` | Memcached |  |
| `mongodb` | MongoDB |  |
| `mssql` | Microsoft SQL Server (This value has stability level RELEASE CANDIDATE) |  |
| `mysql` | MySQL (This value has stability level RELEASE CANDIDATE) |  |
| `neo4j` | Neo4j |  |
| `netezza` | Netezza |  |
| `opensearch` | OpenSearch |  |
| `oracle` | Oracle Database |  |
| `other_sql` | Some other SQL database. Fallback only. See notes. |  |
| `pervasive` | Pervasive PSQL |  |
| `pointbase` | PointBase |  |
| `postgresql` | PostgreSQL (This value has stability level RELEASE CANDIDATE) |  |
| `progress` | Progress Database |  |
| `redis` | Redis |  |
| `redshift` | Amazon Redshift |  |
| `spanner` | Cloud Spanner |  |
| `sqlite` | SQLite |  |
| `sybase` | Sybase |  |
| `teradata` | Teradata |  |
| `trino` | Trino |  |
| `vertica` | Vertica |  |
## Deprecated Database Metrics
"Describes deprecated db metrics attributes."
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `db.client.connections.pool.name` | string | Deprecated, use `db.client.connection.pool.name` instead. | `myDataSource` | 
Replaced by `db.client.connection.pool.name`. |
| `db.client.connections.state` | string | Deprecated, use `db.client.connection.state` instead. | `idle` | 
Replaced by `db.client.connection.state`. |
| `pool.name` | string | Deprecated, use `db.client.connection.pool.name` instead. | `myDataSource` | 
Replaced by `db.client.connection.pool.name`. |
| `state` | string | Deprecated, use `db.client.connection.state` instead. | `idle` | 
Replaced by `db.client.connection.state`. |
---
`db.client.connections.state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `idle` | idle |  |
| `used` | used |  |
---
`state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `idle` | idle |  |
| `used` | used |  |