Enable handling of non-string attributes in Zipkin tests

This commit is contained in:
Alan West 2020-08-25 21:22:41 -07:00
parent 891051c9dd
commit c88120dc58
No known key found for this signature in database
GPG Key ID: 10C64B6E349D00BC
2 changed files with 12 additions and 4 deletions

View File

@ -59,7 +59,9 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests.Implementation
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);

View File

@ -177,6 +177,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
internal static Activity CreateTestActivity(
bool setAttributes = true,
Dictionary<string, object> additionalAttributes = null,
bool convertAttributeValuesToString = true,
bool addEvents = true,
bool addLinks = true,
Resource resource = null,
@ -228,9 +229,14 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests
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[]
{