Skip to content

Commit

Permalink
Merge branch 'main' into pg-prepend-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle authored Mar 12, 2024
2 parents 031fdca + 3d8fe6d commit ca71e53
Show file tree
Hide file tree
Showing 40 changed files with 302 additions and 103 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.172.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.172.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.172.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.172.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.172.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.172.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.172.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
4 changes: 4 additions & 0 deletions instrumentation/faraday/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-faraday

### 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,11 +25,13 @@ 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)

Expand All @@ -39,21 +41,23 @@ def call(env)

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
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.0'
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module Tracers
# GraphQLTracer contains the OpenTelemetry tracer implementation compatible with
# the GraphQL tracer API
class GraphQLTracer < ::GraphQL::Tracing::PlatformTracing
DEFAULT_HASH = {}.freeze

self.platform_keys = {
'lex' => 'graphql.lex',
'parse' => 'graphql.parse',
Expand Down Expand Up @@ -86,24 +88,60 @@ def config
end

def attributes_for(key, data)
attributes = {}
case key
when 'execute_field', 'execute_field_lazy'
attributes['graphql.field.parent'] = data[:owner]&.graphql_name # owner is the concrete type, not interface
attributes['graphql.field.name'] = data[:field]&.graphql_name
attributes['graphql.lazy'] = key == 'execute_field_lazy'
when 'authorized', 'authorized_lazy'
attributes['graphql.type.name'] = data[:type]&.graphql_name
attributes['graphql.lazy'] = key == 'authorized_lazy'
when 'resolve_type', 'resolve_type_lazy'
attributes['graphql.type.name'] = data[:type]&.graphql_name
attributes['graphql.lazy'] = key == 'resolve_type_lazy'
when 'execute_field'
field_attr_cache = data[:query].context.namespace(:otel_attrs)[:execute_field_attrs] ||= attr_cache do |field|
attrs = {}
attrs['graphql.field.parent'] = field.owner.graphql_name if field.owner.graphql_name
attrs['graphql.field.name'] = field.graphql_name if field.graphql_name
attrs['graphql.lazy'] = false
attrs.freeze
end
field_attr_cache[data[:field]]
when 'execute_field_lazy'
lazy_field_attr_cache = data[:query].context.namespace(:otel_attrs)[:execute_field_lazy_attrs] ||= attr_cache do |field|
attrs = {}
attrs['graphql.field.parent'] = field.owner.graphql_name if field.owner.graphql_name
attrs['graphql.field.name'] = field.graphql_name if field.graphql_name
attrs['graphql.lazy'] = true
attrs.freeze
end
lazy_field_attr_cache[data[:field]]
when 'authorized', 'resolve_type'
type_attrs_cache = data[:context].namespace(:otel_attrs)[:type_attrs] ||= attr_cache do |type|
attrs = {}
attrs['graphql.type.name'] = type.graphql_name if type.graphql_name
attrs['graphql.lazy'] = false
attrs.freeze
end
type_attrs_cache[data[:type]]
when 'authorized_lazy', 'resolve_type_lazy'
type_lazy_attrs_cache = data[:context].namespace(:otel_attrs)[:type_lazy_attrs] ||= attr_cache do |type|
attrs = {}
attrs['graphql.type.name'] = type.graphql_name if type.graphql_name
attrs['graphql.lazy'] = true
attrs.freeze
end
type_lazy_attrs_cache[data[:type]]
when 'execute_query'
attributes['graphql.operation.name'] = data[:query].selected_operation_name if data[:query].selected_operation_name
attributes['graphql.operation.type'] = data[:query].selected_operation.operation_type
attributes['graphql.document'] = data[:query].query_string
attrs = {}
attrs['graphql.document'] = data[:query].query_string if data[:query].query_string
# rubocop:disable Style/SafeNavigation - using safe navigation creates more objects, we want to avoid this
attrs['graphql.operation.type'] = data[:query].selected_operation.operation_type if data[:query].selected_operation && data[:query].selected_operation.operation_type
# rubocop:enable Style/SafeNavigation
attrs['graphql.operation.name'] = data[:query].selected_operation_name || 'anonymous'
attrs.freeze
else
DEFAULT_HASH
end
end

def attr_cache
cache_h = Hash.new do |h, k|
h[k] = yield(k)
end
attributes
cache_h.compare_by_identity
cache_h
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 GraphQL
VERSION = '0.27.0'
VERSION = '0.28.0'
end
end
end
Loading

0 comments on commit ca71e53

Please sign in to comment.