Skip to content

Commit ee144f7

Browse files
committed
Strip Rails (.:format) suffix from http.route
1 parent 98edff1 commit ee144f7

File tree

1 file changed

+2
-2
lines changed
  • instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers

1 file changed

+2
-2
lines changed

instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def finish(_name, _id, payload)
5353
# @return [Array<String, Hash>] the span name and attributes
5454
def to_span_name_and_attributes(payload)
5555
request = payload[:request]
56-
http_route = request.route_uri_pattern if request.respond_to?(:route_uri_pattern)
56+
http_route = request.route_uri_pattern.gsub('(.:format)', '') if request.respond_to?(:route_uri_pattern)
5757

5858
attributes = {
5959
OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]),
@@ -63,7 +63,7 @@ def to_span_name_and_attributes(payload)
6363
attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath
6464

6565
if @span_naming == :semconv
66-
return ["#{request.method} #{http_route.gsub('(.:format)', '')}", attributes] if http_route
66+
return ["#{request.method} #{http_route}", attributes] if http_route
6767

6868
return ["#{request.method} /#{payload.dig(:params, :controller)}/#{payload.dig(:params, :action)}", attributes]
6969
end

0 commit comments

Comments
 (0)