Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sentry-rails/lib/sentry/rails/controller_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def sentry_around_action
data_collection = Sentry.configuration.data_collection

path = request.path
query_parameters = request.query_parameters
query_parameters = request.query_parameters rescue nil

if query_parameters.is_a?(Hash)
filtered_query_parameters = data_collection.url_query_params.filter(query_parameters)
Expand All @@ -43,7 +43,7 @@ def sentry_around_action
child_span.set_data(:path, path)

# all params request + body
params = request.params
params = request.params rescue nil
if params.is_a?(Hash)
filtered_params = data_collection.url_query_params.filter(params)
child_span.set_data(:params, filtered_params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def show
render plain: p.id
end

def webhook
request.raw_post
head :ok
end

def attach
p = Post.find(params[:id])

Expand Down
17 changes: 16 additions & 1 deletion sentry-rails/spec/sentry/rails/tracing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@
before do
expect(described_class).to receive(:subscribe_tracing_events).and_call_original

make_basic_app do |config|
make_basic_app do |config, app|
config.traces_sample_rate = 1.0
app.routes.append do
post "/malformed", to: "posts#webhook"
end
end
end

it "does not replace a response when request parameters cannot be parsed" do
skip "Rails parses request parameters before controller callbacks" if Rails::VERSION::MAJOR < 6

response = Rack::MockRequest.new(Rails.application).post(
"/malformed",
input: "not json",
"CONTENT_TYPE" => "application/json"
)

expect(response.status).to eq(200)
end

it "records transaction with exception" do
get "/posts"

Expand Down
Loading