diff options
| author | maybenotilya <[email protected]> | 2026-04-24 10:23:50 +0300 |
|---|---|---|
| committer | maybenotilya <[email protected]> | 2026-04-24 10:58:39 +0300 |
| commit | 9def6761044f6a64646150e26fcbc1ae0d24d8f8 (patch) | |
| tree | a733a8355ab0d1c7d1b02f00b8da9df693b05445 /yt/cpp/mapreduce/http/helpers.cpp | |
| parent | 55a42d4bc7fb22bae0e97d76e7043d43588044b6 (diff) | |
YT-27835: Client tracing
* Changelog entry
Type: fix
Component: cpp-sdk
Create trace\_id on client side
commit_hash:270019c138bed296ed934649a0b157f514fca0cb
Diffstat (limited to 'yt/cpp/mapreduce/http/helpers.cpp')
| -rw-r--r-- | yt/cpp/mapreduce/http/helpers.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/http/helpers.cpp b/yt/cpp/mapreduce/http/helpers.cpp index 0e34610ef1a..07cb3c6d1a9 100644 --- a/yt/cpp/mapreduce/http/helpers.cpp +++ b/yt/cpp/mapreduce/http/helpers.cpp @@ -5,8 +5,13 @@ #include <yt/cpp/mapreduce/interface/logging/yt_log.h> +#include <yt/yt/core/tracing/trace_context.h> + #include <library/cpp/yson/node/node_io.h> +#include <util/stream/format.h> +#include <util/string/builder.h> + namespace NYT { //////////////////////////////////////////////////////////////////////////////// @@ -100,6 +105,23 @@ void LogRequest(const THttpHeader& header, const TString& url, bool includeParam GetLoggedAttributes(header, url, includeParameters, Max<size_t>())); } +TString FormatTraceParentHeader(const NTracing::TTraceId& traceId, const NTracing::TSpanId& spanId) +{ + // Formatting according to W3C traceparent header format + // See https://www.w3.org/TR/trace-context/#traceparent-header for more detailed info + TString traceparent = ::TStringBuilder() + << "00-" + << Hex(traceId.Parts32[3], HF_FULL) + << Hex(traceId.Parts32[2], HF_FULL) + << Hex(traceId.Parts32[1], HF_FULL) + << Hex(traceId.Parts32[0], HF_FULL) + << "-" + << Hex(spanId, HF_FULL) + << "-01"; + traceparent.to_lower(); + return traceparent; +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT |
