Skip to content

Commit

Permalink
sql: add profiler labels for sql statement running remote flows
Browse files Browse the repository at this point in the history
Fixes: #82464

Release note (sql change): SQL queries running on remote nodes
now show up in cpu profiles with "distsql.*" labels. Currently include
appname, gateway, txn and stmt.
  • Loading branch information
cucaroach committed Nov 30, 2022
1 parent ccce779 commit 1447255
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/sql/distsql/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,16 @@ func (ds *ServerImpl) setupFlow(
if req.JobTag != "" {
flowCtx.AmbientContext.AddLogTag("job", req.JobTag)
}
if req.StatementSQL != "" {
flowCtx.AmbientContext.AddLogTag("distsql.stmt", req.StatementSQL)
}
flowCtx.AmbientContext.AddLogTag("distsql.gateway", req.Flow.Gateway)
if req.EvalContext.SessionData.ApplicationName != "" {
flowCtx.AmbientContext.AddLogTag("distsql.appname", req.EvalContext.SessionData.ApplicationName)
}
if leafTxn != nil {
flowCtx.AmbientContext.AddLogTag("distsql.txn", leafTxn.ID())
}
ctx = flowCtx.AmbientContext.AnnotateCtx(ctx)
telemetry.Inc(sqltelemetry.DistSQLExecCounter)
}
Expand Down

0 comments on commit 1447255

Please sign in to comment.