worker-cf-sentry 0.1.0

Sentry client for Cloudflare Workers
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 30.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 473.82 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xtuc

Crate for sending errors or events to Sentry.

Assuming you have your Sentry creds, configure your worker:

Configure wrangler.toml:

[vars]
SENTRY_DSN = ...
SENTRY_ENVIRONMENT = ...
SENTRY_CF_ACCESS_CLIENT_ID = ...

Add Cloudflare Access' secret token:

wrangler secret put SENTRY_CF_ACCESS_CLIENT_SECRET

Add the npm/yarn dependency:

yarn add toucan-js

Finally, use the Sentry client in worker using workers-rs:

#[event(fetch)]
pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Response> {
    let sentry_config = sentry::SentryConfig::from_env(&env)?;
    let sentry = sentry::SentryClient::new(sentry_config, &req, &ctx);

    sentry.set_tag("colo", "LHR");
    sentry.capture_message("this is a message");
    sentry.capture_exception(&Err("this is a error"));

    todo!();
}