From bee13d413c06f8c1ec7ea3e186e9f2fbff0fc0a5 Mon Sep 17 00:00:00 2001 From: Alexandra Konrad <10500694+trisch-me@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:26:30 +0200 Subject: [PATCH] [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 Co-authored-by: Liudmila Molkova --- .chloggen/db_metrics.yaml | 22 +++++++++++ docs/attributes-registry/db.md | 25 ++++++++++++ docs/database/database-metrics.md | 22 +++++------ model/metrics/database-metrics.yaml | 59 ++++++++++------------------- model/registry/db.yaml | 24 ++++++++++++ model/registry/deprecated/db.yaml | 26 +++++++++++++ schema-next.yaml | 21 ++++++++++ 7 files changed, 149 insertions(+), 50 deletions(-) create mode 100755 .chloggen/db_metrics.yaml diff --git a/.chloggen/db_metrics.yaml b/.chloggen/db_metrics.yaml new file mode 100755 index 0000000000..0e8468e967 --- /dev/null +++ b/.chloggen/db_metrics.yaml @@ -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: diff --git a/docs/attributes-registry/db.md b/docs/attributes-registry/db.md index 45c73f0997..5940f91d71 100644 --- a/docs/attributes-registry/db.md +++ b/docs/attributes-registry/db.md @@ -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) @@ -20,6 +21,8 @@ | 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 `` 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 `` | `db.statement` | string | The database statement being executed. | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | ![Deprecated](https://img.shields.io/badge/-deprecated-red)
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)
No replacement at this time. | + +## Deprecated DB Metrics Attributes + +| 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)
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)
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) | + \ No newline at end of file diff --git a/docs/database/database-metrics.md b/docs/database/database-metrics.md index cff733d139..d779bc7a6d 100644 --- a/docs/database/database-metrics.md +++ b/docs/database/database-metrics.md @@ -52,10 +52,10 @@ This metric is [required][MetricRequired]. | 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]. | 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) | ### Metric: `db.client.connections.idle.min` @@ -91,7 +91,7 @@ This metric is [recommended][MetricRecommended]. | 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) | ### Metric: `db.client.connections.max` @@ -107,7 +107,7 @@ This metric is [recommended][MetricRecommended]. | 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) | ### Metric: `db.client.connections.pending_requests` @@ -123,7 +123,7 @@ This metric is [recommended][MetricRecommended]. | 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) | ### Metric: `db.client.connections.timeouts` @@ -139,7 +139,7 @@ This metric is [recommended][MetricRecommended]. | 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) | ### Metric: `db.client.connections.create_time` @@ -155,7 +155,7 @@ This metric is [recommended][MetricRecommended]. | 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) | ### Metric: `db.client.connections.wait_time` @@ -171,7 +171,7 @@ This metric is [recommended][MetricRecommended]. | 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) | ### Metric: `db.client.connections.use_time` @@ -187,7 +187,7 @@ This metric is [recommended][MetricRecommended]. | 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) | [DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/document-status.md diff --git a/model/metrics/database-metrics.yaml b/model/metrics/database-metrics.yaml index d172d9e4b6..cce9257e4f 100644 --- a/model/metrics/database-metrics.yaml +++ b/model/metrics/database-metrics.yaml @@ -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 diff --git a/model/registry/db.yaml b/model/registry/db.yaml index cce3c33972..25532ab6a4 100644 --- a/model/registry/db.yaml +++ b/model/registry/db.yaml @@ -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"] diff --git a/model/registry/deprecated/db.yaml b/model/registry/deprecated/db.yaml index a5a6390b1b..de58225c67 100644 --- a/model/registry/deprecated/db.yaml +++ b/model/registry/deprecated/db.yaml @@ -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"] diff --git a/schema-next.yaml b/schema-next.yaml index 430901253a..5fc05edea2 100644 --- a/schema-next.yaml +++ b/schema-next.yaml @@ -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: