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

Remove log record timestamp default #5374

Merged
merged 3 commits into from
Apr 14, 2023

Conversation

jack-berg
Copy link
Member

Reflects spec issue #3386.

As mentioned here, this further demonstrates that the Bridge API is not for end users. It's trivial for a appender component to map the timestamp from the log record. It will be inconvenient and awkward for an end user to specify the timestamp on each log if they try to misuse the log bridge API.

Without this default behavior, there's no need for SdkLoggerProvider to have a reference to a Clock, so the code simplifies somewhat.

@jack-berg jack-berg requested a review from a team April 12, 2023 19:23
@@ -100,6 +115,7 @@ private SdkEventEmitter(Logger delegateLogger, String eventDomain) {
public void emit(String eventName, Attributes attributes) {
delegateLogger
.logRecordBuilder()
.setTimestamp(clock.now(), TimeUnit.NANOSECONDS)
Copy link
Member Author

Choose a reason for hiding this comment

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

In contrast to the log API, the event API should automatically assign the timestamp. In part because its inconvenient for the user to specify it, but we also currently don't accept any parameters besides the event name and attribute when emitting an event.

@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (2870209) 91.20% compared to head (d9d8cfc) 91.23%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5374      +/-   ##
============================================
+ Coverage     91.20%   91.23%   +0.02%     
- Complexity     4877     4878       +1     
============================================
  Files           549      549              
  Lines         14402    14404       +2     
  Branches       1352     1351       -1     
============================================
+ Hits          13136    13141       +5     
+ Misses          877      875       -2     
+ Partials        389      388       -1     
Impacted Files Coverage Δ
...io/opentelemetry/sdk/logs/SdkLogRecordBuilder.java 97.43% <ø> (-0.19%) ⬇️
...entelemetry/sdk/logs/SdkLoggerProviderBuilder.java 100.00% <ø> (ø)
...pentelemetry/sdk/logs/SdkEventEmitterProvider.java 81.57% <100.00%> (+2.79%) ⬆️

... and 3 files with indirect coverage changes

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 in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jack-berg
Copy link
Member Author

The spec issue discussing this has been resolved. This PR now reflects the intent of the spec.

@jack-berg
Copy link
Member Author

I've pushed a commit that restores the SdkLoggerProvider clock. Even though after this change its not used anymore, it will need to be used by #5370 to set the observed timestamp to the current time if the user does not set it (see spec PR #3385 for more details).

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.

2 participants