UNPKG

691 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3class Trace {
4 constructor(traceId = Trace._generateId(), spanId = traceId, parentSpanId = traceId) {
5 this.traceId = traceId;
6 this.spanId = spanId;
7 this.parentSpanId = parentSpanId;
8 }
9 static _generateId() {
10 return (Date.now() + (Math.floor(Math.random() * 10))).toString(16);
11 }
12 span() {
13 this.parentSpanId = this.spanId;
14 this.spanId = Trace._generateId();
15 }
16 toJSON() {
17 return {
18 traceId: this.traceId,
19 spanId: this.spanId,
20 parentSpanId: this.parentSpanId
21 };
22 }
23}
24exports.Trace = Trace;