analytics-worker is the observability engine of the Hoox trading platform. Deployed as a private internal microservice, it aggregates time-series metrics, database query latencies, execution performance ratios, and API status codes across all V8 isolates. By translating incoming events and writing them to Cloudflare Analytics Engine, it provides the backend telemetry used to draw live charts in the Next.js Dashboard.
⚡ 1. Declared Wrangler Configurations & Bindings
Theanalytics-worker binds directly to Cloudflare’s Analytics Engine dataset and does not expose any public endpoints:
NoCLOUDFLARE_API_TOKENorCLOUDFLARE_ACCOUNT_IDare insecrets— these are set asvarsinwrangler.jsoncand used for the Cloudflare SQL API query path.
🔑 2. Environmental Variables & Encrypted Secrets
CLOUDFLARE_API_TOKEN(var): A secure token withAccount.Analyticsread permissions, allowing the worker to query stored datasets via the Cloudflare SQL API.CLOUDFLARE_ACCOUNT_ID(var): Your Cloudflare Account ID used in SQL API requests.
🔌 3. Internal REST API Specification
Note: For the canonical endpoint directory with full request/response examples across all workers, see /docs/devops/api/endpoints.
All endpoints are reachable via Cloudflare Service Bindings only (no public URL). Each endpoint validates its payload with a Zod schema using .strict() to reject unknown fields.
A. Track Trade Event
- Endpoint:
POST /track/trade - Payload:
- Response:
{ "success": true }
B. Track API Call Event
Invoked by other workers (likehoox or trade-worker) immediately upon completing an action.
- Endpoint:
POST /track/api-call - Payload:
Under-the-Hood Analytics Engine Write
The worker formats and writes a time-series data point to thehoox-analytics dataset:
- Response (200) :
{ "success": true }
C. Track Worker Performance
- Endpoint:
POST /track/worker-perf - Payload:
D. Track Signal
- Endpoint:
POST /track/signal - Payload:
E. Track Notification
- Endpoint:
POST /track/notification - Payload:
F. Health
- Endpoint:
GET /health - Response:
{ "status": "ok", "worker": "analytics-worker" }
Query Methods (Exported Functions)
The analytics worker exports query functions that are called via Service Bindings (not HTTP). Each builds a SQL query and executes it against the Cloudflare Analytics Engine SQL API:
All SQL queries are built via
sanitizeQueryInputs() which validates parameters using allowlists and regex to prevent SQL injection.
📈 4. Dashboard Visual Integrations
The metrics written tohoox-analytics are queried by the dashboard to render:
- System Health Indicators: Real-time error spikes trigger warning banners in under 2 seconds.
- Isolate Latency Charts: Visual line graphs showing V8 processing speeds vs exchange API transit speeds.
- Volume Load Heatmaps: Visualizes peak trading hours and signal traffic volumes globally.
🔗 Next Steps
- System Observability Guides — Deepen your understanding of time-series logging and metrics.
- trade-worker Profile — Review how execution latency details are generated and offloaded.