23 lines
1.6 KiB
TypeScript
23 lines
1.6 KiB
TypeScript
// Метрики заданий (contracts/observability.md), общие для API (relay, sweeper) и worker.
|
|
// Атрибуты только низкой кардинальности: тип job, исход, код ошибки; идентификаторы — в логах и spans.
|
|
import { meter } from '../otel.ts';
|
|
|
|
export const JOB_TYPE = 'attachment.process.v1';
|
|
|
|
// Длительность одной обработки сообщения worker-ом; _count по outcome — счётчик обработанных/ошибочных jobs.
|
|
// outcome: done | retry | failed | noop | discarded | error (сбой вне попытки, сообщение вернётся в очередь).
|
|
export const jobDuration = meter.createHistogram('messenger.job.duration', {
|
|
unit: 's',
|
|
description: 'Processing time of one job delivery by the worker',
|
|
advice: { explicitBucketBoundaries: [0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60] },
|
|
});
|
|
|
|
// От durable acceptance (COMMIT задания при загрузке) до публикации ready (outcome=ready) или до терминальной
|
|
// ошибки (outcome=failed, error.type = error_code). Время считает PostgreSQL одними часами для обеих точек.
|
|
// Граница 30 с совпадает с порогом SLO time-to-ready (infra/prometheus/rules/slo.yml).
|
|
export const timeToReady = meter.createHistogram('messenger.attachment.time_to_ready', {
|
|
unit: 's',
|
|
description: 'Time from durable upload acceptance to published ready (or terminal failure)',
|
|
advice: { explicitBucketBoundaries: [0.5, 1, 2, 5, 10, 15, 30, 60, 120, 300, 600] },
|
|
});
|