opentelemetry-instrumentation-active_model_serializers 0.20.1 → 0.20.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: 4b949c58c29ef0c04a05e08869eef507222a9a42cf3026016604472de3ab538f
4
- data.tar.gz: df0259ac2556ed56fe8bb24c11af3f073052201c63636a17bab48e3815020bb7
3
+ metadata.gz: 79b4ebdf892853ac5b800c445abba347e9a985e1cba611493aff3ef4bc322092
4
+ data.tar.gz: 62430d20906a9614ddae4fea5015e6e2e171268c048e852c33a531c609bb1635
5
5
  SHA512:
6
- metadata.gz: a7f80dbfdca4acb78dd6803e6c90d9f0e5caab468acf0593a8bb87a357bb9f0709a8264ed22507fcf298fc49b693783ceeeb7931fb3a475787fc83ac9a80f8a0
7
- data.tar.gz: 8d4e4e58832adead91fc2cd57eacfe3a0efe7bd32619d8620eccdc74710e5e8a83d0a35e93c11ada3b9f70bcff005755408398bfb5722b74a5458259e4a886bc
6
+ metadata.gz: 9626d66b283b78643c2bde5b7a975f1802ad726a4a178386bf2743762f3fe30fb98ef779c36dc2dbd592abe4b9a19c0a118d26fbbe1a31775a92abdc7f638286
7
+ data.tar.gz: 390d8337a2f50566fcea3a9ff61561a504b26f8acac8ee6f9c31f07ac0ce58fc5be84027efe75dcd885a022d1b193cda28355a0d900a8c06a4bbba6cc06c40de
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release History: opentelemetry-instrumentation-active_model_serializers
2
2
 
3
+ ### v0.20.3 / 2024-12-04
4
+
5
+ * FIXED: Use ActiveSupport::Notifications subscriber to serialize events.
6
+
7
+ ### v0.20.2 / 2024-07-23
8
+
9
+ * DOCS: Add cspell to CI
10
+
3
11
  ### v0.20.1 / 2023-06-05
4
12
 
5
13
  * FIXED: Base config options
@@ -43,7 +51,7 @@
43
51
 
44
52
  ### v0.18.0 / 2021-05-21
45
53
 
46
- * ADDED: Updated API depedency for 1.0.0.rc1
54
+ * ADDED: Updated API dependency for 1.0.0.rc1
47
55
 
48
56
  ### v0.17.0 / 2021-04-22
49
57
 
data/README.md CHANGED
@@ -6,7 +6,7 @@ The OpenTelemetry Active Model Serializers gem is a community maintained instrum
6
6
 
7
7
  Install the gem using:
8
8
 
9
- ```
9
+ ```console
10
10
  gem install opentelemetry-instrumentation-active_model_serializers
11
11
  ```
12
12
 
@@ -38,7 +38,7 @@ Example usage of active_model_serializers can be seen in the `./example/active_m
38
38
 
39
39
  The `opentelemetry-instrumentation-active_model_serializers` 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
 
@@ -50,4 +50,5 @@ Apache 2.0 license. See [LICENSE][license-github] for more information.
50
50
  [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
51
51
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
52
52
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
53
+ [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
53
54
  [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -4,16 +4,24 @@
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
+ require 'opentelemetry-instrumentation-active_support'
8
+
7
9
  module OpenTelemetry
8
10
  module Instrumentation
9
11
  module ActiveModelSerializers
10
12
  # Instrumentation class that detects and installs the ActiveModelSerializers instrumentation
11
13
  class Instrumentation < OpenTelemetry::Instrumentation::Base
14
+ # Minimum supported version of the `active_model_serializers` gem
12
15
  MINIMUM_VERSION = Gem::Version.new('0.10.0')
13
16
 
17
+ # ActiveSupport::Notification topics to which the instrumentation subscribes
18
+ SUBSCRIPTIONS = %w[
19
+ render.active_model_serializers
20
+ ].freeze
21
+
14
22
  install do |_config|
23
+ install_active_support_instrumenation
15
24
  require_dependencies
16
- register_event_handler
17
25
  end
18
26
 
19
27
  present do
@@ -24,24 +32,39 @@ module OpenTelemetry
24
32
  !defined?(::ActiveSupport::Notifications).nil? && gem_version >= MINIMUM_VERSION
25
33
  end
26
34
 
35
+ def subscribe
36
+ SUBSCRIPTIONS.each do |subscription_name|
37
+ OpenTelemetry.logger.debug("Subscribing to #{subscription_name} notifications with #{_tracer}")
38
+ OpenTelemetry::Instrumentation::ActiveSupport.subscribe(_tracer, subscription_name, default_attribute_transformer)
39
+ end
40
+ end
41
+
27
42
  private
28
43
 
44
+ def _tracer
45
+ self.class.instance.tracer
46
+ end
47
+
29
48
  def gem_version
30
49
  Gem::Version.new(::ActiveModel::Serializer::VERSION)
31
50
  end
32
51
 
33
- def require_dependencies
34
- require_relative 'event_handler'
52
+ def install_active_support_instrumenation
53
+ OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance.install({})
35
54
  end
36
55
 
37
- def register_event_handler
38
- ::ActiveSupport::Notifications.subscribe(event_name) do |_name, start, finish, _id, payload|
39
- EventHandler.handle(start, finish, payload)
40
- end
56
+ def require_dependencies
57
+ require_relative 'railtie'
41
58
  end
42
59
 
43
- def event_name
44
- 'render.active_model_serializers'
60
+ def default_attribute_transformer
61
+ lambda { |payload|
62
+ {
63
+ 'serializer.name' => payload[:serializer].name,
64
+ 'serializer.renderer' => 'active_model_serializers',
65
+ 'serializer.format' => payload[:adapter]&.class&.name || 'default'
66
+ }
67
+ }
45
68
  end
46
69
  end
47
70
  end
@@ -0,0 +1,24 @@
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 ActiveModelSerializers # :nodoc:
10
+ def self.subscribe
11
+ Instrumentation.instance.subscribe
12
+ end
13
+
14
+ if defined?(::Rails::Railtie)
15
+ # This Railtie sets up subscriptions to relevant ActiveModelSerializers notifications
16
+ class Railtie < ::Rails::Railtie
17
+ config.after_initialize do
18
+ ::OpenTelemetry::Instrumentation::ActiveModelSerializers.subscribe
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module ActiveModelSerializers
10
- VERSION = '0.20.1'
10
+ VERSION = '0.20.3'
11
11
  end
12
12
  end
13
13
  end
@@ -15,5 +15,5 @@ module OpenTelemetry
15
15
  end
16
16
  end
17
17
 
18
- require_relative './active_model_serializers/instrumentation'
19
- require_relative './active_model_serializers/version'
18
+ require_relative 'active_model_serializers/instrumentation'
19
+ require_relative 'active_model_serializers/version'
@@ -19,4 +19,4 @@ module OpenTelemetry
19
19
  end
20
20
  end
21
21
 
22
- require_relative './instrumentation/active_model_serializers'
22
+ require_relative 'instrumentation/active_model_serializers'
@@ -4,4 +4,4 @@
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
- require_relative './opentelemetry/instrumentation'
7
+ require_relative 'opentelemetry/instrumentation'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-active_model_serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.20.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: 2023-06-05 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentelemetry-instrumentation-active_support
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.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.6.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: opentelemetry-instrumentation-base
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +72,14 @@ dependencies:
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 2.2.0
75
+ version: '2.5'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 2.2.0
82
+ version: '2.5'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -142,70 +156,70 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 1.50.2
159
+ version: 1.68.0
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 1.50.2
166
+ version: 1.68.0
153
167
  - !ruby/object:Gem::Dependency
154
- name: simplecov
168
+ name: rubocop-performance
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: 0.17.1
173
+ version: 1.23.0
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: 0.17.1
180
+ version: 1.23.0
167
181
  - !ruby/object:Gem::Dependency
168
- name: webmock
182
+ name: simplecov
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
185
  - - "~>"
172
186
  - !ruby/object:Gem::Version
173
- version: 3.7.6
187
+ version: 0.17.1
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - "~>"
179
193
  - !ruby/object:Gem::Version
180
- version: 3.7.6
194
+ version: 0.17.1
181
195
  - !ruby/object:Gem::Dependency
182
- name: yard
196
+ name: webmock
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - "~>"
186
200
  - !ruby/object:Gem::Version
187
- version: '0.9'
201
+ version: 3.24.0
188
202
  type: :development
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
206
  - - "~>"
193
207
  - !ruby/object:Gem::Version
194
- version: '0.9'
208
+ version: 3.24.0
195
209
  - !ruby/object:Gem::Dependency
196
- name: yard-doctest
210
+ name: yard
197
211
  requirement: !ruby/object:Gem::Requirement
198
212
  requirements:
199
213
  - - "~>"
200
214
  - !ruby/object:Gem::Version
201
- version: 0.1.6
215
+ version: '0.9'
202
216
  type: :development
203
217
  prerelease: false
204
218
  version_requirements: !ruby/object:Gem::Requirement
205
219
  requirements:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
- version: 0.1.6
222
+ version: '0.9'
209
223
  description: Active Model Serializers instrumentation for the OpenTelemetry framework
210
224
  email:
211
225
  - cncf-opentelemetry-contributors@lists.cncf.io
@@ -220,17 +234,17 @@ files:
220
234
  - lib/opentelemetry-instrumentation-active_model_serializers.rb
221
235
  - lib/opentelemetry/instrumentation.rb
222
236
  - lib/opentelemetry/instrumentation/active_model_serializers.rb
223
- - lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb
224
237
  - lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb
238
+ - lib/opentelemetry/instrumentation/active_model_serializers/railtie.rb
225
239
  - lib/opentelemetry/instrumentation/active_model_serializers/version.rb
226
240
  homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
227
241
  licenses:
228
242
  - Apache-2.0
229
243
  metadata:
230
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_model_serializers/0.20.1/file/CHANGELOG.md
244
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_model_serializers/0.20.3/file/CHANGELOG.md
231
245
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_model_serializers
232
246
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
233
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_model_serializers/0.20.1
247
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_model_serializers/0.20.3
234
248
  post_install_message:
235
249
  rdoc_options: []
236
250
  require_paths:
@@ -1,48 +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 ActiveModelSerializers
10
- # Event handler singleton for ActiveModelSerializers
11
- module EventHandler
12
- extend self
13
-
14
- def handle(start_timestamp, end_timestamp, payload)
15
- tracer.start_span(span_name(payload),
16
- start_timestamp: start_timestamp,
17
- attributes: build_attributes(payload),
18
- kind: :internal)
19
- .finish(end_timestamp: end_timestamp)
20
- end
21
-
22
- protected
23
-
24
- def span_name(payload)
25
- "#{demodulize(payload[:serializer].name)} render"
26
- end
27
-
28
- def build_attributes(payload)
29
- {
30
- 'serializer.name' => payload[:serializer].name,
31
- 'serializer.renderer' => 'active_model_serializers',
32
- 'serializer.format' => payload[:adapter]&.class&.name || 'default'
33
- }
34
- end
35
-
36
- def tracer
37
- ActiveModelSerializers::Instrumentation.instance.tracer
38
- end
39
-
40
- def demodulize(string)
41
- string = string.to_s
42
- i = string.rindex('::')
43
- i ? string[(i + 2)..-1] : string
44
- end
45
- end
46
- end
47
- end
48
- end