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