Skip to content

How to add an attribute to all spans in a trace? #1272

Answered by fbogsany
kroehre asked this question in Q&A
Discussion options

You must be logged in to vote

Baggage does not automatically add attributes to spans in a trace. It can propagate "correlation context" but that's not its only use.

Typically, the easiest ways to add attributes to all spans are using a SpanProcessor, which receives on_start and on_finish callbacks:

# Called when a {Span} is started, if the {Span#recording?}
# returns true.
#
# This method is called synchronously on the execution thread, should
# not throw or block the execution thread.
#
# @param [Span] span the {Span} that just started.
# @param [Context] parent_context the par…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kroehre
Comment options

@robbkidd
Comment options

@robbkidd
Comment options

Answer selected by kroehre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants