Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsderek23/048eaf813af4a1a31a219d75221eb7b7 to your computer and use it in GitHub Desktop.
Save itsderek23/048eaf813af4a1a31a219d75221eb7b7 to your computer and use it in GitHub Desktop.
Scout HTTPoison Instrumentation
# Instruments HTTPoison calls.
#
# Example usage:
#
# defmodule DemoWeb.PageController do
# use DemoWeb, :controller
# alias Demo.HTTPClient
#
# def index(conn, _params) do
# case HTTPClient.get("https://cnn.com") do
# {:ok, %HTTPoison.Response{} = response} ->
# # do something with response
# # render(conn, "index.html")
# {:error, %HTTPoison.Error{} = error} ->
# # do something with error
# # render(conn, "error.html")
# end
# HTTPClient.post("https://cnn.com", "")
# HTTPClient.get!("http://localhost:4567")
# render(conn, "index.html")
# end
# end
defmodule Demo.HTTPClient do
use HTTPoison.Base
import ScoutApm.Tracing
def request(method, url, body \\ "", headers \\ [], options \\ []) do
timing("HTTP", method) do
update_desc(url)
super(method, url, body, headers, options)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment