Skip to content

Commit d9da4df

Browse files
authored
Swap Samples.Telemetry to use .NET Activity (#3819)
* Swap Samples.Telemetry to use .NET Activity * Update TransportTests snapshots
1 parent c3c4a65 commit d9da4df

File tree

3 files changed

+22
-31
lines changed

3 files changed

+22
-31
lines changed

tracer/test/snapshots/TelemetryTests.verified.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
{
33
TraceId: Id_1,
44
SpanId: Id_2,
5-
Name: GetAsync,
5+
Name: Samples.Telemetry.internal,
66
Resource: GetAsync,
77
Service: Samples.Telemetry,
8+
Type: custom,
89
Tags: {
910
env: integration_tests,
1011
language: dotnet,
11-
runtime-id: Guid_1,
12+
otel.library.name: Samples.Telemetry,
13+
otel.status_code: STATUS_CODE_UNSET,
14+
otel.trace_id: Guid_1,
15+
runtime-id: Guid_2,
16+
span.kind: internal,
1217
version: 1.0.0,
1318
_dd.p.dm: -0
1419
},
@@ -34,8 +39,8 @@
3439
http-client-handler-type: System.Net.Http.HttpClientHandler,
3540
http.method: GET,
3641
http.status_code: 200,
37-
http.url: http://localhost:00000/Guid_3/,
38-
runtime-id: Guid_1,
42+
http.url: http://localhost:00000/Guid_4/,
43+
runtime-id: Guid_2,
3944
span.kind: client
4045
},
4146
Metrics: {
@@ -54,8 +59,8 @@
5459
env: integration_tests,
5560
language: dotnet,
5661
otel.status_code: STATUS_CODE_UNSET,
57-
otel.trace_id: Guid_2,
58-
runtime-id: Guid_1,
62+
otel.trace_id: Guid_3,
63+
runtime-id: Guid_2,
5964
span.kind: internal,
6065
version: 1.0.0,
6166
_dd.p.dm: -0
Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
1-
[
1+
[
22
{
33
TraceId: Id_1,
44
SpanId: Id_2,
5-
Name: GetAsync,
6-
Resource: GetAsync,
7-
Service: Samples.Telemetry,
8-
Tags: {
9-
env: integration_tests,
10-
language: dotnet,
11-
runtime-id: Guid_1,
12-
_dd.p.dm: -0
13-
},
14-
Metrics: {
15-
process_id: 0,
16-
_dd.agent_psr: 1.0,
17-
_dd.top_level: 1.0,
18-
_dd.tracer_kr: 1.0,
19-
_sampling_priority_v1: 1.0
20-
}
21-
},
22-
{
23-
TraceId: Id_1,
24-
SpanId: Id_3,
255
Name: http.request,
266
Resource: GET localhost:00000/?/,
277
Service: Samples.Telemetry-http-client,
288
Type: http,
29-
ParentId: Id_2,
309
Tags: {
3110
component: HttpMessageHandler,
3211
env: integration_tests,
@@ -35,10 +14,15 @@
3514
http.status_code: 200,
3615
http.url: http://localhost:00000/Guid_2/,
3716
runtime-id: Guid_1,
38-
span.kind: client
17+
span.kind: client,
18+
_dd.p.dm: -0
3919
},
4020
Metrics: {
41-
_dd.top_level: 1.0
21+
process_id: 0,
22+
_dd.agent_psr: 1.0,
23+
_dd.top_level: 1.0,
24+
_dd.tracer_kr: 1.0,
25+
_sampling_priority_v1: 1.0
4226
}
4327
}
4428
]

tracer/test/test-applications/integrations/Samples.Telemetry/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ namespace Samples.Telemetry
1111
{
1212
internal static class Program
1313
{
14+
private static ActivitySource _source;
1415
private const string ResponseContent = "PONG";
1516
private static readonly Encoding Utf8 = Encoding.UTF8;
1617

1718
public static async Task Main(string[] args)
1819
{
20+
_source = new ActivitySource("Samples.Telemetry");
1921

2022
string port = args.FirstOrDefault(arg => arg.StartsWith("Port="))?.Split('=')[1] ?? "9000";
2123
Console.WriteLine($"Port {port}");
@@ -32,7 +34,7 @@ public static async Task Main(string[] args)
3234
Console.WriteLine("Sending async request with default HttpClient.");
3335
using (var client = new HttpClient())
3436
{
35-
using (SampleHelpers.CreateScope("GetAsync"))
37+
using (_source.StartActivity("GetAsync"))
3638
{
3739
await client.GetAsync(url);
3840
Console.WriteLine("Received response for client.GetAsync(String)");

0 commit comments

Comments
 (0)