diff --git a/pkgs/telemetry/src/TracingHook.cs b/pkgs/telemetry/src/TracingHook.cs index 7cfaa363..f03cb9a5 100644 --- a/pkgs/telemetry/src/TracingHook.cs +++ b/pkgs/telemetry/src/TracingHook.cs @@ -1,6 +1,6 @@ using System.Collections.Immutable; using System.Diagnostics; -using LaunchDarkly.Sdk.Internal; +using System.Reflection; using LaunchDarkly.Sdk.Server.Hooks; namespace LaunchDarkly.Sdk.Server.Telemetry @@ -72,11 +72,13 @@ public TracingHook Build() public class TracingHook : Hook { + private static readonly AssemblyName AssemblyName = typeof(TracingHook).GetTypeInfo().Assembly.GetName(); + /// - /// Used to create new activities if the TracingHook is configured to create them. + /// Used as the source of activities if the TracingHook is configured to create them. /// - private static readonly ActivitySource Source = new ActivitySource("LaunchDarkly.ServerSdk", - AssemblyVersions.GetAssemblyVersionForType(typeof(LdClient)).ToString()); + private static readonly ActivitySource Source = new ActivitySource(AssemblyName.Name, + AssemblyName.Version.ToString()); /// /// Returns the name of the ActivitySource that the TracingHook uses to generate Activities. diff --git a/pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj b/pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj index d57fe06e..43981bac 100644 --- a/pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj +++ b/pkgs/telemetry/test/LaunchDarkly.ServerSdk.Telemetry.Tests.csproj @@ -4,7 +4,7 @@ single framework that we are testing; this allows us to test with older SDK versions that would error out if they saw any newer target frameworks listed here, even if we weren't running those. --> - netstandard2.0;net462;net6.0 + net462;net6.0 $(TESTFRAMEWORK) LaunchDarkly.ServerSdk.Telemetry.Tests LaunchDarkly.ServerSdk.Telemetry.Tests @@ -20,25 +20,8 @@ + - - - - Always - - - Always - - - Always - - - Always - - - Always - - diff --git a/pkgs/telemetry/test/Telemetry/TracingHookTests.cs b/pkgs/telemetry/test/TracingHookTests.cs similarity index 97% rename from pkgs/telemetry/test/Telemetry/TracingHookTests.cs rename to pkgs/telemetry/test/TracingHookTests.cs index db1d82e5..912429a0 100644 --- a/pkgs/telemetry/test/Telemetry/TracingHookTests.cs +++ b/pkgs/telemetry/test/TracingHookTests.cs @@ -55,7 +55,7 @@ public void TracingHookCreatesRootSpans(bool createSpans) { ICollection exportedItems = new Collection(); - var tracerProvider = OpenTelemetry.Sdk.CreateTracerProviderBuilder() + _ = OpenTelemetry.Sdk.CreateTracerProviderBuilder() .AddSource(TracingHook.ActivitySourceName) .AddInMemoryExporter(exportedItems) .Build(); @@ -102,7 +102,7 @@ public void TracingHookCreatesChildSpans(bool createSpans) var testSource = new ActivitySource("test-source", "1.0.0"); - var tracerProvider = OpenTelemetry.Sdk.CreateTracerProviderBuilder() + _ = OpenTelemetry.Sdk.CreateTracerProviderBuilder() .AddSource("test-source") .AddSource(TracingHook.ActivitySourceName) .SetResourceBuilder( @@ -157,9 +157,7 @@ public void TracingHookIncludesVariant(bool includeVariant) { ICollection exportedItems = new Collection(); - var testSource = new ActivitySource("test-source", "1.0.0"); - - var tracerProvider = OpenTelemetry.Sdk.CreateTracerProviderBuilder() + _ = OpenTelemetry.Sdk.CreateTracerProviderBuilder() .AddSource("test-source") .SetResourceBuilder( ResourceBuilder.CreateDefault() @@ -167,6 +165,8 @@ public void TracingHookIncludesVariant(bool includeVariant) .AddInMemoryExporter(exportedItems) .Build(); + var testSource = new ActivitySource("test-source", "1.0.0"); + var hookUnderTest = TracingHook.Builder().IncludeVariant(includeVariant).Build(); var featureKey = "feature-key"; var context = Context.New("foo");