OeditusCredo.Check.Warning.MissingTelemetryForExternalHttp
(OeditusCredo v0.6.1)
View Source
Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of normal and works with any version of Elixir.
Explanation
External HTTP requests should be wrapped with telemetry for observability.
Instrumenting HTTP client calls helps track external API latency, failure rates, and can help identify third-party service issues.
Bad:
def fetch_user_data(user_id) do
Req.get!("https://api.example.com/users/#{user_id}")
endGood:
def fetch_user_data(user_id) do
url = "https://api.example.com/users/#{user_id}"
:telemetry.span(
[:http, :request],
%{method: :get, url: url},
fn ->
result = Req.get!(url)
{result, %{status: result.status}}
end
)
endThis check detects calls to common HTTP clients: Req, HTTPoison, Finch, Tesla, :httpc
Check-Specific Parameters
Use the following parameters to configure this check:
:exclude_test_files
Set to true to skip test files (default: false)
This parameter defaults to nil.
:extra_http_modules
Additional HTTP client tuples {module_parts, [functions]} to check (default: [])
This parameter defaults to nil.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.