@ereo/trace 0.1.28

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.
Files changed (53) hide show
  1. package/README.md +447 -0
  2. package/dist/cli-reporter.d.ts +37 -0
  3. package/dist/cli-reporter.d.ts.map +1 -0
  4. package/dist/client.d.ts +59 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +193 -0
  7. package/dist/collector.d.ts +29 -0
  8. package/dist/collector.d.ts.map +1 -0
  9. package/dist/context.d.ts +17 -0
  10. package/dist/context.d.ts.map +1 -0
  11. package/dist/index.d.ts +24 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +1367 -0
  14. package/dist/instrumentors/auth.d.ts +15 -0
  15. package/dist/instrumentors/auth.d.ts.map +1 -0
  16. package/dist/instrumentors/build.d.ts +18 -0
  17. package/dist/instrumentors/build.d.ts.map +1 -0
  18. package/dist/instrumentors/data.d.ts +31 -0
  19. package/dist/instrumentors/data.d.ts.map +1 -0
  20. package/dist/instrumentors/database.d.ts +26 -0
  21. package/dist/instrumentors/database.d.ts.map +1 -0
  22. package/dist/instrumentors/errors.d.ts +17 -0
  23. package/dist/instrumentors/errors.d.ts.map +1 -0
  24. package/dist/instrumentors/forms.d.ts +22 -0
  25. package/dist/instrumentors/forms.d.ts.map +1 -0
  26. package/dist/instrumentors/index.d.ts +15 -0
  27. package/dist/instrumentors/index.d.ts.map +1 -0
  28. package/dist/instrumentors/islands.d.ts +19 -0
  29. package/dist/instrumentors/islands.d.ts.map +1 -0
  30. package/dist/instrumentors/request.d.ts +24 -0
  31. package/dist/instrumentors/request.d.ts.map +1 -0
  32. package/dist/instrumentors/routing.d.ts +24 -0
  33. package/dist/instrumentors/routing.d.ts.map +1 -0
  34. package/dist/instrumentors/rpc.d.ts +16 -0
  35. package/dist/instrumentors/rpc.d.ts.map +1 -0
  36. package/dist/instrumentors/signals.d.ts +21 -0
  37. package/dist/instrumentors/signals.d.ts.map +1 -0
  38. package/dist/noop.d.ts +24 -0
  39. package/dist/noop.d.ts.map +1 -0
  40. package/dist/noop.js +45 -0
  41. package/dist/ring-buffer.d.ts +27 -0
  42. package/dist/ring-buffer.d.ts.map +1 -0
  43. package/dist/span.d.ts +45 -0
  44. package/dist/span.d.ts.map +1 -0
  45. package/dist/tracer.d.ts +42 -0
  46. package/dist/tracer.d.ts.map +1 -0
  47. package/dist/transport.d.ts +69 -0
  48. package/dist/transport.d.ts.map +1 -0
  49. package/dist/types.d.ts +120 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/viewer.d.ts +20 -0
  52. package/dist/viewer.d.ts.map +1 -0
  53. package/package.json +50 -0
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @ereo/trace - Auth Instrumentor (Layer 8)
3
+ *
4
+ * Creates child span for auth checks.
5
+ * Records: provider, success/fail, role check result, redirect target.
6
+ */
7
+ import type { Span } from '../types';
8
+ /**
9
+ * Trace an auth check operation.
10
+ */
11
+ export declare function traceAuthCheck<T>(parentSpan: Span, operation: 'requireAuth' | 'optionalAuth' | 'requireRoles' | 'custom', checkFn: () => T | Promise<T>, attrs?: {
12
+ provider?: string;
13
+ roles?: string[];
14
+ }): T | Promise<T>;
15
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/instrumentors/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,aAAa,GAAG,cAAc,GAAG,cAAc,GAAG,QAAQ,EACrE,OAAO,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC9C,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAmChB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @ereo/trace - Build Pipeline Instrumentor (Layer 10)
3
+ *
4
+ * Span per build stage.
5
+ * Records: stage name, files processed, duration.
6
+ */
7
+ import type { Span, Tracer } from '../types';
8
+ /**
9
+ * Trace a build stage.
10
+ */
11
+ export declare function traceBuildStage<T>(parentSpan: Span, stageName: string, stageFn: () => T | Promise<T>, attrs?: {
12
+ filesCount?: number;
13
+ }): T | Promise<T>;
14
+ /**
15
+ * Create a build tracer that wraps an entire build process.
16
+ */
17
+ export declare function traceBuild(tracer: Tracer, buildName?: string): Span;
18
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/instrumentors/build.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC7B,KAAK,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA0BhB;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAA2B,GACrC,IAAI,CAEN"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @ereo/trace - Data / Caching Instrumentor (Layer 3)
3
+ *
4
+ * Creates child span per loader in pipeline.
5
+ * Records: loader key, duration, cacheHit, source, waitingFor.
6
+ * Leverages existing PipelineMetrics/LoaderMetrics.
7
+ */
8
+ import type { Span } from '../types';
9
+ /** Loader execution info for tracing */
10
+ export interface LoaderTraceInfo {
11
+ key: string;
12
+ duration: number;
13
+ cacheHit?: boolean;
14
+ source?: string;
15
+ waitingFor?: string[];
16
+ error?: string;
17
+ }
18
+ /**
19
+ * Trace a single loader execution.
20
+ */
21
+ export declare function traceLoader<T>(parentSpan: Span, loaderKey: string, loaderFn: () => T | Promise<T>): T | Promise<T>;
22
+ /**
23
+ * Record loader metrics from existing PipelineMetrics onto the trace.
24
+ * Call after pipeline.execute() completes.
25
+ */
26
+ export declare function recordLoaderMetrics(parentSpan: Span, metrics: LoaderTraceInfo[]): void;
27
+ /**
28
+ * Trace a cache operation (hit/miss/set).
29
+ */
30
+ export declare function traceCacheOperation(parentSpan: Span, operation: 'get' | 'set' | 'invalidate', key: string, hit?: boolean): void;
31
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/instrumentors/data.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAC7B,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAyBhB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,IAAI,EAChB,OAAO,EAAE,eAAe,EAAE,GACzB,IAAI,CAoBN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,KAAK,GAAG,KAAK,GAAG,YAAY,EACvC,GAAG,EAAE,MAAM,EACX,GAAG,CAAC,EAAE,OAAO,GACZ,IAAI,CAKN"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @ereo/trace - Database Instrumentor (Layer 7)
3
+ *
4
+ * Creates child span per DB query.
5
+ * Records: SQL (first 200 chars), param count, row count, duration.
6
+ * Wraps DatabaseAdapter methods externally — no changes to @ereo/db.
7
+ */
8
+ import type { Span } from '../types';
9
+ /** Generic database adapter interface (matches @ereo/db DatabaseAdapter shape) */
10
+ export interface TracedAdapterMethods {
11
+ query?(sql: string, params?: unknown[]): Promise<unknown>;
12
+ execute?(sql: string, params?: unknown[]): Promise<unknown>;
13
+ get?(sql: string, params?: unknown[]): Promise<unknown>;
14
+ all?(sql: string, params?: unknown[]): Promise<unknown[]>;
15
+ run?(sql: string, params?: unknown[]): Promise<unknown>;
16
+ }
17
+ /**
18
+ * Wrap a database adapter to add tracing spans.
19
+ * Returns a proxy that instruments query/execute/get/all/run methods.
20
+ */
21
+ export declare function tracedAdapter<T extends TracedAdapterMethods>(adapter: T, getSpan: () => Span | undefined): T;
22
+ /**
23
+ * Trace a single database query (manual instrumentation).
24
+ */
25
+ export declare function traceQuery<T>(parentSpan: Span, operation: string, sql: string, queryFn: () => Promise<T>): Promise<T>;
26
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/instrumentors/database.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,kFAAkF;AAClF,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1D,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,oBAAoB,EAC1D,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,MAAM,IAAI,GAAG,SAAS,GAC9B,CAAC,CAyCH;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACxB,OAAO,CAAC,CAAC,CAAC,CAkBZ"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @ereo/trace - Error Instrumentor (Layer 11)
3
+ *
4
+ * Captures errors on the active span.
5
+ * Records: error message, stack (truncated), error class, phase.
6
+ */
7
+ import type { Span } from '../types';
8
+ export type ErrorPhase = 'middleware' | 'loader' | 'action' | 'render' | 'rpc' | 'unknown';
9
+ /**
10
+ * Record an error event on the active span.
11
+ */
12
+ export declare function traceError(span: Span, err: unknown, phase?: ErrorPhase): void;
13
+ /**
14
+ * Wrap an async function and capture errors on the span.
15
+ */
16
+ export declare function withErrorCapture<T>(span: Span, phase: ErrorPhase, fn: () => T | Promise<T>): T | Promise<T>;
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/instrumentors/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAE3F;;GAEG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,OAAO,EACZ,KAAK,GAAE,UAAsB,GAC5B,IAAI,CAYN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAchB"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @ereo/trace - Forms Instrumentor (Layer 4)
3
+ *
4
+ * Client-side span for form submission + validation.
5
+ * Records: field count, validation error count, time-to-validate, error sources.
6
+ */
7
+ import type { Span } from '../types';
8
+ /**
9
+ * Trace a form submission.
10
+ */
11
+ export declare function traceFormSubmit<T>(parentSpan: Span, formName: string, submitFn: () => T | Promise<T>, attrs?: {
12
+ fieldCount?: number;
13
+ }): T | Promise<T>;
14
+ /**
15
+ * Record form validation result.
16
+ */
17
+ export declare function recordFormValidation(parentSpan: Span, formName: string, attrs: {
18
+ errorCount: number;
19
+ validationMs: number;
20
+ errorSources?: string[];
21
+ }): void;
22
+ //# sourceMappingURL=forms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.d.ts","sourceRoot":"","sources":["../../src/instrumentors/forms.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC9B,KAAK,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA0BhB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;IACL,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,GACA,IAAI,CAON"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @ereo/trace - Instrumentors barrel export
3
+ */
4
+ export { traceMiddleware, type TraceMiddlewareOptions } from './request';
5
+ export { traceRouteMatch, recordRouteMatch } from './routing';
6
+ export { traceLoader, recordLoaderMetrics, traceCacheOperation, type LoaderTraceInfo } from './data';
7
+ export { traceFormSubmit, recordFormValidation } from './forms';
8
+ export { recordSignalUpdate, recordSignalBatch } from './signals';
9
+ export { traceRPCCall, recordRPCValidation } from './rpc';
10
+ export { tracedAdapter, traceQuery, type TracedAdapterMethods } from './database';
11
+ export { traceAuthCheck } from './auth';
12
+ export { traceHydration, recordHydration } from './islands';
13
+ export { traceBuildStage, traceBuild } from './build';
14
+ export { traceError, withErrorCapture, type ErrorPhase } from './errors';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instrumentors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @ereo/trace - Islands / Hydration Instrumentor (Layer 9)
3
+ *
4
+ * Client-side span per island hydration.
5
+ * Records: component name, strategy, hydration duration, props size.
6
+ */
7
+ import type { Span } from '../types';
8
+ export type HydrationStrategy = 'load' | 'idle' | 'visible' | 'media' | 'none';
9
+ /**
10
+ * Trace an island hydration.
11
+ */
12
+ export declare function traceHydration<T>(parentSpan: Span, componentName: string, strategy: HydrationStrategy, hydrateFn: () => T | Promise<T>, attrs?: {
13
+ propsSize?: number;
14
+ }): T | Promise<T>;
15
+ /**
16
+ * Record hydration timing event (lighter-weight than full span).
17
+ */
18
+ export declare function recordHydration(parentSpan: Span, componentName: string, strategy: HydrationStrategy, durationMs: number): void;
19
+ //# sourceMappingURL=islands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"islands.d.ts","sourceRoot":"","sources":["../../src/instrumentors/islands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/E;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,UAAU,EAAE,IAAI,EAChB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC/B,KAAK,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA2BhB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,IAAI,EAChB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,EAAE,MAAM,GACjB,IAAI,CAMN"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @ereo/trace - Request Lifecycle Instrumentor (Layer 1)
3
+ *
4
+ * Middleware that creates the root trace span wrapping the entire request.
5
+ * Records: method, pathname, headers, statusCode, total duration.
6
+ *
7
+ * Must be inserted as FIRST middleware in BunServer.setupMiddleware().
8
+ */
9
+ import type { MiddlewareHandler } from '@ereo/core';
10
+ import type { Tracer } from '../types';
11
+ export interface TraceMiddlewareOptions {
12
+ /** Paths to exclude from tracing (e.g., static assets) */
13
+ exclude?: string[];
14
+ /** Whether to record request headers */
15
+ recordHeaders?: boolean;
16
+ }
17
+ /**
18
+ * Create trace middleware that instruments the full request lifecycle.
19
+ *
20
+ * @param tracer - The tracer instance (shared across requests)
21
+ * @param options - Configuration options
22
+ */
23
+ export declare function traceMiddleware(tracer: Tracer, options?: TraceMiddlewareOptions): MiddlewareHandler;
24
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/instrumentors/request.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,MAAM,WAAW,sBAAsB;IACrC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wCAAwC;IACxC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,iBAAiB,CAuEvG"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @ereo/trace - Routing Instrumentor (Layer 2)
3
+ *
4
+ * Creates child span for route matching.
5
+ * Records: matched route pattern, params, layout chain, 404 misses.
6
+ */
7
+ import type { Span } from '../types';
8
+ /**
9
+ * Trace a route match operation.
10
+ * Call this wrapping the matchWithLayouts() call in BunServer.handleRequest().
11
+ */
12
+ export declare function traceRouteMatch<T>(parentSpan: Span, matchFn: () => T): T;
13
+ /**
14
+ * Record route match details on the parent span after matching.
15
+ * Lighter-weight alternative when you don't want to wrap matchWithLayouts().
16
+ */
17
+ export declare function recordRouteMatch(parentSpan: Span, match: {
18
+ route: {
19
+ id: string;
20
+ path: string;
21
+ };
22
+ params: Record<string, unknown>;
23
+ } | null): void;
24
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/instrumentors/routing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,UAAU,EAAE,IAAI,EAChB,OAAO,EAAE,MAAM,CAAC,GACf,CAAC,CAuBH;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,IAAI,EAChB,KAAK,EAAE;IAAE,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,GACrF,IAAI,CAQN"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @ereo/trace - RPC Instrumentor (Layer 6)
3
+ *
4
+ * Creates child span per procedure call.
5
+ * Records: procedure path, type (query/mutation), input validation time, handler time, error code.
6
+ */
7
+ import type { Span } from '../types';
8
+ /**
9
+ * Trace an RPC procedure call.
10
+ */
11
+ export declare function traceRPCCall<T>(parentSpan: Span, procedure: string, type: 'query' | 'mutation' | 'subscription', callFn: () => T | Promise<T>): T | Promise<T>;
12
+ /**
13
+ * Record RPC validation timing.
14
+ */
15
+ export declare function recordRPCValidation(parentSpan: Span, procedure: string, validationMs: number, valid: boolean): void;
16
+ //# sourceMappingURL=rpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/instrumentors/rpc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,EAC3C,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAC3B,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA0BhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,OAAO,GACb,IAAI,CAMN"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @ereo/trace - Signals Instrumentor (Layer 5)
3
+ *
4
+ * Records signal update events (not spans) for dev mode.
5
+ * Records: signal name, subscriber count, batch groups.
6
+ */
7
+ import type { Span } from '../types';
8
+ /**
9
+ * Record a signal update event on the active span.
10
+ */
11
+ export declare function recordSignalUpdate(span: Span, name: string, attrs?: {
12
+ subscriberCount?: number;
13
+ batched?: boolean;
14
+ }): void;
15
+ /**
16
+ * Record a batch of signal updates.
17
+ */
18
+ export declare function recordSignalBatch(span: Span, signalNames: string[], attrs?: {
19
+ subscriberCount?: number;
20
+ }): void;
21
+ //# sourceMappingURL=signals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/instrumentors/signals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GACtD,IAAI,CAMN;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC,IAAI,CAMN"}
package/dist/noop.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @ereo/trace/noop - No-op Tracer
3
+ *
4
+ * Zero-cost tracer for production builds. All methods are empty.
5
+ * Import as `@ereo/trace/noop` and alias during production builds
6
+ * for complete tree-shaking.
7
+ */
8
+ import type { Span, SpanLayer, TraceData, Tracer } from './types';
9
+ declare class NoopTracer implements Tracer {
10
+ startTrace(): Span;
11
+ startSpan(): Span;
12
+ activeSpan(): Span | null;
13
+ withSpan<T>(_name: string, _layer: SpanLayer, fn: (span: Span) => T | Promise<T>): T | Promise<T>;
14
+ getTraces(): TraceData[];
15
+ getTrace(): TraceData | undefined;
16
+ subscribe(): () => void;
17
+ mergeClientSpans(): void;
18
+ }
19
+ /** Singleton no-op tracer instance */
20
+ export declare const noopTracer: Tracer;
21
+ /** No-op span for direct usage */
22
+ export declare const noopSpan: Span;
23
+ export { NoopTracer };
24
+ //# sourceMappingURL=noop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../src/noop.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAY,SAAS,EAAE,SAAS,EAA4C,MAAM,EAAE,MAAM,SAAS,CAAC;AActH,cAAM,UAAW,YAAW,MAAM;IAChC,UAAU,IAAI,IAAI;IAGlB,SAAS,IAAI,IAAI;IAGjB,UAAU,IAAI,IAAI,GAAG,IAAI;IAGzB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAGjG,SAAS,IAAI,SAAS,EAAE;IAGxB,QAAQ,IAAI,SAAS,GAAG,SAAS;IAGjC,SAAS,IAAI,MAAM,IAAI;IAGvB,gBAAgB,IAAI,IAAI;CACzB;AAED,sCAAsC;AACtC,eAAO,MAAM,UAAU,EAAE,MAAyB,CAAC;AAEnD,kCAAkC;AAClC,eAAO,MAAM,QAAQ,EAAE,IAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,CAAC"}
package/dist/noop.js ADDED
@@ -0,0 +1,45 @@
1
+ // @bun
2
+ // src/noop.ts
3
+ var NOOP_SPAN = {
4
+ id: "",
5
+ traceId: "",
6
+ setAttribute() {},
7
+ event() {},
8
+ end() {},
9
+ error() {},
10
+ child() {
11
+ return NOOP_SPAN;
12
+ }
13
+ };
14
+
15
+ class NoopTracer {
16
+ startTrace() {
17
+ return NOOP_SPAN;
18
+ }
19
+ startSpan() {
20
+ return NOOP_SPAN;
21
+ }
22
+ activeSpan() {
23
+ return null;
24
+ }
25
+ withSpan(_name, _layer, fn) {
26
+ return fn(NOOP_SPAN);
27
+ }
28
+ getTraces() {
29
+ return [];
30
+ }
31
+ getTrace() {
32
+ return;
33
+ }
34
+ subscribe() {
35
+ return () => {};
36
+ }
37
+ mergeClientSpans() {}
38
+ }
39
+ var noopTracer = new NoopTracer;
40
+ var noopSpan = NOOP_SPAN;
41
+ export {
42
+ noopTracer,
43
+ noopSpan,
44
+ NoopTracer
45
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @ereo/trace - Ring Buffer
3
+ *
4
+ * Fixed-capacity circular buffer for completed traces.
5
+ * FIFO eviction when capacity is reached.
6
+ */
7
+ export declare class RingBuffer<T extends {
8
+ id: string;
9
+ }> {
10
+ readonly capacity: number;
11
+ private buffer;
12
+ private index;
13
+ private count;
14
+ private lookup;
15
+ constructor(capacity: number);
16
+ /** Add an item, evicting the oldest if at capacity */
17
+ push(item: T): void;
18
+ /** Get an item by ID */
19
+ get(id: string): T | undefined;
20
+ /** Get all items in insertion order (oldest first) */
21
+ toArray(): T[];
22
+ /** Number of items currently stored */
23
+ get size(): number;
24
+ /** Clear all items */
25
+ clear(): void;
26
+ }
27
+ //# sourceMappingURL=ring-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ring-buffer.d.ts","sourceRoot":"","sources":["../src/ring-buffer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,UAAU,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IAMlC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IALrC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,MAAM,CAAwB;gBAEjB,QAAQ,EAAE,MAAM;IAIrC,sDAAsD;IACtD,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAYnB,wBAAwB;IACxB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI9B,sDAAsD;IACtD,OAAO,IAAI,CAAC,EAAE;IAgBd,uCAAuC;IACvC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,sBAAsB;IACtB,KAAK,IAAI,IAAI;CAMd"}
package/dist/span.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @ereo/trace - Span Implementation
3
+ *
4
+ * Active span handle with timing, attributes, events, and child creation.
5
+ */
6
+ import type { Span, SpanData, SpanEvent, SpanId, SpanLayer, TraceId } from './types';
7
+ /** Generate an 8-byte hex span ID (16 chars) */
8
+ export declare function generateSpanId(): SpanId;
9
+ /** Generate a 16-byte hex trace ID (32 chars) */
10
+ export declare function generateTraceId(): TraceId;
11
+ export type SpanEndCallback = (span: SpanImpl) => void;
12
+ export type SpanChildFactory = (name: string, layer: SpanLayer, parentId: SpanId) => Span;
13
+ export type SpanEventCallback = (spanId: SpanId, event: SpanEvent) => void;
14
+ /**
15
+ * Concrete Span implementation.
16
+ * Mutable while active, produces immutable SpanData on end().
17
+ */
18
+ export declare class SpanImpl implements Span {
19
+ readonly id: SpanId;
20
+ readonly traceId: TraceId;
21
+ private _parentId;
22
+ private _name;
23
+ private _layer;
24
+ private _status;
25
+ private _startTime;
26
+ private _endTime;
27
+ private _attributes;
28
+ private _events;
29
+ private _children;
30
+ private _ended;
31
+ private _onEnd;
32
+ private _childFactory;
33
+ private _onEvent?;
34
+ constructor(traceId: TraceId, parentId: SpanId | null, name: string, layer: SpanLayer, onEnd: SpanEndCallback, childFactory: SpanChildFactory, onEvent?: SpanEventCallback);
35
+ setAttribute(key: string, value: string | number | boolean): void;
36
+ event(name: string, attributes?: Record<string, string | number | boolean>): void;
37
+ end(): void;
38
+ error(err: unknown): void;
39
+ child(name: string, layer: SpanLayer): Span;
40
+ /** Check if this span has ended */
41
+ get ended(): boolean;
42
+ /** Export the span as immutable data */
43
+ toData(): SpanData;
44
+ }
45
+ //# sourceMappingURL=span.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../src/span.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAc,OAAO,EAAE,MAAM,SAAS,CAAC;AAajG,gDAAgD;AAChD,wBAAgB,cAAc,IAAI,MAAM,CAMvC;AAED,iDAAiD;AACjD,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;AACvD,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;AAC1F,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AAE3E;;;GAGG;AACH,qBAAa,QAAS,YAAW,IAAI;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,WAAW,CAAiD;IACpE,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,QAAQ,CAAC,CAAoB;gBAGnC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,gBAAgB,EAC9B,OAAO,CAAC,EAAE,iBAAiB;IAa7B,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;IAKjE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI;IAOjF,GAAG,IAAI,IAAI;IAOX,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAczB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAM3C,mCAAmC;IACnC,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,wCAAwC;IACxC,MAAM,IAAI,QAAQ;CAgBnB"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @ereo/trace - Core Tracer
3
+ *
4
+ * Creates and manages traces + spans. Stores completed traces in a ring buffer.
5
+ * Emits events for live streaming to CLI/DevTools.
6
+ */
7
+ import type { Span, SpanData, SpanLayer, TraceData, TraceId, TraceMetadata, TraceStreamEvent, Tracer, TracerConfig } from './types';
8
+ /**
9
+ * Core tracer implementation.
10
+ *
11
+ * Span stacks are per-trace to prevent cross-trace corruption when
12
+ * multiple requests are active concurrently on the same tracer instance.
13
+ * The primary instrumentation path (span.child()) always operates within
14
+ * the correct trace via closures. The startSpan()/activeSpan() convenience
15
+ * methods are best-effort and pick the most recently started trace.
16
+ */
17
+ export declare class TracerImpl implements Tracer {
18
+ private traces;
19
+ private activeTraces;
20
+ private spanStacks;
21
+ private subscribers;
22
+ private config;
23
+ constructor(config?: TracerConfig);
24
+ startTrace(name: string, layer: SpanLayer, metadata?: Partial<TraceMetadata>): Span;
25
+ startSpan(name: string, layer: SpanLayer): Span;
26
+ activeSpan(): Span | null;
27
+ withSpan<T>(name: string, layer: SpanLayer, fn: (span: Span) => T | Promise<T>): T | Promise<T>;
28
+ getTraces(): TraceData[];
29
+ getTrace(id: TraceId): TraceData | undefined;
30
+ subscribe(cb: (event: TraceStreamEvent) => void): () => void;
31
+ /** Merge client spans into an existing trace */
32
+ mergeClientSpans(traceId: TraceId, spans: SpanData[]): void;
33
+ /** Find the active span from the most recently started trace's stack */
34
+ private findActiveSpan;
35
+ private createSpan;
36
+ private finalizeTrace;
37
+ private buildTraceData;
38
+ private emit;
39
+ }
40
+ /** Create a new Tracer instance */
41
+ export declare function createTracer(config?: TracerConfig): Tracer;
42
+ //# sourceMappingURL=tracer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EAGR,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,YAAY,EACb,MAAM,SAAS,CAAC;AAcjB;;;;;;;;GAQG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,YAAY,CAAmC;IACvD,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,WAAW,CAAgD;IACnE,OAAO,CAAC,MAAM,CAAyB;gBAE3B,MAAM,GAAE,YAAiB;IAUrC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI;IA0BnF,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAiB/C,UAAU,IAAI,IAAI,GAAG,IAAI;IAIzB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAyB/F,SAAS,IAAI,SAAS,EAAE;IAIxB,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS;IAI5C,SAAS,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI;IAO5D,gDAAgD;IAChD,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI;IAkB3D,wEAAwE;IACxE,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,UAAU;IA+ClB,OAAO,CAAC,aAAa;IA8BrB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,IAAI;CASb;AAED,mCAAmC;AACnC,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @ereo/trace - WebSocket Transport
3
+ *
4
+ * WebSocket server at /__ereo/trace-ws for streaming trace data
5
+ * to the browser DevTools panel and standalone viewer.
6
+ */
7
+ import type { Tracer, TraceStreamEvent, TraceData, SpanData } from './types';
8
+ /** Serializable version of TraceData (Map -> Record) */
9
+ export interface SerializedTraceData {
10
+ id: string;
11
+ rootSpanId: string;
12
+ startTime: number;
13
+ endTime: number;
14
+ duration: number;
15
+ spans: Record<string, SpanData>;
16
+ metadata: TraceData['metadata'];
17
+ }
18
+ /** Serialize a TraceData for JSON transport */
19
+ export declare function serializeTrace(trace: TraceData): SerializedTraceData;
20
+ /** Deserialize a TraceData from JSON transport */
21
+ export declare function deserializeTrace(data: SerializedTraceData): TraceData;
22
+ /** Serialized trace stream event for WebSocket */
23
+ export type SerializedTraceStreamEvent = {
24
+ type: 'trace:start';
25
+ trace: SerializedTraceData;
26
+ } | {
27
+ type: 'trace:end';
28
+ trace: SerializedTraceData;
29
+ } | {
30
+ type: 'span:start';
31
+ span: SpanData;
32
+ } | {
33
+ type: 'span:end';
34
+ span: SpanData;
35
+ } | {
36
+ type: 'span:event';
37
+ spanId: string;
38
+ event: SpanData['events'][0];
39
+ };
40
+ /** Serialize a TraceStreamEvent for WebSocket transport */
41
+ export declare function serializeEvent(event: TraceStreamEvent): SerializedTraceStreamEvent;
42
+ /**
43
+ * Create a WebSocket handler for trace streaming.
44
+ * Attach to the server at `/__ereo/trace-ws`.
45
+ */
46
+ export declare function createTraceWebSocket(tracer: Tracer): {
47
+ /** Handle WebSocket upgrade */
48
+ upgrade: (request: Request) => boolean;
49
+ /** Bun WebSocket handlers */
50
+ websocket: {
51
+ open: (ws: {
52
+ send: (data: string) => void;
53
+ }) => void;
54
+ close: (ws: {
55
+ send: (data: string) => void;
56
+ }) => void;
57
+ message: (ws: {
58
+ send: (data: string) => void;
59
+ }, message: string | Buffer) => void;
60
+ };
61
+ /** Stop streaming and disconnect all clients */
62
+ close: () => void;
63
+ };
64
+ /**
65
+ * Create the HTTP endpoint handler for `/__devtools/api/traces`.
66
+ * Returns all stored traces as JSON.
67
+ */
68
+ export declare function createTracesAPIHandler(tracer: Tracer): (request: Request) => Response;
69
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE7E,wDAAwD;AACxD,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;CACjC;AAED,+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,mBAAmB,CAcpE;AAED,kDAAkD;AAClD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,CAcrE;AAED,kDAAkD;AAClD,MAAM,MAAM,0BAA0B,GAClC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AAEzE,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,0BAA0B,CAKlF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG;IACpD,+BAA+B;IAC/B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IACvC,6BAA6B;IAC7B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,EAAE,EAAE;YAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;SAAE,KAAK,IAAI,CAAC;QACrD,KAAK,EAAE,CAAC,EAAE,EAAE;YAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;SAAE,KAAK,IAAI,CAAC;QACtD,OAAO,EAAE,CAAC,EAAE,EAAE;YAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;SAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;KACnF,CAAC;IACF,gDAAgD;IAChD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAoEA;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,CAyBrF"}