Skip to content
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

Add ReadWriteLogRecord#getContext #4888

Closed

Conversation

jack-berg
Copy link
Member

Resolves #4147.

@jack-berg jack-berg requested a review from a team as a code owner October 26, 2022 16:12
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Base: 90.83% // Head: 90.86% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (ccc4b46) compared to base (21d5597).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4888      +/-   ##
============================================
+ Coverage     90.83%   90.86%   +0.02%     
- Complexity     4857     4861       +4     
============================================
  Files           556      556              
  Lines         14475    14477       +2     
  Branches       1410     1411       +1     
============================================
+ Hits          13149    13154       +5     
+ Misses          908      906       -2     
+ Partials        418      417       -1     
Impacted Files Coverage Δ
...io/opentelemetry/sdk/logs/SdkLogRecordBuilder.java 97.36% <100.00%> (ø)
.../opentelemetry/sdk/logs/SdkReadWriteLogRecord.java 93.93% <100.00%> (+13.29%) ⬆️
...metry/sdk/metrics/export/PeriodicMetricReader.java 87.14% <0.00%> (-2.86%) ⬇️
...ava/io/opentelemetry/sdk/internal/RateLimiter.java 100.00% <0.00%> (+5.88%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -25,7 +26,7 @@ class SdkReadWriteLogRecord implements ReadWriteLogRecord {
private final Resource resource;
private final InstrumentationScopeInfo instrumentationScopeInfo;
private final long epochNanos;
private final SpanContext spanContext;
private final Context context;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think(?) the reason that SdkSpan only contains SpanContext instead of the full Context was to limit memory retention, @jkwatson do you recall anything?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so there is a subtle difference between holding it in the SdkReadWriteLogRecord and holding it in the SdkLogRecordBuilder such that it can be passed to each log processor as an argument LogRecordProcessor#onEmit.

If its held in SdkReadWriteLogRecord, there's a reference to Context until BatchLogRecordProcessor flushes and converts each log record to LogRecordData, so the reference sticks around for essentially the shorter of the batch interval or the time it takes to fill the batch queue.

If instead the context is held in SdkLogRecordBuilder and passed as an argument to each LogRecordProcessor#onEmit(), then the reference only has to stick around until the last processor has synchronously returns from onEmit. This allows the context to be garbage collected while the corresponding log record is still sitting in the BatchLogRecordProcessor queue.

I think this is a good enough reason to include as an argument to onEmit() instead of having a getter on SdkReadWriteLogRecord.

@jack-berg
Copy link
Member Author

Closing in favor of #4889.

@jack-berg jack-berg closed this Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass parentContext to LogProcessor.emit(), similar to SpanProcessor.onStart()
2 participants