From fa314b5fb6fdfbf3e9746df377b0145cde0cfa36 Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Mon, 2 Sep 2024 12:31:17 +0200 Subject: [PATCH] Rename the path and method transaction metadata (#1275) The `path` and `method` metadata naming was a bit confusing. Add the `request_` prefix to make clear it's about the request. We can remove the old context in the next major/minor version. --- .../rename-path-and-method-transaction-metadata.md | 6 ++++++ lib/appsignal/rack.rb | 11 +++++++++-- spec/lib/appsignal/integrations/puma_spec.rb | 2 ++ spec/lib/appsignal/rack/abstract_middleware_spec.rb | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .changesets/rename-path-and-method-transaction-metadata.md diff --git a/.changesets/rename-path-and-method-transaction-metadata.md b/.changesets/rename-path-and-method-transaction-metadata.md new file mode 100644 index 00000000..83fb1855 --- /dev/null +++ b/.changesets/rename-path-and-method-transaction-metadata.md @@ -0,0 +1,6 @@ +--- +bump: patch +type: change +--- + +Rename the `path` and `method` transaction metadata to `request_path` and `request_method` to make it more clear what context this metadata is from. The `path` and `method` metadata will continue to be reported until the next major/minor version. diff --git a/lib/appsignal/rack.rb b/lib/appsignal/rack.rb index 56bd93c1..a6d59c7a 100644 --- a/lib/appsignal/rack.rb +++ b/lib/appsignal/rack.rb @@ -48,10 +48,17 @@ def initialize(request, options = {}) end def apply_to(transaction) - transaction.set_metadata("path", request.path) + request_path = request.path + transaction.set_metadata("request_path", request_path) + # TODO: Remove in next major/minor version + transaction.set_metadata("path", request_path) request_method = request_method_for(request) - transaction.set_metadata("method", request_method) if request_method + if request_method + transaction.set_metadata("request_method", request_method) + # TODO: Remove in next major/minor version + transaction.set_metadata("method", request_method) + end transaction.add_params { params_for(request) } transaction.add_session_data { session_data_for(request) } diff --git a/spec/lib/appsignal/integrations/puma_spec.rb b/spec/lib/appsignal/integrations/puma_spec.rb index f77114b1..39dea34a 100644 --- a/spec/lib/appsignal/integrations/puma_spec.rb +++ b/spec/lib/appsignal/integrations/puma_spec.rb @@ -76,7 +76,9 @@ def lowlevel_error(error, env, status = nil) lowlevel_error(error, env) expect(last_transaction).to include_metadata( + "request_method" => "GET", "method" => "GET", + "request_path" => "/some/path", "path" => "/some/path" ) expect(last_transaction).to include_environment( diff --git a/spec/lib/appsignal/rack/abstract_middleware_spec.rb b/spec/lib/appsignal/rack/abstract_middleware_spec.rb index 2fcbf702..e51bb02d 100644 --- a/spec/lib/appsignal/rack/abstract_middleware_spec.rb +++ b/spec/lib/appsignal/rack/abstract_middleware_spec.rb @@ -171,7 +171,9 @@ def make_request_with_error(error_class, error_message) make_request expect(last_transaction).to include_metadata( + "request_method" => "GET", "method" => "GET", + "request_path" => "/some/path", "path" => "/some/path" ) expect(last_transaction).to include_environment(