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 15, 2023
1 parent a4c60f7 commit 0240d14
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/database/mysql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: MSSQL
--->

# Semantic Conventions for MySQL

**Status**: [Experimental][DocumentStatus]

The Semantic Conventions for the [MySQL](https://www.mysql.com/) extend and override the [Database Semantic Conventions](database-spans.md)
that describe common database operations attributes in addition to the Semantic Conventions
described on this page.

`db.system` MUST be set to `"mysql"`.

## Connection-level attributes

<!-- semconv db.mysql(tag=connection-level-tech-specific) -->
| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| [`db.jdbc.driver_classname`](database-spans.md) | string | The fully-qualified class name of the [Java Database Connectivity (JDBC)](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/) driver used to connect. | `org.postgresql.Driver`; `com.microsoft.sqlserver.jdbc.SQLServerDriver` | Recommended |
| `db.mysql.instance.address` | string | The hostname of the MySQL server instance bound to the current connection. This is useful in cases where the client is connecting to a MySQL server via a proxy or in a clustered environment. This client may obtain this value using queries like `select @@hostname`. | `mysql-e26b99z.example.com` | Recommended: If different from the `server.address` |
<!-- endsemconv -->

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.22.0/specification/document-status.md
19 changes: 19 additions & 0 deletions model/trace/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,24 @@ groups:
connecting to. This name is used to determine the port of a named instance.
examples: 'MSSQLSERVER'

- id: db.mysql
prefix: db.mysql
type: span
extends: db
brief: >
Connection-level attributes for MySQL Server
attributes:
- id: instance.address
tag: connection-level-tech-specific
type: string
brief: >
The hostname of the MySQL server instance bound to the current connection.
This is useful in cases where the client is connecting to a MySQL server via a proxy or in a clustered environment.
This client may obtain this value using queries like `select @@hostname`.
requirement_level:
recommended: If different from the `server.address`
examples: 'mysql-e26b99z.example.com'

- id: db.cassandra
prefix: db.cassandra
type: span
Expand Down Expand Up @@ -611,3 +629,4 @@ groups:
- include: 'db.mongodb'
- include: 'db.sql'
- include: 'db.cosmosdb'
- include: 'db.mysql'

0 comments on commit 0240d14

Please sign in to comment.