Skip to content

docs(append-opentelemetry): clarify MakeBodyLayout bytes output and custom MakeBody usage - #317

Merged
tisonkun merged 2 commits into
mainfrom
docs/otel-make-body-bytes
Dec 1, 2026
Merged

tisonkun merged 2 commits into
mainfrom
docs/otel-make-body-bytes

Conversation

@tisonkun

@tisonkun tisonkun commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MakeBody is an open user-defined extension trait for constructing any AnyValue body (String, Map, ListAny, Bytes, or scalars) from a Record and active Diagnostics. Meanwhile, because logforth_core::Layout::format writes raw bytes into a Vec<u8>, the built-in MakeBodyLayout adapter wraps that byte slice directly as AnyValue::Bytes (OTLP bytes_value) without imposing UTF-8 validation or extra string allocation, which backends such as Grafana Loki display as Base64.

This PR clarifies those contracts across OpentelemetryLogBuilder::make_body, MakeBody, MakeBodyLayout, and the crate README:

  • Describe MakeBody accurately as a general AnyValue body constructor in rustdoc and the README builder table/notes.
  • Document that OpentelemetryLog formats Record::payload() as AnyValue::String by default, while MakeBodyLayout emits AnyValue::Bytes.
  • Provide a runnable MakeBody doctest showing how to wrap a Layout when emitting UTF-8 output as AnyValue::String.

Test Plan

  • Run cargo test -p logforth-append-opentelemetry --doc and cargo +nightly doc -p logforth-append-opentelemetry --no-deps --all-features with -D warnings.

…ustom MakeBody usage

Document that `MakeBodyLayout` wraps `Layout::format`'s `Vec<u8>` output directly as `AnyValue::Bytes` (OTLP `bytes_value`, which backends such as Grafana Loki display as Base64), whereas `OpentelemetryLog` emits `AnyValue::String` by default and callers wanting custom formatted string or structured `AnyValue` bodies should implement `MakeBody` directly.

Signed-off-by: tison <wander4096@gmail.com>
…ension trait

Clarify in the README builder table, operational notes, and rustdoc that `MakeBody` is an open user-defined strategy capable of constructing any `AnyValue` body (`String`, `Map`, `ListAny`, `Bytes`, or scalars), while distinguishing the built-in `MakeBodyLayout` adapter (`Layout` `Vec<u8>` -> `AnyValue::Bytes`).

Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
tisonkun merged commit d163499 into main Dec 1, 2026
16 of 19 checks passed
@tisonkun
tisonkun deleted the docs/otel-make-body-bytes branch December 1, 2026 16:49
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