BuildkiteTestCollector.Tracing (buildkite_test_collector v0.3.1)
Helpers for doing simple tracing in your tests.
Summary
Functions
Measure the execution time of a function and add a trace to the test analytics.
Types
@type section() :: :http | :sql | :sleep | :annotation
Valid trace types.
See the documentation for more information.
ExUnit test tags (specifically the module
and test
tags).
These are used to uniquely identify the test being executed.
Functions
Measure the execution time of a function and add a trace to the test analytics.
Example
alias BuildkiteTestCollector.Tracing
test "it can measure an HTTP request", tags do
assert {:ok, _} =
Tracing.measure(tags, :http, "The koan of Github", fn ->
Tesla.get("https://api.github.com/zen", headers: [{"user-agent", "Tesla"}])
end)
end
test "it can measure a SQL query", tags do
import Ecto.Query
query =
from(tt in "time_travellers",
where: tt.born >= 1968 and tt.born <= 1970,
select: tt.name,
order_by: tt.name
)
assert {:ok, ["Marty McFly", "Theodore Logan, III", "William Stanley Preston, Esq."]} =
Tracing.measure(tags, :sql, inspect(query), fn ->
MyApp.all(query)
end)
end