@@ -811,6 +811,7 @@ class TKqpQueryExecutor : public IKikimrQueryExecutor {
811811 TKiDataQueryBlocks dataQueryBlocks (query);
812812
813813 auto queryAstStr = SerializeExpr (ctx, *query);
814+ TMaybe<TString> traceId = SessionCtx->GetUserRequestContext () ? SessionCtx->GetUserRequestContext ()->TraceId : TMaybe<TString>{};
814815
815816 bool useGenericQuery = ShouldUseGenericQuery (dataQueryBlocks);
816817 bool useScanQuery = ShouldUseScanQuery (dataQueryBlocks, settings);
@@ -828,7 +829,7 @@ class TKqpQueryExecutor : public IKikimrQueryExecutor {
828829 future = Gateway->ExplainGenericQuery (Cluster, SessionCtx->Query ().PreparingQuery ->GetText ());
829830 } else {
830831 future = Gateway->ExecGenericQuery (Cluster, SessionCtx->Query ().PreparingQuery ->GetText (), CollectParameters (query),
831- querySettings, txSettings);
832+ querySettings, txSettings, traceId );
832833 }
833834 } else if (useScanQuery) {
834835 ui64 rowsLimit = 0 ;
@@ -850,7 +851,7 @@ class TKqpQueryExecutor : public IKikimrQueryExecutor {
850851 future = Gateway->ExplainDataQueryAst (Cluster, queryAstStr);
851852 } else {
852853 future = Gateway->ExecDataQueryAst (Cluster, queryAstStr, CollectParameters (query),
853- querySettings, txSettings);
854+ querySettings, txSettings, traceId );
854855 }
855856 }
856857 break ;
@@ -860,7 +861,7 @@ class TKqpQueryExecutor : public IKikimrQueryExecutor {
860861 txSettings.mutable_serializable_read_write ();
861862
862863 future = Gateway->StreamExecGenericQuery (Cluster, SessionCtx->Query ().PreparingQuery ->GetText (), CollectParameters (query),
863- querySettings, txSettings, SessionCtx->Query ().ReplyTarget );
864+ querySettings, txSettings, SessionCtx->Query ().ReplyTarget , traceId );
864865 } else if (useScanQuery) {
865866 future = Gateway->StreamExecScanQueryAst (Cluster, queryAstStr, CollectParameters (query),
866867 querySettings, SessionCtx->Query ().ReplyTarget , SessionCtx->Query ().RpcCtx );
@@ -869,7 +870,7 @@ class TKqpQueryExecutor : public IKikimrQueryExecutor {
869870 txSettings.mutable_serializable_read_write ();
870871
871872 future = Gateway->StreamExecDataQueryAst (Cluster, queryAstStr, CollectParameters (query),
872- querySettings, txSettings, SessionCtx->Query ().ReplyTarget );
873+ querySettings, txSettings, SessionCtx->Query ().ReplyTarget , traceId );
873874 }
874875 break ;
875876
@@ -1033,7 +1034,8 @@ class TKqpHost : public IKqpHost {
10331034 std::optional<TKqpFederatedQuerySetup> federatedQuerySetup, const TIntrusiveConstPtr<NACLib::TUserToken>& userToken,
10341035 const NKikimr::NMiniKQL::IFunctionRegistry* funcRegistry, bool keepConfigChanges, bool isInternalCall,
10351036 TKqpTempTablesState::TConstPtr tempTablesState = nullptr , NActors::TActorSystem* actorSystem = nullptr ,
1036- NYql::TExprContext* ctx = nullptr , const NKikimrConfig::TQueryServiceConfig& queryServiceConfig = NKikimrConfig::TQueryServiceConfig())
1037+ NYql::TExprContext* ctx = nullptr , const NKikimrConfig::TQueryServiceConfig& queryServiceConfig = NKikimrConfig::TQueryServiceConfig(),
1038+ const TIntrusivePtr<TUserRequestContext>& userRequestContext = nullptr )
10371039 : Gateway(gateway)
10381040 , Cluster(cluster)
10391041 , GUCSettings(gUCSettings )
@@ -1044,7 +1046,7 @@ class TKqpHost : public IKqpHost {
10441046 , KeepConfigChanges(keepConfigChanges)
10451047 , IsInternalCall(isInternalCall)
10461048 , FederatedQuerySetup(federatedQuerySetup)
1047- , SessionCtx(new TKikimrSessionContext(funcRegistry, config, TAppData::TimeProvider, TAppData::RandomProvider, userToken))
1049+ , SessionCtx(new TKikimrSessionContext(funcRegistry, config, TAppData::TimeProvider, TAppData::RandomProvider, userToken, nullptr , userRequestContext ))
10481050 , Config(config)
10491051 , TypesCtx(MakeIntrusive<TTypeAnnotationContext>())
10501052 , PlanBuilder(CreatePlanBuilder(*TypesCtx))
@@ -1958,10 +1960,11 @@ TIntrusivePtr<IKqpHost> CreateKqpHost(TIntrusivePtr<IKqpGateway> gateway, const
19581960 const TString& database, TKikimrConfiguration::TPtr config, IModuleResolver::TPtr moduleResolver,
19591961 std::optional<TKqpFederatedQuerySetup> federatedQuerySetup, const TIntrusiveConstPtr<NACLib::TUserToken>& userToken, const TGUCSettings::TPtr& gUCSettings ,
19601962 const NKikimrConfig::TQueryServiceConfig& queryServiceConfig, const TMaybe<TString>& applicationName, const NKikimr::NMiniKQL::IFunctionRegistry* funcRegistry, bool keepConfigChanges,
1961- bool isInternalCall, TKqpTempTablesState::TConstPtr tempTablesState, NActors::TActorSystem* actorSystem, NYql::TExprContext* ctx)
1963+ bool isInternalCall, TKqpTempTablesState::TConstPtr tempTablesState, NActors::TActorSystem* actorSystem, NYql::TExprContext* ctx,
1964+ const TIntrusivePtr<TUserRequestContext>& userRequestContext)
19621965{
19631966 return MakeIntrusive<TKqpHost>(gateway, cluster, database, gUCSettings , applicationName, config, moduleResolver, federatedQuerySetup, userToken, funcRegistry,
1964- keepConfigChanges, isInternalCall, std::move (tempTablesState), actorSystem, ctx, queryServiceConfig);
1967+ keepConfigChanges, isInternalCall, std::move (tempTablesState), actorSystem, ctx, queryServiceConfig, userRequestContext );
19651968}
19661969
19671970} // namespace NKqp
0 commit comments