Skip to main content

Observability

Short version: structured logs, five OpenTelemetry metrics on GET /metrics, and no exported traces. cmd/api installs the OTel Prometheus exporter and mounts it on the same HTTP port as the API (there is no separate metrics port). internal/telemetry declares the instruments; the A2A adapter creates spans, but no tracer provider is installed, so none is recorded.

Metrics​

The instruments come from the global OTel MeterProvider under the scope github.com/claudioed/task-interleaving. cmd/api sets the provider with telemetry.PrometheusMetrics() and serves the result on GET /metrics (internal/adapters/inbound/http/server.go); the route is not part of apis/openapi.yaml. Only cmd/api installs the exporter: cmd/mcp, cmd/a2a, cmd/ti-projector and cmd/ti-reports expose no /metrics.

Instrument (OTel name)TypeUnitAttributesMeaning
taskinterleaving.hints.issuedcounter (int64)none (a count)siteHints issued to stations by the interleaving recommender. Counted when an InterleavingHintIssued fact is handed to the outbox event sink.
taskinterleaving.hints.consumedcounter (int64)none (a count)siteHints whose candidate the hinted station claimed (a HintConsumed fact).
taskinterleaving.hints.expiredcounter (int64)none (a count)siteHints that reached their expires_at unconsumed (a HintExpired fact, raised by the expiry worker).
taskinterleaving.recommender.durationhistogram (float64)snoneWall time of one recommender run, simulation or issuance alike. TimedRanker wraps every Rank call and records it whether the call succeeds or fails.
taskinterleaving.kafka.consumer.laghistogram (float64)sconsumer (fulfillment consumer or layout consumer)How far processing trails the CloudEvent time of a handled message (0 when the event carries no time). Recorded in Consumer.HandleMessage for messages whose type has a handler, just before the handler runs; an undecodable message or a type the consumer ignores records nothing.

The three hint counters are incremented by telemetry.CountingEventSink, which wraps the outbox event sink in cmd/api/adapters.go and counts each hint fact before delegating. telemetry.TimedRanker wraps the recommender in the same file. The instruments are created at package initialisation from the global meter, so they cost one call each and record nothing until the exporter is installed.

Series names as the Prometheus exposition renders them (read from a GET /metrics rendering of a recorded sample; counters gain _total and the second-unit histograms gain _seconds, with _bucket, _sum and _count):

SeriesLabels beyond otel_scope_*
taskinterleaving_hints_issued_totalsite
taskinterleaving_hints_consumed_totalsite
taskinterleaving_hints_expired_totalsite
taskinterleaving_recommender_duration_secondsnone
taskinterleaving_kafka_consumer_lag_secondsconsumer

GET /metrics also serves the Prometheus client's default collectors (go_* runtime series and process_* series) and a target_info series.

QuestionAnswerEvidence
OTLP exporter or OTEL_* variablesnonecmd/api reads only the variables in Configuration; metrics leave through /metrics only
HTTP server metrics (otelchi, otelhttp)none wiredotelhttp appears in go.mod as an indirect dependency only; no middleware uses it
Pod scrape annotationschart value metrics.prometheus.enabled, default falsecharts/task-interleaving/values.yaml; when on, the deployment renders prometheus.io/scrape, prometheus.io/path (/metrics) and prometheus.io/port (8080). warehouse-infra's helm-values/task-interleaving.yaml does not set it
Grafana dashboard for this contextexists, no panel on these metrics. warehouse-infra's scripts/gen-context-dashboards.py registers the context with business_metrics: [] on the comment "0 OTel instruments"; that comment is out of date, the code registers the five instruments above (checked on origin/develop: internal/telemetry/metrics.go, installed by cmd/api only)warehouse-infra terraform/dashboards/contexts/task-interleaving.json (uid warehouse-task-interleaving) has Kong request, error and latency rows, HTTP and Go-runtime rows and Loki log rows; none of its queries reads a taskinterleaving_* series
Alert rulesKong 5xx ratio, pod restarts, API availability and latency burnwarehouse-infra terraform/alerting/warehouse-alert-rules.json, groups warehouse-task-interleaving and warehouse-task-interleaving-slo; none uses a taskinterleaving_* series

Traces​

internal/adapters/inbound/a2a/skills.go starts one span per A2A skill call from the global tracer (a2a.skill <skill>, attribute a2a.skill, status Error when the skill answers a problem). No binary calls SetTracerProvider, so the global tracer is a no-op and no span is recorded or exported today. The HTTP router, the MCP server and the Kafka consumers create no span.

The only other OpenTelemetry code is in internal/adapters/outbound/postgres/outbox_repository.go: when an outbox row is inserted it injects the W3C trace context of the request context into the row's headers (traceparent, and tracestate / baggage when present) so a relay copy carries it onto the Kafka message. With no provider installed the context holds no span, so no trace header is ever written today; an integration test installs a propagator itself to prove the mechanism (outbox_integration_test.go). Kafka consumers do not extract a trace context.

Logs​

Logs are JSON (log/slog) on stdout, one object per line with time, level, msg and the fields below. The level comes from LOG_LEVEL (default info). There is no access log: the HTTP router has no request-logging middleware, so a successful request leaves no line. There are no correlation or trace-id fields.

WhereLevelmsg (abridged)Fields
BootINFOpostgres adapters configured, kafka topics (informational; the broker auto-creates them on first write, the service never creates them through an admin API)brokers, consumes, produces (the last two are the topic lists); topics play no part in /readyz
BootINFOhttp server listeningaddr
BootINFOconsumer runningconsumer (fulfillment consumer or layout consumer), topic, group_id, brokers
BootINFOoutbox relay runninginterval, max_attempts, brokers
BootINFOhint expiry worker runninginterval
Boot retryWARN / INFOretrying / succeeded after retryop (run migrations, ping postgres), attempt, in, err
BootWARNinvalid OUTBOX_RELAY_INTERVAL; using the default, invalid OUTBOX_MAX_ATTEMPTS; using the defaultvalue, default
Boot failureERRORservice exited with error (process exits 1)error
ShutdownINFO / WARNshutdown: readiness flipped to not-ready; waiting for traffic to drain / ignoring invalid SHUTDOWN_DRAIN_DELAY / worker did not stop before the shutdown drain deadlinedrain_delay / value, default / worker
ConsumerINFOevent processedtype, event_id, subject, outcome (applied, duplicate, stale, ignored)
ConsumerWARNskipping a message that is not a valid CloudEventconsumer, topic, error
ConsumerWARNdead-lettering an event that can never be applied / skipping an event that can never be appliedconsumer, type, event_id, error
ConsumerERROR<consumer> handling failed; retrying the same messageerror, partition, offset, attempt, max_attempts, retry_in
ConsumerERROR<consumer> handling failed after the maximum attempts; dead-lettering the message and <consumer> message can never be applied; dead-lettering it without retryerror, partition, offset (and attempts)
ConsumerERRORkafka reader error; retrying (kafka-go retrying a group join, a consumed topic that does not exist yet because its producer has not written, or an unreachable broker; without this logger it would be silent. Not a readiness failure: the consumer recovers by itself)consumer, topic, detail
ConsumerERROR<consumer> offset commit failed; retrying the same message, <consumer> dead-letter publish failed; retrying the same message, consumer stopped; restarting (the reader failed; the consumer runs again after 1 s), consumer close failederror, partition, offset, attempt, retry_in / consumer, restart_in
ReadinessWARNreadiness: dependency is not ready (once per round of checks, at most every 3 s)dependency (postgres or kafka), error (the cause)
RelayERRORoutbox relay pass failederror (text starts outbox row <id> (<type>):)
RelayERRORoutbox relay: row reached the attempt cap and is excluded from future claims; ...outbox_id, topic, event_type, key, attempts, max_attempts, error
RelayERRORoutbox relay stopped, kafka relay sink close failederror
Expiry workerINFOhints expiredexpired
Expiry workerERRORhint expiry sweep failed, hint expiry worker stoppedexpired, error
HTTPERRORrequest failed (an unmapped error, answered as 500 internal-error), handler panickederror or panic, method, path
HTTPWARNidempotency: answer not storederror

<consumer> is the consumer's name, fulfillment consumer or layout consumer (internal/adapters/inbound/kafka).

REST errors are application/problem+json documents whose type is https://errors.task-interleaving.warehouse-systems.dev/<slug>; the slug and status table is in Troubleshooting. The detail of an unmapped error is the fixed text an unexpected error occurred; the real error is only in the request failed log line.

Probes​

GET /healthz (liveness, always 200) and GET /readyz (200 only while Postgres answers and a Kafka broker answers a metadata request, never topics; 503 once shutdown starts or Postgres or the Kafka broker is unreachable) are described in the Runbook. The cause of a failed dependency is only in the WARN log line above; the response body names the dependency.

Suggested checks and alerts​

These are suggestions built from the data that exists, not alert rules that ship with the repo. The first rows below are log searches and SQL probes against the service database; the last rows use the metrics above.

SignalHow to read itSuggested alert
Outbox backlogSELECT count(*), min(created_at) FROM outbox_events WHERE published_at IS NULLoldest unpublished row older than a few minutes
ReadinessGET /readyz 503 with dependency-unavailable; WARN readiness: dependency is not readynot ready for more than a minute
Outbox rows stuck at the capSELECT id, event_type, last_error FROM outbox_events WHERE published_at IS NULL AND attempts >= 20 (use your OUTBOX_MAX_ATTEMPTS)any row; also the ERROR line row reached the attempt cap
Relay failinglog outbox relay pass failedrepeated for more than a minute
Consumer dead letterslogs dead-lettering at ERROR, and the depth of warehouse.fulfillment.events.dlq / warehouse.facility.events.dlqany message
Consumer stuck on one messagerepeated handling failed; retrying the same message with the same partition and offsetmore than the 5 attempts' worth, or consumer-group lag on the source topic
Stale hintsSELECT count(*) FROM hints WHERE state = 'Active' AND expires_at < now() - interval '1 minute'non-zero for several sweeps means the expiry worker is not running or failing (hint expiry sweep failed)
Boot loopservice exited with error and restartsany
5xxrequest failed / handler panickedany
Hint adoptionrate(taskinterleaving_hints_consumed_total[1h]) against rate(taskinterleaving_hints_expired_total[1h]), by sitesuggestion: a site whose hints are almost all expired (its policy or the pool is stale)
Recommender latencyhistogram_quantile(0.95, sum by (le) (rate(taskinterleaving_recommender_duration_seconds_bucket[5m])))suggestion: a sustained rise
Consumer laghistogram_quantile(0.95, sum by (le, consumer) (rate(taskinterleaving_kafka_consumer_lag_seconds_bucket[5m])))suggestion: lag growing without bound on one consumer
Table growthrow counts of outbox_events, idempotency_keys, processed_events (nothing deletes them)capacity planning, see the Runbook

No instrument covers the outbox backlog and age, consumer outcomes or HTTP request duration yet; use the SQL probes and log lines above for those.