Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,18 @@ private static void ConfigureServiceVersionAttributes<TBuilder>(TBuilder builder
where TBuilder : IHostApplicationBuilder
{

var serviceVersion = Assembly.GetExecutingAssembly()
var informationalVersion = Assembly.GetExecutingAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;

if (serviceVersion is null)
if (informationalVersion is null)
{
Console.WriteLine($"Unable to determine service.version from {nameof(AssemblyInformationalVersionAttribute)}. Skipping setting it.");
return;
}

// Extract just major.minor.patch by removing prerelease tags (-) and build metadata (+)
var serviceVersion = informationalVersion.Split(['+', '-'])[0];

var versionAttribute = new KeyValuePair<string, object>("service.version", serviceVersion);

_ = builder.Services.ConfigureOpenTelemetryTracerProvider(tracerProviderBuilder =>
Expand Down
Loading