Skip to content

Commit 864a087

Browse files
committed
database_observability: don't log query text if redaction is enabled
1 parent cfc4715 commit 864a087

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

internal/component/database_observability/postgres/collector/query_samples.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,8 @@ func (c *QuerySamples) buildQuerySampleLabels(state *SampleState) string {
426426
}
427427
}
428428

429-
queryText := state.LastRow.Query.String
430-
if !c.disableQueryRedaction {
431-
queryText = redact(queryText)
432-
}
433-
434429
labels := fmt.Sprintf(
435-
`datname="%s" pid="%d" leader_pid="%s" user="%s" app="%s" client="%s" backend_type="%s" state="%s" xid="%d" xmin="%d" xact_time="%s" query_time="%s" queryid="%d" query="%s" engine="postgres"`,
430+
`datname="%s" pid="%d" leader_pid="%s" user="%s" app="%s" client="%s" backend_type="%s" state="%s" xid="%d" xmin="%d" xact_time="%s" query_time="%s" queryid="%d" engine="postgres"`,
436431
state.LastRow.DatabaseName.String,
437432
state.LastRow.PID,
438433
leaderPID,
@@ -446,11 +441,14 @@ func (c *QuerySamples) buildQuerySampleLabels(state *SampleState) string {
446441
xactDuration,
447442
queryDuration,
448443
state.LastRow.QueryID.Int64,
449-
queryText,
450444
)
451445
if state.LastCpuTime != "" {
452446
labels = fmt.Sprintf(`%s cpu_time="%s"`, labels, state.LastCpuTime)
453447
}
448+
if c.disableQueryRedaction {
449+
queryText := state.LastRow.Query.String
450+
labels = fmt.Sprintf(`%s query_text="%s"`, labels, queryText) // no need to redact
451+
}
454452
return labels
455453
}
456454

0 commit comments

Comments
 (0)