GithubHelp home page GithubHelp logo

isabella232 / epsagon-cloudflare Goto Github PK

View Code? Open in Web Editor NEW

This project forked from epsagon/epsagon-cloudflare

0.0 0.0 0.0 248 KB

Automated tracing library for Cloudflare Workers⚡️

Home Page: https://epsagon.com

License: MIT License

JavaScript 100.00%

epsagon-cloudflare's Introduction


Epsagon Tracing for Cloudflare Workers

This package provides tracing to Cloudflare Workers for the collection of distributed tracing and performance metrics in Epsagon.

Contents

Installation

Installation is done via the usual npm install @epsagon/cloudflare.

Usage

To configure the package, you need to wrap your listener with the epsagon agent. So if your current code looks something like this:

addEventListener('fetch', (event) => {
  event.respondWith(handleRequest(event.request))
})

function handleRequest(request) {
  //your worker code.
}

You can change that to:

import { epsagon } from '@epsagon/cloudflare'

const epsagon_config = {
  token: 'epsagon-token',
  app_name: 'application-name',
}

const listener = epsagon(epsagon_config, (event) => {
  event.respondWith(handleRequest(event.request))
})

addEventListener('fetch', listener)

function handleRequest(request) {
  //your worker code.
}

Tracing Fetch Requests

To be able to associate the a subrequest with the correct incoming request, you will have to use the fetch defined on the tracer described above. The method on the tracer delegates all arguments to the regular fetch method, so the tracer.fetch function is a drop-in replacement for all fetch function calls.

Example:

async function handleRequest(request) {
  return request.tracer.fetch('link')
}

epsagon-cloudflare's People

Contributors

hardingru avatar ranrib avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.