You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
services.AddElasticApm(
new HttpDiagnosticsSubscriber(), // Instruments outbound HTTP calls via HttpClient
new EfCoreDiagnosticsSubscriber()
);
Start the application, which crashes on startup
Expected behavior
The APM agent does not throw an exception when started as part of an application with global-invariant mode enabled.
Actual behavior
The APM agent throws the following exception when started as part of an application with global-invariant mode enabled
[15:48:47 ERR] [Elastic.Apm] Failed initializing agent.
System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
ca is an invalid culture identifier.
at System.Globalization.CultureInfo.GetCultureInfo(String name)
at System.Reflection.RuntimeAssembly.GetLocale()
at System.Reflection.RuntimeAssembly.GetName(Boolean copiedName)
at Elastic.Apm.Api.Service.<>c__DisplayClass36_0.<SetAgentActivationMethod>b__1(Assembly n)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at Elastic.Apm.Api.Service.<SetAgentActivationMethod>g__CheckForLoadedAssembly|36_0(String name)
at Elastic.Apm.Api.Service.SetAgentActivationMethod(IApmLogger logger, Service service)
at Elastic.Apm.Api.Service.GetDefaultService(IConfigurationReader configurationReader, IApmLogger loggerArg)
at Elastic.Apm.AgentComponents..ctor(IApmLogger logger, IConfigurationReader configurationReader, IPayloadSender payloadSender, IMetricsCollector metricsCollector, ICurrentExecutionSegmentsContainer currentExecutionSegmentsContainer, ICentralConfigurationFetcher centralConfigurationFetcher, IApmServerInfo apmServerInfo, BreakdownMetricsProvider breakdownMetricsProvider, IHostNameDetector hostNameDetector)
The text was updated successfully, but these errors were encountered:
After further investigation I've identified that this only occurs when the APM agent is initialized within an application that has assemblies with a culture other than neutral loaded into the AppDomain at the point of AddElasticApm() being called during application startup. As the call stack in the issue description shows, this occurs due to Assembly.GetName() ultimately calling CultureInfo.GetCultureInfo which can't be called in global-invariant mode. This only happens when retrieving the name of an assembly with a culture other than neutral.
I've raised #2423 to fix this which changes the call to Assembly.GetName() to directly extract the assembly name from Assembly.FullName (which is in the format Microsoft.AspNetCore.Mvc.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) which avoids the call to CultureInfo.GetCultureInfo.
This issue is basically the same as #1985 which was previously fixed in #1990 but was re-introduced in #1976 before #1990 merged.
APM Agent version
1.28.3
Environment
Operating system and version: Windows 11 / Alpine Linux
.NET Framework/Core name and version (e.g. .NET 4.6.2, NET Core 3.1.100) : .NET 8
Application Target Framework(s) (e.g. net462, netcoreapp3.1): net80
Describe the bug
The APM agent crashes on startup when running in global-invariant mode. This mode is necessary to run applications in docker using the Alpine Linux .NET runtime images such as https://mcr.microsoft.com/dotnet/aspnet:8.0.7-alpine3.20-amd64 as they don't have culture information included.
To Reproduce
Steps to reproduce the behavior:
.csproj
file:Expected behavior
The APM agent does not throw an exception when started as part of an application with global-invariant mode enabled.
Actual behavior
The APM agent throws the following exception when started as part of an application with global-invariant mode enabled
The text was updated successfully, but these errors were encountered: