-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recommend to capture
db.namespace
from initial connection over not …
…capturing any, also specify `db.namespace` value for PostgreSQL, MySQL and MariaDB (#1437)
- Loading branch information
Showing
10 changed files
with
588 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: enhancement | ||
|
||
# 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: Recommend to capture `db.namespace` from initial connection over not capturing any, also specify `db.namespace` value for PostgreSQL, MySQL and MariaDB | ||
|
||
# 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: [ 1437 ] | ||
|
||
# (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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<!--- Hugo front matter used to generate the website version of this page: | ||
linkTitle: MariaDB | ||
---> | ||
|
||
# Semantic Conventions for MariaDB | ||
|
||
**Status**: [Experimental][DocumentStatus] | ||
|
||
The Semantic Conventions for *MariaDB* extend and override the [Database Semantic Conventions](database-spans.md). | ||
|
||
`db.system` MUST be set to `"mariadb"` and SHOULD be provided **at span creation time**. | ||
|
||
## Attributes | ||
|
||
<!-- semconv db.mariadb --> | ||
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. --> | ||
<!-- see templates/registry/markdown/snippet.md.j2 --> | ||
<!-- prettier-ignore-start --> | ||
<!-- markdownlint-capture --> | ||
<!-- markdownlint-disable --> | ||
|
||
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | | ||
|---|---|---|---|---|---| | ||
| [`db.collection.name`](/docs/attributes-registry/db.md) | string | The name of the SQL table that the operation is acting upon. [1] | `users`; `dbo.products` | `Conditionally Required` [2] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | ||
| [`db.namespace`](/docs/attributes-registry/db.md) | string | The database associated with the connection. [3] | `products`; `customers` | `Conditionally Required` If available without an additional network call. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | ||
| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [4] | `SELECT`; `INSERT`; `UPDATE`; `DELETE`; `CREATE`; `mystoredproc` | `Conditionally Required` [5] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | ||
| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | [Maria DB error code](https://mariadb.com/kb/en/mariadb-error-code-reference/) represented as a string. [6] | `1008`; `3058` | `Conditionally Required` If response has ended with warning or an error. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | ||
| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [7] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | ||
| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [8] | `80`; `8080`; `443` | `Conditionally Required` [9] | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | ||
| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [10] | `SELECT * FROM wuser_table where username = ?`; `SET mykey "WuValue"` | `Recommended` [11] | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | ||
| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [12] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | ||
| [`db.query.parameter.<key>`](/docs/attributes-registry/db.md) | string | A query parameter used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being a string representation of the parameter value. [13] | `someval`; `55` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | ||
|
||
**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. | ||
If the collection name is parsed from the query text, it SHOULD be the first collection name found in the query and it SHOULD match the value provided in the query text including any schema and database name prefix. | ||
For batch operations, if the individual operations are known to have the same collection name then that collection name SHOULD be used, otherwise `db.collection.name` SHOULD NOT be captured. | ||
|
||
**[2]:** If readily available. The collection name MAY be parsed from the query text, in which case it SHOULD be the first collection name found in the query. | ||
|
||
**[3]:** A connection's currently associated database may change during its lifetime, e.g. from executing `USE <database>`. | ||
|
||
If instrumentation is unable to capture the connection's currently associated database on each query | ||
without triggering an additional query to be executed (e.g. `SELECT DATABASE()`), | ||
then it is RECOMMENDED to fallback and use the database provided when the connection was established. | ||
|
||
Instrumentation SHOULD document if `db.namespace` reflects the database provided when the connection was established. | ||
|
||
It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. | ||
|
||
**[4]:** This SHOULD be the SQL command such as `SELECT`, `INSERT`, `UPDATE`, `CREATE`, `DROP`. | ||
In the case of `EXEC`, this SHOULD be the stored procedure name that is being executed. | ||
|
||
**[5]:** If readily available. The operation name MAY be parsed from the query text, in which case it SHOULD be the first operation name found in the query. | ||
|
||
**[6]:** SQL defines [SQLSTATE](https://wikipedia.org/wiki/SQLSTATE) as a database | ||
return code which is adopted by some database systems like PostgreSQL. | ||
See [PostgreSQL error codes](https://www.postgresql.org/docs/current/errcodes-appendix.html) | ||
for the details. | ||
|
||
Other systems like MySQL, Oracle, or MS SQL Server define vendor-specific | ||
error codes. Database SQL drivers usually provide access to both properties. | ||
For example, in Java, the [`SQLException`](https://docs.oracle.com/javase/8/docs/api/java/sql/SQLException.html) | ||
class reports them with `getSQLState()` and `getErrorCode()` methods. | ||
|
||
Instrumentations SHOULD populate the `db.response.status_code` with the | ||
the most specific code available to them. | ||
|
||
Here's a non-exhaustive list of databases that report vendor-specific | ||
codes with granularity higher than SQLSTATE (or don't report SQLSTATE | ||
at all): | ||
|
||
- [DB2 SQL codes](https://www.ibm.com/docs/db2-for-zos/12?topic=codes-sql). | ||
- [Maria DB error codes](https://mariadb.com/kb/en/mariadb-error-code-reference/) | ||
- [Microsoft SQL Server errors](https://docs.microsoft.com/sql/relational-databases/errors-events/database-engine-events-and-errors) | ||
- [MySQL error codes](https://dev.mysql.com/doc/mysql-errors/9.0/en/error-reference-introduction.html) | ||
- [Oracle error codes](https://docs.oracle.com/cd/B28359_01/server.111/b28278/toc.htm) | ||
- [SQLite result codes](https://www.sqlite.org/rescode.html) | ||
|
||
These systems SHOULD set the `db.response.status_code` to a | ||
known vendor-specific error code. If only SQLSTATE is available, | ||
it SHOULD be used. | ||
|
||
When multiple error codes are available and specificity is unclear, | ||
instrumentation SHOULD set the `db.response.status_code` to the | ||
concatenated string of all codes with '/' used as a separator. | ||
|
||
For example, generic DB instrumentation that detected an error and has | ||
SQLSTATE `"42000"` and vendor-specific `1071` should set | ||
`db.response.status_code` to `"42000/1071"`." | ||
|
||
**[7]:** The `error.type` SHOULD match the `db.response.status_code` returned by the database or the client library, or the canonical name of exception that occurred. | ||
When using canonical exception type name, instrumentation SHOULD do the best effort to report the most relevant type. For example, if the original exception is wrapped into a generic one, the original exception SHOULD be preferred. | ||
Instrumentations SHOULD document how `error.type` is populated. | ||
|
||
**[8]:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. | ||
|
||
**[9]:** If using a port other than the default port for this DBMS and if `server.address` is set. | ||
|
||
**[10]:** For sanitization see [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). | ||
For batch operations, if the individual operations are known to have the same query text then that query text SHOULD be used, otherwise all of the individual query texts SHOULD be concatenated with separator `; ` or some other database system specific separator if more applicable. | ||
Even though parameterized query text can potentially have sensitive data, by using a parameterized query the user is giving a strong signal that any sensitive data will be passed as parameter values, and the benefit to observability of capturing the static part of the query text by default outweighs the risk. | ||
|
||
**[11]:** SHOULD be collected by default only if there is sanitization that excludes sensitive information. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext). | ||
|
||
**[12]:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. | ||
|
||
**[13]:** 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. | ||
|
||
|
||
|
||
The following attributes can be important for making sampling decisions | ||
and SHOULD be provided **at span creation time** (if provided at all): | ||
|
||
* [`db.collection.name`](/docs/attributes-registry/db.md) | ||
* [`db.namespace`](/docs/attributes-registry/db.md) | ||
* [`db.operation.name`](/docs/attributes-registry/db.md) | ||
* [`db.query.text`](/docs/attributes-registry/db.md) | ||
* [`server.address`](/docs/attributes-registry/server.md) | ||
* [`server.port`](/docs/attributes-registry/server.md) | ||
|
||
`error.type` 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 | | ||
|---|---|---| | ||
| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | ||
|
||
|
||
|
||
<!-- markdownlint-restore --> | ||
<!-- prettier-ignore-end --> | ||
<!-- END AUTOGENERATED TEXT --> | ||
<!-- endsemconv --> | ||
|
||
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.