From 463c458daf9886e1880c158762ab406879763397 Mon Sep 17 00:00:00 2001 From: ET Date: Tue, 7 Jul 2020 09:22:26 -0700 Subject: [PATCH] Add more database-specific semantic attributes (#899) * Adds Database-specific semantic attributes. * Add CHANGELOG Co-authored-by: Tyler Yahn --- CHANGELOG.md | 1 + api/standard/trace.go | 61 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ff2f2705..1b67f05c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Add `peer.service` semantic attribute. (#898) +- Add database-specific semantic attributes. (#899) - Add semantic convention for `faas.coldstart` and `container.id`. (#909) ### Changed diff --git a/api/standard/trace.go b/api/standard/trace.go index 2f322d0d0..83eae79e8 100644 --- a/api/standard/trace.go +++ b/api/standard/trace.go @@ -124,23 +124,66 @@ var ( HTTPFlavorQUIC = HTTPFlavorKey.String("QUIC") ) -// Standard attribute keys for database clients. +// Standard attribute keys for database connections. const ( - // Database type. For any SQL database, "sql". For others, the - // lower-case database category, e.g. "cassandra", "hbase", or "redis". - DBTypeKey = kv.Key("db.type") + // Identifier for the database system (DBMS) being used. + DBSystemKey = kv.Key("db.system") + // Database Connection String with embedded credentials removed. + DBConnectionStringKey = kv.Key("db.connection_string") + + // Username for accessing database. + DBUserKey = kv.Key("db.user") +) + +var ( + DBSystemDB2 = DBSystemKey.String("db2") // IBM DB2 + DBSystemDerby = DBSystemKey.String("derby") // Apache Derby + DBSystemHive = DBSystemKey.String("hive") // Apache Hive + DBSystemMariaDB = DBSystemKey.String("mariadb") // MariaDB + DBSystemMSSql = DBSystemKey.String("mssql") // Microsoft SQL Server + DBSystemMySQL = DBSystemKey.String("mysql") // MySQL + DBSystemOracle = DBSystemKey.String("oracle") // Oracle Database + DBSystemPostgres = DBSystemKey.String("postgresql") // PostgreSQL + DBSystemSqlite = DBSystemKey.String("sqlite") // SQLite + DBSystemTeradata = DBSystemKey.String("teradata") // Teradata + DBSystemOtherSQL = DBSystemKey.String("other_sql") // Some other Sql database. Fallback only + DBSystemCassandra = DBSystemKey.String("cassandra") // Cassandra + DBSystemCosmosDB = DBSystemKey.String("cosmosdb") // Microsoft Azure CosmosDB + DBSystemCouchbase = DBSystemKey.String("couchbase") // Couchbase + DBSystemCouchDB = DBSystemKey.String("couchdb") // CouchDB + DBSystemDynamoDB = DBSystemKey.String("dynamodb") // Amazon DynamoDB + DBSystemHBase = DBSystemKey.String("hbase") // HBase + DBSystemMongodb = DBSystemKey.String("mongodb") // MongoDB + DBSystemNeo4j = DBSystemKey.String("neo4j") // Neo4j + DBSystemRedis = DBSystemKey.String("redis") // Redis +) + +// Standard attribute keys for database calls. +const ( // Database instance name. - DBInstanceKey = kv.Key("db.instance") + DBNameKey = kv.Key("db.name") // A database statement for the given database type. DBStatementKey = kv.Key("db.statement") - // Username for accessing database. - DBUserKey = kv.Key("db.user") + // A database operation for the given database type. + DBOperationKey = kv.Key("db.operation") +) - // Database URL. - DBUrlKey = kv.Key("db.url") +// Database technology-specific attributes +const ( + // Name of the Cassandra keyspace accessed. Use instead of `db.name`. + DBCassandraKeyspaceKey = kv.Key("db.cassandra.keyspace") + + // HBase namespace accessed. Use instead of `db.name`. + DBHBaseNamespaceKey = kv.Key("db.hbase.namespace") + + // Index of Redis database accessed. Use instead of `db.name`. + DBRedisDBIndexKey = kv.Key("db.redis.database_index") + + // Collection being accessed within the database in `db.name`. + DBMongoDBCollectionKey = kv.Key("db.mongodb.collection") ) // Standard attribute keys for RPC.