Skip to content

Commit

Permalink
update README with new usage
Browse files Browse the repository at this point in the history
  • Loading branch information
robbkidd committed Jun 5, 2024
1 parent d958440 commit f2064fe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions processor/baggage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,22 @@ end

Alternatively, you can provide a custom baggage key predicate to select which baggage keys you want to copy.

For example, to only copy baggage entries that start with `my-key`:
For example, to only copy baggage entries that start with `myapp.`:

```ruby
OUR_BAGGAGE_KEY_PREFIX = 'myapp.'.freeze
OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new(
->(baggage_key) { baggage_key.start_with?('my-key') }
# a constant here improves performance
->(baggage_key) { baggage_key.start_with?(OUR_BAGGAGE_KEY_PREFIX) }
)
```

For example, to only copy baggage entries that match the regex `^key.+`:
For example, to only copy baggage entries that match `myapp.`, `myapp1.` and `myapp42.`:

```ruby
OUR_BAGGAGE_KEY_MATCHER = /\Amyapp\d*\./
OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new(
->(baggage_key) { baggage_key.match?('^key.+') }
->(baggage_key) { OUR_BAGGAGE_KEY_MATCHER.match?(baggage_key) }
)
```

Expand Down

0 comments on commit f2064fe

Please sign in to comment.