Skip to content

ReadWriteLogRecord.getObservedTimestampEpochNanos() default returns the record timestamp #8501

Description

@thswlsqls

Describe the bug

The ReadWriteLogRecord.getObservedTimestampEpochNanos() default method returns the record timestamp instead of the observed timestamp.

Steps to reproduce

Implement ReadWriteLogRecord by providing only the abstract methods (setAttribute, toLogRecordData) and relying on the interface default methods, with a LogRecordData whose timestamp and observed timestamp differ. Call getObservedTimestampEpochNanos().

What did you expect to see?

getObservedTimestampEpochNanos() returns the observed timestamp, like the SDK override SdkReadWriteLogRecord (line 146-147), which returns the observedTimestampEpochNanos field.

What did you see instead?

It returns the record timestamp. The default at ReadWriteLogRecord.getObservedTimestampEpochNanos() (sdk/logs/src/main/java/io/opentelemetry/sdk/logs/ReadWriteLogRecord.java line 99-101) calls toLogRecordData().getTimestampEpochNanos() instead of getObservedTimestampEpochNanos(). The sibling default getTimestampEpochNanos() (line 90-92) is correct, and LogRecordData exposes both getters separately (line 36, line 39). The copy-paste slip arrived with the default getters in #6924. Because SdkReadWriteLogRecord overrides the getter, the SDK pipeline is unaffected; only third-party implementations relying on the defaults get the wrong value.

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-logs
Version: main @ 824334c
How did you reference these artifacts? N/A

Environment
Compiler: Temurin 21
OS: N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions