API & SDK
Node SDK reference
Complete API reference for `@uptimeclarity/node`.
init(options)
Bootstraps the SDK. Call this before any code you want instrumented.
init(options: InitOptions): void
interface InitOptions {
/** Project token. Required. */
token: string;
/** Service name. Defaults to `process.env.npm_package_name`. */
service?: string;
/** Environment. Defaults to `process.env.NODE_ENV`. */
environment?: string;
/** Sample rate, 0–1. Defaults to 1 (capture everything). */
sampleRate?: number;
/** Disable specific integrations. */
disable?: Array<'http' | 'mongodb' | 'fetch'>;
}metric(name, value, tags?)
Emit a custom metric.
metric(name: string, value: number, tags?: Record<string, string>): voidtrace(name, fn)
Wrap an async function in a custom span.
trace<T>(name: string, fn: () => Promise<T>): Promise<T>log.{info,warn,error,debug}(name, payload?)
Emit a structured log line.
log.info('user.signup', { plan: 'pro' })
log.error('payment.failed', err) // Error objects are captured with stackflush()
Force-flush the buffer (e.g. before process exit). Returns when the network request completes or 5 seconds have elapsed.
flush(): Promise<void>