Source File
b3.go
Belonging Package
go.opencensus.io/plugin/ochttp/propagation/b3
package b3 // import "go.opencensus.io/plugin/ochttp/propagation/b3"
import (
)
const (
TraceIDHeader = "X-B3-TraceId"
SpanIDHeader = "X-B3-SpanId"
SampledHeader = "X-B3-Sampled"
)
type HTTPFormat struct{}
var _ propagation.HTTPFormat = (*HTTPFormat)(nil)
func ( *HTTPFormat) ( *http.Request) ( trace.SpanContext, bool) {
, := ParseTraceID(.Header.Get(TraceIDHeader))
if ! {
return trace.SpanContext{}, false
}
, := ParseSpanID(.Header.Get(SpanIDHeader))
if ! {
return trace.SpanContext{}, false
}
, := ParseSampled(.Header.Get(SampledHeader))
return trace.SpanContext{
TraceID: ,
SpanID: ,
TraceOptions: ,
}, true
}
func ( string) (trace.TraceOptions, bool) {
switch {
case "true", "1":
return trace.TraceOptions(1), true
default:
return trace.TraceOptions(0), false
}
}
func ( *HTTPFormat) ( trace.SpanContext, *http.Request) {
.Header.Set(TraceIDHeader, hex.EncodeToString(.TraceID[:]))
.Header.Set(SpanIDHeader, hex.EncodeToString(.SpanID[:]))
var string
if .IsSampled() {
= "1"
} else {
= "0"
}
.Header.Set(SampledHeader, )
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |