Skip to content

Commit

Permalink
Merge pull request #27 from Kielek/activity-source-version
Browse files Browse the repository at this point in the history
Set ActivitySource.Version to NuGet package version
  • Loading branch information
jbogard authored May 14, 2024
2 parents a66c27e + de80864 commit 906bafa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
@@ -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];
}
}

0 comments on commit 906bafa

Please sign in to comment.