opentelemetry-instrumentation-active_record 0.7.2 → 0.7.3

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: 5d1131d4989281075576fd33667b2dfe783c5da679192b254f0ac8bd11490075
4
- data.tar.gz: 719137b4fb014c01449240d61bb12ee0e76671e43bf6fd0b5259461904c28154
3
+ metadata.gz: a1ddaea29d71120e402d121369f632b92fc9a48dfb33c5d60bdc38e3becadeec
4
+ data.tar.gz: 5bb2301384011e58bab8c96b96bbacb3c61f6f34c35a7222031d784858bda89e
5
5
  SHA512:
6
- metadata.gz: 4ee27b5a907c5b08dcf34c96ef61fed9b13a3ebe7f38c9d0a4999d9945f91a77079aca4e9e6fc8b04ce349a8bbf311d16eb9d20288613eaebcc59c270fbc7eb8
7
- data.tar.gz: a7b2dcce676d412fe490d3177bd36c2c2bb9786f5f8791a1042ccbabff6dd5e2a083087679e2f455731094f58755f78861fb40c1b92dafeb837ec229904aa73b
6
+ metadata.gz: 62c14304ace8d9730b7c12fc67a8a7aa99c052172ea71d8cd4499e39f0a37ee6e87678804f55453d734798c6ad2032a6b0c32c211e091f2050d6c03970da1595
7
+ data.tar.gz: 8f119bd04db09a6477487c14945ecb8c201dcab6a487b39f6344b734c9068a3741cac1bd6034ba249dfcae81e9a94c0fffaa58e1024484ecb57802ca25c53ee6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-instrumentation-active_record
2
2
 
3
+ ### v0.7.3 / 2024-08-15
4
+
5
+ * FIXED: Use Active Support Lazy Load Hooks to avoid prematurely initializing ActiveRecord::Base and ActiveJob::Base
6
+
3
7
  ### v0.7.2 / 2024-04-30
4
8
 
5
9
  * FIXED: Resolve active_record testing issue
data/README.md CHANGED
@@ -6,7 +6,7 @@ The Active Record instrumentation is a community-maintained instrumentation for
6
6
 
7
7
  Install the gem using:
8
8
 
9
- ```
9
+ ```console
10
10
  gem install opentelemetry-instrumentation-active_record
11
11
  ```
12
12
 
@@ -38,7 +38,7 @@ Example usage can be seen in the `./example/trace_demonstration.rb` file [here](
38
38
 
39
39
  The `opentelemetry-instrumentation-active_record` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
40
40
 
41
- 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].
41
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our [GitHub Discussions][discussions-url], [Slack Channel][slack-channel] 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].
42
42
 
43
43
  ## License
44
44
 
@@ -49,4 +49,6 @@ The `opentelemetry-instrumentation-active_record` gem is distributed under the A
49
49
  [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
50
50
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
51
51
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
52
+ [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
52
53
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
54
+ [rails-home]: https://rubyonrails.org/
@@ -13,7 +13,7 @@ module OpenTelemetry
13
13
 
14
14
  install do |_config|
15
15
  require_dependencies
16
- patch
16
+ patch_activerecord
17
17
  end
18
18
 
19
19
  present do
@@ -30,27 +30,8 @@ module OpenTelemetry
30
30
  ::ActiveRecord.version
31
31
  end
32
32
 
33
- def patch
34
- # The original approach taken here was to patch each individual module of interest.
35
- # However the patches are applied too late in some applications and as a result the
36
- # Active Record models will not have the instrumentation patches applied.
37
- # Prepending the ActiveRecord::Base class is more consistent in applying
38
- # the patches regardless of initialization order.
39
- #
40
- # Modules to prepend to ActiveRecord::Base are still grouped by the source
41
- # module that they are defined in.
42
- # Example: Patches::PersistenceClassMethods refers to https://github.com/rails/rails/blob/v6.1.0/activerecord/lib/active_record/persistence.rb#L10
43
- ::ActiveRecord::Base.prepend(Patches::Querying)
44
- ::ActiveRecord::Base.prepend(Patches::Persistence)
45
- ::ActiveRecord::Base.prepend(Patches::PersistenceClassMethods)
46
- ::ActiveRecord::Base.prepend(Patches::PersistenceInsertClassMethods)
47
- ::ActiveRecord::Base.prepend(Patches::TransactionsClassMethods)
48
- ::ActiveRecord::Base.prepend(Patches::Validations)
49
-
50
- ::ActiveRecord::Relation.prepend(Patches::RelationPersistence)
51
- end
52
-
53
33
  def require_dependencies
34
+ require 'active_support/lazy_load_hooks'
54
35
  require_relative 'patches/querying'
55
36
  require_relative 'patches/persistence'
56
37
  require_relative 'patches/persistence_class_methods'
@@ -59,6 +40,23 @@ module OpenTelemetry
59
40
  require_relative 'patches/validations'
60
41
  require_relative 'patches/relation_persistence'
61
42
  end
43
+
44
+ def patch_activerecord
45
+ ActiveSupport.on_load(:active_record) do
46
+ # Modules to prepend to ActiveRecord::Base are grouped by the source
47
+ # module that they are defined in as they are included into ActiveRecord::Base
48
+ # Example: Patches::PersistenceClassMethods refers to https://github.com/rails/rails/blob/v6.1.0/activerecord/lib/active_record/persistence.rb#L10
49
+ # which is included into ActiveRecord::Base in https://github.com/rails/rails/blob/914caca2d31bd753f47f9168f2a375921d9e91cc/activerecord/lib/active_record/base.rb#L283
50
+ ::ActiveRecord::Base.prepend(Patches::Querying)
51
+ ::ActiveRecord::Base.prepend(Patches::Persistence)
52
+ ::ActiveRecord::Base.prepend(Patches::PersistenceClassMethods)
53
+ ::ActiveRecord::Base.prepend(Patches::PersistenceInsertClassMethods)
54
+ ::ActiveRecord::Base.prepend(Patches::TransactionsClassMethods)
55
+ ::ActiveRecord::Base.prepend(Patches::Validations)
56
+
57
+ ::ActiveRecord::Relation.prepend(Patches::RelationPersistence)
58
+ end
59
+ end
62
60
  end
63
61
  end
64
62
  end
@@ -20,37 +20,37 @@ module OpenTelemetry
20
20
  module ClassMethods
21
21
  ruby2_keywords def insert(*args)
22
22
  tracer.in_span("#{self}.insert") do
23
- super(*args)
23
+ super
24
24
  end
25
25
  end
26
26
 
27
27
  ruby2_keywords def insert_all(*args)
28
28
  tracer.in_span("#{self}.insert_all") do
29
- super(*args)
29
+ super
30
30
  end
31
31
  end
32
32
 
33
33
  ruby2_keywords def insert!(*args)
34
34
  tracer.in_span("#{self}.insert!") do
35
- super(*args)
35
+ super
36
36
  end
37
37
  end
38
38
 
39
39
  ruby2_keywords def insert_all!(*args)
40
40
  tracer.in_span("#{self}.insert_all!") do
41
- super(*args)
41
+ super
42
42
  end
43
43
  end
44
44
 
45
45
  ruby2_keywords def upsert(*args)
46
46
  tracer.in_span("#{self}.upsert") do
47
- super(*args)
47
+ super
48
48
  end
49
49
  end
50
50
 
51
51
  ruby2_keywords def upsert_all(*args)
52
52
  tracer.in_span("#{self}.upsert_all") do
53
- super(*args)
53
+ super
54
54
  end
55
55
  end
56
56
 
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module ActiveRecord
10
- VERSION = '0.7.2'
10
+ VERSION = '0.7.3'
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-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-30 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.62'
145
+ version: 1.65.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.62'
152
+ version: 1.65.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rubocop-performance
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -233,10 +233,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
233
233
  licenses:
234
234
  - Apache-2.0
235
235
  metadata:
236
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_record/0.7.2/file/CHANGELOG.md
236
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_record/0.7.3/file/CHANGELOG.md
237
237
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_record
238
238
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
239
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_record/0.7.2
239
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_record/0.7.3
240
240
  post_install_message:
241
241
  rdoc_options: []
242
242
  require_paths: