opentelemetry-instrumentation-action_view 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/opentelemetry/instrumentation/action_view/instrumentation.rb +5 -2
- data/lib/opentelemetry/instrumentation/action_view/railtie.rb +4 -6
- data/lib/opentelemetry/instrumentation/action_view/version.rb +1 -1
- metadata +39 -12
- data/lib/opentelemetry/instrumentation/action_view/span_subscriber.rb +0 -111
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 824dc027f56fa829edb6157b6bf3e3467ac671e1ade5caa9b1a55dbc91fe0f39
|
4
|
+
data.tar.gz: c818cf8e952e2202c53a20ed6a0f0a7bb60f7ccaac5ac707b5ae88f446ae56b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a39f086a65baf73768c41130d6a5c81a2787d47957a9b3b179735865764fe837592adb9037fe8ea5400d40a45a613131fa5017e8c201219aea63ba8b47b017e3
|
7
|
+
data.tar.gz: f65e5c0c8b5f0672912fa2deedd30615b6a18328f027be958d1fc85d5c6d303e1ee769661fda03f854903192e190972f8cd9320adc97c18810a65029d65b4421
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-action_view
|
2
2
|
|
3
|
+
### v0.3.0 / 2022-06-09
|
4
|
+
|
5
|
+
* Upgrading Base dependency version
|
6
|
+
* FIXED: Broken test file requirements
|
7
|
+
|
8
|
+
### v0.2.1 / 2022-05-02
|
9
|
+
|
10
|
+
* FIXED: RubyGems Fallback
|
11
|
+
|
12
|
+
### v0.2.0 / 2021-12-01
|
13
|
+
|
14
|
+
* ADDED: Move activesupport notification subsciber out of action_view gem
|
15
|
+
* FIXED: Instrumentation of Rails 7
|
16
|
+
|
3
17
|
### v0.1.3 / 2021-10-06
|
4
18
|
|
5
19
|
* FIXED: Do not replace fanout
|
@@ -19,7 +19,7 @@ module OpenTelemetry
|
|
19
19
|
end
|
20
20
|
|
21
21
|
compatible do
|
22
|
-
|
22
|
+
gem_version >= MINIMUM_VERSION
|
23
23
|
end
|
24
24
|
|
25
25
|
option :disallowed_notification_payload_keys, default: [], validate: :array
|
@@ -27,8 +27,11 @@ module OpenTelemetry
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
+
def gem_version
|
31
|
+
::ActionView.version
|
32
|
+
end
|
33
|
+
|
30
34
|
def require_dependencies
|
31
|
-
require_relative 'span_subscriber'
|
32
35
|
require_relative 'railtie'
|
33
36
|
end
|
34
37
|
end
|
@@ -16,13 +16,11 @@ module OpenTelemetry
|
|
16
16
|
# This Railtie sets up subscriptions to relevant ActionView notifications
|
17
17
|
class Railtie < ::Rails::Railtie
|
18
18
|
config.after_initialize do
|
19
|
-
|
20
|
-
subscriber = OpenTelemetry::Instrumentation::ActionView::SpanSubscriber.new(
|
21
|
-
name: subscription_name,
|
22
|
-
tracer: ActionView::Instrumentation.instance.tracer
|
23
|
-
)
|
19
|
+
::OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance.install({})
|
24
20
|
|
25
|
-
|
21
|
+
SUBSCRIPTIONS.each do |subscription_name|
|
22
|
+
config = ActionView::Instrumentation.instance.config
|
23
|
+
::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(ActionView::Instrumentation.instance.tracer, subscription_name, config[:notification_payload_transform], config[:disallowed_notification_payload_keys])
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-action_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
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.1'
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
40
|
+
version: '0.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: opentelemetry-instrumentation-base
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
47
|
+
version: '0.20'
|
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.
|
54
|
+
version: '0.20'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: appraisal
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,28 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
103
|
+
version: '1.1'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
110
|
+
version: '1.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: opentelemetry-test-helpers
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: rails
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,16 +236,15 @@ files:
|
|
208
236
|
- lib/opentelemetry/instrumentation/action_view.rb
|
209
237
|
- lib/opentelemetry/instrumentation/action_view/instrumentation.rb
|
210
238
|
- lib/opentelemetry/instrumentation/action_view/railtie.rb
|
211
|
-
- lib/opentelemetry/instrumentation/action_view/span_subscriber.rb
|
212
239
|
- lib/opentelemetry/instrumentation/action_view/version.rb
|
213
240
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
214
241
|
licenses:
|
215
242
|
- Apache-2.0
|
216
243
|
metadata:
|
217
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.
|
244
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.3.0/file.CHANGELOG.html
|
218
245
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/action_view
|
219
246
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
220
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.
|
247
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.3.0
|
221
248
|
post_install_message:
|
222
249
|
rdoc_options: []
|
223
250
|
require_paths:
|
@@ -226,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
253
|
requirements:
|
227
254
|
- - ">="
|
228
255
|
- !ruby/object:Gem::Version
|
229
|
-
version: 2.
|
256
|
+
version: 2.6.0
|
230
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
258
|
requirements:
|
232
259
|
- - ">="
|
@@ -1,111 +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
|
-
# rubocop:disable Style/Documentation
|
10
|
-
module ActionView
|
11
|
-
# The SpanSubscriber is a special ActiveSupport::Notification subscription
|
12
|
-
# handler which turns notifications into generic spans, taking care to handle
|
13
|
-
# context appropriately.
|
14
|
-
|
15
|
-
# A very hacky way to make sure that OpenTelemetry::Instrumentation::ActionView::SpanSubscriber
|
16
|
-
# gets invoked first
|
17
|
-
def self.subscribe(pattern = nil, callable = nil)
|
18
|
-
ActiveSupport::Notifications.subscribe(pattern, callable)
|
19
|
-
::ActiveSupport::Notifications.notifier.synchronize do
|
20
|
-
if ::Rails::VERSION::MAJOR == 6
|
21
|
-
s = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern].pop
|
22
|
-
::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern].unshift(s)
|
23
|
-
else
|
24
|
-
s = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).pop
|
25
|
-
::ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).unshift(s)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class SpanSubscriber
|
31
|
-
ALWAYS_VALID_PAYLOAD_TYPES = [TrueClass, FalseClass, String, Numeric, Symbol].freeze
|
32
|
-
|
33
|
-
def initialize(name:, tracer:)
|
34
|
-
@span_name = name.split('.')[0..1].reverse.join(' ').freeze
|
35
|
-
@tracer = tracer
|
36
|
-
end
|
37
|
-
|
38
|
-
def start(name, id, payload)
|
39
|
-
span = @tracer.start_span(@span_name, kind: :internal)
|
40
|
-
token = OpenTelemetry::Context.attach(
|
41
|
-
OpenTelemetry::Trace.context_with_span(span)
|
42
|
-
)
|
43
|
-
payload.merge!(
|
44
|
-
__opentelemetry_span: span,
|
45
|
-
__opentelemetry_ctx_token: token
|
46
|
-
)
|
47
|
-
|
48
|
-
[span, token]
|
49
|
-
end
|
50
|
-
|
51
|
-
def finish(name, id, payload) # rubocop:disable Metrics/AbcSize
|
52
|
-
span = payload.delete(:__opentelemetry_span)
|
53
|
-
token = payload.delete(:__opentelemetry_ctx_token)
|
54
|
-
return unless span && token
|
55
|
-
|
56
|
-
payload = transform_payload(payload)
|
57
|
-
attrs = payload.map do |k, v|
|
58
|
-
[k.to_s, sanitized_value(v)] if valid_payload_key?(k) && valid_payload_value?(v)
|
59
|
-
end
|
60
|
-
span.add_attributes(attrs.compact.to_h)
|
61
|
-
|
62
|
-
if (e = payload[:exception_object])
|
63
|
-
span.record_exception(e)
|
64
|
-
span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}")
|
65
|
-
end
|
66
|
-
|
67
|
-
span.finish
|
68
|
-
OpenTelemetry::Context.detach(token)
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
def instrumentation_config
|
74
|
-
ActionView::Instrumentation.instance.config
|
75
|
-
end
|
76
|
-
|
77
|
-
def transform_payload(payload)
|
78
|
-
return payload if instrumentation_config[:notification_payload_transform].nil?
|
79
|
-
|
80
|
-
instrumentation_config[:notification_payload_transform].call(payload)
|
81
|
-
end
|
82
|
-
|
83
|
-
def valid_payload_key?(key)
|
84
|
-
%i[exception exception_object].none?(key) && instrumentation_config[:disallowed_notification_payload_keys].none?(key)
|
85
|
-
end
|
86
|
-
|
87
|
-
def valid_payload_value?(value)
|
88
|
-
if value.is_a?(Array)
|
89
|
-
return true if value.empty?
|
90
|
-
|
91
|
-
value.map(&:class).uniq.size == 1 && ALWAYS_VALID_PAYLOAD_TYPES.any? { |t| value.first.is_a?(t) }
|
92
|
-
else
|
93
|
-
ALWAYS_VALID_PAYLOAD_TYPES.any? { |t| value.is_a?(t) }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# We'll accept symbols as values, but stringify them; and we'll stringify symbols within an array.
|
98
|
-
def sanitized_value(value)
|
99
|
-
if value.is_a?(Array)
|
100
|
-
value.map { |v| v.is_a?(Symbol) ? v.to_s : v }
|
101
|
-
elsif value.is_a?(Symbol)
|
102
|
-
value.to_s
|
103
|
-
else
|
104
|
-
value
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
# rubocop:enable Style/Documentation
|
111
|
-
end
|