-
Notifications
You must be signed in to change notification settings - Fork 293
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
[Exporter.Geneva] Avoid allocation for serializing scopes #818
[Exporter.Geneva] Avoid allocation for serializing scopes #818
Conversation
@@ -33,11 +33,12 @@ internal sealed class MsgPackLogExporter : MsgPackExporter, IDisposable | |||
private readonly IReadOnlyDictionary<string, object> m_customFields; | |||
|
|||
private readonly ExceptionStackExportMode m_exportExceptionStack; | |||
private readonly ExporterStateForScopes exporterStateForScopes; |
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.
nit: m_exporterStateForScopes
to be consistent with the other fields.
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.
Updated. I think we should update the field names to use Pascal case instead though. 😄
@@ -127,6 +128,8 @@ public MsgPackLogExporter(GenevaExporterOptions options) | |||
this.m_customFields = customFields; | |||
} | |||
|
|||
this.exporterStateForScopes = new ExporterStateForScopes() { CustomFields = this.m_customFields }; |
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.
nit: Just reading the diff, it doesn't seem like ExporterStateForScopes
is needed. You could do something more or less like this...
class MsgPackLogExporter
{
private readonly ThreadLocal<SerializationDataForScopes> m_serializationData = new(() => null);
private static readonly Action<LogRecordScope, MsgPackLogExporter> ProcessScopeForIndividualColumns = (scope, state) =>
{
var stateData = state.m_serializationData.Value;
var customFields = state.m_customFields;
// Do work
}
}
Basically use MsgPackLogExporter
as the state type.
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.
Great suggestion! Updated.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #818 +/- ##
==========================================
+ Coverage 77.55% 77.90% +0.35%
==========================================
Files 168 178 +10
Lines 5243 5459 +216
==========================================
+ Hits 4066 4253 +187
- Misses 1177 1206 +29
|
…/utpilla/opentelemetry-dotnet-contrib into utpilla/Update-GenevaLogExporter
Changes
CHANGELOG.md
updated for non-trivial changesBenchmark Results:
main branch:
With this PR: