Skip to content

Commit

Permalink
Merge branch 'main' into rails-6.0-eol
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylareopelle authored Nov 6, 2023
2 parents 6b53609 + 09f7294 commit f63845d
Show file tree
Hide file tree
Showing 44 changed files with 504 additions and 710 deletions.
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ updates:
directory: "/instrumentation/rails"
schedule:
interval: weekly
- package-ecosystem: bundler
directory: "/resource_detectors"
schedule:
interval: weekly
- package-ecosystem: bundler
directory: "/resources/azure"
schedule:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-contrib-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ jobs:
fail-fast: false
matrix:
gem:
- resource_detectors
- resource-detector-azure
- resource-detector-container
- resource-detector-google_cloud_platform
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
fail-fast: false
matrix:
gem:
- resource_detectors
- resource-detector-azure
- resource-detector-container
- resource-detector-google_cloud_platform
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-instrumentation-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- koala
- lmdb
- net_http
- httpx
- rack
- rails
- restclient
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-instrumentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- gruf
- http
- http_client
- httpx
- koala
- lmdb
- net_http
Expand Down
9 changes: 4 additions & 5 deletions .toys/.data/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ gems:
directory: instrumentation/http_client
version_constant: [OpenTelemetry, Instrumentation, HttpClient, VERSION]

- name: opentelemetry-instrumentation-httpx
directory: instrumentation/httpx
version_constant: [OpenTelemetry, Instrumentation, HTTPX, VERSION]

- name: opentelemetry-instrumentation-koala
directory: instrumentation/koala
version_constant: [OpenTelemetry, Instrumentation, Koala, VERSION]
Expand Down Expand Up @@ -203,11 +207,6 @@ gems:
directory: propagator/xray
version_constant: [OpenTelemetry, Propagator, XRay, VERSION]

- name: opentelemetry-resource_detectors
directory: resource_detectors
version_rb_path: lib/opentelemetry/resource/detectors/version.rb
version_constant: [OpenTelemetry, Resource, Detectors, VERSION]

- name: opentelemetry-resource-detector-azure
directory: resources/azure
version_rb_path: lib/opentelemetry/resource/detector/azure/version.rb
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ instrumentation/grape/ @muripic @fbogsany @mwear @robertlaurin @dazuma @ericmust

instrumentation/graphql/ @swalkinshaw @rmosolgo @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd

instrumentation/httpx/ @HoneyryderChuck @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd

instrumentation/mongo/ @johnnyshields @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd

instrumentation/racecar/ @chrisholmes @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ _Setting up a running Ruby environment is outside the scope of this document._
This repository contains multiple Ruby gems:

* Various instrumentation gems located in subdirectories of `instrumentation`
* Various resource detector gems located in subdirectories of `resources`
* `opentelemetry-propagator-xray` located in the `propagator/xray` directory
* `opentelemetry-propagator-ottrace` located in the `propagator/ottrace` directory
* `opentelemetry-resource_detectors` located in the `resource_detectors` directory

Each of these gems has its configuration and tests.

For example, to test `opentelemetry-resource_detectors` you would:
For example, to test `opentelemetry-instrumentation-action_pack` you would:

1. Change directory to `resource_detectors`
1. Change directory to `instrumentation/action_pack`
2. Install the bundle with `bundle install`
3. Run the tests with `bundle exec rake`

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ using OpenTelemetry with minimal changes to your application. See the
This repository also contains libraries to aid with interoperablity with vendor specific tracing solutions:

- [Context Propagation](propagator/): OTTrace and Amazon X-Ray
- [Resource Detectors](resource_detectors/):
- [Resource Detectors](resources/):
- Azure
- Container
- Google Cloud Platform
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/active_support/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-active_support

### v0.4.4 / 2023-10-31

* FIXED: Remove call to ActiveSupport::Notifications.notifier#synchronize deprecated in Rails 7.2

### v0.4.3 / 2023-10-16

* FIXED: Add Rails 7.1 compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ def self.subscribe(

subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber)

::ActiveSupport::Notifications.notifier.synchronize do
subscribers = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern]

if subscribers.nil?
OpenTelemetry.handle_error(
message: 'Unable to move OTEL ActiveSupport Notifications subscriber to the front of the notifications list which may cause incomplete traces.' \
'Please report an issue here: ' \
'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/new?labels=bug&template=bug_report.md&title=ActiveSupport%20Notifications%20subscribers%20list%20is%20nil'
)
else
subscribers.unshift(
subscribers.delete(subscriber_object)
)
# this can be removed once we drop support for Rails < 7.2
# see https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/707 for more context
if ::ActiveSupport::Notifications.notifier.respond_to?(:synchronize)
::ActiveSupport::Notifications.notifier.synchronize do
subscribers = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern]

if subscribers.nil?
OpenTelemetry.handle_error(
message: 'Unable to move OTEL ActiveSupport Notifications subscriber to the front of the notifications list which may cause incomplete traces.' \
'Please report an issue here: ' \
'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/new?labels=bug&template=bug_report.md&title=ActiveSupport%20Notifications%20subscribers%20list%20is%20nil'
)
else
subscribers.unshift(
subscribers.delete(subscriber_object)
)
end
end
end
subscriber_object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module ActiveSupport
VERSION = '0.4.3'
VERSION = '0.4.4'
end
end
end
4 changes: 4 additions & 0 deletions instrumentation/grape/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-grape

### v0.1.5 / 2023-10-31

* FIXED: Remove dependency on ActiveSupport core extensions from Grape instrumentation

### v0.1.4 / 2023-08-02

* FIXED: Fix opentelemetry-api version constraint in grape gemspec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module OpenTelemetry
module Instrumentation
module Grape
# Current gem version
VERSION = '0.1.4'
VERSION = '0.1.5'
end
end
end
9 changes: 9 additions & 0 deletions instrumentation/httpx/.yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--no-private
--title=OpenTelemetry HTTPX Instrumentation
--markup=markdown
--main=README.md
./lib/opentelemetry/instrumentation/**/*.rb
./lib/opentelemetry/instrumentation.rb
-
README.md
CHANGELOG.md
13 changes: 13 additions & 0 deletions instrumentation/httpx/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 'httpx-1' do
gem 'httpx', '~> 1.0'
end

appraise 'httpx-0' do
gem 'httpx', '~> 0.24'
end
1 change: 1 addition & 0 deletions instrumentation/httpx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Release History: opentelemetry-instrumentation-httpx
6 changes: 3 additions & 3 deletions resource_detectors/Gemfile → instrumentation/httpx/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source 'https://rubygems.org'

gemspec

group :development, :test do
gem 'byebug' unless RUBY_PLATFORM == 'java'
gem 'pry'
group :test do
gem 'opentelemetry-instrumentation-base', path: '../base'
gem 'pry-byebug', platform: 'ruby'
end
File renamed without changes.
49 changes: 49 additions & 0 deletions instrumentation/httpx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# OpenTelemetry Http Instrumentation

The HTTPX instrumentation is a community-maintained instrumentation for the [HTTPX][httpx-home] gem.

## How do I get started?

Install the gem using:

```
gem install opentelemetry-instrumentation-httpx
```

Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-httpx` in your `Gemfile`.

## Usage

To use the instrumentation, call `use` with the name of the instrumentation:

```ruby
OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::HTTPX'
end
```

Alternatively, you can also call `use_all` to install all the available instrumentation.

```ruby
OpenTelemetry::SDK.configure do |c|
c.use_all
end
```

## How can I get involved?

The `opentelemetry-instrumentation-httpx` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.

The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].

## License

The `opentelemetry-instrumentation-httpx` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.

[http-home]: https://gitlab.com/os85/httpx
[bundler-home]: https://bundler.io
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
File renamed without changes.
27 changes: 27 additions & 0 deletions instrumentation/httpx/example/trace_demonstration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

require 'bundler/inline'

gemfile(true) do
source 'https://rubygems.org'
gem 'opentelemetry-api'
gem 'opentelemetry-instrumentation-base'
gem 'opentelemetry-instrumentation-httpx'
gem 'opentelemetry-sdk'
gem 'httpx'
end

require 'opentelemetry-api'
require 'opentelemetry-sdk'
require 'opentelemetry-instrumentation-httpx'
require 'httpx'

# Export traces to console by default
ENV['OTEL_TRACES_EXPORTER'] ||= 'console'

OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::HTTPX'
end

# A basic HTTP example
HTTPX.get('https://github.com')
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
#
# SPDX-License-Identifier: Apache-2.0

require_relative 'opentelemetry/resource/detectors'
require_relative 'opentelemetry/instrumentation'
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'opentelemetry/sdk'
require 'opentelemetry/resource/detectors/version'
require 'opentelemetry/resource/detectors/google_cloud_platform'
require 'opentelemetry/resource/detectors/azure'
require 'opentelemetry/resource/detectors/auto_detector'

# OpenTelemetry is an open source observability framework, providing a
# general-purpose API, SDK, and related tools required for the instrumentation
# of cloud-native software, frameworks, and libraries.
#
# The OpenTelemetry module provides global accessors for telemetry objects.
# See the documentation for the `opentelemetry-api` gem for details.
module OpenTelemetry
module Resource
# Detectors contains the resource detectors as well as the AutoDetector
# that can run all the detectors and return an accumlated resource
module Detectors
end
# Instrumentation should be able to handle the case when the library is not installed on a user's system.
module Instrumentation
end
end

require_relative 'instrumentation/httpx'
19 changes: 19 additions & 0 deletions instrumentation/httpx/lib/opentelemetry/instrumentation/httpx.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

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

require 'opentelemetry'
require 'opentelemetry-instrumentation-base'

module OpenTelemetry
module Instrumentation
# Contains the OpenTelemetry instrumentation for the Http gem
module HTTPX
end
end
end

require_relative 'httpx/instrumentation'
require_relative 'httpx/version'
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

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

module OpenTelemetry
module Instrumentation
module HTTPX
# The Instrumentation class contains logic to detect and install the Http instrumentation
class Instrumentation < OpenTelemetry::Instrumentation::Base
install do |_config|
require_dependencies
patch
end

compatible do
Gem::Version.new(::HTTPX::VERSION) >= Gem::Version.new('0.24.7')
end

present do
defined?(::HTTPX)
end

option :peer_service, default: nil, validate: :string

def patch
otel_session = ::HTTPX.plugin(Plugin)

::HTTPX.send(:remove_const, :Session)
::HTTPX.send(:const_set, :Session, otel_session.class)
end

def require_dependencies
require_relative 'plugin'
end
end
end
end
end
Loading

0 comments on commit f63845d

Please sign in to comment.