-
Notifications
You must be signed in to change notification settings - Fork 450
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
[Logs SDK] Modify LogRecord to use Vector instead of OrderMap for attributes #1142
Conversation
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.
Why was an OrderMap
chosen in the first place? Do we do any lookups/deduplication on this data?
I think it was a result of #794 |
There are no lookups in the log SDK. The lookups could be part of any external exporters, but there shouldn't be significant difference in complexity - o(n) vs o(1) - for smaller number of attributes. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1142 +/- ##
=======================================
- Coverage 49.8% 49.3% -0.6%
=======================================
Files 171 175 +4
Lines 20171 20464 +293
=======================================
+ Hits 10061 10101 +40
- Misses 10110 10363 +253
☔ View full report in Codecov by Sentry. |
Changes
This is to further validate the benchmark introduced in #1121, changing the
LogRecord
to store attributes inVec
instead ofOrderMap
/IndexMap
. The benchmark was done to emit the tokio-tracing log to user-event exporter.As an example, to emit the error log with below attributes:
With
OrderMap
:It takes around ~1000 ns to emit a single event.
With
Vector
:It takes around ~700 ns to emit a single event.
The user_events tracepoint was disabled, so no actual export was happening. Which means most of the above overhead was coming from logs SDK (and not the exporter).
The user_events export iterate over the attributes to serialize, and doesn't require to do any lookup on particular key.
These changes come at below cost:
The PR is raised to further discuss if these changes would be good for log signal, or any better suggestion. Another option I thought was to have SDK support both data structures, and let user select which one to use. Something like this (not tested):
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes