Skip to content

Fall back to observed timestamp in SystemOutLogRecordExporter - #8944

Merged
jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/systemout-log-exporter-observed-timestamp-fallback
Oct 15, 2026
Merged

jack-berg merged 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/systemout-log-exporter-observed-timestamp-fallback

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8942

Description

  • SystemOutLogRecordExporter.formatLog() printed 1970-01-01T00:00:00Z for any log record emitted without setTimestamp(...), because it only read getTimestampEpochNanos(), which is 0 in that case.
  • It now uses the observed timestamp when Timestamp is 0, following the logs data model guidance for single-timestamp formats: "Use Timestamp if it is present, otherwise use ObservedTimestamp." EventToSpanEventBridge (sdk-extensions/incubator) uses the same fallback.
  • No field is added and the format is unchanged. Records that set a timestamp (including log4j/logback/JUL appender bridges) print as before.
  • Spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-observedtimestamp

Testing done

  • Added SystemOutLogRecordExporterTest#formatWithoutTimestampUsesObservedTimestamp (timestamp unset, observed timestamp set). With the fix reverted it fails: expected 1970-08-07T10:00:00Z ... but was 1970-01-01T00:00:00Z ....
  • Existing format() and formatWithEventName() set a timestamp and leave the observed timestamp at 0; they still pass, so Timestamp keeps priority.
  • ./gradlew :exporters:logging:check passed (17 tests). No apidiff change: formatLog is package-private.

@thswlsqls
thswlsqls marked this pull request as ready for review October 13, 2026 05:32
@thswlsqls
thswlsqls requested a review from a team as a code owner October 13, 2026 05:32
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-15 21:52 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.66%. Comparing base (387f5c5) to head (b4664c9).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8944      +/-   ##
============================================
+ Coverage     90.65%   90.66%   +0.01%     
- Complexity    10887    10890       +3     
============================================
  Files          1015     1015              
  Lines         29731    29734       +3     
  Branches       3876     3877       +1     
============================================
+ Hits          26953    26959       +6     
  Misses         1860     1860              
+ Partials        918      915       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@jack-berg
jack-berg merged commit 1522a4d into open-telemetry:main Oct 15, 2026
35 checks passed
@otelbot

otelbot Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

SystemOutLogRecordExporter prints epoch time when log timestamp is unset

2 participants