fix: rename tracedPGxHooks to tracedSQLHooks

This commit is contained in:
DevMiner 2024-07-28 16:56:41 +02:00
parent 8bf2fa122d
commit d5cbb6a757

View file

@ -26,7 +26,7 @@ type dbCtxVal struct {
attrs []attribute.KeyValue
}
type tracedPgxHooks struct {
type tracedSQLHooks struct {
dbType string
t *Telemetry
@ -36,7 +36,7 @@ type tracedPgxHooks struct {
mDuration metric.Float64Histogram
}
func (h *tracedPgxHooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error) {
func (h *tracedSQLHooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error) {
cleanedQuery := strings.ReplaceAll(query, "\n", " ")
cleanedQuery = strings.ReplaceAll(cleanedQuery, "\t", " ")
cleanedQuery = strings.ReplaceAll(cleanedQuery, " ", " ")
@ -78,7 +78,7 @@ func (h *tracedPgxHooks) Before(ctx context.Context, query string, args ...inter
}), nil
}
func (h *tracedPgxHooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error) {
func (h *tracedSQLHooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error) {
if s := SpanFromContext(ctx); s != nil {
s.End()
}
@ -106,7 +106,7 @@ func (t *Telemetry) TraceSQL(driver driver.Driver, dbType string, printQueries b
log.Fatal().Err(err).Msg("failed to create request duration histogram")
}
return sqlhooks.Wrap(driver, &tracedPgxHooks{
return sqlhooks.Wrap(driver, &tracedSQLHooks{
dbType: dbType,
printQueries: printQueries,