-
Notifications
You must be signed in to change notification settings - Fork 511
gorm.io/gorm.v1 contrib does not respect DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED #4578
Copy link
Copy link
Open
Labels
bugunintended behavior that has to be fixedunintended behavior that has to be fixed
Description
Description
The contrib/gorm.io/gorm.v1 package hardcodes "gorm.db" as the service name in newConfigWithDefaults() (option.go:39):
cfg.serviceName = "gorm.db"This means DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED=true has no effect — spans traced through gorm always appear as a separate gorm.db service in Datadog APM instead of being rolled under the global DD_SERVICE.
By comparison, the contrib/jackc/pgx.v5 package correctly uses:
serviceName: instr.ServiceName(instrumentation.ComponentDefault, nil)Which respects DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED and falls back to DD_SERVICE when enabled.
Root Cause
Two things are missing:
instrumentation/packages.go:PackageGormIOGormV1has nonamingmap, unlikePackageJackcPGXV5which defines one.contrib/gorm.io/gorm.v1/option.go:newConfigWithDefaults()hardcodes"gorm.db"instead of callinginstr.ServiceName().
Expected Behavior
When DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED=true, gorm spans should use the global DD_SERVICE name instead of gorm.db, matching the behavior of pgx and database/sql integrations.
Proposed Fix
- Add a
namingmap toPackageGormIOGormV1ininstrumentation/packages.go(matching the pgx pattern) - Replace
cfg.serviceName = "gorm.db"withcfg.serviceName = instr.ServiceName(instrumentation.ComponentDefault, nil)incontrib/gorm.io/gorm.v1/option.go
Environment
- dd-trace-go v2.6.0
- Using Orchestrion auto-instrumentation
DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED=trueDD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED=true
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugunintended behavior that has to be fixedunintended behavior that has to be fixed