artsy/datadog-tracer-js

Name: datadog-tracer-js

Owner: Artsy

Description: OpenTracing tracer implementation for Datadog in JavaScript.

Forked from: rochdev/datadog-tracer-js

Created: 2017-11-27 21:59:09.0

Updated: 2017-11-27 21:59:11.0

Pushed: 2017-11-29 22:19:49.0

Homepage: null

Size: 328

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Datadog Tracer

npm Build Status codecov Code Climate Greenkeeper badge bitHound Dependencies

OpenTracing tracer implementation for Datadog in JavaScript. It is intended for use both on the server and in the browser.

Installation
NodeJS
install --save datadog-tracer

Node >= 4 is required.

Browser

The library supports CommonJS and AMD loaders and also exports globally as DatadogTracer.

NOTE: If you want to use binary propagation, make sure to also include the minimal version of protobuf.js before this library.

CDN
ipt src="//cdn.rawgit.com/rochdev/datadog-tracer-js/0.X.X/dist/datadog-tracer.min.js"></script>

NOTE: Remember to replace the version tag with the exact release your project depends upon.

Frontend
ipt src="node_modules/datadog-tracer/dist/datadog-tracer.min.js"></script>
Usage

See the OpenTracing JavaScript documentation for more information.

Custom tracer options
Example
t express = require('express')
t Tracer = require('datadog-tracer')

t app = express()
t tracer = new Tracer({ service: 'example' })

andle errors from Datadog agent. omit this if you want to ignore errors
er.on('error', e => console.log(e))

get('/hello/:name', (req, res) => {
nst span = tracer.startSpan('say_hello')

an.addTags({
'resource': '/hello/:name', // required by Datadog
'type': 'web', // required by Datadog
'span.kind': 'server',
'http.method': 'GET',
'http.url': req.url,
'http.status_code': '200'


an.finish()

s.send(`Hello, ${req.params.name}!`)


listen(3000)

See the examples folder for more advanced examples.

API Documentation

See the OpenTracing JavaScript API

Additional Resources

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.