Skip to content

Commit a261bdf

Browse files
committed
squash: tests and more docs
1 parent 529a87e commit a261bdf

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

instrumentation/action_pack/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ See the table below for details of what [Rails Framework Hook Events](https://gu
4646

4747
This instrumentation generally uses [HTTP server semantic conventions](https://opentelemetry.io/docs/specs/semconv/http/http-spans/) to update the existing Rack span.
4848

49-
For Rails 7.1+, the span name is updated to match the HTTP method and route that was matched for the request using [`ActionDispath::Request#route_uri_pattern`](https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-route_uri_pattern), e.g.: `GET /users/(:id)`
49+
For Rails 7.1+, the span name is updated to match the HTTP method and route that was matched for the request using [`ActionDispath::Request#route_uri_pattern`](https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-route_uri_pattern), e.g.: `GET /users/:id`
5050

5151
For older versions of Rails the span name is updated to match the HTTP method, controller, and action name that was the tartget of the request, e.g.: `GET /example/index`
5252

instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module ActionPack
2020
#
2121
# Specifies how the span names are set. Can be one of:
2222
#
23-
# - `:semconv` **(default)** - The span name will use HTTP semantic conventions '{method http.route}', for example `GET /users/(:id)`
23+
# - `:semconv` **(default)** - The span name will use HTTP semantic conventions '{method http.route}', for example `GET /users/:id`
2424
# - `:class` - The span name will appear as '<ActionController class name>#<action>',
2525
# for example `UsersController#show`.
2626
#

instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,36 @@
142142
describe 'span naming' do
143143
describe 'when using the default span_naming configuration' do
144144
describe 'successful requests' do
145-
it 'uses the http method controller and action name' do
146-
skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version >= Gem::Version.new('7.1')
147-
get '/ok'
145+
describe 'Rails Version < 7.1' do
146+
it 'uses the http method controller and action name' do
147+
skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version >= Gem::Version.new('7.1')
148+
get '/ok'
149+
150+
_(span.name).must_equal 'GET /example/ok'
151+
end
152+
153+
it 'excludes route params' do
154+
skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version >= Gem::Version.new('7.1')
155+
get '/items/1234'
148156

149-
_(span.name).must_equal 'GET /example/ok'
157+
_(span.name).must_equal 'GET /example/item'
158+
end
150159
end
151160

152-
it 'uses the Rails route' do
153-
skip "Rails #{Rails.gem_version} does not define ActionDispatch::Request#route_uri_pattern" if Rails.gem_version < Gem::Version.new('7.1')
154-
get '/ok'
161+
describe 'Rails Version >= 7.1' do
162+
it 'uses the Rails route' do
163+
skip "Rails #{Rails.gem_version} does not define ActionDispatch::Request#route_uri_pattern" if Rails.gem_version < Gem::Version.new('7.1')
164+
get '/ok'
165+
166+
_(span.name).must_equal 'GET /ok'
167+
end
168+
169+
it 'includes route params' do
170+
skip "Rails #{Rails.gem_version} does not define ActionDispatch::Request#route_uri_pattern" if Rails.gem_version < Gem::Version.new('7.1')
171+
get '/items/1234'
155172

156-
_(span.name).must_equal 'GET /ok'
173+
_(span.name).must_equal 'GET /items/:id'
174+
end
157175
end
158176
end
159177

0 commit comments

Comments
 (0)