Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Save baggage in span #153

Merged
merged 4 commits into from
May 24, 2017
Merged

Save baggage in span #153

merged 4 commits into from
May 24, 2017

Conversation

black-adder
Copy link
Contributor

@black-adder black-adder commented May 23, 2017

We want to save the baggage when it is first set within the span. I think it makes sense to make baggage a first class item.

The new jaeger.thrift idl will look like:

struct BaggageRecord {
  1: required string key
  2: required string value
  3: optional i64 timestamp
}

struct Span {
  ...
  12: optional list<BaggageRecord> baggageRecords
}

Alternatives would be either tags or logs.
tag: we only have key-value so it would have to be a json blob of baggage:{key, value, timestamp}
log: same as above, we would have to use the fields which are key-value as well (json blob)

By making this a first class citizen, we don't need to manually parse the tags/logs for the UI.

Why timestamp in BaggageRecord? If the same baggage key is set multiple times, we can use the timestamp to differentiate them. (Not sure if it's really needed)

Fixes https://github.com/uber/jaeger/issues/179

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 85.642% when pulling 4df8735 on save_baggage_on_write into c762689 on master.

@yurishkuro
Copy link
Member

I think we can simply log it, to avoid introducing a new data model concept, as I don't see a really strong use case for it being a first class citizen. The log would be structured as

event=baggage
key=baggage key
value=baggage value

@black-adder
Copy link
Contributor Author

sure, a little extra work on the jaeger model to ui model conversion then

@yurishkuro
Copy link
Member

UI can easily find the logs with baggage event. Again, let's try to not change the data models if we don't have to.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 85.681% when pulling 7836d13 on save_baggage_on_write into c762689 on master.

span_test.go Outdated
value := logRecord.Fields[2].Value().(string)

require.Contains(t, expected, key)
assert.Equal(t, value, expected[key])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected should be first

span.go Outdated
@@ -173,6 +178,15 @@ func (s *Span) SetBaggageItem(key, value string) opentracing.Span {
s.Lock()
defer s.Unlock()
s.context = s.context.WithBaggageItem(key, value)
if !s.context.IsSampled() {
return s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this shortcut makes the assumption that the baggage log is always the last thing, which may not be the correct assumption in the future. It's better to include the log statement inside the if - it does not introduce significant nesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not completely following, if the span is not sampled, we shouldn't log the span so it should fall outside of the id stmt. Not sure what you mean by "the baggage log is always the last thing"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply meant

If sampled then log baggage.

span.go Outdated
}

// this function should only be called while holding a Write lock
func (s *Span) logFieldsWithLock(fields ...log.Field) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: L100: setTagNoLocking, here WithLock. We should be consistent.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@black-adder black-adder changed the title Save baggage in span POC Save baggage in span May 24, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 85.681% when pulling 7464ea0 on save_baggage_on_write into c762689 on master.

@@ -104,7 +104,7 @@ func TestSpanPropagator(t *testing.T) {
assert.Equal(t, exp.context, sp.context, formatName)
assert.Equal(t, "span.kind", sp.tags[0].key)
assert.Equal(t, expTags, sp.tags[1:] /*skip span.kind tag*/, formatName)
assert.Equal(t, exp.logs, sp.logs, formatName)
assert.NotEqual(t, exp.logs, sp.logs, formatName) // Only the parent span should have baggage logs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not equal is a very weak test, it may succeed for other reasons

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 85.748% when pulling f3f4390 on save_baggage_on_write into c762689 on master.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@black-adder black-adder merged commit bcb0e9e into master May 24, 2017
@black-adder black-adder deleted the save_baggage_on_write branch May 24, 2017 19:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants