Skip to main content

Basic configuration

import { LynxTracer } from "@lynx/sdk";

const lynx = new LynxTracer({
  clientId: "support-api",
  endpoint: "https://lynx.example.com",
  apiKey: process.env.LYNX_API_KEY,
  workspaceId: "workspace_123",
  environment: "production",
  appVersion: "1.4.0",
});

Capture options

OptionDefaultDescription
sampleRate1Fraction of runs to capture, from 0 to 1.
captureInputtrueCapture input payloads.
captureOutputtrueCapture output payloads.
captureMode"smart"Use "full", "metadata-only", or "smart".
maxPayloadLength5000Maximum serialized payload length.

Delivery options

const lynx = new LynxTracer({
  clientId: "support-api",
  endpoint: "https://lynx.example.com",
  apiKey: process.env.LYNX_API_KEY,
  delivery: {
    mode: "BACKGROUND",
    timeoutMs: 1000,
    flushOnRunEnd: false,
    flushIntervalMs: 3000,
    batchSize: 50,
    maxQueueSize: 1000,
    overflowStrategy: "DROP_OLDEST",
  },
  circuitBreaker: {
    enabled: true,
    failureThreshold: 3,
    cooldownMs: 30000,
  },
});

Environment variables

The default lynx export reads configuration from environment variables.
import { lynx } from "@lynx/sdk";
VariableDescription
LYNX_CLIENT_IDClient or service identifier.
LYNX_ENDPOINTLynx server URL.
LYNX_API_KEYAPI key for ingestion.
LYNX_WORKSPACE_IDDefault workspace ID.
LYNX_AGENT_IDDefault agent ID.
LYNX_SAMPLE_RATESampling rate from 0 to 1.
LYNX_CAPTURE_INPUTWhether to capture inputs.
LYNX_CAPTURE_OUTPUTWhether to capture outputs.
LYNX_CAPTURE_MODEfull, metadata-only, or smart.
LYNX_MAX_PAYLOAD_LENGTHMaximum payload string length.
LYNX_APP_VERSIONApplication version metadata.
LYNX_DEPLOYMENT_IDDeployment ID metadata.
LYNX_ENVIRONMENTRuntime environment metadata.
LYNX_POLICY_VERSIONPolicy version metadata.
LYNX_DELIVERY_MODEBLOCKING or BACKGROUND.
LYNX_DELIVERY_TIMEOUT_MSDelivery timeout in milliseconds.
LYNX_DELIVERY_FLUSH_ON_RUN_ENDtrue or false.
LYNX_DELIVERY_FLUSH_INTERVAL_MSBackground flush interval.
LYNX_DELIVERY_BATCH_SIZEBatch size for blocking mode triggers.
LYNX_DELIVERY_MAX_QUEUE_SIZEMaximum queued event count.
LYNX_DELIVERY_OVERFLOW_STRATEGYDROP_OLDEST or DROP_NEWEST.
LYNX_CIRCUIT_BREAKER_ENABLEDtrue or false.
LYNX_CIRCUIT_BREAKER_FAILURE_THRESHOLDFailure count before opening the breaker.
LYNX_CIRCUIT_BREAKER_COOLDOWN_MSBreaker cooldown in milliseconds.