Skip to content
This repository was archived by the owner on Aug 25, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/metrics/src/trace/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const TIMEOUT_TRACE = 6;
export const ERROR_TRACE = 8;
export const TRACER_TIMEOUT = 30 * 1000;
export const CURRENT_SPAN = Symbol('CURRENT_SPAN');
export const CURRENT_TRACER = Symbol('CURRENT_TRACER');
export const SKIP_RATE = Symbol('SKIP_RATE');
15 changes: 11 additions & 4 deletions packages/metrics/src/trace/TraceManager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';
const cls = require('./cls');
const TRACEID = 'traceId';
const uuid = require('uuid');
import { Tracer } from './Tracer';
const debug = require('debug')('Pandora:Metrics:TraceManager');
import { MessageSender } from '../util/MessageSender';
import { MessageConstants } from '../MetricsConstants';
import { TRACER_TIMEOUT } from './Constants';
import { TRACER_TIMEOUT, CURRENT_TRACER } from './Constants';

export class TraceManager {

Expand Down Expand Up @@ -49,7 +48,7 @@ export class TraceManager {
}

getCurrentTracer() {
const traceId = this.ns.get(TRACEID);
const traceId = this.ns.get(CURRENT_TRACER);
if (traceId) {
return this.traceContainer[traceId];
}
Expand All @@ -59,14 +58,22 @@ export class TraceManager {
return this.traceContainer[traceId];
}

startLocal(name) {

}

endLocal(name) {

}

create(options: {
traceId?,
ns?
} = {}) {
try {
options.traceId = options.traceId || uuid();
const traceId = options.traceId;
this.ns.set(TRACEID, traceId);
this.ns.set(CURRENT_TRACER, traceId);
options.ns = this.ns;
const tracer = new Tracer(options);
this.traceContainer[traceId] = tracer;
Expand Down