Skip to content

Commit

Permalink
Enable handling of non-string attributes in Zipkin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwest committed Aug 26, 2020
1 parent 891051c commit c88120d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointResolution()
public void ZipkinSpanConverterTest_GenerateActivity_RemoteEndpointResolutionPriority(RemoteEndpointPriorityTestCase testCase)
{
// Arrange
var activity = ZipkinExporterTests.CreateTestActivity(additionalAttributes: testCase.RemoteEndpointAttributes);
var activity = ZipkinExporterTests.CreateTestActivity(
additionalAttributes: testCase.RemoteEndpointAttributes,
convertAttributeValuesToString: false);

// Act & Assert
var zipkinSpan = ZipkinActivityConversionExtensions.ToZipkinSpan(activity, DefaultZipkinEndpoint);
Expand Down
12 changes: 9 additions & 3 deletions test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void ZipkinExporterIntegrationTest(bool useShortTraceIds)
internal static Activity CreateTestActivity(
bool setAttributes = true,
Dictionary<string, object> additionalAttributes = null,
bool convertAttributeValuesToString = true,
bool addEvents = true,
bool addLinks = true,
Resource resource = null,
Expand Down Expand Up @@ -228,9 +229,14 @@ internal static Activity CreateTestActivity(

var activitySource = new ActivitySource(nameof(CreateTestActivity));

var tags = setAttributes ?
attributes.Select(kvp => new KeyValuePair<string, object>(kvp.Key, kvp.Value.ToString()))
: null;
IEnumerable<KeyValuePair<string, object>> tags = null;
if (setAttributes)
{
tags = convertAttributeValuesToString
? attributes.Select(kvp => new KeyValuePair<string, object>(kvp.Key, kvp.Value.ToString()))
: attributes.Select(kvp => new KeyValuePair<string, object>(kvp.Key, kvp.Value));
}

var links = addLinks ?
new[]
{
Expand Down

0 comments on commit c88120d

Please sign in to comment.