Skip to content

Commit e3210be

Browse files
authored
fix baggage and tag concurrent problem (#29)
1 parent c790f92 commit e3210be

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

CHANGLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.1.17] - 2025-12-04
2+
### Fixed
3+
- fix baggage and tag concurrent problem
4+
15
## [0.1.16] - 2025-11-10
26
### Fixed
37
- fix baggage escape problem

internal/trace/span.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ type TagTruncateConf struct {
8383
InputOutputFieldMaxByte int
8484
}
8585

86+
func (s *Span) GetBaggage() map[string]string {
87+
var bg map[string]string
88+
s.lock.RLock()
89+
rawBag := s.SpanContext.GetBaggage()
90+
if rawBag != nil {
91+
bg = make(map[string]string)
92+
for k, v := range rawBag {
93+
bg[k] = v
94+
}
95+
}
96+
s.lock.RUnlock()
97+
return bg
98+
}
99+
86100
func (s *Span) setCutOffTag(cutOffKeys []string) {
87101
if cutOffTags, ok := s.SystemTagMap[consts.CutOff]; ok {
88102
if value, ok := cutOffTags.([]string); ok {
@@ -117,7 +131,16 @@ func (s *Span) GetTagMap() map[string]interface{} {
117131
return nil
118132
}
119133

120-
return s.TagMap
134+
var tagMap map[string]interface{}
135+
s.lock.RLock()
136+
if s.TagMap != nil {
137+
tagMap = make(map[string]interface{})
138+
for k, v := range s.TagMap {
139+
tagMap[k] = v
140+
}
141+
}
142+
s.lock.RUnlock()
143+
return tagMap
121144
}
122145

123146
func (s *Span) GetDuration() int64 {

internal/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ package internal
55

66
// Version returns the version of the loop package.
77
func Version() string {
8-
return "v0.1.16"
8+
return "v0.1.17"
99
}

0 commit comments

Comments
 (0)