Skip to content

SdkLogRecordBuilder does not properly set default timestamp #8097

@Quaffel

Description

@Quaffel

Describe the bug
The javadoc for LogRecordBuilder#setTimestap states that if the timestamp "[is] unset, it will be set to the current time when emit() is called." (javadoc).

This does not seem to be consistent with the implementation of SdkLogRecordBuilder#emit (src) as it only provides a default value for the observed timestamp, not for the (event) timestamp.

Steps to reproduce

The following snippet produces a log entry that has an observed timestamp configured. The (event) timestamp is missing.

Logger logger = GlobalOpenTelemetry.get().getLogsBridge().get("some-instrumentation-scope");

Attributes attributes = Attributes.builder()
    .put(AttributeKey.stringKey("tenant-id"), "some-tenant-id")
    .build();

logger.logRecordBuilder()
    .setBody("some-message")
    .setSeverity(Severity.INFO)
    .setAllAttributes(attributes)
    .emit();
}

What did you expect to see?
The produced record should either include the (event) timestamp or the javadoc should not mention that the value is automatically populated.

What did you see instead?
(not applicable)

What version and what artifacts are you using?

  • io.opentelemetry:opentelemetry-bom:1.57.0
  • io.opentelemetry.javaagent:opentelemetry-javaagent:2.25.0

Environment
(not applicable)

Additional context
(not applicable)

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions