autotel-edge 3.16.5 → 3.16.8
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/{chunk-FCYVL2I7.js → chunk-AL7ZD64M.js} +13 -3
- package/dist/chunk-AL7ZD64M.js.map +1 -0
- package/dist/{chunk-64INGUZF.js → chunk-ILPGMTMU.js} +3 -3
- package/dist/{chunk-64INGUZF.js.map → chunk-ILPGMTMU.js.map} +1 -1
- package/dist/events.d.ts +2 -2
- package/dist/events.js +1 -1
- package/dist/{execution-logger-DxsSbafj.d.ts → execution-logger-77TRRoWn.d.ts} +15 -2
- package/dist/index.d.ts +112 -5
- package/dist/index.js +237 -4
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -1
- package/dist/sampling.d.ts +1 -1
- package/dist/{types-CzykyUX6.d.ts → types-uulICZo7.d.ts} +1 -1
- package/package.json +11 -16
- package/skills/autotel-edge/SKILL.md +0 -4
- package/src/composition.test.ts +130 -0
- package/src/composition.ts +132 -0
- package/src/execution-logger.test.ts +95 -0
- package/src/execution-logger.ts +36 -2
- package/src/index.ts +33 -0
- package/src/middleware-toolkit.test.ts +71 -0
- package/src/middleware-toolkit.ts +94 -0
- package/src/plugin-runner.test.ts +100 -0
- package/src/plugin-runner.ts +215 -0
- package/bin/intent.js +0 -6
- package/dist/chunk-FCYVL2I7.js.map +0 -1
|
@@ -244,13 +244,14 @@ function getExecutionLogger(ctx, options) {
|
|
|
244
244
|
lastSnapshot = snapshot;
|
|
245
245
|
return snapshot;
|
|
246
246
|
},
|
|
247
|
-
fork(label, fn) {
|
|
247
|
+
fork(label, fn, forkOptions) {
|
|
248
248
|
const parentCorrelationId = activeContext.correlationId;
|
|
249
249
|
if (typeof parentCorrelationId !== "string" || parentCorrelationId.length === 0) {
|
|
250
250
|
throw new Error(
|
|
251
251
|
"[autotel-edge] log.fork() requires the parent logger to have a correlationId. Ensure execution context was created by autotel trace instrumentation."
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
|
+
const lifecycle = forkOptions?.lifecycle;
|
|
254
255
|
const tracer = trace.getTracer("autotel-edge.execution-logger");
|
|
255
256
|
void tracer.startActiveSpan(`execution.fork:${label}`, (childSpan) => {
|
|
256
257
|
const childContext = {
|
|
@@ -262,6 +263,7 @@ function getExecutionLogger(ctx, options) {
|
|
|
262
263
|
operation: label,
|
|
263
264
|
_parentCorrelationId: parentCorrelationId
|
|
264
265
|
});
|
|
266
|
+
lifecycle?.onChildEnter?.(childLog);
|
|
265
267
|
return Promise.resolve().then(() => fn()).then(() => {
|
|
266
268
|
childLog.emitNow();
|
|
267
269
|
}).catch((err) => {
|
|
@@ -269,6 +271,14 @@ function getExecutionLogger(ctx, options) {
|
|
|
269
271
|
childLog.error(error);
|
|
270
272
|
childLog.emitNow();
|
|
271
273
|
}).finally(() => {
|
|
274
|
+
try {
|
|
275
|
+
lifecycle?.onChildExit?.(childLog);
|
|
276
|
+
} catch (hookError) {
|
|
277
|
+
console.warn(
|
|
278
|
+
"[autotel-edge] fork onChildExit hook threw:",
|
|
279
|
+
hookError
|
|
280
|
+
);
|
|
281
|
+
}
|
|
272
282
|
childSpan.end();
|
|
273
283
|
});
|
|
274
284
|
});
|
|
@@ -277,5 +287,5 @@ function getExecutionLogger(ctx, options) {
|
|
|
277
287
|
}
|
|
278
288
|
|
|
279
289
|
export { createTraceContext, getExecutionLogger, setSpanName };
|
|
280
|
-
//# sourceMappingURL=chunk-
|
|
281
|
-
//# sourceMappingURL=chunk-
|
|
290
|
+
//# sourceMappingURL=chunk-AL7ZD64M.js.map
|
|
291
|
+
//# sourceMappingURL=chunk-AL7ZD64M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/trace-context.ts","../src/execution-logger.ts"],"names":["otelTrace"],"mappings":";;;;;AAgBA,IAAM,WAAA,uBAAkB,OAAA,EAAsB;AAsDvC,SAAS,mBAAmB,IAAA,EAA0B;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AQ,CAAA;AAAA,UACnC,SAAS,SAAA,EAAW;AAClB,YAAA,OAAA,CAAQ,IAAA;AAAA,cACN,6CAAA;AAAA,cACA;AAAA,aACF;AAAA,UACF;AACA,UAAA,SAAA,CAAU,GAAA,EAAI;AAAA,QAChB,CAAC,CAAA;AAAA,MACL,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"chunk-AL7ZD64M.js","sourcesContent":["/**\n * Trace context types and utilities\n */\n\nimport type {\n AttributeValue,\n Link,\n Span,\n SpanStatusCode,\n TimeInput,\n} from '@opentelemetry/api';\n\n/**\n * WeakMap to store span names for active spans.\n * Enables retrieving span names for correlation helpers.\n */\nconst spanNameMap = new WeakMap<Span, string>();\n\n/**\n * Base trace context containing trace identifiers\n */\nexport interface TraceContextBase {\n traceId: string;\n spanId: string;\n correlationId: string;\n 'code.function'?: string;\n}\n\n/**\n * Span methods available on trace context\n */\nexport interface SpanMethods {\n /** Set a single attribute on the span */\n setAttribute(key: string, value: AttributeValue): void;\n /** Set multiple attributes on the span */\n setAttributes(attrs: Record<string, AttributeValue>): void;\n /** Set the status of the span */\n setStatus(status: { code: SpanStatusCode; message?: string }): void;\n /** Record an exception on the span */\n recordException(exception: Error, time?: TimeInput): void;\n /** Add an event to the span (for logging milestones/checkpoints) */\n addEvent(\n name: string,\n attributesOrStartTime?: Record<string, AttributeValue> | TimeInput,\n startTime?: TimeInput,\n ): void;\n /** Add a link to another span */\n addLink(link: Link): void;\n /** Add multiple links to other spans */\n addLinks(links: Link[]): void;\n /** Update the span name dynamically */\n updateName(name: string): void;\n /** Check if the span is recording */\n isRecording(): boolean;\n}\n\n/**\n * Complete trace context that merges base context and span methods\n *\n * This is the ctx parameter passed to factory functions in trace().\n * It provides access to trace IDs and span manipulation methods.\n */\nexport type TraceContext = TraceContextBase & SpanMethods;\n\n/**\n * Create a TraceContext from an OpenTelemetry Span\n *\n * This utility extracts trace context information from a span\n * and provides span manipulation methods in a consistent format.\n */\nexport function createTraceContext(span: Span): TraceContext {\n const spanContext = span.spanContext();\n return {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n correlationId: spanContext.traceId.slice(0, 16),\n 'code.function': spanNameMap.get(span),\n setAttribute: span.setAttribute.bind(span),\n setAttributes: span.setAttributes.bind(span),\n setStatus: span.setStatus.bind(span),\n recordException: span.recordException.bind(span),\n addEvent: span.addEvent.bind(span),\n addLink: span.addLink.bind(span),\n addLinks: span.addLinks.bind(span),\n updateName: span.updateName.bind(span),\n isRecording: span.isRecording.bind(span),\n };\n}\n\n/**\n * Store the span name for later retrieval via trace context helpers.\n */\nexport function setSpanName(span: Span, name: string): void {\n spanNameMap.set(span, name);\n}\n","import { trace as otelTrace, SpanStatusCode } from '@opentelemetry/api';\nimport type { AttributeValue } from '@opentelemetry/api';\nimport type { TraceContext } from './functional';\nimport { createTraceContext } from './core/trace-context';\n\nconst POST_EMIT_FORK_HINT =\n \"For intentional background work tied to this execution, use log.fork('label', fn) when available.\";\n\nfunction warnPostEmit(method: string, detail: string): void {\n console.warn(\n `[autotel-edge] ${method} called after the execution event was emitted - ${detail} This data will not appear in observability. ${POST_EMIT_FORK_HINT}`,\n );\n}\n\nfunction mergeInto(\n target: Record<string, unknown>,\n source: Record<string, unknown>,\n): void {\n for (const key in source) {\n const sourceVal = source[key];\n if (sourceVal === undefined) continue;\n const targetVal = target[key];\n if (\n sourceVal !== null &&\n typeof sourceVal === 'object' &&\n !Array.isArray(sourceVal) &&\n targetVal !== null &&\n typeof targetVal === 'object' &&\n !Array.isArray(targetVal)\n ) {\n mergeInto(\n targetVal as Record<string, unknown>,\n sourceVal as Record<string, unknown>,\n );\n } else if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {\n target[key] = [...targetVal, ...sourceVal];\n } else {\n target[key] = sourceVal;\n }\n }\n}\n\nfunction generateCorrelationId(): string {\n if (\n typeof globalThis.crypto !== 'undefined' &&\n typeof globalThis.crypto.randomUUID === 'function'\n ) {\n return globalThis.crypto.randomUUID();\n }\n\n return `exec-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n}\n\n/**\n * Optional lifecycle hooks for adapters that need to track child loggers\n * spawned by `log.fork()` (e.g. activeLoggers maps in framework integrations).\n */\nexport interface ForkLifecycle {\n /** Called after the child logger is created, before `fn` runs. */\n onChildEnter?: (child: ExecutionLogger) => void;\n /** Called after the child has finished (emit + drain), success or failure. */\n onChildExit?: (child: ExecutionLogger) => void;\n}\n\nexport interface ForkOptions {\n lifecycle?: ForkLifecycle;\n}\n\nexport interface ExecutionLogger {\n set(fields: Record<string, unknown>): void;\n info(message: string, fields?: Record<string, unknown>): void;\n warn(message: string, fields?: Record<string, unknown>): void;\n error(error: Error | string, fields?: Record<string, unknown>): void;\n getContext(): Record<string, unknown>;\n emitNow(overrides?: Record<string, unknown>): ExecutionLogSnapshot;\n fork(\n label: string,\n fn: () => void | Promise<void>,\n options?: ForkOptions,\n ): void;\n}\n\nexport interface ExecutionLogSnapshot {\n timestamp: string;\n traceId: string;\n spanId: string;\n correlationId: string;\n context: Record<string, unknown>;\n}\n\nexport interface ExecutionLoggerOptions {\n onEmit?: (snapshot: ExecutionLogSnapshot) => void | Promise<void>;\n}\n\nfunction toAttributeValue(value: unknown): AttributeValue | undefined {\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return value;\n }\n\n if (Array.isArray(value)) {\n if (\n value.every((item) => typeof item === 'string') ||\n value.every((item) => typeof item === 'number') ||\n value.every((item) => typeof item === 'boolean')\n ) {\n return value as AttributeValue;\n }\n\n try {\n return JSON.stringify(value);\n } catch {\n return '<serialization-failed>';\n }\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (value instanceof Error) {\n return value.message;\n }\n\n return undefined;\n}\n\nfunction flattenToAttributes(\n fields: Record<string, unknown>,\n prefix = '',\n): Record<string, AttributeValue> {\n const out: Record<string, AttributeValue> = {};\n const seen = new WeakSet<object>();\n\n function flatten(obj: Record<string, unknown>, currentPrefix: string): void {\n for (const [key, value] of Object.entries(obj)) {\n if (value == null) continue;\n\n const nextKey = currentPrefix ? `${currentPrefix}.${key}` : key;\n const attr = toAttributeValue(value);\n\n if (attr !== undefined) {\n out[nextKey] = attr;\n continue;\n }\n\n if (typeof value === 'object' && value.constructor === Object) {\n if (seen.has(value)) {\n out[nextKey] = '<circular-reference>';\n continue;\n }\n\n seen.add(value);\n flatten(value as Record<string, unknown>, nextKey);\n continue;\n }\n\n try {\n out[nextKey] = JSON.stringify(value);\n } catch {\n out[nextKey] = '<serialization-failed>';\n }\n }\n }\n\n flatten(fields, prefix);\n return out;\n}\n\nfunction getErrorAttributes(error: Error): Record<string, AttributeValue> {\n const attributes: Record<string, AttributeValue> = {\n 'error.type': error.name || 'Error',\n 'error.message': error.message,\n };\n\n if (error.stack) {\n attributes['error.stack'] = error.stack;\n }\n\n const structured = error as Error & {\n why?: string;\n fix?: string;\n link?: string;\n code?: string | number;\n status?: number;\n details?: Record<string, unknown>;\n };\n\n if (structured.why) attributes['error.why'] = structured.why;\n if (structured.fix) attributes['error.fix'] = structured.fix;\n if (structured.link) attributes['error.link'] = structured.link;\n if (structured.code !== undefined) {\n attributes['error.code'] =\n typeof structured.code === 'string'\n ? structured.code\n : String(structured.code);\n }\n if (structured.status !== undefined) {\n attributes['error.status'] = structured.status;\n }\n if (structured.details) {\n Object.assign(\n attributes,\n flattenToAttributes(structured.details, 'error.details'),\n );\n }\n\n return attributes;\n}\n\nfunction resolveContext(ctx?: TraceContext): TraceContext {\n if (ctx) return ctx;\n\n const span = otelTrace.getActiveSpan();\n if (!span) {\n throw new Error(\n '[autotel-edge] getExecutionLogger() requires an active span or explicit TraceContext. Wrap your handler with trace() or pass ctx directly.',\n );\n }\n\n return createTraceContext(span);\n}\n\nexport function getExecutionLogger(\n ctx?: TraceContext,\n options?: ExecutionLoggerOptions,\n): ExecutionLogger {\n const activeContext = resolveContext(ctx);\n let contextState: Record<string, unknown> = {};\n let emitted = false;\n let lastSnapshot: ExecutionLogSnapshot | null = null;\n\n const addLogEvent = (\n level: 'info' | 'warn' | 'error',\n message: string,\n fields?: Record<string, unknown>,\n ) => {\n const attrs = fields ? flattenToAttributes(fields) : undefined;\n activeContext.addEvent(`log.${level}`, {\n message,\n ...attrs,\n });\n };\n\n const sealCheck = (method: string, keys: string[]): void => {\n if (emitted) {\n warnPostEmit(\n method,\n `Keys dropped: ${keys.length ? keys.join(', ') : '(empty)'}.`,\n );\n }\n };\n\n return {\n set(fields: Record<string, unknown>) {\n sealCheck('log.set()', Object.keys(fields));\n if (emitted) return;\n mergeInto(contextState, fields);\n activeContext.setAttributes(flattenToAttributes(fields));\n },\n\n info(message: string, fields?: Record<string, unknown>) {\n const keys = fields\n ? ['message', ...Object.keys(fields).filter((k) => k !== 'requestLogs')]\n : ['message'];\n sealCheck('log.info()', keys);\n if (emitted) return;\n addLogEvent('info', message, fields);\n if (fields) {\n mergeInto(contextState, fields);\n activeContext.setAttributes(flattenToAttributes(fields));\n }\n },\n\n warn(message: string, fields?: Record<string, unknown>) {\n const keys = fields\n ? ['message', ...Object.keys(fields).filter((k) => k !== 'requestLogs')]\n : ['message'];\n sealCheck('log.warn()', keys);\n if (emitted) return;\n addLogEvent('warn', message, fields);\n activeContext.setAttribute('autotel.log.level', 'warn');\n if (fields) {\n mergeInto(contextState, fields);\n activeContext.setAttributes(flattenToAttributes(fields));\n }\n },\n\n error(error: Error | string, fields?: Record<string, unknown>) {\n const keys = fields ? [...Object.keys(fields), 'error'] : ['error'];\n sealCheck('log.error()', keys);\n if (emitted) return;\n const err = typeof error === 'string' ? new Error(error) : error;\n\n activeContext.recordException(err);\n activeContext.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n activeContext.setAttributes(getErrorAttributes(err));\n addLogEvent('error', err.message, fields);\n\n if (fields) {\n mergeInto(contextState, fields);\n activeContext.setAttributes(flattenToAttributes(fields));\n }\n\n activeContext.setAttribute('autotel.log.level', 'error');\n },\n\n getContext() {\n return { ...contextState };\n },\n\n emitNow(overrides?: Record<string, unknown>): ExecutionLogSnapshot {\n if (emitted) {\n warnPostEmit('log.emitNow()', 'Ignoring duplicate emit.');\n return lastSnapshot as ExecutionLogSnapshot;\n }\n\n const mergedContext = {\n ...contextState,\n ...(overrides ?? {}),\n };\n const flattened = flattenToAttributes(mergedContext);\n activeContext.setAttributes(flattened);\n\n const snapshot: ExecutionLogSnapshot = {\n timestamp: new Date().toISOString(),\n traceId: activeContext.traceId,\n spanId: activeContext.spanId,\n correlationId: activeContext.correlationId,\n context: mergedContext,\n };\n\n activeContext.addEvent('log.emit.manual', {\n ...flattened,\n });\n\n if (options?.onEmit) {\n Promise.resolve(options.onEmit(snapshot)).catch((error) => {\n console.warn('[autotel-edge] execution logger onEmit failed:', error);\n });\n }\n\n emitted = true;\n lastSnapshot = snapshot;\n return snapshot;\n },\n\n fork(\n label: string,\n fn: () => void | Promise<void>,\n forkOptions?: ForkOptions,\n ): void {\n const parentCorrelationId = activeContext.correlationId;\n if (\n typeof parentCorrelationId !== 'string' ||\n parentCorrelationId.length === 0\n ) {\n throw new Error(\n '[autotel-edge] log.fork() requires the parent logger to have a correlationId. ' +\n 'Ensure execution context was created by autotel trace instrumentation.',\n );\n }\n\n const lifecycle = forkOptions?.lifecycle;\n const tracer = otelTrace.getTracer('autotel-edge.execution-logger');\n void tracer.startActiveSpan(`execution.fork:${label}`, (childSpan) => {\n const childContext: TraceContext = {\n ...createTraceContext(childSpan),\n correlationId: generateCorrelationId(),\n };\n\n const childLog = getExecutionLogger(childContext);\n childLog.set({\n operation: label,\n _parentCorrelationId: parentCorrelationId,\n });\n\n lifecycle?.onChildEnter?.(childLog);\n\n return Promise.resolve()\n .then(() => fn())\n .then(() => {\n childLog.emitNow();\n })\n .catch((err: unknown) => {\n const error = err instanceof Error ? err : new Error(String(err));\n childLog.error(error);\n childLog.emitNow();\n })\n .finally(() => {\n try {\n lifecycle?.onChildExit?.(childLog);\n } catch (hookError) {\n console.warn(\n '[autotel-edge] fork onChildExit hook threw:',\n hookError,\n );\n }\n childSpan.end();\n });\n });\n },\n };\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { ParentBasedSampler, AlwaysOnSampler } from '@opentelemetry/sdk-trace-ba
|
|
|
5
5
|
import { createContextKey, context } from '@opentelemetry/api';
|
|
6
6
|
|
|
7
7
|
// src/core/exporter.ts
|
|
8
|
-
var PACKAGE_VERSION = "3.16.
|
|
8
|
+
var PACKAGE_VERSION = "3.16.8";
|
|
9
9
|
var defaultHeaders = {
|
|
10
10
|
accept: "application/json",
|
|
11
11
|
"content-type": "application/json",
|
|
@@ -306,5 +306,5 @@ function createInitialiser(config) {
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
export { OTLPExporter, createInitialiser, getActiveConfig, parseConfig, setConfig };
|
|
309
|
-
//# sourceMappingURL=chunk-
|
|
310
|
-
//# sourceMappingURL=chunk-
|
|
309
|
+
//# sourceMappingURL=chunk-ILPGMTMU.js.map
|
|
310
|
+
//# sourceMappingURL=chunk-ILPGMTMU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/exporter.ts","../src/types.ts","../src/core/spanprocessor.ts","../src/core/config.ts"],"names":["api_context"],"mappings":";;;;;;;AAiBA,IAAM,eAAA,GAAkB,QAAA;AAExB,IAAM,cAAA,GAAyC;AAAA,EAC7C,MAAA,EAAQ,kBAAA;AAAA,EACR,cAAA,EAAgB,kBAAA;AAAA,EAChB,YAAA,EAAc,iBAAiB,eAAe,CAAA;AAChD,CAAA;AAKO,IAAM,eAAN,MAA2C;AAAA,EACxC,OAAA;AAAA,EACA,GAAA;AAAA,EAER,YAAY,MAAA,EAA4B;AACtC,IAAA,IAAA,CAAK,MAAM,MAAA,CAAO,GAAA;AAClB,IAAA,IAAA,CAAK,UAAU,MAAA,CAAO,MAAA,CAAO,EAAC,EAAG,cAAA,EAAgB,OAAO,OAAO,CAAA;AAAA,EACjE;AAAA,EAEA,MAAA,CAAO,OAAc,cAAA,EAAsD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A;AAAA,GACnD;AAEA,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,OAAO,IAAI,kBAAA,CAAmB,EAAE,IAAA,EAAM,cAAqB,CAAA;AAAA,EAC7D;AAEA,EAAA,OAAO,YAAA;AACT;AAKO,SAAS,kBAAkB,MAAA,EAA0C;AAC1E,EAAA,IAAI,OAAO,WAAW,UAAA,EAAY;AAChC,IAAA,OAAO,CAAC,KAAK,OAAA,KAAY;AACvB,MAAA,MAAM,IAAA,GAAO,WAAA,CAAY,MAAA,CAAO,GAAA,EAAK,OAAO,CAAC,CAAA;AAC7C,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,EACF,CAAA,MAAO;AACL,IAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,IAAA,OAAO,MAAM,MAAA;AAAA,EACf;AACF","file":"chunk-64INGUZF.js","sourcesContent":["/**\n * Lightweight OTLP exporter for edge environments\n * Ported and adapted from @microlabs/\n *\n * This exporter is much smaller than the standard @opentelemetry/exporter-trace-otlp-http\n * because it uses fetch() directly instead of Node.js http/https modules.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\nimport { OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\nimport { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';\nimport type { SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport type { OTLPExporterConfig } from '../types';\n\n// Version is injected at build time via tsup define\n// This avoids runtime filesystem access which isn't available in edge environments\nconst PACKAGE_VERSION = process.env.AUTOTEL_EDGE_VERSION || '0.1.1';\n\nconst defaultHeaders: Record<string, string> = {\n accept: 'application/json',\n 'content-type': 'application/json',\n 'user-agent': `autotel-edge v${PACKAGE_VERSION}`,\n};\n\n/**\n * Minimal OTLP exporter using fetch()\n */\nexport class OTLPExporter implements SpanExporter {\n private headers: Record<string, string>;\n private url: string;\n\n constructor(config: OTLPExporterConfig) {\n this.url = config.url;\n this.headers = Object.assign({}, defaultHeaders, config.headers);\n }\n\n export(items: any[], resultCallback: (result: ExportResult) => void): void {\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: any[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n this.send(items, resolve, reject);\n } catch (error) {\n reject(error);\n }\n });\n }\n\n send(\n items: any[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void,\n ): void {\n const decoder = new TextDecoder();\n const exportMessage = JsonTraceSerializer.serializeRequest(items);\n\n const body = decoder.decode(exportMessage);\n const params: RequestInit = {\n method: 'POST',\n headers: this.headers,\n body,\n };\n\n fetch(this.url, params)\n .then((response) => {\n if (response.ok) {\n onSuccess();\n } else {\n onError(\n new OTLPExporterError(\n `Exporter received a statusCode: ${response.status}`,\n ),\n );\n }\n })\n .catch((error) => {\n onError(\n new OTLPExporterError(\n `Exception during export: ${error.toString()}`,\n error.code,\n error.stack,\n ),\n );\n });\n }\n\n async shutdown(): Promise<void> {\n // No-op for edge environments\n }\n}\n","/**\n * Shared types for autotel-edge\n */\n\nimport type {\n Attributes,\n Context,\n Span,\n SpanOptions,\n TextMapPropagator,\n} from '@opentelemetry/api';\nimport type {\n ReadableSpan,\n Sampler,\n SpanExporter,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\n\n// Re-export commonly used types\n\n\n/**\n * Extended SpanOptions with per-span sampler support\n */\nexport interface ExtendedSpanOptions extends SpanOptions {\n sampler?: Sampler;\n}\n\n/**\n * Trigger types for edge handlers\n * Can be a Request or any vendor-specific trigger type\n */\nexport type Trigger =\n | Request\n | DOConstructorTrigger\n | WorkflowTrigger\n | 'do-alarm'\n | unknown;\n\nexport interface DOConstructorTrigger {\n id: string;\n name?: string;\n}\n\nexport interface WorkflowTrigger {\n type: 'workflow';\n name: string;\n}\n\n/**\n * Config types\n */\nexport interface OTLPExporterConfig {\n url: string;\n headers?: Record<string, string>;\n}\n\nexport type ExporterConfig = OTLPExporterConfig | SpanExporter;\n\nexport interface ServiceConfig {\n name: string;\n namespace?: string;\n version?: string;\n}\n\nexport interface ParentRatioSamplingConfig {\n acceptRemote?: boolean;\n ratio: number;\n}\n\ntype HeadSamplerConf = Sampler | ParentRatioSamplingConfig;\n\nexport interface SamplingConfig<HS extends HeadSamplerConf = HeadSamplerConf> {\n headSampler?: HS;\n tailSampler?: TailSampleFn;\n}\n\nexport interface InstrumentationOptions {\n instrumentGlobalFetch?: boolean;\n instrumentGlobalCache?: boolean;\n /**\n * Disable instrumentation entirely (useful for local development)\n * When enabled, the handler is returned as-is without any instrumentation\n * @default false\n */\n disabled?: boolean;\n}\n\n/**\n * Utility types\n */\nexport type OrPromise<T> = T | Promise<T>;\n\n/**\n * Adapter event types\n */\nexport type FunnelStepStatus =\n | 'started'\n | 'completed'\n | 'abandoned'\n | 'failed'\n | (string & {});\n\nexport type OutcomeStatus =\n | 'success'\n | 'failure'\n | 'partial'\n | (string & {});\n\nexport interface EdgeEventBase {\n [key: string]: unknown;\n service: string;\n timestamp: number;\n attributes: Record<string, unknown>;\n traceId?: string;\n spanId?: string;\n correlationId?: string;\n name: string; // Normalized event name for easy access\n}\n\nexport interface EdgeTrackEvent extends EdgeEventBase {\n type: 'event';\n event: string;\n}\n\nexport interface EdgeFunnelStepEvent extends EdgeEventBase {\n type: 'funnel-step';\n funnel: string;\n status: FunnelStepStatus;\n}\n\nexport interface EdgeOutcomeEvent extends EdgeEventBase {\n type: 'outcome';\n operation: string;\n outcome: OutcomeStatus;\n}\n\nexport interface EdgeValueEvent extends EdgeEventBase {\n type: 'value';\n metric: string;\n value: number;\n}\n\nexport type EdgeEvent =\n | EdgeTrackEvent\n | EdgeFunnelStepEvent\n | EdgeOutcomeEvent\n | EdgeValueEvent;\n\nexport type EdgeSubscriber = (event: EdgeEvent) => OrPromise<void>;\n\nexport interface FetcherConfig {\n includeTraceContext?: boolean | ((request: Request) => boolean);\n}\n\nexport interface RouteServiceConfig {\n service: string;\n}\n\nexport interface PostProcessParams {\n /**\n * The request object that was passed to the fetch handler.\n */\n request: Request;\n /**\n * The generated response object.\n */\n response: Response;\n /**\n * A readable version of the span object that can be used to access the span's attributes and events.\n */\n readable: ReadableSpan;\n}\n\nexport interface FetchHandlerConfig {\n /**\n * Whether to enable context propagation for incoming requests to `fetch`.\n * This enables or disables distributed tracing from W3C Trace Context headers.\n * @default true\n */\n acceptTraceContext?: boolean | ((request: Request) => boolean);\n /**\n * Allows further customization of the generated span, based on the request/response data.\n */\n postProcess?: (span: Span, ctx: PostProcessParams) => void;\n /**\n * Route patterns to include for fetch handler instrumentation.\n * Supports glob patterns like '/api/**'.\n * If not set, all routes are included.\n */\n include?: string[];\n /**\n * Route patterns to exclude from fetch handler instrumentation.\n * Supports glob patterns like '/health' and '/_internal/**'.\n * Exclusions take precedence over inclusions.\n */\n exclude?: string[];\n /**\n * Route-specific service mapping.\n * The first matching pattern wins based on object iteration order.\n */\n routes?: Record<string, RouteServiceConfig>;\n}\n\nexport interface HandlerConfig {\n fetch?: FetchHandlerConfig;\n}\n\nexport interface DataSafetyConfig {\n /** Redact query parameters from URL attributes (default: false) */\n redactQueryParams?: boolean;\n /** Control D1 SQL statement capture: 'full' (default), 'obfuscated', or 'off' */\n captureDbStatement?: 'off' | 'obfuscated' | 'full';\n /** Only capture these email headers (lowercase). When set, other headers are excluded. */\n emailHeaderAllowlist?: string[];\n}\n\ninterface EdgeConfigBase {\n service: ServiceConfig;\n handlers?: HandlerConfig;\n fetch?: FetcherConfig;\n postProcessor?: PostProcessorFn;\n sampling?: SamplingConfig;\n propagator?: TextMapPropagator;\n instrumentation?: InstrumentationOptions;\n subscribers?: EdgeSubscriber[];\n /** Opt-in data safety controls for sensitive attribute capture */\n dataSafety?: DataSafetyConfig;\n}\n\ninterface EdgeConfigExporter extends EdgeConfigBase {\n exporter: ExporterConfig;\n}\n\ninterface EdgeConfigSpanProcessors extends EdgeConfigBase {\n spanProcessors: SpanProcessor | SpanProcessor[];\n}\n\nexport type EdgeConfig = EdgeConfigExporter | EdgeConfigSpanProcessors;\n\nexport function isSpanProcessorConfig(\n config: EdgeConfig,\n): config is EdgeConfigSpanProcessors {\n return !!(config as EdgeConfigSpanProcessors).spanProcessors;\n}\n\nexport interface ResolvedEdgeConfig extends EdgeConfigBase {\n handlers: Required<HandlerConfig>;\n fetch: Required<FetcherConfig>;\n postProcessor: PostProcessorFn;\n sampling: Required<SamplingConfig<Sampler>>;\n spanProcessors: SpanProcessor[];\n propagator: TextMapPropagator;\n instrumentation: InstrumentationOptions;\n subscribers: EdgeSubscriber[];\n}\n\n/**\n * Function types\n */\nexport type ResolveConfigFn<Env = any> = (\n env: Env,\n trigger: Trigger,\n) => EdgeConfig;\nexport type ConfigurationOption = EdgeConfig | ResolveConfigFn;\n\nexport type PostProcessorFn = (spans: ReadableSpan[]) => ReadableSpan[];\nexport type TailSampleFn = (traceInfo: LocalTrace) => boolean;\n\nexport interface LocalTrace {\n traceId: string;\n spans: ReadableSpan[];\n localRootSpan: ReadableSpan;\n}\n\n/**\n * Span processor with flush support\n */\nexport type TraceFlushableSpanProcessor = SpanProcessor & {\n forceFlush: (traceId?: string) => Promise<void>;\n};\n\n/**\n * Handler instrumentation\n */\nexport interface InitialSpanInfo {\n name: string;\n options: SpanOptions;\n context?: Context;\n}\n\nexport interface HandlerInstrumentation<T extends Trigger, R extends any> {\n getInitialSpanInfo: (trigger: T) => InitialSpanInfo;\n getAttributesFromResult?: (result: Awaited<R>) => Attributes;\n instrumentTrigger?: (trigger: T) => T;\n executionSucces?: (span: Span, trigger: T, result: Awaited<R>) => void;\n executionFailed?: (span: Span, trigger: T, error?: any) => void;\n}\n\n/**\n * Utility types\n */\n\nexport {type Attributes, type Context, type Span, type SpanOptions} from '@opentelemetry/api';\nexport {type ReadableSpan} from '@opentelemetry/sdk-trace-base';\n","/**\n * Span processor with flush and tail sampling support\n */\n\nimport type { Context } from '@opentelemetry/api';\nimport type {\n ReadableSpan,\n Span,\n SpanExporter,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type { PostProcessorFn, TailSampleFn, LocalTrace } from '../types';\n\n/**\n * Span processor that supports flush by trace ID and tail sampling\n */\nexport class SpanProcessorWithFlush implements SpanProcessor {\n private exporter: SpanExporter;\n private postProcessor?: PostProcessorFn;\n private spans: Map<string, ReadableSpan[]> = new Map();\n\n constructor(exporter: SpanExporter, postProcessor?: PostProcessorFn) {\n this.exporter = exporter;\n this.postProcessor = postProcessor;\n }\n\n onStart(_span: Span, _parentContext: Context): void {\n // No-op for now\n }\n\n onEnd(span: ReadableSpan): void {\n const traceId = span.spanContext().traceId;\n\n if (!this.spans.has(traceId)) {\n this.spans.set(traceId, []);\n }\n\n this.spans.get(traceId)!.push(span);\n }\n\n /**\n * Force flush spans for a specific trace\n */\n async forceFlush(traceId?: string): Promise<void> {\n if (traceId) {\n const spans = this.spans.get(traceId);\n if (spans && spans.length > 0) {\n await this.exportSpans(spans);\n this.spans.delete(traceId);\n }\n } else {\n // Flush all traces\n const promises: Promise<void>[] = [];\n for (const [id, spans] of this.spans.entries()) {\n promises.push(this.exportSpans(spans));\n this.spans.delete(id);\n }\n await Promise.all(promises);\n }\n }\n\n async shutdown(): Promise<void> {\n await this.forceFlush();\n if (this.exporter) {\n await this.exporter.shutdown();\n }\n }\n\n /**\n * Export spans with post-processing\n * Errors are caught and logged but don't throw to prevent worker instability\n */\n private async exportSpans(spans: ReadableSpan[]): Promise<void> {\n if (spans.length === 0) return;\n if (!this.exporter) return; // No exporter configured (e.g., in tests)\n\n let processedSpans = spans;\n\n if (this.postProcessor) {\n try {\n processedSpans = this.postProcessor(spans);\n } catch (error) {\n // Post-processor errors should not prevent export\n console.error('[autotel-edge] Post-processor error:', error);\n // Continue with original spans\n processedSpans = spans;\n }\n }\n\n return new Promise((resolve) => {\n this.exporter.export(processedSpans, (result) => {\n if (result.code === 0) {\n // SUCCESS\n resolve();\n } else {\n // Log but don't reject - exporter failures shouldn't crash the worker\n console.error(\n '[autotel-edge] Exporter error:',\n result.error?.message || 'Unknown error',\n );\n resolve(); // Resolve instead of reject to prevent unhandled promise rejection\n }\n });\n });\n }\n}\n\n/**\n * Span processor that supports tail sampling decisions\n */\nexport class TailSamplingSpanProcessor implements SpanProcessor {\n private wrapped: SpanProcessorWithFlush;\n private tailSampler?: TailSampleFn;\n private traces: Map<string, LocalTrace> = new Map();\n\n constructor(\n exporter: SpanExporter,\n postProcessor?: PostProcessorFn,\n tailSampler?: TailSampleFn,\n ) {\n this.wrapped = new SpanProcessorWithFlush(exporter, postProcessor);\n this.tailSampler = tailSampler;\n }\n\n onStart(span: Span, parentContext: Context): void {\n this.wrapped.onStart(span, parentContext);\n }\n\n onEnd(span: ReadableSpan): void {\n const traceId = span.spanContext().traceId;\n const spanId = span.spanContext().spanId;\n const parentSpanId = 'parentSpanId' in span ? span.parentSpanId : undefined;\n\n // Initialize trace if not exists\n if (!this.traces.has(traceId)) {\n this.traces.set(traceId, {\n traceId,\n spans: [],\n localRootSpan: undefined as any, // Will be set when we identify the local root\n });\n }\n\n const trace = this.traces.get(traceId)!;\n\n // Determine if this span is a local root by checking if its parent is in buffered spans\n // A span is a local root if:\n // 1. It has no parentSpanId (definitive root)\n // 2. Its parentSpanId doesn't match any already-buffered span (remote parent = distributed trace entry)\n const hasLocalParent = parentSpanId &&\n trace.spans.some(s => s.spanContext().spanId === parentSpanId);\n\n // Set localRootSpan if this is the local root (no local parent found in buffer)\n if (!hasLocalParent) {\n trace.localRootSpan = span;\n }\n\n trace.spans.push(span); // Buffer the span AFTER checking parent relationships\n\n // Auto-flush decision: only auto-flush for normal traces (no parentSpanId at all)\n // For distributed traces (parentSpanId present), we rely on explicit forceFlush() from instrument.ts\n // This ensures we don't trigger before all spans have been buffered\n const isDefinitiveRoot = !parentSpanId;\n const shouldAutoFlush = isDefinitiveRoot && trace.localRootSpan &&\n trace.localRootSpan.spanContext().spanId === spanId;\n\n if (shouldAutoFlush) {\n if (this.tailSampler) {\n const shouldKeep = this.tailSampler(trace);\n\n if (shouldKeep) {\n // Export ALL buffered spans in the trace\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n // Force flush to actually export the spans\n void this.wrapped.forceFlush(traceId);\n }\n // If not keeping, just drop all spans (don't export)\n } else {\n // No tail sampler, export all buffered spans\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n // Force flush to actually export the spans\n void this.wrapped.forceFlush(traceId);\n }\n\n // Clean up trace after decision\n this.traces.delete(traceId);\n }\n // If not local root span, just buffer it - don't export yet\n }\n\n async forceFlush(traceId?: string): Promise<void> {\n if (traceId) {\n // Make tail sampling decision for this specific trace before flushing\n const trace = this.traces.get(traceId);\n if (trace) {\n // Ensure localRootSpan is set (fallback to first span if not)\n // This handles distributed traces where no span has undefined parentSpanId\n if (!trace.localRootSpan && trace.spans.length > 0) {\n trace.localRootSpan = trace.spans[0];\n }\n\n if (this.tailSampler) {\n const shouldKeep = this.tailSampler(trace);\n\n if (shouldKeep) {\n // Export ALL buffered spans in the trace\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n }\n } else {\n // No tail sampler, export all buffered spans\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n }\n\n // Clean up trace after decision\n this.traces.delete(traceId);\n }\n }\n return this.wrapped.forceFlush(traceId);\n }\n\n async shutdown(): Promise<void> {\n this.traces.clear();\n return this.wrapped.shutdown();\n }\n}\n","/**\n * Configuration system for autotel-edge\n */\n\nimport { W3CTraceContextPropagator } from '@opentelemetry/core';\nimport { ParentBasedSampler, AlwaysOnSampler } from '@opentelemetry/sdk-trace-base';\nimport { context as api_context, createContextKey, type Context } from '@opentelemetry/api';\nimport type {\n EdgeConfig,\n ResolvedEdgeConfig,\n ConfigurationOption,\n Trigger,\n ParentRatioSamplingConfig,\n} from '../types';\nimport { isSpanProcessorConfig } from '../types';\nimport { OTLPExporter } from './exporter';\nimport { TailSamplingSpanProcessor } from './spanprocessor';\n\n/**\n * Type for config initialization function\n */\nexport type Initialiser = (env: any, trigger: Trigger) => ResolvedEdgeConfig;\n\n/**\n * Context key for storing config (isolates config per-request)\n */\nconst CONFIG_KEY = createContextKey('autotel-edge-config');\n\n/**\n * Get the currently active config from context\n *\n * This reads the config from the active context, ensuring each request\n * has its own isolated config even when multiple requests are in-flight.\n */\nexport function getActiveConfig(): ResolvedEdgeConfig | null {\n const value = api_context.active().getValue(CONFIG_KEY) as\n | ResolvedEdgeConfig\n | null\n | undefined;\n return value ?? null;\n}\n\n/**\n * Set the active config in context\n *\n * Returns a new context with the config stored. This context should be\n * used with api_context.with() to ensure the config is isolated per-request.\n *\n * @example\n * ```typescript\n * const config = parseConfig({ service: { name: 'my-service' } });\n * const context = setConfig(config);\n *\n * api_context.with(context, () => {\n * // Config is available here via getActiveConfig()\n * });\n * ```\n */\nexport function setConfig(config: ResolvedEdgeConfig): Context {\n return api_context.active().setValue(CONFIG_KEY, config);\n}\n\n/**\n * Parse and validate configuration\n */\nexport function parseConfig(config: EdgeConfig): ResolvedEdgeConfig {\n // Parse head sampler\n const headSampler =\n config.sampling?.headSampler ??\n new ParentBasedSampler({\n root: new AlwaysOnSampler(),\n });\n\n const parsedHeadSampler =\n typeof headSampler === 'object' && 'ratio' in headSampler\n ? createParentRatioSampler(headSampler)\n : headSampler;\n\n // Parse tail sampler (default: keep sampled or error traces)\n const tailSampler =\n config.sampling?.tailSampler ??\n ((traceInfo) => {\n const localRootSpan = traceInfo.localRootSpan;\n const ctx = localRootSpan.spanContext();\n // Keep if sampled or if root span has error\n return (ctx.traceFlags & 1) === 1 || localRootSpan.status.code === 2; // SAMPLED flag | ERROR status\n });\n\n // Parse exporter - use TailSamplingSpanProcessor when tail sampler is present\n const spanProcessors = isSpanProcessorConfig(config)\n ? Array.isArray(config.spanProcessors)\n ? config.spanProcessors\n : [config.spanProcessors]\n : [\n // Use TailSamplingSpanProcessor to enable tail sampling\n new TailSamplingSpanProcessor(\n typeof config.exporter === 'object' && 'url' in config.exporter\n ? new OTLPExporter(config.exporter)\n : config.exporter,\n config.postProcessor,\n tailSampler, // Wire up the tail sampler!\n ),\n ];\n\n // Build resolved config\n const resolved: ResolvedEdgeConfig = {\n service: config.service,\n handlers: {\n fetch: config.handlers?.fetch ?? {},\n },\n fetch: {\n includeTraceContext: config.fetch?.includeTraceContext ?? true,\n },\n postProcessor: config.postProcessor ?? ((spans) => spans),\n sampling: {\n headSampler: parsedHeadSampler,\n tailSampler,\n },\n spanProcessors,\n propagator: config.propagator ?? new W3CTraceContextPropagator(),\n instrumentation: {\n instrumentGlobalFetch: config.instrumentation?.instrumentGlobalFetch ?? true,\n instrumentGlobalCache: config.instrumentation?.instrumentGlobalCache ?? false,\n disabled: config.instrumentation?.disabled ?? false,\n },\n subscribers: config.subscribers ?? [],\n dataSafety: config.dataSafety,\n };\n\n return resolved;\n}\n\n/**\n * Create a parent-based ratio sampler\n */\nfunction createParentRatioSampler(config: ParentRatioSamplingConfig) {\n const { ratio, acceptRemote = true } = config;\n\n // Simple ratio sampler\n const ratioSampler = {\n shouldSample: () => ({\n decision: Math.random() < ratio ? 1 : 0, // RECORD_AND_SAMPLED : NOT_RECORD\n attributes: {},\n }),\n toString: () => `ParentRatioSampler{ratio=${ratio}}`,\n };\n\n if (acceptRemote) {\n return new ParentBasedSampler({ root: ratioSampler as any });\n }\n\n return ratioSampler;\n}\n\n/**\n * Create a config initializer function\n */\nexport function createInitialiser(config: ConfigurationOption): Initialiser {\n if (typeof config === 'function') {\n return (env, trigger) => {\n const conf = parseConfig(config(env, trigger));\n return conf;\n };\n } else {\n const parsed = parseConfig(config);\n return () => parsed;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/exporter.ts","../src/types.ts","../src/core/spanprocessor.ts","../src/core/config.ts"],"names":["api_context"],"mappings":";;;;;;;AAiBA,IAAM,eAAA,GAAkB,QAAA;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,WAAA,IAAe,EAAC;AAAA,IACpC,YAAY,MAAA,CAAO;AAAA,GACrB;AAEA,EAAA,OAAO,QAAA;AACT;AAKA,SAAS,yBAAyB,MAAA,EAAmC;AACnE,EAAA,MAAM,EAAE,KAAA,EAAO,YAAA,GAAe,IAAA,EAAK,GAAI,MAAA;AAGvC,EAAA,MAAM,YAAA,GAAe;AAAA,IACnB,cAAc,OAAO;AAAA,MACnB,QAAA,EAAU,IAAA,CAAK,MAAA,EAAO,GAAI,QAAQ,CAAA,GAAI,CAAA;AAAA;AAAA,MACtC,YAAY;AAAC,KACf,CAAA;AAAA,IACA,QAAA,EAAU,MAAM,CAAA,yBAAA,EAA4B,KAAK,CAAA,CAAA;AAAA,GACnD;AAEA,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,OAAO,IAAI,kBAAA,CAAmB,EAAE,IAAA,EAAM,cAAqB,CAAA;AAAA,EAC7D;AAEA,EAAA,OAAO,YAAA;AACT;AAKO,SAAS,kBAAkB,MAAA,EAA0C;AAC1E,EAAA,IAAI,OAAO,WAAW,UAAA,EAAY;AAChC,IAAA,OAAO,CAAC,KAAK,OAAA,KAAY;AACvB,MAAA,MAAM,IAAA,GAAO,WAAA,CAAY,MAAA,CAAO,GAAA,EAAK,OAAO,CAAC,CAAA;AAC7C,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA,EACF,CAAA,MAAO;AACL,IAAA,MAAM,MAAA,GAAS,YAAY,MAAM,CAAA;AACjC,IAAA,OAAO,MAAM,MAAA;AAAA,EACf;AACF","file":"chunk-ILPGMTMU.js","sourcesContent":["/**\n * Lightweight OTLP exporter for edge environments\n * Ported and adapted from @microlabs/\n *\n * This exporter is much smaller than the standard @opentelemetry/exporter-trace-otlp-http\n * because it uses fetch() directly instead of Node.js http/https modules.\n */\n\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\nimport { OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\nimport { JsonTraceSerializer } from '@opentelemetry/otlp-transformer';\nimport type { SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport type { OTLPExporterConfig } from '../types';\n\n// Version is injected at build time via tsup define\n// This avoids runtime filesystem access which isn't available in edge environments\nconst PACKAGE_VERSION = process.env.AUTOTEL_EDGE_VERSION || '0.1.1';\n\nconst defaultHeaders: Record<string, string> = {\n accept: 'application/json',\n 'content-type': 'application/json',\n 'user-agent': `autotel-edge v${PACKAGE_VERSION}`,\n};\n\n/**\n * Minimal OTLP exporter using fetch()\n */\nexport class OTLPExporter implements SpanExporter {\n private headers: Record<string, string>;\n private url: string;\n\n constructor(config: OTLPExporterConfig) {\n this.url = config.url;\n this.headers = Object.assign({}, defaultHeaders, config.headers);\n }\n\n export(items: any[], resultCallback: (result: ExportResult) => void): void {\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: any[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n this.send(items, resolve, reject);\n } catch (error) {\n reject(error);\n }\n });\n }\n\n send(\n items: any[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void,\n ): void {\n const decoder = new TextDecoder();\n const exportMessage = JsonTraceSerializer.serializeRequest(items);\n\n const body = decoder.decode(exportMessage);\n const params: RequestInit = {\n method: 'POST',\n headers: this.headers,\n body,\n };\n\n fetch(this.url, params)\n .then((response) => {\n if (response.ok) {\n onSuccess();\n } else {\n onError(\n new OTLPExporterError(\n `Exporter received a statusCode: ${response.status}`,\n ),\n );\n }\n })\n .catch((error) => {\n onError(\n new OTLPExporterError(\n `Exception during export: ${error.toString()}`,\n error.code,\n error.stack,\n ),\n );\n });\n }\n\n async shutdown(): Promise<void> {\n // No-op for edge environments\n }\n}\n","/**\n * Shared types for autotel-edge\n */\n\nimport type {\n Attributes,\n Context,\n Span,\n SpanOptions,\n TextMapPropagator,\n} from '@opentelemetry/api';\nimport type {\n ReadableSpan,\n Sampler,\n SpanExporter,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\n\n// Re-export commonly used types\n\n\n/**\n * Extended SpanOptions with per-span sampler support\n */\nexport interface ExtendedSpanOptions extends SpanOptions {\n sampler?: Sampler;\n}\n\n/**\n * Trigger types for edge handlers\n * Can be a Request or any vendor-specific trigger type\n */\nexport type Trigger =\n | Request\n | DOConstructorTrigger\n | WorkflowTrigger\n | 'do-alarm'\n | unknown;\n\nexport interface DOConstructorTrigger {\n id: string;\n name?: string;\n}\n\nexport interface WorkflowTrigger {\n type: 'workflow';\n name: string;\n}\n\n/**\n * Config types\n */\nexport interface OTLPExporterConfig {\n url: string;\n headers?: Record<string, string>;\n}\n\nexport type ExporterConfig = OTLPExporterConfig | SpanExporter;\n\nexport interface ServiceConfig {\n name: string;\n namespace?: string;\n version?: string;\n}\n\nexport interface ParentRatioSamplingConfig {\n acceptRemote?: boolean;\n ratio: number;\n}\n\ntype HeadSamplerConf = Sampler | ParentRatioSamplingConfig;\n\nexport interface SamplingConfig<HS extends HeadSamplerConf = HeadSamplerConf> {\n headSampler?: HS;\n tailSampler?: TailSampleFn;\n}\n\nexport interface InstrumentationOptions {\n instrumentGlobalFetch?: boolean;\n instrumentGlobalCache?: boolean;\n /**\n * Disable instrumentation entirely (useful for local development)\n * When enabled, the handler is returned as-is without any instrumentation\n * @default false\n */\n disabled?: boolean;\n}\n\n/**\n * Utility types\n */\nexport type OrPromise<T> = T | Promise<T>;\n\n/**\n * Adapter event types\n */\nexport type FunnelStepStatus =\n | 'started'\n | 'completed'\n | 'abandoned'\n | 'failed'\n | (string & {});\n\nexport type OutcomeStatus =\n | 'success'\n | 'failure'\n | 'partial'\n | (string & {});\n\nexport interface EdgeEventBase {\n [key: string]: unknown;\n service: string;\n timestamp: number;\n attributes: Record<string, unknown>;\n traceId?: string;\n spanId?: string;\n correlationId?: string;\n name: string; // Normalized event name for easy access\n}\n\nexport interface EdgeTrackEvent extends EdgeEventBase {\n type: 'event';\n event: string;\n}\n\nexport interface EdgeFunnelStepEvent extends EdgeEventBase {\n type: 'funnel-step';\n funnel: string;\n status: FunnelStepStatus;\n}\n\nexport interface EdgeOutcomeEvent extends EdgeEventBase {\n type: 'outcome';\n operation: string;\n outcome: OutcomeStatus;\n}\n\nexport interface EdgeValueEvent extends EdgeEventBase {\n type: 'value';\n metric: string;\n value: number;\n}\n\nexport type EdgeEvent =\n | EdgeTrackEvent\n | EdgeFunnelStepEvent\n | EdgeOutcomeEvent\n | EdgeValueEvent;\n\nexport type EdgeSubscriber = (event: EdgeEvent) => OrPromise<void>;\n\nexport interface FetcherConfig {\n includeTraceContext?: boolean | ((request: Request) => boolean);\n}\n\nexport interface RouteServiceConfig {\n service: string;\n}\n\nexport interface PostProcessParams {\n /**\n * The request object that was passed to the fetch handler.\n */\n request: Request;\n /**\n * The generated response object.\n */\n response: Response;\n /**\n * A readable version of the span object that can be used to access the span's attributes and events.\n */\n readable: ReadableSpan;\n}\n\nexport interface FetchHandlerConfig {\n /**\n * Whether to enable context propagation for incoming requests to `fetch`.\n * This enables or disables distributed tracing from W3C Trace Context headers.\n * @default true\n */\n acceptTraceContext?: boolean | ((request: Request) => boolean);\n /**\n * Allows further customization of the generated span, based on the request/response data.\n */\n postProcess?: (span: Span, ctx: PostProcessParams) => void;\n /**\n * Route patterns to include for fetch handler instrumentation.\n * Supports glob patterns like '/api/**'.\n * If not set, all routes are included.\n */\n include?: string[];\n /**\n * Route patterns to exclude from fetch handler instrumentation.\n * Supports glob patterns like '/health' and '/_internal/**'.\n * Exclusions take precedence over inclusions.\n */\n exclude?: string[];\n /**\n * Route-specific service mapping.\n * The first matching pattern wins based on object iteration order.\n */\n routes?: Record<string, RouteServiceConfig>;\n}\n\nexport interface HandlerConfig {\n fetch?: FetchHandlerConfig;\n}\n\nexport interface DataSafetyConfig {\n /** Redact query parameters from URL attributes (default: false) */\n redactQueryParams?: boolean;\n /** Control D1 SQL statement capture: 'full' (default), 'obfuscated', or 'off' */\n captureDbStatement?: 'off' | 'obfuscated' | 'full';\n /** Only capture these email headers (lowercase). When set, other headers are excluded. */\n emailHeaderAllowlist?: string[];\n}\n\ninterface EdgeConfigBase {\n service: ServiceConfig;\n handlers?: HandlerConfig;\n fetch?: FetcherConfig;\n postProcessor?: PostProcessorFn;\n sampling?: SamplingConfig;\n propagator?: TextMapPropagator;\n instrumentation?: InstrumentationOptions;\n subscribers?: EdgeSubscriber[];\n /** Opt-in data safety controls for sensitive attribute capture */\n dataSafety?: DataSafetyConfig;\n}\n\ninterface EdgeConfigExporter extends EdgeConfigBase {\n exporter: ExporterConfig;\n}\n\ninterface EdgeConfigSpanProcessors extends EdgeConfigBase {\n spanProcessors: SpanProcessor | SpanProcessor[];\n}\n\nexport type EdgeConfig = EdgeConfigExporter | EdgeConfigSpanProcessors;\n\nexport function isSpanProcessorConfig(\n config: EdgeConfig,\n): config is EdgeConfigSpanProcessors {\n return !!(config as EdgeConfigSpanProcessors).spanProcessors;\n}\n\nexport interface ResolvedEdgeConfig extends EdgeConfigBase {\n handlers: Required<HandlerConfig>;\n fetch: Required<FetcherConfig>;\n postProcessor: PostProcessorFn;\n sampling: Required<SamplingConfig<Sampler>>;\n spanProcessors: SpanProcessor[];\n propagator: TextMapPropagator;\n instrumentation: InstrumentationOptions;\n subscribers: EdgeSubscriber[];\n}\n\n/**\n * Function types\n */\nexport type ResolveConfigFn<Env = any> = (\n env: Env,\n trigger: Trigger,\n) => EdgeConfig;\nexport type ConfigurationOption = EdgeConfig | ResolveConfigFn;\n\nexport type PostProcessorFn = (spans: ReadableSpan[]) => ReadableSpan[];\nexport type TailSampleFn = (traceInfo: LocalTrace) => boolean;\n\nexport interface LocalTrace {\n traceId: string;\n spans: ReadableSpan[];\n localRootSpan: ReadableSpan;\n}\n\n/**\n * Span processor with flush support\n */\nexport type TraceFlushableSpanProcessor = SpanProcessor & {\n forceFlush: (traceId?: string) => Promise<void>;\n};\n\n/**\n * Handler instrumentation\n */\nexport interface InitialSpanInfo {\n name: string;\n options: SpanOptions;\n context?: Context;\n}\n\nexport interface HandlerInstrumentation<T extends Trigger, R extends any> {\n getInitialSpanInfo: (trigger: T) => InitialSpanInfo;\n getAttributesFromResult?: (result: Awaited<R>) => Attributes;\n instrumentTrigger?: (trigger: T) => T;\n executionSucces?: (span: Span, trigger: T, result: Awaited<R>) => void;\n executionFailed?: (span: Span, trigger: T, error?: any) => void;\n}\n\n/**\n * Utility types\n */\n\nexport {type Attributes, type Context, type Span, type SpanOptions} from '@opentelemetry/api';\nexport {type ReadableSpan} from '@opentelemetry/sdk-trace-base';\n","/**\n * Span processor with flush and tail sampling support\n */\n\nimport type { Context } from '@opentelemetry/api';\nimport type {\n ReadableSpan,\n Span,\n SpanExporter,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport type { PostProcessorFn, TailSampleFn, LocalTrace } from '../types';\n\n/**\n * Span processor that supports flush by trace ID and tail sampling\n */\nexport class SpanProcessorWithFlush implements SpanProcessor {\n private exporter: SpanExporter;\n private postProcessor?: PostProcessorFn;\n private spans: Map<string, ReadableSpan[]> = new Map();\n\n constructor(exporter: SpanExporter, postProcessor?: PostProcessorFn) {\n this.exporter = exporter;\n this.postProcessor = postProcessor;\n }\n\n onStart(_span: Span, _parentContext: Context): void {\n // No-op for now\n }\n\n onEnd(span: ReadableSpan): void {\n const traceId = span.spanContext().traceId;\n\n if (!this.spans.has(traceId)) {\n this.spans.set(traceId, []);\n }\n\n this.spans.get(traceId)!.push(span);\n }\n\n /**\n * Force flush spans for a specific trace\n */\n async forceFlush(traceId?: string): Promise<void> {\n if (traceId) {\n const spans = this.spans.get(traceId);\n if (spans && spans.length > 0) {\n await this.exportSpans(spans);\n this.spans.delete(traceId);\n }\n } else {\n // Flush all traces\n const promises: Promise<void>[] = [];\n for (const [id, spans] of this.spans.entries()) {\n promises.push(this.exportSpans(spans));\n this.spans.delete(id);\n }\n await Promise.all(promises);\n }\n }\n\n async shutdown(): Promise<void> {\n await this.forceFlush();\n if (this.exporter) {\n await this.exporter.shutdown();\n }\n }\n\n /**\n * Export spans with post-processing\n * Errors are caught and logged but don't throw to prevent worker instability\n */\n private async exportSpans(spans: ReadableSpan[]): Promise<void> {\n if (spans.length === 0) return;\n if (!this.exporter) return; // No exporter configured (e.g., in tests)\n\n let processedSpans = spans;\n\n if (this.postProcessor) {\n try {\n processedSpans = this.postProcessor(spans);\n } catch (error) {\n // Post-processor errors should not prevent export\n console.error('[autotel-edge] Post-processor error:', error);\n // Continue with original spans\n processedSpans = spans;\n }\n }\n\n return new Promise((resolve) => {\n this.exporter.export(processedSpans, (result) => {\n if (result.code === 0) {\n // SUCCESS\n resolve();\n } else {\n // Log but don't reject - exporter failures shouldn't crash the worker\n console.error(\n '[autotel-edge] Exporter error:',\n result.error?.message || 'Unknown error',\n );\n resolve(); // Resolve instead of reject to prevent unhandled promise rejection\n }\n });\n });\n }\n}\n\n/**\n * Span processor that supports tail sampling decisions\n */\nexport class TailSamplingSpanProcessor implements SpanProcessor {\n private wrapped: SpanProcessorWithFlush;\n private tailSampler?: TailSampleFn;\n private traces: Map<string, LocalTrace> = new Map();\n\n constructor(\n exporter: SpanExporter,\n postProcessor?: PostProcessorFn,\n tailSampler?: TailSampleFn,\n ) {\n this.wrapped = new SpanProcessorWithFlush(exporter, postProcessor);\n this.tailSampler = tailSampler;\n }\n\n onStart(span: Span, parentContext: Context): void {\n this.wrapped.onStart(span, parentContext);\n }\n\n onEnd(span: ReadableSpan): void {\n const traceId = span.spanContext().traceId;\n const spanId = span.spanContext().spanId;\n const parentSpanId = 'parentSpanId' in span ? span.parentSpanId : undefined;\n\n // Initialize trace if not exists\n if (!this.traces.has(traceId)) {\n this.traces.set(traceId, {\n traceId,\n spans: [],\n localRootSpan: undefined as any, // Will be set when we identify the local root\n });\n }\n\n const trace = this.traces.get(traceId)!;\n\n // Determine if this span is a local root by checking if its parent is in buffered spans\n // A span is a local root if:\n // 1. It has no parentSpanId (definitive root)\n // 2. Its parentSpanId doesn't match any already-buffered span (remote parent = distributed trace entry)\n const hasLocalParent = parentSpanId &&\n trace.spans.some(s => s.spanContext().spanId === parentSpanId);\n\n // Set localRootSpan if this is the local root (no local parent found in buffer)\n if (!hasLocalParent) {\n trace.localRootSpan = span;\n }\n\n trace.spans.push(span); // Buffer the span AFTER checking parent relationships\n\n // Auto-flush decision: only auto-flush for normal traces (no parentSpanId at all)\n // For distributed traces (parentSpanId present), we rely on explicit forceFlush() from instrument.ts\n // This ensures we don't trigger before all spans have been buffered\n const isDefinitiveRoot = !parentSpanId;\n const shouldAutoFlush = isDefinitiveRoot && trace.localRootSpan &&\n trace.localRootSpan.spanContext().spanId === spanId;\n\n if (shouldAutoFlush) {\n if (this.tailSampler) {\n const shouldKeep = this.tailSampler(trace);\n\n if (shouldKeep) {\n // Export ALL buffered spans in the trace\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n // Force flush to actually export the spans\n void this.wrapped.forceFlush(traceId);\n }\n // If not keeping, just drop all spans (don't export)\n } else {\n // No tail sampler, export all buffered spans\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n // Force flush to actually export the spans\n void this.wrapped.forceFlush(traceId);\n }\n\n // Clean up trace after decision\n this.traces.delete(traceId);\n }\n // If not local root span, just buffer it - don't export yet\n }\n\n async forceFlush(traceId?: string): Promise<void> {\n if (traceId) {\n // Make tail sampling decision for this specific trace before flushing\n const trace = this.traces.get(traceId);\n if (trace) {\n // Ensure localRootSpan is set (fallback to first span if not)\n // This handles distributed traces where no span has undefined parentSpanId\n if (!trace.localRootSpan && trace.spans.length > 0) {\n trace.localRootSpan = trace.spans[0];\n }\n\n if (this.tailSampler) {\n const shouldKeep = this.tailSampler(trace);\n\n if (shouldKeep) {\n // Export ALL buffered spans in the trace\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n }\n } else {\n // No tail sampler, export all buffered spans\n for (const bufferedSpan of trace.spans) {\n this.wrapped.onEnd(bufferedSpan);\n }\n }\n\n // Clean up trace after decision\n this.traces.delete(traceId);\n }\n }\n return this.wrapped.forceFlush(traceId);\n }\n\n async shutdown(): Promise<void> {\n this.traces.clear();\n return this.wrapped.shutdown();\n }\n}\n","/**\n * Configuration system for autotel-edge\n */\n\nimport { W3CTraceContextPropagator } from '@opentelemetry/core';\nimport { ParentBasedSampler, AlwaysOnSampler } from '@opentelemetry/sdk-trace-base';\nimport { context as api_context, createContextKey, type Context } from '@opentelemetry/api';\nimport type {\n EdgeConfig,\n ResolvedEdgeConfig,\n ConfigurationOption,\n Trigger,\n ParentRatioSamplingConfig,\n} from '../types';\nimport { isSpanProcessorConfig } from '../types';\nimport { OTLPExporter } from './exporter';\nimport { TailSamplingSpanProcessor } from './spanprocessor';\n\n/**\n * Type for config initialization function\n */\nexport type Initialiser = (env: any, trigger: Trigger) => ResolvedEdgeConfig;\n\n/**\n * Context key for storing config (isolates config per-request)\n */\nconst CONFIG_KEY = createContextKey('autotel-edge-config');\n\n/**\n * Get the currently active config from context\n *\n * This reads the config from the active context, ensuring each request\n * has its own isolated config even when multiple requests are in-flight.\n */\nexport function getActiveConfig(): ResolvedEdgeConfig | null {\n const value = api_context.active().getValue(CONFIG_KEY) as\n | ResolvedEdgeConfig\n | null\n | undefined;\n return value ?? null;\n}\n\n/**\n * Set the active config in context\n *\n * Returns a new context with the config stored. This context should be\n * used with api_context.with() to ensure the config is isolated per-request.\n *\n * @example\n * ```typescript\n * const config = parseConfig({ service: { name: 'my-service' } });\n * const context = setConfig(config);\n *\n * api_context.with(context, () => {\n * // Config is available here via getActiveConfig()\n * });\n * ```\n */\nexport function setConfig(config: ResolvedEdgeConfig): Context {\n return api_context.active().setValue(CONFIG_KEY, config);\n}\n\n/**\n * Parse and validate configuration\n */\nexport function parseConfig(config: EdgeConfig): ResolvedEdgeConfig {\n // Parse head sampler\n const headSampler =\n config.sampling?.headSampler ??\n new ParentBasedSampler({\n root: new AlwaysOnSampler(),\n });\n\n const parsedHeadSampler =\n typeof headSampler === 'object' && 'ratio' in headSampler\n ? createParentRatioSampler(headSampler)\n : headSampler;\n\n // Parse tail sampler (default: keep sampled or error traces)\n const tailSampler =\n config.sampling?.tailSampler ??\n ((traceInfo) => {\n const localRootSpan = traceInfo.localRootSpan;\n const ctx = localRootSpan.spanContext();\n // Keep if sampled or if root span has error\n return (ctx.traceFlags & 1) === 1 || localRootSpan.status.code === 2; // SAMPLED flag | ERROR status\n });\n\n // Parse exporter - use TailSamplingSpanProcessor when tail sampler is present\n const spanProcessors = isSpanProcessorConfig(config)\n ? Array.isArray(config.spanProcessors)\n ? config.spanProcessors\n : [config.spanProcessors]\n : [\n // Use TailSamplingSpanProcessor to enable tail sampling\n new TailSamplingSpanProcessor(\n typeof config.exporter === 'object' && 'url' in config.exporter\n ? new OTLPExporter(config.exporter)\n : config.exporter,\n config.postProcessor,\n tailSampler, // Wire up the tail sampler!\n ),\n ];\n\n // Build resolved config\n const resolved: ResolvedEdgeConfig = {\n service: config.service,\n handlers: {\n fetch: config.handlers?.fetch ?? {},\n },\n fetch: {\n includeTraceContext: config.fetch?.includeTraceContext ?? true,\n },\n postProcessor: config.postProcessor ?? ((spans) => spans),\n sampling: {\n headSampler: parsedHeadSampler,\n tailSampler,\n },\n spanProcessors,\n propagator: config.propagator ?? new W3CTraceContextPropagator(),\n instrumentation: {\n instrumentGlobalFetch: config.instrumentation?.instrumentGlobalFetch ?? true,\n instrumentGlobalCache: config.instrumentation?.instrumentGlobalCache ?? false,\n disabled: config.instrumentation?.disabled ?? false,\n },\n subscribers: config.subscribers ?? [],\n dataSafety: config.dataSafety,\n };\n\n return resolved;\n}\n\n/**\n * Create a parent-based ratio sampler\n */\nfunction createParentRatioSampler(config: ParentRatioSamplingConfig) {\n const { ratio, acceptRemote = true } = config;\n\n // Simple ratio sampler\n const ratioSampler = {\n shouldSample: () => ({\n decision: Math.random() < ratio ? 1 : 0, // RECORD_AND_SAMPLED : NOT_RECORD\n attributes: {},\n }),\n toString: () => `ParentRatioSampler{ratio=${ratio}}`,\n };\n\n if (acceptRemote) {\n return new ParentBasedSampler({ root: ratioSampler as any });\n }\n\n return ratioSampler;\n}\n\n/**\n * Create a config initializer function\n */\nexport function createInitialiser(config: ConfigurationOption): Initialiser {\n if (typeof config === 'function') {\n return (env, trigger) => {\n const conf = parseConfig(config(env, trigger));\n return conf;\n };\n } else {\n const parsed = parseConfig(config);\n return () => parsed;\n }\n}\n"]}
|
package/dist/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EdgeEvent, O as OrPromise, F as FunnelStepStatus, a as OutcomeStatus } from './types-
|
|
2
|
-
export { b as EdgeFunnelStepEvent, c as EdgeOutcomeEvent, d as EdgeTrackEvent, e as EdgeValueEvent } from './types-
|
|
1
|
+
import { E as EdgeEvent, O as OrPromise, F as FunnelStepStatus, a as OutcomeStatus } from './types-uulICZo7.js';
|
|
2
|
+
export { b as EdgeFunnelStepEvent, c as EdgeOutcomeEvent, d as EdgeTrackEvent, e as EdgeValueEvent } from './types-uulICZo7.js';
|
|
3
3
|
import '@opentelemetry/api';
|
|
4
4
|
import '@opentelemetry/sdk-trace-base';
|
|
5
5
|
|
package/dist/events.js
CHANGED
|
@@ -47,6 +47,19 @@ interface SpanMethods {
|
|
|
47
47
|
*/
|
|
48
48
|
type TraceContext = TraceContextBase & SpanMethods;
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Optional lifecycle hooks for adapters that need to track child loggers
|
|
52
|
+
* spawned by `log.fork()` (e.g. activeLoggers maps in framework integrations).
|
|
53
|
+
*/
|
|
54
|
+
interface ForkLifecycle {
|
|
55
|
+
/** Called after the child logger is created, before `fn` runs. */
|
|
56
|
+
onChildEnter?: (child: ExecutionLogger) => void;
|
|
57
|
+
/** Called after the child has finished (emit + drain), success or failure. */
|
|
58
|
+
onChildExit?: (child: ExecutionLogger) => void;
|
|
59
|
+
}
|
|
60
|
+
interface ForkOptions {
|
|
61
|
+
lifecycle?: ForkLifecycle;
|
|
62
|
+
}
|
|
50
63
|
interface ExecutionLogger {
|
|
51
64
|
set(fields: Record<string, unknown>): void;
|
|
52
65
|
info(message: string, fields?: Record<string, unknown>): void;
|
|
@@ -54,7 +67,7 @@ interface ExecutionLogger {
|
|
|
54
67
|
error(error: Error | string, fields?: Record<string, unknown>): void;
|
|
55
68
|
getContext(): Record<string, unknown>;
|
|
56
69
|
emitNow(overrides?: Record<string, unknown>): ExecutionLogSnapshot;
|
|
57
|
-
fork(label: string, fn: () => void | Promise<void
|
|
70
|
+
fork(label: string, fn: () => void | Promise<void>, options?: ForkOptions): void;
|
|
58
71
|
}
|
|
59
72
|
interface ExecutionLogSnapshot {
|
|
60
73
|
timestamp: string;
|
|
@@ -68,4 +81,4 @@ interface ExecutionLoggerOptions {
|
|
|
68
81
|
}
|
|
69
82
|
declare function getExecutionLogger(ctx?: TraceContext, options?: ExecutionLoggerOptions): ExecutionLogger;
|
|
70
83
|
|
|
71
|
-
export { type ExecutionLogSnapshot as E, type TraceContext as T, type ExecutionLogger as a, type ExecutionLoggerOptions as b, getExecutionLogger as g };
|
|
84
|
+
export { type ExecutionLogSnapshot as E, type ForkLifecycle as F, type TraceContext as T, type ExecutionLogger as a, type ExecutionLoggerOptions as b, type ForkOptions as c, getExecutionLogger as g };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { Resource } from '@opentelemetry/resources';
|
|
|
5
5
|
import { ReadableSpan, TimedEvent, SpanProcessor, SpanExporter, TracerConfig, Sampler } from '@opentelemetry/sdk-trace-base';
|
|
6
6
|
export { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
7
7
|
import { OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
|
|
8
|
-
import { f as OTLPExporterConfig, g as Trigger, R as ResolvedEdgeConfig, C as ConfigurationOption, h as EdgeConfig } from './types-
|
|
9
|
-
export { D as DOConstructorTrigger,
|
|
8
|
+
import { f as OTLPExporterConfig, g as Trigger, R as ResolvedEdgeConfig, C as ConfigurationOption, h as EdgeConfig, P as PostProcessorFn, i as EdgeSubscriber, j as ResolveConfigFn, k as RouteServiceConfig } from './types-uulICZo7.js';
|
|
9
|
+
export { D as DOConstructorTrigger, l as DataSafetyConfig, m as ExporterConfig, H as HandlerInstrumentation, I as InitialSpanInfo, n as InstrumentationOptions, L as LocalTrace, S as SamplingConfig, o as ServiceConfig, T as TailSampleFn, p as TraceFlushableSpanProcessor, W as WorkflowTrigger } from './types-uulICZo7.js';
|
|
10
10
|
export { Buffer } from 'node:buffer';
|
|
11
|
-
import { T as TraceContext } from './execution-logger-
|
|
12
|
-
export { E as ExecutionLogSnapshot, a as ExecutionLogger, b as ExecutionLoggerOptions, g as getExecutionLogger } from './execution-logger-
|
|
11
|
+
import { T as TraceContext } from './execution-logger-77TRRoWn.js';
|
|
12
|
+
export { E as ExecutionLogSnapshot, a as ExecutionLogger, b as ExecutionLoggerOptions, F as ForkLifecycle, c as ForkOptions, g as getExecutionLogger } from './execution-logger-77TRRoWn.js';
|
|
13
13
|
export { ParsedError, parseError } from './parse-error.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -293,4 +293,111 @@ interface SpanOptions {
|
|
|
293
293
|
declare function span<T = unknown>(options: SpanOptions, fn: (span: Span) => T): T;
|
|
294
294
|
declare function span<T = unknown>(options: SpanOptions, fn: (span: Span) => Promise<T>): Promise<T>;
|
|
295
295
|
|
|
296
|
-
|
|
296
|
+
/**
|
|
297
|
+
* Identity helper for authoring an autotel configuration once with full
|
|
298
|
+
* type-checking. Mirrors `defineConfig` patterns in tools like Vite / Vitest.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* import { defineConfig } from 'autotel-edge'
|
|
303
|
+
*
|
|
304
|
+
* export const otelConfig = defineConfig({
|
|
305
|
+
* service: { name: 'checkout' },
|
|
306
|
+
* exporter: { url: process.env.OTLP_URL! },
|
|
307
|
+
* })
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare function defineConfig<T extends EdgeConfig | ResolveConfigFn>(config: T): T;
|
|
311
|
+
/**
|
|
312
|
+
* Run a list of subscribers in registration order. Errors thrown by an
|
|
313
|
+
* individual subscriber are caught and logged so a buggy subscriber never
|
|
314
|
+
* blocks the others — important because `subscribers` is the primary
|
|
315
|
+
* extensibility point for in-process side effects.
|
|
316
|
+
*/
|
|
317
|
+
declare function composeSubscribers(subscribers: Array<EdgeSubscriber>, options?: {
|
|
318
|
+
name?: string;
|
|
319
|
+
}): EdgeSubscriber;
|
|
320
|
+
/**
|
|
321
|
+
* Chain post-processors so each one sees the output of the previous one.
|
|
322
|
+
* This matches the standard OTel post-processor contract: take spans, return
|
|
323
|
+
* spans (possibly filtered, redacted, or annotated).
|
|
324
|
+
*/
|
|
325
|
+
declare function composePostProcessors(processors: Array<PostProcessorFn>): PostProcessorFn;
|
|
326
|
+
/**
|
|
327
|
+
* Fan out span lifecycle events to multiple span processors. Any single
|
|
328
|
+
* processor's failure is isolated so it cannot break the others.
|
|
329
|
+
*
|
|
330
|
+
* Useful when you want to attach, say, a sampling processor + a custom
|
|
331
|
+
* attribute redactor + the default batch processor without having to author a
|
|
332
|
+
* single processor that knows about all three.
|
|
333
|
+
*/
|
|
334
|
+
declare function composeSpanProcessors(processors: SpanProcessor[]): SpanProcessor;
|
|
335
|
+
|
|
336
|
+
type Awaitable$1<T> = T | Promise<T>;
|
|
337
|
+
interface PluginHookContexts<TSetup = unknown, TEnrich = unknown, TDrain = unknown, TKeep = unknown, TRequestStart = unknown, TRequestFinish = unknown, TClientLog = unknown, TLogger = unknown> {
|
|
338
|
+
setup: TSetup;
|
|
339
|
+
enrich: TEnrich;
|
|
340
|
+
drain: TDrain;
|
|
341
|
+
keep: TKeep;
|
|
342
|
+
requestStart: TRequestStart;
|
|
343
|
+
requestFinish: TRequestFinish;
|
|
344
|
+
clientLog: TClientLog;
|
|
345
|
+
logger: TLogger;
|
|
346
|
+
}
|
|
347
|
+
type DefaultPluginContexts = PluginHookContexts;
|
|
348
|
+
interface EdgePlugin<Ctx extends PluginHookContexts = DefaultPluginContexts> {
|
|
349
|
+
name: string;
|
|
350
|
+
setup?: (ctx: Ctx['setup']) => Awaitable$1<void>;
|
|
351
|
+
enrich?: (ctx: Ctx['enrich']) => Awaitable$1<void>;
|
|
352
|
+
drain?: (ctx: Ctx['drain']) => Awaitable$1<void>;
|
|
353
|
+
keep?: (ctx: Ctx['keep']) => Awaitable$1<void>;
|
|
354
|
+
onRequestStart?: (ctx: Ctx['requestStart']) => void;
|
|
355
|
+
onRequestFinish?: (ctx: Ctx['requestFinish']) => void;
|
|
356
|
+
onClientLog?: (ctx: Ctx['clientLog']) => void;
|
|
357
|
+
extendLogger?: (logger: Ctx['logger']) => void;
|
|
358
|
+
}
|
|
359
|
+
interface PluginRunner<Ctx extends PluginHookContexts = DefaultPluginContexts> {
|
|
360
|
+
readonly plugins: readonly EdgePlugin<Ctx>[];
|
|
361
|
+
readonly hasEnrich: boolean;
|
|
362
|
+
readonly hasDrain: boolean;
|
|
363
|
+
readonly hasKeep: boolean;
|
|
364
|
+
readonly hasRequestLifecycle: boolean;
|
|
365
|
+
readonly hasClientLog: boolean;
|
|
366
|
+
readonly hasExtendLogger: boolean;
|
|
367
|
+
applyExtendLogger: (logger: Ctx['logger']) => void;
|
|
368
|
+
runOnRequestStart: (ctx: Ctx['requestStart']) => void;
|
|
369
|
+
runOnRequestFinish: (ctx: Ctx['requestFinish']) => void;
|
|
370
|
+
runOnClientLog: (ctx: Ctx['clientLog']) => void;
|
|
371
|
+
runSetup: (ctx: Ctx['setup']) => Promise<void>;
|
|
372
|
+
runEnrich: (ctx: Ctx['enrich']) => Promise<void>;
|
|
373
|
+
runDrain: (ctx: Ctx['drain']) => Promise<void>;
|
|
374
|
+
runKeep: (ctx: Ctx['keep']) => Promise<void>;
|
|
375
|
+
}
|
|
376
|
+
interface PluginRunnerOptions {
|
|
377
|
+
logger?: Pick<Console, 'error'>;
|
|
378
|
+
}
|
|
379
|
+
declare function definePlugin<Ctx extends PluginHookContexts = DefaultPluginContexts>(plugin: EdgePlugin<Ctx>): EdgePlugin<Ctx>;
|
|
380
|
+
declare function createPluginRunner<Ctx extends PluginHookContexts = DefaultPluginContexts>(plugins?: EdgePlugin<Ctx>[], options?: PluginRunnerOptions): PluginRunner<Ctx>;
|
|
381
|
+
declare function getEmptyPluginRunner(): PluginRunner;
|
|
382
|
+
|
|
383
|
+
type Awaitable<T> = T | Promise<T>;
|
|
384
|
+
declare function matchesRoutePattern(path: string, pattern: string): boolean;
|
|
385
|
+
interface RouteFilterOptions {
|
|
386
|
+
include?: string[];
|
|
387
|
+
exclude?: string[];
|
|
388
|
+
}
|
|
389
|
+
declare function shouldInstrumentPath(path: string, options?: RouteFilterOptions): boolean;
|
|
390
|
+
declare function getServiceForPath(path: string, routes?: Record<string, RouteServiceConfig>): string | undefined;
|
|
391
|
+
interface MiddlewareFinishContext<TEvent, TRequest = unknown> {
|
|
392
|
+
event: TEvent;
|
|
393
|
+
request: TRequest;
|
|
394
|
+
status?: number;
|
|
395
|
+
}
|
|
396
|
+
interface MiddlewarePipelineOptions<TEvent, TRequest = unknown> {
|
|
397
|
+
enrichers?: Array<(ctx: MiddlewareFinishContext<TEvent, TRequest>) => Awaitable<void>>;
|
|
398
|
+
drains?: Array<(ctx: MiddlewareFinishContext<TEvent, TRequest>) => Awaitable<void>>;
|
|
399
|
+
logger?: Pick<Console, 'error'>;
|
|
400
|
+
}
|
|
401
|
+
declare function runMiddlewareFinishPipeline<TEvent, TRequest = unknown>(ctx: MiddlewareFinishContext<TEvent, TRequest>, options?: MiddlewarePipelineOptions<TEvent, TRequest>): Promise<void>;
|
|
402
|
+
|
|
403
|
+
export { AsyncLocalStorageContextManager, ConfigurationOption, type DefaultPluginContexts, EdgeConfig, type EdgePlugin, EdgeSubscriber, type Initialiser, type InstrumentOptions, type MiddlewareFinishContext, type MiddlewarePipelineOptions, OTLPExporter, OTLPExporterConfig, type PluginHookContexts, type PluginRunner, type PluginRunnerOptions, PostProcessorFn, ResolveConfigFn, ResolvedEdgeConfig, type RouteFilterOptions, RouteServiceConfig, SpanImpl, TraceContext, Trigger, WorkerTracer, WorkerTracerProvider, composePostProcessors, composeSpanProcessors, composeSubscribers, createInitialiser, createPluginRunner, defineConfig, definePlugin, getActiveConfig, getEmptyPluginRunner, getServiceForPath, instrument as instrumentFunctions, matchesRoutePattern, parseConfig, runMiddlewareFinishPipeline, setConfig, shouldInstrumentPath, span, trace, type traceOptions, withNextSpan, withTracing };
|