Skip to content

Commit

Permalink
Set request metadata in middleware via helpers
Browse files Browse the repository at this point in the history
Do not rely on the transaction's request object handling, but set the
request metadata using our helpers.

This follows our new pattern of how our instrumentation sets data on
transactions.
  • Loading branch information
tombruijn committed Jul 10, 2024
1 parent 1663deb commit 468d947
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/appsignal/rack/abstract_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def call(env)
Appsignal::Transaction.create(
SecureRandom.uuid,
Appsignal::Transaction::HTTP_REQUEST,
request
Appsignal::Transaction::GenericRequest.new({})
)
end

Expand Down Expand Up @@ -148,6 +148,12 @@ def add_transaction_metadata_after(transaction, request)
transaction.set_metadata("method", request_method) if request_method

transaction.set_params_if_nil { params_for(request) }
transaction.set_session_data_if_nil do
request.session if request.respond_to?(:session)
end
transaction.set_headers_if_nil do
request.env if request.respond_to?(:env)
end
queue_start = Appsignal::Rack::Utils.queue_start_from(request.env)
transaction.set_queue_start(queue_start) if queue_start
end
Expand Down

0 comments on commit 468d947

Please sign in to comment.