Skip to content

Commit

Permalink
Merge pull request #971 from appsignal/refactor-sinatra-specs
Browse files Browse the repository at this point in the history
Refactor Sinatra spec to Transaction#to_h usage + bug fix
  • Loading branch information
tombruijn authored Jun 26, 2023
2 parents bb6fad1 + 5a4797c commit e19bad1
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 73 deletions.
6 changes: 6 additions & 0 deletions .changesets/fix-sinatra-request-custom-params-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "fix"
---

Fix Sinatra request custom request parameters method. If the Sinatra option `params_method` is set, a different method than `params` will be called on the request object to fetch the request parameters. This can be used to add custom filtering to parameters recorded by AppSignal.
5 changes: 3 additions & 2 deletions lib/appsignal/rack/sinatra_instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ def call(env)
end

def call_with_appsignal_monitoring(env)
env[:params_method] = @options[:params_method] if @options[:params_method]
options = { :force => @options.include?(:force) && @options[:force] }
options.merge!(:params_method => @options[:params_method]) if @options[:params_method]
request = @options.fetch(:request_class, Sinatra::Request).new(env)
transaction = Appsignal::Transaction.create(
SecureRandom.uuid,
Appsignal::Transaction::HTTP_REQUEST,
request,
:force => @options.include?(:force) && @options[:force]
options
)
begin
Appsignal.instrument("process_action.sinatra") do
Expand Down
Loading

0 comments on commit e19bad1

Please sign in to comment.