|
| 1 | +# Baggage Span Processor |
| 2 | + |
| 3 | +This is an OpenTelemetry [span processor](https://opentelemetry.io/docs/specs/otel/trace/sdk/#span-processor) that reads key/values stored in [Baggage](https://opentelemetry.io/docs/specs/otel/baggage/api/) in the starting span's parent context and adds them as attributes to the span. |
| 4 | + |
| 5 | +## How do I get started? |
| 6 | + |
| 7 | +Install the gem using: |
| 8 | + |
| 9 | +```shell |
| 10 | +gem install opentelemetry-processor-baggage |
| 11 | +``` |
| 12 | + |
| 13 | +Or, if you use [bundler][bundler-home], include `opentelemetry-processor-baggage` to your `Gemfile`. |
| 14 | + |
| 15 | +### Version Compatibility |
| 16 | + |
| 17 | +* OpenTelemetry API v1.0+ |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +To install the instrumentation, add the gem to your Gemfile: |
| 22 | + |
| 23 | +```ruby |
| 24 | +gem 'opentelemetry-processor-baggage' |
| 25 | +``` |
| 26 | + |
| 27 | +Then add the processor to an SDK's configuration: |
| 28 | + |
| 29 | +```ruby |
| 30 | +require 'rubygems' |
| 31 | +require 'bundler/setup' |
| 32 | + |
| 33 | +Bundler.require |
| 34 | + |
| 35 | +OpenTelemetry::SDK.configure do |c| |
| 36 | + # Add the BaggageSpanProcessor to the collection of span processors |
| 37 | + c.add_span_processor(OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new) |
| 38 | + |
| 39 | + # Because the span processor list is no longer empty, the SDK will not use the |
| 40 | + # values in OTEL_TRACES_EXPORTER to instantiate exporters. |
| 41 | + # You'll need to declare your own here in the configure block. |
| 42 | + # |
| 43 | + # These lines setup the default: a batching OTLP exporter. |
| 44 | + c.add_span_processor( |
| 45 | + # these constructors without arguments will pull config from the environment |
| 46 | + OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new( |
| 47 | + OpenTelemetry::Exporter::OTLP::Exporter.new() |
| 48 | + ) |
| 49 | + ) |
| 50 | +end |
| 51 | +``` |
| 52 | + |
| 53 | +## How can I get involved? |
| 54 | + |
| 55 | +The `opentelemetry-processor-baggage` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. |
| 56 | + |
| 57 | +The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. |
| 58 | + |
| 59 | +## License |
| 60 | + |
| 61 | +The `opentelemetry-instrumentation-sinatra` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. |
| 62 | + |
| 63 | +[bundler-home]: https://bundler.io |
| 64 | +[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib |
| 65 | +[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE |
| 66 | +[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig |
| 67 | +[community-meetings]: https://github.com/open-telemetry/community#community-meetings |
| 68 | +[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions |
0 commit comments