UNPKG

skywalking-backend-js-netease

Version:

The NodeJS agent for Apache SkyWalking

69 lines 2.43 kB
"use strict"; /*! * * 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 }); const tslib_1 = require("tslib"); const DummySpan_1 = tslib_1.__importDefault(require("../../trace/span/DummySpan")); const Segment_1 = tslib_1.__importDefault(require("../../trace/context/Segment")); const ContextManager_1 = tslib_1.__importDefault(require("./ContextManager")); class DummyContext { constructor() { this.segment = new Segment_1.default(); this.nSpans = 0; this.finished = false; } newEntrySpan(operation, carrier, inherit) { return DummySpan_1.default.create(this); } newExitSpan(operation, component, inherit) { return DummySpan_1.default.create(this); } newLocalSpan(operation, parent) { return DummySpan_1.default.create(this); } start(span) { const 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; } stop(span) { if (--this.nSpans) return false; ContextManager_1.default.clear(span); return true; } async(span) { ContextManager_1.default.clear(span); } resync(span) { ContextManager_1.default.restore(span); } traceId() { if (!this.segment.relatedTraces) { return 'N/A'; } return this.segment.relatedTraces[0].toString(); } } exports.default = DummyContext; //# sourceMappingURL=DummyContext.js.map