diff --git a/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/DiagnosticsActivityEventSubscriber.cs b/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/DiagnosticsActivityEventSubscriber.cs index 01abc9d..3de277d 100644 --- a/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/DiagnosticsActivityEventSubscriber.cs +++ b/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/DiagnosticsActivityEventSubscriber.cs @@ -12,8 +12,7 @@ public class DiagnosticsActivityEventSubscriber : IEventSubscriber private readonly InstrumentationOptions _options; internal static readonly AssemblyName AssemblyName = typeof(DiagnosticsActivityEventSubscriber).Assembly.GetName(); internal static readonly string ActivitySourceName = AssemblyName.Name; - internal static readonly Version Version = AssemblyName.Version; - internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString()); + internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, SignalVersionHelper.GetVersion<DiagnosticsActivityEventSubscriber>()); public const string ActivityName = "MongoDB.Driver.Core.Events.Command"; diff --git a/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/SignalVersionHelper.cs b/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/SignalVersionHelper.cs new file mode 100644 index 0000000..a1915b8 --- /dev/null +++ b/src/MongoDB.Driver.Core.Extensions.DiagnosticSources/SignalVersionHelper.cs @@ -0,0 +1,11 @@ +using System.Reflection; + +namespace MongoDB.Driver.Core.Extensions.DiagnosticSources; + +internal static class SignalVersionHelper +{ + public static string GetVersion<T>() + { + return typeof(T).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion.Split('+')[0]; + } +} \ No newline at end of file