opentelemetry-instrumentation-action_view 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/opentelemetry/instrumentation/action_view/instrumentation.rb +0 -1
- data/lib/opentelemetry/instrumentation/action_view/railtie.rb +4 -6
- data/lib/opentelemetry/instrumentation/action_view/version.rb +1 -1
- metadata +20 -7
- 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: 52213cc69860a40c5c84fc88b32f585458285d463500c38a608b8684aef576c9
|
4
|
+
data.tar.gz: 12d0053a8a39b0ed6fc83cc5b6b0a5de86b18210ae9ce996a58bd5b416b97698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0dbd124ffe15d87bf11c464bd8b4f5b1641aedfdf6f5581f4ae71f27a3d8f14dd8da43f85ca8a5568904bf36858c35e166e57c02fc5709d6c008cdb37cb773e
|
7
|
+
data.tar.gz: e1c6cd8cf9d832bf1733bd682a65ef0e9a0967a102786334ec9832edef104c297c76eea086a1146a5c9f6d83941cfe2803dee5d29ba47e70f313b289d8ec650f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-action_view
|
2
2
|
|
3
|
+
### v0.2.0 / 2021-12-01
|
4
|
+
|
5
|
+
* ADDED: Move activesupport notification subsciber out of action_view gem
|
6
|
+
* FIXED: Instrumentation of Rails 7
|
7
|
+
|
3
8
|
### v0.1.3 / 2021-10-06
|
4
9
|
|
5
10
|
* FIXED: Do not replace fanout
|
@@ -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.2.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-
|
11
|
+
date: 2021-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -24,20 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.0.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.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
|
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.19.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.
|
54
|
+
version: 0.19.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: appraisal
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,16 +222,15 @@ files:
|
|
208
222
|
- lib/opentelemetry/instrumentation/action_view.rb
|
209
223
|
- lib/opentelemetry/instrumentation/action_view/instrumentation.rb
|
210
224
|
- lib/opentelemetry/instrumentation/action_view/railtie.rb
|
211
|
-
- lib/opentelemetry/instrumentation/action_view/span_subscriber.rb
|
212
225
|
- lib/opentelemetry/instrumentation/action_view/version.rb
|
213
226
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
214
227
|
licenses:
|
215
228
|
- Apache-2.0
|
216
229
|
metadata:
|
217
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.
|
230
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.2.0/file.CHANGELOG.html
|
218
231
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/action_view
|
219
232
|
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.
|
233
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-action_view/v0.2.0
|
221
234
|
post_install_message:
|
222
235
|
rdoc_options: []
|
223
236
|
require_paths:
|
@@ -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
|