From dbc3e1e44e77c1baef385cdf1c9783c8ae9f2e6a Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Tue, 26 Sep 2023 02:45:56 +0000 Subject: [PATCH] feat: Add MySQL instance address attribute At GitHub we run MySQL in multi-node clusters and are often interested in knowing the hostname of a node that is executing a query or command. In order to acheive this we added an attribute to the Trilogy instrumentation named `db.mysql.instance.address` which is populated with the hostname of the node: This change adds the attribute to the database model as a MySQL specific connection attribute. --- docs/database/database-spans.md | 1 + model/trace/database.yaml | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/database/database-spans.md b/docs/database/database-spans.md index 1d3f6471f9..48f49c51d9 100644 --- a/docs/database/database-spans.md +++ b/docs/database/database-spans.md @@ -65,6 +65,7 @@ Some database systems may allow a connection to switch to a different `db.user`, | Attribute | Type | Description | Examples | Requirement Level | |---|---|---|---|---| | `db.connection_string` | string | The connection string used to connect to the database. It is recommended to remove embedded credentials. | `Server=(localdb)\v11.0;Integrated Security=true;` | Recommended | +| `db.instance.id` | string | An 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` | Recommended: If different from the `server.address` | | `db.system` | string | An identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers. | `other_sql` | Required | | `db.user` | string | Username for accessing the database. | `readonly_user`; `reporting_user` | Recommended | | [`network.peer.address`](../attributes-registry/network.md) | string | Peer address of the network connection - IP address or Unix domain socket name. | `10.1.2.80`; `/tmp/my.sock` | Recommended | diff --git a/model/trace/database.yaml b/model/trace/database.yaml index 7540e58c15..cb19625983 100644 --- a/model/trace/database.yaml +++ b/model/trace/database.yaml @@ -246,6 +246,16 @@ groups: tag: connection-level - ref: network.type tag: connection-level + - id: instance.id + tag: connection-level + type: string + brief: > + An 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`. + requirement_level: + recommended: If different from the `server.address` + examples: 'mysql-e26b99z.example.com' - id: db.mssql prefix: db.mssql