Tracer
Direct Subclass:
Tracer is the entry-point between the instrumentation API and the tracing implementation.
The default object acts as a no-op implementation.
Constructor Summary
| Public Constructor | ||
| public |
constructor(imp: *) Note: this constructor should not be called directly by consumers of this code. |
|
Method Summary
| Public Methods | ||
| public |
Request that any buffered or in-memory data is flushed out of the process. |
|
| public |
Handle to implementation object. |
|
| public |
Injects the information about the given span into the carrier so that the span can propogate across inter-process barriers. |
|
| public |
Returns a new Span object with the given operation name using the trace information from the carrier. |
|
| public |
Starts and returns a new Span representing a logical unit of work. |
|
Public Constructors
public constructor(imp: *) source
Note: this constructor should not be called directly by consumers of this code. The singleton's initNewTracer() method should be invoked instead.
Params:
| Name | Type | Attribute | Description |
| imp | * |
Public Methods
public flush(done: function(err: objectg)) source
Request that any buffered or in-memory data is flushed out of the process.
Params:
| Name | Type | Attribute | Description |
| done | function(err: objectg) | optional callback function with
the signature |
public imp(): object source
Handle to implementation object.
Use of this method is discouraged as it greatly reduces the portability of the calling code. Use only when implementation-specific functionality must be used and cannot accessed otherwise.
public inject(span: Span, format: string, carrier: any) source
Injects the information about the given span into the carrier so that the span can propogate across inter-process barriers.
See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers.
Consider this pseudocode example:
var clientSpan = ...;
...
// Inject clientSpan into a text carrier.
var textCarrier = {};
Tracer.inject(clientSpan, Tracer.FORMAT_TEXT_MAP, textCarrier);
// Incorporate the textCarrier into the outbound HTTP request header
// map.
outboundHTTPReq.headers.extend(textCarrier);
// ... send the httpReq
For FORMAT_BINARY, inject() will set the buffer field to an Array-like (Array, ArrayBuffer, or TypedBuffer) object containing the injected binary data. Any valid Object can be used as long as the buffer field of the object can be set.
public join(operationName: string, format: string, carrier: any): Span source
Returns a new Span object with the given operation name using the trace information from the carrier.
See FORMAT_TEXT_MAP and FORMAT_BINARY for the two required carriers.
Consider this pseudocode example:
// Use the inbound HTTP request's headers as a text map carrier.
var textCarrier = inboundHTTPReq.headers;
var serverSpan = Tracer.join(
"operation name", Tracer.FORMAT_TEXT_MAP, textCarrier);
For FORMAT_BINARY, carrier is expected to have a field named buffer
that contains an Array-like object (Array, ArrayBuffer, or TypedBuffer).
public startSpan(nameOrFields: string | object, fields: object): Span source
Starts and returns a new Span representing a logical unit of work.
Params:
| Name | Type | Attribute | Description |
| nameOrFields | string | object | if the given argument is a
string, it is the name of the operation and the second |
|
| fields | object |
|
the fields to set on the newly created span. |
| fields.operationName | string |
|
the name to use for the newly created span. Required if called with a single argument. |
| fields.parent | Span |
|
the parent of the newly created span |
| fields.tags | object |
|
set of key-value pairs which will be set as tags on the newly created Span. Ownership of the object is passed to the created span for efficiency reasons (the caller should not modify this object after calling startSpan). |
| fields.startTime | number |
|
a manually specified start time for the created Span object. The time should be specified in milliseconds as Unix timestamp. Decimal value are supported to represent time values with sub-millisecond accuracy. |