- ledgerline.transactions.total (counter: kind, status, currency) and ledgerline.transaction.duration (histogram, seconds: kind) in gateway, the only place that sees the final outcome, failures included. currency is client input, so values outside the seeded set are recorded as "other". - ledgerline.fraud.score (histogram, buckets in 0.1 steps to 1.0) in fraud. - ledgerline.stream.lag (observable gauge: consumer_group) in audit and notifier, read from XINFO GROUPS through a separate sync Redis client, because callbacks run on the scrape thread; the call is untraced so scrapes don't create traces. - ledgerline.db.pool.in_use (observable up-down counter: pool) in every service with a DB engine. The SQLAlchemy instrumentation's own pool metric names a pool by DSN, which merges the normal and starved engines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
572 B
Python
20 lines
572 B
Python
import asyncio
|
|
|
|
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
|
|
|
|
from common.db import engine
|
|
from common.logging_config import configure_logging
|
|
from common.metrics import observe_db_pools, observe_stream_lag
|
|
from common.telemetry import setup_telemetry
|
|
|
|
from . import consumer
|
|
|
|
configure_logging("audit")
|
|
setup_telemetry(service_name="audit")
|
|
SQLAlchemyInstrumentor().instrument(engines=[engine.sync_engine])
|
|
observe_db_pools({"default": engine})
|
|
observe_stream_lag(consumer.GROUP)
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(consumer.run())
|