> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB instrumentation

## Setup

To instrument your MongoDB usage, you'll need to import the OpenTelemetry official instrumentation package:

```go Go theme={null}
import "go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo"
```

Before initializing your MongoDB connection, add the `otelmongo.NewMonitor()` as a monitor in the connection options as shown in the example below.

```go Go theme={null}
opts := options.Client()
opts.Monitor = otelmongo.NewMonitor()
opts.ApplyURI("mongodb://your.mongo.host:27017")
client, err := mongo.Connect(ctx, opts)
if err != nil {
	panic(err)
}
```

> [!WARNING]
>
> At this time the Mongo instrumentation reports all queries in an unsanitized
> fashion. This means that any PII data is sent to AppSignal, like email
> addresses and passwords. This will be configurable in a future version of the
> Mongo instrumentation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.