Skip to content

Commit cc310e6

Browse files
authored
Use actual version of the Npgsql for ActivitySource (#6277)
1 parent 4f7cf71 commit cc310e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Npgsql/NpgsqlActivitySource.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
using System.Diagnostics;
55
using System.Net;
66
using System.Net.Sockets;
7+
using System.Reflection;
78

89
namespace Npgsql;
910

1011
static class NpgsqlActivitySource
1112
{
12-
static readonly ActivitySource Source = new("Npgsql", "0.2.0");
13+
static readonly ActivitySource Source = new("Npgsql", GetLibraryVersion());
1314

1415
internal static bool IsEnabled => Source.HasListeners();
1516

@@ -143,4 +144,9 @@ internal static void SetException(Activity activity, Exception ex, bool escaped
143144
activity.SetStatus(ActivityStatusCode.Error, statusDescription);
144145
activity.Dispose();
145146
}
147+
148+
static string GetLibraryVersion()
149+
=> typeof(NpgsqlDataSource).Assembly
150+
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
151+
.InformationalVersion ?? "UNKNOWN";
146152
}

0 commit comments

Comments
 (0)