Skip to content

Commit d208339

Browse files
dubonzidmathieupellaredMrAlias
authored
[otelmongo] Disable adding the mongo 'db.statement' tag by default (#3519)
* Disable adding the mongo 'db.statement' tag by default As of now, the 'db.statement' tag is not obfuscated, which can lead to sensitive information being leaked through the tag. See #3388 * Update CHANGELOG.md * Update CHANGELOG.md * Update mongo.go * fix reverted changelog change in conflict resolution * Move changelog entry to unreleased --------- Co-authored-by: Damien Mathieu <[email protected]> Co-authored-by: Robert Pająk <[email protected]> Co-authored-by: Tyler Yahn <[email protected]> Co-authored-by: Tyler Yahn <[email protected]>
1 parent 6682591 commit d208339

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1616
### Changed
1717

1818
- 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)
19+
- 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)
1920

2021
### Fixed
2122

instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ type config struct {
3333
// newConfig returns a config with all Options set.
3434
func newConfig(opts ...Option) config {
3535
cfg := config{
36-
TracerProvider: otel.GetTracerProvider(),
36+
TracerProvider: otel.GetTracerProvider(),
37+
CommandAttributeDisabled: true,
3738
}
3839
for _, opt := range opts {
3940
opt.apply(&cfg)
@@ -68,7 +69,8 @@ func WithTracerProvider(provider trace.TracerProvider) Option {
6869
}
6970

7071
// WithCommandAttributeDisabled specifies if the MongoDB command is added as an attribute to Spans or not.
71-
// The MongoDB command will be added as an attribute to Spans by default if this option is not provided.
72+
// This is disabled by default and the MongoDB command will not be added as an attribute
73+
// to Spans if this option is not provided.
7274
func WithCommandAttributeDisabled(disabled bool) Option {
7375
return optionFunc(func(cfg *config) {
7476
cfg.CommandAttributeDisabled = disabled

instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/mongo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (m *monitor) Finished(evt *event.CommandFinishedEvent, err error) {
107107
span.End()
108108
}
109109

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

0 commit comments

Comments
 (0)