@kangc/skywalking-backend-js
Version:
The NodeJS agent for Apache SkyWalking
70 lines • 2.76 kB
JavaScript
;
/*!
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var DummySpan_1 = tslib_1.__importDefault(require("../../trace/span/DummySpan"));
var Segment_1 = tslib_1.__importDefault(require("../../trace/context/Segment"));
var ContextManager_1 = tslib_1.__importDefault(require("./ContextManager"));
var DummyContext = /** @class */ (function () {
function DummyContext() {
this.segment = new Segment_1.default();
this.nSpans = 0;
this.finished = false;
}
DummyContext.prototype.newEntrySpan = function (operation, carrier, inherit) {
return DummySpan_1.default.create(this);
};
DummyContext.prototype.newExitSpan = function (operation, component, inherit) {
return DummySpan_1.default.create(this);
};
DummyContext.prototype.newLocalSpan = function (operation) {
return DummySpan_1.default.create(this);
};
DummyContext.prototype.start = function (span) {
var spans = ContextManager_1.default.spansDup();
if (!this.nSpans++) {
ContextManager_1.default.checkCold(); // set cold to false
if (spans.indexOf(span) === -1)
spans.push(span);
}
return this;
};
DummyContext.prototype.stop = function (span) {
if (--this.nSpans)
return false;
ContextManager_1.default.clear(span);
return true;
};
DummyContext.prototype.async = function (span) {
ContextManager_1.default.clear(span);
};
DummyContext.prototype.resync = function (span) {
ContextManager_1.default.restore(span);
};
DummyContext.prototype.traceId = function () {
if (!this.segment.relatedTraces) {
return 'N/A';
}
return this.segment.relatedTraces[0].toString();
};
return DummyContext;
}());
exports.default = DummyContext;
//# sourceMappingURL=DummyContext.js.map