Skip to content

Commit

Permalink
Merge branch 'strip-rails-format-suffix' of github.com:akahn/opentele…
Browse files Browse the repository at this point in the history
…metry-ruby-contrib into strip-rails-format-suffix

* 'strip-rails-format-suffix' of github.com:akahn/opentelemetry-ruby-contrib:
  feat: AWS lambda programatic wrap (open-telemetry#1308)
  chore: bump ruby/setup-ruby from 1.213.0 to 1.214.0 (open-telemetry#1371)
  test: Fix simplecov configuration (open-telemetry#1366)
  chore: Strip Rails (.:format) suffix from http.route
  • Loading branch information
akahn committed Jan 29, 2025
2 parents cd9fe4b + d86d71d commit e081529
Show file tree
Hide file tree
Showing 78 changed files with 418 additions and 182 deletions.
22 changes: 20 additions & 2 deletions .github/actions/test_gem/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ inputs:
required: false
type: boolean
default: false
coverage:
description: Enforce test coverage
required: false
type: boolean
default: false
minimum_coverage:
description: Minimum test coverage
required: false
type: string
default: 85
build:
description: Build gem
required: false
Expand Down Expand Up @@ -74,7 +84,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.213.0
uses: ruby/setup-ruby@v1.214.0
with:
ruby-version: "${{ inputs.ruby }}"
working-directory: "${{ steps.setup.outputs.gem_dir }}"
Expand All @@ -85,7 +95,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.213.0
uses: ruby/setup-ruby@v1.214.0
with:
ruby-version: "${{ inputs.ruby }}"
bundler: "latest"
Expand Down Expand Up @@ -161,6 +171,14 @@ runs:
bundle exec rake rubocop
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Coverage
shell: bash
if: "${{ inputs.coverage == 'true' }}"
# This starts a new simplecov run which tracks nothing of its own,
# but merges with the existing coverage reports generated during testing.
run: 'bundle exec ruby -e ''require "simplecov"; SimpleCov.minimum_coverage(${{ inputs.minimum_coverage }})'''
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Build Gem
shell: bash
if: "${{ inputs.build == 'true' }}"
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/ci-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
if: "${{ matrix.os == 'ubuntu-latest' }}"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-helpers-${{ matrix.gem }}"
ruby: "jruby-9.4.9.0"
ruby: "jruby-9.4.10.0"

propagators:
strategy:
Expand Down Expand Up @@ -92,7 +93,7 @@ jobs:
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-propagator-${{ matrix.gem }}"
ruby: "jruby-9.4.9.0"
ruby: "jruby-9.4.10.0"

resource-detectors:
strategy:
Expand Down Expand Up @@ -125,13 +126,14 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
if: "${{ matrix.os == 'ubuntu-latest' }}"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-${{ matrix.gem }}"
ruby: "jruby-9.4.9.0"
ruby: "jruby-9.4.10.0"

processors:
strategy:
Expand Down Expand Up @@ -162,10 +164,11 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
if: "${{ matrix.os == 'ubuntu-latest' && steps.jruby_skip.outputs.skip == 'false' }}"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-processor-${{ matrix.gem }}"
ruby: "jruby-9.4.9.0"
ruby: "jruby-9.4.10.0"
8 changes: 7 additions & 1 deletion .github/workflows/ci-instrumentation-with-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
ruby: "jruby-9.4.9.0"
ruby: "jruby-9.4.10.0"
services:
memcached:
image: memcached:alpine
Expand Down Expand Up @@ -92,6 +93,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
mysql:
Expand Down Expand Up @@ -129,6 +131,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
zookeeper:
Expand Down Expand Up @@ -182,6 +185,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
redis:
Expand Down Expand Up @@ -226,6 +230,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
postgres:
Expand Down Expand Up @@ -267,6 +272,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
rabbitmq:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-instrumentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ jobs:
- name: "Test Ruby 3.1"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "JRuby Filter"
id: jruby_skip
Expand Down Expand Up @@ -108,4 +109,4 @@ jobs:
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
ruby: "jruby-9.4.9.0"
ruby: "jruby-9.4.10.0"
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.213.0
- uses: ruby/setup-ruby@v1.214.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.213.0
uses: ruby/setup-ruby@v1.214.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.213.0
uses: ruby/setup-ruby@v1.214.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.213.0
uses: ruby/setup-ruby@v1.214.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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.213.0
- uses: ruby/setup-ruby@v1.214.0
with:
ruby-version: "3.1"
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.213.0
uses: ruby/setup-ruby@v1.214.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.213.0
uses: ruby/setup-ruby@v1.214.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.213.0
uses: ruby/setup-ruby@v1.214.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
14 changes: 14 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'digest'

digest = Digest::MD5.new
digest.update('test')
digest.update(ENV.fetch('BUNDLE_GEMFILE', 'gemfile')) if ENV['APPRAISAL_INITIALIZED']

ENV['ENABLE_COVERAGE'] ||= '1'

if ENV['ENABLE_COVERAGE'].to_i.positive?
SimpleCov.command_name(digest.hexdigest)
SimpleCov.start do
add_filter %r{^/test/}
end
end
1 change: 1 addition & 0 deletions helpers/mysql/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.71.0'
spec.add_development_dependency 'rubocop-performance', '~> 1.23.0'
spec.add_development_dependency 'simplecov', '~> 0.22.0'
spec.add_development_dependency 'yard', '~> 0.9'
spec.add_development_dependency 'yard-doctest', '~> 0.1.6'

Expand Down
1 change: 1 addition & 0 deletions helpers/sql-obfuscation/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_mailer/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_pack/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_view/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_job/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: Apache-2.0
ENV['OTEL_LOG_LEVEL'] ||= 'fatal'

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_record/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_support/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/all/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
26 changes: 26 additions & 0 deletions instrumentation/aws_lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ def otel_wrapper(event:, context:)
end
```

### Alternative Usage

If using a Lambda Layer is not an option for your given setup, you can programmatically instrument a handler by using the `OpenTelemetry::Instrumentation::AwsLambda::Wrap` module.

```ruby
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/aws_lambda'

OpenTelemetry::SDK.configure do |c|
c.service_name = '<YOUR_SERVICE_NAME>'
c.use 'OpenTelemetry::Instrumentation::AwsLambda'
end

# Lambda Handler
module Example
class Handler
extend OpenTelemetry::Instrumentation::AwsLambda::Wrap

def self.process(event:, context:)
puts event.inspect
end
instrument_handler :process
end
end
```

## Example

To run the example:
Expand Down
Loading

0 comments on commit e081529

Please sign in to comment.