forked from influxdata/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtracing.go
More file actions
29 lines (24 loc) · 687 Bytes
/
tracing.go
File metadata and controls
29 lines (24 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package flux
import (
"context"
)
type contextKey string
const queryTracingContextKey contextKey = "query-tracing-enabled"
// WithQueryTracingEnabled will return a child context
// that will turn on experimental query tracing.
func WithQueryTracingEnabled(parentCtx context.Context) context.Context {
return context.WithValue(parentCtx, queryTracingContextKey, true)
}
// IsQueryTracingEnabled will return true if the context
// contains a key indicating that experimental tracing is enabled.
func IsQueryTracingEnabled(ctx context.Context) bool {
v := ctx.Value(queryTracingContextKey)
if v == nil {
return false
}
b, ok := v.(bool)
if !ok {
return false
}
return b
}