Skip to content

Metrics

Metrics instruments and tags

ChokaQ публикует metrics через .NET API System.Diagnostics.Metrics. Meter name - ChokaQ.

Metrics - public production contract. Names, units и tag cardinality должны быть достаточно стабильны для dashboards и alerts.

Instruments

MetricTypeMeaning
chokaq.jobs.enqueuedCounterJobs accepted into the queue.
chokaq.jobs.completedCounterJobs completed successfully.
chokaq.jobs.failedCounterHandler execution failures.
chokaq.jobs.processing_durationHistogram, msHandler processing duration.
chokaq.jobs.queue_lagHistogram, msTime eligible jobs waited before processing.
chokaq.jobs.dlqCounterJobs moved to DLQ.
chokaq.jobs.retriedCounterJobs scheduled for retry.
chokaq.workers.activeUpDownCounterCurrent active processing workers.
chokaq.jobs.heartbeat_failuresCounterFailed heartbeat writes.
chokaq.jobs.state_transition_conflictsCounterWorker-owned transitions that affected no rows.
chokaq.idempotency.claimsCounterIdempotency claim outcomes.
chokaq.circuits.eventsCounterCircuit breaker state events.

Cardinality control

Metrics tags ограничиваются options ChokaQ:Metrics:

  • max queue tag values;
  • max job type tag values;
  • max error tag values;
  • max failure reason tag values;
  • max tag value length;
  • unknown value label;
  • overflow value label.

Когда process видит слишком много distinct values, новые values сворачиваются в overflow label вместо создания unlimited time series.

Alerting guidance

SignalUse
Queue lag p95/p99Primary saturation alert.
DLQ rateTerminal failure alert.
Retry rateDownstream instability signal.
Heartbeat failuresStorage or worker health issue.
State transition conflictsOwnership/race/recovery signal.
Circuit eventsSystemic downstream failure protection.

Архитектурное решение

Почему этот pattern?

OpenTelemetry-compatible metrics позволяют ChokaQ интегрироваться с существующим monitoring без зависимости от конкретного vendor.

Trade-offs

Tag cardinality должен контролироваться. Queue names, job types и error values могут стать unbounded, если applications передают в них dynamic strings.

Рассмотренные альтернативы

AlternativeBenefitCost
Vendor-specific SDKRich features.Привязывает users к одному observability stack.
Logs-derived metricsFlexible.Медленнее и дороже для alerting.
No built-in metricsМаленький runtime surface.Слабый production story.

Дополнительные вопросы

Почему queue lag важнее queue depth?
Depth не содержит time context. Lag показывает, сколько eligible work реально ждет.

Зачем ограничивать tag values?
Чтобы accidental high-cardinality time series не повредили monitoring backend.

Какая metric показывает duplicate-protection behavior?
chokaq.idempotency.claims, разбитая по outcome.

Лицензия Apache 2.0