Skip to content

Commit

Permalink
Get right TraceId in SessionActor
Browse files Browse the repository at this point in the history
  • Loading branch information
va-kuznecov committed Jan 10, 2024
1 parent ea061ca commit c80bfea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ydb/core/kqp/common/events/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ struct TEvQueryRequest: public NActors::TEventLocal<TEvQueryRequest, TKqpEvents:
return Record.GetTraceId();
}

NWilson::TTraceId GetWilsonTraceId() const {
if (RequestCtx) {
return RequestCtx->GetWilsonTraceId();
}
return {};
}

const TString& GetRequestType() const {
if (RequestCtx) {
if (!RequestType) {
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/kqp/session_actor/kqp_query_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TKqpQueryState : public TNonCopyable {
TKqpQueryState(TEvKqp::TEvQueryRequest::TPtr& ev, ui64 queryId, const TString& database,
const TString& cluster, TKqpDbCountersPtr dbCounters, bool longSession,
const NKikimrConfig::TTableServiceConfig& tableServiceConfig, const NKikimrConfig::TQueryServiceConfig& queryServiceConfig,
NWilson::TTraceId&& traceId, const TString& sessionId, TMonotonic startedAt)
const TString& sessionId, TMonotonic startedAt)
: QueryId(queryId)
, Database(database)
, Cluster(cluster)
Expand All @@ -62,7 +62,7 @@ class TKqpQueryState : public TNonCopyable {
SetQueryDeadlines(tableServiceConfig, queryServiceConfig);
auto action = GetAction();
KqpSessionSpan = NWilson::TSpan(
TWilsonKqp::KqpSession, std::move(traceId),
TWilsonKqp::KqpSession, std::move(RequestEv->GetWilsonTraceId()),
"Session.query." + NKikimrKqp::EQueryAction_Name(action), NWilson::EFlags::AUTO_END);
if (RequestEv->GetUserRequestContext()) {
UserRequestContext = RequestEv->GetUserRequestContext();
Expand Down
3 changes: 1 addition & 2 deletions ydb/core/kqp/session_actor/kqp_session_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {
ev->Get()->SetClientLostAction(selfId, as);
QueryState = std::make_shared<TKqpQueryState>(
ev, QueryId, Settings.Database, Settings.Cluster, Settings.DbCounters, Settings.LongSession,
Settings.TableService, Settings.QueryService, std::move(ev->TraceId), SessionId,
AppData()->MonotonicTimeProvider->Now());
Settings.TableService, Settings.QueryService, SessionId, AppData()->MonotonicTimeProvider->Now());
if (QueryState->UserRequestContext->TraceId.empty()) {
QueryState->UserRequestContext->TraceId = UlidGen.Next().ToString();
}
Expand Down

0 comments on commit c80bfea

Please sign in to comment.