-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add baggage span processor #937
feat: Add baggage span processor #937
Conversation
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.
Here's the first take on the long-awaited span processor to take current Baggage key/values and add them as attributes to spans as they start.
Not sure of the module namespace in the current state. This is a span processor, so should we nest it more deeply under the OpenTelemetry::Trace namespace? Is "Span" in its name sufficient? What do y'all think?
We can work on adding unit tests to this. The first edition of those would look a lot like the RSpec specs I wrote over here.
processor/baggage/lib/opentelemetry/processor/baggage/baggage_span_processor.rb
Outdated
Show resolved
Hide resolved
Indent appropriately. Lift some doc content to the BaggageSpanProcessor class and focus the method docs on the method behavior.
Something that I want to confirm, this is still going to require that the user annotate the active/current span in addition to using baggage. It's also going to transfer these attributes across service boundaries. Is that the effect that you want? If so, I think it is important to highlight that this will potentially cause message and HTTP headers to impact performance since there isn't anything built in to say prevent the headers from growing unwieldy. (No per-header compression e.g.) In addition to that baggage usage means library instrumentation will include all items in outbound headers to 3rd parties, which will raise concerns for privacy. I realize that these concerns I am highlighting are not specific to this implementation but issues with Baggage; however, I think it would be important to highlight these concerns so that Baggage users are not caught off guard. span.add_attributes('user_id' => user.id, 'cart_id' => cart.id)
ctx = OpenTelemetry::Baggage.build do |builder|
builder.set_value('user_id', user.id)
builder.set_value('cart_id', cart.id)
end
tracer.in_span('checkout') do |span|
# yada yada yada
end |
Yes, it is known that baggage entries are transported to 3rd parties and you're correct this is a fault of baggage not this processor in particular. I haven't added a README yet, but will add warnings there, in the class implementation and any module functions to make it as clear as possible. I'll add a note regarding unbounded header size too. |
Do any other languages have an implementation in contrib, or more broadly, do any other languages have non-spec processors that live in contrib? (Fwiw I'm fine with this PR just kinda curious if y'all are setting precedent here, which, again, is fine if so) |
406b24d
to
96a7d62
Compare
We (Honeycomb) have started opening PRs to add BaggageSpanProcessor to contrib in other languages, so: technically "no" but also maybe "yes" soon. |
Huzzah. Ty @robbkidd , Sounds good to me. Ping if this gets stuck in the mud happy to help w/approvals but otherwise will leave to the folks more tuned in with uh..the world (I'm on pto for a little while) |
Well, I succeeded in adding a new set of jobs for Processors to the CI matrix! 🙌🏻 Now to wait for the matrix ... ⏳ |
... correct the module namespace in code example
Also, lean into spec's let.
Horrah! BaggageSpanProcessor tests pass. 🎉 |
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.
My only request for an actual change is to consolidate the CI jobs.
The other comments are optional changes/food for thought.
processor/baggage/lib/opentelemetry/processor/baggage/baggage_span_processor.rb
Show resolved
Hide resolved
|
||
describe '#on_start' do | ||
it 'adds current baggage keys/values as attributes when a span starts' do | ||
span.expect(:add_attributes, span, [{ 'a_key' => 'a_value' }]) |
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.
💭 Since a span is essentially a struct as opposed to a service and you all are having to configure the SDK for some of tests below, I think it is enough to test this functionality using state-based test as opposed to using interaction-based testing.
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.
I believe these tests were added to reflect a similar pattern used in other (instrumentation) packages. Is it worth replacing these or just a suggestion to reduce complexity?
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.
It was a suggestion but really, I leave the final decision up to you.
processor/baggage/lib/opentelemetry/processor/baggage/baggage_span_processor.rb
Show resolved
Hide resolved
Added this follow-up enhancement issue to track adding a key predicate function to control what keys are copied to newly created span attributes. |
Thanks for your feedback @arielvalentin. I've worked through and addressed your comments. Let me know if there's anything else. |
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.
Thank you for your contribution!
…rib into mike/baggage-span-processor # Conflicts: # .github/workflows/ci-contrib.yml
@arielvalentin - I've pulled in the change jruby 9.4.6.0 update and updated the new processors workflow. Is there anything else you need / want before accepting this PR? |
Follow up to open-telemetry#937 to make the gem releasable with our automation.
tell toys about the new baggage span processor Follow up to #937 to make the gem releasable with our automation.
Summary of changes
Adds the baggage span processor. I've added under new root dir
processors
, not sure if that's the best place for it or it should go somewhere else. Happy to take direction.