From 9db1d0dbc0527e1c64cf7995d2633278ef5e9fea Mon Sep 17 00:00:00 2001 From: Gregory LEOCADIE Date: Mon, 16 Dec 2024 15:44:17 +0100 Subject: [PATCH] Fix git metadata retrieval --- tracer/src/Datadog.Trace/Configuration/TracerSettings.cs | 2 +- .../Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs b/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs index 3e548c8c8413..3b61aec6ab43 100644 --- a/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs @@ -211,7 +211,7 @@ _ when x.ToBoolean() is { } boolean => boolean, .AsString(); // DD_GIT_REPOSITORY_URL has precedence over DD_TAGS - GitRepositoryUrl = GetExplicitSettingOrTag(GitRepositoryUrl, globalTags, Ci.Tags.CommonTags.GitCommit, ConfigurationKeys.GitRepositoryUrl); + GitRepositoryUrl = GetExplicitSettingOrTag(GitRepositoryUrl, globalTags, Ci.Tags.CommonTags.GitRepository, ConfigurationKeys.GitRepositoryUrl); GitMetadataEnabled = config .WithKeys(ConfigurationKeys.GitMetadataEnabled) diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs index 943588851c5e..fc09476d7110 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs @@ -1275,7 +1275,7 @@ public void DDTagsSetsServiceInformation() { var source = new NameValueConfigurationSource(new() { - { "DD_TAGS", "env:datadog_env,service:datadog_service,version:datadog_version" }, + { "DD_TAGS", "env:datadog_env,service:datadog_service,version:datadog_version,git.repository_url:https://Myrepository,git.commit.sha:42" }, }); var tracerSettings = new TracerSettings(source); @@ -1283,6 +1283,8 @@ public void DDTagsSetsServiceInformation() tracerSettings.Environment.Should().Be("datadog_env"); tracerSettings.ServiceVersion.Should().Be("datadog_version"); tracerSettings.ServiceName.Should().Be("datadog_service"); + tracerSettings.GitRepositoryUrl.Should().Be("https://Myrepository"); + tracerSettings.GitCommitSha.Should().Be("42"); } [Fact]