opentelemetry-instrumentation-active_support 0.5.2 → 0.6.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb96f6aa88f3f2cfcef205f3c8b35d4aadcd5deb88f96cece9dd0483a9d651b
|
4
|
+
data.tar.gz: 2e182a42afc7147b758a1bb70e8f3aed10b2a427781be74f039046081f680cd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c92ea1d46342f741e4773b5d4776fc1fa3cbef1dad880958e2a19a6d747b8c604ded8dff1f619a34787f4c24be206b13d6fb14dae9975c79d26fde764a90e1d1
|
7
|
+
data.tar.gz: 8fa040cf4aa404157181d6907be56d695375fdd029c3f82aa7f261548a34905bf0dd1d57231cd5a5a686de29d49882583622c62004ddeebb539e7780fd558c57
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-active_support
|
2
2
|
|
3
|
+
### v0.6.0 / 2024-07-02
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Custom ActiveSupport Span Names
|
6
|
+
|
7
|
+
* ADDED: Custom ActiveSupport Span Names
|
8
|
+
|
9
|
+
### v0.5.3 / 2024-06-20
|
10
|
+
|
11
|
+
* FIXED: Include span kind in ActiveSupport Instrumentation helper
|
12
|
+
|
3
13
|
### v0.5.2 / 2024-06-20
|
4
14
|
|
5
15
|
* ADDED: ActiveSupport user specified span kind
|
data/README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# OpenTelemetry ActiveSupport Instrumentation
|
2
|
+
|
2
3
|
The Active Support instrumentation is a community-maintained instrumentation for the Active Support portion of the [Ruby on Rails][rails-home] web-application framework.
|
3
4
|
|
4
5
|
## How do I get started?
|
5
6
|
|
6
7
|
Install the gem using:
|
7
8
|
|
8
|
-
```
|
9
|
+
```console
|
10
|
+
|
9
11
|
gem install opentelemetry-instrumentation-active_support
|
12
|
+
|
10
13
|
```
|
11
14
|
|
12
15
|
Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-active_support` in your `Gemfile`.
|
@@ -17,21 +20,24 @@ To use the instrumentation, call `use` with the name of the instrumentation and
|
|
17
20
|
to desired ActiveSupport notification:
|
18
21
|
|
19
22
|
```ruby
|
23
|
+
|
20
24
|
OpenTelemetry::SDK.configure do |c|
|
21
25
|
c.use 'OpenTelemetry::Instrumentation::ActiveSupport'
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
28
|
tracer = OpenTelemetry.tracer_provider.tracer('my_app_or_gem', '0.1.0')
|
26
29
|
::OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo')
|
30
|
+
|
27
31
|
```
|
28
32
|
|
29
33
|
Alternatively, you can also call `use_all` to install all the available instrumentation.
|
30
34
|
|
31
35
|
```ruby
|
36
|
+
|
32
37
|
OpenTelemetry::SDK.configure do |c|
|
33
38
|
c.use_all
|
34
39
|
end
|
40
|
+
|
35
41
|
```
|
36
42
|
|
37
43
|
## Examples
|
@@ -8,6 +8,9 @@ module OpenTelemetry
|
|
8
8
|
module Instrumentation
|
9
9
|
# rubocop:disable Style/Documentation
|
10
10
|
module ActiveSupport
|
11
|
+
LEGACY_NAME_FORMATTER = ->(name) { name.split('.')[0..1].reverse.join(' ') }
|
12
|
+
|
13
|
+
# rubocop:disable Metrics/ParameterLists
|
11
14
|
# The SpanSubscriber is a special ActiveSupport::Notification subscription
|
12
15
|
# handler which turns notifications into generic spans, taking care to handle
|
13
16
|
# context appropriately.
|
@@ -19,15 +22,17 @@ module OpenTelemetry
|
|
19
22
|
tracer,
|
20
23
|
pattern,
|
21
24
|
notification_payload_transform = nil,
|
22
|
-
disallowed_notification_payload_keys =
|
23
|
-
kind
|
25
|
+
disallowed_notification_payload_keys = nil,
|
26
|
+
kind: nil,
|
27
|
+
span_name_formatter: nil
|
24
28
|
)
|
25
29
|
subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new(
|
26
30
|
name: pattern,
|
27
31
|
tracer: tracer,
|
28
32
|
notification_payload_transform: notification_payload_transform,
|
29
33
|
disallowed_notification_payload_keys: disallowed_notification_payload_keys,
|
30
|
-
kind:
|
34
|
+
kind: kind,
|
35
|
+
span_name_formatter: span_name_formatter
|
31
36
|
)
|
32
37
|
|
33
38
|
subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber)
|
@@ -54,16 +59,19 @@ module OpenTelemetry
|
|
54
59
|
subscriber_object
|
55
60
|
end
|
56
61
|
|
62
|
+
# rubocop:enable Metrics/ParameterLists
|
57
63
|
class SpanSubscriber
|
58
64
|
ALWAYS_VALID_PAYLOAD_TYPES = [TrueClass, FalseClass, String, Numeric, Symbol].freeze
|
59
65
|
|
60
|
-
|
61
|
-
|
66
|
+
# rubocop:disable Metrics/ParameterLists
|
67
|
+
def initialize(name:, tracer:, notification_payload_transform: nil, disallowed_notification_payload_keys: nil, kind: nil, span_name_formatter: nil)
|
68
|
+
@span_name = safe_span_name_for(span_name_formatter, name).dup.freeze
|
62
69
|
@tracer = tracer
|
63
70
|
@notification_payload_transform = notification_payload_transform
|
64
|
-
@disallowed_notification_payload_keys = disallowed_notification_payload_keys
|
71
|
+
@disallowed_notification_payload_keys = Array(disallowed_notification_payload_keys)
|
65
72
|
@kind = kind || :internal
|
66
73
|
end
|
74
|
+
# rubocop:enable Metrics/ParameterLists
|
67
75
|
|
68
76
|
def start(name, id, payload)
|
69
77
|
span = @tracer.start_span(@span_name, kind: @kind)
|
@@ -128,6 +136,16 @@ module OpenTelemetry
|
|
128
136
|
value
|
129
137
|
end
|
130
138
|
end
|
139
|
+
|
140
|
+
# Helper method to try an shield the span name formatter from errors
|
141
|
+
#
|
142
|
+
# It wraps the user supplied formatter in a rescue block and returns the original name if a StandardError is raised by the formatter
|
143
|
+
def safe_span_name_for(span_name_formatter, name)
|
144
|
+
span_name_formatter&.call(name) || name
|
145
|
+
rescue StandardError => e
|
146
|
+
OpenTelemetry.handle_error(exception: e, message: 'Error calling span_name_formatter. Using default span name.')
|
147
|
+
name
|
148
|
+
end
|
131
149
|
end
|
132
150
|
end
|
133
151
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-active_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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: 2024-
|
11
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '13.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rspec-mocks
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: rubocop
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -269,10 +283,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
269
283
|
licenses:
|
270
284
|
- Apache-2.0
|
271
285
|
metadata:
|
272
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.
|
286
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.6.0/file/CHANGELOG.md
|
273
287
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_support
|
274
288
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
275
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.
|
289
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-active_support/0.6.0
|
276
290
|
post_install_message:
|
277
291
|
rdoc_options: []
|
278
292
|
require_paths:
|