Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse dictionaries in ActivityExtensions, MetricItemExtensions and OtlpLogExporter #5727

Closed
Closed
Show file tree
Hide file tree
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 @@ -6,6 +6,15 @@
converted using `Convert.ToString` will now format using
`CultureInfo.InvariantCulture`.
([#5700](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5700))
* Reuse `spansByLibrary` dictionary in `ActivityExtensions` to reduce memory
allocation.
([#4943](https://github.com/open-telemetry/opentelemetry-dotnet/issues/4943))
* Reuse `metricsByLibrary` dictionary in `MetricItemExtensions` to reduce memory
allocation.
([#4943](https://github.com/open-telemetry/opentelemetry-dotnet/issues/4943))
* Reuse `logsByCategory` dictionary in `OtlpLogExporter` to reduce memory
allocation.
([#4943](https://github.com/open-telemetry/opentelemetry-dotnet/issues/4943))

## 1.9.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OpenTelemetry.Internal;
using OpenTelemetry.Proto.Collector.Trace.V1;
using OpenTelemetry.Proto.Common.V1;
using OpenTelemetry.Proto.Metrics.V1;

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check failure on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Using directive is unnecessary.

Check warning on line 11 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Using directive is unnecessary.
using OpenTelemetry.Proto.Resource.V1;
using OpenTelemetry.Proto.Trace.V1;
using OpenTelemetry.Trace;
Expand All @@ -18,41 +19,51 @@
internal static class ActivityExtensions
{
private static readonly ConcurrentBag<ScopeSpans> SpanListPool = new();
private static Dictionary<string, ScopeSpans>? spansByLibraryCached;

internal static void AddBatch(
this ExportTraceServiceRequest request,
SdkLimitOptions sdkLimitOptions,
Resource processResource,
in Batch<Activity> activityBatch)
{
Dictionary<string, ScopeSpans> spansByLibrary = new Dictionary<string, ScopeSpans>();
ResourceSpans resourceSpans = new ResourceSpans
{
Resource = processResource,
};
request.ResourceSpans.Add(resourceSpans);
var spansByLibrary = Interlocked.Exchange(ref spansByLibraryCached, null) ?? new Dictionary<string, ScopeSpans>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulomorgado - We could define this field as [ThreadStatic]

[ThreadStatic]
private static Dictionary<string, ScopeSpans>? spansByLibrary;
....
....
...

internal static void AddBatch(..)
{
     spansByLibrary ??= new Dictionary<string, ScopeSpans>();
..
..
..

Copy link
Author

@paulomorgado paulomorgado Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishweshbankwar,

@paulomorgado - We could define this field as [ThreadStatic]

[ThreadStatic]
private static Dictionary<string, ScopeSpans>? spansByLibrary;
....
....
...

internal static void AddBatch(..)
{
     spansByLibrary ??= new Dictionary<string, ScopeSpans>();
..
..
..

How many concurrent threads do you expect to be concurrently requesting these dictionaries?

With [ThreadStatic], the dictionaries will be created per-thread, depending on the thread that started this, which might not always be the same one, and might leak.

[ThreadStatic] is for when you are sure that you'll need it for every thread running the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a dedicated Exporter thread and that should be the only one invoking this code path.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can benchmark it, but accessing thread local storage might be worse than interlocked operations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many concurrent threads do you expect to be concurrently requesting these dictionaries?

it depends - With single instance of exporter configured as BatchExportProcessor. There would be only one thread executing this. With multiple instances, there could be multiple threads executing this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could do that. That would require some refactoring and I would not recommend that effort as the implementation will change anyways with #5450.

is the concern that #5450 will change OTLP Exporter internals, so its better to not make any changes there for now?
If that is the case, then lets close this PR itself as we should not be proceeding with any approaches being discussed, until after the rewriting is complete.

Copy link
Contributor

@utpilla utpilla Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a dedicated Exporter thread and that should be the only one invoking this code path.

Isn't this code path called for SimpleExportProcessor as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the concern that #5450 will change OTLP Exporter internals, so its better to not make any changes there for now

Yes

If that is the case, then lets close this PR itself as we should not be proceeding with any approaches being discussed, until after the rewriting is complete

Agree. I was open to do the small change until #5450 completes. Already have #5731 now, we can close this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@utpilla

Isn't this code path called for SimpleExportProcessor as well?

Yes - that is also called within the lock right?

Copy link
Contributor

@utpilla utpilla Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. I was mainly concerned with HashMap being static. The issue would mainly be with multiple instances of exporter:

  • Multiple SimpleExportProcessor instances
  • Multiple BatchExportProcessor instances
  • Or a combination of both

@vishweshbankwar I just noticed you already covered this concern in one of your comments above.


foreach (var activity in activityBatch)
try
{
Span? span = activity.ToOtlpSpan(sdkLimitOptions);
if (span == null)
ResourceSpans resourceSpans = new ResourceSpans
{
OpenTelemetryProtocolExporterEventSource.Log.CouldNotTranslateActivity(
nameof(ActivityExtensions),
nameof(AddBatch));
continue;
}
Resource = processResource,
};
request.ResourceSpans.Add(resourceSpans);

var activitySourceName = activity.Source.Name;
if (!spansByLibrary.TryGetValue(activitySourceName, out var spans))
foreach (var activity in activityBatch)
{
spans = GetSpanListFromPool(activitySourceName, activity.Source.Version);
Span? span = activity.ToOtlpSpan(sdkLimitOptions);
if (span == null)
{
OpenTelemetryProtocolExporterEventSource.Log.CouldNotTranslateActivity(
nameof(ActivityExtensions),
nameof(AddBatch));
continue;
}

spansByLibrary.Add(activitySourceName, spans);
resourceSpans.ScopeSpans.Add(spans);
}
var activitySourceName = activity.Source.Name;
if (!spansByLibrary.TryGetValue(activitySourceName, out var spans))
{
spans = GetSpanListFromPool(activitySourceName, activity.Source.Version);

spansByLibrary.Add(activitySourceName, spans);
resourceSpans.ScopeSpans.Add(spans);
}

spans.Spans.Add(span);
spans.Spans.Add(span);
}
}
finally
{
spansByLibrary.Clear();
Interlocked.Exchange(ref spansByLibraryCached, spansByLibrary);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,52 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation;
internal static class MetricItemExtensions
{
private static readonly ConcurrentBag<ScopeMetrics> MetricListPool = new();
private static Dictionary<string, ScopeMetrics>? metricsByLibraryCached;

internal static void AddMetrics(
this OtlpCollector.ExportMetricsServiceRequest request,
OtlpResource.Resource processResource,
in Batch<Metric> metrics)
{
var metricsByLibrary = new Dictionary<string, ScopeMetrics>();
var resourceMetrics = new ResourceMetrics
{
Resource = processResource,
};
request.ResourceMetrics.Add(resourceMetrics);
var metricsByLibrary = Interlocked.Exchange(ref metricsByLibraryCached, null) ?? new Dictionary<string, ScopeMetrics>();

foreach (var metric in metrics)
try
{
var otlpMetric = metric.ToOtlpMetric();

// TODO: Replace null check with exception handling.
if (otlpMetric == null)
var resourceMetrics = new ResourceMetrics
{
OpenTelemetryProtocolExporterEventSource.Log.CouldNotTranslateMetric(
nameof(MetricItemExtensions),
nameof(AddMetrics));
continue;
}
Resource = processResource,
};
request.ResourceMetrics.Add(resourceMetrics);

var meterName = metric.MeterName;
if (!metricsByLibrary.TryGetValue(meterName, out var scopeMetrics))
foreach (var metric in metrics)
{
scopeMetrics = GetMetricListFromPool(meterName, metric.MeterVersion, metric.MeterTags);
var otlpMetric = metric.ToOtlpMetric();

metricsByLibrary.Add(meterName, scopeMetrics);
resourceMetrics.ScopeMetrics.Add(scopeMetrics);
}
// TODO: Replace null check with exception handling.
if (otlpMetric == null)
{
OpenTelemetryProtocolExporterEventSource.Log.CouldNotTranslateMetric(
nameof(MetricItemExtensions),
nameof(AddMetrics));
continue;
}

scopeMetrics.Metrics.Add(otlpMetric);
var meterName = metric.MeterName;
if (!metricsByLibrary.TryGetValue(meterName, out var scopeMetrics))
{
scopeMetrics = GetMetricListFromPool(meterName, metric.MeterVersion, metric.MeterTags);

metricsByLibrary.Add(meterName, scopeMetrics);
resourceMetrics.ScopeMetrics.Add(scopeMetrics);
}

scopeMetrics.Metrics.Add(otlpMetric);
}
}
finally
{
metricsByLibrary.Clear();
Interlocked.Exchange(ref metricsByLibraryCached, metricsByLibrary);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
internal sealed class OtlpLogRecordTransformer
{
internal static readonly ConcurrentBag<OtlpLogs.ScopeLogs> LogListPool = new();
private Dictionary<string, OtlpLogs.ScopeLogs>? logsByCategory;

private readonly SdkLimitOptions sdkLimitOptions;

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-stable

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / validate-packages / run-package-validation-experimental

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net7.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-latest, net8.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-latest, net6.0)

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-stable

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Readonly fields should appear before non-readonly fields

Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental

Readonly fields should appear before non-readonly fields
private readonly ExperimentalOptions experimentalOptions;

public OtlpLogRecordTransformer(SdkLimitOptions sdkLimitOptions, ExperimentalOptions experimentalOptions)
Expand All @@ -31,35 +32,42 @@
OtlpResource.Resource processResource,
in Batch<LogRecord> logRecordBatch)
{
// TODO: https://github.com/open-telemetry/opentelemetry-dotnet/issues/4943
Dictionary<string, OtlpLogs.ScopeLogs> logsByCategory = new Dictionary<string, OtlpLogs.ScopeLogs>();
var logsByCategory = Interlocked.Exchange(ref this.logsByCategory, null) ?? new Dictionary<string, OtlpLogs.ScopeLogs>();

var request = new OtlpCollector.ExportLogsServiceRequest();

var resourceLogs = new OtlpLogs.ResourceLogs
try
{
Resource = processResource,
};
request.ResourceLogs.Add(resourceLogs);
var request = new OtlpCollector.ExportLogsServiceRequest();

foreach (var logRecord in logRecordBatch)
{
var otlpLogRecord = this.ToOtlpLog(logRecord);
if (otlpLogRecord != null)
var resourceLogs = new OtlpLogs.ResourceLogs
{
var scopeName = logRecord.Logger.Name;
if (!logsByCategory.TryGetValue(scopeName, out var scopeLogs))
Resource = processResource,
};
request.ResourceLogs.Add(resourceLogs);

foreach (var logRecord in logRecordBatch)
{
var otlpLogRecord = this.ToOtlpLog(logRecord);
if (otlpLogRecord != null)
{
scopeLogs = this.GetLogListFromPool(scopeName);
logsByCategory.Add(scopeName, scopeLogs);
resourceLogs.ScopeLogs.Add(scopeLogs);
}
var scopeName = logRecord.Logger.Name;
if (!logsByCategory.TryGetValue(scopeName, out var scopeLogs))
{
scopeLogs = this.GetLogListFromPool(scopeName);
logsByCategory.Add(scopeName, scopeLogs);
resourceLogs.ScopeLogs.Add(scopeLogs);
}

scopeLogs.LogRecords.Add(otlpLogRecord);
scopeLogs.LogRecords.Add(otlpLogRecord);
}
}
}

return request;
return request;
}
finally
{
logsByCategory.Clear();
Interlocked.Exchange(ref this.logsByCategory, logsByCategory);
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
Loading