DealDocumentScreening/src/contract_check/worker_notify/__main__.py
febux b279d6c61a Switch observability to passive collection: remove OTLP push, Vector replaces otel-collector
- core/telemetry.py is now a no-op (no opentelemetry imports); entrypoints
  no longer call setup/shutdown telemetry
- Remove all opentelemetry-* deps from pyproject groups; regenerate uv.lock
- Drop otel_exporter_otlp_endpoint/otel_service_name settings; sentry and
  auth use "contract-check" instead
- Stop publishing worker metrics ports; bind API metrics to 127.0.0.1 by
  default via API_METRICS_BIND_HOST
- Replace otel-collector with Vector in observer profile (docker_logs +
  prometheus_scrape -> OpenObserve); add deploy/observability/vector-config.yaml
- Update .env.example, docs (ARCHITECTURE, DEPLOY), README, Makefile
- Rewrite tests/unit/test_telemetry.py for the no-op implementation
2026-09-06 19:17:08 +03:00

59 lines
1.7 KiB
Python

"""worker-notify entrypoint: connects to RabbitMQ and runs the notify consumer."""
from __future__ import annotations
import asyncio
import signal
from src.contract_check.core.config import get_settings
from src.contract_check.core.logging import bind_context, configure_logging, get_logger
from src.contract_check.core.metrics import start_metrics_server
from src.contract_check.core.sentry import init_sentry
from src.contract_check.worker_notify.consumer import NotifyConsumer
log = get_logger(__name__)
async def main() -> None:
settings = get_settings()
configure_logging(
settings.log_level,
json_output=settings.json_logs,
service="worker-notify",
env=settings.env,
)
bind_context(service="worker-notify", env=settings.env)
init_sentry("worker-notify")
start_metrics_server(9103)
consumer = NotifyConsumer(
url=settings.rabbitmq_url,
origin="worker-notify",
prefetch=settings.mq_prefetch_notify,
max_attempts=settings.mq_max_attempts,
retry_base_ms=settings.mq_retry_base_ms,
)
await consumer.connect()
loop = asyncio.get_running_loop()
stop_event = asyncio.Event()
for sig in (signal.SIGINT, signal.SIGTERM):
loop.add_signal_handler(sig, stop_event.set)
consumer_task = asyncio.create_task(consumer.run())
stop_task = asyncio.create_task(stop_event.wait())
log.info("worker_notify_started", prefetch=settings.mq_prefetch_notify)
try:
await asyncio.wait(
{consumer_task, stop_task},
return_when=asyncio.FIRST_COMPLETED,
)
finally:
await consumer.stop()
if __name__ == "__main__":
asyncio.run(main())