Skip to content
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

[otelmongo] Disable adding the mongo 'db.statement' tag by default #3519

Merged
merged 9 commits into from
Apr 26, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Changed

- Update `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` to align gRPC server span status with the changes in the OpenTelemetry specification. (#3685)
- Adding the `db.statement` tag to spans in `go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo` is now disabled by default. (#3519)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type config struct {
// newConfig returns a config with all Options set.
func newConfig(opts ...Option) config {
cfg := config{
TracerProvider: otel.GetTracerProvider(),
TracerProvider: otel.GetTracerProvider(),
CommandAttributeDisabled: true,
}
for _, opt := range opts {
opt.apply(&cfg)
Expand Down Expand Up @@ -68,7 +69,8 @@ func WithTracerProvider(provider trace.TracerProvider) Option {
}

// WithCommandAttributeDisabled specifies if the MongoDB command is added as an attribute to Spans or not.
// The MongoDB command will be added as an attribute to Spans by default if this option is not provided.
// This is disabled by default and the MongoDB command will not be added as an attribute
// to Spans if this option is not provided.
func WithCommandAttributeDisabled(disabled bool) Option {
return optionFunc(func(cfg *config) {
cfg.CommandAttributeDisabled = disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (m *monitor) Finished(evt *event.CommandFinishedEvent, err error) {
span.End()
}

// TODO sanitize values where possible
// TODO sanitize values where possible, then reenable `db.statement` span attributes default.
// TODO limit maximum size.
func sanitizeCommand(command bson.Raw) string {
b, _ := bson.MarshalExtJSON(command, false, false)
Expand Down