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

1.0.1 • 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_TRACING_ENABLED
    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.

Migration guide

The version 1.0.0 contains breaking changes. In order to upgrade you need to make the following changes in your application:

  • Requires Node.js version v18 or greater
  • Change the environment variable DD_ENABLE_TRACING to DD_TRACING_ENABLED

Package Sidebar

Install

npm i @bufferapp/bufftracer

Weekly Downloads

20

Version

1.0.1

License

ISC

Unpacked Size

73.8 kB

Total Files

44

Last publish

Collaborators

  • jakubolek
  • 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