From efd9345199e986e61488def054a33f193acf7298 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Thu, 30 Nov 2023 02:22:16 -0600 Subject: [PATCH] feat: Add MySQL instance address attribute (#345) Co-authored-by: Alexander Wert --- docs/attributes-registry/db.md | 1 + docs/database/database-spans.md | 1 + model/registry/db.yaml | 8 ++++++++ model/trace/database.yaml | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/docs/attributes-registry/db.md b/docs/attributes-registry/db.md index 1964f71282..c178bbe971 100644 --- a/docs/attributes-registry/db.md +++ b/docs/attributes-registry/db.md @@ -23,6 +23,7 @@ | Attribute | Type | Description | Examples | |---|---|---|---| | `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;` | +| `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` | | `db.name` | string | This 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.operation` | string | The name of the operation being executed, e.g. the [MongoDB command name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as `findAndModify`, or the SQL keyword. [2] | `findAndModify`; `HMSET`; `SELECT` | | `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | diff --git a/docs/database/database-spans.md b/docs/database/database-spans.md index 8a1d7055f7..b352e48252 100644 --- a/docs/database/database-spans.md +++ b/docs/database/database-spans.md @@ -64,6 +64,7 @@ Some database systems may allow a connection to switch to a different `db.user`, | Attribute | Type | Description | Examples | Requirement Level | |---|---|---|---|---| | [`db.connection_string`](../attributes-registry/db.md) | 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`](../attributes-registry/db.md) | 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`](../attributes-registry/db.md) | 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`](../attributes-registry/db.md) | 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/registry/db.yaml b/model/registry/db.yaml index 3ec2d84c66..a17c1046d4 100644 --- a/model/registry/db.yaml +++ b/model/registry/db.yaml @@ -422,3 +422,11 @@ groups: Username for accessing the database. examples: ['readonly_user', 'reporting_user'] tag: db-generic + - id: instance.id + tag: db-generic + 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`. + examples: 'mysql-e26b99z.example.com' diff --git a/model/trace/database.yaml b/model/trace/database.yaml index ed4f57161a..9df75ee20f 100644 --- a/model/trace/database.yaml +++ b/model/trace/database.yaml @@ -46,6 +46,10 @@ groups: tag: connection-level - ref: network.type tag: connection-level + - ref: db.instance.id + tag: connection-level + requirement_level: + recommended: If different from the `server.address` - id: db.mssql type: span