Skip to content

Commit

Permalink
Use assembly information version for User-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
martincostello committed Feb 3, 2023
1 parent da938d7 commit da53a18
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// </copyright>

using System.Diagnostics;
using System.Reflection;
#if NETFRAMEWORK
using System.Net.Http;
#endif
Expand Down Expand Up @@ -51,7 +52,7 @@ public class OtlpExporterOptions
private const OtlpExportProtocol DefaultOtlpExportProtocol = OtlpExportProtocol.Grpc;
private const string UserAgentProduct = "OTel-OTLP-Exporter-Dotnet";

private static readonly Version UserAgentProductVersion = GetAssemblyVersion();
private static readonly string UserAgentProductVersion = GetAssemblyVersion();

private Uri endpoint;

Expand Down Expand Up @@ -204,12 +205,12 @@ internal static void RegisterOtlpExporterOptionsFactory(IServiceCollection servi
sp.GetRequiredService<IOptionsMonitor<BatchExportActivityProcessorOptions>>().Get(name)));
}

private static Version GetAssemblyVersion()
private static string GetAssemblyVersion()
{
try
{
var assemblyName = typeof(OtlpExporterOptions).Assembly.GetName();
return assemblyName.Version;
var assemblyVersion = typeof(OtlpExporterOptions).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
return assemblyVersion.InformationalVersion;
}
catch (Exception)
{
Expand Down

0 comments on commit da53a18

Please sign in to comment.