Skip to content

Commit

Permalink
Merge branch 'main' into fix-dalli-gat
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlaurin authored Jan 9, 2025
2 parents 8002aef + 8bf09af commit 516c844
Show file tree
Hide file tree
Showing 50 changed files with 347 additions and 337 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/installation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
fail-fast: false
matrix:
ruby-version:
- 3.4
- 3.3
- 3.2
- 3.1
- 3.0
name: ${{ matrix.ruby-version }}
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/active_model_serializers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-active_model_serializers

### v0.21.1 / 2025-01-07

* DOCS: Update action for link check and fix one broken link

### v0.21.0 / 2024-12-19

* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module ActiveModelSerializers
VERSION = '0.21.0'
VERSION = '0.21.1'
end
end
end
4 changes: 4 additions & 0 deletions instrumentation/all/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-all

### v0.71.0 / 2025-01-07

* ADDED: Faraday Minimum v1.0

### v0.70.0 / 2024-12-19

* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0
Expand Down
3 changes: 2 additions & 1 deletion instrumentation/all/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ group :test do
.sort
.each { |dir| gem "opentelemetry-helpers-#{dir}", path: "../../helpers/#{dir}" }

excluded_instrumentations = %w[. .. all grpc]
Dir.entries('../')
.select { |entry| File.directory?(File.join('../', entry)) }
.reject { |entry| %w[. .. all].include?(entry) } # rubocop:disable Performance/CollectionLiteralInLoop
.reject { |entry| excluded_instrumentations.include?(entry) }
.sort
.each { |dir| gem "opentelemetry-instrumentation-#{dir}", path: "../#{dir}" }
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module All
VERSION = '0.70.0'
VERSION = '0.71.0'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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.24.0'
spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.25.0'
spec.add_dependency 'opentelemetry-instrumentation-grape', '~> 0.2.0'
spec.add_dependency 'opentelemetry-instrumentation-graphql', '~> 0.28.0'
spec.add_dependency 'opentelemetry-instrumentation-gruf', '~> 0.2.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.25.0 / 2025-01-07

* ADDED: Faraday Minimum v1.0

### v0.24.8 / 2024-12-17

* FIXED: Share Faraday Attrs with Adapter Spans
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.24.8'
VERSION = '0.25.0'
end
end
end
3 changes: 0 additions & 3 deletions instrumentation/grpc/.rspec

This file was deleted.

13 changes: 13 additions & 0 deletions instrumentation/grpc/Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

appraise 'grpc-1.68' do
gem 'grpc', '~> 1.68.0'
end

appraise 'grpc-latest' do
gem 'grpc'
end
10 changes: 4 additions & 6 deletions instrumentation/grpc/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ source "https://rubygems.org"
# Specify your gem's dependencies in opentelemetry-instrumentation-grpc.gemspec
gemspec

gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "standard", "~> 1.3"
gem "opentelemetry-sdk", "~> 1.0"
gem "opentelemetry-test-helpers"
gem "grpc"
group :test do
gem 'opentelemetry-instrumentation-base', path: '../base'
gem 'pry'
end
13 changes: 4 additions & 9 deletions instrumentation/grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ instrumentation.
end
```

You *also* need to make sure your stubs are using the interceptor, e.g.

```ruby
otel = OpenTelemetry::Instrumentation::Grpc.client_interceptor
SomeService::Stub.new(host, credentials, *args, **kwargs, interceptors: [otel])
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Integration tests rely on a real gRPC server that is started by relevant tests. The proto definition is located in `test/support/proto/ping.proto`. Making changes to the proto definition requires re-creating gRPC-generated code. To do this, run the following command:

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
```sh
bundle exec grpc_tools_ruby_protoc --ruby_out=. --grpc_out=. test/support/proto/ping.proto
```

## Contributing

Expand Down
24 changes: 19 additions & 5 deletions instrumentation/grpc/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
#
# SPDX-License-Identifier: Apache-2.0

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'yard'
require 'rubocop/rake_task'

RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new

require "standard/rake"
Rake::TestTask.new :test do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end

task default: %i[spec standard]
YARD::Rake::YardocTask.new do |t|
t.stats_options = ['--list-undoc']
end

if RUBY_ENGINE == 'truffleruby'
task default: %i[test]
else
task default: %i[test rubocop yard]
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@

require "opentelemetry"
require "opentelemetry-instrumentation-base"
require "active_support/inflector"

module OpenTelemetry
module Instrumentation
# Contains the OpenTelemetry instrumentation for the gRPC gem
module Grpc
class Error < StandardError; end

module_function

def client_interceptor
Interceptors::Client.new
end
end
end
end

require_relative "grpc/instrumentation"
require_relative "grpc/interceptors/client"
require_relative "grpc/version"
require_relative 'grpc/interceptors/client_tracer'
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
private

def patch
::GRPC::ClientInterceptor.prepend(Interceptors::Client)
::GRPC::ClientStub.prepend(Patches::ClientStub)
end

def require_dependencies
require_relative "interceptors/client"
require_relative 'interceptors/client_tracer'
require_relative 'patches/client_stub'
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module OpenTelemetry
module Instrumentation
module Grpc
module Interceptors
class Client
# ClientTracer is a gRPC client interceptor which instrument gRPC calls with OpenTelemetry tracing
class ClientTracer < ::GRPC::ClientInterceptor
def request_response(request: nil, call: nil, method: nil, metadata: nil, &blk)
call(type: "request_response", requests: [request], call: call, method: method, metadata: metadata, &blk)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
module Instrumentation
module Grpc
module Patches
# Module to be prepended to force gRPC to use the client interceptor by
# default so the user doesn't have to manually add it when initializing a client.
module ClientStub
def initialize(host, creds, **args)
interceptors = args[:interceptors] || []
interceptors.unshift(Interceptors::ClientTracer.new) unless interceptors.any? do |interceptor|
interceptor.is_a?(Interceptors::ClientTracer)
end
args[:interceptors] = interceptors

super
end
end
end
end
end
end
18 changes: 15 additions & 3 deletions instrumentation/grpc/opentelemetry-instrumentation-grpc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

# Uncomment to register a new dependency of your gem
spec.add_dependency "opentelemetry-instrumentation-base", "~> 0.22.4"
spec.add_dependency "opentelemetry-api", "~> 1.2"
spec.add_runtime_dependency "activesupport", ">= 4"
spec.add_dependency 'opentelemetry-api', '~> 1.2'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.4'

spec.add_development_dependency 'appraisal', '~> 2.5'
spec.add_development_dependency 'bundler', '~> 2.4'
spec.add_development_dependency 'google-protobuf', '~> 4.29'
spec.add_development_dependency 'grpc-tools', '~> 1.64'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1'
spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.4'
spec.add_development_dependency 'rake', '~> 13.2'
spec.add_development_dependency 'rubocop', '~> 1.69.1'
spec.add_development_dependency 'rubocop-performance', '~> 1.23.0'
spec.add_development_dependency 'simplecov', '~> 0.17.1'
spec.add_development_dependency 'yard', '~> 0.9'

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
Expand Down
14 changes: 0 additions & 14 deletions instrumentation/grpc/spec/example/Gemfile

This file was deleted.

13 changes: 0 additions & 13 deletions instrumentation/grpc/spec/example/base.rb

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions instrumentation/grpc/spec/example/proto/example_api.proto

This file was deleted.

25 changes: 0 additions & 25 deletions instrumentation/grpc/spec/example/proto/example_api_pb.rb

This file was deleted.

25 changes: 0 additions & 25 deletions instrumentation/grpc/spec/example/proto/example_api_services_pb.rb

This file was deleted.

Loading

0 comments on commit 516c844

Please sign in to comment.