UNPKG

autotel-cloudflare

Version:

The #1 OpenTelemetry package for Cloudflare Workers - complete bindings coverage, native CF OTel integration, advanced sampling

84 lines (78 loc) 2.03 kB
/** * autotel-cloudflare * * The #1 OpenTelemetry package for Cloudflare Workers * * Features: * - Native Cloudflare OTel integration (works with wrangler.toml destinations) * - Complete bindings coverage (KV, R2, D1, DO, AI, Vectorize, etc.) * - Multiple API styles (instrument, wrapModule, functional) * - Advanced sampling strategies * - Events integration * - Zero vendor lock-in (OTLP compatible) * * @example Quick Start * ```typescript * import { wrapModule, trace } from 'autotel-cloudflare' * * const processOrder = trace(async (orderId: string) => { * const order = await env.ORDERS_KV.get(orderId) * return order * }) * * export default wrapModule( * { * service: { name: 'my-worker' }, * instrumentBindings: true, * sampling: 'adaptive' * }, * { * async fetch(req, env, ctx) { * return Response.json(await processOrder('123')) * } * } * ) * ``` */ // Re-export EVERYTHING from autotel-edge (vendor-agnostic foundation) export * from 'autotel-edge'; export { getRequestLogger, getQueueLogger, getWorkflowLogger, getActorLogger, createWorkersLogger, type ExecutionLogger, type ExecutionLoggerOptions, type ExecutionLogSnapshot, type WorkersLoggerOptions, } from './execution-logger'; // Cloudflare-specific wrappers export { instrument, wrapModule, wrapDurableObject, defineWorkerFetch, type DefineWorkerFetchOptions, type WorkerFetchHandler, } from './wrappers'; // Cloudflare-specific handlers export { instrumentDO, instrumentWorkflow } from './handlers'; // Cloudflare-specific bindings export { instrumentKV, instrumentR2, instrumentD1, instrumentServiceBinding, instrumentBindings, instrumentAI, instrumentVectorize, instrumentHyperdrive, instrumentQueueProducer, instrumentAnalyticsEngine, instrumentImages, instrumentRateLimiter, instrumentBrowserRendering, } from './bindings'; // Global instrumentations export { instrumentGlobalFetch, instrumentGlobalCache } from './global';