opentelemetry-instrumentation-rails 0.18.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e34571f27de616ba58694c8237c0aa261d2fb4bd0fffdc233a2c6aadb57a9db6
4
- data.tar.gz: eb6d54e06b7e8b4e25d863ce342130de2c41c41ebdf23c287c8dda0b9d286462
3
+ metadata.gz: 83e599f0c6dd74b03a1ba2351634df27b41830de3d5c7a98d7978e937736cf04
4
+ data.tar.gz: b4f033ba3bf54a043dc592c95377678c630b08bd5b1a62598fc3e04f41139fdd
5
5
  SHA512:
6
- metadata.gz: d9a6b78d0b3aba5bc89f0b4c7a5cc6f4af50509958d65f789356fe5823688682cea61e8167b317e82f9c25427d5b80f4cffba7032784d7c5213d3a107153d53d
7
- data.tar.gz: 1948237271395861da709a3ec93f0cccc6ddfce8ccf3bea1f3065ee48df1ead58f1dfcb657d23c834bd854dcf5ced63ff66adf8501fba8c9d86fe6ae9513a512
6
+ metadata.gz: 327efc6f764d24ab8d239e494344b4c85d7e1376fafa378a90e8171ccb104e821a4b0400c5a13de542e25a858357829dfad9a812e1965e2ba8c5b6f1ebfbb020
7
+ data.tar.gz: b9d58fb62cc0adb707dd3477af5dba12051dab2bc83cf43deeb1eee5ff29f8037fd1e963873a4d6a142c12ce5f45a06a465c6f7dbd86eeb9465500f633294a67
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Release History: opentelemetry-instrumentation-rails
2
2
 
3
+ ### v0.19.0 / 2021-08-12
4
+
5
+ * ADDED: Instrument active record
6
+ * ADDED: Add ActionView instrumentation via ActiveSupport::Notifications
7
+ * FIXED: Rails instrumentation to not explicitly install sub gems
8
+ * DOCS: Update docs to rely more on environment variable configuration
9
+
10
+ * This release adds support for Active Record and Action View.
11
+ * The `enable_recognize_route` configuration option has been moved to the ActionPack gem.
12
+ * See readme for details on how to configure the sub instrumentation gems.
13
+
3
14
  ### v0.18.1 / 2021-06-23
4
15
 
5
16
  * FIXED: Updated rack middleware position to zero
data/README.md CHANGED
@@ -14,15 +14,7 @@ Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-r
14
14
 
15
15
  ## Usage
16
16
 
17
- To use the instrumentation, call `use` with the name of the instrumentation:
18
-
19
- ```ruby
20
- OpenTelemetry::SDK.configure do |c|
21
- c.use 'OpenTelemetry::Instrumentation::Rails'
22
- end
23
- ```
24
-
25
- Alternatively, you can also call `use_all` to install all the available instrumentation.
17
+ To use the Rails instrumentation, call `use_all` so it installs all the instrumentation gems.
26
18
 
27
19
  ```ruby
28
20
  OpenTelemetry::SDK.configure do |c|
@@ -30,15 +22,14 @@ OpenTelemetry::SDK.configure do |c|
30
22
  end
31
23
  ```
32
24
 
33
-
34
25
  ### Configuration options
35
26
 
36
- The `http.route` attribute is disabled by default because we use [.recognize](https://github.com/rails/rails/blob/v6.1.3/actionpack/lib/action_dispatch/journey/router.rb#L65)
27
+ The Rails instrumentation attempts to mirror the structure of the Ruby on Rails. It is a collection of instrumentation gems for components of Rails such as Action View, Active Record, Action Pack, etc...
28
+
29
+ You may want to include all of the Rails instrumentation but disable a single instrumentation gem that it includes. Here is an example of how you can disable Active Record when using this instrumentation gem.
37
30
  ```ruby
38
31
  OpenTelemetry::SDK.configure do |c|
39
- c.use 'OpenTelemetry::Instrumentation::Rails', {
40
- enable_recognize_route: true
41
- }
32
+ c.use_all({ 'OpenTelemetry::Instrumentation::ActiveRecord' => { enabled: false } })
42
33
  end
43
34
  ```
44
35
 
@@ -15,6 +15,8 @@ module OpenTelemetry
15
15
  end
16
16
  end
17
17
 
18
- require 'opentelemetry-instrumentation-rack'
18
+ require 'opentelemetry-instrumentation-action_pack'
19
+ require 'opentelemetry-instrumentation-action_view'
20
+ require 'opentelemetry-instrumentation-active_record'
19
21
  require_relative './rails/instrumentation'
20
22
  require_relative './rails/version'
@@ -12,30 +12,19 @@ module OpenTelemetry
12
12
  # The Instrumentation class contains logic to detect and install the Rails
13
13
  # instrumentation
14
14
  class Instrumentation < OpenTelemetry::Instrumentation::Base
15
- install do |_config|
16
- require_dependencies
17
- require_railtie
18
- patch_metal
19
- end
20
-
21
- present do
22
- defined?(::Rails)
23
- end
15
+ MINIMUM_VERSION = Gem::Version.new('5.2.0')
24
16
 
25
- option :enable_recognize_route, default: false, validate: :boolean
17
+ # This gem requires the instrumentantion gems for the different
18
+ # components of Rails, as a result it does not have any explicit
19
+ # work to do in the install step.
20
+ install { true }
21
+ present { defined?(::Rails) }
22
+ compatible { gem_version >= MINIMUM_VERSION }
26
23
 
27
24
  private
28
25
 
29
- def require_dependencies
30
- require_relative 'patches/action_controller/metal'
31
- end
32
-
33
- def require_railtie
34
- require_relative 'railtie'
35
- end
36
-
37
- def patch_metal
38
- ::ActionController::Metal.prepend(Patches::ActionController::Metal)
26
+ def gem_version
27
+ Gem.loaded_specs['actionpack'].version
39
28
  end
40
29
  end
41
30
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Rails
10
- VERSION = '0.18.1'
10
+ VERSION = '0.19.0'
11
11
  end
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2021-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,42 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.rc2
19
+ version: 1.0.0.rc3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0.rc2
26
+ version: 1.0.0.rc3
27
27
  - !ruby/object:Gem::Dependency
28
- name: opentelemetry-instrumentation-base
28
+ name: opentelemetry-instrumentation-action_pack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: opentelemetry-instrumentation-action_view
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 0.18.1
47
+ version: 0.1.0
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 0.18.1
54
+ version: 0.1.0
41
55
  - !ruby/object:Gem::Dependency
42
- name: opentelemetry-instrumentation-rack
56
+ name: opentelemetry-instrumentation-active_record
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: opentelemetry-instrumentation-base
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: 0.19.0
75
+ version: 0.18.2
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: 0.19.0
82
+ version: 0.18.2
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: appraisal
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -235,8 +263,6 @@ files:
235
263
  - lib/opentelemetry/instrumentation.rb
236
264
  - lib/opentelemetry/instrumentation/rails.rb
237
265
  - lib/opentelemetry/instrumentation/rails/instrumentation.rb
238
- - lib/opentelemetry/instrumentation/rails/patches/action_controller/metal.rb
239
- - lib/opentelemetry/instrumentation/rails/railtie.rb
240
266
  - lib/opentelemetry/instrumentation/rails/version.rb
241
267
  homepage: https://github.com/open-telemetry/opentelemetry-ruby
242
268
  licenses:
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright The OpenTelemetry Authors
4
- #
5
- # SPDX-License-Identifier: Apache-2.0
6
-
7
- module OpenTelemetry
8
- module Instrumentation
9
- module Rails
10
- module Patches
11
- module ActionController
12
- # Module to prepend to ActionController::Metal for instrumentation
13
- module Metal
14
- def dispatch(name, request, response)
15
- rack_span = OpenTelemetry::Instrumentation::Rack.current_span
16
- rack_span.name = "#{self.class.name}##{name}" if rack_span.context.valid? && !request.env['action_dispatch.exception']
17
-
18
- add_rails_route(rack_span, request) if instrumentation_config[:enable_recognize_route]
19
- super(name, request, response)
20
- end
21
-
22
- private
23
-
24
- def add_rails_route(rack_span, request)
25
- ::Rails.application.routes.router.recognize(request) do |route, _params|
26
- rack_span.set_attribute('http.route', route.path.spec.to_s)
27
- end
28
- end
29
-
30
- def instrumentation_config
31
- Rails::Instrumentation.instance.config
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright The OpenTelemetry Authors
4
- #
5
- # SPDX-License-Identifier: Apache-2.0
6
-
7
- module OpenTelemetry
8
- module Instrumentation
9
- module Rails
10
- # The Instrumentation class contains logic to detect and install the Rails
11
- # instrumentation, while this Railtie is used to conventionally instrument
12
- # the Rails application through its initialization hooks
13
- class Railtie < ::Rails::Railtie
14
- config.before_initialize do |app|
15
- OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.install({})
16
-
17
- app.middleware.insert_before(
18
- 0,
19
- OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware
20
- )
21
- end
22
- end
23
- end
24
- end
25
- end