diff --git a/instrumentor/sdks/sdks.go b/instrumentor/sdks/sdks.go index bc95df0f1..7f474e878 100644 --- a/instrumentor/sdks/sdks.go +++ b/instrumentor/sdks/sdks.go @@ -56,6 +56,23 @@ func SetDefaultSDKs(ctx context.Context) error { return nil } +func copyOtelSdkMap(m map[common.ProgrammingLanguage]common.OtelSdk) map[common.ProgrammingLanguage]common.OtelSdk { + // Create a new map with the same capacity as the original + newMap := make(map[common.ProgrammingLanguage]common.OtelSdk, len(m)) + + // Copy each key-value pair to the new map + for key, value := range m { + newMap[key] = common.OtelSdk{ + SdkType: value.SdkType, + SdkTier: value.SdkTier, + } + } + + return newMap +} + func GetDefaultSDKs() map[common.ProgrammingLanguage]common.OtelSdk { - return defaultOtelSdkPerLanguage + // return a copy of the map, so it can be modified without affecting the original + // and if used by multiple goroutines, it will be safe to write to the instance returned + return copyOtelSdkMap(defaultOtelSdkPerLanguage) }