Skip to content

Fall back to observed timestamp in SystemOutLogRecordExporter - #8944

Open
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/systemout-log-exporter-observed-timestamp-fallback
Open

thswlsqls wants to merge 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

Waiting on reviewers · refreshed 2026-10-13 05:58 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • 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.

This branch has not been deployed

No deployments
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

1 participant