ot-got
v0.3.1
Published
Convenience wrapper for got to add opentracing spans to requests
Downloads
42
Maintainers
Readme
ot-got
Convenience wrapper for
got
to that adds opentracing spans to the request.
Copied then adapted for opentracing from gl-got Assumes you already use opentracing-javascript in your project.
Screenshot
Install
$ npm install --save ot-got
or
$ yarn add ot-got
Usage
This package can be used like you would use normal got
with the exception of if you want to trace the requests, you must add a config, like so:
const otGot = require('ot-got');
otGot('https://your-microservice.io', {
tracingOptions: {
parentSpan: span,
injectHeaders: true
}
}).then(res => {
// response
});
API
Same as got
(including the stream API and aliases), but with some additional options below.
tracingOptions
Type: object
Shared config for all your tracing. See below for possible properties.
tracer
Type: Tracer
Default: globalTracer()
Can be set manually, but if not this will use the opentracing package globalTracer()
function.
parentSpan
Type: Span
Passes in a span used as childOf
ref to the span we create in ot-got for requests.
closeParentSpan
Type: boolean
Default: false
Wether you want the client do close the parent span or not
injectHeaders
Type: boolean
Default: false
Wether you want the client to inject headers to the request or not. By doing this the service you are calling will be able to continue the trace.
License
MIT © Sindre Sorhus © Fredrik Pettersen