-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation; | |
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 GitHub Actions / validate-packages / run-package-validation-stable
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-stable
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-stable
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-stable
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-stable
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 GitHub Actions / validate-packages / run-package-validation-experimental
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-experimental
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-experimental
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-experimental
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / validate-packages / run-package-validation-experimental
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-stable / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / build-test-project-experimental / build-test (windows-latest, net462)
Check failure on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs 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 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 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 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 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 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 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 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 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 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 GitHub Actions / lint-dotnet-format / run-dotnet-format-stable
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-stable
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-stable
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-stable
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-stable
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental
Check warning on line 22 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/OtlpLogRecordTransformer.cs GitHub Actions / lint-dotnet-format / run-dotnet-format-experimental
|
||
private readonly ExperimentalOptions experimentalOptions; | ||
|
@@ -31,35 +32,42 @@ internal OtlpCollector.ExportLogsServiceRequest BuildExportRequest( | |
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)] | ||
|