Skip to content

Get right TraceId in SessionActor #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2024
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
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