https://github.com/topfreegames/jaeger-tracer-node
Node Jaeger client extended with context propagation and external libs patches
https://github.com/topfreegames/jaeger-tracer-node
Last synced: 6 months ago
JSON representation
Node Jaeger client extended with context propagation and external libs patches
- Host: GitHub
- URL: https://github.com/topfreegames/jaeger-tracer-node
- Owner: topfreegames
- License: mit
- Created: 2018-03-22T17:00:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-22T16:40:18.000Z (almost 4 years ago)
- Last Synced: 2025-04-12T17:23:24.832Z (6 months ago)
- Language: JavaScript
- Size: 66.4 KB
- Stars: 3
- Watchers: 13
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jaeger Tracer for NodeJS
[](http://standardjs.com)## Basic Usage
This module automaticaly does most of the work by patching external libraries, such as _http_, _ioredis_, _mongodb_, and _sequelize_. The only thing that has to be done import this module before all others and configure the tracer.```javascript
const jaeger = require('jaeger-tracer-node')// Other imports
jaeger.configure({
disable: false,
probability: 0.001,
serviceName: 'my-service',
tags: {
'my-tag': 'my-value'
}
})// Main loop
```## Advanced Usage
In case there is need for manually creating spans, two approaches exist for referencing the parent.Notice that the spans need to be propagated in order for the patched libraries to know which is the current span.
Also, if your custom code sends requests to other servers, the span can be injected into a carrier for transmission.### Using a span carrier
This carrier can be something similar to an HTTP header or `null`.```javascript
let span = jaeger.startSpan(carrier, 'my-span', {
'my-tag': 'my-value'
})span.propagate(() => {
mySynchronousFunction(request)
})
span.finish()
```### Using the current span
The current span will never be `null`, so no check is needed. However, if it is not set, the new span will lack a parent.```javascript
let parent = jaeger.currentSpan()
let span = parent.startSpan('my-span')span.inject(myCarrier)
myFunctionWithCallback(myCarrier, err => {
span.finish(err)
})
```