From c88120dc58b5b3647cf7aea42ffca157b754bfcc Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Tue, 25 Aug 2020 21:22:41 -0700 Subject: [PATCH] Enable handling of non-string attributes in Zipkin tests --- .../ZipkinActivityExporterRemoteEndpointTests.cs | 4 +++- .../ZipkinExporterTests.cs | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityExporterRemoteEndpointTests.cs b/test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityExporterRemoteEndpointTests.cs index 973eb15aa..ed33110da 100644 --- a/test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityExporterRemoteEndpointTests.cs +++ b/test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityExporterRemoteEndpointTests.cs @@ -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); diff --git a/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs b/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs index 6c098b451..3c52df256 100644 --- a/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Zipkin.Tests/ZipkinExporterTests.cs @@ -177,6 +177,7 @@ namespace OpenTelemetry.Exporter.Zipkin.Tests internal static Activity CreateTestActivity( bool setAttributes = true, Dictionary 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(kvp.Key, kvp.Value.ToString())) - : null; + IEnumerable> tags = null; + if (setAttributes) + { + tags = convertAttributeValuesToString + ? attributes.Select(kvp => new KeyValuePair(kvp.Key, kvp.Value.ToString())) + : attributes.Select(kvp => new KeyValuePair(kvp.Key, kvp.Value)); + } + var links = addLinks ? new[] {