Semantic conventions for database client calls

February 11, 2020 ยท View on GitHub

For database client call the SpanKind MUST be Client.

Span name should be set to low cardinality value representing the statement executed on the database. It may be stored procedure name (without argument), sql statement without variable arguments, etc. When it's impossible to get any meaningful representation of the span name, it can be populated using the same value as db.instance.

Note, Redis, Cassandra, HBase and other storage systems may reuse the same attribute names.

Attribute nameNotes and examplesRequired?
db.typeDatabase type. For any SQL database, "sql". For others, the lower-case database category, e.g. "cassandra", "hbase", or "redis".Yes
db.instanceDatabase instance name. E.g., In java, if the jdbc.url="jdbc:mysql://db.example.com:3306/customers", the instance name is "customers".Yes
db.statementA database statement for the given database type. Note, that the value may be sanitized to exclude sensitive information. E.g., for db.type="sql", "SELECT * FROM wuser_table"; for db.type="redis", "SET mykey 'WuValue'".Yes
db.userUsername for accessing database. E.g., "readonly_user" or "reporting_user"No
db.urlJDBC substring like "mysql://db.example.com:3306"Yes

Additionally at least one of net.peer.name or net.peer.ip from the network attributes is required and net.peer.port is recommended.