feat: propagate trace context through outbox and add pipeline saturation metrics
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -666,6 +666,8 @@ class FakeAttachmentJobRepository(
|
||||
attempt=job.attempt,
|
||||
created_at=job.created_at,
|
||||
updated_at=job.updated_at,
|
||||
traceparent=job.traceparent,
|
||||
tracestate=job.tracestate,
|
||||
)
|
||||
return job
|
||||
|
||||
@@ -700,6 +702,39 @@ class FakeAttachmentJobRepository(
|
||||
)
|
||||
return sum(min(len(group), limit) for group in groups)
|
||||
|
||||
async def queue_snapshot(
|
||||
self,
|
||||
*,
|
||||
now: datetime,
|
||||
) -> dataclasses.QueueSnapshotDTO:
|
||||
unfinished = [
|
||||
job
|
||||
for job in self._db.jobs.values()
|
||||
if job.state
|
||||
in {AttachmentJobState.QUEUED, AttachmentJobState.PROCESSING}
|
||||
]
|
||||
outbox = [
|
||||
job
|
||||
for job in unfinished
|
||||
if job.state == AttachmentJobState.QUEUED
|
||||
and job.published_at is None
|
||||
]
|
||||
return dataclasses.QueueSnapshotDTO(
|
||||
taken_at=now,
|
||||
scheduled=sum(1 for job in outbox if _due_at(job) > now),
|
||||
outbox=sum(1 for job in outbox if _due_at(job) <= now),
|
||||
published=len(self._published()),
|
||||
processing=sum(
|
||||
1
|
||||
for job in unfinished
|
||||
if job.state == AttachmentJobState.PROCESSING
|
||||
),
|
||||
oldest_created_at=min(
|
||||
(job.created_at for job in unfinished),
|
||||
default=None,
|
||||
),
|
||||
)
|
||||
|
||||
async def get_attachment_job(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user