Zipking will export all strings (#1197)
* Zipking will export all strings * updating tests * renaming tests, solving incorrect tests * net.peer.port will be exported as well
This commit is contained in:
parent
a09e1f8fa3
commit
465fc09320
|
|
@ -208,17 +208,16 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation
|
|||
{
|
||||
state.ServiceNamespace = strVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
PooledList<KeyValuePair<string, object>>.Add(ref state.Tags, new KeyValuePair<string, object>(key, strVal));
|
||||
}
|
||||
}
|
||||
else if (attribute.Value is int intVal && attribute.Key == SemanticConventions.AttributeNetPeerPort)
|
||||
{
|
||||
state.Port = intVal;
|
||||
|
||||
PooledList<KeyValuePair<string, object>>.Add(ref state.Tags, new KeyValuePair<string, object>(key, strVal));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (attribute.Value is int intVal && attribute.Key == SemanticConventions.AttributeNetPeerPort)
|
||||
{
|
||||
state.Port = intVal;
|
||||
}
|
||||
|
||||
PooledList<KeyValuePair<string, object>>.Add(ref state.Tags, attribute);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
private static readonly ZipkinEndpoint DefaultZipkinEndpoint = new ZipkinEndpoint("TestService");
|
||||
|
||||
[Fact]
|
||||
public void ZipkinActivityConversion_ToZipkinSpan_AllPropertiesSet()
|
||||
public void ToZipkinSpan_AllPropertiesSet()
|
||||
{
|
||||
// Arrange
|
||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
||||
|
|
@ -45,7 +45,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
int counter = 0;
|
||||
var tagsArray = zipkinSpan.Tags.Value.ToArray();
|
||||
|
||||
foreach (var tags in activity.Tags)
|
||||
foreach (var tags in activity.TagObjects)
|
||||
{
|
||||
Assert.Equal(tagsArray[counter].Key, tags.Key);
|
||||
Assert.Equal(tagsArray[counter++].Value, tags.Value);
|
||||
|
|
@ -59,7 +59,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void ZipkinActivityConversion_ToZipkinSpan_NoEvents()
|
||||
public void ToZipkinSpan_NoEvents()
|
||||
{
|
||||
// Arrange
|
||||
var activity = ZipkinExporterTests.CreateTestActivity(addEvents: false);
|
||||
|
|
@ -75,7 +75,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
int counter = 0;
|
||||
var tagsArray = zipkinSpan.Tags.Value.ToArray();
|
||||
|
||||
foreach (var tags in activity.Tags)
|
||||
foreach (var tags in activity.TagObjects)
|
||||
{
|
||||
Assert.Equal(tagsArray[counter].Key, tags.Key);
|
||||
Assert.Equal(tagsArray[counter++].Value, tags.Value);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
private static readonly ZipkinEndpoint DefaultZipkinEndpoint = new ZipkinEndpoint("TestService");
|
||||
|
||||
[Fact]
|
||||
public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointOmittedByDefault()
|
||||
public void GenerateActivity_RemoteEndpointOmittedByDefault()
|
||||
{
|
||||
// Arrange
|
||||
var activity = ZipkinExporterTests.CreateTestActivity();
|
||||
|
|
@ -34,11 +34,11 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
// Act & Assert
|
||||
var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);
|
||||
|
||||
Assert.Null(zipkinSpan.RemoteEndpoint);
|
||||
Assert.NotNull(zipkinSpan.RemoteEndpoint);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointResolution()
|
||||
public void GenerateActivity_RemoteEndpointResolution()
|
||||
{
|
||||
// Arrange
|
||||
var activity = ZipkinExporterTests.CreateTestActivity(
|
||||
|
|
@ -56,7 +56,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
|
|||
|
||||
[Theory]
|
||||
[MemberData(nameof(RemoteEndpointPriorityTestCase.GetTestCases), MemberType = typeof(RemoteEndpointPriorityTestCase))]
|
||||
public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
|
||||
public void GenerateActivity_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
|
||||
{
|
||||
// Arrange
|
||||
var activity = ZipkinExporterTests.CreateTestActivity(additionalAttributes: testCase.RemoteEndpointAttributes);
|
||||
|
|
|
|||
|
|
@ -84,14 +84,14 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void ZipkinExporter_BadArgs()
|
||||
public void BadArgs()
|
||||
{
|
||||
TracerProviderBuilder builder = null;
|
||||
Assert.Throws<ArgumentNullException>(() => builder.AddZipkinExporter());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZipkinExporter_SuppresssesInstrumentation()
|
||||
public void SuppresssesInstrumentation()
|
||||
{
|
||||
const string ActivitySourceName = "zipkin.test";
|
||||
Guid requestId = Guid.NewGuid();
|
||||
|
|
@ -135,7 +135,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
|
|||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public void ZipkinExporterIntegrationTest(bool useShortTraceIds)
|
||||
public void IntegrationTest(bool useShortTraceIds)
|
||||
{
|
||||
Guid requestId = Guid.NewGuid();
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
|
|||
var traceId = useShortTraceIds ? TraceId.Substring(TraceId.Length - 16, 16) : TraceId;
|
||||
|
||||
Assert.Equal(
|
||||
$@"[{{""traceId"":""{traceId}"",""name"":""Name"",""parentId"":""{ZipkinActivityConversionExtensions.EncodeSpanId(activity.ParentSpanId)}"",""id"":""{ZipkinActivityConversionExtensions.EncodeSpanId(context.SpanId)}"",""kind"":""CLIENT"",""timestamp"":{timestamp},""duration"":60000000,""localEndpoint"":{{""serviceName"":""OpenTelemetry Exporter""{ipInformation}}},""annotations"":[{{""timestamp"":{eventTimestamp},""value"":""Event1""}},{{""timestamp"":{eventTimestamp},""value"":""Event2""}}],""tags"":{{""stringKey"":""value"",""longKey"":""1"",""longKey2"":""1"",""doubleKey"":""1"",""doubleKey2"":""1"",""longArrayKey"":""1,2"",""boolKey"":""True"",""library.name"":""CreateTestActivity""}}}}]",
|
||||
$@"[{{""traceId"":""{traceId}"",""name"":""Name"",""parentId"":""{ZipkinActivityConversionExtensions.EncodeSpanId(activity.ParentSpanId)}"",""id"":""{ZipkinActivityConversionExtensions.EncodeSpanId(context.SpanId)}"",""kind"":""CLIENT"",""timestamp"":{timestamp},""duration"":60000000,""localEndpoint"":{{""serviceName"":""OpenTelemetry Exporter""{ipInformation}}},""remoteEndpoint"":{{""serviceName"":""http://localhost:44312/""}},""annotations"":[{{""timestamp"":{eventTimestamp},""value"":""Event1""}},{{""timestamp"":{eventTimestamp},""value"":""Event2""}}],""tags"":{{""stringKey"":""value"",""longKey"":""1"",""longKey2"":""1"",""doubleKey"":""1"",""doubleKey2"":""1"",""longArrayKey"":""1,2"",""boolKey"":""True"",""http.host"":""http://localhost:44312/"",""library.name"":""CreateTestActivity""}}}}]",
|
||||
Responses[requestId]);
|
||||
}
|
||||
|
||||
|
|
@ -198,12 +198,16 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
|
|||
{ "doubleKey2", 1F },
|
||||
{ "longArrayKey", new long[] { 1, 2 } },
|
||||
{ "boolKey", true },
|
||||
{ "http.host", "http://localhost:44312/" }, // simulating instrumentation tag adding http.host
|
||||
};
|
||||
if (additionalAttributes != null)
|
||||
{
|
||||
foreach (var attribute in additionalAttributes)
|
||||
{
|
||||
attributes.Add(attribute.Key, attribute.Value);
|
||||
if (!attributes.ContainsKey(attribute.Key))
|
||||
{
|
||||
attributes.Add(attribute.Key, attribute.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue