0.3.1 • Published 5 years ago

ot-got v0.3.1

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

ot-got Build Status Coverage Status install size

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

Example trace with Jaeger

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