From 45e32b56e818a1ef5aecbef95ed532640e6205f0 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 24 Jul 2019 13:54:56 -0700 Subject: [PATCH 01/11] Add Azure collector --- .../AzureSdkCollector.cs | 141 ++++++++++++++++++ .../OpenTelemetry.Collector.Azure.csproj | 10 ++ .../Implementation/TraceExporterHandler.cs | 2 +- 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs create mode 100644 src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj diff --git a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs new file mode 100644 index 00000000000..752a62b9ec3 --- /dev/null +++ b/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs @@ -0,0 +1,141 @@ +// +// Copyright 2018, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +namespace OpenTelemetry.Collectors.Azure +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Diagnostics; + using OpenTelemetry.Context; + using OpenTelemetry.Trace; + + public class AzureSdkCollector : IDisposable, IObserver, IObserver> + { + private readonly ConcurrentDictionary scopes = new ConcurrentDictionary(new ActivityReferenceEqualityComparer()); + + private readonly ITracer tracer; + + private readonly ISampler sampler; + + private List subscriptions = new List(); + + public AzureSdkCollector(ITracer tracer, ISampler sampler) + { + this.tracer = tracer; + this.sampler = sampler; + + this.subscriptions.Add(DiagnosticListener.AllListeners.Subscribe(this)); + } + + public void Dispose() + { + lock (this.subscriptions) + { + foreach (var subscription in this.subscriptions) + { + subscription.Dispose(); + } + } + } + + public void OnCompleted() + { + } + + public void OnError(Exception error) + { + } + + public void OnNext(KeyValuePair value) + { + if (value.Key.EndsWith("Start")) + { + this.OnStartActivity(Activity.Current, value.Value); + } + else if (value.Key.EndsWith("Stop")) + { + // Current.Parent is used because OT wraps additional Activity over + this.OnStopActivity(Activity.Current.Parent, value.Value); + } + else if (value.Key.EndsWith("Exception")) + { + // Current.Parent is used because OT wraps additional Activity over + this.OnException(Activity.Current.Parent, value.Value); + } + } + + public void OnNext(DiagnosticListener value) + { + if (value.Name.StartsWith("Azure")) + { + lock (this.subscriptions) + { + this.subscriptions.Add(value.Subscribe(this)); + } + } + } + + private void OnStartActivity(Activity current, object valueValue) + { + var span = this.tracer.SpanBuilder(current.OperationName) + .SetSampler(this.sampler) + .StartSpan(); + + this.scopes.TryAdd(current, this.tracer.WithSpan(span)); + } + + private void OnStopActivity(Activity current, object valueValue) + { + var span = this.tracer.CurrentSpan; + foreach (var keyValuePair in current.Tags) + { + span.SetAttribute(keyValuePair.Key, keyValuePair.Value); + } + + this.scopes.TryRemove(current, out var scope); + + scope?.Dispose(); + } + + private void OnException(Activity current, object valueValue) + { + var span = this.tracer.CurrentSpan; + foreach (var keyValuePair in current.Tags) + { + span.SetAttribute(keyValuePair.Key, keyValuePair.Value); + } + + span.Status = Status.Unknown; + + this.scopes.TryRemove(current, out var scope); + scope?.Dispose(); + } + + public class ActivityReferenceEqualityComparer : EqualityComparer + { + public override bool Equals(Activity x, Activity y) + { + return ReferenceEquals(x, y); + } + + public override int GetHashCode(Activity obj) + { + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj); + } + } + } +} diff --git a/src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj b/src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj new file mode 100644 index 00000000000..29bfd46a780 --- /dev/null +++ b/src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj @@ -0,0 +1,10 @@ + + + + netstandard2.0 + + + + + + diff --git a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs index b43a65e56e2..839eb67993d 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/Implementation/TraceExporterHandler.cs @@ -91,7 +91,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; From d807eb5f89186c99ea491e42071927e3bc7363e6 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 24 Jul 2019 15:02:18 -0700 Subject: [PATCH 02/11] Url as the name --- .../AzureSdkCollector.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs index 752a62b9ec3..e81173b4f5b 100644 --- a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs @@ -91,7 +91,22 @@ public void OnNext(DiagnosticListener value) private void OnStartActivity(Activity current, object valueValue) { - var span = this.tracer.SpanBuilder(current.OperationName) + var operationName = current.OperationName; + foreach (var keyValuePair in current.Tags) + { + if (keyValuePair.Key == "http.url") + { + var indexOfQuery = keyValuePair.Value.IndexOf('?'); + if (indexOfQuery == -1) + { + indexOfQuery = keyValuePair.Value.Length; + } + + operationName = keyValuePair.Value.Substring(0, indexOfQuery); + } + } + + var span = this.tracer.SpanBuilder(operationName) .SetSampler(this.sampler) .StartSpan(); From 380dbe337e42b93bd0f3b02af462dc2aea2ef007 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Wed, 24 Jul 2019 15:23:43 -0700 Subject: [PATCH 03/11] Full --- src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs index e81173b4f5b..6c3c4443b81 100644 --- a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs @@ -96,13 +96,7 @@ private void OnStartActivity(Activity current, object valueValue) { if (keyValuePair.Key == "http.url") { - var indexOfQuery = keyValuePair.Value.IndexOf('?'); - if (indexOfQuery == -1) - { - indexOfQuery = keyValuePair.Value.Length; - } - - operationName = keyValuePair.Value.Substring(0, indexOfQuery); + operationName = keyValuePair.Value; } } From 86686ce7151b2293dd4f3530ba6f714b9fec75d5 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 26 Jul 2019 10:20:50 -0700 Subject: [PATCH 04/11] Comments --- .../OpenTelemetry.Collector.Azure.csproj | 10 ------ .../AzureSdkCollector.cs | 31 ++++++++++++------- 2 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj rename src/{OpenTelemetry.Collector.Azure => OpenTelemetry.Collector.Dependencies}/AzureSdkCollector.cs (83%) diff --git a/src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj b/src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj deleted file mode 100644 index 29bfd46a780..00000000000 --- a/src/OpenTelemetry.Collector.Azure/OpenTelemetry.Collector.Azure.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - netstandard2.0 - - - - - - diff --git a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs similarity index 83% rename from src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs rename to src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs index 6c3c4443b81..bb7e85d92e9 100644 --- a/src/OpenTelemetry.Collector.Azure/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs @@ -14,7 +14,7 @@ // limitations under the License. // -namespace OpenTelemetry.Collectors.Azure +namespace OpenTelemetry.Collector.Dependencies { using System; using System.Collections.Concurrent; @@ -62,19 +62,26 @@ public void OnError(Exception error) public void OnNext(KeyValuePair value) { - if (value.Key.EndsWith("Start")) + try { - this.OnStartActivity(Activity.Current, value.Value); - } - else if (value.Key.EndsWith("Stop")) - { - // Current.Parent is used because OT wraps additional Activity over - this.OnStopActivity(Activity.Current.Parent, value.Value); + if (value.Key.EndsWith("Start")) + { + this.OnStartActivity(Activity.Current, value.Value); + } + else if (value.Key.EndsWith("Stop")) + { + // Current.Parent is used because OT wraps additional Activity over + this.OnStopActivity(Activity.Current, value.Value); + } + else if (value.Key.EndsWith("Exception")) + { + // Current.Parent is used because OT wraps additional Activity over + this.OnException(Activity.Current, value.Value); + } } - else if (value.Key.EndsWith("Exception")) + catch (Exception) { - // Current.Parent is used because OT wraps additional Activity over - this.OnException(Activity.Current.Parent, value.Value); + // TODO: Log } } @@ -101,6 +108,8 @@ private void OnStartActivity(Activity current, object valueValue) } var span = this.tracer.SpanBuilder(operationName) + .SetCreateChild(false) + .SetSpanKind(SpanKind.Client) .SetSampler(this.sampler) .StartSpan(); From 120b74892c6473f7a76ccb955639166905416d5c Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 26 Jul 2019 11:00:00 -0700 Subject: [PATCH 05/11] More feedback --- .../AzureSdkCollector.cs | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs index bb7e85d92e9..c0045c81ce4 100644 --- a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs @@ -17,7 +17,6 @@ namespace OpenTelemetry.Collector.Dependencies { using System; - using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using OpenTelemetry.Context; @@ -25,8 +24,6 @@ namespace OpenTelemetry.Collector.Dependencies public class AzureSdkCollector : IDisposable, IObserver, IObserver> { - private readonly ConcurrentDictionary scopes = new ConcurrentDictionary(new ActivityReferenceEqualityComparer()); - private readonly ITracer tracer; private readonly ISampler sampler; @@ -113,7 +110,7 @@ private void OnStartActivity(Activity current, object valueValue) .SetSampler(this.sampler) .StartSpan(); - this.scopes.TryAdd(current, this.tracer.WithSpan(span)); + this.tracer.WithSpan(span); } private void OnStopActivity(Activity current, object valueValue) @@ -124,9 +121,7 @@ private void OnStopActivity(Activity current, object valueValue) span.SetAttribute(keyValuePair.Key, keyValuePair.Value); } - this.scopes.TryRemove(current, out var scope); - - scope?.Dispose(); + this.tracer.CurrentSpan.End(); } private void OnException(Activity current, object valueValue) @@ -139,21 +134,7 @@ private void OnException(Activity current, object valueValue) span.Status = Status.Unknown; - this.scopes.TryRemove(current, out var scope); - scope?.Dispose(); - } - - public class ActivityReferenceEqualityComparer : EqualityComparer - { - public override bool Equals(Activity x, Activity y) - { - return ReferenceEquals(x, y); - } - - public override int GetHashCode(Activity obj) - { - return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(obj); - } + this.tracer.CurrentSpan.End(); } } } From 936e67458ecbc95682b4a4c9ef1d6f2b9fe3d9ba Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Fri, 26 Jul 2019 11:25:03 -0700 Subject: [PATCH 06/11] More --- .../AzureSdkCollector.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs index c0045c81ce4..39b3e36741b 100644 --- a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs @@ -127,14 +127,8 @@ private void OnStopActivity(Activity current, object valueValue) private void OnException(Activity current, object valueValue) { var span = this.tracer.CurrentSpan; - foreach (var keyValuePair in current.Tags) - { - span.SetAttribute(keyValuePair.Key, keyValuePair.Value); - } - - span.Status = Status.Unknown; - this.tracer.CurrentSpan.End(); + span.Status = Status.Unknown.WithDescription(valueValue?.ToString()); } } } From 21a000d09ec80114e58131bfd6bc70f59dadd4cd Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Mon, 29 Jul 2019 13:30:00 -0700 Subject: [PATCH 07/11] Start with OK span --- src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs index 39b3e36741b..6b562e29458 100644 --- a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs @@ -110,6 +110,8 @@ private void OnStartActivity(Activity current, object valueValue) .SetSampler(this.sampler) .StartSpan(); + span.Status = Status.Ok; + this.tracer.WithSpan(span); } From 28dd41730ad7da91513b9d050e00673a53cc394d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 30 Jul 2019 08:53:15 -0700 Subject: [PATCH 08/11] fb --- ...ector.cs => AzureSdkDiagnosticListener.cs} | 54 ++++--------------- .../DependenciesCollector.cs | 6 ++- 2 files changed, 14 insertions(+), 46 deletions(-) rename src/OpenTelemetry.Collector.Dependencies/{AzureSdkCollector.cs => AzureSdkDiagnosticListener.cs} (58%) diff --git a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs similarity index 58% rename from src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs rename to src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs index 6b562e29458..ce8894d09e6 100644 --- a/src/OpenTelemetry.Collector.Dependencies/AzureSdkCollector.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs @@ -1,4 +1,4 @@ -// +// // Copyright 2018, OpenTelemetry Authors // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,10 +19,10 @@ namespace OpenTelemetry.Collector.Dependencies using System; using System.Collections.Generic; using System.Diagnostics; - using OpenTelemetry.Context; + using OpenTelemetry.Collector.Dependencies.Common; using OpenTelemetry.Trace; - public class AzureSdkCollector : IDisposable, IObserver, IObserver> + internal class AzureSdkDiagnosticListener : ListenerHandler { private readonly ITracer tracer; @@ -30,12 +30,11 @@ public class AzureSdkCollector : IDisposable, IObserver, IOb private List subscriptions = new List(); - public AzureSdkCollector(ITracer tracer, ISampler sampler) + public AzureSdkDiagnosticListener(string sourceName, ITracer tracer, ISampler sampler) + : base(sourceName, tracer, null) { this.tracer = tracer; this.sampler = sampler; - - this.subscriptions.Add(DiagnosticListener.AllListeners.Subscribe(this)); } public void Dispose() @@ -57,43 +56,7 @@ public void OnError(Exception error) { } - public void OnNext(KeyValuePair value) - { - try - { - if (value.Key.EndsWith("Start")) - { - this.OnStartActivity(Activity.Current, value.Value); - } - else if (value.Key.EndsWith("Stop")) - { - // Current.Parent is used because OT wraps additional Activity over - this.OnStopActivity(Activity.Current, value.Value); - } - else if (value.Key.EndsWith("Exception")) - { - // Current.Parent is used because OT wraps additional Activity over - this.OnException(Activity.Current, value.Value); - } - } - catch (Exception) - { - // TODO: Log - } - } - - public void OnNext(DiagnosticListener value) - { - if (value.Name.StartsWith("Azure")) - { - lock (this.subscriptions) - { - this.subscriptions.Add(value.Subscribe(this)); - } - } - } - - private void OnStartActivity(Activity current, object valueValue) + public override void OnStartActivity(Activity current, object valueValue) { var operationName = current.OperationName; foreach (var keyValuePair in current.Tags) @@ -101,6 +64,7 @@ private void OnStartActivity(Activity current, object valueValue) if (keyValuePair.Key == "http.url") { operationName = keyValuePair.Value; + break; } } @@ -115,7 +79,7 @@ private void OnStartActivity(Activity current, object valueValue) this.tracer.WithSpan(span); } - private void OnStopActivity(Activity current, object valueValue) + public override void OnStopActivity(Activity current, object valueValue) { var span = this.tracer.CurrentSpan; foreach (var keyValuePair in current.Tags) @@ -126,7 +90,7 @@ private void OnStopActivity(Activity current, object valueValue) this.tracer.CurrentSpan.End(); } - private void OnException(Activity current, object valueValue) + public override void OnException(Activity current, object valueValue) { var span = this.tracer.CurrentSpan; diff --git a/src/OpenTelemetry.Collector.Dependencies/DependenciesCollector.cs b/src/OpenTelemetry.Collector.Dependencies/DependenciesCollector.cs index 2ed0259ab94..dd838c693f8 100644 --- a/src/OpenTelemetry.Collector.Dependencies/DependenciesCollector.cs +++ b/src/OpenTelemetry.Collector.Dependencies/DependenciesCollector.cs @@ -40,7 +40,11 @@ public DependenciesCollector(DependenciesCollectorOptions options, ITracer trace { this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber( new Dictionary, ListenerHandler>>() - { { "HttpHandlerDiagnosticListener", (t, s) => new HttpHandlerDiagnosticListener(t, s) } }, + { + { "HttpHandlerDiagnosticListener", (t, s) => new HttpHandlerDiagnosticListener(t, s) }, + { "Azure.Clients", (t, s) => new AzureSdkDiagnosticListener("Azure.Clients", t, sampler) }, + { "Azure.Pipeline", (t, s) => new AzureSdkDiagnosticListener("Azure.Pipeline", t, sampler) }, + }, tracer, x => { From 0061b69d38a534c3ba418ed871b6fc7f83cb6caf Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 30 Jul 2019 12:09:57 -0700 Subject: [PATCH 09/11] FB --- src/Directory.Build.targets | 5 +---- .../AzureSdkDiagnosticListener.cs | 14 -------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 347a97078b1..df626b008da 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -2,9 +2,6 @@ - - all - runtime; build; native; contentfiles; analyzers - + \ No newline at end of file diff --git a/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs index ce8894d09e6..c3e1a5e95d0 100644 --- a/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs @@ -17,7 +17,6 @@ namespace OpenTelemetry.Collector.Dependencies { using System; - using System.Collections.Generic; using System.Diagnostics; using OpenTelemetry.Collector.Dependencies.Common; using OpenTelemetry.Trace; @@ -28,8 +27,6 @@ internal class AzureSdkDiagnosticListener : ListenerHandler private readonly ISampler sampler; - private List subscriptions = new List(); - public AzureSdkDiagnosticListener(string sourceName, ITracer tracer, ISampler sampler) : base(sourceName, tracer, null) { @@ -37,17 +34,6 @@ public AzureSdkDiagnosticListener(string sourceName, ITracer tracer, ISampler sa this.sampler = sampler; } - public void Dispose() - { - lock (this.subscriptions) - { - foreach (var subscription in this.subscriptions) - { - subscription.Dispose(); - } - } - } - public void OnCompleted() { } From 6f7a4b7e06f0b94ebb57407c3069336c689445bd Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 30 Jul 2019 12:21:22 -0700 Subject: [PATCH 10/11] undo --- src/Directory.Build.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index df626b008da..347a97078b1 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -2,6 +2,9 @@ - + + all + runtime; build; native; contentfiles; analyzers + \ No newline at end of file From d4893e4f3bf8c2c1802fadf99ee8817bf14a1125 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 30 Jul 2019 15:21:11 -0700 Subject: [PATCH 11/11] Http --- .../AzureSdkDiagnosticListener.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs b/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs index c3e1a5e95d0..6dceb006ddb 100644 --- a/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs +++ b/src/OpenTelemetry.Collector.Dependencies/AzureSdkDiagnosticListener.cs @@ -44,21 +44,25 @@ public void OnError(Exception error) public override void OnStartActivity(Activity current, object valueValue) { + bool isHttp = false; var operationName = current.OperationName; foreach (var keyValuePair in current.Tags) { if (keyValuePair.Key == "http.url") { + isHttp = true; operationName = keyValuePair.Value; break; } } - var span = this.tracer.SpanBuilder(operationName) + var spanBuilder = this.tracer.SpanBuilder(operationName) .SetCreateChild(false) - .SetSpanKind(SpanKind.Client) - .SetSampler(this.sampler) - .StartSpan(); + .SetSampler(this.sampler); + + spanBuilder.SetSpanKind(isHttp ? SpanKind.Client : SpanKind.Internal); + + var span = spanBuilder.StartSpan(); span.Status = Status.Ok;