semantic-conventions/docs/database/mongodb.md

2.9 KiB

Semantic Conventions for MongoDB

Status: Experimental

The Semantic Conventions for MongoDB extend and override the Database Semantic Conventions that describe common database operations attributes in addition to the Semantic Conventions described on this page.

db.system MUST be set to "mongodb".

Attributes

Attribute Type Description Examples Requirement Level Stability
db.collection.name string The MongoDB collection being accessed within the database stated in db.namespace. [1] public.users; customers Required Experimental
db.namespace string The MongoDB database name. [2] customers; test.users Conditionally Required If available. Experimental
db.operation.name string The name of the command being executed. [3] findAndModify; getMore; update Conditionally Required [4] Experimental

[1]: If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization.

[2]:

[3]: See MongoDB database commands.

[4]: If readily available. Otherwise, if the instrumentation library parses db.query.text to capture db.operation.name, then it SHOULD be the first operation name found in the query.

Example

Key Value
Span name "findAndModify products"
db.system "mongodb"
server.address "mongodb0.example.com"
server.port 27017
network.peer.address "192.0.2.14"
network.peer.port 27017
network.transport "tcp"
db.collection.name "products"
db.namespace "shopDb"
db.query.text not set
db.operation.name "findAndModify"