Skip to content

Latest commit

 

History

History
450 lines (338 loc) · 31.8 KB

database-metrics.md

File metadata and controls

450 lines (338 loc) · 31.8 KB

Semantic Conventions for Database Metrics

Status: Mixed

Warning

Existing database instrumentations that are using v1.24.0 of this document (or prior):

  • SHOULD NOT change the version of the database conventions that they emit by default until the database semantic conventions are marked stable. Conventions include, but are not limited to, attributes, metric and span names, and unit of measure.
  • SHOULD introduce an environment variable OTEL_SEMCONV_STABILITY_OPT_IN in the existing major version which is a comma-separated list of values. If the list of values includes:
    • database - emit the new, stable database conventions, and stop emitting the old experimental database conventions that the instrumentation emitted previously.
    • database/dup - emit both the old and the stable database conventions, allowing for a seamless transition.
    • The default behavior (in the absence of one of these values) is to continue emitting whatever version of the old experimental database conventions the instrumentation was emitting previously.
    • Note: database/dup has higher precedence than database in case both values are present
  • SHOULD maintain (security patching at a minimum) the existing major version for at least six months after it starts emitting both sets of conventions.
  • SHOULD drop the environment variable in the next major version.

Database operation

Metric: db.client.operation.duration

Status: Release Candidate

This metric is required.

When this metric is reported alongside a database operation span, the metric value SHOULD be the same as the database operation span duration.

This metric SHOULD be specified with ExplicitBucketBoundaries of [ 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10 ].

Name Instrument Type Unit (UCUM) Description Stability
db.client.operation.duration Histogram s Duration of database client operations. [1] Experimental

[1]: Batch operations SHOULD be recorded as a single operation.

Attribute Type Description Examples Requirement Level Stability
db.system string The database management system (DBMS) product as identified by the client instrumentation. [1] other_sql; adabas; cache Required Experimental
db.collection.name string The name of a collection (table, container) within the database. [2] public.users; customers Conditionally Required [3] Experimental
db.namespace string The name of the database, fully qualified within the server address and port. [4] customers; test.users Conditionally Required If available. Experimental
db.operation.name string The name of the operation or command being executed. [5] findAndModify; HMSET; SELECT Conditionally Required [6] Experimental
db.response.status_code string Database response status code. [7] 102; ORA-17002; 08P01; 404 Conditionally Required [8] Experimental
error.type string Describes a class of error the operation ended with. [9] timeout; java.net.UnknownHostException; server_certificate_invalid; 500 Conditionally Required If and only if the operation failed. Stable
server.port int Server port number. [10] 80; 8080; 443 Conditionally Required [11] Stable
network.peer.address string Peer address of the database node where the operation was performed. [12] 10.1.2.80; /tmp/my.sock Recommended If applicable for this database system. Stable
network.peer.port int Peer port number of the network connection. 65123 Recommended If and only if network.peer.address is set. Stable
server.address string Name of the database host. [13] example.com; 10.1.2.80; /tmp/my.sock Recommended Stable

[1]: 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 is set to postgresql based on the instrumentation's best knowledge. This attribute has stability level RELEASE CANDIDATE.

[2]: It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used, otherwise db.collection.name SHOULD NOT be captured. This attribute has stability level RELEASE CANDIDATE.

[3]: If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name in the query.

[4]: 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. This attribute has stability level RELEASE CANDIDATE.

[5]: It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. If the operation name is parsed from the query text, it SHOULD be the first operation name found in the query. 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. This attribute has stability level RELEASE CANDIDATE.

[6]: If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query.

[7]: 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. This attribute has stability level RELEASE CANDIDATE.

[8]: If the operation failed and status code is available.

[9]: The error.type SHOULD match the db.response.status_code returned by the database or the client library, or the canonical name of exception that occurred. When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. Instrumentations SHOULD document how error.type is populated.

[10]: When observed from the client side, and when communicating through an intermediary, server.port SHOULD represent the server port behind any intermediaries, for example proxies, if it's available.

[11]: If using a port other than the default port for this DBMS and if server.address is set.

[12]: Semantic conventions for individual database systems SHOULD document whether network.peer.* attributes are applicable. Network peer address and port are useful when the application interacts with individual database nodes directly. If a database operation involved multiple network calls (for example retries), the address of the last contacted node SHOULD be used.

[13]: When observed from the client side, and when communicating through an intermediary, server.address SHOULD represent the server address behind any intermediaries, for example proxies, if it's available.

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) Experimental
cassandra Apache Cassandra Experimental
clickhouse ClickHouse Experimental
cockroachdb CockroachDB Experimental
cosmosdb Microsoft Azure Cosmos DB Experimental
couchbase Couchbase Experimental
couchdb CouchDB Experimental
db2 IBM Db2 Experimental
derby Apache Derby Experimental
dynamodb Amazon DynamoDB Experimental
edb EnterpriseDB Experimental
elasticsearch Elasticsearch Experimental
filemaker FileMaker Experimental
firebird Firebird Experimental
geode Apache Geode Experimental
h2 H2 Experimental
hanadb SAP HANA Experimental
hbase Apache HBase Experimental
hive Apache Hive Experimental
hsqldb HyperSQL DataBase Experimental
influxdb InfluxDB Experimental
informix Informix Experimental
ingres Ingres Experimental
instantdb InstantDB Experimental
interbase InterBase Experimental
intersystems_cache InterSystems Caché Experimental
mariadb MariaDB (This value has stability level RELEASE CANDIDATE) Experimental
maxdb SAP MaxDB Experimental
memcached Memcached Experimental
mongodb MongoDB Experimental
mssql Microsoft SQL Server (This value has stability level RELEASE CANDIDATE) Experimental
mysql MySQL (This value has stability level RELEASE CANDIDATE) Experimental
neo4j Neo4j Experimental
netezza Netezza Experimental
opensearch OpenSearch Experimental
oracle Oracle Database Experimental
other_sql Some other SQL database. Fallback only. See notes. Experimental
pervasive Pervasive PSQL Experimental
pointbase PointBase Experimental
postgresql PostgreSQL (This value has stability level RELEASE CANDIDATE) Experimental
progress Progress Database Experimental
redis Redis Experimental
redshift Amazon Redshift Experimental
spanner Cloud Spanner Experimental
sqlite SQLite Experimental
sybase Sybase Experimental
teradata Teradata Experimental
trino Trino Experimental
vertica Vertica Experimental

error.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
_OTHER A fallback error value to be used when the instrumentation doesn't define a custom value. Stable

Experimental

Connection pools

The following metric instruments describe database client connection pool operations.

Metric: db.client.connection.count

This metric is required.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.count UpDownCounter {connection} The number of connections that are currently in state described by the state attribute Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental
db.client.connection.state string The state of a connection in the pool idle Required Experimental

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 Experimental
used used Experimental

Metric: db.client.connection.idle.max

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.idle.max UpDownCounter {connection} The maximum number of idle open connections allowed Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.idle.min

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.idle.min UpDownCounter {connection} The minimum number of idle open connections allowed Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.max

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.max UpDownCounter {connection} The maximum number of open connections allowed Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.pending_requests

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.pending_requests UpDownCounter {request} The number of current pending requests for an open connection Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.timeouts

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.timeouts Counter {timeout} The number of connection timeouts that have occurred trying to obtain a connection from the pool Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.create_time

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.create_time Histogram s The time it took to create a new connection Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.wait_time

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.wait_time Histogram s The time it took to obtain an open connection from the pool Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental

Metric: db.client.connection.use_time

This metric is recommended.

Name Instrument Type Unit (UCUM) Description Stability
db.client.connection.use_time Histogram s The time between borrowing a connection and returning it to the pool Experimental
Attribute Type Description Examples Requirement Level 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 Required Experimental