@splunk/otel
Version:
The Splunk distribution of OpenTelemetry Node Instrumentation provides a Node agent that automatically instruments your Node application to capture and report distributed traces to Splunk APM.
34 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SplunkBatchSpanProcessor = exports.SYNTHETIC_RUN_ID_FIELD = void 0;
/*
* Copyright Splunk Inc.
*
* Licensed 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.
*/
const api_1 = require("@opentelemetry/api");
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
exports.SYNTHETIC_RUN_ID_FIELD = 'Synthetics-RunId';
class SplunkBatchSpanProcessor extends sdk_trace_base_1.BatchSpanProcessor {
onStart(_span, parentContext = api_1.context.active()) {
var _a, _b;
super.onStart(_span, parentContext);
const syntheticsId = (_b = (_a = api_1.propagation
.getBaggage(parentContext)) === null || _a === void 0 ? void 0 : _a.getEntry(exports.SYNTHETIC_RUN_ID_FIELD)) === null || _b === void 0 ? void 0 : _b.value;
if (syntheticsId !== undefined && syntheticsId.length > 0) {
_span.setAttribute(exports.SYNTHETIC_RUN_ID_FIELD, syntheticsId);
}
}
}
exports.SplunkBatchSpanProcessor = SplunkBatchSpanProcessor;
//# sourceMappingURL=SplunkBatchSpanProcessor.js.map