285 lines
18 KiB
Markdown
285 lines
18 KiB
Markdown
<!--- Hugo front matter used to generate the website version of this page:
|
|
linkTitle: Cosmos DB
|
|
--->
|
|
|
|
# Semantic Conventions for Microsoft Cosmos DB
|
|
|
|
**Status**: [Experimental][DocumentStatus]
|
|
|
|
The Semantic Conventions for [Microsoft Cosmos DB](https://azure.microsoft.com/products/cosmos-db/)
|
|
extend and override the [Database Semantic Conventions](database-spans.md).
|
|
|
|
## Attributes
|
|
|
|
`db.system` MUST be set to `"cosmosdb"` and SHOULD be provided **at span creation time**.
|
|
|
|
Cosmos DB instrumentation includes call-level (public API) surface spans and network spans. Depending on the connection mode (Gateway or Direct), network-level spans may also be created.
|
|
|
|
<!-- semconv db.cosmosdb -->
|
|
<!-- 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 | Cosmos DB container name. [1] | `public.users`; `customers` | `Conditionally Required` if available |  |
|
|
| [`db.cosmosdb.connection_mode`](/docs/attributes-registry/db.md) | string | Cosmos client connection mode. | `gateway`; `direct` | `Conditionally Required` [2] |  |
|
|
| [`db.cosmosdb.operation_type`](/docs/attributes-registry/db.md) | string | Cosmos DB Operation Type. | `batch`; `create`; `delete` | `Conditionally Required` when performing one of the operations in this list |  |
|
|
| [`db.cosmosdb.request_charge`](/docs/attributes-registry/db.md) | double | RU consumed for that operation | `46.18`; `1.0` | `Conditionally Required` when available |  |
|
|
| [`db.cosmosdb.sub_status_code`](/docs/attributes-registry/db.md) | int | Cosmos DB sub status code. | `1000`; `1002` | `Conditionally Required` when response was received and contained sub-code. |  |
|
|
| [`db.namespace`](/docs/attributes-registry/db.md) | string | The name of the database, fully qualified within the server address and port. | `customers`; `test.users` | `Conditionally Required` If available. |  |
|
|
| [`db.operation.name`](/docs/attributes-registry/db.md) | string | The name of the operation or command being executed. [3] | `create_item`; `query_items`; `read_item` | `Conditionally Required` [4] |  |
|
|
| [`db.response.status_code`](/docs/attributes-registry/db.md) | string | Cosmos DB status code. [5] | `200`; `201` | `Conditionally Required` if response was received |  |
|
|
| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [6] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` If and only if the operation failed. |  |
|
|
| [`server.port`](/docs/attributes-registry/server.md) | int | Server port number. [7] | `80`; `8080`; `443` | `Conditionally Required` If not default (443). |  |
|
|
| [`az.namespace`](/docs/attributes-registry/azure.md) | string | [Azure Resource Provider Namespace](https://learn.microsoft.com/azure/azure-resource-manager/management/azure-services-resource-providers) as recognized by the client. [8] | `Microsoft.DocumentDB` | `Recommended` |  |
|
|
| [`db.cosmosdb.client_id`](/docs/attributes-registry/db.md) | string | Unique Cosmos client instance id. | `3ba4827d-4422-483f-b59f-85b74211c11d` | `Recommended` |  |
|
|
| [`db.cosmosdb.request_content_length`](/docs/attributes-registry/db.md) | int | Request payload size in bytes | | `Recommended` |  |
|
|
| [`db.operation.batch.size`](/docs/attributes-registry/db.md) | int | The number of queries included in a batch operation. [9] | `2`; `3`; `4` | `Recommended` |  |
|
|
| [`db.query.summary`](/docs/attributes-registry/db.md) | string | Low cardinality representation of a database query text. [10] | `SELECT wuser_table`; `INSERT shipping_details SELECT orders`; `get user by id` | `Recommended` [11] |  |
|
|
| [`db.query.text`](/docs/attributes-registry/db.md) | string | The database query being executed. [12] | `SELECT * FROM wuser_table where username = ?`; `SET mykey ?` | `Recommended` [13] |  |
|
|
| [`server.address`](/docs/attributes-registry/server.md) | string | Name of the database host. [14] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` |  |
|
|
| [`user_agent.original`](/docs/attributes-registry/user-agent.md) | string | Full user-agent string is generated by Cosmos DB SDK [15] | `cosmos-netstandard-sdk/3.23.0\|3.23.1\|1\|X64\|Linux 5.4.0-1098-azure 104 18\|.NET Core 3.1.32\|S\|` | `Recommended` |  |
|
|
| [`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. [16] | `someval`; `55` | `Opt-In` |  |
|
|
|
|
**[1]:** It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.
|
|
|
|
**[2]:** if not `gateway` (the default value is assumed to be `gateway`).
|
|
|
|
**[3]:** The `db.operation.name` has the following list of well-known values.
|
|
If one of them applies, then the respective value MUST be used.
|
|
|
|
Batch operations:
|
|
|
|
- `execute_batch`
|
|
|
|
Bulk operations:
|
|
|
|
- `execute_bulk` SHOULD be used on spans reported for methods like
|
|
[`executeBulkOperations`](https://javadoc.io/doc/com.azure/azure-cosmos/latest/com/azure/cosmos/CosmosAsyncContainer.html#executeBulkOperations)).
|
|
which represents a bulk execution of multiple operations.
|
|
- `bulk_{operation name}` (`bulk_create_item`, `bulk_upsert_item`, etc) SHOULD be used on spans describing individual operations (when they are reported)
|
|
within the bulk. This pattern SHOULD be used when instrumentation creates span per each operation, but operations are buffered and then performed in bulk.
|
|
For example, this applies when [`AllowBulkExecution`](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.allowbulkexecution)
|
|
property is configured on the `Microsoft.Azure.Cosmos` client.
|
|
|
|
Change feed operations:
|
|
|
|
- `query_change_feed`
|
|
|
|
Conflicts operations:
|
|
|
|
- `delete_conflict`
|
|
- `query_conflicts`
|
|
- `read_all_conflicts`
|
|
- `read_conflict`
|
|
|
|
Container operations:
|
|
|
|
- `create_container`
|
|
- `create_container_if_not_exists`
|
|
- `delete_container`
|
|
- `query_containers`
|
|
- `read_all_containers`
|
|
- `read_container`
|
|
- `read_container_throughput`
|
|
- `replace_container`
|
|
- `replace_container_throughput`
|
|
|
|
Database operations:
|
|
|
|
- `create_database`
|
|
- `create_database_if_not_exists`
|
|
- `delete_database`
|
|
- `query_databases`
|
|
- `read_all_databases`
|
|
- `read_database`
|
|
- `read_database_throughput`
|
|
- `replace_database_throughput`
|
|
|
|
Encryption key operations:
|
|
|
|
- `create_client_encryption_key`
|
|
- `query_client_encryption_keys`
|
|
- `read_all_client_encryption_keys`
|
|
- `read_client_encryption_key`
|
|
- `replace_client_encryption_key`
|
|
|
|
Item operations:
|
|
|
|
- `create_item`
|
|
- `delete_all_items_by_partition_key`
|
|
- `delete_item`
|
|
- `patch_item`
|
|
- `query_items`
|
|
- `read_all_items`
|
|
- `read_all_items_of_logical_partition`
|
|
- `read_many_items`
|
|
- `read_item`
|
|
- `replace_item`
|
|
- `upsert_item`
|
|
|
|
Permission operations:
|
|
|
|
- `create_permission`
|
|
- `delete_permission`
|
|
- `query_permissions`
|
|
- `read_all_permissions`
|
|
- `read_permission`
|
|
- `replace_permission`
|
|
- `upsert_permission`
|
|
|
|
Stored procedure operations:
|
|
|
|
- `create_stored_procedure`
|
|
- `delete_stored_procedure`
|
|
- `execute_stored_procedure`
|
|
- `query_stored_procedures`
|
|
- `read_all_stored_procedures`
|
|
- `read_stored_procedure`
|
|
- `replace_stored_procedure`
|
|
|
|
Trigger operations:
|
|
|
|
- `create_trigger`
|
|
- `delete_trigger`
|
|
- `query_triggers`
|
|
- `read_all_triggers`
|
|
- `read_trigger`
|
|
- `replace_trigger`
|
|
|
|
User operations:
|
|
|
|
- `create_user`
|
|
- `delete_user`
|
|
- `query_users`
|
|
- `read_all_users`
|
|
- `read_user`
|
|
- `replace_user`
|
|
- `upsert_user`
|
|
|
|
User-defined function operations:
|
|
|
|
- `create_user_defined_function`
|
|
- `delete_user_defined_function`
|
|
- `query_user_defined_functions`
|
|
- `read_all_user_defined_functions`
|
|
- `read_user_defined_function`
|
|
|
|
If none of them applies, it's RECOMMENDED to use language-agnostic representation of
|
|
client method name in snake_case. Instrumentations SHOULD document
|
|
additional values when introducing new operations.
|
|
|
|
**[4]:** If readily available and if there is a single operation name that describes the database call. The operation name MAY be parsed from the query text, in which case it SHOULD be the single operation name found in the query.
|
|
|
|
**[5]:** The status code returned by the database. Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes.
|
|
Semantic conventions for individual database systems SHOULD document what `db.response.status_code` means in the context of that system.
|
|
This attribute has stability level RELEASE CANDIDATE.
|
|
|
|
**[6]:** 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.
|
|
|
|
**[7]:** 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.
|
|
|
|
**[8]:** When `az.namespace` attribute is populated, it MUST be set to `Microsoft.DocumentDB` for all operations performed by Cosmos DB client.
|
|
|
|
**[9]:** Operations are only considered batches when they contain two or more operations, and so `db.operation.batch.size` SHOULD never be `1`.
|
|
This attribute has stability level RELEASE CANDIDATE.
|
|
|
|
**[10]:** `db.query.summary` provides static summary of the query text. It describes a class of database queries and is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries.
|
|
Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not available, instrumentations that support query parsing SHOULD generate a summary following [Generating query summary](../../docs/database/database-spans.md#generating-a-summary-of-the-quey-text) section.
|
|
This attribute has stability level RELEASE CANDIDATE.
|
|
|
|
**[11]:** if readily available or if instrumentation supports query summarization.
|
|
|
|
**[12]:** 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.
|
|
This attribute has stability level RELEASE CANDIDATE.
|
|
|
|
**[13]:** Non-parameterized query text SHOULD NOT be collected by default unless there is sanitization that excludes sensitive data, e.g. by redacting all literal values present in the query text. See [Sanitization of `db.query.text`](../../docs/database/database-spans.md#sanitization-of-dbquerytext).
|
|
Parameterized query text SHOULD be collected by default (the query parameter values themselves are opt-in, see [`db.query.parameter.<key>`](../../docs/attributes-registry/db.md)).
|
|
|
|
**[14]:** 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.
|
|
|
|
**[15]:** The user-agent value is generated by SDK which is a combination of<br> `sdk_version` : Current version of SDK. e.g. 'cosmos-netstandard-sdk/3.23.0'<br> `direct_pkg_version` : Direct package version used by Cosmos DB SDK. e.g. '3.23.1'<br> `number_of_client_instances` : Number of cosmos client instances created by the application. e.g. '1'<br> `type_of_machine_architecture` : Machine architecture. e.g. 'X64'<br> `operating_system` : Operating System. e.g. 'Linux 5.4.0-1098-azure 104 18'<br> `runtime_framework` : Runtime Framework. e.g. '.NET Core 3.1.32'<br> `failover_information` : Generated key to determine if region failover enabled.
|
|
Format Reg-{D (Disabled discovery)}-S(application region)|L(List of preferred regions)|N(None, user did not configure it).
|
|
Default value is "NS".
|
|
|
|
**[16]:** 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.
|
|
This attribute has stability level RELEASE CANDIDATE.
|
|
|
|
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.summary`](/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)
|
|
|
|
`db.cosmosdb.connection_mode` 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 |
|
|
|---|---|---|
|
|
| `direct` | Direct connection. |  |
|
|
| `gateway` | Gateway (HTTP) connections mode |  |
|
|
|
|
`db.cosmosdb.operation_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 |
|
|
|---|---|---|
|
|
| `batch` | batch |  |
|
|
| `create` | create |  |
|
|
| `delete` | delete |  |
|
|
| `execute` | execute |  |
|
|
| `execute_javascript` | execute_javascript |  |
|
|
| `head` | head |  |
|
|
| `head_feed` | head_feed |  |
|
|
| `invalid` | invalid |  |
|
|
| `patch` | patch |  |
|
|
| `query` | query |  |
|
|
| `query_plan` | query_plan |  |
|
|
| `read` | read |  |
|
|
| `read_feed` | read_feed |  |
|
|
| `replace` | replace |  |
|
|
| `upsert` | upsert |  |
|
|
|
|
`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. |  |
|
|
|
|
<!-- markdownlint-restore -->
|
|
<!-- prettier-ignore-end -->
|
|
<!-- END AUTOGENERATED TEXT -->
|
|
<!-- endsemconv -->
|
|
|
|
## Example
|
|
|
|
| Key | Value |
|
|
|:-------------------------------------| :------------------- |
|
|
| Span name | `"read_item orders"` |
|
|
| `az.namespace` | `"Microsoft.DocumentDB"` |
|
|
| `db.system` | `"cosmosdb"` |
|
|
| `db.collection.name` | `"orders"` |
|
|
| `db.namespace` | `"ShopDb"` |
|
|
| `db.operation.name` | `"read_item"` |
|
|
| `server.address` | `"account.documents.azure.com"` |
|
|
| `db.cosmosdb.client_id` | `"3ba4827d-4422-483f-b59f-85b74211c11d"` |
|
|
| `db.cosmosdb.operation_type` | `"read"` |
|
|
| `user_agent.original` | `"cosmos-netstandard-sdk/3.23.0\|3.23.1\|1\|X64\|Linux 5.4.0-1098-azure 104 18\|.NET Core 3.1.32\|S\|"` |
|
|
| `db.cosmosdb.request_content_length` | `20` |
|
|
| `db.cosmosdb.status_code` | `201` |
|
|
| `db.cosmosdb.sub_status_code` | `0` |
|
|
| `db.cosmosdb.request_charge` | `7.43` |
|
|
|
|
[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
|