Skip to content

Commit

Permalink
Enable OTLP exporter for multiple registrations
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkumar-rangaraj committed Dec 11, 2024
1 parent 1f39623 commit 4328df7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@ internal static class ProtobufOtlpLogSerializer
private const int TraceIdSize = 16;
private const int SpanIdSize = 8;

private static readonly Stack<List<LogRecord>> LogsListPool = [];
private static readonly Dictionary<string, List<LogRecord>> ScopeLogsList = [];
[ThreadStatic]
private static Stack<List<LogRecord>>? logsListPool;
[ThreadStatic]
private static Dictionary<string, List<LogRecord>>? scopeLogsList;

[ThreadStatic]
private static SerializationState? threadSerializationState;

internal static int WriteLogsData(ref byte[] buffer, int writePosition, SdkLimitOptions sdkLimitOptions, ExperimentalOptions experimentalOptions, Resources.Resource? resource, in Batch<LogRecord> logRecordBatch)
{
logsListPool ??= [];
scopeLogsList ??= [];

foreach (var logRecord in logRecordBatch)
{
var scopeName = logRecord.Logger.Name;
if (!ScopeLogsList.TryGetValue(scopeName, out var logRecords))
if (!scopeLogsList.TryGetValue(scopeName, out var logRecords))
{
logRecords = LogsListPool.Count > 0 ? LogsListPool.Pop() : [];
ScopeLogsList[scopeName] = logRecords;
logRecords = logsListPool.Count > 0 ? logsListPool.Pop() : [];
scopeLogsList[scopeName] = logRecords;
}

if (logRecord.Source == LogRecord.LogRecordSource.FromSharedPool)
Expand All @@ -43,7 +48,7 @@ internal static int WriteLogsData(ref byte[] buffer, int writePosition, SdkLimit
logRecords.Add(logRecord);
}

writePosition = TryWriteResourceLogs(ref buffer, writePosition, sdkLimitOptions, experimentalOptions, resource, ScopeLogsList);
writePosition = TryWriteResourceLogs(ref buffer, writePosition, sdkLimitOptions, experimentalOptions, resource, scopeLogsList);
ReturnLogRecordListToPool();

return writePosition;
Expand Down Expand Up @@ -79,9 +84,9 @@ internal static int TryWriteResourceLogs(ref byte[] buffer, int writePosition, S

internal static void ReturnLogRecordListToPool()
{
if (ScopeLogsList.Count != 0)
if (scopeLogsList.Count != 0)

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.
{
foreach (var entry in ScopeLogsList)
foreach (var entry in scopeLogsList)
{
foreach (var logRecord in entry.Value)
{
Expand All @@ -96,10 +101,10 @@ internal static void ReturnLogRecordListToPool()
}

entry.Value.Clear();
LogsListPool.Push(entry.Value);
logsListPool.Push(entry.Value);

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 104 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpLogSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.
}

ScopeLogsList.Clear();
scopeLogsList.Clear();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,31 @@ internal static class ProtobufOtlpMetricSerializer
private const int TraceIdSize = 16;
private const int SpanIdSize = 8;

private static readonly Stack<List<Metric>> MetricListPool = [];
private static readonly Dictionary<string, List<Metric>> ScopeMetricsList = [];
[ThreadStatic]
private static Stack<List<Metric>>? metricListPool;
[ThreadStatic]
private static Dictionary<string, List<Metric>>? scopeMetricsList;

private delegate int WriteExemplarFunc(byte[] buffer, int writePosition, in Exemplar exemplar);

internal static int WriteMetricsData(ref byte[] buffer, int writePosition, Resources.Resource? resource, in Batch<Metric> batch)
{
metricListPool ??= [];
scopeMetricsList ??= [];

foreach (var metric in batch)
{
var metricName = metric.MeterName;
if (!ScopeMetricsList.TryGetValue(metricName, out var metrics))
if (!scopeMetricsList.TryGetValue(metricName, out var metrics))
{
metrics = MetricListPool.Count > 0 ? MetricListPool.Pop() : new List<Metric>();
ScopeMetricsList[metricName] = metrics;
metrics = metricListPool.Count > 0 ? metricListPool.Pop() : new List<Metric>();
scopeMetricsList[metricName] = metrics;
}

metrics.Add(metric);
}

writePosition = TryWriteResourceMetrics(ref buffer, writePosition, resource, ScopeMetricsList);
writePosition = TryWriteResourceMetrics(ref buffer, writePosition, resource, scopeMetricsList);
ReturnMetricListToPool();

return writePosition;
Expand Down Expand Up @@ -67,15 +72,15 @@ internal static int TryWriteResourceMetrics(ref byte[] buffer, int writePosition

private static void ReturnMetricListToPool()
{
if (ScopeMetricsList.Count != 0)
if (scopeMetricsList.Count != 0)

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 75 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.
{
foreach (var entry in ScopeMetricsList)
foreach (var entry in scopeMetricsList)
{
entry.Value.Clear();
MetricListPool.Push(entry.Value);
metricListPool.Push(entry.Value);

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 80 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpMetricSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.
}

ScopeMetricsList.Clear();
scopeMetricsList.Clear();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ internal static class ProtobufOtlpTraceSerializer
private const int TraceIdSize = 16;
private const int SpanIdSize = 8;

private static readonly Stack<List<Activity>> ActivityListPool = [];
private static readonly Dictionary<string, List<Activity>> ScopeTracesList = [];
[ThreadStatic]
private static Stack<List<Activity>>? activityListPool;
[ThreadStatic]
private static Dictionary<string, List<Activity>>? scopeTracesList;

internal static int WriteTraceData(ref byte[] buffer, int writePosition, SdkLimitOptions sdkLimitOptions, Resources.Resource? resource, in Batch<Activity> batch)
{
activityListPool ??= [];
scopeTracesList ??= [];

foreach (var activity in batch)
{
var sourceName = activity.Source.Name;
if (!ScopeTracesList.TryGetValue(sourceName, out var activities))
if (!scopeTracesList.TryGetValue(sourceName, out var activities))
{
activities = ActivityListPool.Count > 0 ? ActivityListPool.Pop() : [];
ScopeTracesList[sourceName] = activities;
activities = activityListPool.Count > 0 ? activityListPool.Pop() : [];
scopeTracesList[sourceName] = activities;
}

activities.Add(activity);
Expand Down Expand Up @@ -74,15 +79,15 @@ internal static int TryWriteResourceSpans(ref byte[] buffer, int writePosition,

internal static void ReturnActivityListToPool()
{
if (ScopeTracesList.Count != 0)
if (scopeTracesList.Count != 0)

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 82 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.
{
foreach (var entry in ScopeTracesList)
foreach (var entry in scopeTracesList)
{
entry.Value.Clear();
ActivityListPool.Push(entry.Value);
activityListPool.Push(entry.Value);

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (otel-linux-arm64, net9.0)

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.

Check failure on line 87 in src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTraceSerializer.cs

View workflow job for this annotation

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

Dereference of a possibly null reference.
}

ScopeTracesList.Clear();
scopeTracesList.Clear();
}
}

Expand All @@ -96,9 +101,9 @@ internal static int WriteResourceSpans(byte[] buffer, int writePosition, SdkLimi

internal static int WriteScopeSpans(byte[] buffer, int writePosition, SdkLimitOptions sdkLimitOptions)
{
if (ScopeTracesList != null)
if (scopeTracesList != null)
{
foreach (KeyValuePair<string, List<Activity>> entry in ScopeTracesList)
foreach (KeyValuePair<string, List<Activity>> entry in scopeTracesList)
{
writePosition = ProtobufSerializer.WriteTag(buffer, writePosition, ProtobufOtlpTraceFieldNumberConstants.ResourceSpans_Scope_Spans, ProtobufWireType.LEN);
int resourceSpansScopeSpansLengthPosition = writePosition;
Expand Down

0 comments on commit 4328df7

Please sign in to comment.