Skip to content

Commit

Permalink
Merge branch 'main' into add-http-url-to-excon-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
arielvalentin authored Jun 18, 2024
2 parents aa59f0c + e70ed65 commit f0d8953
Show file tree
Hide file tree
Showing 31 changed files with 171 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/actions/test_gem/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ runs:
# ...but not for appraisals, sadly.
- name: Install Ruby ${{ inputs.ruby }} with dependencies
if: "${{ steps.setup.outputs.appraisals == 'false' }}"
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: "${{ inputs.ruby }}"
working-directory: "${{ steps.setup.outputs.gem_dir }}"
Expand All @@ -77,7 +77,7 @@ runs:
# If we're using appraisals, do it all manually.
- name: Install Ruby ${{ inputs.ruby }} without dependencies
if: "${{ steps.setup.outputs.appraisals == 'true' }}"
uses: ruby/setup-ruby@v1.176.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: "${{ inputs.ruby }}"
bundler: "latest"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/installation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4
# ATTENTION: Dependabot does not know how to update shared actions file.
# If you see it update setup-ruby here also update it as part of actions/test_gem/action.yml
- uses: ruby/setup-ruby@v1.178.0
- uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ matrix.ruby-version }}
- name: "Install Latest Gem Versions on ${{ matrix.ruby-version }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-hook-on-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Ruby ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-hook-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Ruby ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-perform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Ruby ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Process Release
runs-on: ubuntu-latest
steps:
- uses: googleapis/[email protected].1
- uses: googleapis/[email protected].3
id: prepare

outputs:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
- uses: ruby/setup-ruby@v1.178.0
- uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: "3.0"
bundler: latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-request-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Ruby ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Ruby ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-retry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Ruby ${{ env.ruby_version }}
uses: ruby/setup-ruby@v1.178.0
uses: ruby/setup-ruby@v1.180.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ services:
command: ./start_server.sh
working_dir: /app/instrumentation/sinatra/example

processor-baggage-test:
<<: *base
working_dir: /app/processor/baggage
command: |
bash -c "bundle install && rake"
mongo:
image: mongo:4.4
expose:
Expand Down
2 changes: 1 addition & 1 deletion helpers/mysql/opentelemetry-helpers-mysql.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20'
spec.add_dependency 'opentelemetry-common', '~> 0.21'

spec.add_development_dependency 'bundler', '~> 2.4'
spec.add_development_dependency 'minitest', '~> 5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-common', '~> 0.20'
spec.add_dependency 'opentelemetry-common', '~> 0.21'

spec.add_development_dependency 'bundler', '~> 2.4'
spec.add_development_dependency 'minitest', '~> 5.0'
Expand Down
12 changes: 12 additions & 0 deletions instrumentation/base/lib/opentelemetry/instrumentation/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@ def enabled_by_env_var?
ENV[var_name] != 'false'
end

# Checks to see if the user has passed any environment variables that set options
# for instrumentation. By convention, the environment variable will be the name
# of the instrumentation, uppercased, with '::' replaced by underscores,
# OPENTELEMETRY shortened to OTEL_{LANG}, and _CONFIG_OPTS appended.
# For example, the environment variable name for OpenTelemetry::Instrumentation::Faraday
# will be OTEL_RUBY_INSTRUMENTATION_FARADAY_CONFIG_OPTS. A value of 'peer_service=new_service;'
# will override the options set from ::OpenTelemetry::SDK.configure do |c| ... end for Faraday.
#
# For an array option, simply separate the values with commas (e.g., option=a,b,c,d).
# For a boolean option, set the value to true or false (e.g., option=true).
# For integer, string, enum, set the value as a string (e.g., option=string).
# Callable options are not allowed to be set through environment variables.
def config_overrides_from_env
var_name = name.dup.tap do |n|
n.upcase!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21'
spec.add_dependency 'opentelemetry-registry', '~> 0.1'

spec.add_development_dependency 'bundler', '~> 2.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
1 change: 1 addition & 0 deletions instrumentation/grape/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ gemspec
group :test do
gem 'opentelemetry-instrumentation-base', path: '../base'
gem 'opentelemetry-instrumentation-rack', path: '../rack'
gem 'builder'
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'bundler', '~> 2.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'activejob', '>= 6.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'
spec.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.21'

Expand Down
32 changes: 28 additions & 4 deletions processor/baggage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.

Keys and values added to Baggage will appear on all subsequent child spans for a trace within this service *and* will be propagated to external services via propagation headers.
Keys and values added to Baggage will appear on all subsequent child spans, not the current active span, for a trace within this service *and* will be propagated to external services via propagation headers.
If the external services also have a Baggage span processor, the keys and values will appear in those child spans as well.

⚠️ Waning ⚠️
Expand Down Expand Up @@ -31,7 +31,7 @@ To install the instrumentation, add the gem to your Gemfile:
gem 'opentelemetry-processor-baggage'
```

Then add the processor to an SDK's configuration:
Then configure the span processor to copy all baggage entries:

```ruby
require 'rubygems'
Expand All @@ -40,8 +40,11 @@ require 'bundler/setup'
Bundler.require

OpenTelemetry::SDK.configure do |c|
# Add the BaggageSpanProcessor to the collection of span processors
c.add_span_processor(OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new)
# Add the BaggageSpanProcessor to the collection of span processors and
# copy all baggage entries
c.add_span_processor(OpenTelemetry::Processor::Baggage::BaggageSpanProcessor.new(
OpenTelemetry::Processor::Baggage::ALLOW_ALL_BAGGAGE_KEYS
))

# Because the span processor list is no longer empty, the SDK will not use the
# values in OTEL_TRACES_EXPORTER to instantiate exporters.
Expand All @@ -57,6 +60,27 @@ OpenTelemetry::SDK.configure do |c|
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 `myapp.`:

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

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) { OUR_BAGGAGE_KEY_MATCHER.match?(baggage_key) }
)
```

## How can I get involved?

The `opentelemetry-processor-baggage` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
Expand Down
Loading

0 comments on commit f0d8953

Please sign in to comment.