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

tracing: add baggage methods to Tracing::Span #12260

Merged

Conversation

matthewgrossman
Copy link
Contributor

@matthewgrossman matthewgrossman commented Jul 23, 2020

Commit Message: tracing: add baggage methods to Tracing::Span
Additional Description: references #11622: We want an envoy filter to be able to read information off of the OT baggage to guide some routing decisions. First step is exposing the functionality of the existing spans/tracers so we can access this baggage dict within the filters. Once this functionality is added to the Tracing::Span, we can access with the baggage info inside a filter
Risk Level: Low: Small optional feature
Testing: Unit testing is added for all derived classes of Tracing::Span. All of the classes are noops except OpenTracingSpan (test) and LightStep (test)
Docs Changes: N/A for now, should something about baggage be added to tracing.rst?
Release Notes: think we need a note here?

Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
* @param key baggage key
* @param key baggage value
*/
virtual void setBaggage(const std::string& key, const std::string& value) PURE;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference with setTag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

baggage is persisted in the SpanContext, which means that any subsequent spans can access data in the baggage (it gets injected/extracted across process boundaries). This is useful when you need to embed information that is available for the entirety of the request

more reading: https://opentracing.io/docs/overview/tags-logs-baggage/, https://github.com/opentracing/specification/blob/master/specification.md#set-a-baggage-item

@mattklein123 mattklein123 self-assigned this Jul 23, 2020
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Copy link
Contributor

@LisaLudique LisaLudique left a comment

Choose a reason for hiding this comment

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

looks good so far, pending unit tests for the tracers and adding/updating documentation (it should be clear where baggage is/isn't supported)

include/envoy/tracing/http_tracer.h Outdated Show resolved Hide resolved
include/envoy/tracing/http_tracer.h Outdated Show resolved Hide resolved
Comment on lines 197 to 199
void Span::setBaggage(const std::string&, const std::string&) {}

std::string Span::getBaggage(const std::string&) { return std::string(); }
Copy link
Contributor

Choose a reason for hiding this comment

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

consider logging a warning here that this tracer doesn't support baggage (and likewise for the other tracers that do not support it)

Copy link
Contributor

Choose a reason for hiding this comment

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

you could even log an error saying baggage isn't supported similar to

ENVOY_LOG(error, "RateLimitingSampler is not supported.");

Copy link
Member

Choose a reason for hiding this comment

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

A warning isn't safe in the data path. I would either do nothing and leave a TODO or have a stat for dropped baggage. Same elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left comments for the spans that don't support baggage (opencensus, xray) and a TODO for zipkin

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I will defer to @LisaLudique for initial review.

/wait

Comment on lines 197 to 199
void Span::setBaggage(const std::string&, const std::string&) {}

std::string Span::getBaggage(const std::string&) { return std::string(); }
Copy link
Member

Choose a reason for hiding this comment

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

A warning isn't safe in the data path. I would either do nothing and leave a TODO or have a stat for dropped baggage. Same elsewhere.

Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
@matthewgrossman matthewgrossman changed the title WIP Add opentracing baggage methods tracing: add baggage methods to Tracing::Span Jul 30, 2020
@matthewgrossman matthewgrossman marked this pull request as ready for review July 30, 2020 02:46
@matthewgrossman
Copy link
Contributor Author

tuned up the PR with tests/comments/todos, tried to get the description to match the template as well. Might be worth reading that again since it's likely changed since last review.

Do we need to express anywhere else that not all implementations of Tracing::Span currently support the baggage methods? Maybe that's what would be valuable somewhere in some documentation

@LisaLudique
Copy link
Contributor

tests look good!

I would suggest adding a section on baggage and delineating the level of support for each tracer in https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing

Signed-off-by: Matthew Grossman <[email protected]>
Signed-off-by: Matthew Grossman <[email protected]>
LisaLudique
LisaLudique previously approved these changes Aug 10, 2020
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM with small comment. Thank you!

/wait

Comment on lines 199 to 201
void Span::setBaggage(absl::string_view, absl::string_view) {}

std::string Span::getBaggage(absl::string_view) { return std::string(); }
Copy link
Member

Choose a reason for hiding this comment

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

nit: just inline this above.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@matthewgrossman
Copy link
Contributor Author

thanks for the help in review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants