|
|
@ -19,39 +19,39 @@ var ( |
|
|
|
|
|
|
|
|
|
|
|
// SpanContext implements opentracing.SpanContext
|
|
|
|
// SpanContext implements opentracing.SpanContext
|
|
|
|
type spanContext struct { |
|
|
|
type spanContext struct { |
|
|
|
// traceID represents globally unique ID of the trace.
|
|
|
|
// TraceID represents globally unique ID of the trace.
|
|
|
|
// Usually generated as a random number.
|
|
|
|
// Usually generated as a random number.
|
|
|
|
traceID uint64 |
|
|
|
TraceID uint64 |
|
|
|
|
|
|
|
|
|
|
|
// spanID represents span ID that must be unique within its trace,
|
|
|
|
// SpanID represents span ID that must be unique within its trace,
|
|
|
|
// but does not have to be globally unique.
|
|
|
|
// but does not have to be globally unique.
|
|
|
|
spanID uint64 |
|
|
|
SpanID uint64 |
|
|
|
|
|
|
|
|
|
|
|
// parentID refers to the ID of the parent span.
|
|
|
|
// ParentID refers to the ID of the parent span.
|
|
|
|
// Should be 0 if the current span is a root span.
|
|
|
|
// Should be 0 if the current span is a root span.
|
|
|
|
parentID uint64 |
|
|
|
ParentID uint64 |
|
|
|
|
|
|
|
|
|
|
|
// flags is a bitmap containing such bits as 'sampled' and 'debug'.
|
|
|
|
// Flags is a bitmap containing such bits as 'sampled' and 'debug'.
|
|
|
|
flags byte |
|
|
|
Flags byte |
|
|
|
|
|
|
|
|
|
|
|
// probability
|
|
|
|
// Probability
|
|
|
|
probability float32 |
|
|
|
Probability float32 |
|
|
|
|
|
|
|
|
|
|
|
// current level
|
|
|
|
// Level current level
|
|
|
|
level int |
|
|
|
Level int |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c spanContext) isSampled() bool { |
|
|
|
func (c spanContext) isSampled() bool { |
|
|
|
return (c.flags & flagSampled) == flagSampled |
|
|
|
return (c.Flags & flagSampled) == flagSampled |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c spanContext) isDebug() bool { |
|
|
|
func (c spanContext) isDebug() bool { |
|
|
|
return (c.flags & flagDebug) == flagDebug |
|
|
|
return (c.Flags & flagDebug) == flagDebug |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// IsValid check spanContext valid
|
|
|
|
// IsValid check spanContext valid
|
|
|
|
func (c spanContext) IsValid() bool { |
|
|
|
func (c spanContext) IsValid() bool { |
|
|
|
return c.traceID != 0 && c.spanID != 0 |
|
|
|
return c.TraceID != 0 && c.SpanID != 0 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// emptyContext emptyContext
|
|
|
|
// emptyContext emptyContext
|
|
|
@ -69,10 +69,10 @@ var emptyContext = spanContext{} |
|
|
|
// sample-rate: s-{base16(BigEndian(float32))}
|
|
|
|
// sample-rate: s-{base16(BigEndian(float32))}
|
|
|
|
func (c spanContext) String() string { |
|
|
|
func (c spanContext) String() string { |
|
|
|
base := make([]string, 4) |
|
|
|
base := make([]string, 4) |
|
|
|
base[0] = strconv.FormatUint(uint64(c.traceID), 16) |
|
|
|
base[0] = strconv.FormatUint(uint64(c.TraceID), 16) |
|
|
|
base[1] = strconv.FormatUint(uint64(c.spanID), 16) |
|
|
|
base[1] = strconv.FormatUint(uint64(c.SpanID), 16) |
|
|
|
base[2] = strconv.FormatUint(uint64(c.parentID), 16) |
|
|
|
base[2] = strconv.FormatUint(uint64(c.ParentID), 16) |
|
|
|
base[3] = strconv.FormatUint(uint64(c.flags), 16) |
|
|
|
base[3] = strconv.FormatUint(uint64(c.Flags), 16) |
|
|
|
return strings.Join(base, ":") |
|
|
|
return strings.Join(base, ":") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -101,10 +101,10 @@ func contextFromString(value string) (spanContext, error) { |
|
|
|
return emptyContext, errInvalidTracerString |
|
|
|
return emptyContext, errInvalidTracerString |
|
|
|
} |
|
|
|
} |
|
|
|
sctx := spanContext{ |
|
|
|
sctx := spanContext{ |
|
|
|
traceID: rets[0], |
|
|
|
TraceID: rets[0], |
|
|
|
spanID: rets[1], |
|
|
|
SpanID: rets[1], |
|
|
|
parentID: rets[2], |
|
|
|
ParentID: rets[2], |
|
|
|
flags: byte(rets[3]), |
|
|
|
Flags: byte(rets[3]), |
|
|
|
} |
|
|
|
} |
|
|
|
return sctx, nil |
|
|
|
return sctx, nil |
|
|
|
} |
|
|
|
} |
|
|
|