Cloudflare Workers
This guide configures logs. Replace YOUR_INGEST_KEY with your key on your server, never in a public example.
1. Store the Worker secret
Section titled “1. Store the Worker secret”Enter the ingest key at the prompt. Keep service and environment in Worker vars. This example sends logs through the JSON adapter without a Node.js SDK.
npx wrangler secret put SQ_INGEST_KEY2. Send a bounded server-side log
Section titled “2. Send a bounded server-side log”waitUntil extends the request lifetime but is not a durable queue. Batch and use a durable queue with bounded retries for production. Avoid logging full URLs, authorization headers or personal data. To export platform logs instead, use the Cloudflare Logpush guide.
export default { async fetch(request, env, ctx) { ctx.waitUntil((async () => { const response = await fetch("https://otlp.siteqwality.com/ingest", { method: "POST", headers: {"Content-Type": "application/json", "Authorization": "Bearer " + env.SQ_INGEST_KEY}, body: JSON.stringify({message: "Worker request", level: "info", service: "my-service", env: "production"}) }); if (!response.ok) throw new Error("Telemetry send failed with status " + response.status); const result = await response.json(); if (result.rejected) throw new Error("Telemetry record rejected"); })()); return new Response("ok"); }};3. Deploy the Worker
Section titled “3. Deploy the Worker”Make one request and inspect Logs. This does not automatically emit traces or metrics.
npx wrangler deploySee your data
Section titled “See your data”Open Logs, Traces or Metrics. New data usually shows up within a minute, and a page that says it is waiting for data switches to your data on its own. Nothing arriving? See what each status code means in failure handling.
Production checklist
Section titled “Production checklist”Store the key in your platform secret mechanism, rotate it when exposed and remove test keys. Set a stable service.name and deployment.environment.name; avoid user IDs or unbounded values in metric labels. Prefer a persistent queue, bounded retries and exporter failure monitoring. Review redaction and processors before increasing traffic.