Skip to main content

SDK Reference

CheckUpstream SDKs instrument your application to capture outbound HTTP telemetry. They automatically detect calls to supported services and report latency, status codes, and error rates. SDKs are available for 8 languages, all sharing the same configuration surface.


Installation

npm install @checkupstream/sdk

Initialization

The @checkupstream/sdk package patches globalThis.fetch to automatically intercept outbound HTTP calls.

import { checkupstream } from "@checkupstream/sdk";

checkupstream.init({
  apiKey: "cup_your_api_key",
});

// Your existing fetch calls are now instrumented
const response = await fetch("https://api.stripe.com/v1/charges");
// → Telemetry event: { host: "api.stripe.com", endpoint: "/v1/charges", status: 200, latency_ms: 142 }

Shutdown

process.on("SIGTERM", async () => {
  await checkupstream.shutdown();
  process.exit(0);
});

Framework integrations: Express, Fastify, Hono, NestJS, Next.js, Nuxt, SvelteKit


Common Configuration

All SDKs share the same configuration options. Field names use the idiomatic casing for each language (e.g., apiKey in JS, api_key in Python, APIKey in Go).

CheckUpstreamConfig
PropertyTypeStatusDefaultDescription
apiKey
stringRequiredYour project API key (starts with cup_)
endpoint
stringOptional"https://ingest.checkupstream.com/v1/events"Telemetry ingestion endpoint
services
string[]OptionalundefinedRestrict monitoring to specific service slugs. If omitted, all auto-detected services are tracked.
flushIntervalMs
numberOptional10000How often to flush the telemetry batch (milliseconds)
maxBatchSize
numberOptional100Maximum events per batch before auto-flush
enabled
booleanOptionaltrueSet to false to disable the SDK entirely (useful for test environments)

Telemetry Events

Each intercepted request generates a telemetry event:

TelemetryEvent
PropertyTypeStatusDefaultDescription
host
stringRequiredRequest hostname, e.g. "api.stripe.com". The server maps hosts to services.
endpoint
stringRequiredRequest path, e.g. "/v1/charges"
status
numberRequiredHTTP status code
latency_ms
numberRequiredRequest duration in milliseconds
ts
numberRequiredUnix timestamp (ms)

Events are batched and sent as a TelemetryBatch:

TelemetryBatch
PropertyTypeStatusDefaultDescription
sdk_key
stringRequiredYour API key
batch
TelemetryEvent[]RequiredArray of telemetry events

Auto-Detected Services

All SDKs automatically recognize outbound requests to these domains:

DomainService
api.stripe.comStripe
api.openai.comOpenAI
api.anthropic.comAnthropic
s3.amazonaws.comAWS S3
dynamodb.amazonaws.comAWS DynamoDB
api.twilio.comTwilio
api.sendgrid.comSendGrid
api.resend.comResend
api.clerk.comClerk
api.supabase.coSupabase
api.posthog.comPostHog
api.segment.ioSegment
api.mixpanel.comMixpanel
api.algolia.comAlgolia
api.cloudinary.comCloudinary

Subdomain matching is also supported: for example, us-east-1.s3.amazonaws.com matches AWS S3.

Filtering Services

To only track specific services, pass a services array:

checkupstream.init({
  apiKey: "cup_your_api_key",
  services: ["stripe", "openai"],
});

Requests to other services will be passed through without instrumentation.

Disabling in Tests

checkupstream.init({
  apiKey: "cup_test_key",
  enabled: process.env.NODE_ENV === "production",
});