Micrometer Observation
One Observation per task execution — a timer and a trace span from a single instrumentation.
One Observation per task execution — a timer and a trace span from a single instrumentation.
Optional dependency: io.micrometer:micrometer-observation (the SDK compiles
against it as compileOnly; add it to your build). FlexiQObservation is a
middleware that wraps each task
execution in a Micrometer Observation — one instrumentation that yields both
metrics (a timer) and a trace span, exported by whatever handlers your
ObservationRegistry is configured with.
import org.byteveda.flexiq.contrib.FlexiQObservation;
flexiq.use(new FlexiQObservation(registry));Each execution attempt starts an observation named flexiq.task with the
low-cardinality key value flexiq.task = the task name. On success the
observation stops cleanly; when the handler throws, the exception is recorded
on the observation before it stops. A retry is a new attempt, so it produces a
new observation.
The three-argument constructor customizes the observation name and filters tasks:
flexiq.use(new FlexiQObservation(
registry,
"app.job", // observation name (default "flexiq.task")
task -> !task.startsWith("internal."))); // Predicate<String> task filter| Parameter | Type | Default | Description |
|---|---|---|---|
registry | ObservationRegistry | — | The registry your app configures |
name | String | "flexiq.task" | Observation (and derived timer/span) name |
taskFilter | Predicate<String> | all tasks | Return false to skip a task |
FlexiQObservation creates observations; it never configures exporters. Wire
the registry to your backends the standard Micrometer way — a
DefaultMeterObservationHandler over your MeterRegistry (Prometheus,
Datadog, ...) for metrics, and a micrometer-tracing bridge (OpenTelemetry,
Brave) for spans. In a Spring Boot app with Actuator, inject the
auto-configured ObservationRegistry and both come pre-wired.
Because metrics and traces derive from the same Observation, you instrument once and choose backends per environment — no flexiq-specific exporter configuration exists or is needed.