SamplingRule
Source:
src/AWS/XRay/SamplingRule.ts
An AWS X-Ray sampling rule that controls which requests are recorded as traces by instrumented applications.
X-Ray evaluates sampling rules in ascending priority order for each request. The first matching rule borrows from its reservoir, then applies the fixed rate.
Creating Sampling Rules
Section titled “Creating Sampling Rules”Sample all requests to a service
import * as XRay from "alchemy/AWS/XRay";
const rule = yield* XRay.SamplingRule("SampleEverything", { priority: 100, fixedRate: 1.0, reservoirSize: 5, serviceName: "my-api-*",});Low-rate sampling for a noisy endpoint
const rule = yield* XRay.SamplingRule("HealthChecks", { priority: 10, fixedRate: 0.01, urlPath: "/health", httpMethod: "GET",});Match on segment attributes
const rule = yield* XRay.SamplingRule("PremiumTenants", { priority: 50, fixedRate: 0.5, reservoirSize: 1, attributes: { tier: "premium" },});