<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ydb/library/cpp/yt/logging/structured_payload.cpp, branch main</title>
<subtitle>Mirror of YDB github repos</subtitle>
<id>https://code.mastervirt.ru/ydb/atom?h=main</id>
<link rel='self' href='https://code.mastervirt.ru/ydb/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/'/>
<updated>2026-07-17T09:07:46Z</updated>
<entry>
<title>YT-28451: Add tagged logging API and opaque event payload</title>
<updated>2026-07-17T09:07:46Z</updated>
<author>
<name>babenko</name>
<email>babenko@yandex-team.com</email>
</author>
<published>2026-07-16T07:32:17Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=cc4f0cb52cee106a1e84c653823087861b8c8df5'/>
<id>urn:sha1:cc4f0cb52cee106a1e84c653823087861b8c8df5</id>
<content type='text'>
Replace `TLogEvent::MessageRef` with an opaque `Payload` that carries the message
together with structured key/value tags, deferring tag rendering to the consumer
(logging thread).

- Add the `TTaggedPayloadWriter`/`TTaggedPayloadReader` codec (`NDetail`), with a
  per-thread chunk-cached builder so tagged logging does no per-message heap
  allocation.
- Model the payload as a typed `TLogEventPayload` — a `std::variant` of the opaque
  strong typedefs `TTaggedLogEventPayload` and `TStructuredLogEventPayload` (each
  over `TSharedRef`). The active alternative identifies the event kind, so the
  separate `ELogMessageKind` enum and `TLogEvent::MessageKind` field are removed;
  consumers dispatch via `std::holds_alternative`/`std::get` instead of a tag.
- Add the fluent `YT_TLOG_*` API: `YT_TLOG_INFO("Message").With(key, value)` and
  `.With(key, value, "%spec")`; disabled levels skip argument evaluation.
- Add well-known tags: `.With(value)` attaches a value under a statically known
  key resolved by ADL (e.g. `.With(error)` for the `Error` tag).
- Teach the plain-text and structured formatters to render tags; add the
  `enable_native_tags` knob to emit tags into a nested structured attribute.
- Add producer-side benchmarks. The tagged API is cheaper than `YT_LOG_*` for
  tagged calls and on par for tag-free ones:

#|
|| **Producer call** | **`YT_LOG_*`** | **`YT_TLOG_*`** | **Δ** ||
|| no tags   | 81 ns  | 82 ns  | +2%  ||
|| 1 tag     | 124 ns | 88 ns  | -29% ||
|| 2 tags    | 140 ns | 101 ns | -28% ||
|| 3 tags    | 372 ns | 283 ns | -24% ||
|#

--

#| || **&lt;a href="https://nda.ya.ru/t/p0sVNSOC7ijzFF" target="_blank"&gt;![](https://nda.ya.ru/t/mAiQIjHx7Mm3JC =30x) Echo tests&lt;/a&gt;** || |#
commit_hash:70efc90e5c2b71e5311415a4e4508db42ff28971
</content>
</entry>
</feed>
