Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response status codes to Plug samples #452

Merged
merged 1 commit into from
Jan 28, 2019
Merged

Conversation

jeffkreeftmeijer
Copy link
Member

@jeffkreeftmeijer jeffkreeftmeijer commented Jan 28, 2019

Like appsignal/appsignal-ruby#183, but for Elixir. As requested via support (private Intercom link). Opening this pull request instead of an issue since the implementation was mostly done answering their question.

I recommend tagging samples manually until we merge this. That would look something like this;

defmodule AppsignalPhoenixExampleWeb.PageController do
  use AppsignalPhoenixExampleWeb, :controller

  def index(conn, _params) do
    conn = render(conn, "index.html")
    Appsignal.Transaction.set_sample_data("tags", %{status: to_string(conn.status)})
    conn
  end
end

When using the temporary solution: Some things to note is to update the conn with the result of your render/2 call to make sure the response code is set. Also; don’t forget to return the conn from your action, as Appsignal.Transaction.set_sample_data/2 returns the Appsignal.Transaction struct.

@@ -150,7 +150,8 @@ if Appsignal.plug?() do
%{
"method" => method,
"path" => path,
"request_id" => request_id
"request_id" => request_id,
"status" => status
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is status descriptive enough in the context of an AppSignal transaction? (for when it can be jobs etc)
Would status_code or http_status/http_status_code make more sense in the AppSignal.com UI?

Copy link
Member

@tombruijn tombruijn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise the code looks good! Tested it and it works 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants