Skip to content

Commit

Permalink
normalizeのバグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
mazrean committed Dec 3, 2024
1 parent f7a651d commit 6576422
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions db/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,16 @@ type segmentBuilder interface {
}

func (m *measureSegment) setQueryResult(query string, args []driver.Value, namedArgs []driver.NamedValue, queryDur float64) {
normalizedQuery := m.normalizeQuery(query)

if enableQueryTrace {
normalizedQuery := m.normalizeQuery(query)

queryCountVec.WithLabelValues(m.driver, m.addr, normalizedQuery).Inc()
queryDurHistogramVec.WithLabelValues(m.driver, m.addr, normalizedQuery).Observe(queryDur)
queryExecHook(m.driver, normalizedQuery, query, args, namedArgs, queryDur)
}
}

func measureQuery[T any](segment *measureSegment, query string, args []driver.Value, namedArgs []driver.NamedValue, f func() (T, error)) (T, error) {
query = segment.normalizeQuery(query)

start := time.Now()
result, err := f()
queryDur := float64(time.Since(start)) / float64(time.Second)
Expand Down

0 comments on commit 6576422

Please sign in to comment.