From eff88d7932a6ff6a102381fb7cca58fea6f3dee6 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 14 Dec 2023 10:55:50 +0100 Subject: [PATCH] Refactor service mapping to a more general location --- .../Integrations/DatabaseIntegrationHelper.php | 4 ---- src/Integrations/Integrations/Integration.php | 12 +++++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Integrations/Integrations/DatabaseIntegrationHelper.php b/src/Integrations/Integrations/DatabaseIntegrationHelper.php index ce5221cd672..084c0b1bf94 100644 --- a/src/Integrations/Integrations/DatabaseIntegrationHelper.php +++ b/src/Integrations/Integrations/DatabaseIntegrationHelper.php @@ -63,10 +63,6 @@ public static function propagateViaSqlComments($query, $databaseService, $mode = $tags = []; if ($databaseService != "") { - $mapping = dd_trace_env_config('DD_SERVICE_MAPPING'); - if (isset($mapping[$databaseService])) { - $databaseService = $mapping[$databaseService]; - } $tags["dddbs"] = $databaseService; } diff --git a/src/Integrations/Integrations/Integration.php b/src/Integrations/Integrations/Integration.php index 085435056f8..027f5df4a7e 100644 --- a/src/Integrations/Integrations/Integration.php +++ b/src/Integrations/Integrations/Integration.php @@ -167,13 +167,19 @@ public static function handleInternalSpanServiceName(SpanData $span, $fallbackNa if ($flatServiceNames) { $rootSpan = \DDTrace\root_span(); if ($rootSpan) { - $span->service = $rootSpan->service; + $service = $rootSpan->service; } else { - $span->service = \ddtrace_config_app_name($fallbackName); + $service = \ddtrace_config_app_name($fallbackName); } } else { - $span->service = $fallbackName; + $service = $fallbackName; } + + $mapping = \dd_trace_env_config('DD_SERVICE_MAPPING'); + if (isset($mapping[$service])) { + $service = $mapping[$service]; + } + $span->service = $service; } }