gcloud-trace
Custom Google Cloud StackDriver tracing client w/out monkey patching
Installation
npm i --save gcloud-trace
Usage
Configure google trace options:
https://github.com/GoogleCloudPlatform/cloud-trace-nodejs https://github.com/GoogleCloudPlatform/cloud-trace-nodejs/blob/a1650a414c153f68f904909f3bba1d9ae73270da/config.js
const trace = // initialize trace w/ optionstrace
Glossary
Each bar line in the chart below is a SpanData
.
The first bar is the RootSpanData
. SpanData
's have name
s and have labels
(reference properties).
Custom trace RootSpanData
const trace = trace const spanName = 'root trace span'const spanData = trace// ... see span data usage below
Custom trace RootSpanData for a request
// spanName will be the url path// parent span info (traceId and parentSpanId) are extracted from req.headers[trace.HEADER_NAME]// request info labels are automatically added to the spanconst spanData = trace// ... see span data usage below
SpanData methods
// add trace span labelsspanData// add trace span propertiesspanData// end trace span time and report to stackdriverspanData
Create a child SpanData
const spanName = 'childSpanName'spanData // same optional opts..
Maintain trace across services
client.js
const trace = tracestart//...const traceHeader = spanDataconst headers = {}headerstraceHEADER_NAME = traceHeaderhttp
server.js
const trace = tracestart http
Maintain trace non-http across services
client.js
//...const traceHeader = spanData
server.js
const trace =
License
MIT