Remove a confusing closure
Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
parent
0ab3b724cc
commit
46b61a38cd
|
@ -678,22 +678,20 @@ func (s *Silences) QueryOne(params ...QueryParam) (*pb.Silence, error) {
|
||||||
// Query for silences based on the given query parameters. It returns the
|
// Query for silences based on the given query parameters. It returns the
|
||||||
// resulting silences and the state version the result is based on.
|
// resulting silences and the state version the result is based on.
|
||||||
func (s *Silences) Query(params ...QueryParam) ([]*pb.Silence, int, error) {
|
func (s *Silences) Query(params ...QueryParam) ([]*pb.Silence, int, error) {
|
||||||
start := time.Now()
|
|
||||||
s.metrics.queriesTotal.Inc()
|
s.metrics.queriesTotal.Inc()
|
||||||
|
defer prometheus.NewTimer(s.metrics.queryDuration).ObserveDuration()
|
||||||
|
|
||||||
sils, version, err := func() ([]*pb.Silence, int, error) {
|
|
||||||
q := &query{}
|
q := &query{}
|
||||||
for _, p := range params {
|
for _, p := range params {
|
||||||
if err := p(q); err != nil {
|
if err := p(q); err != nil {
|
||||||
|
s.metrics.queryErrorsTotal.Inc()
|
||||||
return nil, s.Version(), err
|
return nil, s.Version(), err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s.query(q, s.now())
|
sils, version, err := s.query(q, s.now())
|
||||||
}()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.metrics.queryErrorsTotal.Inc()
|
s.metrics.queryErrorsTotal.Inc()
|
||||||
}
|
}
|
||||||
s.metrics.queryDuration.Observe(time.Since(start).Seconds())
|
|
||||||
return sils, version, err
|
return sils, version, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue