Skip to content

feat(append-opentelemetry): leave body unset when default message payload is empty - #318

Open
tisonkun wants to merge 1 commit into
mainfrom
feat/otel-empty-body-none
Open

tisonkun wants to merge 1 commit into
mainfrom
feat/otel-empty-body-none

Conversation

@tisonkun

@tisonkun tisonkun commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

When logging structured events with an empty message payload (such as info!(logger, ["port" = 8080])) and no custom MakeBody, OpentelemetryLog previously called log_record.set_body(AnyValue::from("")), emitting an explicit empty string body instead of leaving SdkLogRecord::body unset (None).

This PR skips SdkLogRecord::set_body when make_body is None and Record::payload() formats to "" (covering both static payload_static() and dynamic Arguments), matching OpenTelemetry's optional LogRecord.body semantics while preserving custom MakeBody behavior.

Test Plan

  • Assert record.body() == None for both static and dynamic empty payloads in tests-integration/tests/append_test/opentelemetry.rs.
  • Run append_test, doctests, and rustdoc checks for logforth-append-opentelemetry.

…load is empty

Skip calling `SdkLogRecord::set_body` when no custom `MakeBody` is configured and `Record::payload()` formats to an empty string, leaving `SdkLogRecord::body` as `None` instead of emitting `AnyValue::String("")` on structured events without a message text.

Signed-off-by: tison <wander4096@gmail.com>
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.

1 participant