Skip to content

Commit

Permalink
Add response status codes to Plug samples
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkreeftmeijer committed Jan 28, 2019
1 parent 4608f36 commit 1fc1329
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/appsignal/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ if Appsignal.plug?() do
|> Enum.into(%{})
end

def extract_meta_data(%Plug.Conn{method: method, request_path: path} = conn) do
def extract_meta_data(%Plug.Conn{method: method, request_path: path, status: status} = conn) do
request_id =
conn
|> Plug.Conn.get_resp_header("x-request-id")
Expand All @@ -150,7 +150,8 @@ if Appsignal.plug?() do
%{
"method" => method,
"path" => path,
"request_id" => request_id
"request_id" => request_id,
"status" => status
}
end

Expand Down
6 changes: 4 additions & 2 deletions test/appsignal/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,13 @@ defmodule Appsignal.PlugTest do
assert Appsignal.Plug.extract_meta_data(%Plug.Conn{
method: "GET",
request_path: "/foo",
resp_headers: [{"x-request-id", "kk4hk5sis7c3b56t683nnmdig632c9ot"}]
resp_headers: [{"x-request-id", "kk4hk5sis7c3b56t683nnmdig632c9ot"}],
status: 200
}) == %{
"method" => "GET",
"path" => "/foo",
"request_id" => "kk4hk5sis7c3b56t683nnmdig632c9ot"
"request_id" => "kk4hk5sis7c3b56t683nnmdig632c9ot",
"status" => 200
}
end
end
Expand Down

0 comments on commit 1fc1329

Please sign in to comment.