From 7138a8098cd726f234a5e8d417ea400b0025484c Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Wed, 26 Nov 2025 12:39:58 +0100 Subject: [PATCH] Remove build pre-release tags and build metadata from service.version --- .../OpenTelemetry/OpenTelemetryExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/Elastic.Documentation.Api.Infrastructure/OpenTelemetry/OpenTelemetryExtensions.cs b/src/api/Elastic.Documentation.Api.Infrastructure/OpenTelemetry/OpenTelemetryExtensions.cs index fc33e4675..d6572a751 100644 --- a/src/api/Elastic.Documentation.Api.Infrastructure/OpenTelemetry/OpenTelemetryExtensions.cs +++ b/src/api/Elastic.Documentation.Api.Infrastructure/OpenTelemetry/OpenTelemetryExtensions.cs @@ -105,15 +105,18 @@ private static void ConfigureServiceVersionAttributes(TBuilder builder where TBuilder : IHostApplicationBuilder { - var serviceVersion = Assembly.GetExecutingAssembly() + var informationalVersion = Assembly.GetExecutingAssembly() .GetCustomAttribute()?.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("service.version", serviceVersion); _ = builder.Services.ConfigureOpenTelemetryTracerProvider(tracerProviderBuilder =>