Datadog Tracer
OpenTracing tracer implementation for Datadog in JavaScript.
It is intended for use both on the server and (soon) in the browser.
Installation
NodeJS
npm install --save datadog-tracer
Node >= 4 is required.
Browser
Not yet supported
Usage
See the OpenTracing JavaScript documentation for more information.
Custom tracer options
- service: name of the Datadog service
- hostname: hostname of the Datadog agent (default: localhost)
- port: port of the Datadog agent (default: 8126)
- protocol: protocol of the Datadog agent (default: http)
- endpoint: full URL of the Datadog agent (alternative to hostname+port+protocol)
Example
var express = require('express')
var Tracer = require('datadog-tracer')
var tracer = new Tracer({ service: 'my service' })
tracer.on('error', function (e) {
console.log(e)
})
var app = express()
app.get('/user/:id', function (req, res) {
var span = tracer.startSpan('someOperation')
span.addTags({
'resource': '/user/:id',
'type': 'web',
'span.kind': 'server',
'http.method': 'GET',
'http.url': '/user/123',
'http.status_code': '200'
})
span.finish()
res.send()
})
See the semantic conventions for
more information about tags.
API Documentation
See the OpenTracing JavaScript API