Skip to content

j-white/cloudflare-otlp-exporter

Repository files navigation

Cloudflare OpenTelemetry exporter

Deploy to Cloudflare Workers

Description

This worker was written to push Cloudflare Analytics data to an OpenTelemetry collector.

It is inspired by the cloudflare-exporter.

By running it as a worker and pushing metrics, we avoid the need to deploy a dedicated container and allow the worker to be run on green compute.

Metrics currently supported

  • Workers
  • D1
  • Durable Objects
  • Queues
  • Zones

Usage

  • Clone the repo
  • Modify the wrangler.toml file to include your Cloudflare account ID and API token and OTel collector endpoint
  • Run npx wrangler deploy --env dev to deploy the worker

How it works

  • Scrape the Cloudflare Analytics API via GraphQL
  • Build the metrics in a Prometheus registry (ideally this would be directly with OTel, but ran into some challenges with threading and WASM for these SDKs)
  • Convert the Prometheus registry to OTel metrics
  • Push the OTel metrics to an OTel collector via protobuf (JSON encoding for OTel Metrics is broken in the Rust SDKs and is only used for testing)

Next steps

  • Add more metrics
  • Help improve OTel Rust SDKs and remove dependency on Prometheus

About

OpenTelemetry exporter for Cloudflare

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages