Skip to content
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

Merged

Conversation

MikeGoldsmith
Copy link
Member

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.

Copy link
Member

@robbkidd robbkidd left a 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.

robbkidd and others added 2 commits April 19, 2024 15:54
Indent appropriately.

Lift some doc content to the BaggageSpanProcessor class and focus the
method docs on the method behavior.
@arielvalentin
Copy link
Collaborator

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 

@MikeGoldsmith
Copy link
Member Author

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.

@ericmustin
Copy link
Contributor

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)

@MikeGoldsmith MikeGoldsmith force-pushed the mike/baggage-span-processor branch from 406b24d to 96a7d62 Compare April 22, 2024 16:14
@robbkidd
Copy link
Member

robbkidd commented Apr 22, 2024

Do any other languages have an implementation in contrib, or more broadly, do any other languages have non-spec processors that live in contrib?

We (Honeycomb) have started opening PRs to add BaggageSpanProcessor to contrib in other languages, so: technically "no" but also maybe "yes" soon.

@ericmustin
Copy link
Contributor

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)

@robbkidd
Copy link
Member

Well, I succeeded in adding a new set of jobs for Processors to the CI matrix! 🙌🏻

Now to wait for the matrix ... ⏳

@robbkidd
Copy link
Member

Horrah! BaggageSpanProcessor tests pass. 🎉

@robbkidd robbkidd self-assigned this Apr 22, 2024
@robbkidd robbkidd added feature New feature or request ruby Pull requests that update Ruby code labels Apr 22, 2024
Copy link
Collaborator

@arielvalentin arielvalentin left a 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.

.github/workflows/ci-processors.yml Outdated Show resolved Hide resolved
CODEOWNERS 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' }])
Copy link
Collaborator

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.

Copy link
Member Author

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?

Copy link
Collaborator

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.

@MikeGoldsmith
Copy link
Member Author

Added this follow-up enhancement issue to track adding a key predicate function to control what keys are copied to newly created span attributes.

@MikeGoldsmith
Copy link
Member Author

My only request for an actual change is to consolidate the CI jobs.

The other comments are optional changes/food for thought.

Thanks for your feedback @arielvalentin. I've worked through and addressed your comments. Let me know if there's anything else.

Copy link
Collaborator

@arielvalentin arielvalentin left a 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
@MikeGoldsmith
Copy link
Member Author

@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?

@arielvalentin arielvalentin merged commit 0675915 into open-telemetry:main Apr 30, 2024
51 checks passed
@MikeGoldsmith MikeGoldsmith deleted the mike/baggage-span-processor branch April 30, 2024 12:02
robbkidd added a commit to robbkidd/opentelemetry-ruby-contrib that referenced this pull request Apr 30, 2024
Follow up to open-telemetry#937 to make the gem releasable with our automation.
arielvalentin pushed a commit that referenced this pull request Apr 30, 2024
tell toys about the new baggage span processor

Follow up to #937 to make the gem releasable with our automation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request for new component: Baggage Span Processor
5 participants