mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/tracing: Add context key constants
This commit is contained in:
parent
d7ab444aec
commit
bfd3346532
2 changed files with 11 additions and 6 deletions
|
|
@ -275,8 +275,8 @@ func (d *Delivery) RequestFromPeers(ctx context.Context, req *network.Request) (
|
||||||
|
|
||||||
// setting this value in the context creates a new span that can persist across the sendpriority queue and the network roundtrip
|
// setting this value in the context creates a new span that can persist across the sendpriority queue and the network roundtrip
|
||||||
// this span will finish only when delivery is handled (or times out)
|
// this span will finish only when delivery is handled (or times out)
|
||||||
ctx = context.WithValue(ctx, "stream_send_tag", "stream.send.request")
|
ctx = context.WithValue(ctx, tracing.StoreLabelId, "stream.send.request")
|
||||||
ctx = context.WithValue(ctx, "stream_send_meta", fmt.Sprintf("%v.%v", sp.ID(), req.Addr))
|
ctx = context.WithValue(ctx, tracing.StoreLabelMeta, fmt.Sprintf("%v.%v", sp.ID(), req.Addr))
|
||||||
err := sp.SendPriority(ctx, &RetrieveRequestMsg{
|
err := sp.SendPriority(ctx, &RetrieveRequestMsg{
|
||||||
Addr: req.Addr,
|
Addr: req.Addr,
|
||||||
SkipCheck: req.SkipCheck,
|
SkipCheck: req.SkipCheck,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,11 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// TracingEnabledFlag is the CLI flag name to use to enable trace collections.
|
// TracingEnabledFlag is the CLI flag name to use to enable trace collections.
|
||||||
const TracingEnabledFlag = "tracing"
|
const (
|
||||||
|
TracingEnabledFlag = "tracing"
|
||||||
|
StoreLabelId = "span_save_id"
|
||||||
|
StoreLabelMeta = "span_save_meta"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Closer io.Closer
|
Closer io.Closer
|
||||||
|
|
@ -117,7 +121,8 @@ func StartSaveSpan(ctx context.Context) context.Context {
|
||||||
if !Enabled {
|
if !Enabled {
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
traceId := ctx.Value("span_save_id")
|
traceId := ctx.Value(StoreLabelId)
|
||||||
|
|
||||||
if traceId != nil {
|
if traceId != nil {
|
||||||
traceStr := traceId.(string)
|
traceStr := traceId.(string)
|
||||||
var sp opentracing.Span
|
var sp opentracing.Span
|
||||||
|
|
@ -125,11 +130,11 @@ func StartSaveSpan(ctx context.Context) context.Context {
|
||||||
ctx,
|
ctx,
|
||||||
traceStr,
|
traceStr,
|
||||||
)
|
)
|
||||||
traceMeta := ctx.Value("span_save_meta")
|
traceMeta := ctx.Value(StoreLabelMeta)
|
||||||
if traceMeta != nil {
|
if traceMeta != nil {
|
||||||
traceStr = traceStr + "." + traceMeta.(string)
|
traceStr = traceStr + "." + traceMeta.(string)
|
||||||
}
|
}
|
||||||
store.spans.Store(traceId, sp)
|
store.spans.Store(traceStr, sp)
|
||||||
}
|
}
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue