• Stars
    star
    636
  • Rank 70,723 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 7 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript APM Tracer

dd-trace: Node.js APM Tracer Library

npm v4 npm v3 npm v2 npm dev codecov

Bits the dog  JavaScript

dd-trace is an npm package that you can install in your Node.js application to capture APM (Application Performance Monitoring) data. In Datadog terminology this library is called a Tracer. This data is then sent off to a process which collects and aggregates the data, called an Agent. Finally the data is sent off to the Datadog servers where it's stored and made available for querying in a myriad of ways, such as displaying in a dashboard or triggering alerts.

Tracer, Agent, Datadog relationship diagram

Documentation

Most of the documentation for dd-trace is available on these webpages:

Version Release Lines and Maintenance

Release Line Latest Version Node.js Status Initial Release End of Life
v1 npm v1 >= v12 End of Life 2021-07-13 2022-02-25
v2 npm v2 >= v12 Maintenance 2022-01-28 2023-08-15
v3 npm v3 >= v14 Maintenance 2022-08-15 2024-05-15
v4 npm v4 >= v16 Current 2023-05-12 Unknown

We currently maintain three release lines, namely v2, v3 and v4. Features and bug fixes that are merged are released to the v4 line and, if appropriate, also the v2 and v3 line.

For any new projects it is recommended to use the v4 release line:

$ npm install dd-trace
$ yarn add dd-trace

However, existing projects that already use the v2 or v3 release lines, or projects that need to support EOL versions of Node.js, may continue to use these release lines. This is done by specifying the version when installing the package. Note that we also publish to npm using a latest-node12 and latest-node14 tag that can also be used for install:

$ npm install dd-trace@3
$ yarn add dd-trace@3
$ npm install dd-trace@latest-node14
$ yarn add dd-trace@latest-node14

Any backwards-breaking functionality that is introduced into the library will result in an increase of the major version of the library and therefore a new release line. Such releases are kept to a minimum to reduce the pain of upgrading the library.

When a new release line is introduced the previous release line then enters maintenance mode where it will receive updates for the next year. Once that year is up the release line enters End of Life and will not receive new updates. The library also follows the Node.js LTS lifecycle wherein new release lines drop compatibility with Node.js versions that reach end of life (with the maintenance release line still receiving updates for a year).

For more information about library versioning and compatibility, see the NodeJS Compatibility Requirements page.

Changes associated with each individual release are documented on the GitHub Releases screen.

Development

Before contributing to this open source project, read our CONTRIBUTING.md.

Requirements

Since this project supports multiple Node versions, using a version manager such as nvm is recommended.

We use yarn for its workspace functionality, so make sure to install that as well.

To install dependencies once you have Node and yarn installed, run:

$ yarn

Testing

Before running plugin tests, the data stores need to be running. The easiest way to start all of them is to use the provided docker-compose configuration:

$ docker-compose up -d -V --remove-orphans --force-recreate
$ yarn services

Note The couchbase, grpc and oracledb instrumentations rely on native modules that do not compile on ARM64 devices (for example M1/M2 Mac) - their tests cannot be run locally on these devices.

Unit Tests

There are several types of unit tests, for various types of components. The following commands may be useful:

# Tracer core tests (i.e. testing `packages/dd-trace`)
$ yarn test:trace:core
# "Core" library tests (i.e. testing `packages/datadog-core`
$ yarn test:core
# Instrumentations tests (i.e. testing `packages/datadog-instrumentations`
$ yarn test:instrumentations

Several other components have test commands as well. See package.json for details.

To test plugins (i.e. components in packages/datadog-plugin-XXXX directories, set the PLUGINS environment variable to the plugin you're interested in, and use yarn test:plugins. If you need to test multiple plugins you may separate then with a pipe (|) delimiter. Here's an example testing the express and bluebird plugins:

PLUGINS="express|bluebird" yarn test:plugins

Memory Leaks

To run the memory leak tests, use:

$ yarn leak:core

# or

$ yarn leak:plugins

Linting

We use ESLint to make sure that new code is conform to our coding standards.

To run the linter, use:

$ yarn lint

Experimental ESM Support

Warning

ESM support has been temporarily disabled starting from Node 20 as significant changes are in progress.

ESM support is currently in the experimental stages, while CJS has been supported since inception. This means that code loaded using require() should work fine but code loaded using import might not always work.

Use the following command to enable experimental ESM support with your application:

node --loader dd-trace/loader-hook.mjs entrypoint.js

Benchmarks

Our microbenchmarks live in benchmark/sirun. Each directory in there corresponds to a specific benchmark test and its variants, which are used to track regressions and improvements over time.

In addition to those, when two or more approaches must be compared, please write a benchmark in the benchmark/index.js module so that we can keep track of the most efficient algorithm. To run your benchmark, use:

$ yarn bench

Serverless / Lambda

Note that there is a separate Lambda project, datadog-lambda-js, that is responsible for enabling metrics and distributed tracing when your application runs on Lambda. That project does depend on the dd-trace package but also adds a lot of Lambda-related niceties. If you find any issues specific to Lambda integrations then the issues may get solved quicker if they're added to that repository. That said, even if your application runs on Lambda, any core instrumentation issues not related to Lambda itself may be better served by opening an issue in this repository. Regardless of where you open the issue, someone at Datadog will try to help.

Bundling

Generally, dd-trace works by intercepting require() calls that a Node.js application makes when loading modules. This includes modules that are built-in to Node.js, like the fs module for accessing the filesystem, as well as modules installed from the npm registry, like the pg database module.

Also generally, bundlers work by crawling all of the require() calls that an application makes to files on disk, replacing the require() calls with custom code, and then concatenating all of the resulting JavaScript into one "bundled" file. When a built-in module is loaded, like require('fs'), that call can then remain the same in the resulting bundle.

Fundamentally APM tools like dd-trace stop working at this point. Perhaps they continue to intercept the calls for built-in modules but don't intercept calls to third party libraries. This means that by default when you bundle a dd-trace app with a bundler it is likely to capture information about disk access (via fs) and outbound HTTP requests (via http), but will otherwise omit calls to third party libraries (like extracting incoming request route information for the express framework or showing which query is run for the mysql database client).

To get around this, one can treat all third party modules, or at least third party modules that the APM needs to instrument, as being "external" to the bundler. With this setting the instrumented modules remain on disk and continue to be loaded via require() while the non-instrumented modules are bundled. Sadly this results in a build with many extraneous files and starts to defeat the purpose of bundling.

For these reasons it's necessary to have custom-built bundler plugins. Such plugins are able to instruct the bundler on how to behave, injecting intermediary code and otherwise intercepting the "translated" require() calls. The result is that many more packages are then included in the bundled JavaScript file. Some applications can have 100% of modules bundled, however native modules still need to remain external to the bundle.

Esbuild Support

This library provides experimental esbuild support in the form of an esbuild plugin, and currently requires at least Node.js v16.17 or v18.7. To use the plugin, make sure you have dd-trace@3+ installed, and then require the dd-trace/esbuild module when building your bundle.

Here's an example of how one might use dd-trace with esbuild:

const ddPlugin = require('dd-trace/esbuild')
const esbuild = require('esbuild')

esbuild.build({
  entryPoints: ['app.js'], 
  bundle: true,
  outfile: 'out.js',
  plugins: [ddPlugin],
  platform: 'node', // allows built-in modules to be required
  target: ['node16']
}).catch((err) => {
  console.error(err)
  process.exit(1)
})

Security Vulnerabilities

If you have found a security issue, please contact the security team directly at [email protected].

More Repositories

1

go-profiler-notes

felixge's notes on the various go profiling methods that are available.
Jupyter Notebook
3,255
star
2

glommio

Glommio is a thread-per-core crate that makes writing highly parallel asynchronous applications in a thread-per-core architecture easier for rustaceans.
Rust
3,076
star
3

datadog-agent

Main repository for Datadog Agent
Go
2,859
star
4

stratus-red-team

☁️ ⚡ Granular, Actionable Adversary Emulation for the Cloud
Go
1,752
star
5

dd-agent

Datadog Agent Version 5
Python
1,291
star
6

integrations-core

Core integrations of the Datadog Agent
Python
917
star
7

KubeHound

Tool for building Kubernetes attack paths
Go
737
star
8

zstd

Zstd wrapper for Go
C
732
star
9

dd-trace-go

Datadog Go Library including APM tracing, profiling, and security monitoring.
Go
659
star
10

the-monitor

Markdown files for Datadog's longform blog posts: https://www.datadoghq.com/blog/
Python
613
star
11

guarddog

🐍 🔍 GuardDog is a CLI tool to Identify malicious PyPI and npm packages
Python
588
star
12

datadogpy

The Datadog Python library
Python
575
star
13

dd-trace-py

Datadog Python APM Client
Python
519
star
14

dd-trace-java

Datadog APM client for Java
Java
500
star
15

yubikey

YubiKey at Datadog
Shell
494
star
16

dd-trace-php

Datadog PHP Clients
PHP
491
star
17

kafka-kit

Kafka storage rebalancing, automated replication throttle, cluster API and more
Go
485
star
18

documentation

The source for Datadog's documentation site.
HTML
471
star
19

dd-trace-dotnet

.NET Client Library for Datadog APM
C#
443
star
20

security-labs-pocs

Proof of concept code for Datadog Security Labs referenced exploits.
Shell
355
star
21

go-python3

Go bindings to the CPython-3 API
Go
344
star
22

helm-charts

Helm charts for Datadog products
Go
344
star
23

datadog-go

go dogstatsd client library for datadog
Go
332
star
24

terraform-provider-datadog

Terraform Datadog provider
Go
329
star
25

datadog-serverless-functions

Repo of AWS Lambda and Azure Functions functions that process streams and send data to Datadog
Python
326
star
26

docker-dd-agent

Datadog Agent Dockerfile for Trusted Builds.
Roff
302
star
27

browser-sdk

Datadog Browser SDK
TypeScript
302
star
28

datadog-operator

Kubernetes Operator for Datadog Resources
Go
301
star
29

ansible-datadog

Ansible role for Datadog Agent
Jinja
299
star
30

dd-trace-rb

Datadog Tracing Ruby Client
Ruby
261
star
31

threatest

Threatest is a CLI and Go framework for end-to-end testing threat detection rules.
Go
260
star
32

integrations-extras

Community developed integrations and plugins for the Datadog Agent.
Python
252
star
33

watermarkpodautoscaler

Custom controller that extends the Horizontal Pod Autoscaler
Go
210
star
34

pupernetes

Spin up a full fledged Kubernetes environment designed for local development & CI
Go
201
star
35

Miscellany

Miscellaneous scripts and tools
Python
197
star
36

dd-sdk-ios

Datadog SDK for iOS - Swift and Objective-C.
Swift
195
star
37

php-datadogstatsd

A PHP client for DogStatsd
PHP
185
star
38

java-dogstatsd-client

Java statsd client library
Java
175
star
39

sketches-go

Go implementations of the distributed quantile sketch algorithm DDSketch
Go
167
star
40

dogstatsd-ruby

A Ruby client for DogStatsd
Ruby
166
star
41

dd-sdk-android

Datadog SDK for Android (Compatible with Kotlin and Java)
Kotlin
150
star
42

chaos-controller

🐒 🔥 Datadog Failure Injection System for Kubernetes
C
142
star
43

kvexpress

Go program to move data in and out of Consul's KV store.
Go
128
star
44

HASH

HASH (HTTP Agnostic Software Honeypot)
JavaScript
128
star
45

malicious-software-packages-dataset

An open-source dataset of malicious software packages found in the wild, 100% vetted by humans.
Python
125
star
46

ebpf-manager

This manager helps handle the life cycle of your eBPF programs
Go
118
star
47

docker-compose-example

A working example of using Docker Compose with Datadog
Python
116
star
48

orchestrion

Automatic compile-time instrumentation of Go code
Go
115
star
49

dd-sdk-reactnative

Datadog SDK for ReactNative
TypeScript
115
star
50

trace-examples

trace sample apps
Python
113
star
51

sketches-java

DDSketch: A Fast and Fully-Mergeable Quantile Sketch with Relative-Error Guarantees.
Java
113
star
52

datadog-lambda-js

The Datadog AWS Lambda Library for Node
TypeScript
105
star
53

gohai

System information collector
Go
102
star
54

build-plugins

A set of universal bundler plugins to interact with Datadog directly from your builds.
TypeScript
101
star
55

jmxfetch

Export JMX metrics
Java
98
star
56

chef-datadog

Chef cookbook for Datadog Agent & Integrations
Ruby
97
star
57

piecewise

Functions for piecewise regression on time series data
Python
96
star
58

extendeddaemonset

Kubernetes Extended Daemonset controller
Go
96
star
59

datadog-static-analyzer

Datadog Static Analyzer
Rust
96
star
60

datadog-api-client-go

Golang client for the Datadog API
Go
95
star
61

ansible-datadog-callback

Ansible callback to get stats & events directly into Datadog http://datadoghq.com
Python
94
star
62

dogstatsd-csharp-client

A DogStatsD client for C#/.NET
C#
94
star
63

gostackparse

Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s.
Go
94
star
64

dogapi-rb

Ruby client for Datadog's API
Ruby
92
star
65

redux-doghouse

Scoping helpers for building reusable components with Redux
JavaScript
90
star
66

ecommerce-workshop

Example eCommerce App for workshops and observability
Ruby
89
star
67

serverless-plugin-datadog

Serverless plugin to automagically instrument your Lambda functions with Datadog
TypeScript
87
star
68

ebpfbench

## Auto-archived due to inactivity. ## profile eBPF programs from Go
Go
87
star
69

datadog-ci

Use Datadog from your CI.
TypeScript
85
star
70

sketches-py

Python implementations of the distributed quantile sketch algorithm DDSketch
Python
83
star
71

datadog-lambda-python

The Datadog AWS Lambda Layer for Python
Python
83
star
72

ddqa

Datadog's QA manager for releases of GitHub repositories
Python
82
star
73

datadog-api-client-typescript

Typescript client for the Datadog API
TypeScript
77
star
74

dirtypipe-container-breakout-poc

Container Excape PoC for CVE-2022-0847 "DirtyPipe"
77
star
75

datadog-trace-agent

Datadog Trace Agent archive (pre-6.10.0)
70
star
76

heroku-buildpack-datadog

Heroku Buildpack to run the Datadog Agent in a Dyno
Shell
69
star
77

datadog-lambda-extension

Rust
68
star
78

datadog-api-client-python

Python client for the Datadog API
Python
68
star
79

datadog-cdk-constructs

CDK construct library to automagically instrument your Lambda functions with Datadog
TypeScript
65
star
80

lading

A suite of data generation and load testing tools
Rust
64
star
81

jsonapi

A marshaler/unmarshaler for JSON:API.
Go
62
star
82

datadog-api-client-java

Java client for the Datadog API
Java
61
star
83

managed-kubernetes-auditing-toolkit

All-in-one auditing toolkit for identifying common security issues in managed Kubernetes environments. Currently supports AWS EKS.
Go
60
star
84

datadog-lambda-go

The Datadog AWS Lambda package for Go
Go
59
star
85

serilog-sinks-datadog-logs

Serilog Sink that sends log events to Datadog https://www.datadoghq.com/
C#
53
star
86

puppet-datadog-agent

Puppet module to install the Datadog agent
Ruby
50
star
87

effective-dashboards

A curated list of useful Datadog dashboards and Dashboard design best practices
47
star
88

opencensus-go-exporter-datadog

Datadog exporter for OpenCensus metrics
Go
47
star
89

gello

## Auto-archived due to inactivity. ## :octocat: A self-hosted server for managing Trello cards based on GitHub webhook events
Python
45
star
90

datadog-cloudformation-resources

Python
44
star
91

ebpf-training

Go
44
star
92

dd-sdk-flutter

Flutter bindings and tools for utilizing Datadog Mobile SDKs
Dart
43
star
93

jenkins-datadog-plugin

ARCHIVED: Current repository is now located https://github.com/jenkinsci/datadog-plugin
Java
42
star
94

synthetics-ci-github-action

Use Browser and API tests in your CI/CD with Datadog Continuous Testing
TypeScript
41
star
95

dd-opentracing-cpp

Datadog Opentracing C++ Client
C++
40
star
96

rum-react-integration-examples

rum-react-integration
TypeScript
39
star
97

fluent-plugin-datadog

Fluentd output plugin for Datadog: https://www.datadog.com
Ruby
38
star
98

datadog-sync-cli

Datadog cli tool to sync resources across organizations.
Python
38
star
99

ddprof

The Datadog Native Profiler for Linux
C++
36
star
100

cloudformation-template

Easily set up the Datadog AWS integration using CloudFormation
Shell
34
star