@bufferapp/bufftracer
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

BuffTracer

A Datadog wrapper library to enable DD APM and tag API traces

Getting Started

Install npm package

npm install --save-exact @bufferapp/bufftracer

Initialize tracer at the start of the service

This should be the first import in your index.tsfile.

import '@bufferapp/bufftracer'

Declare the following required env variables in the helm charts of each service

  // core-api.yaml

  - name: DD_ENABLE_TRACING
    value: 'true'
  - name: DD_SERVICE_NAME
    value: 'core-api'
  - name: DD_TRACE_AGENT_HOSTNAME
    valueFrom:
      fieldRef:
        fieldPath: status.hostIP
  - name: DD_TRACE_AGENT_PORT
    value: '8126'
  - name: NODE_ENV # or APP_STAGE
    value: production

What it does

The library parses the incoming request, generates metadata, sets DD resource name to be the edge/endpoint and tags the DD span with the metadata.

API metadata format

type APIRequestMetadata = {
  name: 'core-api' | string
  type: 'graphql' | 'rpc' | 'rest'
  client: 'buffertools-graphql-playground' | string
  edge: string
  fields: Array<string>
  deprecatedFields: Array<string>
  args: Array<string>
}

Datadog APM tag

image

The DD APM tags are then used to generate DD custom metrics named api.request, which we can use to build dashboard and know who is consuming which parts of our API.

Package Sidebar

Install

npm i @bufferapp/bufftracer

Weekly Downloads

51

Version

0.2.0

License

ISC

Unpacked Size

90.1 kB

Total Files

53

Last publish

Collaborators

  • davidluhr
  • egomezd
  • jacobchadwell
  • philippemiguet
  • josemdev
  • msanroman
  • daisymarie128
  • hamstu
  • stevenc81
  • bufferbot
  • mayauribe
  • esclapes
  • ay8s
  • mickmahady
  • dinostheo
  • hitherejoe
  • dace
  • erickhun
  • kmbriseno
  • kiriappeee
  • cmunozgar
  • peteremilbuffer
  • arekpn
  • abeeb
  • buffermw