autotel-cloudflare 2.18.18 → 2.18.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actors.d.ts +54 -89
- package/dist/actors.d.ts.map +1 -0
- package/dist/actors.js +990 -986
- package/dist/actors.js.map +1 -1
- package/dist/agents.d.ts +102 -128
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +275 -259
- package/dist/agents.js.map +1 -1
- package/dist/bindings-D3lNJZmq.js +975 -0
- package/dist/bindings-D3lNJZmq.js.map +1 -0
- package/dist/bindings-xEZcXo5r.d.ts +149 -0
- package/dist/bindings-xEZcXo5r.d.ts.map +1 -0
- package/dist/bindings.d.ts +2 -139
- package/dist/bindings.js +3 -4
- package/dist/common-DiWH6nmG.js +63 -0
- package/dist/common-DiWH6nmG.js.map +1 -0
- package/dist/events.d.ts +1 -1
- package/dist/events.js +3 -3
- package/dist/execution-logger-BxmgP8jF.js +65 -0
- package/dist/execution-logger-BxmgP8jF.js.map +1 -0
- package/dist/{logger-Cm_73k3-.d.ts → execution-logger-tgQmJeeU.d.ts} +9 -7
- package/dist/execution-logger-tgQmJeeU.d.ts.map +1 -0
- package/dist/handlers-CMg9l_T-.js +378 -0
- package/dist/handlers-CMg9l_T-.js.map +1 -0
- package/dist/handlers-C_VojUeA.d.ts +96 -0
- package/dist/handlers-C_VojUeA.d.ts.map +1 -0
- package/dist/handlers.d.ts +2 -112
- package/dist/handlers.js +3 -4
- package/dist/index.d.ts +20 -99
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +644 -600
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +3 -3
- package/dist/logger.js +5 -4
- package/dist/parse-error.d.ts +2 -1
- package/dist/parse-error.js +3 -3
- package/dist/sampling.d.ts +1 -4
- package/dist/sampling.js +3 -3
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -3
- package/package.json +6 -6
- package/dist/bindings.js.map +0 -1
- package/dist/chunk-KAUHT25H.js +0 -1084
- package/dist/chunk-KAUHT25H.js.map +0 -1
- package/dist/chunk-MIDMNKDC.js +0 -333
- package/dist/chunk-MIDMNKDC.js.map +0 -1
- package/dist/chunk-O4IYKWPJ.js +0 -55
- package/dist/chunk-O4IYKWPJ.js.map +0 -1
- package/dist/chunk-RVVMMPWN.js +0 -63
- package/dist/chunk-RVVMMPWN.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/handlers.js.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/parse-error.js.map +0 -1
- package/dist/sampling.js.map +0 -1
- package/dist/testing.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings-D3lNJZmq.js","names":[],"sources":["../src/bindings/ai.ts","../src/bindings/vectorize.ts","../src/bindings/hyperdrive.ts","../src/bindings/queue-producer.ts","../src/bindings/analytics-engine.ts","../src/bindings/images.ts","../src/bindings/bindings.ts","../src/bindings/rate-limiter.ts","../src/bindings/browser-rendering.ts"],"sourcesContent":["/**\n * Workers AI binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\n/**\n * Instrument Workers AI binding\n */\nexport function instrumentAI<T extends Ai>(ai: T, bindingName?: string): T {\n const name = bindingName || 'ai';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'run' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [model] = args as [string, unknown, unknown];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `AI ${name}: run ${model}`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'gen_ai.system': 'cloudflare-workers-ai',\n 'gen_ai.operation.name': 'run',\n 'gen_ai.request.model': model,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n if (result?.usage?.prompt_tokens !== undefined) {\n setAttr(span, 'gen_ai.usage.input_tokens', Number(result.usage.prompt_tokens));\n }\n if (result?.usage?.completion_tokens !== undefined) {\n setAttr(span, 'gen_ai.usage.output_tokens', Number(result.usage.completion_tokens));\n }\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(ai, handler);\n}\n","/**\n * Vectorize binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\nconst TRACED_METHODS = ['query', 'insert', 'upsert', 'deleteByIds', 'getByIds', 'describe'] as const;\n\n/**\n * Instrument Vectorize index binding\n */\nexport function instrumentVectorize<T extends VectorizeIndex>(vectorize: T, indexName?: string): T {\n const name = indexName || 'vectorize';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (typeof prop === 'string' && TRACED_METHODS.includes(prop as any) && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const operation = prop as string;\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n const attributes: Record<string, string | number> = {\n 'db.system': 'cloudflare-vectorize',\n 'db.operation': operation,\n 'db.collection.name': name,\n };\n\n // Per-operation attributes\n if (operation === 'query') {\n const queryInput = args[0] as { topK?: number } | undefined;\n if (queryInput?.topK !== undefined) {\n attributes['db.vectorize.top_k'] = queryInput.topK;\n }\n }\n\n if ((operation === 'insert' || operation === 'upsert') && Array.isArray(args[0])) {\n attributes['db.vectorize.vectors_count'] = args[0].length;\n }\n\n return tracer.startActiveSpan(\n `Vectorize ${name}: ${operation}`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n\n if (operation === 'query' && result?.matches) {\n setAttr(span, 'db.vectorize.matches_count', result.matches.length);\n }\n\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(vectorize, handler);\n}\n","/**\n * Hyperdrive binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\n/**\n * Instrument Hyperdrive binding\n */\nexport function instrumentHyperdrive<T extends Hyperdrive>(hyperdrive: T, bindingName?: string): T {\n const name = bindingName || 'hyperdrive';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'connect' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n const attributes: Record<string, string | number> = {\n 'db.system': 'cloudflare-hyperdrive',\n 'db.operation': 'connect',\n };\n\n // Extract connection info safely (never record password)\n try {\n setAttr({ setAttribute: (k: string, v: any) => { if (v !== undefined && v !== null) attributes[k] = v; } }, 'server.address', target.host);\n setAttr({ setAttribute: (k: string, v: any) => { if (v !== undefined && v !== null) attributes[k] = v; } }, 'server.port', target.port);\n setAttr({ setAttribute: (k: string, v: any) => { if (v !== undefined && v !== null) attributes[k] = v; } }, 'db.user', target.user);\n } catch {\n // Properties may not be accessible in all environments\n }\n\n return tracer.startActiveSpan(\n `Hyperdrive ${name}: connect`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(hyperdrive, handler);\n}\n","/**\n * Queue producer binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\n/**\n * Instrument Queue producer binding\n */\nexport function instrumentQueueProducer<T extends Queue>(queue: T, queueName?: string): T {\n const name = queueName || 'queue';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'send' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `Queue ${name}: send`,\n {\n kind: SpanKind.PRODUCER,\n attributes: {\n 'messaging.system': 'cloudflare-queues',\n 'messaging.operation.type': 'publish',\n 'messaging.operation': 'send',\n 'messaging.destination.name': name,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n setAttr(span, 'messaging.message.id', (result as any)?.messageId);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n if (prop === 'sendBatch' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [messages] = args as [{ body: unknown }[]];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `Queue ${name}: sendBatch`,\n {\n kind: SpanKind.PRODUCER,\n attributes: {\n 'messaging.system': 'cloudflare-queues',\n 'messaging.operation.type': 'publish',\n 'messaging.operation': 'sendBatch',\n 'messaging.destination.name': name,\n 'messaging.batch.message_count': Array.isArray(messages) ? messages.length : 0,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(queue, handler);\n}\n","/**\n * Analytics Engine binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap } from './common';\n\n/**\n * Instrument Analytics Engine binding\n */\nexport function instrumentAnalyticsEngine<T extends AnalyticsEngineDataset>(ae: T, datasetName?: string): T {\n const name = datasetName || 'analytics-engine';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'writeDataPoint' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [dataPoint] = args as [AnalyticsEngineDataPoint | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n const attributes: Record<string, string | number> = {\n 'analytics.system': 'cloudflare-analytics-engine',\n 'analytics.operation': 'writeDataPoint',\n };\n\n if (dataPoint) {\n if (dataPoint.indexes) {\n attributes['analytics.indexes_count'] = Array.isArray(dataPoint.indexes) ? dataPoint.indexes.length : 1;\n }\n if (dataPoint.doubles) {\n attributes['analytics.doubles_count'] = dataPoint.doubles.length;\n }\n if (dataPoint.blobs) {\n attributes['analytics.blobs_count'] = dataPoint.blobs.length;\n }\n }\n\n return tracer.startActiveSpan(\n `AnalyticsEngine ${name}: writeDataPoint`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n },\n (span) => {\n try {\n // writeDataPoint is synchronous/void\n Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(ae, handler);\n}\n","/**\n * Images binding instrumentation\n *\n * The Images binding uses a fluent chain: input() -> transform() -> draw() -> output()\n * We only create a span at the terminal output() call to avoid intermediate noise.\n * info() is a standalone operation and gets its own span.\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\nconst pipelineMetaSymbol = Symbol('images-pipeline-meta');\n\ninterface PipelineMeta {\n operationCount: number;\n}\n\ninterface ImagesLike {\n info(blob: ReadableStream | ArrayBuffer | Blob): Promise<{ width: number; height: number; format: string }>;\n input(blob: ReadableStream | ArrayBuffer | Blob): ImageTransformerLike;\n}\n\ninterface ImageTransformerLike {\n transform(options: unknown): ImageTransformerLike;\n draw(image: unknown, options?: unknown): ImageTransformerLike;\n output(options?: unknown): Promise<ImageOutputLike>;\n}\n\ninterface ImageOutputLike {\n response(): Response;\n blob(): Promise<Blob>;\n arrayBuffer(): Promise<ArrayBuffer>;\n}\n\nfunction proxyTransformer(transformer: ImageTransformerLike, meta: PipelineMeta, bindingName: string): ImageTransformerLike {\n const handler: ProxyHandler<ImageTransformerLike> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if ((prop === 'transform' || prop === 'draw') && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n meta.operationCount++;\n const result = Reflect.apply(fnTarget, target, args);\n // If the result is the transformer itself (fluent chain), return our proxy\n if (result === target || (result && typeof result === 'object' && 'output' in result)) {\n return proxyTransformer(result as ImageTransformerLike, meta, bindingName);\n }\n return result;\n },\n });\n }\n\n if (prop === 'output' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n const [formatOrOptions] = args;\n\n const attributes: Record<string, string | number> = {\n 'images.system': 'cloudflare-images',\n 'images.pipeline.operation_count': meta.operationCount,\n };\n\n // Capture output format\n if (typeof formatOrOptions === 'string') {\n attributes['images.output.format'] = formatOrOptions;\n } else if (formatOrOptions && typeof formatOrOptions === 'object') {\n const fmt = (formatOrOptions as any).format;\n if (fmt) attributes['images.output.format'] = fmt;\n }\n\n return tracer.startActiveSpan(\n `Images ${bindingName}: output`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n const proxy = new Proxy(transformer, handler);\n Object.defineProperty(proxy, pipelineMetaSymbol, {\n value: meta,\n writable: false,\n enumerable: false,\n configurable: false,\n });\n return proxy;\n}\n\n/**\n * Instrument Images binding\n */\nexport function instrumentImages<T extends ImagesLike>(images: T, bindingName?: string): T {\n const name = bindingName || 'images';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'info' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `Images ${name}: info`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'images.system': 'cloudflare-images',\n 'images.operation': 'info',\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n setAttr(span, 'images.width', result?.width);\n setAttr(span, 'images.height', result?.height);\n setAttr(span, 'images.format', result?.format);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n if (prop === 'input' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const transformer = Reflect.apply(fnTarget, target, args) as ImageTransformerLike;\n const meta: PipelineMeta = { operationCount: 0 };\n return proxyTransformer(transformer, meta, name);\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(images, handler);\n}\n","/**\n * Auto-instrumentation for Cloudflare Workers bindings\n * \n * Note: This file uses Cloudflare Workers types (KVNamespace, R2Bucket, D1Database, Fetcher, etc.)\n * which are globally available via @cloudflare/workers-types when listed in tsconfig.json.\n * These types are devDependencies only - they're not runtime dependencies.\n * At runtime, Cloudflare Workers runtime provides the actual implementations.\n * \n * This module provides automatic tracing for Cloudflare bindings:\n * - KV (key-value operations)\n * - R2 (object storage operations)\n * - D1 (database operations)\n * - Service Bindings\n * - Events Engine\n * - Workers AI\n * - Vectorize\n * - Hyperdrive\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport { WorkerTracer, getActiveConfig } from 'autotel-edge';\nimport { wrap, isWrapped } from './common';\nimport { instrumentAI } from './ai';\nimport { instrumentVectorize } from './vectorize';\nimport { instrumentHyperdrive } from './hyperdrive';\nimport { instrumentQueueProducer } from './queue-producer';\nimport { instrumentAnalyticsEngine } from './analytics-engine';\nimport { instrumentImages } from './images';\n\ntype DbStatementCapture = 'off' | 'obfuscated' | 'full';\n\n/**\n * Sanitize a SQL statement based on the capture mode.\n * - 'full': returns the statement as-is\n * - 'obfuscated': replaces string literals and numbers with '?'\n * - 'off': returns undefined (attribute not set)\n */\nfunction sanitizeStatement(query: string, mode: DbStatementCapture): string | undefined {\n if (mode === 'off') return undefined;\n if (mode === 'obfuscated') return query.replaceAll(/'[^']*'/g, \"'?'\").replaceAll(/\\b\\d+\\b/g, '?');\n return query;\n}\n\n/**\n * Instrument KV namespace\n */\nexport function instrumentKV<K extends KVNamespace>(kv: K, namespaceName?: string): K {\n const name = namespaceName || 'kv';\n \n const kvHandler: ProxyHandler<K> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n \n if (prop === 'get' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [key, options] = args as [string, KVNamespaceGetOptions<unknown> | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `KV ${name}: get`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-kv',\n 'db.operation': 'get',\n 'db.namespace': name,\n 'db.key': key,\n 'db.cache_hit': options?.cacheTtl !== undefined,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setAttribute('db.result.type', result === null ? 'null' : typeof result);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n if (prop === 'put' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [key] = args as [string, unknown, KVNamespacePutOptions | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `KV ${name}: put`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-kv',\n 'db.operation': 'put',\n 'db.namespace': name,\n 'db.key': key,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n if (prop === 'delete' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [key] = args as [string];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `KV ${name}: delete`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-kv',\n 'db.operation': 'delete',\n 'db.namespace': name,\n 'db.key': key,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n if (prop === 'list' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [options] = args as [KVNamespaceListOptions | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `KV ${name}: list`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-kv',\n 'db.operation': 'list',\n 'db.namespace': name,\n 'db.prefix': options?.prefix || undefined,\n 'db.limit': options?.limit || undefined,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setAttribute('db.result.keys_count', result.keys.length);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n return value;\n },\n };\n \n return wrap(kv, kvHandler);\n}\n\n/**\n * Instrument R2 bucket\n */\nexport function instrumentR2<R extends R2Bucket>(r2: R, bucketName?: string): R {\n const name = bucketName || 'r2';\n \n const r2Handler: ProxyHandler<R> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n \n if (prop === 'get' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [key] = args as [string, R2GetOptions | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `R2 ${name}: get`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-r2',\n 'db.operation': 'get',\n 'db.bucket': name,\n 'db.key': key,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n if (result) {\n span.setAttribute('db.result.size', result.size);\n span.setAttribute('db.result.etag', result.etag);\n span.setAttribute('db.result.content_type', result.httpMetadata?.contentType);\n } else {\n span.setAttribute('db.result.exists', false);\n }\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n if (prop === 'put' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [key] = args as [string, ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, R2PutOptions | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `R2 ${name}: put`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-r2',\n 'db.operation': 'put',\n 'db.bucket': name,\n 'db.key': key,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setAttribute('db.result.etag', result.etag);\n span.setAttribute('db.result.uploaded', result.uploaded);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n if (prop === 'delete' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const keys = args as string[];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `R2 ${name}: delete`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-r2',\n 'db.operation': 'delete',\n 'db.bucket': name,\n 'db.keys_count': keys.length,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n if (prop === 'list' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [options] = args as [R2ListOptions | undefined];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `R2 ${name}: list`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'db.system': 'cloudflare-r2',\n 'db.operation': 'list',\n 'db.bucket': name,\n 'db.prefix': options?.prefix || undefined,\n 'db.limit': options?.limit || undefined,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setAttribute('db.result.objects_count', result.objects.length);\n span.setAttribute('db.result.truncated', result.truncated);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n return value;\n },\n };\n \n return wrap(r2, r2Handler);\n}\n\n/**\n * Instrument D1 database\n */\nexport function instrumentD1<D extends D1Database>(d1: D, databaseName?: string): D {\n const name = databaseName || 'd1';\n \n const d1Handler: ProxyHandler<D> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n \n if (prop === 'prepare' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [query] = args as [string];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n const prepared = Reflect.apply(fnTarget, target, args);\n \n // Instrument the prepared statement\n const preparedHandler: ProxyHandler<typeof prepared> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n \n if (prop === 'first' || prop === 'run' || prop === 'all' || prop === 'raw') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const activeConfig = getActiveConfig();\n const captureMode: DbStatementCapture = activeConfig?.dataSafety?.captureDbStatement ?? 'full';\n const statement = sanitizeStatement(query, captureMode);\n const attributes: Record<string, any> = {\n 'db.system': 'cloudflare-d1',\n 'db.operation': prop,\n 'db.name': name,\n };\n if (statement !== undefined) {\n attributes['db.statement'] = statement;\n }\n return tracer.startActiveSpan(\n `D1 ${name}: ${prop}`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n if (prop === 'all' && Array.isArray(result)) {\n span.setAttribute('db.result.rows_count', result.length);\n } else if (prop === 'first' && result) {\n span.setAttribute('db.result.exists', true);\n }\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n return value;\n },\n };\n \n return wrap(prepared, preparedHandler);\n },\n });\n }\n \n if (prop === 'exec' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [query] = args as [string];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n const activeConfig = getActiveConfig();\n const captureMode: DbStatementCapture = activeConfig?.dataSafety?.captureDbStatement ?? 'full';\n const statement = sanitizeStatement(query, captureMode);\n const attributes: Record<string, any> = {\n 'db.system': 'cloudflare-d1',\n 'db.operation': 'exec',\n 'db.name': name,\n };\n if (statement !== undefined) {\n attributes['db.statement'] = statement;\n }\n\n return tracer.startActiveSpan(\n `D1 ${name}: exec`,\n {\n kind: SpanKind.CLIENT,\n attributes,\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n span.setAttribute('db.result.count', result.count);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n \n return value;\n },\n };\n \n return wrap(d1, d1Handler);\n}\n\n/**\n * Instrument service binding (Fetcher)\n *\n * Unlike other bindings, Fetcher objects are native Cloudflare C++ bindings\n * whose methods throw \"Illegal invocation\" when called through a Proxy with\n * a different `this` reference. We work around this by calling `target.fetch()`\n * directly on the original binding instead of using `Reflect.apply` on a\n * detached function reference.\n */\nexport function instrumentServiceBinding<F extends Fetcher>(fetcher: F, serviceName?: string): F {\n const name = serviceName || 'service';\n\n const fetcherHandler: ProxyHandler<F> = {\n get(target, prop) {\n if (prop === 'fetch' && typeof target.fetch === 'function') {\n // Return a plain function wrapper instead of proxying the native method.\n // This avoids detaching the native method from its binding, which would\n // cause \"Illegal invocation\" on Cloudflare's native Fetcher objects.\n const tracedFetch = (...args: any[]) => {\n const [input, init] = args as [RequestInfo | URL, RequestInit | undefined];\n const request = new Request(input, init);\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `Service ${name}: ${request.method}`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'rpc.system': 'cloudflare-service-binding',\n 'rpc.service': name,\n 'http.request.method': request.method,\n 'url.full': request.url,\n },\n },\n async (span) => {\n try {\n // Call fetch directly on the original target to preserve\n // the native `this` binding that Cloudflare requires\n const response = await target.fetch(input, init as RequestInit);\n span.setAttribute('http.response.status_code', response.status);\n span.setStatus({ code: SpanStatusCode.OK });\n return response;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n };\n return tracedFetch;\n }\n\n // For non-fetch properties, access the original target directly\n // to avoid Proxy-related issues with native bindings\n const value = Reflect.get(target, prop);\n if (typeof value === 'function') {\n // Bind native methods to the original target to prevent\n // \"Illegal invocation\" errors\n return value.bind(target);\n }\n return value;\n },\n };\n\n return wrap(fetcher, fetcherHandler);\n}\n\n/**\n * Detection helpers\n */\nconst hasMethod = (obj: any, m: string): boolean =>\n typeof obj?.[m] === 'function';\n\nconst hasExactMethods = (obj: any, methods: string[]): boolean =>\n methods.every(m => hasMethod(obj, m));\n\n/**\n * Auto-instrument all Cloudflare bindings in the environment\n *\n * Detection order (most specific first):\n * 1. R2 — get, put, delete, list, head\n * 2. KV — get, put, delete, list (not head)\n * 3. D1 — prepare, exec\n * 4. Vectorize — query, insert, upsert, describe\n * 5. AI — run + (gateway or models discriminator)\n * 6. Hyperdrive — connect + connectionString + host\n * 7. Queue Producer — send, sendBatch (not get)\n * 8. Analytics Engine — writeDataPoint\n * 9. Images — info, input\n * 10. Service Binding — fetch (broadest, must be last)\n *\n * Not auto-detected (manual only):\n * - Rate Limiter — limit() alone too generic\n * - Browser Rendering — indistinguishable from Service Binding\n */\nconst envCache = new WeakMap<object, Record<string, any>>();\n\nexport function instrumentBindings(env: Record<string, any>): Record<string, any> {\n const cached = envCache.get(env);\n if (cached) return cached;\n\n const instrumented: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(env)) {\n if (!value || typeof value !== 'object') {\n instrumented[key] = value;\n continue;\n }\n\n // Skip already-instrumented bindings\n if (isWrapped(value)) {\n instrumented[key] = value;\n continue;\n }\n\n // 1. R2 — most specific (has head)\n if (hasExactMethods(value, ['get', 'put', 'delete', 'list', 'head'])) {\n instrumented[key] = instrumentR2(value as R2Bucket, key);\n continue;\n }\n\n // 2. KV — like R2 but without head\n if (hasExactMethods(value, ['get', 'put', 'delete', 'list']) && !('head' in value)) {\n instrumented[key] = instrumentKV(value as KVNamespace, key);\n continue;\n }\n\n // 3. D1\n if (hasExactMethods(value, ['prepare', 'exec'])) {\n instrumented[key] = instrumentD1(value as D1Database, key);\n continue;\n }\n\n // 4. Vectorize\n if (hasExactMethods(value, ['query', 'insert', 'upsert', 'describe'])) {\n instrumented[key] = instrumentVectorize(value as VectorizeIndex, key);\n continue;\n }\n\n // 5. AI — has run() + discriminator properties\n if (hasMethod(value, 'run') && ('gateway' in value || 'models' in value)) {\n instrumented[key] = instrumentAI(value as Ai, key);\n continue;\n }\n\n // 6. Hyperdrive — connect + connection properties\n if (hasMethod(value, 'connect') && 'connectionString' in value && 'host' in value) {\n instrumented[key] = instrumentHyperdrive(value as Hyperdrive, key);\n continue;\n }\n\n // 7. Queue Producer — send + sendBatch (not get, to avoid KV collision)\n if (hasExactMethods(value, ['send', 'sendBatch']) && !('get' in value)) {\n instrumented[key] = instrumentQueueProducer(value as Queue, key);\n continue;\n }\n\n // 8. Analytics Engine\n if (hasMethod(value, 'writeDataPoint')) {\n instrumented[key] = instrumentAnalyticsEngine(value as AnalyticsEngineDataset, key);\n continue;\n }\n\n // 9. Images\n if (hasExactMethods(value, ['info', 'input'])) {\n instrumented[key] = instrumentImages(value as any, key);\n continue;\n }\n\n // 10. Service Binding (broadest — must be last)\n if (hasMethod(value, 'fetch')) {\n instrumented[key] = instrumentServiceBinding(value as Fetcher, key);\n continue;\n }\n\n // Unknown binding type — pass through\n instrumented[key] = value;\n }\n\n envCache.set(env, instrumented);\n return instrumented;\n}\n\n","/**\n * Rate Limiter binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\ninterface RateLimiterLike {\n limit(options: { key: string }): Promise<{ success: boolean }>;\n}\n\n/**\n * Instrument Rate Limiter binding (manual only — not auto-detected)\n */\nexport function instrumentRateLimiter<T extends RateLimiterLike>(limiter: T, bindingName?: string): T {\n const name = bindingName || 'rate-limiter';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'limit' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [options] = args as [{ key: string }];\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `RateLimiter ${name}: limit`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'rate_limiter.system': 'cloudflare-rate-limiter',\n 'rate_limiter.key': options?.key,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n setAttr(span, 'rate_limiter.success', result?.success);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(limiter, handler);\n}\n","/**\n * Browser Rendering binding instrumentation\n */\n\nimport {\n trace,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport type { WorkerTracer } from 'autotel-edge';\nimport { wrap, setAttr } from './common';\n\ninterface BrowserRenderingLike {\n fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;\n}\n\n/**\n * Instrument Browser Rendering binding (manual only — not auto-detected)\n */\nexport function instrumentBrowserRendering<T extends BrowserRenderingLike>(browser: T, bindingName?: string): T {\n const name = bindingName || 'browser';\n\n const handler: ProxyHandler<T> = {\n get(target, prop) {\n const value = Reflect.get(target, prop);\n\n if (prop === 'fetch' && typeof value === 'function') {\n return new Proxy(value, {\n apply: (fnTarget, _thisArg, args) => {\n const [input] = args as [RequestInfo | URL, RequestInit | undefined];\n const url = typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url;\n const tracer = trace.getTracer('autotel-edge') as WorkerTracer;\n\n return tracer.startActiveSpan(\n `BrowserRendering ${name}: fetch`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n 'browser.system': 'cloudflare-browser-rendering',\n 'url.full': url,\n },\n },\n async (span) => {\n try {\n const result = await Reflect.apply(fnTarget, target, args);\n setAttr(span, 'http.response.status_code', result?.status);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.recordException(error as Error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n } finally {\n span.end();\n }\n },\n );\n },\n });\n }\n\n return value;\n },\n };\n\n return wrap(browser, handler);\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,aAA2B,IAAO,aAAyB;CACzE,MAAM,OAAO,eAAe;CAqD5B,OAAO,KAAK,IAAI,EAlDd,IAAI,QAAQ,MAAM;EAChB,MAAM,QAAQ,QAAQ,IAAI,QAAQ,IAAI;EAEtC,IAAI,SAAS,SAAS,OAAO,UAAU,YACrC,OAAO,IAAI,MAAM,OAAO,EACtB,QAAQ,UAAU,UAAU,SAAS;GACnC,MAAM,CAAC,SAAS;GAGhB,OAFe,MAAM,UAAU,cAEnB,CAAC,CAAC,gBACZ,MAAM,KAAK,QAAQ,SACnB;IACE,MAAM,SAAS;IACf,YAAY;KACV,iBAAiB;KACjB,yBAAyB;KACzB,wBAAwB;IAC1B;GACF,GACA,OAAO,SAAS;IACd,IAAI;KACF,MAAM,SAAS,MAAM,QAAQ,MAAM,UAAU,QAAQ,IAAI;KACzD,IAAI,QAAQ,OAAO,kBAAkB,QACnC,QAAQ,MAAM,6BAA6B,OAAO,OAAO,MAAM,aAAa,CAAC;KAE/E,IAAI,QAAQ,OAAO,sBAAsB,QACvC,QAAQ,MAAM,8BAA8B,OAAO,OAAO,MAAM,iBAAiB,CAAC;KAEpF,KAAK,UAAU,EAAE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flare Workers types (KVNamespace, R2Bucket, D1Database, Fetcher, etc.)
|
|
6
|
+
* which are globally available via @cloudflare/workers-types when listed in tsconfig.json.
|
|
7
|
+
* These types are devDependencies only - they're not runtime dependencies.
|
|
8
|
+
* At runtime, Cloudflare Workers runtime provides the actual implementations.
|
|
9
|
+
*
|
|
10
|
+
* This module provides automatic tracing for Cloudflare bindings:
|
|
11
|
+
* - KV (key-value operations)
|
|
12
|
+
* - R2 (object storage operations)
|
|
13
|
+
* - D1 (database operations)
|
|
14
|
+
* - Service Bindings
|
|
15
|
+
* - Events Engine
|
|
16
|
+
* - Workers AI
|
|
17
|
+
* - Vectorize
|
|
18
|
+
* - Hyperdrive
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Instrument KV namespace
|
|
22
|
+
*/
|
|
23
|
+
declare function instrumentKV<K extends KVNamespace>(kv: K, namespaceName?: string): K;
|
|
24
|
+
/**
|
|
25
|
+
* Instrument R2 bucket
|
|
26
|
+
*/
|
|
27
|
+
declare function instrumentR2<R extends R2Bucket>(r2: R, bucketName?: string): R;
|
|
28
|
+
/**
|
|
29
|
+
* Instrument D1 database
|
|
30
|
+
*/
|
|
31
|
+
declare function instrumentD1<D extends D1Database>(d1: D, databaseName?: string): D;
|
|
32
|
+
/**
|
|
33
|
+
* Instrument service binding (Fetcher)
|
|
34
|
+
*
|
|
35
|
+
* Unlike other bindings, Fetcher objects are native Cloudflare C++ bindings
|
|
36
|
+
* whose methods throw "Illegal invocation" when called through a Proxy with
|
|
37
|
+
* a different `this` reference. We work around this by calling `target.fetch()`
|
|
38
|
+
* directly on the original binding instead of using `Reflect.apply` on a
|
|
39
|
+
* detached function reference.
|
|
40
|
+
*/
|
|
41
|
+
declare function instrumentServiceBinding<F extends Fetcher>(fetcher: F, serviceName?: string): F;
|
|
42
|
+
declare function instrumentBindings(env: Record<string, any>): Record<string, any>;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/bindings/ai.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Workers AI binding instrumentation
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Instrument Workers AI binding
|
|
50
|
+
*/
|
|
51
|
+
declare function instrumentAI<T extends Ai>(ai: T, bindingName?: string): T;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/bindings/vectorize.d.ts
|
|
54
|
+
/**
|
|
55
|
+
* Vectorize binding instrumentation
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Instrument Vectorize index binding
|
|
59
|
+
*/
|
|
60
|
+
declare function instrumentVectorize<T extends VectorizeIndex>(vectorize: T, indexName?: string): T;
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/bindings/hyperdrive.d.ts
|
|
63
|
+
/**
|
|
64
|
+
* Hyperdrive binding instrumentation
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Instrument Hyperdrive binding
|
|
68
|
+
*/
|
|
69
|
+
declare function instrumentHyperdrive<T extends Hyperdrive>(hyperdrive: T, bindingName?: string): T;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/bindings/queue-producer.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* Queue producer binding instrumentation
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* Instrument Queue producer binding
|
|
77
|
+
*/
|
|
78
|
+
declare function instrumentQueueProducer<T extends Queue>(queue: T, queueName?: string): T;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/bindings/analytics-engine.d.ts
|
|
81
|
+
/**
|
|
82
|
+
* Analytics Engine binding instrumentation
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Instrument Analytics Engine binding
|
|
86
|
+
*/
|
|
87
|
+
declare function instrumentAnalyticsEngine<T extends AnalyticsEngineDataset>(ae: T, datasetName?: string): T;
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/bindings/images.d.ts
|
|
90
|
+
/**
|
|
91
|
+
* Images binding instrumentation
|
|
92
|
+
*
|
|
93
|
+
* The Images binding uses a fluent chain: input() -> transform() -> draw() -> output()
|
|
94
|
+
* We only create a span at the terminal output() call to avoid intermediate noise.
|
|
95
|
+
* info() is a standalone operation and gets its own span.
|
|
96
|
+
*/
|
|
97
|
+
interface ImagesLike {
|
|
98
|
+
info(blob: ReadableStream | ArrayBuffer | Blob): Promise<{
|
|
99
|
+
width: number;
|
|
100
|
+
height: number;
|
|
101
|
+
format: string;
|
|
102
|
+
}>;
|
|
103
|
+
input(blob: ReadableStream | ArrayBuffer | Blob): ImageTransformerLike;
|
|
104
|
+
}
|
|
105
|
+
interface ImageTransformerLike {
|
|
106
|
+
transform(options: unknown): ImageTransformerLike;
|
|
107
|
+
draw(image: unknown, options?: unknown): ImageTransformerLike;
|
|
108
|
+
output(options?: unknown): Promise<ImageOutputLike>;
|
|
109
|
+
}
|
|
110
|
+
interface ImageOutputLike {
|
|
111
|
+
response(): Response;
|
|
112
|
+
blob(): Promise<Blob>;
|
|
113
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Instrument Images binding
|
|
117
|
+
*/
|
|
118
|
+
declare function instrumentImages<T extends ImagesLike>(images: T, bindingName?: string): T;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/bindings/rate-limiter.d.ts
|
|
121
|
+
/**
|
|
122
|
+
* Rate Limiter binding instrumentation
|
|
123
|
+
*/
|
|
124
|
+
interface RateLimiterLike {
|
|
125
|
+
limit(options: {
|
|
126
|
+
key: string;
|
|
127
|
+
}): Promise<{
|
|
128
|
+
success: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Instrument Rate Limiter binding (manual only — not auto-detected)
|
|
133
|
+
*/
|
|
134
|
+
declare function instrumentRateLimiter<T extends RateLimiterLike>(limiter: T, bindingName?: string): T;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/bindings/browser-rendering.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* Browser Rendering binding instrumentation
|
|
139
|
+
*/
|
|
140
|
+
interface BrowserRenderingLike {
|
|
141
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Instrument Browser Rendering binding (manual only — not auto-detected)
|
|
145
|
+
*/
|
|
146
|
+
declare function instrumentBrowserRendering<T extends BrowserRenderingLike>(browser: T, bindingName?: string): T;
|
|
147
|
+
//#endregion
|
|
148
|
+
export { instrumentQueueProducer as a, instrumentAI as c, instrumentKV as d, instrumentR2 as f, instrumentAnalyticsEngine as i, instrumentBindings as l, instrumentRateLimiter as n, instrumentHyperdrive as o, instrumentServiceBinding as p, instrumentImages as r, instrumentVectorize as s, instrumentBrowserRendering as t, instrumentD1 as u };
|
|
149
|
+
//# sourceMappingURL=bindings-xEZcXo5r.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings-xEZcXo5r.d.ts","names":[],"sources":["../src/bindings/bindings.ts","../src/bindings/ai.ts","../src/bindings/vectorize.ts","../src/bindings/hyperdrive.ts","../src/bindings/queue-producer.ts","../src/bindings/analytics-engine.ts","../src/bindings/images.ts","../src/bindings/rate-limiter.ts","../src/bindings/browser-rendering.ts"],"mappings":";;AAkDA;;;;;;;;;;;;;;;AAAqF;AA6KrF;;;;iBA7KgB,YAAA,WAAuB,WAAA,EAAa,EAAA,EAAI,CAAA,EAAG,aAAA,YAAyB,CAAA;;;;iBA6KpE,YAAA,WAAuB,QAAA,EAAU,EAAA,EAAI,CAAA,EAAG,UAAA,YAAsB,CAAA;;;;iBAqL9D,YAAA,WAAuB,UAAA,EAAY,EAAA,EAAI,CAAA,EAAG,YAAA,YAAwB,CAAA;;;AArLH;AAqL/E;;;;;;iBAwIgB,wBAAA,WAAmC,OAAA,EAAS,OAAA,EAAS,CAAA,EAAG,WAAA,YAAuB,CAAA;AAAA,iBA8F/E,kBAAA,CAAmB,GAAA,E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AA,WAAgC,eAAA,EAAiB,OAAA,EAAS,CAAA,EAAG,WAAA,YAAuB,CAAA;;;;AP+BpG;;UQtCU,oBAAA;EACR,KAAA,CAAM,KAAA,EAAO,WAAA,GAAc,GAAA,EAAK,IAAA,GAAO,WAAA,GAAc,OAAA,CAAQ,QAAA;AAAA;;;;iBAM/C,0BAAA,WAAqC,oBAAA,EAAsB,OAAA,EAAS,CAAA,EAAG,WAAA,YAAuB,CAAA"}
|
package/dist/bindings.d.ts
CHANGED
|
@@ -1,139 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Note: This file uses Cloudflare Workers types (KVNamespace, R2Bucket, D1Database, Fetcher, etc.)
|
|
5
|
-
* which are globally available via @cloudflare/workers-types when listed in tsconfig.json.
|
|
6
|
-
* These types are devDependencies only - they're not runtime dependencies.
|
|
7
|
-
* At runtime, Cloudflare Workers runtime provides the actual implementations.
|
|
8
|
-
*
|
|
9
|
-
* This module provides automatic tracing for Cloudflare bindings:
|
|
10
|
-
* - KV (key-value operations)
|
|
11
|
-
* - R2 (object storage operations)
|
|
12
|
-
* - D1 (database operations)
|
|
13
|
-
* - Service Bindings
|
|
14
|
-
* - Events Engine
|
|
15
|
-
* - Workers AI
|
|
16
|
-
* - Vectorize
|
|
17
|
-
* - Hyperdrive
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Instrument KV namespace
|
|
21
|
-
*/
|
|
22
|
-
declare function instrumentKV<K extends KVNamespace>(kv: K, namespaceName?: string): K;
|
|
23
|
-
/**
|
|
24
|
-
* Instrument R2 bucket
|
|
25
|
-
*/
|
|
26
|
-
declare function instrumentR2<R extends R2Bucket>(r2: R, bucketName?: string): R;
|
|
27
|
-
/**
|
|
28
|
-
* Instrument D1 database
|
|
29
|
-
*/
|
|
30
|
-
declare function instrumentD1<D extends D1Database>(d1: D, databaseName?: string): D;
|
|
31
|
-
/**
|
|
32
|
-
* Instrument service binding (Fetcher)
|
|
33
|
-
*
|
|
34
|
-
* Unlike other bindings, Fetcher objects are native Cloudflare C++ bindings
|
|
35
|
-
* whose methods throw "Illegal invocation" when called through a Proxy with
|
|
36
|
-
* a different `this` reference. We work around this by calling `target.fetch()`
|
|
37
|
-
* directly on the original binding instead of using `Reflect.apply` on a
|
|
38
|
-
* detached function reference.
|
|
39
|
-
*/
|
|
40
|
-
declare function instrumentServiceBinding<F extends Fetcher>(fetcher: F, serviceName?: string): F;
|
|
41
|
-
declare function instrumentBindings(env: Record<string, any>): Record<string, any>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Workers AI binding instrumentation
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Instrument Workers AI binding
|
|
48
|
-
*/
|
|
49
|
-
declare function instrumentAI<T extends Ai>(ai: T, bindingName?: string): T;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Vectorize binding instrumentation
|
|
53
|
-
*/
|
|
54
|
-
/**
|
|
55
|
-
* Instrument Vectorize index binding
|
|
56
|
-
*/
|
|
57
|
-
declare function instrumentVectorize<T extends VectorizeIndex>(vectorize: T, indexName?: string): T;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Hyperdrive binding instrumentation
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* Instrument Hyperdrive binding
|
|
64
|
-
*/
|
|
65
|
-
declare function instrumentHyperdrive<T extends Hyperdrive>(hyperdrive: T, bindingName?: string): T;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Queue producer binding instrumentation
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
* Instrument Queue producer binding
|
|
72
|
-
*/
|
|
73
|
-
declare function instrumentQueueProducer<T extends Queue>(queue: T, queueName?: string): T;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Analytics Engine binding instrumentation
|
|
77
|
-
*/
|
|
78
|
-
/**
|
|
79
|
-
* Instrument Analytics Engine binding
|
|
80
|
-
*/
|
|
81
|
-
declare function instrumentAnalyticsEngine<T extends AnalyticsEngineDataset>(ae: T, datasetName?: string): T;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Images binding instrumentation
|
|
85
|
-
*
|
|
86
|
-
* The Images binding uses a fluent chain: input() -> transform() -> draw() -> output()
|
|
87
|
-
* We only create a span at the terminal output() call to avoid intermediate noise.
|
|
88
|
-
* info() is a standalone operation and gets its own span.
|
|
89
|
-
*/
|
|
90
|
-
interface ImagesLike {
|
|
91
|
-
info(blob: ReadableStream | ArrayBuffer | Blob): Promise<{
|
|
92
|
-
width: number;
|
|
93
|
-
height: number;
|
|
94
|
-
format: string;
|
|
95
|
-
}>;
|
|
96
|
-
input(blob: ReadableStream | ArrayBuffer | Blob): ImageTransformerLike;
|
|
97
|
-
}
|
|
98
|
-
interface ImageTransformerLike {
|
|
99
|
-
transform(options: unknown): ImageTransformerLike;
|
|
100
|
-
draw(image: unknown, options?: unknown): ImageTransformerLike;
|
|
101
|
-
output(options?: unknown): Promise<ImageOutputLike>;
|
|
102
|
-
}
|
|
103
|
-
interface ImageOutputLike {
|
|
104
|
-
response(): Response;
|
|
105
|
-
blob(): Promise<Blob>;
|
|
106
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Instrument Images binding
|
|
110
|
-
*/
|
|
111
|
-
declare function instrumentImages<T extends ImagesLike>(images: T, bindingName?: string): T;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Rate Limiter binding instrumentation
|
|
115
|
-
*/
|
|
116
|
-
interface RateLimiterLike {
|
|
117
|
-
limit(options: {
|
|
118
|
-
key: string;
|
|
119
|
-
}): Promise<{
|
|
120
|
-
success: boolean;
|
|
121
|
-
}>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Instrument Rate Limiter binding (manual only — not auto-detected)
|
|
125
|
-
*/
|
|
126
|
-
declare function instrumentRateLimiter<T extends RateLimiterLike>(limiter: T, bindingName?: string): T;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Browser Rendering binding instrumentation
|
|
130
|
-
*/
|
|
131
|
-
interface BrowserRenderingLike {
|
|
132
|
-
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Instrument Browser Rendering binding (manual only — not auto-detected)
|
|
136
|
-
*/
|
|
137
|
-
declare function instrumentBrowserRendering<T extends BrowserRenderingLike>(browser: T, bindingName?: string): T;
|
|
138
|
-
|
|
139
|
-
export { instrumentAI, instrumentAnalyticsEngine, instrumentBindings, instrumentBrowserRendering, instrumentD1, instrumentHyperdrive, instrumentImages, instrumentKV, instrumentQueueProducer, instrumentR2, instrumentRateLimiter, instrumentServiceBinding, instrumentVectorize };
|
|
1
|
+
import { a as instrumentQueueProducer, c as instrumentAI, d as instrumentKV, f as instrumentR2, i as instrumentAnalyticsEngine, l as instrumentBindings, n as instrumentRateLimiter, o as instrumentHyperdrive, p as instrumentServiceBinding, r as instrumentImages, s as instrumentVectorize, t as instrumentBrowserRendering, u as instrumentD1 } from "./bindings-xEZcXo5r.js";
|
|
2
|
+
export { instrumentAI, instrumentAnalyticsEngine, instrumentBindings, instrumentBrowserRendering, instrumentD1, instrumentHyperdrive, instrumentImages, instrumentKV, instrumentQueueProducer, instrumentR2, instrumentRateLimiter, instrumentServiceBinding, instrumentVectorize };
|
package/dist/bindings.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//# sourceMappingURL=bindings.js.map
|
|
1
|
+
import { a as instrumentKV, c as instrumentImages, d as instrumentHyperdrive, f as instrumentVectorize, i as instrumentD1, l as instrumentAnalyticsEngine, n as instrumentRateLimiter, o as instrumentR2, p as instrumentAI, r as instrumentBindings, s as instrumentServiceBinding, t as instrumentBrowserRendering, u as instrumentQueueProducer } from "./bindings-D3lNJZmq.js";
|
|
2
|
+
|
|
3
|
+
export { instrumentAI, instrumentAnalyticsEngine, instrumentBindings, instrumentBrowserRendering, instrumentD1, instrumentHyperdrive, instrumentImages, instrumentKV, instrumentQueueProducer, instrumentR2, instrumentRateLimiter, instrumentServiceBinding, instrumentVectorize };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/bindings/common.ts
|
|
2
|
+
/**
|
|
3
|
+
* Common instrumentation utilities
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Promise tracker for waitUntil
|
|
7
|
+
*/
|
|
8
|
+
var PromiseTracker = class {
|
|
9
|
+
promises = [];
|
|
10
|
+
track(promise) {
|
|
11
|
+
this.promises.push(promise);
|
|
12
|
+
}
|
|
13
|
+
async wait() {
|
|
14
|
+
await Promise.allSettled(this.promises);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Proxy ExecutionContext to track waitUntil promises
|
|
19
|
+
*/
|
|
20
|
+
function proxyExecutionContext(ctx) {
|
|
21
|
+
const tracker = new PromiseTracker();
|
|
22
|
+
return {
|
|
23
|
+
ctx: new Proxy(ctx, { get(target, prop) {
|
|
24
|
+
if (prop === "waitUntil") return (promise) => {
|
|
25
|
+
tracker.track(promise);
|
|
26
|
+
return target.waitUntil(promise);
|
|
27
|
+
};
|
|
28
|
+
return Reflect.get(target, prop);
|
|
29
|
+
} }),
|
|
30
|
+
tracker
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Helper to wrap/unwrap proxied objects
|
|
35
|
+
*/
|
|
36
|
+
const unwrapSymbol = Symbol("unwrap");
|
|
37
|
+
function isWrapped(item) {
|
|
38
|
+
return item && !!item[unwrapSymbol];
|
|
39
|
+
}
|
|
40
|
+
function unwrap(item) {
|
|
41
|
+
if (item && isWrapped(item)) return item[unwrapSymbol];
|
|
42
|
+
else return item;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Set attribute only if value is defined and non-null
|
|
46
|
+
*/
|
|
47
|
+
function setAttr(span, key, value) {
|
|
48
|
+
if (value !== void 0 && value !== null) span.setAttribute(key, value);
|
|
49
|
+
}
|
|
50
|
+
function wrap(item, handler) {
|
|
51
|
+
const proxy = new Proxy(item, handler);
|
|
52
|
+
Object.defineProperty(proxy, unwrapSymbol, {
|
|
53
|
+
value: item,
|
|
54
|
+
writable: false,
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: false
|
|
57
|
+
});
|
|
58
|
+
return proxy;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { wrap as a, unwrap as i, proxyExecutionContext as n, setAttr as r, isWrapped as t };
|
|
63
|
+
//# sourceMappingURL=common-DiWH6nmG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-DiWH6nmG.js","names":[],"sources":["../src/bindings/common.ts"],"sourcesContent":["/**\n * Common instrumentation utilities\n */\n\n/**\n * Promise tracker for waitUntil\n */\nexport class PromiseTracker {\n private promises: Promise<unknown>[] = [];\n\n track(promise: Promise<unknown>): void {\n this.promises.push(promise);\n }\n\n async wait(): Promise<void> {\n await Promise.allSettled(this.promises);\n }\n}\n\n/**\n * Proxy ExecutionContext to track waitUntil promises\n */\nexport function proxyExecutionContext(ctx: ExecutionContext): {\n ctx: ExecutionContext;\n tracker: PromiseTracker;\n} {\n const tracker = new PromiseTracker();\n\n const proxied = new Proxy(ctx, {\n get(target, prop) {\n if (prop === 'waitUntil') {\n return (promise: Promise<unknown>) => {\n tracker.track(promise);\n return target.waitUntil(promise);\n };\n }\n return Reflect.get(target, prop);\n },\n });\n\n return { ctx: proxied, tracker };\n}\n\n/**\n * Helper to wrap/unwrap proxied objects\n */\nconst unwrapSymbol = Symbol('unwrap');\n\ntype Wrapped<T> = { [unwrapSymbol]: T } & T;\n\nexport function isWrapped<T>(item: T): item is Wrapped<T> {\n return item && !!(item as Wrapped<T>)[unwrapSymbol];\n}\n\nexport function unwrap<T extends object>(item: T): T {\n if (item && isWrapped(item)) {\n return item[unwrapSymbol];\n } else {\n return item;\n }\n}\n\n/**\n * Set attribute only if value is defined and non-null\n */\nexport function setAttr(span: { setAttribute: (key: string, value: any) => void }, key: string, value: unknown): void {\n if (value !== undefined && value !== null) {\n span.setAttribute(key, value);\n }\n}\n\nexport function wrap<T extends object>(\n item: T,\n handler: ProxyHandler<T>,\n): Wrapped<T> {\n const proxy = new Proxy(item, handler) as Wrapped<T>;\n Object.defineProperty(proxy, unwrapSymbol, {\n value: item,\n writable: false,\n enumerable: false,\n configurable: false,\n });\n return proxy;\n}\n"],"mappings":";;;;;;;AAOA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,WAA+B,CAAC;CAExC,MAAM,SAAiC;EACrC,KAAK,SAAS,KAAK,OAAO;CAC5B;CAEA,MAAM,OAAsB;EAC1B,MAAM,QAAQ,WAAW,KAAK,QAAQ;CACxC;AACF;;;;AAKA,SAAgB,sBAAsB,KAGpC;CACA,MAAM,UAAU,IAAI,eAAe;CAcnC,OAAO;EAAE,KAAK,IAZM,MAAM,KAAK,EAC7B,IAAI,QAAQ,MAAM;GAChB,IAAI,SAAS,aACX,QAAQ,YAA8B;IACpC,QAAQ,MAAM,OAAO;IACrB,OAAO,OAAO,UAAU,OAAO;GACjC;GAEF,OAAO,QAAQ,IAAI,QAAQ,IAAI;EACjC,EACF,CAEoB;EAAG;CAAQ;AACjC;;;;AAKA,MAAM,eAAe,OAAO,QAAQ;AAIpC,SAAgB,UAAa,MAA6B;CACxD,OAAO,QAAQ,CAAC,CAAE,KAAoB;AACxC;AAEA,SAAgB,OAAyB,MAAY;CACnD,IAAI,QAAQ,UAAU,IAAI,GACxB,OAAO,KAAK;MAEZ,OAAO;AAEX;;;;AAKA,SAAgB,QAAQ,MAA2D,KAAa,OAAsB;CACpH,IAAI,UAAU,UAAa,UAAU,MACnC,KAAK,aAAa,KAAK,KAAK;AAEhC;AAEA,SAAgB,KACd,MACA,SACY;CACZ,MAAM,QAAQ,IAAI,MAAM,MAAM,OAAO;CACrC,OAAO,eAAe,OAAO,cAAc;EACzC,OAAO;EACP,UAAU;EACV,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;AACT"}
|
package/dist/events.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "autotel-edge/events";
|
package/dist/events.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export * from "autotel-edge/events"
|
|
2
|
+
|
|
3
|
+
export { };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getExecutionLogger } from "autotel-edge/logger";
|
|
2
|
+
|
|
3
|
+
//#region src/execution-logger.ts
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function collectHeaders(headers, include) {
|
|
8
|
+
if (!include || include.length === 0) return void 0;
|
|
9
|
+
const allowlist = new Set(include.map((h) => h.toLowerCase()));
|
|
10
|
+
const out = {};
|
|
11
|
+
headers.forEach((value, key) => {
|
|
12
|
+
if (allowlist.has(key.toLowerCase())) out[key] = value;
|
|
13
|
+
});
|
|
14
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
15
|
+
}
|
|
16
|
+
function pickCfContext(request) {
|
|
17
|
+
const cf = Reflect.get(request, "cf");
|
|
18
|
+
if (!isRecord(cf)) return {};
|
|
19
|
+
const out = {};
|
|
20
|
+
if (typeof cf.colo === "string") out.colo = cf.colo;
|
|
21
|
+
if (typeof cf.country === "string") out.country = cf.country;
|
|
22
|
+
if (typeof cf.asn === "number") out.asn = cf.asn;
|
|
23
|
+
if (typeof cf.city === "string") out.city = cf.city;
|
|
24
|
+
if (typeof cf.region === "string") out.region = cf.region;
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create an execution logger pre-populated with common request context.
|
|
29
|
+
* Best used from fetch handlers that already run inside autotel span context.
|
|
30
|
+
*/
|
|
31
|
+
function createWorkersLogger(request, options = {}, ctx) {
|
|
32
|
+
const log = getExecutionLogger(ctx);
|
|
33
|
+
const url = new URL(request.url);
|
|
34
|
+
const cfRay = request.headers.get("cf-ray") ?? void 0;
|
|
35
|
+
const traceparent = request.headers.get("traceparent") ?? void 0;
|
|
36
|
+
log.set({
|
|
37
|
+
request: {
|
|
38
|
+
method: request.method,
|
|
39
|
+
path: url.pathname,
|
|
40
|
+
url: request.url,
|
|
41
|
+
requestId: options.requestId ?? cfRay,
|
|
42
|
+
headers: collectHeaders(request.headers, options.headers)
|
|
43
|
+
},
|
|
44
|
+
cfRay,
|
|
45
|
+
traceparent,
|
|
46
|
+
...pickCfContext(request)
|
|
47
|
+
});
|
|
48
|
+
return log;
|
|
49
|
+
}
|
|
50
|
+
function getRequestLogger(ctx, options) {
|
|
51
|
+
return getExecutionLogger(ctx, options);
|
|
52
|
+
}
|
|
53
|
+
function getQueueLogger(ctx, options) {
|
|
54
|
+
return getExecutionLogger(ctx, options);
|
|
55
|
+
}
|
|
56
|
+
function getWorkflowLogger(ctx, options) {
|
|
57
|
+
return getExecutionLogger(ctx, options);
|
|
58
|
+
}
|
|
59
|
+
function getActorLogger(ctx, options) {
|
|
60
|
+
return getExecutionLogger(ctx, options);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { getWorkflowLogger as a, getRequestLogger as i, getActorLogger as n, getQueueLogger as r, createWorkersLogger as t };
|
|
65
|
+
//# sourceMappingURL=execution-logger-BxmgP8jF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-logger-BxmgP8jF.js","names":[],"sources":["../src/execution-logger.ts"],"sourcesContent":["import {\n type ExecutionLogger,\n type ExecutionLoggerOptions,\n type ExecutionLogSnapshot,\n getExecutionLogger,\n type TraceContext,\n} from 'autotel-edge/logger';\n\nexport type {\n ExecutionLogger,\n ExecutionLoggerOptions,\n ExecutionLogSnapshot,\n};\n\nexport interface WorkersLoggerOptions {\n /** Override derived request id (default: cf-ray header value when present). */\n requestId?: string;\n /** Optional request header allowlist to include in logger context. */\n headers?: string[];\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction collectHeaders(\n headers: Headers,\n include: string[] | undefined,\n): Record<string, string> | undefined {\n if (!include || include.length === 0) return undefined;\n\n const allowlist = new Set(include.map((h) => h.toLowerCase()));\n const out: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (allowlist.has(key.toLowerCase())) {\n out[key] = value;\n }\n });\n\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction pickCfContext(request: Request): Record<string, unknown> {\n const cf = Reflect.get(request, 'cf');\n if (!isRecord(cf)) return {};\n\n const out: Record<string, unknown> = {};\n if (typeof cf.colo === 'string') out.colo = cf.colo;\n if (typeof cf.country === 'string') out.country = cf.country;\n if (typeof cf.asn === 'number') out.asn = cf.asn;\n if (typeof cf.city === 'string') out.city = cf.city;\n if (typeof cf.region === 'string') out.region = cf.region;\n return out;\n}\n\n/**\n * Create an execution logger pre-populated with common request context.\n * Best used from fetch handlers that already run inside autotel span context.\n */\nexport function createWorkersLogger(\n request: Request,\n options: WorkersLoggerOptions = {},\n ctx?: TraceContext,\n): ExecutionLogger {\n const log = getExecutionLogger(ctx);\n const url = new URL(request.url);\n const cfRay = request.headers.get('cf-ray') ?? undefined;\n const traceparent = request.headers.get('traceparent') ?? undefined;\n\n log.set({\n request: {\n method: request.method,\n path: url.pathname,\n url: request.url,\n requestId: options.requestId ?? cfRay,\n headers: collectHeaders(request.headers, options.headers),\n },\n cfRay,\n traceparent,\n ...pickCfContext(request),\n });\n\n return log;\n}\n\nexport function getRequestLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getQueueLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getWorkflowLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n\nexport function getActorLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n return getExecutionLogger(ctx, options);\n}\n"],"mappings":";;;AAqBA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,eACP,SACA,SACoC;CACpC,IAAI,CAAC,WAAW,QAAQ,WAAW,GAAG,OAAO;CAE7C,MAAM,YAAY,IAAI,IAAI,QAAQ,KAAK,MAAM,EAAE,YAAY,CAAC,CAAC;CAC7D,MAAM,MAA8B,CAAC;CACrC,QAAQ,SAAS,OAAO,QAAQ;EAC9B,IAAI,UAAU,IAAI,IAAI,YAAY,CAAC,GACjC,IAAI,OAAO;CAEf,CAAC;CAED,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,IAAI,MAAM;AAC7C;AAEA,SAAS,cAAc,SAA2C;CAChE,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAI;CACpC,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC;CAE3B,MAAM,MAA+B,CAAC;CACtC,IAAI,OAAO,GAAG,SAAS,UAAU,IAAI,OAAO,GAAG;CAC/C,IAAI,OAAO,GAAG,YAAY,UAAU,IAAI,UAAU,GAAG;CACrD,IAAI,OAAO,GAAG,QAAQ,UAAU,IAAI,MAAM,GAAG;CAC7C,IAAI,OAAO,GAAG,SAAS,UAAU,IAAI,OAAO,GAAG;CAC/C,IAAI,OAAO,GAAG,WAAW,UAAU,IAAI,SAAS,GAAG;CACnD,OAAO;AACT;;;;;AAMA,SAAgB,oBACd,SACA,UAAgC,CAAC,GACjC,KAC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