Entry points
Flare files every error, log line and trace under the work that started it: a request, a job or a command. That's what you see next to each line in the log list, and what Flare uses to filter and group your errors, logs and traces. You don't call anything for it. Flare reads it from the spans your app already has.
How Flare picks the entry point
When your code reports an error or writes a log line, Flare looks at the spans around it and takes the closest one that describes a piece of work:
| Span | Entry point | Listed as |
|---|---|---|
The request span of the axum or Actix Web middleware, or any span with otel.kind = "server" and a url.full or url.path field |
a request | the method and the route, like GET /users/{id}. Without a route, the method and the path, like GET /users/7. |
A span with otel.kind = "consumer" |
a job | the name of the span, like handle_order_message |
A span with flare.span_type = "command" |
a command | the name of the span, like import |
Outside these spans, the entry point is your program itself: a command, listed under the name of the executable, like my-app.
The closest span wins, so a job that runs inside a command is still filed as a job.
Flare reads these spans with the tracing layer. That works whether a trace is sent or not: with traces_sample_rate at 0, every error and log line still gets its entry point.
Requests
The axum and Actix Web middleware take care of requests. Every error and log line in a handler is filed under its route, like GET /users/{id}. A request that matches no route, like a 404, is filed under its method and path.
Jobs
The span of a queue consumer is all Flare needs:
Rust
#[tracing::instrument(
parent = None,
skip_all,
fields(otel.kind = "consumer", messaging.destination.name = "orders"),
)]
async fn handle_order_message(delivery: Delivery) {
// Errors and log lines in here are filed under the job `handle_order_message`.
}
The job is listed under the name of the span. messaging.destination.name tells Flare which queue the job came from.
Commands
A command line tool that does one thing needs nothing: its errors and log lines are filed under the name of the executable. When your tool has subcommands, mark the function that runs each one:
Rust
#[tracing::instrument(skip_all, fields(flare.span_type = "command"))]
fn import(args: ImportArgs) {
// Errors and log lines in here are filed under the command `import`.
}
The span becomes a command in your traces too, so Flare lists each subcommand under Commands, grouped on its name. To list the command under another name than the function, add otel.name, like otel.name = "import orders".
Setting the entry point yourself
When your app doesn't use the Flare tracing layer, set the entry point on the scope instead:
Rust
use flareapp::EntryPoint;
flareapp::configure_scope(|scope| {
scope.set_entry_point(EntryPoint::current_process().handler_identifier("import"));
});
EntryPoint::current_process() is a command with the command line of your program, and handler_identifier is the name Flare lists it under. There's also EntryPoint::queue("send-invoice") for a job and EntryPoint::web(url) for a request you handle without the middleware. To give one job its own entry point, put it on the scope of that job, as in jobs and other async work.
Where you set it decides what wins. An entry point on the scope of one piece of work, set inside with_scope, with_flare_scope or a request of the middleware, wins over the spans. An entry point on the app-wide scope, like the one above, only counts when no span around the work has one. So a worker can set its own entry point when it starts, and each job still gets the entry point of its job span.
What Flare receives
Errors, log lines and the first span of each trace carry the entry point as attributes:
| Attribute | Request | Job | Command |
|---|---|---|---|
flare.entry_point.type |
web |
queue |
cli |
flare.entry_point.value |
the full URL | the queue name, or the span name without messaging.destination.name |
the command line |
flare.entry_point.handler.identifier |
GET /users/{id} |
the span name | the span name, or the name of the executable |
flare.entry_point.handler.type |
axum_route or actix_route when a route matched, otherwise none |
none | rust_command, or rust_binary for the executable |
The entry points page of the protocol docs explains how Flare uses each of them.
Read more
- Scopes: give a job or task its own user and context.
- Instrumenting your code: the spans for queue consumers and background work.