feat(observability): add product metrics for API, outbox and delivery

This commit is contained in:
shira committed 2026-10-06 19:48:15 +03:00
1 parent 560724e2aa
commit 94488e2b57
51 files changed
+3655 -68

No files matched your search

@@ -0,0 +1,32 @@
package outbound
import (
"context"
"time"
"lincodex/backend/internal/domain"
)
// DeliveryStatusCount is the number of stored deliveries of one kind in one
// status.
type DeliveryStatusCount struct {
Kind domain.MailKind
Status domain.DeliveryStatus
Deliveries int64
}
// DeliveryStatistics aggregates all stored deliveries for operators and
// metrics. It holds no recipient, address, content, or delivery ID.
type DeliveryStatistics struct {
// Counts has one entry per kind and status that has deliveries.
Counts []DeliveryStatusCount
// EarliestPendingAttemptAt is the earliest NextAttemptAt of a pending
// delivery, by the application clock that wrote it; zero without
// pending deliveries.
EarliestPendingAttemptAt time.Time
}
// DeliveryStatisticsReader reads the delivery aggregate without locking.
type DeliveryStatisticsReader interface {
DeliveryStatistics(ctx context.Context) (DeliveryStatistics, error)
}