Count and trace attachment jobs through a job observer port
Add the JobObserver port to the attachments zone and its adapter on the OpenTelemetry API: every delivery adds one to messenger.jobs.processed and records messenger.job.duration in seconds with buckets from 50 ms to 60 s, both labelled only by job.type and outcome, and puts the job id, the attachment id, the attempt and the outcome on the current consumer span, which turns to ERROR on retry_scheduled, failed and error. The worker entrypoint measures each delivery, reports the outcome of the handler or error when it raised, and writes a job.processed record. Without the SDK the adapter runs on the no-op providers of the API. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e60b4eac98
commit
e2ec3fe9af
@@ -34,6 +34,7 @@ from messenger.attachments.application.ports import (
|
||||
Faults,
|
||||
ImageInspector,
|
||||
Jitter,
|
||||
JobObserver,
|
||||
JobPublisher,
|
||||
ObjectStorage,
|
||||
VariantRenderer,
|
||||
@@ -54,6 +55,7 @@ from messenger.attachments.infrastructure.postgres import (
|
||||
)
|
||||
from messenger.attachments.infrastructure.rabbitmq import RabbitJobPublisher
|
||||
from messenger.attachments.infrastructure.s3 import S3ObjectStorage, s3_client
|
||||
from messenger.attachments.infrastructure.telemetry import OtelJobObserver
|
||||
from messenger.shared.application.commands import Command
|
||||
from messenger.shared.application.messagebus import CommandHandler
|
||||
from messenger.shared.application.ports import Clock, EventPublisher, IdGenerator, Logger
|
||||
@@ -196,6 +198,10 @@ class WorkerProvider(Provider):
|
||||
def jitter(self) -> Jitter:
|
||||
return RandomJitter()
|
||||
|
||||
@provide(scope=Scope.APP)
|
||||
def observer(self) -> JobObserver:
|
||||
return OtelJobObserver()
|
||||
|
||||
@provide(scope=Scope.REQUEST)
|
||||
def command_bus(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user