https://github.com/rochdev/datadog-tracer-js
[DEPRECATED] OpenTracing tracer implementation for Datadog in JavaScript.
https://github.com/rochdev/datadog-tracer-js
datadog opentracing
Last synced: about 1 year ago
JSON representation
[DEPRECATED] OpenTracing tracer implementation for Datadog in JavaScript.
- Host: GitHub
- URL: https://github.com/rochdev/datadog-tracer-js
- Owner: rochdev
- License: mit
- Created: 2017-04-10T09:44:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-23T07:58:15.000Z (almost 8 years ago)
- Last Synced: 2024-10-19T12:15:28.389Z (over 1 year ago)
- Topics: datadog, opentracing
- Language: JavaScript
- Homepage:
- Size: 371 KB
- Stars: 39
- Watchers: 2
- Forks: 8
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Datadog Tracer
[](https://www.npmjs.com/package/datadog-tracer)
[](https://travis-ci.org/rochdev/datadog-tracer-js)
[](https://codecov.io/gh/rochdev/datadog-tracer-js)
[](https://codeclimate.com/github/rochdev/datadog-tracer-js)
[](https://greenkeeper.io/)
[](https://www.bithound.io/github/rochdev/datadog-tracer-js/master/dependencies/npm)
## DEPRECATED: The official library [dd-trace-js](https://github.com/DataDog/dd-trace-js) has now been released.
OpenTracing tracer implementation for Datadog in JavaScript.
It is intended for use both on the server and in the browser.
## Installation
### NodeJS
```sh
npm 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](https://github.com/dcodeIO/protobuf.js/tree/master/dist/minimal) before this library.
#### CDN
```html
```
**NOTE:** Remember to replace the version tag with the exact [release](https://github.com/rochdev/datadog-tracer-js/tags) your project depends upon.
#### Frontend
```html
```
## Usage
See the OpenTracing JavaScript [documentation](https://github.com/opentracing/opentracing-javascript) 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
```js
const express = require('express')
const Tracer = require('datadog-tracer')
const app = express()
const tracer = new Tracer({ service: 'example' })
// handle errors from Datadog agent. omit this if you want to ignore errors
tracer.on('error', e => console.log(e))
app.get('/hello/:name', (req, res) => {
const span = tracer.startSpan('say_hello')
span.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'
})
span.finish()
res.send(`Hello, ${req.params.name}!`)
})
app.listen(3000)
```
See the [examples](examples) folder for more advanced examples.
## API Documentation
See the OpenTracing JavaScript [API](https://doc.esdoc.org/github.com/opentracing/opentracing-javascript/)
## Additional Resources
* [OpenTracing Specification](https://github.com/opentracing/specification/blob/master/specification.md)
* [OpenTracing Semantic Conventions](https://github.com/opentracing/specification/blob/master/semantic_conventions.md)