opentelemetry-instrumentation-action_pack 0.9.0 → 0.11.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 +12 -0
- data/README.md +22 -2
- data/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb +33 -15
- data/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb +28 -2
- data/lib/opentelemetry/instrumentation/action_pack/version.rb +1 -1
- metadata +17 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05533fdb3c934a831910410df2655646e034512b7fe6ed59532e0049bb9dd1e5
|
4
|
+
data.tar.gz: 4ec7fafbd1210f9d1e3846a3d897bc5d7b65f79970ce93a69eb57f7d5788d661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d061fa758b5203f675121906a1d04f31e6eba85d1601db9757ec89edd3a0b2b9577cd805e2e933fee281f438d17eb65afdfe32d0580564eebdc3d977879950
|
7
|
+
data.tar.gz: 55812b577b1dbd7a11875406136c0f73cfc5f0444a9903f34e99e59374f0d9fb5db6a1a568b77db544d1e7db1aae9383b955f8695d3b1c8623313aa7a7994c69
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-action_pack
|
2
2
|
|
3
|
+
### v0.11.0 / 2025-01-16
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Drop Support for EoL Rails 6.1
|
6
|
+
* BREAKING CHANGE: Set minimum supported version to Ruby 3.1
|
7
|
+
|
8
|
+
* ADDED: Drop Support for EoL Rails 6.1
|
9
|
+
* ADDED: Set minimum supported version to Ruby 3.1
|
10
|
+
|
11
|
+
### v0.10.0 / 2024-11-19
|
12
|
+
|
13
|
+
* ADDED: Use Semconv Naming For ActionPack
|
14
|
+
|
3
15
|
### v0.9.0 / 2024-01-09
|
4
16
|
|
5
17
|
* BREAKING CHANGE: Use ActiveSupport instead of patches #703
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ The Action Pack instrumentation is a community-maintained instrumentation for th
|
|
6
6
|
|
7
7
|
Install the gem using:
|
8
8
|
|
9
|
-
```
|
9
|
+
```console
|
10
10
|
gem install opentelemetry-instrumentation-action_pack
|
11
11
|
```
|
12
12
|
|
@@ -42,6 +42,24 @@ See the table below for details of what [Rails Framework Hook Events](https://gu
|
|
42
42
|
| - | - | - | - |
|
43
43
|
| `process_action.action_controller` | :white_check_mark: | :x: | It modifies the existing Rack span |
|
44
44
|
|
45
|
+
## Semantic Conventions
|
46
|
+
|
47
|
+
This instrumentation generally uses [HTTP server semantic conventions](https://opentelemetry.io/docs/specs/semconv/http/http-spans/) to update the existing Rack span.
|
48
|
+
|
49
|
+
For Rails 7.1+, the span name is updated to match the HTTP method and route that was matched for the request using [`ActionDispatch::Request#route_uri_pattern`](https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-route_uri_pattern), e.g.: `GET /users/:id`
|
50
|
+
|
51
|
+
For older versions of Rails the span name is updated to match the HTTP method, controller, and action name that was the target of the request, e.g.: `GET /example/index`
|
52
|
+
|
53
|
+
> ![NOTE]: Users may override the `span_naming` option to default to Legacy Span Naming Behavior that uses the controller's class name and action in Ruby documentation syntax, e.g. `ExampleController#index`.
|
54
|
+
|
55
|
+
This instrumentation does not emit any custom attributes.
|
56
|
+
|
57
|
+
| Attribute Name | Type | Notes |
|
58
|
+
| - | - | - |
|
59
|
+
| `code.namespace` | String | `ActionController` class name |
|
60
|
+
| `code.function` | String | `ActionController` action name e.g. `index`, `show`, `edit`, etc... |
|
61
|
+
| `http.route` | String | (Rails 7.1+) the route that was matched for the request |
|
62
|
+
| `http.target` | String | The `request.filtered_path` |
|
45
63
|
|
46
64
|
### Error Handling for Action Controller
|
47
65
|
|
@@ -57,7 +75,7 @@ Example usage can be seen in the `./example/trace_demonstration.rb` file [here](
|
|
57
75
|
|
58
76
|
The `opentelemetry-instrumentation-action_pack` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
|
59
77
|
|
60
|
-
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry
|
78
|
+
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].
|
61
79
|
|
62
80
|
## License
|
63
81
|
|
@@ -68,4 +86,6 @@ The `opentelemetry-instrumentation-action_pack` gem is distributed under the Apa
|
|
68
86
|
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
|
69
87
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
70
88
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
89
|
+
[slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
|
71
90
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
|
91
|
+
[rails-home]: https://rubyonrails.org/
|
@@ -13,6 +13,7 @@ module OpenTelemetry
|
|
13
13
|
# @param config [Hash] of instrumentation options
|
14
14
|
def initialize(config)
|
15
15
|
@config = config
|
16
|
+
@span_naming = config.fetch(:span_naming)
|
16
17
|
end
|
17
18
|
|
18
19
|
# Invoked by ActiveSupport::Notifications at the start of the instrumentation block
|
@@ -22,20 +23,11 @@ module OpenTelemetry
|
|
22
23
|
# @param payload [Hash] the payload passed as a method argument
|
23
24
|
# @return [Hash] the payload passed as a method argument
|
24
25
|
def start(_name, _id, payload)
|
25
|
-
|
26
|
+
span_name, attributes = to_span_name_and_attributes(payload)
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
attributes_to_append = {
|
32
|
-
OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]),
|
33
|
-
OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(payload[:action])
|
34
|
-
}
|
35
|
-
|
36
|
-
attributes_to_append[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath
|
37
|
-
|
38
|
-
rack_span.add_attributes(attributes_to_append)
|
28
|
+
span = OpenTelemetry::Instrumentation::Rack.current_span
|
29
|
+
span.name = span_name
|
30
|
+
span.add_attributes(attributes)
|
39
31
|
rescue StandardError => e
|
40
32
|
OpenTelemetry.handle_error(exception: e)
|
41
33
|
end
|
@@ -47,11 +39,37 @@ module OpenTelemetry
|
|
47
39
|
# @param payload [Hash] the payload passed as a method argument
|
48
40
|
# @return [Hash] the payload passed as a method argument
|
49
41
|
def finish(_name, _id, payload)
|
50
|
-
|
51
|
-
|
42
|
+
span = OpenTelemetry::Instrumentation::Rack.current_span
|
43
|
+
span.record_exception(payload[:exception_object]) if payload[:exception_object]
|
52
44
|
rescue StandardError => e
|
53
45
|
OpenTelemetry.handle_error(exception: e)
|
54
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# Extracts the span name and attributes from the payload
|
51
|
+
#
|
52
|
+
# @param payload [Hash] the payload passed from ActiveSupport::Notifications
|
53
|
+
# @return [Array<String, Hash>] the span name and attributes
|
54
|
+
def to_span_name_and_attributes(payload)
|
55
|
+
request = payload[:request]
|
56
|
+
http_route = request.route_uri_pattern if request.respond_to?(:route_uri_pattern)
|
57
|
+
|
58
|
+
attributes = {
|
59
|
+
OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]),
|
60
|
+
OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(payload[:action])
|
61
|
+
}
|
62
|
+
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_ROUTE] = http_route if http_route
|
63
|
+
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath
|
64
|
+
|
65
|
+
if @span_naming == :semconv
|
66
|
+
return ["#{request.method} #{http_route.gsub('(.:format)', '')}", attributes] if http_route
|
67
|
+
|
68
|
+
return ["#{request.method} /#{payload.dig(:params, :controller)}/#{payload.dig(:params, :action)}", attributes]
|
69
|
+
end
|
70
|
+
|
71
|
+
["#{payload[:controller]}##{payload[:action]}", attributes]
|
72
|
+
end
|
55
73
|
end
|
56
74
|
end
|
57
75
|
end
|
@@ -7,9 +7,33 @@
|
|
7
7
|
module OpenTelemetry
|
8
8
|
module Instrumentation
|
9
9
|
module ActionPack
|
10
|
-
# The Instrumentation class contains logic to detect and install the ActionPack instrumentation
|
10
|
+
# The {OpenTelemetry::Instrumentation::ActionPack::Instrumentation} class contains logic to detect and install the ActionPack instrumentation
|
11
|
+
#
|
12
|
+
# Installation and configuration of this instrumentation is done within the
|
13
|
+
# {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry/SDK#configure-instance_method OpenTelemetry::SDK#configure}
|
14
|
+
# block, calling {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use use()}
|
15
|
+
# or {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use_all use_all()}.
|
16
|
+
#
|
17
|
+
# ## Configuration keys and options
|
18
|
+
#
|
19
|
+
# ### `:span_naming`
|
20
|
+
#
|
21
|
+
# Specifies how the span names are set. Can be one of:
|
22
|
+
#
|
23
|
+
# - `:semconv` **(default)** - The span name will use HTTP semantic conventions '{method http.route}', for example `GET /users/:id`
|
24
|
+
# - `:class` - The span name will appear as '<ActionController class name>#<action>',
|
25
|
+
# for example `UsersController#show`.
|
26
|
+
#
|
27
|
+
# @example An explicit default configuration
|
28
|
+
# OpenTelemetry::SDK.configure do |c|
|
29
|
+
# c.use_all({
|
30
|
+
# 'OpenTelemetry::Instrumentation::ActionPack' => {
|
31
|
+
# span_naming: :class
|
32
|
+
# },
|
33
|
+
# })
|
34
|
+
# end
|
11
35
|
class Instrumentation < OpenTelemetry::Instrumentation::Base
|
12
|
-
MINIMUM_VERSION = Gem::Version.new('
|
36
|
+
MINIMUM_VERSION = Gem::Version.new('7')
|
13
37
|
|
14
38
|
install do |_config|
|
15
39
|
require_railtie
|
@@ -17,6 +41,8 @@ module OpenTelemetry
|
|
17
41
|
patch
|
18
42
|
end
|
19
43
|
|
44
|
+
option :span_naming, default: :semconv, validate: %i[semconv class]
|
45
|
+
|
20
46
|
present do
|
21
47
|
defined?(::ActionController)
|
22
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-action_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.23.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.23.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: opentelemetry-instrumentation-rack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.3'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rails
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '6.1'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '6.1'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: rake
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,28 +142,28 @@ dependencies:
|
|
156
142
|
requirements:
|
157
143
|
- - "~>"
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
145
|
+
version: 1.69.1
|
160
146
|
type: :development
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
150
|
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
152
|
+
version: 1.69.1
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: rubocop-performance
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
157
|
- - "~>"
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
159
|
+
version: 1.23.0
|
174
160
|
type: :development
|
175
161
|
prerelease: false
|
176
162
|
version_requirements: !ruby/object:Gem::Requirement
|
177
163
|
requirements:
|
178
164
|
- - "~>"
|
179
165
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
166
|
+
version: 1.23.0
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: simplecov
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +184,14 @@ dependencies:
|
|
198
184
|
requirements:
|
199
185
|
- - "~>"
|
200
186
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
187
|
+
version: 3.24.0
|
202
188
|
type: :development
|
203
189
|
prerelease: false
|
204
190
|
version_requirements: !ruby/object:Gem::Requirement
|
205
191
|
requirements:
|
206
192
|
- - "~>"
|
207
193
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
194
|
+
version: 3.24.0
|
209
195
|
- !ruby/object:Gem::Dependency
|
210
196
|
name: yard
|
211
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,11 +229,11 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
243
229
|
licenses:
|
244
230
|
- Apache-2.0
|
245
231
|
metadata:
|
246
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.
|
232
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.11.0/file/CHANGELOG.md
|
247
233
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/action_pack
|
248
234
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
249
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.
|
250
|
-
post_install_message:
|
235
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.11.0
|
236
|
+
post_install_message:
|
251
237
|
rdoc_options: []
|
252
238
|
require_paths:
|
253
239
|
- lib
|
@@ -255,15 +241,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
255
241
|
requirements:
|
256
242
|
- - ">="
|
257
243
|
- !ruby/object:Gem::Version
|
258
|
-
version: '3.
|
244
|
+
version: '3.1'
|
259
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
260
246
|
requirements:
|
261
247
|
- - ">="
|
262
248
|
- !ruby/object:Gem::Version
|
263
249
|
version: '0'
|
264
250
|
requirements: []
|
265
|
-
rubygems_version: 3.
|
266
|
-
signing_key:
|
251
|
+
rubygems_version: 3.3.27
|
252
|
+
signing_key:
|
267
253
|
specification_version: 4
|
268
254
|
summary: ActionPack instrumentation for the OpenTelemetry framework
|
269
255
|
test_files: []
|