@karmaniverous/aws-xray-tools
    Preparing search index...

    @karmaniverous/aws-xray-tools

    AWS X-Ray Tools

    npm version Node Current docs changelog license

    Small, focused utilities for guarded AWS X-Ray capture of AWS SDK v3 clients.

    This package is intended to be imported by other aws-*-tools packages so they can offer consistent, optional X-Ray instrumentation without duplicating guarded-import logic.

    npm i @karmaniverous/aws-xray-tools
    

    This package is ESM-only (Node >= 20).

    import {
    captureAwsSdkV3Client,
    shouldEnableXray,
    type Logger,
    type XrayMode,
    type XrayState,
    } from '@karmaniverous/aws-xray-tools';
    import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
    import { captureAwsSdkV3Client } from '@karmaniverous/aws-xray-tools';

    const base = new SecretsManagerClient({ region: 'us-east-1' });

    // Guarded: does nothing unless capture is enabled and daemon is configured.
    const client = captureAwsSdkV3Client(base, {
    mode: 'auto',
    daemonAddress: process.env.AWS_XRAY_DAEMON_ADDRESS,
    logger: console,
    });
    • mode: 'off': never capture.
    • mode: 'auto' (default): capture only when AWS_XRAY_DAEMON_ADDRESS is set.
    • mode: 'on': force capture (throws if daemon address is missing).

    This package loads aws-xray-sdk only when capture is enabled.

    To enable capture in your app/package, install the optional peer dependency:

    npm i aws-xray-sdk
    

    If capture is enabled but aws-xray-sdk is not installed, captureAwsSdkV3Client throws with a clear error message.


    Built for you with ❤️ on Bali! Find more great tools & templates on my GitHub Profile.