[BREAKING] move attributes from db metrics to the registry (#909)

Co-authored-by: Joao Grassi <5938087+joaopgrassi@users.noreply.github.com>
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Co-authored-by: Liudmila Molkova <limolkova@microsoft.com>
This commit is contained in:
Alexandra Konrad 2024-04-18 23:26:30 +02:00 committed by GitHub
parent 54cc03eb61
commit bee13d413c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 149 additions and 50 deletions

22
.chloggen/db_metrics.yaml Executable file
View File

@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component: db
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Rename `pool.name` to `db.client.connections.pool.name` and `state` to `db.client.connections.state`.
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
# The values here must be integers.
issues: [909]
# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

View File

@ -12,6 +12,7 @@
- [MSSQL Attributes](#mssql-attributes)
- [Redis Attributes](#redis-attributes)
- [Deprecated DB Attributes](#deprecated-db-attributes)
- [Deprecated DB Metrics Attributes](#deprecated-db-metrics-attributes)
<!-- tocstop -->
@ -20,6 +21,8 @@
<!-- semconv registry.db(omit_requirement_level,tag=db-generic) -->
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `db.client.connections.pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `db.client.connections.state` | string | The state of a connection in the pool | `idle` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `db.collection.name` | string | The name of a collection (table, container) within the database. [1] | `public.users`; `customers` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `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` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `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). [2] | `customers`; `main` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
@ -35,6 +38,13 @@
**[3]:** Query parameters should only be captured when `db.query.text` is parameterized with placeholders.
If a parameter has no name and instead is referenced only by index, then `<key>` SHOULD be the 0-based index.
`db.client.connections.state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `idle` | idle | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `used` | used | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
`db.system` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
@ -208,3 +218,18 @@ If a parameter has no name and instead is referenced only by index, then `<key>`
| `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.query.text`. |
| `db.user` | string | Deprecated, no replacement at this time. | `readonly_user`; `reporting_user` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>No replacement at this time. |
<!-- endsemconv -->
## Deprecated DB Metrics Attributes
<!-- semconv registry.db.metrics.deprecated(omit_requirement_level) -->
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `pool.name` | string | Deprecated, use `db.client.connections.pool.name` instead. | `myDataSource` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.client.connections.pool.name`. |
| `state` | string | Deprecated, use `db.client.connections.state` instead. | `idle` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)<br>Replaced by `db.client.connections.state`. |
`state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `idle` | idle | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `used` | used | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->

View File

@ -52,10 +52,10 @@ This metric is [required][MetricRequired].
<!-- semconv metric.db.client.connections.usage(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `state` | string | The state of a connection in the pool | `idle` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.state`](../attributes-registry/db.md) | string | The state of a connection in the pool | `idle` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
`state` MUST be one of the following:
`db.client.connections.state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
@ -75,7 +75,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.idle.max(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.idle.min`
@ -91,7 +91,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.idle.min(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.max`
@ -107,7 +107,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.max(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.pending_requests`
@ -123,7 +123,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.pending_requests(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.timeouts`
@ -139,7 +139,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.timeouts(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.create_time`
@ -155,7 +155,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.create_time(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.wait_time`
@ -171,7 +171,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.wait_time(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
### Metric: `db.client.connections.use_time`
@ -187,7 +187,7 @@ This metric is [recommended][MetricRecommended].
<!-- semconv metric.db.client.connections.use_time(full) -->
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| `pool.name` | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`db.client.connections.pool.name`](../attributes-registry/db.md) | string | The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. | `myDataSource` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
<!-- endsemconv -->
[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/document-status.md

View File

@ -1,33 +1,4 @@
groups:
- id: attributes.db
type: attribute_group
brief: Describes Database attributes
attributes:
- id: state
stability: experimental
type:
allow_custom_values: false
members:
- id: idle
value: 'idle'
stability: experimental
- id: used
value: 'used'
stability: experimental
requirement_level: required
brief: "The state of a connection in the pool"
examples: ["idle"]
- id: pool.name
type: string
stability: experimental
requirement_level: required
brief: >
The name of the connection pool; unique within the instrumented application.
In case the connection pool implementation doesn't provide a name,
instrumentation should use a combination of `server.address` and `server.port` attributes
formatted as `server.address:server.port`.
examples: ["myDataSource"]
- id: metric.db.client.connections.usage
type: metric
metric_name: db.client.connections.usage
@ -36,8 +7,10 @@ groups:
instrument: updowncounter
unit: "{connection}"
attributes:
- ref: state
- ref: pool.name
- ref: db.client.connections.state
requirement_level: required
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.idle.max
type: metric
@ -47,7 +20,8 @@ groups:
instrument: updowncounter
unit: "{connection}"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.idle.min
type: metric
@ -57,7 +31,8 @@ groups:
instrument: updowncounter
unit: "{connection}"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.max
type: metric
@ -67,7 +42,8 @@ groups:
instrument: updowncounter
unit: "{connection}"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.pending_requests
type: metric
@ -77,7 +53,8 @@ groups:
instrument: updowncounter
unit: "{request}"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.timeouts
type: metric
@ -87,7 +64,8 @@ groups:
instrument: counter
unit: "{timeout}"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.create_time
type: metric
@ -97,7 +75,8 @@ groups:
instrument: histogram
unit: "ms"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.wait_time
type: metric
@ -107,7 +86,8 @@ groups:
instrument: histogram
unit: "ms"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required
- id: metric.db.client.connections.use_time
type: metric
@ -117,4 +97,5 @@ groups:
instrument: histogram
unit: "ms"
attributes:
- ref: pool.name
- ref: db.client.connections.pool.name
requirement_level: required

View File

@ -487,3 +487,27 @@ groups:
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'
- id: client.connections.state
tag: db-generic
stability: experimental
type:
allow_custom_values: true
members:
- id: idle
value: 'idle'
stability: experimental
- id: used
value: 'used'
stability: experimental
brief: "The state of a connection in the pool"
examples: ["idle"]
- id: client.connections.pool.name
tag: db-generic
type: string
stability: experimental
brief: >
The name of the connection pool; unique within the instrumented application.
In case the connection pool implementation doesn't provide a name,
instrumentation should use a combination of `server.address` and `server.port` attributes
formatted as `server.address:server.port`.
examples: ["myDataSource"]

View File

@ -66,3 +66,29 @@ groups:
brief: 'Deprecated, use `db.collection.name` instead.'
deprecated: "Replaced by `db.collection.name`."
examples: 'mytable'
- id: registry.db.metrics.deprecated
type: attribute_group
brief: >
"Describes deprecated db metrics attributes."
attributes:
- id: state
stability: experimental
type:
allow_custom_values: true
members:
- id: idle
value: 'idle'
stability: experimental
- id: used
value: 'used'
stability: experimental
brief: "Deprecated, use `db.client.connections.state` instead."
deprecated: "Replaced by `db.client.connections.state`."
examples: ["idle"]
- id: pool.name
type: string
stability: experimental
brief: "Deprecated, use `db.client.connections.pool.name` instead."
deprecated: "Replaced by `db.client.connections.pool.name`."
examples: ["myDataSource"]

View File

@ -2,6 +2,27 @@ file_format: 1.1.0
schema_url: https://opentelemetry.io/schemas/next
versions:
next:
metrics:
changes:
# https://github.com/open-telemetry/semantic-conventions/pull/909
- rename_attributes:
attribute_map:
state: db.client.connections.state
apply_to_metrics:
- db.client.connections.usage
- rename_attributes:
attribute_map:
pool.name: db.client.connections.pool.name
apply_to_metrics:
- db.client.connections.usage
- db.client.connections.idle.max
- db.client.connections.idle.min
- db.client.connections.max
- db.client.connections.pending_requests
- db.client.connections.timeouts
- db.client.connections.create_time
- db.client.connections.wait_time
- db.client.connections.use_time
1.25.0:
spans: