Skip to content

Add local baggage and tagged baggage #33991

Open
Listed in
Open
@marcingrzejszczak

Description

@marcingrzejszczak

If we look at Sleuth & Boot tracing Baggage features comparison we're still missing two.

  • Local Baggage - local baggage means baggage available within this JVM but one that does not get propagated over the wire
  • Tagged Baggage - tagged baggage means baggage that automatically gets added as a tag

Local Baggage Sleuth implementation

Tagged Baggage Sleuth implementation

Activity

changed the title [-][Observability] Add local baggage and tagged baggage[/-] [+]Add local baggage and tagged baggage[/+] on Jan 26, 2023
added this to the 3.1.x milestone on Jan 26, 2023
modified the milestones: 3.1.x, 3.x on Apr 17, 2023
carlosalm-msft

carlosalm-msft commented on May 5, 2023

@carlosalm-msft

hi folks, do you have any ETA on this? Thanks!

wilkinsona

wilkinsona commented on May 5, 2023

@wilkinsona
Member

Nothing specific, no. The issue is in the 3.x milestone which means there's no definite plan for it at the moment.

michael-wirth

michael-wirth commented on Jul 10, 2023

@michael-wirth

Here's a little workaround for Spring Boot 3.1.x

OpenTelementry and Brave implementation behave differently.

Brave

requires the local baggage to be registered:

    @Bean
    internal fun localBaggagePropagationCustomizer() =
        brave.baggage.BaggagePropagationCustomizer { customizer ->
           customizer.add(SingleBaggageField.local(BaggageField.create("localBaggage")))
        }

Set the local baggage in a WebFilter:

    override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> =
        chain.filter(exchange)
                        .doOnSubscribe { tracer.createBaggageInScope(localBaggage, "value") }

OpenTelementry

doesn't require registering local baggage properties, but setting the baggage is more complicated:

  • it is possible to set only 1 baggage. calling createBaggageInScope will cancel all previous baggages
  • a new observation must be started with Micrometer.observation
    override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
        tracer.createBaggageInScope("localBaggage", "value")  // the value can also be set via "contextWrite", but not via "doOnSubscribe"
        return chain.filter(exchange)
            .tap(reactor.core.observability.micrometer.Micrometer.observation(registry))
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @scottfrederick@wilkinsona@marcingrzejszczak@michael-wirth@spring-projects-issues

        Issue actions

          Add local baggage and tagged baggage · Issue #33991 · spring-projects/spring-boot