@@ -10,7 +10,7 @@ import (
10
10
"time"
11
11
12
12
"github.com/go-kit/kit/log/level"
13
- opentracing "github.com/opentracing/opentracing-go"
13
+ ot "github.com/opentracing/opentracing-go"
14
14
"github.com/prometheus/client_golang/prometheus"
15
15
"github.com/prometheus/client_golang/prometheus/promauto"
16
16
"github.com/prometheus/prometheus/config"
@@ -280,13 +280,18 @@ func (r *Ruler) getOrCreateNotifier(userID string) (*notifier.Manager, error) {
280
280
n = newRulerNotifier (& notifier.Options {
281
281
QueueCapacity : r .cfg .NotificationQueueCapacity ,
282
282
Do : func (ctx context.Context , client * http.Client , req * http.Request ) (* http.Response , error ) {
283
- // Note: The passed-in context comes from the Prometheus rule group code
283
+ // Note: The passed-in context comes from the Prometheus notifier
284
284
// and does *not* contain the userID. So it needs to be added to the context
285
285
// here before using the context to inject the userID into the HTTP request.
286
286
ctx = user .InjectOrgID (ctx , userID )
287
287
if err := user .InjectOrgIDIntoHTTPRequest (ctx , req ); err != nil {
288
288
return nil , err
289
289
}
290
+ // Jaeger complains the passed-in context has an invalid span ID, so start a new root span
291
+ sp := ot .GlobalTracer ().StartSpan ("notify" , ot.Tag {Key : "organization" , Value : userID })
292
+ defer sp .Finish ()
293
+ ctx = ot .ContextWithSpan (ctx , sp )
294
+ ot .GlobalTracer ().Inject (sp .Context (), ot .HTTPHeaders , ot .HTTPHeadersCarrier (req .Header ))
290
295
return ctxhttp .Do (ctx , client , req )
291
296
},
292
297
}, util .Logger )
@@ -313,7 +318,7 @@ func (r *Ruler) Evaluate(userID string, item *workItem) {
313
318
level .Debug (logger ).Log ("msg" , "evaluating rules..." , "num_rules" , len (item .group .Rules ()))
314
319
ctx , cancelTimeout := context .WithTimeout (ctx , r .cfg .GroupTimeout )
315
320
instrument .CollectedRequest (ctx , "Evaluate" , evalDuration , nil , func (ctx native_ctx.Context ) error {
316
- if span := opentracing .SpanFromContext (ctx ); span != nil {
321
+ if span := ot .SpanFromContext (ctx ); span != nil {
317
322
span .SetTag ("instance" , userID )
318
323
span .SetTag ("groupName" , item .groupName )
319
324
}
0 commit comments