Move the RequestCompleted dispatch and usage-metrics publishing out of the
large shared shutdown hook into a dedicated Http::shutdown() hook that
injects only what it needs (request, response, project, user, usage,
publisherForUsage, authorization, bus, apiKey). Drop the now-unused
usage/publisherForUsage/bus/apiKey/authorization injections from the main
hook. Registered after the cache hook so cache writes keep happening
before usage publishing, as in the original single-hook ordering.
Also tighten the cache hook with guard clauses: hoist the cache/key/
signature setup, make the create path save-and-return explicitly instead
of relying on the empty-document signature mismatch, resolve the resource
labels lazily inside the create branch (so the param reconstruction and
label parsing only run on a cache miss, not on every cached hit), and
collapse the trailing save into the existing-entry path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
audits.resource labels only reference URL path params (resource IDs), so
the audit code can use the injected 'params' local directly instead of
reconstructing the full resolved param set. The path+query/body+default
reconstruction now lives only in the cache hook, where the screenshot
cache.resource label genuinely needs query params.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move the cache.resource / cache.resourceType handling out of the large
shared shutdown hook into a dedicated Http::shutdown() hook in the 'api'
group. It injects only what caching needs (route, params, request,
response, project, user, dbForProject, authorization) and guards with
early returns, leaving the main hook focused on events, audit, and usage.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use Request::getParam() for the query/body+default fallback instead of a
cached getParams() copy, dropping the temporary and shortening the diff.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The http server exposes the route's path values as an injectable 'params'
local, so inject it directly rather than rebuilding them via
Router::preparePath() + Route::getPathValues(). Query/body params and
declared defaults are still merged in to reproduce the full resolved
param set (path values take precedence), matching prior getParamsValues()
behaviour.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reconstruct request param values from per-request sources (path values +
request params + param defaults) instead of reading the deprecated
mutable value store on the shared Route object, mirroring the
framework's own Http::getArguments() resolution precedence.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Revert to the original swallow-and-continue: a failed batch delete is
recorded on the span and skipped so the remaining cleanups still run.
Drops the attemptAll helper and restores deleteCollection's sequential
calls for a minimal diff.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the inline cleanup array + accumulator loop with a small
variadic attemptAll() helper, so deleteCollection reads as the intent:
run all cleanups, rethrow the first failure.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Dropping the deleteByGroup swallow meant a failure in the first cleanup
(related-attribute purge) skipped the attribute and index cleanups,
leaving orphaned metadata rows since the table was already dropped.
Run every cleanup in deleteCollection regardless of individual failures,
then rethrow the first error so the worker still marks the message failed
and retries the outstanding work.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The project resource setter is the canonical owner of project.id (cloud
already adds it there for every worker span). Add it to the OSS worker
project resource too, and drop the redundant project.id from the
database worker. Also drop queue.pid/queue.name/message.timestamp:
queue.name duplicates the span action (worker.databases) and none were
part of the logging this PR replaced.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously a failed batch delete was caught and swallowed, acking the
message as if it succeeded even though the documents remained. Let the
error propagate so the worker marks the message failed and retries.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
These describe the project database connection and apply to every
operation, so trace them up front in action() (from dbForProject, which
deleteByGroup always uses) rather than inside deleteByGroup.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Identifiers end in .id by convention; rename delete_by_group.collection
to delete_by_group.collection.id.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Namespace and tenant describe the database regardless of outcome, so
record them (along with the target collection) up front instead of only
on the error path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Namespace and tenant are properties of the database, so trace them as
database.namespace / database.tenant rather than under the operation.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move each Span::add next to where its value is resolved instead of
clumping them. Split the delete_by_group error string into separate
structured attributes (namespace, collection.id, tenant, error) so it
is no longer an unstructured log embedded in a span.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace unstructured Console::info/error calls in the database worker
with structured Span::add tags. Operation identifiers (project, database,
collection, document) and queue metadata are recorded up front; swallowed
errors (deleteByGroup, attribute NotFound) are surfaced as spans so they
stay visible. Redundant Console::error calls before rethrows are dropped
since the entry-point harness owns span error lifecycle.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>