Context and Baggage API usage #701
Replies: 2 comments 1 reply
-
@arielvalentin your example is idiomatic given the current API. The Baggage::Manager helps to manipulate baggage in a context, and then the Context API is used to activate / deactivate a given context instance. Also, given that you are starting to look at using baggage, you might have some opinions on #703. |
Beta Was this translation helpful? Give feedback.
-
I almost feel like it would look more idiomatic if it read as: updated_context = OpenTelemetry.baggage.merge do |context|
context.set_value(key_a: "foo")
context.set_value(key_b: "bar")
end ...primarily since |
Beta Was this translation helpful? Give feedback.
-
I am interested in taking in using the Context and Baggage API in our applications however I want to ensure I am doing so in an idiomatic way.
I can see that the API provides utility methods like
OpenTelemetry::Context.with_current
that changes theimplicit
reference inOpenTelemetry::Context.current
.The
OpenTelemetry::Baggage::Manager
also generates a new instance of theOpenTelemetry::Context
that has a newly populated baggage entry, defaulting to using theimplicit
context. e.g.OpenTelemetry::Baggage::Manager#build
I also see examples in auto-instrumented libraries that set the
implicit
scope usingOpenTelemetry::Context.with_value
, but haven't seen any used forBaggage
just yet.Would this be the idiomatic way to do so?
Beta Was this translation helpful? Give feedback.
All reactions