Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ydb/core/viewer/json_pipe_req.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,20 @@ class TViewerPipeClient : public TActorBootstrapped<TDerived> {
traceId = NWilson::TTraceId::FromTraceparentHeader(traceparent, TComponentTracingLevels::ProductionVerbose);
}
TStringBuf wantTrace = Event->Get()->Request.GetHeader("X-Want-Trace");
if (!traceId && FromStringWithDefault<bool>(wantTrace)) {
traceId = NWilson::TTraceId::NewTraceId(TComponentTracingLevels::ProductionVerbose, Max<ui32>());
TStringBuf traceVerbosity = Event->Get()->Request.GetHeader("X-Trace-Verbosity");
TStringBuf traceTTL = Event->Get()->Request.GetHeader("X-Trace-TTL");
if (!traceId && (FromStringWithDefault<bool>(wantTrace) || !traceVerbosity.empty() || !traceTTL.empty())) {
ui8 verbosity = TComponentTracingLevels::ProductionVerbose;
if (traceVerbosity) {
verbosity = FromStringWithDefault<ui8>(traceVerbosity, verbosity);
verbosity = std::min(verbosity, NWilson::TTraceId::MAX_VERBOSITY);
}
ui32 ttl = Max<ui32>();
if (traceTTL) {
ttl = FromStringWithDefault<ui32>(traceTTL, ttl);
ttl = std::min(ttl, NWilson::TTraceId::MAX_TIME_TO_LIVE);
}
traceId = NWilson::TTraceId::NewTraceId(verbosity, ttl);
}
if (traceId) {
Span = {TComponentTracingLevels::THttp::TopLevel, std::move(traceId), "http", NWilson::EFlags::AUTO_END};
Expand Down
10 changes: 7 additions & 3 deletions ydb/library/actors/wilson/wilson_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ namespace NWilson {
ui32 Raw;
};

public:
static constexpr ui8 MAX_VERBOSITY = 15;
static constexpr ui32 MAX_TIME_TO_LIVE = 4095;

private:
TTraceId(TTrace traceId, ui64 spanId, ui8 verbosity, ui32 timeToLive)
: TraceId(traceId)
{
if (timeToLive == Max<ui32>()) {
timeToLive = 4095;
timeToLive = MAX_TIME_TO_LIVE;
}
Y_ABORT_UNLESS(verbosity <= 15);
Y_ABORT_UNLESS(timeToLive <= 4095);
Y_ABORT_UNLESS(verbosity <= MAX_VERBOSITY);
Y_ABORT_UNLESS(timeToLive <= MAX_TIME_TO_LIVE);
SpanId = spanId;
Verbosity = verbosity;
TimeToLive = timeToLive;
Expand Down