howdy/telemetry/recorder
Recent traces and log lines, held in memory for the dev admin.
let recorder = recorder.new(keep: 200)
let assert Ok(Nil) =
telemetry.new("acme-web")
|> telemetry.record(recorder)
|> telemetry.start
admin.new()
|> admin.telemetry(recorder)
A trace is kept from the moment its root span ends, the request in most
cases, until keep newer traces have arrived. Spans whose root never
ends here are dropped after a few minutes. The last 2,000 log lines are
kept, with the trace they were logged in.
The tables belong to a process that exits with the process that called
new, so make the recorder in main.
Types
pub type Log {
Log(
at: Int,
level: String,
message: String,
trace_id: option.Option(String),
span_id: option.Option(String),
)
}
Constructors
-
Log( at: Int, level: String, message: String, trace_id: option.Option(String), span_id: option.Option(String), )
A finished span. Times are in microseconds: start since the Unix
epoch, duration from start to end.
pub type Span {
Span(
trace_id: String,
span_id: String,
parent_id: option.Option(String),
name: String,
kind: trace.Kind,
start: Int,
duration: Int,
attributes: List(#(String, Value)),
events: List(Event),
links: List(#(String, String)),
status: Status,
scope: String,
)
}
Constructors
-
Span( trace_id: String, span_id: String, parent_id: option.Option(String), name: String, kind: trace.Kind, start: Int, duration: Int, attributes: List(#(String, Value)), events: List(Event), links: List(#(String, String)), status: Status, scope: String, )Arguments
- links
-
The trace and span ids of the spans this one links to.
- scope
-
The library that opened the span, such as
howdyorpgo.
pub type Status {
Unset
Succeeded
Failed(message: String)
}
Constructors
-
Unset -
Succeeded -
Failed(message: String)
Values
pub fn attribute(span: Span, key: String) -> option.Option(Value)
The value of the attribute key on span, if it has one.
pub fn logs(recorder: Recorder, trace_id: String) -> List(Log)
The log lines written while the trace with id trace_id ran.
pub fn recent_logs(
recorder: Recorder,
limit limit: Int,
) -> List(Log)
The last limit log lines, oldest first.
pub fn trace(
recorder: Recorder,
trace_id: String,
) -> Result(List(Span), Nil)
Every span of the trace with id trace_id, earliest first.
pub fn traces(
recorder: Recorder,
limit limit: Int,
) -> List(Trace)
Up to limit traces, newest first.
pub fn value_to_string(value: Value) -> String
A value as text, the way the admin shows it.