Skip to content

Commit

Permalink
[v3] add language tag all spans (#4839)
Browse files Browse the repository at this point in the history
* add language tag all spans

* fix unit tests

* update test snapshots

* update smoke test snapshots

* update test snapshots
  • Loading branch information
lucaspimentel authored and andrewlock committed Jul 4, 2024
1 parent 186af37 commit 0b4908c
Show file tree
Hide file tree
Showing 93 changed files with 5,968 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"http.method": "GET",
"http.status_code": "200",
"http.url": "http://localhost:5000/api/values",
"language": "dotnet",
"out.host": "localhost",
"runtime-id": "11c61d09-16bb-477f-87ab-4f81d656c5ca",
"span.kind": "client"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"http.method": "GET",
"http.status_code": "200",
"http.url": "http://localhost:5000/api/values",
"language": "dotnet",
"out.host": "localhost",
"runtime-id": "b34b2bed-9444-4597-87f6-b8202b03b1b8",
"span.kind": "client"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,10 @@ private int WriteTags(ref byte[] bytes, int offset, in SpanModel model, ITagProc
offset += MessagePackBinary.WriteRaw(ref bytes, offset, envRawBytes);
}

// add "language=dotnet" tag to all spans, except those that
// represents a downstream service or external dependency
if (span.Tags is not InstrumentationTags { SpanKind: SpanKinds.Client or SpanKinds.Producer })
{
count++;
offset += MessagePackBinary.WriteStringBytes(ref bytes, offset, _languageNameBytes);
offset += MessagePackBinary.WriteStringBytes(ref bytes, offset, _languageValueBytes);
}
// add "language=dotnet" tag to all spans
count++;
offset += MessagePackBinary.WriteStringBytes(ref bytes, offset, _languageNameBytes);
offset += MessagePackBinary.WriteStringBytes(ref bytes, offset, _languageValueBytes);

// add "version" tags to all spans whose service name is the default service name
if (string.Equals(span.Context.ServiceNameInternal, model.TraceChunk.DefaultServiceName, StringComparison.OrdinalIgnoreCase))
Expand All @@ -426,7 +422,7 @@ private int WriteTags(ref byte[] bytes, int offset, in SpanModel model, ITagProc
}
}

// SCI tags will be sent only once per trace
// SCI tags will be sent only once per trace chunk
if (model.IsFirstSpanInChunk)
{
var gitCommitShaRawBytes = MessagePackStringCache.GetGitCommitShaBytes(model.TraceChunk.GitCommitSha);
Expand Down
23 changes: 8 additions & 15 deletions tracer/test/Datadog.Trace.Tests/Tagging/TagsListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@ public async Task Serialize_LanguageTag_ManualInstrumentation()
}

[Theory]
[InlineData(SpanKinds.Client, null)]
[InlineData(SpanKinds.Server, TracerConstants.Language)]
[InlineData(SpanKinds.Producer, null)]
[InlineData(SpanKinds.Consumer, TracerConstants.Language)]
[InlineData("other", TracerConstants.Language)]
public async Task Serialize_LanguageTag_AutomaticInstrumentation(string spanKind, string expectedLanguage)
[InlineData(SpanKinds.Client)]
[InlineData(SpanKinds.Server)]
[InlineData(SpanKinds.Producer)]
[InlineData(SpanKinds.Consumer)]
[InlineData(SpanKinds.Internal)]
[InlineData("other")]
public async Task Serialize_LanguageTag_AutomaticInstrumentation(string spanKind)
{
const int customTagCount = 15;

Expand All @@ -253,15 +254,7 @@ public async Task Serialize_LanguageTag_AutomaticInstrumentation(string spanKind
await _tracer.FlushAsync();
var traceChunks = _testApi.Wait();
var deserializedSpan = traceChunks.Single().Single();

if (expectedLanguage == null)
{
deserializedSpan.Tags.Should().NotContainKey(Tags.Language);
}
else
{
deserializedSpan.Tags.Should().Contain(Tags.Language, expectedLanguage);
}
deserializedSpan.Tags.Should().Contain(Tags.Language, TracerConstants.Language);
}

private static void SetupForSerializationTest(Span span, int customTagCount)
Expand Down
19 changes: 19 additions & 0 deletions tracer/test/snapshots/AerospikeTests.SchemaV0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -33,6 +34,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -55,6 +57,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -77,6 +80,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -101,6 +105,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -125,6 +130,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -149,6 +155,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -173,6 +180,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -196,6 +204,7 @@
aerospike.setname: myset1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -220,6 +229,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -244,6 +254,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -268,6 +279,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -292,6 +304,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -316,6 +329,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -340,6 +354,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -364,6 +379,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -388,6 +404,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -412,6 +429,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand All @@ -436,6 +454,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
runtime-id: Guid_1,
span.kind: client
},
Expand Down
19 changes: 19 additions & 0 deletions tracer/test/snapshots/AerospikeTests.SchemaV1.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand All @@ -36,6 +37,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand All @@ -61,6 +63,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand All @@ -86,6 +89,7 @@
aerospike.namespace: test,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -113,6 +117,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -140,6 +145,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -167,6 +173,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -194,6 +201,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand All @@ -220,6 +228,7 @@
aerospike.setname: myset1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -247,6 +256,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -274,6 +284,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -301,6 +312,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -328,6 +340,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -355,6 +368,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -382,6 +396,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -409,6 +424,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -436,6 +452,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -463,6 +480,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down Expand Up @@ -490,6 +508,7 @@
aerospike.userkey: mykey1,
component: aerospike,
env: integration_tests,
language: dotnet,
peer.service: test,
runtime-id: Guid_1,
span.kind: client,
Expand Down
Loading

0 comments on commit 0b4908c

Please sign in to comment.