Skip to content

feat(telemetry): add queue health snapshots - #41

Merged
elpete merged 8 commits into
mainfrom
feat/worker-health-adapter
Oct 25, 2026
Merged

elpete merged 8 commits into
mainfrom
feat/worker-health-adapter

Conversation

@elpete

@elpete elpete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Add provider-owned queue-health snapshots without a Sentry dependency or a default backend.

Choose a worker pool for worker activity plus its queue backlog, or a connection for backlog without local workers. Companion to Sentry #56, which uses one automaticCollectors.queues list:

// Configure periodic collection in Sentry.
moduleSettings.sentry.automaticCollectors = {
    // Start the sampler; the application also needs a valid DSN and enableMetrics=true.
    enabled: true,
    // One provider-neutral list for queue and worker measurements.
    queues: [ {
        // Fixed logical metric label, independent of cbq identifiers.
        name: "mail",
        // Explicit provider-owned implementation.
        adapter: "QueueHealthAdapter@cbq",
        // Choose worker activity plus backlog from this cbq worker pool.
        options: {
            // Its connection/provider and queue selection determine the snapshot.
            workerPool: "outbound"
        }
    } ]
};

For queue backlog without a worker pool:

// Use the same collector with a connection-only source.
moduleSettings.sentry.automaticCollectors.queues = [ {
    // Fixed logical metric label.
    name: "mail",
    // Provider-owned snapshot implementation.
    adapter: "QueueHealthAdapter@cbq",
    // Select storage and queues without collecting shared worker activity.
    options: {
        // Registered cbq connection; its provider owns table/datasource settings.
        connection: "database",
        // Optional string, array or wildcard; omit to use the connection's default queue.
        queue: "mail"
    }
} ];

Configure exactly one of workerPool or connection. The adapter resolves it freshly on every sample. Worker-pool selection uses that worker pool's connection and queue string/array/wildcard unless options.queue overrides backlog selection. Connection-only snapshots use the connection's default queue when no override is given and never include worker fields. Missing, blank, nonsimple, ambiguous and legacy options.pool selections raise cbq.Telemetry.InvalidQueueHealthSelection; a metric label never chooses a source.

DBProvider.getQueueHealth() owns the configured table, datasource/query options and parameterized aggregate through DatabaseQueueSnapshot. It reads pending depth/oldest age, runnable/delayed work and reserved/stale leases without reserving jobs or starting workers. Providers without queue-snapshot support retain supported worker fields, or return an empty connection-only snapshot. Missing capabilities stay absent, and sampling errors propagate rather than becoming zero.

The adapter follows sample(context) without importing a Sentry interface. WorkerHealthAdapter@cbq remains an alias, and samplePool(pool) remains available for existing manual worker-only calls. Worker measurements describe the whole worker pool even when options.queue narrows backlog; use connection-only snapshots for extra per-queue breakdowns to avoid duplicating shared worker activity. No package/lock changes; selecting the mapping requires a cbq release containing this change.

Checks

  • All 13 checks passed on 107f2b1 against main, including the full Lucee 5/6 and Adobe 2021/2023/2025 matrix and real MySQL snapshots. Hosted CI
  • The 14 adapter specs passed locally on Lucee 5, Adobe 2023 and BoxLang with zero failures/errors/skips.
  • Companion Sentry coverage passed 141/141 on all three local engines, including real PostgreSQL/cbq workers, backlog/age/lease state and connection-only snapshots.
  • Independent code and CFML/BoxLang review passed. Formatting and whitespace checks passed.
  • Updated the branch from main and preserved its isolated provider fixture for dialect compilation, so pretend queries cannot affect application-provider teardown.

This is an additive minor release for cbq 7.1.0. The Ortus documentation update is cbq docs #2.

Local proof uses prepared runtimes. Actual worker heartbeats, process-crash recovery, non-database provider snapshots and real Sentry delivery/indexing remain outside this change.

@elpete elpete changed the title Add a provider-owned worker health snapshot adapter Add provider-owned queue health snapshots Oct 24, 2026
@elpete elpete changed the title Add provider-owned queue health snapshots feat(telemetry): add queue health snapshots Oct 25, 2026
@elpete
elpete changed the base branch from next to main October 25, 2026 19:37
@elpete
elpete marked this pull request as ready for review October 25, 2026 19:43
@elpete
elpete merged commit 6812c15 into main Oct 25, 2026
13 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