-
-
Save mitchellhenke/60eaea45c1a317fe26d39cf2452bb640 to your computer and use it in GitHub Desktop.
Scout HTTPoison Instrumentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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