Source File
http.go
Belonging Package
google.golang.org/api/transport/http/internal/propagation
package propagation
import (
)
const (
httpHeaderMaxSize = 200
httpHeader = `X-Cloud-Trace-Context`
)
var _ propagation.HTTPFormat = (*HTTPFormat)(nil)
type HTTPFormat struct{}
func ( *HTTPFormat) ( *http.Request) ( trace.SpanContext, bool) {
if == "" || len() > httpHeaderMaxSize {
return trace.SpanContext{}, false
}
:= strings.Index(, `/`)
if == -1 {
return trace.SpanContext{}, false
}
, := [:], [+1:]
, := hex.DecodeString()
if != nil {
return trace.SpanContext{}, false
}
copy(.TraceID[:], )
if !strings.HasPrefix(, "o=") {
return , true
}
, := strconv.ParseUint([2:], 10, 64)
if != nil {
return trace.SpanContext{}, false
}
.TraceOptions = trace.TraceOptions()
return , true
}
func ( *HTTPFormat) ( trace.SpanContext, *http.Request) {
:= binary.BigEndian.Uint64(.SpanID[:])
:= fmt.Sprintf("%s/%d;o=%d", hex.EncodeToString(.TraceID[:]), , int64(.TraceOptions))
.Header.Set(httpHeader, )
![]() |
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. |