-
Notifications
You must be signed in to change notification settings - Fork 289
Delete a baggage item when value is blank #562
Conversation
Codecov Report
@@ Coverage Diff @@
## master #562 +/- ##
==========================================
+ Coverage 88.64% 90.53% +1.89%
==========================================
Files 61 24 -37
Lines 3311 1670 -1641
==========================================
- Hits 2935 1512 -1423
+ Misses 249 109 -140
+ Partials 127 49 -78 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make sure all commits are signed (see CONTRIBUTING)
span_context.go
Outdated
if _, ok := c.baggage[key]; ok { | ||
newBaggage = make(map[string]string, len(c.baggage)) | ||
for k, v := range c.baggage { | ||
newBaggage[k] = v | ||
} | ||
delete(newBaggage, key) | ||
} else { | ||
newBaggage = c.baggage | ||
} | ||
return SpanContext{c.traceID, c.spanID, c.parentID, newBaggage, "", c.samplingState, c.remote} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if _, ok := c.baggage[key]; ok { | |
newBaggage = make(map[string]string, len(c.baggage)) | |
for k, v := range c.baggage { | |
newBaggage[k] = v | |
} | |
delete(newBaggage, key) | |
} else { | |
newBaggage = c.baggage | |
} | |
return SpanContext{c.traceID, c.spanID, c.parentID, newBaggage, "", c.samplingState, c.remote} | |
if _, ok := c.baggage[key]; !ok { | |
return c | |
} | |
newBaggage = make(map[string]string, len(c.baggage)) | |
for k, v := range c.baggage { | |
newBaggage[k] = v | |
} | |
delete(newBaggage, key) | |
return SpanContext{c.traceID, c.spanID, c.parentID, newBaggage, "", c.samplingState, c.remote} |
ctx = ctx.WithBaggageItem("some-KEY", "") | ||
assert.Nil(t, ctx.baggage) | ||
ctx = ctx.WithBaggageItem("some-KEY", "Some-Value") | ||
assert.Equal(t, map[string]string{"some-KEY": "Some-Value"}, ctx.baggage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.Equal(t, map[string]string{"some-KEY": "Some-Value"}, ctx.baggage) | |
assert.Equal(t, map[string]string{"some-KEY": "Some-Value"}, ctx.baggage) | |
ctx = ctx.WithBaggageItem("another-KEY", "") | |
assert.Equal(t, map[string]string{"some-KEY": "Some-Value"}, ctx.baggage) |
span_context_test.go
Outdated
ctx = ctx.WithBaggageItem("some-KEY", "") | ||
assert.Equal(t, map[string]string{}, ctx.baggage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx = ctx.WithBaggageItem("some-KEY", "") | |
assert.Equal(t, map[string]string{}, ctx.baggage) | |
ctx2 := ctx.WithBaggageItem("some-KEY", "") | |
assert.Equal(t, map[string]string{"some-KEY": "Some-Value"}, ctx.baggage, "parent unchanged") | |
assert.Equal(t, map[string]string{}, ctx2.baggage) |
Signed-off-by: zacscoding <[email protected]>
d24aa37
to
7c867de
Compare
@yurishkuro thx for review :) updated all comments 👍 |
Which problem is this PR solving?
Short description of the changes