Database

Generic Database Attributes

AttributeTypeDescriptionExamples
db.connection_stringstringThe connection string used to connect to the database. It is recommended to remove embedded credentials.Server=(localdb)\v11.0;Integrated Security=true;
db.instance.idstringAn identifier (address, unique name, or any other identifier) of the database instance that is executing queries or mutations on the current connection. This is useful in cases where the database is running in a clustered environment and the instrumentation is able to record the node executing the query. The client may obtain this value in databases like MySQL using queries like select @@hostname.mysql-e26b99z.example.com
db.namestringThis attribute is used to report the name of the database being accessed. For commands that switch the database, this should be set to the target database (even if the command fails). [1]customers; main
db.operationstringThe name of the operation being executed, e.g. the MongoDB command name such as findAndModify, or the SQL keyword. [2]findAndModify; HMSET; SELECT
db.statementstringThe database statement being executed.SELECT * FROM wuser_table; SET mykey "WuValue"
db.systemstringAn identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers.other_sql
db.userstringUsername for accessing the database.readonly_user; reporting_user

[1]: In some SQL databases, the database name to be used is called “schema name”. In case there are multiple layers that could be considered for database name (e.g. Oracle instance name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema name).

[2]: When setting this to an SQL keyword, it is not recommended to attempt any client-side parsing of db.statement just to get this property, but it should be set if the operation name is provided by the library being instrumented. If the SQL statement has an ambiguous operation, or performs more than one operation, this value may be omitted.

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.

ValueDescription
other_sqlSome other SQL database. Fallback only. See notes.
mssqlMicrosoft SQL Server
mssqlcompactMicrosoft SQL Server Compact
mysqlMySQL
oracleOracle Database
db2IBM Db2
postgresqlPostgreSQL
redshiftAmazon Redshift
hiveApache Hive
cloudscapeCloudscape
hsqldbHyperSQL DataBase
progressProgress Database
maxdbSAP MaxDB
hanadbSAP HANA
ingresIngres
firstsqlFirstSQL
edbEnterpriseDB
cacheInterSystems Caché
adabasAdabas (Adaptable Database System)
firebirdFirebird
derbyApache Derby
filemakerFileMaker
informixInformix
instantdbInstantDB
interbaseInterBase
mariadbMariaDB
netezzaNetezza
pervasivePervasive PSQL
pointbasePointBase
sqliteSQLite
sybaseSybase
teradataTeradata
verticaVertica
h2H2
coldfusionColdFusion IMQ
cassandraApache Cassandra
hbaseApache HBase
mongodbMongoDB
redisRedis
couchbaseCouchbase
couchdbCouchDB
cosmosdbMicrosoft Azure Cosmos DB
dynamodbAmazon DynamoDB
neo4jNeo4j
geodeApache Geode
elasticsearchElasticsearch
memcachedMemcached
cockroachdbCockroachDB
opensearchOpenSearch
clickhouseClickHouse
spannerCloud Spanner
trinoTrino

Cassandra Attributes

AttributeTypeDescriptionExamples
db.cassandra.consistency_levelstringThe consistency level of the query. Based on consistency values from CQL.all
db.cassandra.coordinator.dcstringThe data center of the coordinating node for a query.us-west-2
db.cassandra.coordinator.idstringThe ID of the coordinating node for a query.be13faa2-8574-4d71-926d-27f16cf8a7af
db.cassandra.idempotencebooleanWhether or not the query is idempotent.
db.cassandra.page_sizeintThe fetch size used for paging, i.e. how many rows will be returned at once.5000
db.cassandra.speculative_execution_countintThe number of times a query was speculatively executed. Not set or 0 if the query was not executed speculatively.0; 2
db.cassandra.tablestringThe name of the primary Cassandra table that the operation is acting upon, including the keyspace name (if applicable). [1]mytable

[1]: This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of db.statement just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.

db.cassandra.consistency_level MUST be one of the following:

ValueDescription
allall
each_quorumeach_quorum
quorumquorum
local_quorumlocal_quorum
oneone
twotwo
threethree
local_onelocal_one
anyany
serialserial
local_seriallocal_serial

CosmosDB Attributes

AttributeTypeDescriptionExamples
db.cosmosdb.client_idstringUnique Cosmos client instance id.3ba4827d-4422-483f-b59f-85b74211c11d
db.cosmosdb.connection_modestringCosmos client connection mode.gateway
db.cosmosdb.containerstringCosmos DB container name.anystring
db.cosmosdb.operation_typestringCosmosDB Operation Type.Invalid
db.cosmosdb.request_chargedoubleRU consumed for that operation46.18; 1.0
db.cosmosdb.request_content_lengthintRequest payload size in bytes
db.cosmosdb.status_codeintCosmos DB status code.200; 201
db.cosmosdb.sub_status_codeintCosmos DB sub status code.1000; 1002

db.cosmosdb.connection_mode MUST be one of the following:

ValueDescription
gatewayGateway (HTTP) connections mode
directDirect connection.

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.

ValueDescription
Invalidinvalid
Createcreate
Patchpatch
Readread
ReadFeedread_feed
Deletedelete
Replacereplace
Executeexecute
Queryquery
Headhead
HeadFeedhead_feed
Upsertupsert
Batchbatch
QueryPlanquery_plan
ExecuteJavaScriptexecute_javascript

Elasticsearch Attributes

AttributeTypeDescriptionExamples
db.elasticsearch.cluster.namestringRepresents the identifier of an Elasticsearch cluster.e9106fc68e3044f0b1475b04bf4ffd5f
db.elasticsearch.node.namestringRepresents the human-readable identifier of the node/instance to which a request was routed.instance-0000000001
db.elasticsearch.path_parts.<key>stringA dynamic value in the url path. [1]db.elasticsearch.path_parts.index=test-index; db.elasticsearch.path_parts.doc_id=123

[1]: Many Elasticsearch url paths allow dynamic values. These SHOULD be recorded in span attributes in the format db.elasticsearch.path_parts.<key>, where <key> is the url path part name. The implementation SHOULD reference the elasticsearch schema in order to map the path part values to their names.

JDBC Attributes

AttributeTypeDescriptionExamples
db.jdbc.driver_classnamestringThe fully-qualified class name of the Java Database Connectivity (JDBC) driver used to connect.org.postgresql.Driver; com.microsoft.sqlserver.jdbc.SQLServerDriver

MongoDB Attributes

AttributeTypeDescriptionExamples
db.mongodb.collectionstringThe MongoDB collection being accessed within the database stated in db.name.customers; products

MSSQL Attributes

AttributeTypeDescriptionExamples
db.mssql.instance_namestringThe Microsoft SQL Server instance name connecting to. This name is used to determine the port of a named instance. [1]MSSQLSERVER

[1]: If setting a db.mssql.instance_name, server.port is no longer required (but still recommended if non-standard).

Redis Attributes

AttributeTypeDescriptionExamples
db.redis.database_indexintThe index of the database being accessed as used in the SELECT command, provided as an integer. To be used instead of the generic db.name attribute.0; 1; 15

SQL Attributes

AttributeTypeDescriptionExamples
db.sql.tablestringThe name of the primary table that the operation is acting upon, including the database name (if applicable). [1]public.users; customers

[1]: It is not recommended to attempt any client-side parsing of db.statement just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set.