Add an OpenTracing span for each rule (#4027)

* Add an OpenTracing span for each rule

So that tags and child spans can be traced back to the rule that they
refer to.
pull/4032/head
Bryan Boreham 7 years ago committed by Brian Brazil
parent 68e394a56e
commit 93494d8b7e

@ -27,6 +27,7 @@ import (
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
opentracing "github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
@ -324,7 +325,10 @@ func (g *Group) Eval(ctx context.Context, ts time.Time) {
} }
func(i int, rule Rule) { func(i int, rule Rule) {
sp, ctx := opentracing.StartSpanFromContext(ctx, "rule")
sp.SetTag("name", rule.Name())
defer func(t time.Time) { defer func(t time.Time) {
sp.Finish()
evalDuration.Observe(time.Since(t).Seconds()) evalDuration.Observe(time.Since(t).Seconds())
rule.SetEvaluationTime(time.Since(t)) rule.SetEvaluationTime(time.Since(t))
}(time.Now()) }(time.Now())

Loading…
Cancel
Save