Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
makePayload(metric) {
const serviceName = this.getServiceName(metric);
const tracer = this.getTracer(serviceName);
let parentCtx;
if (metric.parent) {
parentCtx = new Jaeger.SpanContext(
this.convertID(metric.requestID), // traceId,
this.convertID(metric.parent), // spanId,
null, // parentId,
null, // traceIdStr
null, // spanIdStr
null, // parentIdStr
1, // flags
{}, // baggage
"" // debugId
);
}
const span = tracer.startSpan(this.getSpanName(metric), {
startTime: metric.startTime,
childOf: parentCtx,
tags: {
this.rootSpan = tracer.startSpan(name + " " + action, {childOf: parent});
this.rootSpan.setTag("event", "cs");
}
else if (kind === SpanKind.Event) {
this.rootSpan = tracer.startSpan("Event " + action, { childOf: parent });
this.rootSpan.setTag("event", "sr");
}
else if (kind === SpanKind.Task) {
this.rootSpan = tracer.startSpan("Async " + action, { childOf: parent });
this.rootSpan.setTag("event", "sr");
}
else if (kind === SpanKind.Request) {
this.rootSpan = tracer.startSpan(action, { childOf: parent });
this.rootSpan.setTag("event", "sr");
}
this.rootSpan._spanContext = new jaeger.SpanContext(null, null, null, id.correlationId, id.spanId, id.parentId, 0x01);
}
startSpan(span: ISpanTracker, name: string, action: string): ITrackerAdapter {
const parentId = (span.context.requestTracker && span.context.requestTracker.id) || null;
const parent = (parentId && new jaeger.SpanContext(null, null, null, parentId.correlationId, parentId.spanId, parentId.parentId, 0x01)) || null;
return new JaegerRequestTracker(this.tracer, span.id, span.kind, name, action, parent);
}
}