Source File
span_context.go
Belonging Package
go.opentelemetry.io/otel/api/trace
package trace
import (
)
FlagsDebug = byte(0x04)
ErrInvalidHexID errorConst = "trace-id and span-id can only contain [0-9a-f] characters, all lowercase"
ErrInvalidTraceIDLength errorConst = "hex encoded trace-id must have length equals to 32"
ErrNilTraceID errorConst = "trace-id can't be all zero"
ErrInvalidSpanIDLength errorConst = "hex encoded span-id must have length equals to 16"
ErrNilSpanID errorConst = "span-id can't be all zero"
)
type errorConst string
func ( errorConst) () string {
return string()
}
type ID [16]byte
var nilTraceID ID
var _ json.Marshaler = nilTraceID
func ( ID) () bool {
return !bytes.Equal([:], nilTraceID[:])
}
func ( ID) () string {
return hex.EncodeToString([:])
}
func ( SpanID) () string {
return hex.EncodeToString([:])
}
func ( string) (SpanID, error) {
:= SpanID{}
if len() != 16 {
return , ErrInvalidSpanIDLength
}
if := decodeHex(, [:]); != nil {
return ,
}
if !.IsValid() {
return , ErrNilSpanID
}
return , nil
}
func ( string, []byte) error {
for , := range {
switch {
case 'a' <= && <= 'f':
continue
case '0' <= && <= '9':
continue
default:
return ErrInvalidHexID
}
}
, := hex.DecodeString()
if != nil {
return
}
copy(, )
return nil
}
type SpanContext struct {
TraceID ID
SpanID SpanID
TraceFlags byte
}
func () SpanContext {
return SpanContext{}
}
func ( SpanContext) () bool {
return .HasTraceID() && .HasSpanID()
}
func ( SpanContext) () bool {
return .TraceID.IsValid()
}
func ( SpanContext) () bool {
return .SpanID.IsValid()
}
func ( SpanContext) () bool {
return .TraceFlags&FlagsDeferred == FlagsDeferred
}
func ( SpanContext) () bool {
return .TraceFlags&FlagsDebug == FlagsDebug
}
func ( SpanContext) () bool {
return .TraceFlags&FlagsSampled == FlagsSampled
![]() |
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. |