8000 Descriptive spans, OpenTelemetry trace context and more metrics (0.2.5) by arminhammer · Pull Request #58 · arminhammer/jackdaw · GitHub
[go: up one dir, main page]

Skip to content

Descriptive spans, OpenTelemetry trace context and more metrics (0.2.5) - #58

Merged
arminhammer merged 7 commits into
mainfrom
span-names
Nov 10, 2026
Merged

arminhammer merged 7 commits into
mainfrom
span-names

Conversation

@arminhammer
Copy link
Copy Markdown
Owner

Why

In Grafana every jackdaw span was named step (or workflow), so a 240-step trace was a wall of identical rows, and you had to open each span to see what it was. Only two spans existed, the YAML engine had none, and several paths ran with no span at all.

What changes

Span names. Every span sets otel.name, which tracing-opentelemetry exports as the span name. A trace now reads workflow shop/order@1, call charge, attempt 2, retry backoff 200ms, sleep 1h, run shipping, HTTP POST pay.example. The tracing names and existing fields stay.

More spans, and more context on them:

  • The step span now covers the whole step, from TaskStarted to its journal write and TaskCompleted. It records seq, ordinal, key, call site, outcome, timeout, cache hit, child instance id and payload sizes.
  • Under a step: attempt, retry backoff, limit wait and persist journal spans. Task code now logs inside its attempt span.
  • A single replay span covers the steps replayed on resume, with one event per step.
  • Signals, updates, queries, events, schedule ticks, lease renewal, recovery, replay checks each get a span.
  • YAML engine: a workflow span, a span per task nested as in the workflow (with its JSON pointer as task.reference), and a span per for iteration.
  • Executor (client) spans: HTTP with method, URL without query, and status; scripts; shell commands; containers.
  • Listener (server) spans for HTTP and gRPC requests.
  • Every Event is logged in the span it happened in, so it shows as a span event.
  • Failures set otel.status_code = ERROR, error.type and exception.message.
  • Fields that change are recorded once with their final value, because trace backends keep every value an attribute is given (tests/otel_export.rs checks for duplicates).

Parent/child fixes:

  • A child workflow now sits under the step that runs it on purpose, not by accident.
  • ctx.start and recovered instances get traces of their own, linked to the span that started them.
  • The span and subscriber now follow blocking store calls (Redb) and script output readers.

Payloads: EngineBuilder::trace_payloads(max_bytes) puts truncated step inputs and outputs on spans. It is off by default, since payloads can hold sensitive data.

Feature otel: a listener request with a W3C traceparent header continues the caller's trace, and ctx.http / YAML call: http carry the current trace on. It uses the propagator the application installs; the library still installs nothing.

Metrics: workflow duration, running and resumed instances, continue-as-new, step outcome and timeouts, replayed steps, attempt duration, heartbeat timeouts, cache hits and misses, limit waits, active tasks, store latency and errors (by store type), leases, delivered messages, emitted events, schedule ticks and lag, replay divergences, listener requests, and jq evaluations. Both engines report them. Labels never carry instance ids.

CLI: j 8000 ackdaw run --otlp-endpoint URL sends traces over OTLP/HTTP, and --metrics-addr ADDR serves Prometheus /metrics with histogram buckets. Both are behind the default telemetry feature.

Other:

  • Fixes a race where a YAML run's TaskStarted could be reported before its WorkflowStarted.
  • Version bumped to 0.2.5. Adds a guide chapter, guide::observability, covering spans, fields, metrics and Grafana TraceQL/PromQL examples, and a CHANGELOG entry.

Behaviour changes to note

  • Task code logs are now inside an attempt span, which is a child of the step span (it used to log directly in the step span).
  • jackdaw_step_duration_seconds gains an outcome label.
  • A workflow started with ctx.start no longer appears inside its starter's trace. It has its own trace, linked to the starter.

Testing

  • 16 new cucumber scenarios in operations/observability.feature, 17 with the updated existing ones: span names, attempt and backoff spans, events as span events, error status, the replay span, payloads on and off, the start trace, continue-as-new runs, the YAML task tree, and metrics.
  • tests/otel_export.rs runs a real tracing-opentelemetry pipeline with an in-memory exporter. It checks exported names, parent links, status, span events, no duplicate attributes, and traceparent continuation through an HTTP listener.
  • cargo clippy is clean for --all-features --all-targets, default features, --no-default-features, otel alone, wasm32-wasip2, and the CLI with and without telemetry.
  • Checked by hand: jackdaw run against a local OTLP receiver received the expected span names and service.name, and /metrics served the new series as histograms.
  • Full cargo test --workspace --all-features: everything passes except a few flaky scenarios under full parallel load:
    • config.feature "same id with other input is refused unless restarted" fails on main too (4 of 10 runs in isolation). The purge sees the finished instance still in memory, because it is published before it is forgotten.
    • The YAML "purged and its id used again" scenario looks like the same race, and "a crash during compensation" timed out once. Both passed 8 of 8 in isolation on this branch.

🤖 Generated with Claude Code

arminhammer and others added 6 commits November 10, 2026 16:06
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spans now set otel.name, so a trace viewer shows what each span did
(`call charge`, `sleep 5s`, `attempt 2`, `for items`) instead of
`step` everywhere, and carry the context to drill down:

- workflow span: name, version, engine, run, parent instance, outcome
  and error status
- step span: covers the whole live step (TaskStarted to its record and
  TaskCompleted), with seq, ordinal, key, call site, timeout, outcome,
  cache hit, child instance id and payload sizes
- attempt, retry backoff, limit wait and persist spans under a step
- one replay span per resume, with an event per replayed step
- spans for signals, updates, queries and events sent to an instance,
  schedule ticks, lease renewal, recovery and replay checks
- every Event is logged in the span it happened in
- ctx.start and recovered instances get traces of their own
- YAML engine: workflow span, a span per task (nested as in the
  workflow, with its JSON pointer), a span per for-loop iteration
- the span and subscriber now follow blocking calls (Redb stores) and
  script output readers
- EngineBuilder::trace_payloads(max_bytes) puts truncated step inputs
  and outputs on spans (off by default)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- executor spans for HTTP calls (method, URL without query, status),
  scripts, shell commands and containers, in both engines
- request spans for HTTP and gRPC listeners (SERVER kind, route, status)
- feature `otel`: a request carrying a W3C traceparent continues the
  caller's trace, and HTTP calls carry the current one on, through the
  propagator the application installs
- every store call is timed (debug span, latency and error metrics),
  and the YAML engine's events are logged in the span they happen in
- metrics: workflow duration, running and resumed instances,
  continue-as-new, step outcome and timeouts, replayed steps, task
  attempts, heartbeat timeouts, cache hits, limit waits, active tasks,
  persistence, leases, messages, emitted events, schedule ticks and lag,
  replay divergences, listener requests, jq evaluations
- fields that change are recorded once, with their final value, since
  trace backends keep every value an attribute is given
- tests/otel_export.rs checks what an OpenTelemetry exporter receives

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`jackdaw run --otlp-endpoint URL` (or OTEL_EXPORTER_OTLP_ENDPOINT) sends
spans to an OpenTelemetry collector over OTLP/HTTP as service `jackdaw`,
with W3C trace context as the propagator; JACKDAW_OTLP_FILTER picks the
spans (default info). `--metrics-addr ADDR` serves the engine's metrics
at /metrics, with histogram buckets for the *_seconds metrics. Both are
behind the CLI's `telemetry` feature, on by default.

The persistence metrics' `backend` label now names the store
(RedbPersistence, ...) rather than the trait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mirror of a YAML run read task events from the store before taking
the run's opening event from its channel, and its poll tick raced the
channel, so TaskStarted could be reported before WorkflowStarted. The
channel now comes first, and the store is read once the opening event
is in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arminhammer
arminhammer merged commit 2938732 into main Nov 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0