Skip to content

Commit f23557a

Browse files
authored
Merge c428e26 into f60b60f
2 parents f60b60f + c428e26 commit f23557a

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

ydb/core/viewer/json_pipe_req.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,20 @@ class TViewerPipeClient : public TActorBootstrapped<TDerived> {
135135
traceId = NWilson::TTraceId::FromTraceparentHeader(traceparent, TComponentTracingLevels::ProductionVerbose);
136136
}
137137
TStringBuf wantTrace = Event->Get()->Request.GetHeader("X-Want-Trace");
138-
if (!traceId && FromStringWithDefault<bool>(wantTrace)) {
139-
traceId = NWilson::TTraceId::NewTraceId(TComponentTracingLevels::ProductionVerbose, Max<ui32>());
138+
TStringBuf traceVerbosity = Event->Get()->Request.GetHeader("X-Trace-Verbosity");
139+
TStringBuf traceTTL = Event->Get()->Request.GetHeader("X-Trace-TTL");
140+
if (!traceId && (FromStringWithDefault<bool>(wantTrace) || !traceVerbosity.empty() || !traceTTL.empty())) {
141+
ui8 verbosity = TComponentTracingLevels::ProductionVerbose;
142+
if (traceVerbosity) {
143+
verbosity = FromStringWithDefault<ui8>(traceVerbosity, verbosity);
144+
verbosity = std::min(verbosity, NWilson::TTraceId::MAX_VERBOSITY);
145+
}
146+
ui32 ttl = Max<ui32>();
147+
if (traceTTL) {
148+
ttl = FromStringWithDefault<ui32>(traceTTL, ttl);
149+
ttl = std::min(ttl, NWilson::TTraceId::MAX_TIME_TO_LIVE);
150+
}
151+
traceId = NWilson::TTraceId::NewTraceId(verbosity, ttl);
140152
}
141153
if (traceId) {
142154
Span = {TComponentTracingLevels::THttp::TopLevel, std::move(traceId), "http", NWilson::EFlags::AUTO_END};

ydb/library/actors/wilson/wilson_trace.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ namespace NWilson {
2626
ui32 Raw;
2727
};
2828

29+
public:
30+
static constexpr ui8 MAX_VERBOSITY = 15;
31+
static constexpr ui32 MAX_TIME_TO_LIVE = 4095;
32+
2933
private:
3034
TTraceId(TTrace traceId, ui64 spanId, ui8 verbosity, ui32 timeToLive)
3135
: TraceId(traceId)
3236
{
3337
if (timeToLive == Max<ui32>()) {
34-
timeToLive = 4095;
38+
timeToLive = MAX_TIME_TO_LIVE;
3539
}
36-
Y_ABORT_UNLESS(verbosity <= 15);
37-
Y_ABORT_UNLESS(timeToLive <= 4095);
40+
Y_ABORT_UNLESS(verbosity <= MAX_VERBOSITY);
41+
Y_ABORT_UNLESS(timeToLive <= MAX_TIME_TO_LIVE);
3842
SpanId = spanId;
3943
Verbosity = verbosity;
4044
TimeToLive = timeToLive;

0 commit comments

Comments
 (0)