From e3ae739d9eba596dd4be9505a70215172a8217ca Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Mon, 29 Jul 2019 18:48:03 -0700 Subject: [PATCH 1/2] Do not export calls to Zipkin --- .../Implementation/TraceExporterHandler.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs index b43a65e56e2..42bba985a09 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs @@ -40,12 +40,14 @@ internal class TraceExporterHandler : IHandler private readonly ZipkinTraceExporterOptions options; private readonly ZipkinEndpoint localEndpoint; private readonly HttpClient httpClient; + private readonly string serviceEndpoint; public TraceExporterHandler(ZipkinTraceExporterOptions options, HttpClient client) { this.options = options; this.localEndpoint = this.GetLocalZipkinEndpoint(); this.httpClient = client ?? new HttpClient(); + this.serviceEndpoint = options.Endpoint?.ToString(); } public async Task ExportAsync(IEnumerable spanDataList) @@ -54,8 +56,22 @@ public async Task ExportAsync(IEnumerable spanDataList) foreach (var data in spanDataList) { - var zipkinSpan = this.GenerateSpan(data, this.localEndpoint); - zipkinSpans.Add(zipkinSpan); + bool shouldExport = true; + foreach (var label in data.Attributes.AttributeMap) + { + if (label.Key == "http.url" && label.Value?.ToString() == this.serviceEndpoint) + { + // do not track calls to Zipkin + shouldExport = false; + break; + } + } + + if (shouldExport) + { + var zipkinSpan = this.GenerateSpan(data, this.localEndpoint); + zipkinSpans.Add(zipkinSpan); + } } try From b678d1905d28b1b7494cf1d7feee7e9478d8e3f7 Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Mon, 29 Jul 2019 19:04:59 -0700 Subject: [PATCH 2/2] up --- .../Implementation/TraceExporterHandler.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs index 42bba985a09..b9254e4198b 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs @@ -59,10 +59,14 @@ public async Task ExportAsync(IEnumerable spanDataList) bool shouldExport = true; foreach (var label in data.Attributes.AttributeMap) { - if (label.Key == "http.url" && label.Value?.ToString() == this.serviceEndpoint) + if (label.Key == "http.url") { - // do not track calls to Zipkin - shouldExport = false; + if (label.Value is string urlStr && urlStr == this.serviceEndpoint) + { + // do not track calls to Zipkin + shouldExport = false; + } + break; } } @@ -107,7 +111,7 @@ internal ZipkinSpan GenerateSpan(SpanData spanData, ZipkinEndpoint localEndpoint foreach (var label in spanData.Attributes.AttributeMap) { - spanBuilder.PutTag(label.Key, (string)label.Value); + spanBuilder.PutTag(label.Key, label.Value.ToString()); } var status = spanData.Status;