From f3164d31a2974931784255f1ee7ceaa73674f429 Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Wed, 11 Nov 2020 22:06:32 -0300 Subject: [PATCH 1/6] Fixing ActivitySource from DiagnosticSource --- .../Implementation/HttpInListener.cs | 5 ++++- .../Implementation/HttpInListener.cs | 5 ++++- .../Implementation/GrpcClientDiagnosticListener.cs | 7 +++++-- .../HttpHandlerDiagnosticListener.cs | 6 +++++- .../SqlClientInstrumentation.cs | 1 + src/OpenTelemetry/Trace/ActivitySourceAdapter.cs | 13 ++++++++++++- .../Trace/ActivitySourceAdapterBenchmark.cs | 3 ++- .../Trace/ActivitySourceAdapterTest.cs | 14 +++++++------- .../Trace/TracerProviderSdkTest.cs | 6 +++--- 9 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs index 25fc3b9773..8fcae5d95d 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs @@ -26,8 +26,11 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation { internal class HttpInListener : ListenerHandler { + internal const string ActivitySourceName = "OpenTelemetry.Http"; internal const string ActivityNameByHttpInListener = "ActivityCreatedByHttpInListener"; internal const string ActivityOperationName = "Microsoft.AspNet.HttpReqIn"; + internal static readonly Version Version = typeof(HttpInListener).Assembly.GetName().Version; + internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); private static readonly Func> HttpRequestHeaderValuesGetter = (request, name) => request.Headers.GetValues(name); private readonly PropertyFetcher routeFetcher = new PropertyFetcher("Route"); private readonly PropertyFetcher routeTemplateFetcher = new PropertyFetcher("RouteTemplate"); @@ -106,7 +109,7 @@ public override void OnStartActivity(Activity activity, object payload) var path = requestValues.Path; activity.DisplayName = path; - this.activitySource.Start(activity, ActivityKind.Server); + this.activitySource.Start(activity, ActivityKind.Server, ActivitySource); if (activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 40ed598b23..943741794c 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -30,6 +30,9 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation { internal class HttpInListener : ListenerHandler { + internal const string ActivitySourceName = "OpenTelemetry.AspNetCore"; + internal static readonly Version Version = typeof(HttpInListener).Assembly.GetName().Version; + internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); private const string UnknownHostName = "UNKNOWN-HOST"; private const string ActivityNameByHttpInListener = "ActivityCreatedByHttpInListener"; private static readonly Func> HttpRequestHeaderValuesGetter = (request, name) => request.Headers[name]; @@ -104,7 +107,7 @@ public override void OnStartActivity(Activity activity, object payload) } } - this.activitySource.Start(activity, ActivityKind.Server); + this.activitySource.Start(activity, ActivityKind.Server, ActivitySource); if (activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs index 678fc97643..9f54dd6572 100644 --- a/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs @@ -25,8 +25,11 @@ namespace OpenTelemetry.Instrumentation.GrpcNetClient.Implementation { internal class GrpcClientDiagnosticListener : ListenerHandler { - private readonly GrpcClientInstrumentationOptions options; + internal const string ActivitySourceName = "OpenTelemetry.Grpc"; + internal static readonly Version Version = typeof(GrpcClientDiagnosticListener).Assembly.GetName().Version; + internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); + private readonly GrpcClientInstrumentationOptions options; private readonly ActivitySourceAdapter activitySource; private readonly PropertyFetcher startRequestFetcher = new PropertyFetcher("Request"); @@ -83,7 +86,7 @@ public override void OnStartActivity(Activity activity, object payload) activity.DisplayName = grpcMethod?.Trim('/'); - this.activitySource.Start(activity, ActivityKind.Client); + this.activitySource.Start(activity, ActivityKind.Client, ActivitySource); if (activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index 9e07be88be..d699e830b5 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -30,6 +30,10 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation { internal class HttpHandlerDiagnosticListener : ListenerHandler { + internal const string ActivitySourceName = "OpenTelemetry.Http"; + internal static readonly Version Version = typeof(HttpHandlerDiagnosticListener).Assembly.GetName().Version; + internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); + private static readonly Regex CoreAppMajorVersionCheckRegex = new Regex("^\\.NETCoreApp,Version=v(\\d+)\\.", RegexOptions.Compiled | RegexOptions.IgnoreCase); private readonly ActivitySourceAdapter activitySource; @@ -79,7 +83,7 @@ public override void OnStartActivity(Activity activity, object payload) activity.DisplayName = HttpTagHelper.GetOperationNameForHttpMethod(request.Method); - this.activitySource.Start(activity, ActivityKind.Client); + this.activitySource.Start(activity, ActivityKind.Client, ActivitySource); if (activity.IsAllDataRequested) { diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentation.cs b/src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentation.cs index fa7b6569a1..5e3f2faa23 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentation.cs +++ b/src/OpenTelemetry.Instrumentation.SqlClient/SqlClientInstrumentation.cs @@ -14,6 +14,7 @@ // limitations under the License. // using System; +using System.Diagnostics; using OpenTelemetry.Instrumentation.SqlClient.Implementation; namespace OpenTelemetry.Instrumentation.SqlClient diff --git a/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs b/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs index 6e514d5f7e..0962d5475c 100644 --- a/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs +++ b/src/OpenTelemetry/Trace/ActivitySourceAdapter.cs @@ -39,6 +39,7 @@ namespace OpenTelemetry.Trace internal class ActivitySourceAdapter { private static readonly Action SetKindProperty = CreateActivityKindSetter(); + private static readonly Action SetActivitySourceProperty = CreateActivitySourceSetter(); private readonly Sampler sampler; private readonly Action getRequestedDataAction; private BaseProcessor activityProcessor; @@ -71,11 +72,13 @@ private ActivitySourceAdapter() /// /// to be started. /// ActivityKind to be set of the activity. + /// ActivitySource to be set of the activity. [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "ActivityProcessor is hot path")] - public void Start(Activity activity, ActivityKind kind) + public void Start(Activity activity, ActivityKind kind, ActivitySource source) { OpenTelemetrySdkEventSource.Log.ActivityStarted(activity); + SetActivitySourceProperty(activity, source); SetKindProperty(activity, kind); this.getRequestedDataAction(activity); if (activity.IsAllDataRequested) @@ -103,6 +106,14 @@ internal void UpdateProcessor(BaseProcessor processor) this.activityProcessor = processor; } + private static Action CreateActivitySourceSetter() + { + ParameterExpression instance = Expression.Parameter(typeof(Activity), "instance"); + ParameterExpression propertyValue = Expression.Parameter(typeof(ActivitySource), "propertyValue"); + var body = Expression.Assign(Expression.Property(instance, "Source"), propertyValue); + return Expression.Lambda>(body, instance, propertyValue).Compile(); + } + private static Action CreateActivityKindSetter() { ParameterExpression instance = Expression.Parameter(typeof(Activity), "instance"); diff --git a/test/Benchmarks/Trace/ActivitySourceAdapterBenchmark.cs b/test/Benchmarks/Trace/ActivitySourceAdapterBenchmark.cs index e88407ae76..468d31ba57 100644 --- a/test/Benchmarks/Trace/ActivitySourceAdapterBenchmark.cs +++ b/test/Benchmarks/Trace/ActivitySourceAdapterBenchmark.cs @@ -56,6 +56,7 @@ public void ActivitySourceAdapterStartStop() private class TestInstrumentation { + internal static ActivitySource ActivitySource = new ActivitySource("test", "1.0.0"); private ActivitySourceAdapter adapter; public TestInstrumentation(ActivitySourceAdapter adapter) @@ -65,7 +66,7 @@ public TestInstrumentation(ActivitySourceAdapter adapter) public void Start(Activity activity) { - this.adapter.Start(activity, ActivityKind.Internal); + this.adapter.Start(activity, ActivityKind.Internal, ActivitySource); } public void Stop(Activity activity) diff --git a/test/OpenTelemetry.Tests/Trace/ActivitySourceAdapterTest.cs b/test/OpenTelemetry.Tests/Trace/ActivitySourceAdapterTest.cs index 2bade8904c..87f52e15a6 100644 --- a/test/OpenTelemetry.Tests/Trace/ActivitySourceAdapterTest.cs +++ b/test/OpenTelemetry.Tests/Trace/ActivitySourceAdapterTest.cs @@ -62,7 +62,7 @@ public void ActivitySourceAdapterSetsKind(ActivityKind kind) { var activity = new Activity("test"); activity.Start(); - this.activitySourceAdapter.Start(activity, kind); + this.activitySourceAdapter.Start(activity, kind, new ActivitySource("test", "1.0.0")); Assert.Equal(kind, activity.Kind); } @@ -100,7 +100,7 @@ public void ActivitySourceAdapterCallsStartStopActivityProcessor1(SamplingDecisi var activity = new Activity("test"); activity.Start(); - this.activitySourceAdapter.Start(activity, ActivityKind.Producer); + this.activitySourceAdapter.Start(activity, ActivityKind.Producer, new ActivitySource("test", "1.0.0")); activity.Stop(); this.activitySourceAdapter.Stop(activity); @@ -141,7 +141,7 @@ public void ActivitySourceAdapterCallsStartStopActivityProcessor2(bool isSampled var activity = new Activity("test"); activity.Start(); - this.activitySourceAdapter.Start(activity, ActivityKind.Internal); + this.activitySourceAdapter.Start(activity, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); activity.Stop(); this.activitySourceAdapter.Stop(activity); @@ -164,7 +164,7 @@ public void ActivitySourceAdapterPopulatesSamplingAttributesToActivity(SamplingD var activity = new Activity("test"); activity.Start(); - this.activitySourceAdapter.Start(activity, ActivityKind.Internal); + this.activitySourceAdapter.Start(activity, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); if (sampling != SamplingDecision.Drop) { Assert.Contains(new KeyValuePair("tagkeybysampler", "tagvalueaddedbysampler"), activity.TagObjects); @@ -186,7 +186,7 @@ public void ActivitySourceAdapterPopulatesSamplingParamsCorrectlyForRootActivity // and becomes root activity var activity = new Activity("test"); activity.Start(); - this.activitySourceAdapter.Start(activity, ActivityKind.Internal); + this.activitySourceAdapter.Start(activity, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); activity.Stop(); this.activitySourceAdapter.Stop(activity); } @@ -217,7 +217,7 @@ public void ActivitySourceAdapterPopulatesSamplingParamsCorrectlyForActivityWith var activity = new Activity("test").SetParentId(remoteParentId); activity.TraceStateString = tracestate; activity.Start(); - this.activitySourceAdapter.Start(activity, ActivityKind.Internal); + this.activitySourceAdapter.Start(activity, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); activity.Stop(); this.activitySourceAdapter.Stop(activity); } @@ -250,7 +250,7 @@ public void ActivitySourceAdapterPopulatesSamplingParamsCorrectlyForActivityWith // i.e of the parent Activity var activity = new Activity("test"); activity.Start(); - this.activitySourceAdapter.Start(activity, ActivityKind.Client); + this.activitySourceAdapter.Start(activity, ActivityKind.Client, new ActivitySource("test", "1.0.0")); activity.Stop(); this.activitySourceAdapter.Stop(activity); diff --git a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs index cd8e099f90..356f417052 100644 --- a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs +++ b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs @@ -283,7 +283,7 @@ public void TracerProvideSdkCreatesActivitySource() var adapter = testInstrumentation.Adapter; Activity activity = new Activity("test"); activity.Start(); - adapter.Start(activity, ActivityKind.Internal); + adapter.Start(activity, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); adapter.Stop(activity); activity.Stop(); @@ -313,7 +313,7 @@ public void TracerProvideSdkCreatesActivitySource() tracerProvider.AddProcessor(testActivityProcessorNew); Activity activityNew = new Activity("test"); activityNew.Start(); - adapter.Start(activityNew, ActivityKind.Internal); + adapter.Start(activityNew, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); adapter.Stop(activityNew); activityNew.Stop(); @@ -336,7 +336,7 @@ public void TracerProvideSdkCreatesActivitySourceWhenNoProcessor() var adapter = testInstrumentation.Adapter; Activity activity = new Activity("test"); activity.Start(); - adapter.Start(activity, ActivityKind.Internal); + adapter.Start(activity, ActivityKind.Internal, new ActivitySource("test", "1.0.0")); adapter.Stop(activity); activity.Stop(); From 05cb3833f8cea7c4055c6bef417a39ff19ceffc1 Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Wed, 11 Nov 2020 22:15:28 -0300 Subject: [PATCH 2/6] updating changelog --- src/OpenTelemetry/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index e5a9475bbe..c6a6e2171a 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -11,6 +11,10 @@ `CustomProperty`. ([#1463](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1463)) * Remove RentrantExportProcessor as it is not required by spec. +* `ActivitySourceAdapter.Start` requires `ActivitySource` to update new + activities. + ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) + ## 0.8.0-beta.1 From da27289151a5786a39c7d86e867bb728988bd4de Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Wed, 11 Nov 2020 22:25:20 -0300 Subject: [PATCH 3/6] fixing changelog, updating instrumentation aspnetcore benchmark --- src/OpenTelemetry/CHANGELOG.md | 7 ++----- .../InstrumentedAspNetCoreBenchmark.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index c6a6e2171a..0dd105e0e1 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -14,16 +14,13 @@ * `ActivitySourceAdapter.Start` requires `ActivitySource` to update new activities. ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) - ## 0.8.0-beta.1 Released 2020-Nov-5 -* TracerProviderBuilder API changes - Renamed AddInstrumentation to AddDiagnosticSourceInstrumentation - and made internal. - Added AddInstrumentation +* TracerProviderBuilder API changes Renamed AddInstrumentation to + AddDiagnosticSourceInstrumentation and made internal. Added AddInstrumentation ([#1454](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1454)) * DiagnosticSource subscription helper classes (DiagnosticSourceSubscriber, diff --git a/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs b/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs index 9426417682..2742623684 100644 --- a/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs +++ b/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs @@ -15,10 +15,14 @@ // #if !NETFRAMEWORK +using System.Diagnostics; using System.Net.Http; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; using Benchmarks.Helper; +using OpenTelemetry; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; namespace Benchmarks.Instrumentation { @@ -27,15 +31,24 @@ namespace Benchmarks.Instrumentation public class InstrumentedAspNetCoreBenchmark { private const string LocalhostUrl = "http://localhost:5050"; + private const string ResourceName = "aspnetcore-service-example"; + private const string SourceName = "aspnetcore-test"; private HttpClient client; private LocalServer localServer; + private TracerProvider tracerProvider; [GlobalSetup] public void GlobalSetup() { this.localServer = new LocalServer(LocalhostUrl, true); this.client = new HttpClient(); + + this.tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddAspNetCoreInstrumentation() + .SetResource(Resources.CreateServiceResource(ResourceName)) + .AddSource(SourceName) + .Build(); } [GlobalCleanup] @@ -43,6 +56,7 @@ public void GlobalCleanup() { this.localServer.Dispose(); this.client.Dispose(); + this.tracerProvider.Dispose(); } [Benchmark] From 4c294d938425c02eb1663176b33b410b1c97ec08 Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Wed, 11 Nov 2020 22:30:53 -0300 Subject: [PATCH 4/6] undoing --- .../InstrumentedAspNetCoreBenchmark.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs b/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs index 2742623684..9426417682 100644 --- a/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs +++ b/test/Benchmarks/Instrumentation/InstrumentedAspNetCoreBenchmark.cs @@ -15,14 +15,10 @@ // #if !NETFRAMEWORK -using System.Diagnostics; using System.Net.Http; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; using Benchmarks.Helper; -using OpenTelemetry; -using OpenTelemetry.Resources; -using OpenTelemetry.Trace; namespace Benchmarks.Instrumentation { @@ -31,24 +27,15 @@ namespace Benchmarks.Instrumentation public class InstrumentedAspNetCoreBenchmark { private const string LocalhostUrl = "http://localhost:5050"; - private const string ResourceName = "aspnetcore-service-example"; - private const string SourceName = "aspnetcore-test"; private HttpClient client; private LocalServer localServer; - private TracerProvider tracerProvider; [GlobalSetup] public void GlobalSetup() { this.localServer = new LocalServer(LocalhostUrl, true); this.client = new HttpClient(); - - this.tracerProvider = Sdk.CreateTracerProviderBuilder() - .AddAspNetCoreInstrumentation() - .SetResource(Resources.CreateServiceResource(ResourceName)) - .AddSource(SourceName) - .Build(); } [GlobalCleanup] @@ -56,7 +43,6 @@ public void GlobalCleanup() { this.localServer.Dispose(); this.client.Dispose(); - this.tracerProvider.Dispose(); } [Benchmark] From d549be4aad77afe097d751623badcb181639cdc1 Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Thu, 12 Nov 2020 14:46:42 -0300 Subject: [PATCH 5/6] updating assembly naming --- .../Implementation/HttpInListener.cs | 6 ++++-- .../Implementation/HttpInListener.cs | 6 ++++-- .../Implementation/GrpcClientDiagnosticListener.cs | 6 ++++-- .../Implementation/HttpHandlerDiagnosticListener.cs | 5 +++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs index 8fcae5d95d..b3699bbb2f 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Reflection; using System.Web; using System.Web.Routing; using OpenTelemetry.Context.Propagation; @@ -26,10 +27,11 @@ namespace OpenTelemetry.Instrumentation.AspNet.Implementation { internal class HttpInListener : ListenerHandler { - internal const string ActivitySourceName = "OpenTelemetry.Http"; internal const string ActivityNameByHttpInListener = "ActivityCreatedByHttpInListener"; internal const string ActivityOperationName = "Microsoft.AspNet.HttpReqIn"; - internal static readonly Version Version = typeof(HttpInListener).Assembly.GetName().Version; + internal static readonly AssemblyName AssemblyName = typeof(HttpInListener).Assembly.GetName(); + internal static readonly string ActivitySourceName = AssemblyName.Name; + internal static readonly Version Version = AssemblyName.Version; internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); private static readonly Func> HttpRequestHeaderValuesGetter = (request, name) => request.Headers.GetValues(name); private readonly PropertyFetcher routeFetcher = new PropertyFetcher("Route"); diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs index 943741794c..96391a6816 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using Microsoft.AspNetCore.Http; @@ -30,8 +31,9 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation { internal class HttpInListener : ListenerHandler { - internal const string ActivitySourceName = "OpenTelemetry.AspNetCore"; - internal static readonly Version Version = typeof(HttpInListener).Assembly.GetName().Version; + internal static readonly AssemblyName AssemblyName = typeof(HttpInListener).Assembly.GetName(); + internal static readonly string ActivitySourceName = AssemblyName.Name; + internal static readonly Version Version = AssemblyName.Version; internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); private const string UnknownHostName = "UNKNOWN-HOST"; private const string ActivityNameByHttpInListener = "ActivityCreatedByHttpInListener"; diff --git a/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs index 9f54dd6572..25c52c270e 100644 --- a/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.GrpcNetClient/Implementation/GrpcClientDiagnosticListener.cs @@ -17,6 +17,7 @@ using System; using System.Diagnostics; using System.Net.Http; +using System.Reflection; using OpenTelemetry.Context.Propagation; using OpenTelemetry.Instrumentation.Http; using OpenTelemetry.Trace; @@ -25,8 +26,9 @@ namespace OpenTelemetry.Instrumentation.GrpcNetClient.Implementation { internal class GrpcClientDiagnosticListener : ListenerHandler { - internal const string ActivitySourceName = "OpenTelemetry.Grpc"; - internal static readonly Version Version = typeof(GrpcClientDiagnosticListener).Assembly.GetName().Version; + internal static readonly AssemblyName AssemblyName = typeof(GrpcClientDiagnosticListener).Assembly.GetName(); + internal static readonly string ActivitySourceName = AssemblyName.Name; + internal static readonly Version Version = AssemblyName.Version; internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); private readonly GrpcClientInstrumentationOptions options; diff --git a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs index d699e830b5..8fac07b9f3 100644 --- a/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs +++ b/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs @@ -30,8 +30,9 @@ namespace OpenTelemetry.Instrumentation.Http.Implementation { internal class HttpHandlerDiagnosticListener : ListenerHandler { - internal const string ActivitySourceName = "OpenTelemetry.Http"; - internal static readonly Version Version = typeof(HttpHandlerDiagnosticListener).Assembly.GetName().Version; + internal static readonly AssemblyName AssemblyName = typeof(HttpHandlerDiagnosticListener).Assembly.GetName(); + internal static readonly string ActivitySourceName = AssemblyName.Name; + internal static readonly Version Version = AssemblyName.Version; internal static readonly ActivitySource ActivitySource = new ActivitySource(ActivitySourceName, Version.ToString()); private static readonly Regex CoreAppMajorVersionCheckRegex = new Regex("^\\.NETCoreApp,Version=v(\\d+)\\.", RegexOptions.Compiled | RegexOptions.IgnoreCase); From 5d48189b96ee12f50a24e6b2b4f7ceca7f0431fe Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Thu, 12 Nov 2020 15:30:26 -0300 Subject: [PATCH 6/6] updating changelog --- .../CHANGELOG.md | 10 +++++++--- .../CHANGELOG.md | 14 +++++++++----- .../CHANGELOG.md | 6 ++++-- .../CHANGELOG.md | 10 +++++++--- .../CHANGELOG.md | 4 ++++ src/OpenTelemetry/CHANGELOG.md | 4 ++-- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md index dfa0e01d51..52a2295f09 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md @@ -2,13 +2,17 @@ ## Unreleased +* AspNetInstrumentation sets ActivitySource to activities created outside + ActivitySource. + ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) + ## 0.8.0-beta.1 Released 2020-Nov-5 -* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor - to CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator - and changed from interface to abstract class. +* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor to + CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator and + changed from interface to abstract class. ([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1427)) * Propagators.DefaultTextMapPropagator will be used as the default Propagator. ([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1428)) diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 76e72648c4..c7947085e9 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* AspNetCoreInstrumentation sets ActivitySource to activities created outside + ActivitySource. + ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) + ## 0.8.0-beta.1 Released 2020-Nov-5 @@ -11,12 +15,12 @@ Released 2020-Nov-5 ([#1408](https://github.com/open-telemetry/opentelemetry-dotnet/issues/1408)) * Added configuration option `EnableGrpcAspNetCoreSupport` to enable or disable support for adding OpenTelemetry RPC attributes when using - [Grpc.AspNetCore](https://www.nuget.org/packages/Grpc.AspNetCore/). - This option is enabled by default. + [Grpc.AspNetCore](https://www.nuget.org/packages/Grpc.AspNetCore/). This + option is enabled by default. ([#1423](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1423)) -* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor - to CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator - and changed from interface to abstract class. +* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor to + CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator and + changed from interface to abstract class. ([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1427)) * Propagators.DefaultTextMapPropagator will be used as the default Propagator ([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1428)) diff --git a/src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md index cb3ec53ded..5b70093e60 100644 --- a/src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.GrpcNetClient/CHANGELOG.md @@ -2,9 +2,11 @@ ## Unreleased -* Add context propagation, when SuppressDownstreamInstrumentation - is enabled. +* Add context propagation, when SuppressDownstreamInstrumentation is enabled. [#1464](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1464) +* GrpcNetClientInstrumentation sets ActivitySource to activities created outside + ActivitySource. + ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) ## 0.8.0-beta.1 diff --git a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md index 93cc4bce2a..9e4e97db91 100644 --- a/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* HttpInstrumentation sets ActivitySource to activities created outside + ActivitySource. + ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) + ## 0.8.0-beta.1 Released 2020-Nov-5 @@ -10,9 +14,9 @@ Released 2020-Nov-5 `HttpWebRequest` in Activity.CustomProperty. To enrich activity, use the Enrich action on the instrumentation. ([#1407](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1407)) -* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor - to CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator - and changed from interface to abstract class. +* Renamed TextMapPropagator to TraceContextPropagator, CompositePropapagor to + CompositeTextMapPropagator. IPropagator is renamed to TextMapPropagator and + changed from interface to abstract class. ([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1427)) * Propagators.DefaultTextMapPropagator will be used as the default Propagator ([#1427](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1428)) diff --git a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md index db7bec881b..12d86189d3 100644 --- a/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* SqlInstrumentation sets ActivitySource to activities created outside + ActivitySource. + ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) + ## 0.8.0-beta.1 Released 2020-Nov-5 diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 0dd105e0e1..6de4e181ed 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -11,8 +11,8 @@ `CustomProperty`. ([#1463](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1463)) * Remove RentrantExportProcessor as it is not required by spec. -* `ActivitySourceAdapter.Start` requires `ActivitySource` to update new - activities. +* `ActivitySourceAdapter` supports setting `ActivitySource` for Activities + created without `ActivitySource`. ([#1515](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1515/)) ## 0.8.0-beta.1