How ghbihuy123/astrotel works
Project type and purpose
• Astrotel is a Python library (not a standalone web service) that integrates application frameworks (FastAPI, Celery) with OpenTelemetry tracing and logging, exporting data to OTEL collectors or backends (Signoz, Jaeger).
File structure
• src/astrotel/
• base.py – core abstractions for tracing/logging
• config.py – environment-driven settings loader
• error.py – custom exceptions and error handling
• provider/ – framework adapters
· fastapi.py – FastAPI tracer setup
· celery.py – Celery tracer setup
• Tests and CI configs (.github/workflows) confirm a library project with linters, formatting, tests, and release pipelines.
README for additional insights
• Describes Python ≥3.12, pip install extras ([fastapi]), usage code snippets, env-var configuration, supported exporters (HTTP/gRPC), and integration points (logging handler).
Main components & relationships
a. Client Application
• FastAPI app or Celery worker code calls into Astrotel.provider.*
b. Astrotel Library
• Core modules (base, config, error)
• Provider modules inject middleware spans, configure log handler
c. OpenTelemetry SDK Pipeline
• Span processors, BatchSpanProcessor
• Exporter (OTLP HTTP or gRPC)
d. OTEL Collector (or direct exporter)
• Receives traces/logs
• Forwards to backends (Signoz, Jaeger)
e. Backend Systems
• Signoz, Jaeger, other tracing UIs
Data flow:
1. HTTP request → FastAPI endpoint
2. Provider.fastapi config adds tracing middleware → Spans emitted
3. Logging via Python logging + Astrotel handler → LogRecords forwarded as telemetry
4. Spans/Logs flow through OTEL SDK → Exporter
5. Exporter sends telemetry to Collector (via HTTP/gRPC) → Backend UI
Architectural patterns & design principles
• Adapter pattern: provider modules implement framework-specific hooks
• Configuration via environment variables
• Separation of concerns: core tracing logic vs. framework adapters
• Modular, extensible for new frameworks or exporters
Detailed capture
• Support for HTTP vs. gRPC exporters
• “Application Runtime”
• “Telemetry Pipeline”
• “External Systems”