Skip to content

Commit 6001ab8

Browse files
authored
Add process tags to telemetry (#7780)
## Summary of changes add processtags to the body of telemetry requests, as part of the application data. equivalent of DataDog/dd-trace-java#8837 ## Reason for change [AIDM-195] ## Implementation details pretty straightforward. ## Test coverage relies on snapshots ## Other details <!-- Fixes #{issue} --> <!-- ⚠️ Note: Where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. MergeQueue is NOT enabled in this repository. If you have write access to the repo, the PR has 1-2 approvals (see above), and all of the required checks have passed, you can use the Squash and Merge button to merge the PR. If you don't have write access, or you need help, reach out in the #apm-dotnet channel in Slack. --> [AIDM-195]: https://datadoghq.atlassian.net/browse/AIDM-195?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 60661e9 commit 6001ab8

File tree

10 files changed

+36
-14
lines changed

10 files changed

+36
-14
lines changed

tracer/src/Datadog.Trace/Telemetry/Collectors/ApplicationTelemetryCollector.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public void RecordTracerSettings(
3030
Interlocked.Exchange(ref _gitMetadata, gitMetadata);
3131
}
3232

33+
string? processTags = null;
34+
if (tracerSettings.PropagateProcessTags && !string.IsNullOrEmpty(ProcessTags.SerializedTags))
35+
{
36+
processTags = ProcessTags.SerializedTags;
37+
}
38+
3339
var frameworkDescription = FrameworkDescription.Instance;
3440
var application = new ApplicationTelemetryData(
3541
serviceName: defaultServiceName,
@@ -41,7 +47,8 @@ public void RecordTracerSettings(
4147
runtimeName: frameworkDescription.Name,
4248
runtimeVersion: frameworkDescription.ProductVersion,
4349
commitSha: gitMetadata?.CommitSha,
44-
repositoryUrl: gitMetadata?.RepositoryUrl);
50+
repositoryUrl: gitMetadata?.RepositoryUrl,
51+
processTags: processTags);
4552

4653
Interlocked.Exchange(ref _applicationData, application);
4754

@@ -95,7 +102,8 @@ public void RecordGitMetadata(GitMetadata gitMetadata)
95102
runtimeName: original.RuntimeName,
96103
runtimeVersion: original.RuntimeVersion,
97104
commitSha: gitMetadata.CommitSha,
98-
repositoryUrl: gitMetadata.RepositoryUrl);
105+
repositoryUrl: gitMetadata.RepositoryUrl,
106+
processTags: original.ProcessTags);
99107

100108
var updated = Interlocked.Exchange(ref _applicationData, application);
101109
if (updated == original)

tracer/src/Datadog.Trace/Telemetry/DTOs/ApplicationTelemetryData.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Datadog.Trace.Telemetry;
99

1010
internal class ApplicationTelemetryData
1111
{
12-
public ApplicationTelemetryData(string serviceName, string env, string serviceVersion, string tracerVersion, string languageName, string languageVersion, string runtimeName, string runtimeVersion, string? commitSha, string? repositoryUrl)
12+
public ApplicationTelemetryData(string serviceName, string env, string serviceVersion, string tracerVersion, string languageName, string languageVersion, string runtimeName, string runtimeVersion, string? commitSha, string? repositoryUrl, string? processTags)
1313
{
1414
ServiceName = serviceName;
1515
Env = env;
@@ -21,6 +21,7 @@ public ApplicationTelemetryData(string serviceName, string env, string serviceVe
2121
RuntimeVersion = runtimeVersion;
2222
CommitSha = commitSha;
2323
RepositoryUrl = repositoryUrl;
24+
ProcessTags = processTags;
2425
}
2526

2627
public string ServiceName { get; set; }
@@ -44,4 +45,6 @@ public ApplicationTelemetryData(string serviceName, string env, string serviceVe
4445
public string? CommitSha { get; set; }
4546

4647
public string? RepositoryUrl { get; set; }
48+
49+
public string? ProcessTags { get; set; }
4750
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelperTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public TelemetryHelperTests(ITestOutputHelper output)
4040
runtimeName: "dotnet",
4141
runtimeVersion: "7.0.1",
4242
commitSha: "testCommitSha",
43-
repositoryUrl: "testRepositoryUrl");
43+
repositoryUrl: "testRepositoryUrl",
44+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads");
4445
_host = new HostTelemetryData("MY_HOST", "Windows", "x64");
4546
_output = output;
4647
}

tracer/test/Datadog.Trace.IntegrationTests/TelemetryTransportTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ private static TelemetryData GetSampleData() =>
167167
runtimeName: "dotnet",
168168
runtimeVersion: "7.0.3",
169169
commitSha: "aaaaaaaaaaaaaaaaaa",
170-
repositoryUrl: "https://github.com/myOrg/myRepo"),
170+
repositoryUrl: "https://github.com/myOrg/myRepo",
171+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads"),
171172
host: new HostTelemetryData("SOME_HOST", "Windows", "x64"),
172173
payload: null);
173174

tracer/test/Datadog.Trace.Tests/Telemetry/TelemetryDataBuilderTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public TelemetryDataBuilderTests()
3434
runtimeName: FrameworkDescription.Instance.Name,
3535
runtimeVersion: FrameworkDescription.Instance.ProductVersion,
3636
commitSha: "testCommitSha",
37-
repositoryUrl: "testRepositoryUrl");
37+
repositoryUrl: "testRepositoryUrl",
38+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads");
3839
_host = new HostTelemetryData("MY_MACHINE", "Windows", "arm64");
3940
}
4041

tracer/test/Datadog.Trace.Tests/Telemetry/Transports/JsonTelemetryTransportTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public void SerializedAppStartedShouldProduceJsonWithExpectedFormat()
3737
runtimeName: "dotnet",
3838
runtimeVersion: "7.0.3",
3939
commitSha: "testCommitSha",
40-
repositoryUrl: "testRepositoryUrl"),
40+
repositoryUrl: "testRepositoryUrl",
41+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads"),
4142
host: new HostTelemetryData(
4243
hostname: "i-09ecf74c319c49be8",
4344
os: "GNU/Linux",
@@ -100,7 +101,8 @@ public void SerializedMetricsTelemetryShouldProduceJsonWithExpectedFormat()
100101
runtimeName: "dotnet",
101102
runtimeVersion: "7.0.3",
102103
commitSha: "testCommitSha",
103-
repositoryUrl: "testRepositoryUrl"),
104+
repositoryUrl: "testRepositoryUrl",
105+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads"),
104106
host: new HostTelemetryData(
105107
hostname: "i-09ecf74c319c49be8",
106108
os: "GNU/Linux",
@@ -171,7 +173,8 @@ public void SerializedDistributionMetricsTelemetryShouldProduceJsonWithExpectedF
171173
runtimeName: "dotnet",
172174
runtimeVersion: "7.0.3",
173175
commitSha: "testCommitSha",
174-
repositoryUrl: "testRepositoryUrl"),
176+
repositoryUrl: "testRepositoryUrl",
177+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads"),
175178
host: new HostTelemetryData(
176179
hostname: "i-09ecf74c319c49be8",
177180
os: "GNU/Linux",
@@ -237,7 +240,8 @@ public void SerializedMessageBatchShouldProduceJsonWithExpectedFormat()
237240
runtimeName: "dotnet",
238241
runtimeVersion: "7.0.3",
239242
commitSha: "testCommitSha",
240-
repositoryUrl: "testRepositoryUrl"),
243+
repositoryUrl: "testRepositoryUrl",
244+
processTags: "entrypoint.basedir:Users,entrypoint.workdir:Downloads"),
241245
host: new HostTelemetryData(
242246
hostname: "i-09ecf74c319c49be8",
243247
os: "GNU/Linux",

tracer/test/Datadog.Trace.Tests/Telemetry/telemetry_app-started.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"runtime_name": "dotnet",
1616
"runtime_version": "7.0.3",
1717
"commit_sha": "testCommitSha",
18-
"repository_url": "testRepositoryUrl"
18+
"repository_url": "testRepositoryUrl",
19+
"process_tags": "entrypoint.basedir:Users,entrypoint.workdir:Downloads"
1920
},
2021
"host": {
2122
"hostname": "i-09ecf74c319c49be8",

tracer/test/Datadog.Trace.Tests/Telemetry/telemetry_distributions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"runtime_name": "dotnet",
1515
"runtime_version": "7.0.3",
1616
"commit_sha": "testCommitSha",
17-
"repository_url": "testRepositoryUrl"
17+
"repository_url": "testRepositoryUrl",
18+
"process_tags": "entrypoint.basedir:Users,entrypoint.workdir:Downloads"
1819
},
1920
"host": {
2021
"hostname": "i-09ecf74c319c49be8",

tracer/test/Datadog.Trace.Tests/Telemetry/telemetry_generate-metrics.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"runtime_name": "dotnet",
1515
"runtime_version": "7.0.3",
1616
"commit_sha": "testCommitSha",
17-
"repository_url": "testRepositoryUrl"
17+
"repository_url": "testRepositoryUrl",
18+
"process_tags": "entrypoint.basedir:Users,entrypoint.workdir:Downloads"
1819
},
1920
"host": {
2021
"hostname": "i-09ecf74c319c49be8",

tracer/test/Datadog.Trace.Tests/Telemetry/telemetry_message-batch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"runtime_name": "dotnet",
1616
"runtime_version": "7.0.3",
1717
"commit_sha": "testCommitSha",
18-
"repository_url": "testRepositoryUrl"
18+
"repository_url": "testRepositoryUrl",
19+
"process_tags": "entrypoint.basedir:Users,entrypoint.workdir:Downloads"
1920
},
2021
"host": {
2122
"hostname": "i-09ecf74c319c49be8",

0 commit comments

Comments
 (0)