Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/** Whether this span is a RootSpan */
get isRootSpan(): boolean {
return this.parentSpanId === '';
}
/** Trace id asscoiated with span. */
traceId = '';
/** Trace state associated with span */
traceState: webTypes.TraceState = '';
/** The display name of the span. */
name = DEFAULT_SPAN_NAME;
/** Kind of span. */
kind: webTypes.SpanKind = webTypes.SpanKind.UNSPECIFIED;
/** An object to log information to. Logs to the JS console by default. */
logger: webTypes.Logger = console;
/**
* Status associated with this span. Defaults to OK status. Note that the
* `code` is not an HTTP status, but is a specific trace status code. See:
* https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#mapping-from-http-status-codes-to-trace-status-codes
*/
status: webTypes.Status = { code: webTypes.CanonicalCode.OK };
/** A set of attributes, each in the format [KEY]:[VALUE] */
attributes: webTypes.Attributes = {};
/** Text annotations with a set of attributes. */
annotations: webTypes.Annotation[] = [];
constructor(
/** Trace associated with this root span. */
private readonly tracer: webTypes.TracerBase,
/** A trace options object to build the root span. */
context?: webTypes.TraceOptions
) {
super();
if (context) {
this.name = context.name;
this.kind = context.kind || webTypes.SpanKind.UNSPECIFIED;
const spanContext = context.spanContext;
if (spanContext) {
this.parentSpanId = spanContext.spanId || '';
this.traceId = spanContext.traceId;
this.traceState = spanContext.traceState || '';
}
} else {
this.traceId = randomTraceId();
}
}