Skip to content

Commit

Permalink
Add a comment to grape endpoint explaining route format removal
Browse files Browse the repository at this point in the history
  • Loading branch information
y9v committed Sep 17, 2024
1 parent 7317018 commit c62c24d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/datadog/tracing/contrib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ def endpoint_start_process(_name, _start, _finish, _id, payload)
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_ENDPOINT_RUN)

if (grape_route = env['grape.routing_args']) && grape_route[:route_info]
puts '=' * 80
puts grape_route[:route_info].path
puts '=' * 80
trace.set_tag(
Tracing::Metadata::Ext::HTTP::TAG_ROUTE,
# here we are removing the format from the path:
# e.g. /path/to/resource(.json) => /path/to/resource
# e.g. /path/to/resource(.:format) => /path/to/resource
grape_route[:route_info].path&.gsub(/\(\.:?\w+\)\z/, '')
)

Expand Down

0 comments on commit c62c24d

Please sign in to comment.