Skip to content

Commit

Permalink
feat: Add MySQL instance address attribute
Browse files Browse the repository at this point in the history
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:

<open-telemetry/opentelemetry-ruby-contrib#487>

This change adds the attribute to the database model as a MySQL specific connection attribute.
  • Loading branch information
arielvalentin committed Nov 19, 2023
1 parent a4c60f7 commit dbc3e1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/database/database-spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
10 changes: 10 additions & 0 deletions model/trace/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbc3e1e

Please sign in to comment.