-
Notifications
You must be signed in to change notification settings - Fork 849
Description
Package
OpenTelemetry
Package Version
| Package Name | Version |
|---|---|
| OpenTelemetry.Extensions.OpenTelemetryProtocol | 1.9.0 |
| OpenTelemetry.Extensions.Hosting | 1.9.0 |
| OpenTelemetry.Extensions.AspNetCore | 1.9.0 |
| OpenTelemetry.Extensions.Http | 1.9.0 |
| OpenTelemetry.Extensions.Runtime | 1.9.0 |
Runtime Version
net9.0
Description
Adding OpenTelemetry to our native AOT'd ASP.NET Core "TodosApi" app in aspnet/Benchmarks#2014 shows the app size increase from 18.1 MB to 22.2 MB. About half of that size is from the OTLP Exporter. If I remove the OTLP Exporter, it drops back down to 20.0 MB.
For loo
Steps to Reproduce
dotnet publish the app before and after aspnet/Benchmarks#2014. Measure the app size in bin\Release\net9.0\win-x64\publish.
Expected Result
The app size change should be as minimal as possible.
Actual Result
The app gets about 22% larger when enabling OTel.
Additional Context
Using https://github.com/MichalStrehovsky/sizoscope, you can get some insight into what is taking all the size.
The first thing that jumps out to me is the usage of Regex:
This is coming from
opentelemetry-dotnet/src/OpenTelemetry/Trace/TracerProviderSdk.cs
Lines 254 to 259 in 6ec1510
| if (state.Sources.Any()) | |
| { | |
| // Validation of source name is already done in builder. | |
| if (state.Sources.Any(s => WildcardHelper.ContainsWildcard(s))) | |
| { | |
| var regex = WildcardHelper.GetWildcardRegex(state.Sources); |
The unfortunate thing about this is not only app size, but also on native AOT'd apps, Regex's that don't use the source generator are always interpreted. So if that Regex is called often, it will slow down the app compared to a "normal" .NET app.
For the OTLP Exporter, it looks like most of the app size is coming from Grpc:
and from generic collections of structs:


