open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.23k stars 765 forks source link

[metrics] Optimize lookup costs using .NET 9 alternative lookup #5777

Open cijothomas opened 3 months ago

cijothomas commented 3 months ago

Metrics hot path now involves copying the incoming ReadOnlySpan into a Thread-Local array to do the dictionary lookup. With the new capability to lookup Dictionary with just ReadOnlySpan, we can avoid the thread-local copy cost. Opening an issue to track this.

Unrelated/Related : Rust's Dictionary(hashmap) already allowed such lookups, and I leveraged that in OTel Rust metrics and avoided entire copy costs and got good per gains (https://github.com/open-telemetry/opentelemetry-rust/pull/1989).