opentelemetry-instrumentation-action_pack 0.12.1 → 0.12.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d469bead142d9682483795b636de7c9d46fc8d410651f3409ab8e106a9d28f48
|
4
|
+
data.tar.gz: 3e5fbfaa2a26ea52fa01f58077f8420e92b4a7a3561a4b6547ecbeecfcea07c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98b81892126505b05311b3ca67feb6e530e7543742fa36895e301312e737ed8e5804f8c840aaf8e743ac29e00cec79d81be9908313888311f958225ba7a38d65
|
7
|
+
data.tar.gz: 1207dcac466eb75ba81f1b2ce75e8be3136f26d22e997fdb4acace9b84fbadba18aac959f181f29c8a2a0b091a9e9c7b5a3c2e37d86ec108080391c888bd8266
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -69,7 +69,7 @@ The error object will be retained within `payload[:exception_object]`. Additiona
|
|
69
69
|
|
70
70
|
## Examples
|
71
71
|
|
72
|
-
Example usage can be seen in the `./example/trace_demonstration.rb` file
|
72
|
+
Example usage can be seen in the [`./example/trace_demonstration.rb` file](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/action_pack/example/trace_demonstration.ru)
|
73
73
|
|
74
74
|
## How can I get involved?
|
75
75
|
|
@@ -23,9 +23,34 @@ module OpenTelemetry
|
|
23
23
|
# @param payload [Hash] the payload passed as a method argument
|
24
24
|
# @return [Hash] the payload passed as a method argument
|
25
25
|
def start(_name, _id, payload)
|
26
|
-
|
26
|
+
request = payload[:request]
|
27
|
+
# It seems that there are cases in Rails functional tests where it bypasses the routing system and the `action_dispatch.route_uri_pattern` header not being set.
|
28
|
+
# Our Test suite executes the routing system so we are unable to recreate this error case.
|
29
|
+
# https://github.com/rails/rails/blob/747f85f200e7bb2c1a31b4e26e5a5655e2dc0cdc/actionpack/lib/action_dispatch/http/request.rb#L160
|
30
|
+
http_route = request.route_uri_pattern&.chomp('(.:format)') if request.respond_to?(:route_uri_pattern)
|
31
|
+
|
32
|
+
attributes = {
|
33
|
+
OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]),
|
34
|
+
OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(payload[:action])
|
35
|
+
}
|
36
|
+
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_ROUTE] = http_route if http_route
|
37
|
+
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath
|
27
38
|
|
28
39
|
span = OpenTelemetry::Instrumentation::Rack.current_span
|
40
|
+
span_name = if @span_naming == :semconv
|
41
|
+
if http_route
|
42
|
+
"#{request.method} #{http_route}"
|
43
|
+
else
|
44
|
+
"#{request.method} /#{payload.dig(:params, :controller)}/#{payload.dig(:params, :action)}"
|
45
|
+
end
|
46
|
+
# If there is an exception we want to keep the original span name
|
47
|
+
# so it is easier to see where the request was routed to.
|
48
|
+
elsif request.env['action_dispatch.exception']
|
49
|
+
span.name
|
50
|
+
else
|
51
|
+
"#{payload[:controller]}##{payload[:action]}"
|
52
|
+
end
|
53
|
+
|
29
54
|
span.name = span_name
|
30
55
|
span.add_attributes(attributes)
|
31
56
|
rescue StandardError => e
|
@@ -44,35 +69,6 @@ module OpenTelemetry
|
|
44
69
|
rescue StandardError => e
|
45
70
|
OpenTelemetry.handle_error(exception: e)
|
46
71
|
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
|
-
# It seems that there are cases in Rails functional tests where it bypasses the routing system and the `action_dispatch.route_uri_pattern` header not being set.
|
57
|
-
# Our Test suite executes the routing system so we are unable to recreate this error case.
|
58
|
-
# https://github.com/rails/rails/blob/747f85f200e7bb2c1a31b4e26e5a5655e2dc0cdc/actionpack/lib/action_dispatch/http/request.rb#L160
|
59
|
-
http_route = request.route_uri_pattern&.chomp('(.:format)') if request.respond_to?(:route_uri_pattern)
|
60
|
-
|
61
|
-
attributes = {
|
62
|
-
OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]),
|
63
|
-
OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(payload[:action])
|
64
|
-
}
|
65
|
-
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_ROUTE] = http_route if http_route
|
66
|
-
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath
|
67
|
-
|
68
|
-
if @span_naming == :semconv
|
69
|
-
return ["#{request.method} #{http_route}", attributes] if http_route
|
70
|
-
|
71
|
-
return ["#{request.method} /#{payload.dig(:params, :controller)}/#{payload.dig(:params, :action)}", attributes]
|
72
|
-
end
|
73
|
-
|
74
|
-
["#{payload[:controller]}##{payload[:action]}", attributes]
|
75
|
-
end
|
76
72
|
end
|
77
73
|
end
|
78
74
|
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.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -75,10 +75,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
|
75
75
|
licenses:
|
76
76
|
- Apache-2.0
|
77
77
|
metadata:
|
78
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.12.
|
78
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.12.2/file/CHANGELOG.md
|
79
79
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/action_pack
|
80
80
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
81
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.12.
|
81
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-action_pack/0.12.2
|
82
82
|
post_install_message:
|
83
83
|
rdoc_options: []
|
84
84
|
require_paths:
|