diff --git a/internal/consts/consts.go b/internal/consts/consts.go index f845233..177fe15 100644 --- a/internal/consts/consts.go +++ b/internal/consts/consts.go @@ -40,7 +40,7 @@ const ( ) const ( - GlobalTraceVersion = 1 + GlobalTraceVersion = 0 ) const ( diff --git a/internal/trace/span.go b/internal/trace/span.go index 162e8d1..dbff22e 100644 --- a/internal/trace/span.go +++ b/internal/trace/span.go @@ -221,6 +221,11 @@ func parseCommaSeparatedMap(src string, cover bool) (baggage map[string]string) return baggage } + // empty value is invalid + if tempKey == "" || tempValue == "" { + continue + } + _, exist := baggage[tempKey] // cover old value if cover is true if !exist || cover { @@ -915,7 +920,10 @@ func (s *Span) toHeaderBaggage() (string, error) { for k, v := range s.Baggage { tempK := k tempV := v - m[tempK] = tempV + // empty key or value is invalid + if tempK != "" && tempV != "" { + m[tempK] = tempV + } } return util.MapToStringString(m), nil }