Skip to content

Commit 3432e27

Browse files
authored
Merge pull request #160034 from yuzefovich/blathers/backport-release-26.1-159964
release-26.1: sql: attach opName string as pprof label for internal queries
2 parents 0f03329 + 99ec795 commit 3432e27

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

pkg/sql/conn_executor_exec.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,15 +4461,25 @@ func (ex *connExecutor) execWithProfiling(
44614461
}
44624462
// Compute fingerprint ID here since ih.Setup hasn't been called yet.
44634463
fingerprintID := appstatspb.ConstructStatementFingerprintID(
4464-
stmtNoConstants, ex.implicitTxn(), ex.sessionData().Database)
4465-
pprofutil.Do(ctx, func(ctx context.Context) {
4466-
err = op(ctx)
4467-
},
4464+
stmtNoConstants, ex.implicitTxn(), ex.sessionData().Database,
4465+
)
4466+
labels := make([]string, 0, 12)
4467+
labels = append(labels, []string{
44684468
workloadid.ProfileTag, sqlstatsutil.EncodeStmtFingerprintIDToString(fingerprintID),
44694469
"appname", ex.sessionData().ApplicationName,
44704470
"addr", remoteAddr,
44714471
"stmt.tag", ast.StatementTag(),
44724472
"stmt.no.constants", stmtNoConstants,
4473+
}...)
4474+
if opName, ok := GetInternalOpName(ctx); ok {
4475+
labels = append(labels, "opname", opName)
4476+
}
4477+
pprofutil.Do(
4478+
ctx,
4479+
func(ctx context.Context) {
4480+
err = op(ctx)
4481+
},
4482+
labels...,
44734483
)
44744484
} else {
44754485
err = op(ctx)

0 commit comments

Comments
 (0)