github.com/mier85/go-sensor@v1.30.1-0.20220920111756-9bf41b3bc7e0/w3ctrace/parent.go (about) 1 // (c) Copyright IBM Corp. 2021 2 // (c) Copyright Instana Inc. 2020 3 4 package w3ctrace 5 6 // Flags contains the trace flags as defined by https://www.w3.org/TR/trace-context/#trace-flags 7 type Flags struct { 8 Sampled bool 9 } 10 11 // Parent represents trace parent extracted from `traceparent` header 12 type Parent struct { 13 Version Version 14 TraceID string 15 ParentID string 16 Flags Flags 17 } 18 19 // ParseParent parses the value of `traceparent` header according to the version 20 // defined in the first field 21 func ParseParent(s string) (Parent, error) { 22 ver, err := ParseVersion(s) 23 if err != nil { 24 return Parent{}, ErrContextCorrupted 25 } 26 27 return ver.parseParent(s) 28 } 29 30 // String returns string representation of a trace parent. The returned value is compatible with the 31 // `traceparent` header format 32 func (p Parent) String() string { 33 return p.Version.formatParent(p) 34 }