ipld-eth-server/vendor/github.com/ipfs/go-metrics-interface/context.go
Elizabeth Engelman 36533f7c3f Update vendor directory and make necessary code changes
Fixes for new geth version
2019-09-25 16:32:27 -05:00

27 lines
537 B
Go

package metrics
import "context"
const CtxScopeKey = "ipfs.metrics.scope"
func CtxGetScope(ctx context.Context) string {
s := ctx.Value(CtxScopeKey)
if s == nil {
return "<no-scope>"
}
str, ok := s.(string)
if !ok {
return "<no-scope>"
}
return str
}
func CtxScope(ctx context.Context, scope string) context.Context {
return context.WithValue(ctx, CtxScopeKey, scope)
}
func CtxSubScope(ctx context.Context, subscope string) context.Context {
curscope := CtxGetScope(ctx)
return CtxScope(ctx, curscope+"."+subscope)
}