finciero-zipkin-js
v1.1.2
Published
Finciero package to encapsulate zipkin trace logic
Downloads
10
Readme
Finciero JS Zipkin
finciero-zipkin-js is an abstraction of zipkin-js
This library let us start a new zipkin tracer
or continue a child trace
.
Config zipkin and kafka.
To use this library you need setup KAFKA_SERVICE_URL
in your environment variables.
Also, you can use this to run kafka and zipkin with docker.
Usage
The basic usage is as follow:
const { TracerJS } = require('finciero-zipkin-js')
const tracer = new TracerJS()
tracer.config({
name: 'service-name',
kind: 'service-kind',
logger: someLogger(),
})
then you can start a new trace with:
tracer.start()
Or you can pass and object with an old tracer:
const oldTracerData = {
traceId: 'some-trace-id',
parentId: 'some-parent-id',
spanId: 'some-span-id',
sampled: true,
}
tracer.start(oldTracerData)
And this will continue the trace given in the method parameters.
To finish a trace record, just use:
tracer.finish()
This will stop the current trace record. If an error happen in your program, you can pass as argument the error and the finish
method will trace the error, this push the error data to kafka and zipkin.
const err = new Error('awesome error')
tracer.finish(err)