-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor semantic conventions #1977
Changes from all commits
9f21dfd
f5327cd
1d8689d
78785cf
c2f0af8
8663e5f
26fdb26
2e28d21
fbe392e
0a423bc
fb48cb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Semantic Conventions | ||
|
||
**Status**: [Experimental](../document-status.md) | ||
|
||
Spans and metrics often represent well-known protocols such as HTTP requests, database calls, or message queues. | ||
It is important to record these operations consistently across every implementation in every language. | ||
Predictible, uniform data enables observability backends to perform deep automated analysis. | ||
In OpenTelemetry, these definitions are called **semantic conventions**. | ||
|
||
Semantic conventions are defined for the following operations: | ||
|
||
* [Networking](networking/networking.md): Lower-level session, transport, and network protocols. | ||
* [HTTP](http/http.md): HTTP clients and servers. | ||
* [Database](database/): SQL and NoSQL client calls. | ||
* [RPC/RMI](rpc/): Remote procedure calls (e.g., gRPC). | ||
* [Messaging](messaging/): messaging system components (queues, publish/subscribe, etc.). | ||
* [FaaS](faas/): Function as a Service (e.g., AWS Lambda). | ||
* [Runtime](runtime/): Aspects of programming languages and runtimes such as exceptions, threads, and source code annotations. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Database client calls | ||
|
||
**Status**: [Experimental](../../document-status.md) | ||
|
||
<!-- Re-generate TOC with `markdown-toc --no-first-h1 -i` --> | ||
|
||
<!-- toc --> | ||
|
||
- [Semantic conventions for database client calls](#semantic-conventions-for-database-client-calls) | ||
- [Connection-level attributes](#connection-level-attributes) | ||
- [Notes and well-known identifiers for `db.system`](#notes-and-well-known-identifiers-for-dbsystem) | ||
- [Call-level attributes](#call-level-attributes) | ||
|
||
<!-- tocstop --> | ||
|
||
## Requirements | ||
|
||
**Span kind:** MUST always be `CLIENT`. | ||
|
||
The **span name** SHOULD be set to a low cardinality value representing the statement executed on the database. | ||
It MAY be a stored procedure name (without arguments, DB statement without variable arguments, operation name, etc. | ||
|
||
When it's otherwise impossible to get any meaningful span name, `db.name` MAY be used. | ||
|
||
## Connection-level attributes | ||
|
||
These attributes will usually be the same for all operations performed over the same database connection. | ||
Some database systems may allow a connection to switch to a different `db.user`, for example, and other database systems may not even have the concept of a connection at all. | ||
|
||
<!-- semconv db(tag=connection-level) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `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` | Yes | | ||
| `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;` | No | | ||
| `db.user` | string | Username for accessing the database. | `readonly_user`; `reporting_user` | No | | ||
| [`net.peer.ip`](../networking/networking.md) | string | Remote address of the peer (dotted decimal for IPv4 or [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) | `127.0.0.1` | See below. | | ||
| [`net.peer.name`](../networking/networking.md) | string | Remote hostname or similar, see note below. | `example.com` | See below. | | ||
| [`net.peer.port`](../networking/networking.md) | int | Remote port number. | `80`; `8080`; `443` | Conditional [1] | | ||
| [`net.transport`](../networking/networking.md) | string | Transport protocol used. See note below. | `ip_tcp` | Conditional [2] | | ||
|
||
**[1]:** Required if using a port other than the default port for this DBMS. | ||
|
||
**[2]:** Recommended in general, required for in-process databases (`"inproc"`). | ||
|
||
**Additional attribute requirements:** At least one of the following sets of attributes is required: | ||
|
||
* [`net.peer.name`](../networking/networking.md) | ||
* [`net.peer.ip`](../networking/networking.md) | ||
|
||
`db.system` MUST be one of the following or, if none of the listed values apply, a custom value: | ||
|
||
| Value | Description | | ||
|---|---| | ||
| `other_sql` | Some other SQL database. Fallback only. See notes. | | ||
| `mssql` | Microsoft SQL Server | | ||
| `mysql` | MySQL | | ||
| `oracle` | Oracle Database | | ||
| `db2` | IBM Db2 | | ||
| `postgresql` | PostgreSQL | | ||
| `redshift` | Amazon Redshift | | ||
| `hive` | Apache Hive | | ||
| `cloudscape` | Cloudscape | | ||
| `hsqldb` | HyperSQL DataBase | | ||
| `progress` | Progress Database | | ||
| `maxdb` | SAP MaxDB | | ||
| `hanadb` | SAP HANA | | ||
| `ingres` | Ingres | | ||
| `firstsql` | FirstSQL | | ||
| `edb` | EnterpriseDB | | ||
| `cache` | InterSystems Caché | | ||
| `adabas` | Adabas (Adaptable Database System) | | ||
| `firebird` | Firebird | | ||
| `derby` | Apache Derby | | ||
| `filemaker` | FileMaker | | ||
| `informix` | Informix | | ||
| `instantdb` | InstantDB | | ||
| `interbase` | InterBase | | ||
| `mariadb` | MariaDB | | ||
| `netezza` | Netezza | | ||
| `pervasive` | Pervasive PSQL | | ||
| `pointbase` | PointBase | | ||
| `sqlite` | SQLite | | ||
| `sybase` | Sybase | | ||
| `teradata` | Teradata | | ||
| `vertica` | Vertica | | ||
| `h2` | H2 | | ||
| `coldfusion` | ColdFusion IMQ | | ||
| `cassandra` | Apache Cassandra | | ||
| `hbase` | Apache HBase | | ||
| `mongodb` | MongoDB | | ||
| `redis` | Redis | | ||
| `couchbase` | Couchbase | | ||
| `couchdb` | CouchDB | | ||
| `cosmosdb` | Microsoft Azure Cosmos DB | | ||
| `dynamodb` | Amazon DynamoDB | | ||
| `neo4j` | Neo4j | | ||
| `geode` | Apache Geode | | ||
| `elasticsearch` | Elasticsearch | | ||
| `memcached` | Memcached | | ||
| `cockroachdb` | CockroachDB | | ||
<!-- endsemconv --> | ||
|
||
### Notes and well-known identifiers for `db.system` | ||
|
||
The list above is a non-exhaustive list of well-known identifiers to be specified for `db.system`. | ||
|
||
If a value defined in this list applies to the DBMS to which the request is sent, this value MUST be used. | ||
If no value defined in this list is suitable, a custom value MUST be provided. | ||
This custom value MUST be the name of the DBMS in lowercase and without a version number to stay consistent with existing identifiers. | ||
|
||
It is encouraged to open a PR towards this specification to add missing values to the list, especially when instrumentations for those missing databases are written. | ||
This allows multiple instrumentations for the same database to be aligned and eases analyzing for backends. | ||
|
||
The value `other_sql` is intended as a fallback and MUST only be used if the DBMS is known to be SQL-compliant but the concrete product is not known to the instrumentation. | ||
If the concrete DBMS is known to the instrumentation, its specific identifier MUST be used. | ||
|
||
Back ends could, for example, use the provided identifier to determine the appropriate SQL dialect for parsing the `db.statement`. | ||
|
||
When additional attributes are added that only apply to a specific DBMS, its identifier SHOULD be used as a namespace in the attribute key as for the attributes in the sections below. | ||
|
||
## Call-level attributes | ||
|
||
These attributes may be different for each operation performed, even if the same connection is used for multiple operations. | ||
Usually only one `db.name` will be used per connection though. | ||
|
||
<!-- semconv db(tag=call-level,remove_constraints) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `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). | `customers`; `main` | Conditional [1] | | ||
| `db.statement` | string | The database statement being executed. [2] | `SELECT * FROM wuser_table`; `SET mykey "WuValue"` | Conditional [3] | | ||
| `db.operation` | string | The name of the operation being executed. | `findAndModify`; `HMSET`; `SELECT` | Required, if `db.statement` is not applicable. | | ||
|
||
**[1]:** Required if applicable and no more-specific attribute is defined. | ||
|
||
**[2]:** The value may be sanitized to exclude sensitive information. | ||
|
||
**[3]:** Required if applicable and not explicitly disabled via instrumentation configuration. | ||
<!-- endsemconv --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Cassandra | ||
|
||
**Status**: [Experimental](../../../document-status.md) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like having implementations in separate documents. This will allow us to have experimental documents for implementations, while the overall conventions could be stable. |
||
|
||
## Cassandra Attributes | ||
|
||
<!-- semconv db.tech(tag=call-level-tech-specific-cassandra) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `db.cassandra.keyspace` | string | The name of the keyspace being accessed. To be used instead of the generic `db.name` attribute. | `mykeyspace` | Yes | | ||
| `db.cassandra.page_size` | int | The fetch size used for paging, i.e. how many rows will be returned at once. | `5000` | No | | ||
| `db.cassandra.consistency_level` | string | The consistency level of the query. Based on consistency values from [CQL](https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/dml/dmlConfigConsistency.html). | `all` | No | | ||
| `db.cassandra.table` | string | The name of the primary table that the operation is acting upon, including the schema name (if applicable). [1] | `mytable` | Recommended if available. | | ||
| `db.cassandra.idempotence` | boolean | Whether or not the query is idempotent. | | No | | ||
| `db.cassandra.speculative_execution_count` | int | The number of times a query was speculatively executed. Not set or `0` if the query was not executed speculatively. | `0`; `2` | No | | ||
| `db.cassandra.coordinator.id` | string | The ID of the coordinating node for a query. | `be13faa2-8574-4d71-926d-27f16cf8a7af` | No | | ||
| `db.cassandra.coordinator.dc` | string | The data center of the coordinating node for a query. | `us-west-2` | No | | ||
|
||
**[1]:** This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set. | ||
<!-- endsemconv --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# CouchDB | ||
|
||
**Status**: [Experimental](../../../document-status.md) | ||
|
||
## Requirements | ||
|
||
`db.system` MUST be set to `couchdb`. | ||
|
||
`db.operation` should be set to the HTTP method + the target REST route according to the API reference documentation. | ||
For example, when retrieving a document, `db.operation` would be set to (literally, i.e., without replacing the placeholders with concrete values): [`GET /{db}/{docid}`][CouchDB get doc]. | ||
|
||
[CouchDB get doc]: http://docs.couchdb.org/en/stable/api/document/common.html#get--db-docid |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# HBase | ||
|
||
**Status**: [Experimental](../../../document-status.md) | ||
|
||
## Requirements | ||
|
||
`db.system` MUST be set to `hbase`. | ||
|
||
## Attributes | ||
|
||
<!-- semconv db.hbase(tag=call-level-tech-specific) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `db.hbase.namespace` | string | The [HBase namespace](https://hbase.apache.org/book.html#_namespace) being accessed. To be used instead of the generic `db.name` attribute. | `default` | Yes | | ||
<!-- endsemconv --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# JDMC | ||
|
||
**Status**: [Experimental](../../../document-status.md) | ||
|
||
## Requirements | ||
|
||
`db.system` MUST be set to `jdmc`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JDMC or JDBC? Also, so I understand, "database" implies database-clients and database-servers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it was just clients, and the span kind is CLIENT. |
||
|
||
## Attributes | ||
|
||
<!-- semconv db.jdbc(tag=connection-level-tech-specific,remove_constraints) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `db.jdbc.driver_classname` | 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` | No | | ||
<!-- endsemconv --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# MongoDB | ||
|
||
**Status**: [Experimental](../../document-status.md) | ||
|
||
## Requirements | ||
|
||
`db.system` MUST be set to `mongodb`. | ||
`db.operation` MUST be set to the [MongoDB command name](https://docs.mongodb.com/manual/reference/command/#database-operations), such as `findAndModify`. | ||
|
||
## Attributes | ||
|
||
<!-- semconv db.mongodb(tag=call-level-tech-specific) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `db.mongodb.collection` | string | The collection being accessed within the database stated in `db.name`. | `customers`; `products` | Yes | | ||
<!-- endsemconv --> | ||
|
||
## Example | ||
|
||
| Key | Value | | ||
| :---------------------- | :----------------------------------------------------------- | | ||
| Span name | `"products.findAndModify"` | | ||
| `db.system` | `"mongodb"` | | ||
| `db.connection_string` | not set | | ||
| `db.user` | `"the_user"` | | ||
| `net.peer.name` | `"mongodb0.example.com"` | | ||
| `net.peer.ip` | `"192.0.2.14"` | | ||
| `net.peer.port` | `27017` | | ||
| `net.transport` | `"IP.TCP"` | | ||
| `db.name` | `"shopDb"` | | ||
| `db.statement` | not set | | ||
| `db.operation` | `"findAndModify"` | | ||
| `db.mongodb.collection` | `"products"` | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# MSSQL | ||
|
||
**Status**: [Experimental](../../../document-status.md) | ||
|
||
## Requirements | ||
|
||
`db.system` MUST be set to `mssql`. | ||
|
||
## Attributes | ||
|
||
<!-- semconv db.mssql(tag=connection-level-tech-specific,remove_constraints) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `db.mssql.instance_name` | string | The Microsoft SQL Server [instance name](https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) connecting to. This name is used to determine the port of a named instance. [1] | `MSSQLSERVER` | No | | ||
|
||
**[1]:** If setting a `db.mssql.instance_name`, `net.peer.port` is no longer required (but still recommended if non-standard). | ||
<!-- endsemconv --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# MySQL | ||
|
||
**Status**: [Experimental](../../document-status.md) | ||
|
||
## Example | ||
|
||
| Key | Value | | ||
| :---------------------- | :----------------------------------------------------------- | | ||
| Span name | `"SELECT ShopDb.orders"` | | ||
| `db.system` | `"mysql"` | | ||
| `db.connection_string` | `"Server=shopdb.example.com;Database=ShopDb;Uid=billing_user;TableCache=true;UseCompression=True;MinimumPoolSize=10;MaximumPoolSize=50;"` | | ||
| `db.user` | `"billing_user"` | | ||
| `net.peer.name` | `"shopdb.example.com"` | | ||
| `net.peer.ip` | `"192.0.2.12"` | | ||
| `net.peer.port` | `3306` | | ||
| `net.transport` | `"IP.TCP"` | | ||
| `db.name` | `"ShopDb"` | | ||
| `db.statement` | `"SELECT * FROM orders WHERE order_id = 'o4711'"` | | ||
| `db.operation` | `"SELECT"` | | ||
| `db.sql.table` | `"orders"` | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Redis | ||
|
||
**Status**: [Experimental](../../document-status.md) | ||
|
||
## Requirements | ||
|
||
For **Redis**, the value provided for `db.statement` SHOULD correspond to the syntax of the Redis CLI. | ||
If, for example, the [`HMSET` command][] is invoked, `"HMSET myhash field1 'Hello' field2 'World'"` would be a suitable value for `db.statement`. | ||
|
||
[`HMSET` command]: https://redis.io/commands/hmset | ||
|
||
## Example | ||
|
||
In this example, Redis is connected using a unix domain socket and therefore the connection string and `net.peer.ip` are left out. | ||
Furthermore, `db.name` is not specified as there is no database name in Redis and `db.redis.database_index` is set instead. | ||
|
||
| Key | Value | | ||
| :------------------------ | :-------------------------------------------- | | ||
| Span name | `"HMSET myhash"` | | ||
| `db.system` | `"redis"` | | ||
| `db.connection_string` | not set | | ||
| `db.user` | not set | | ||
| `net.peer.name` | `"/tmp/redis.sock"` | | ||
| `net.transport` | `"Unix"` | | ||
| `db.name` | not set | | ||
| `db.statement` | `"HMSET myhash field1 'Hello' field2 'World"` | | ||
| `db.operation` | not set | | ||
| `db.redis.database_index` | `15` | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SQL | ||
|
||
**Status**: [Experimental](../../document-status.md) | ||
|
||
## Requirements | ||
|
||
**Span name:** SQL statements may have very high cardinality even without arguments. | ||
Unless the statement is known to be of low cardinality, SQL spans SHOULD be named `<db.operation> <db.name>.<db.sql.table>`. | ||
If `db.sql.table` is ambiguous or unavailable, the span SHOULD be named `<db.operation> <db.name>`. | ||
If `db.operation` is ambiguous or unavailable, the span SHOULD be named `<db.name>.<db.sql.table>`. | ||
|
||
`db.operation` SHOULD be set to the SQL keyword. If the SQL statement has an ambiguous operation, or performs more than one operation, this value may be omitted. | ||
|
||
It is not recommended to attempt any client-side parsing of `db.statement` to derive the values for `db.sql.table` or `db.operation`. These attributes should only be included if the library being instrumented already provides them. | ||
|
||
## Attributes | ||
|
||
<!-- semconv db.tech(tag=call-level-tech-specific) --> | ||
| Attribute | Type | Description | Examples | Required | | ||
|---|---|---|---|---| | ||
| `db.sql.table` | string | The name of the primary table that the operation is acting upon, including the schema name (if applicable). [1] | `public.users`; `customers` | Recommended if available. | | ||
|
||
**[1]:** It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set. | ||
<!-- endsemconv --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Telemetry signals? Otherwise you will have to list Logs (and other stuff) in the future.