Skip to content

Commit 1f57945

Browse files
committed
fix: Remove funtionName from labels from pg_query_duration_seconds_* metrics
1 parent 813ff96 commit 1f57945

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

common-lib/utils/SqlUtil.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,31 +85,31 @@ func ExecutePGQueryProcessor(cfg bean.PgQueryMonitoringConfig, event bean.PgQuer
8585
} else {
8686
status = SUCCESS
8787
}
88-
PgQueryDuration.WithLabelValues(status, cfg.ServiceName, event.FuncName, getErrorType(pgError).String()).Observe(queryDuration.Seconds())
88+
PgQueryDuration.WithLabelValues(status, cfg.ServiceName, getErrorType(pgError).String()).Observe(queryDuration.Seconds())
8989
}
9090

9191
// Log pg query if enabled
9292
logThresholdQueries := cfg.LogSlowQuery && queryDuration.Milliseconds() > cfg.QueryDurationThreshold
9393
logNetworkFailure := queryError && cfg.LogAllFailureQueries && isNetworkError(pgError)
9494
if logNetworkFailure {
95-
log.Println(fmt.Sprintf("%s - query time", PgNetworkErrorLogPrefix), "duration", queryDuration.Seconds(), "query", event.Query, "pgError", pgError)
95+
log.Println(fmt.Sprintf("%s - query time", PgNetworkErrorLogPrefix), "duration", queryDuration.Seconds(), "functionName", event.FuncName, "query", event.Query, "pgError", pgError)
9696
}
9797
logFailureQuery := queryError && cfg.LogAllFailureQueries && !isNetworkError(pgError)
9898
if logFailureQuery {
99-
log.Println(fmt.Sprintf("%s - query time", PgQueryFailLogPrefix), "duration", queryDuration.Seconds(), "query", event.Query, "pgError", pgError)
99+
log.Println(fmt.Sprintf("%s - query time", PgQueryFailLogPrefix), "duration", queryDuration.Seconds(), "functionName", event.FuncName, "query", event.Query, "pgError", pgError)
100100
}
101101
if logThresholdQueries {
102-
log.Println(fmt.Sprintf("%s - query time", PgQuerySlowLogPrefix), "duration", queryDuration.Seconds(), "query", event.Query)
102+
log.Println(fmt.Sprintf("%s - query time", PgQuerySlowLogPrefix), "duration", queryDuration.Seconds(), "functionName", event.FuncName, "query", event.Query)
103103
}
104104
if cfg.LogAllQuery {
105-
log.Println("query time", "duration", queryDuration.Seconds(), "query", event.Query)
105+
log.Println("query time", "duration", queryDuration.Seconds(), "functionName", event.FuncName, "query", event.Query)
106106
}
107107
}
108108

109109
var PgQueryDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
110110
Name: "pg_query_duration_seconds",
111111
Help: "Duration of PG queries",
112-
}, []string{"status", "serviceName", "functionName", "errorType"})
112+
}, []string{"status", "serviceName", "errorType"})
113113

114114
func getErrorType(err error) ErrorType {
115115
if err == nil {

0 commit comments

Comments
 (0)