-
Notifications
You must be signed in to change notification settings - Fork 784
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 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; | ||
|
||
public OtlpLogRecordTransformer(SdkLimitOptions sdkLimitOptions, ExperimentalOptions experimentalOptions) | ||
|
@@ -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)] | ||
|
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vishweshbankwar,
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.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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?
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this code path called for
SimpleExportProcessor
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Agree. I was open to do the small change until #5450 completes. Already have #5731 now, we can close this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - that is also called within the lock right?
There was a problem hiding this comment.
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
beingstatic
. The issue would mainly be with multiple instances of exporter:@vishweshbankwar I just noticed you already covered this concern in one of your comments above.