@bufferapp/bufftracer
v1.0.1
Published
A Datadog wrapper library to enable DD APM and tag API traces
Downloads
83
Readme
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.ts
file.
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
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
toDD_TRACING_ENABLED