Skip to content

Commit

Permalink
Merge branch 'main' into update-helpers-codeowners
Browse files Browse the repository at this point in the history
  • Loading branch information
arielvalentin authored Mar 24, 2024
2 parents 23e0d8b + c00bf91 commit aa991d9
Show file tree
Hide file tree
Showing 40 changed files with 334 additions and 107 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci-instrumentation-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: "Test Ruby 3.3"
# BLOCKED BY: https://github.com/bigcommerce/gruf/pull/197
if: "${{ matrix.gem != 'gruf' }}"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci-instrumentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: "Test Ruby 3.3"
# BLOCKED BY: https://github.com/bigcommerce/gruf/pull/197
if: "${{ matrix.gem != 'gruf' }}"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
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 @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1.171.0
- uses: ruby/setup-ruby@v1.173.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.171.0
uses: ruby/setup-ruby@v1.173.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.171.0
uses: ruby/setup-ruby@v1.173.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.171.0
uses: ruby/setup-ruby@v1.173.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 @@ -47,7 +47,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.171.0
- uses: ruby/setup-ruby@v1.173.0
with:
ruby-version: "3.0"
bundler: latest
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.171.0
uses: ruby/setup-ruby@v1.173.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.171.0
uses: ruby/setup-ruby@v1.173.0
with:
ruby-version: ${{ env.ruby_version }}
- name: Checkout repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
stale-pr-label: "stale"
exempt-pr-labels: "keep"
days-before-pr-stale: 30
days-before-pr-close: 15
days-before-pr-close: 30
4 changes: 2 additions & 2 deletions helpers/mysql/opentelemetry-helpers-mysql.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.57.2'
spec.add_development_dependency 'rubocop-performance', '~> 1.19.1'
spec.add_development_dependency 'rubocop', '~> 1.60.2'
spec.add_development_dependency 'rubocop-performance', '~> 1.20.1'
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.57.2'
spec.add_development_dependency 'rubocop-performance', '~> 1.19.1'
spec.add_development_dependency 'rubocop', '~> 1.60.2'
spec.add_development_dependency 'rubocop-performance', '~> 1.20.1'
spec.add_development_dependency 'yard', '~> 0.9'
spec.add_development_dependency 'yard-doctest', '~> 0.1.6'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def self.load_fixture
acceptable_outputs << FAILED_TO_OBFUSCATE_MESSAGE if test_case['malformed']

dialects.each do |dialect|
define_method("test_sql_obfuscation_#{name}_#{dialect}") do
define_method(:"test_sql_obfuscation_#{name}_#{dialect}") do
actual_obfuscated = OpenTelemetry::Helpers::SqlObfuscation.obfuscate_sql(query, adapter: dialect.to_sym)
message = build_failure_message(query, dialect, acceptable_outputs, actual_obfuscated)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ def patch
end

def require_dependencies
# Our patches depend on Ruby 2 Keyword Syntax compatability since it is decorating the existing AR API
# Once we migrate to ActiveSupport Notifications based instrumentation we can remove this require statement.
require 'ruby2_keywords' # rubocop:disable Lint/RedundantRequireStatement
require_relative 'patches/querying'
require_relative 'patches/persistence'
require_relative 'patches/persistence_class_methods'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Gem::Specification.new do |spec|

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

spec.add_development_dependency 'activerecord', '>= 6.1'
spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
13 changes: 13 additions & 0 deletions instrumentation/all/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Release History: opentelemetry-instrumentation-all

### v0.60.0 / 2024-02-20

* ADDED: Add support gruf 2.19
* ADDED: Faraday add support for internal spans

### v0.59.0 / 2024-02-16

* BREAKING CHANGE: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).

### v0.58.0 / 2024-02-15

* CHANGED: upgrade mysql2 instrumentation

### v0.57.0 / 2024-02-08

* BREAKING CHANGE: Move shared sql behavior to helper gems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module All
VERSION = '0.57.0'
VERSION = '0.60.0'
end
end
end
8 changes: 4 additions & 4 deletions instrumentation/all/opentelemetry-instrumentation-all.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ Gem::Specification.new do |spec|
spec.add_dependency 'opentelemetry-instrumentation-delayed_job', '~> 0.22.0'
spec.add_dependency 'opentelemetry-instrumentation-ethon', '~> 0.21.1'
spec.add_dependency 'opentelemetry-instrumentation-excon', '~> 0.22.0'
spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.23.1'
spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.24.0'
spec.add_dependency 'opentelemetry-instrumentation-grape', '~> 0.1.3'
spec.add_dependency 'opentelemetry-instrumentation-graphql', '~> 0.27.0'
spec.add_dependency 'opentelemetry-instrumentation-gruf', '~> 0.1.0'
spec.add_dependency 'opentelemetry-instrumentation-graphql', '~> 0.28.0'
spec.add_dependency 'opentelemetry-instrumentation-gruf', '~> 0.2.0'
spec.add_dependency 'opentelemetry-instrumentation-http', '~> 0.23.1'
spec.add_dependency 'opentelemetry-instrumentation-http_client', '~> 0.22.1'
spec.add_dependency 'opentelemetry-instrumentation-koala', '~> 0.20.1'
spec.add_dependency 'opentelemetry-instrumentation-lmdb', '~> 0.22.1'
spec.add_dependency 'opentelemetry-instrumentation-mongo', '~> 0.22.1'
spec.add_dependency 'opentelemetry-instrumentation-mysql2', '~> 0.26.0'
spec.add_dependency 'opentelemetry-instrumentation-mysql2', '~> 0.27.0'
spec.add_dependency 'opentelemetry-instrumentation-net_http', '~> 0.22.1'
spec.add_dependency 'opentelemetry-instrumentation-pg', '~> 0.27.0'
spec.add_dependency 'opentelemetry-instrumentation-que', '~> 0.8.0'
Expand Down
8 changes: 8 additions & 0 deletions instrumentation/faraday/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release History: opentelemetry-instrumentation-faraday

### v0.24.1 / 2024-03-22

* FIXED: Propagate response attributes on Faraday::Error.

### v0.24.0 / 2024-02-20

* ADDED: Faraday add support for internal spans

### v0.23.4 / 2023-11-23

* CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
defined?(::Faraday)
end

option :span_kind, default: :client, validate: %i[client internal]
option :peer_service, default: nil, validate: :string

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,50 @@ class TracerMiddleware < ::Faraday::Middleware

def call(env)
http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method]
config = Faraday::Instrumentation.instance.config

attributes = span_creation_attributes(
http_method: http_method, url: env.url
http_method: http_method, url: env.url, config: config
)
tracer.in_span(
"HTTP #{http_method}", attributes: attributes, kind: :client
"HTTP #{http_method}", attributes: attributes, kind: config.fetch(:span_kind)
) do |span|
OpenTelemetry.propagation.inject(env.request_headers)

app.call(env).on_complete { |resp| trace_response(span, resp) }
app.call(env).on_complete { |resp| trace_response(span, resp.status) }
rescue ::Faraday::Error => e
trace_response(span, e.response[:status]) if e.response

raise
end
end

private

attr_reader :app

def span_creation_attributes(http_method:, url:)
def span_creation_attributes(http_method:, url:, config:)
instrumentation_attrs = {
'http.method' => http_method,
'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s)
'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s),
'faraday.adapter.name' => app.class.name
}
instrumentation_attrs['net.peer.name'] = url.host if url.host
config = Faraday::Instrumentation.instance.config
instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service]

instrumentation_attrs.merge!(
OpenTelemetry::Common::HTTP::ClientContext.attributes
)
end

# Versions prior to 1.0 do not define an accessor for app
attr_reader :app if Gem::Version.new(Faraday::VERSION) < Gem::Version.new('1.0.0')

def tracer
Faraday::Instrumentation.instance.tracer
end

def trace_response(span, response)
span.set_attribute('http.status_code', response.status)
span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response.status.to_i)
def trace_response(span, status)
span.set_attribute('http.status_code', status)
span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status.to_i)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Faraday
VERSION = '0.23.4'
VERSION = '0.24.1'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,33 @@
_(span.attributes['peer.service']).must_equal 'example:faraday'
end

it 'defaults to span kind client' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install

client.get('/success')

_(span.kind).must_equal :client
end

it 'allows overriding the span kind to internal' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install(span_kind: :internal)

client.get('/success')

_(span.kind).must_equal :internal
end

it 'reports the name of the configured adapter' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install

client.get('/success')

_(span.attributes.fetch('faraday.adapter.name')).must_equal Faraday::Adapter::Test.name
end

it 'prioritizes context attributes over config for peer service name' do
instrumentation.instance_variable_set(:@installed, false)
instrumentation.install(peer_service: 'example:faraday')
Expand Down Expand Up @@ -151,5 +178,25 @@
)
end
end

describe 'when faraday raises an error' do
let(:client) do
Faraday.new do |builder|
builder.response :raise_error
builder.adapter(:test) do |stub|
stub.get('/not_found') { |_| [404, {}, 'NOT FOUND'] }
end
end
end

it 'adds response attributes' do
assert_raises Faraday::Error do
client.get('/not_found')
end

_(span.attributes['http.status_code']).must_equal 404
_(span.status.code).must_equal OpenTelemetry::Trace::Status::ERROR
end
end
end
end
6 changes: 6 additions & 0 deletions instrumentation/graphql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History: opentelemetry-instrumentation-graphql

### v0.28.0 / 2024-02-16

* BREAKING CHANGE: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).

* ADDED: GraphQL Legacy Tracer perf improvements [#867](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/867).

### v0.27.0 / 2023-11-28

* CHANGED: Performance optimization cache attribute hashes [#723](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/723)
Expand Down
Loading

0 comments on commit aa991d9

Please sign in to comment.