UNPKG

enhanced-adot-node-autoinstrumentation

Version:

This package provides Amazon Web Services distribution of the OpenTelemetry Node Instrumentation, which allows for auto-instrumentation of NodeJS applications.

26 lines 1.31 kB
"use strict"; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.FallbackSampler = void 0; const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base"); const rate_limiting_sampler_1 = require("./rate-limiting-sampler"); // FallbackSampler samples 1 req/sec and additional 5% of requests using TraceIdRatioBasedSampler. class FallbackSampler { constructor() { this.fixedRateSampler = new sdk_trace_base_1.TraceIdRatioBasedSampler(0.05); this.rateLimitingSampler = new rate_limiting_sampler_1.RateLimitingSampler(1); } shouldSample(context, traceId, spanName, spanKind, attributes, links) { const samplingResult = this.rateLimitingSampler.shouldSample(context, traceId, spanName, spanKind, attributes, links); if (samplingResult.decision !== sdk_trace_base_1.SamplingDecision.NOT_RECORD) { return samplingResult; } return this.fixedRateSampler.shouldSample(context, traceId); } toString() { return 'FallbackSampler{fallback sampling with sampling config of 1 req/sec and 5% of additional requests'; } } exports.FallbackSampler = FallbackSampler; //# sourceMappingURL=fallback-sampler.js.map