@lunora/observability 1.0.0-alpha.5 → 1.0.0-alpha.51

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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +123 -26
  3. package/dist/index.d.ts +123 -26
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-CeplWoRm.mjs +22 -0
  6. package/dist/packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BGGX6k5D.mjs +3 -0
  7. package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs +56 -0
  8. package/dist/packem_shared/ISSUE_SEVERITIES-gLC4VEPQ.mjs +15 -0
  9. package/dist/packem_shared/MIN_ADMIN_TOKEN_LENGTH-CidkqOQ1.mjs +1 -0
  10. package/dist/packem_shared/MetricBuffer-DnOJJVHH.mjs +1 -0
  11. package/dist/packem_shared/REQUEST_LOG_TABLE-DMQIHLi_.mjs +1 -0
  12. package/dist/packem_shared/SpanBuffer-zjqCAuGp.mjs +1 -0
  13. package/dist/packem_shared/createDatabaseTally-DCMuBKoP.mjs +1 -0
  14. package/dist/packem_shared/createMetrics-B366_-Qf.mjs +1 -0
  15. package/dist/packem_shared/findDanglingReferences-Dxl42LBT.mjs +1 -0
  16. package/dist/packem_shared/metric-buffer-Bx0XbypU.mjs +1 -0
  17. package/dist/packem_shared/prune-marker-B4An9Nuj.mjs +1 -0
  18. package/dist/packem_shared/readMetricHistory-TKfnwFNv.mjs +31 -0
  19. package/dist/packem_shared/readQueryInsights-D37H7MII.mjs +32 -0
  20. package/dist/packem_shared/request-log-COB2xhns.mjs +22 -0
  21. package/dist/packem_shared/resolveTraceAnchor-FyCYPLGu.mjs +1 -0
  22. package/dist/packem_shared/run-sql-0aPgJkIw.mjs +1 -0
  23. package/dist/packem_shared/trace-context-DfJZi_g2.mjs +1 -0
  24. package/package.json +5 -5
  25. package/dist/packem_shared/AUTH_METRICS_BUCKETS_TABLE-C2V-DiGu.mjs +0 -22
  26. package/dist/packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-xF11R4vX.mjs +0 -3
  27. package/dist/packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-BB8kcFBe.mjs +0 -56
  28. package/dist/packem_shared/ISSUE_SEVERITIES-Js6lGUG5.mjs +0 -15
  29. package/dist/packem_shared/MIN_ADMIN_TOKEN_LENGTH-T-zuwRVR.mjs +0 -1
  30. package/dist/packem_shared/MetricBuffer-CYrLuEsz.mjs +0 -1
  31. package/dist/packem_shared/REQUEST_LOG_TABLE-BvpprPd_.mjs +0 -1
  32. package/dist/packem_shared/SpanBuffer-BR6Ff0M-.mjs +0 -1
  33. package/dist/packem_shared/createDatabaseTally-DBs7wDeF.mjs +0 -1
  34. package/dist/packem_shared/createMetrics-BXNmqy0o.mjs +0 -1
  35. package/dist/packem_shared/findDanglingReferences-D-x9LvY0.mjs +0 -1
  36. package/dist/packem_shared/metric-buffer-CdgXal7w.mjs +0 -1
  37. package/dist/packem_shared/readMetricHistory-CVcUgQEL.mjs +0 -31
  38. package/dist/packem_shared/readQueryInsights-DN07YcQy.mjs +0 -32
  39. package/dist/packem_shared/request-log-BwFic6VV.mjs +0 -21
  40. package/dist/packem_shared/resolveTraceAnchor-IAN8riI0.mjs +0 -1
  41. package/dist/packem_shared/trace-context-DrdF960P.mjs +0 -1
package/README.md CHANGED
@@ -27,7 +27,7 @@ Three details are Cloudflare's rather than this package's, so the host passes th
27
27
 
28
28
  - **AI model** — `explainIssue(binding, args, { defaultModel })`. `DEFAULT_EXPLAIN_ISSUE_MODEL` is a Workers AI id, exported so the Cloudflare host has a name to pass rather than a string literal.
29
29
  - **Query batch size** — `readIssueStates(sql, hashes, { hashQueryBatch })`. `DEFAULT_HASH_QUERY_BATCH` is 100, the Durable Object SQLite bound-parameter cap; a host with a different cap passes its own.
30
- - **Span projections** — `HostSpanLike`, `HostTracingLike`, `HostTracingResolver`, `resolveHostTracing`, `fuseHostSpans`, `applyHostSpanAttributes`. Named for the role, not the provider. Cloudflare's `enterSpan` callback argument is one shape that satisfies them.
30
+ - **Span projections** — the exported types `HostSpanLike`, `HostTracingLike` and `HostTracingResolver`. Named for the role, not the provider; Cloudflare's `enterSpan` callback argument is one shape that satisfies them. The host injects its tracer through the `TracerDeps` option fields `fuseHostSpans?: boolean` and `resolveHostTracing?: HostTracingResolver` — those are option names, not exported values, and the resolver itself lives in the host (`@lunora/do`'s `shard-do.ts` guards a dynamic `import("cloudflare:workers")`).
31
31
 
32
32
  ## Importing it
33
33
 
package/dist/index.d.mts CHANGED
@@ -64,9 +64,9 @@ declare const ensureAuthMetricsTables: (sql: SqlExec) => void;
64
64
  * `failures` advances only when `outcome === "fail"`. `since_ms` is set once on
65
65
  * the first attempt and never moved (so it stays a true first-seen marker).
66
66
  *
67
- * Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements plus a bounded
68
- * `DELETE`, all keyed by primary key cheap enough to fire off the auth
69
- * response path without blocking it.
67
+ * Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements, all keyed by
68
+ * primary key, plus a bounded `DELETE` that runs once per bucket window
69
+ * cheap enough to fire off the auth response path without blocking it.
70
70
  */
71
71
  declare const recordAuthEvent: (sql: SqlExec, input: RecordAuthEventInput) => void;
72
72
  /**
@@ -605,7 +605,7 @@ declare const createSpanCollector: (ids: {
605
605
  *
606
606
  * **DO async-context caveat (EXPERIMENTAL, partially workerd-validated).**
607
607
  * `tracing.enterSpan` is now confirmed to EXIST and RUN inside a real Durable
608
- * Object under `@cloudflare/vitest-pool-workers` (see
608
+ * Object under `@cloudflare/vitest-plugin` (see
609
609
  * `__tests__/workerd/context-telemetry-cf-bridge.workerd.test.ts`): it resolves
610
610
  * from `cloudflare:workers`, its callback executes and returns the body value
611
611
  * without throwing, `span.isTraced` is a real boolean, and — the key additive
@@ -625,6 +625,14 @@ declare const createTracer: (deps: TracerDeps) => ContextTracer;
625
625
  interface TracedFetchDeps {
626
626
  /** The trace the CLIENT spans belong to. */
627
627
  anchor: TraceAnchor;
628
+ /**
629
+ * Whether to record a failed fetch's error message verbatim rather than
630
+ * redacted. Same dev-only escape hatch as {@link TracerDeps.captureRaw}, and
631
+ * the same reason: a `fetch` TypeError embeds the request URL, so a key in a
632
+ * query string would otherwise reach the collector in the clear on the very
633
+ * span whose `url.full` is scrubbed by `redactUrl`.
634
+ */
635
+ captureRaw?: boolean;
628
636
  /** Function path the spans are attributed to. */
629
637
  functionPath: string;
630
638
  /**
@@ -911,7 +919,7 @@ interface RecordFunctionMetricInput {
911
919
  * dispatch used no declared index, keeping the hot path unchanged.
912
920
  */
913
921
  indexHits?: ReadonlyArray<IndexHit>;
914
- /** The `&lt;file>:&lt;function>` identifier. */
922
+ /** The `<file>:<function>` identifier. */
915
923
  path: string;
916
924
  /**
917
925
  * Distinct tables this dispatch full-scanned (read with no index / point
@@ -1040,7 +1048,7 @@ interface AiRunBinding {
1040
1048
  }
1041
1049
  /** Parsed `__lunora_admin__:explainIssue` payload: the folded Issue's identifying facts, plus an optional model override. */
1042
1050
  interface ExplainIssueArgs {
1043
- /** The Issue's culprit (`&lt;file>:&lt;function>` or `container:&lt;name>`), for grounding context. */
1051
+ /** The Issue's culprit (`<file>:<function>` or `container:<name>`), for grounding context. */
1044
1052
  culprit?: string;
1045
1053
  /** Per-request model-id override; falls back to the caller's `defaultModel`, then {@link DEFAULT_EXPLAIN_ISSUE_MODEL}. */
1046
1054
  model?: string;
@@ -1189,13 +1197,15 @@ type LogLevel = ContextLogLevel;
1189
1197
  */
1190
1198
  interface LogEntry {
1191
1199
  exitCode?: number;
1192
- /** Structured fields from a `ctx.log.&lt;level>(message, fields)` / `ctx.log.with(fields)` call, when present. */
1200
+ /** Structured fields from a `ctx.log.<level>(message, fields)` / `ctx.log.with(fields)` call, when present. */
1193
1201
  fields?: Record<string, unknown>;
1194
1202
  functionPath?: string;
1195
1203
  instance?: string;
1196
1204
  level: LogLevel;
1197
1205
  message: string;
1198
1206
  timestamp: number;
1207
+ /** Trace the line was emitted under; absent outside a dispatch (container lifecycle, hibernation-path errors). What the Studio joins a log line to its waterfall on. */
1208
+ traceId?: string;
1199
1209
  }
1200
1210
  /**
1201
1211
  * A bounded, in-memory ring buffer of recent {@link LogEntry} records.
@@ -1480,7 +1490,7 @@ interface RequestLogEntry {
1480
1490
  durationMs: number;
1481
1491
  /** Error message when `outcome === "error"`, redacted like args/identity; absent on success. */
1482
1492
  errorMessage?: string;
1483
- /** The `&lt;file>:&lt;function>` identifier dispatched, e.g. `messages:list`. */
1493
+ /** The `<file>:<function>` identifier dispatched, e.g. `messages:list`. */
1484
1494
  functionPath: string;
1485
1495
  /** Identity-claim envelope forwarded by the runtime, JSON-decoded; leaf values are redacted (the claims are PII), so only the shape survives. Absent for anonymous requests. Correlate on `userId` instead. */
1486
1496
  identity?: Record<string, unknown>;
@@ -1498,6 +1508,8 @@ interface RequestLogEntry {
1498
1508
  tablesRead: string[];
1499
1509
  /** Tables the handler wrote (from the change tracker); empty for a read-only dispatch. */
1500
1510
  tablesWritten: string[];
1511
+ /** W3C trace id (32-hex) of the dispatch; `undefined` on a row appended before this column existed. See the module docstring on the retention asymmetry. */
1512
+ traceId?: string;
1501
1513
  /** Wall-clock millis when the dispatch completed. */
1502
1514
  ts: number;
1503
1515
  /** Acting userId forwarded by the runtime, or `undefined` when anonymous. */
@@ -1516,6 +1528,7 @@ interface AppendRequestLogEntry {
1516
1528
  subscriptionsReRun?: number;
1517
1529
  tablesRead?: string[];
1518
1530
  tablesWritten?: string[];
1531
+ traceId?: string;
1519
1532
  ts: number;
1520
1533
  userId?: string;
1521
1534
  }
@@ -1528,7 +1541,7 @@ interface RequestLogWriteOptions {
1528
1541
  }
1529
1542
  /** Filters for {@link readRequestLog}, all AND-combined; every value is a bound SQL parameter, so nothing here injects SQL. */
1530
1543
  interface ReadRequestLogOptions {
1531
- /** Functions whose path begins with this prefix (a `&lt;file>:` or `&lt;file>:&lt;fn>` correlation). */
1544
+ /** Functions whose path begins with this prefix (a `<file>:` or `<file>:<fn>` correlation). */
1532
1545
  functionPathPrefix?: string;
1533
1546
  /** Upper bound on returned rows, clamped to [1, 10000]. */
1534
1547
  limit?: number;
@@ -1558,7 +1571,7 @@ interface ErrorIssue {
1558
1571
  assignee?: string;
1559
1572
  /** Number of `error` rows folded into this Issue within the scanned window. */
1560
1573
  count: number;
1561
- /** The `&lt;file>:&lt;function>` (or `container:&lt;name>`) the errors came from. */
1574
+ /** The `<file>:<function>` (or `container:<name>`) the errors came from. */
1562
1575
  culprit: string;
1563
1576
  /** Wall-clock millis of the oldest folded row. */
1564
1577
  firstSeen: number;
@@ -1597,7 +1610,7 @@ interface IssuesResult {
1597
1610
  }
1598
1611
  /** Filters for {@link readErrorIssues}; forwarded to {@link readRequestLog} with `outcome` forced to `error`. */
1599
1612
  interface ReadIssuesOptions {
1600
- /** Functions whose path begins with this prefix (a `&lt;file>:` or `&lt;file>:&lt;fn>` correlation). */
1613
+ /** Functions whose path begins with this prefix (a `<file>:` or `<file>:<fn>` correlation). */
1601
1614
  functionPathPrefix?: string;
1602
1615
  /** Upper bound on error rows scanned before grouping, clamped to [1, 10000]. */
1603
1616
  limit?: number;
@@ -1622,7 +1635,7 @@ interface ReadIssuesOptions {
1622
1635
  * STRING — which is what `errorMessage`/log `fields`-as-rendered-text are —
1623
1636
  * only pattern-shaped matches apply: emails, long digit runs / structured
1624
1637
  * numeric IDs (credit-card, phone, SSN, AWS-access-key-style), and an explicit
1625
- * `Bearer &lt;token>` / `token=…`-shaped substring. A free-text `password=hunter2`
1638
+ * `Bearer <token>` / `token=…`-shaped substring. A free-text `password=hunter2`
1626
1639
  * or a bare provider API key embedded in prose (e.g. `sk-live-…`) is NOT
1627
1640
  * caught on a plain string — there is no key to match against, and neither is
1628
1641
  * a recognized value pattern. So this is a PII-pattern net for rendered text,
@@ -1651,12 +1664,17 @@ declare const redactArgs: (value: unknown, captureRaw?: boolean) => unknown;
1651
1664
  *
1652
1665
  * `error_fingerprint` is the {@link fingerprintError} grouping hash captured
1653
1666
  * from the RAW `error_message` at write time, before {@link appendRequestLogEntry}
1654
- * redacts it — see that function's docstring. It is added via a guarded
1655
- * `ALTER TABLE` rather than baked into the `CREATE`, mirroring
1667
+ * redacts it — see that function's docstring. `trace_id` is the dispatch's W3C
1668
+ * trace id, the correlation key to the span ring and to whatever collector
1669
+ * `otlpSink` ships to.
1670
+ *
1671
+ * Both are also added via a guarded `ALTER TABLE`, mirroring
1656
1672
  * `function-metrics.ts`'s `ensureFunctionMetricsTables`, so a shard whose
1657
- * `__lunora_reqlog__` predates this column gains it on the next call without a
1673
+ * `__lunora_reqlog__` predates a column gains it on the next call without a
1658
1674
  * migration. SQLite has no `ADD COLUMN IF NOT EXISTS`, so the duplicate-column
1659
- * error from a re-run (or the freshly-created schema above) is swallowed.
1675
+ * error from a re-run (or from the freshly-created schema above) is swallowed
1676
+ * per column — the loop is what keeps one column's duplicate from skipping the
1677
+ * next column's add.
1660
1678
  */
1661
1679
  declare const ensureRequestLogTable: (sql: SqlExec) => void;
1662
1680
  /**
@@ -1672,8 +1690,8 @@ declare const ensureRequestLogTable: (sql: SqlExec) => void;
1672
1690
  * it's redacted below, and the resulting hash is persisted in
1673
1691
  * `error_fingerprint`. `readErrorIssues` groups off that stored hash instead of
1674
1692
  * recomputing `fingerprintError` from the (redacted) `error_message` column, so
1675
- * masking a PII-bearing value — e.g. two different `&lt;n>`-bucketed IDs that
1676
- * redact to two different tag lengths (`&lt;DL>` vs `&lt;BANKACC>`) — can't split an
1693
+ * masking a PII-bearing value — e.g. two different `<n>`-bucketed IDs that
1694
+ * redact to two different tag lengths (`<DL>` vs `<BANKACC>`) — can't split an
1677
1695
  * existing Issue or change its identity.
1678
1696
  */
1679
1697
  declare const appendRequestLogEntry: (sql: SqlExec, entry: AppendRequestLogEntry, options?: RequestLogWriteOptions) => void;
@@ -1702,7 +1720,7 @@ declare const emitRequestLogEvent: (entry: AppendRequestLogEntry, options?: Requ
1702
1720
  */
1703
1721
  type LogEventInput = LogEvent;
1704
1722
  /**
1705
- * Split a `ctx.log.&lt;level>(...)` call's raw arguments into a display `message`
1723
+ * Split a `ctx.log.<level>(...)` call's raw arguments into a display `message`
1706
1724
  * and optional structured `fields`. The structured form — a message string plus
1707
1725
  * a plain-object fields bag — is matched only for exactly `(string, object)`;
1708
1726
  * every other shape is console-style and rendered whole (so existing
@@ -1842,6 +1860,15 @@ interface TraceSpan {
1842
1860
  message: string;
1843
1861
  type: string;
1844
1862
  };
1863
+ /**
1864
+ * Timestamped occurrences inside the span — `span.addEvent(...)` and
1865
+ * `span.recordException(...)`. Carried through so a handled retry or a
1866
+ * swallowed exception is visible on the span it happened in, which is the
1867
+ * only place it is interpretable. Absent when the body recorded none.
1868
+ */
1869
+ events?: SpanEventPoint[];
1870
+ /** OTel `SpanKind`; absent means `"internal"`. */
1871
+ kind?: OtlpSpanKind;
1845
1872
  name: string;
1846
1873
  /** Start of this span relative to the trace's start, in ms. */
1847
1874
  offsetMs: number;
@@ -1860,12 +1887,25 @@ interface TraceSummary {
1860
1887
  rootName: string;
1861
1888
  shardKey?: string;
1862
1889
  /**
1863
- * Spans ordered by `(offsetMs, depth)`, ready to render as waterfall rows.
1864
- * Start time alone is not enough to order them: spans are recorded on
1865
- * completion and `startTs` has millisecond resolution, so a parent and its
1866
- * child routinely tie. Breaking that tie by depth makes the sequence a valid
1867
- * pre-order traversal of the span tree, so indenting each row by its `depth`
1868
- * yields the nesting without a separate tree walk.
1890
+ * Spans in **pre-order**, ready to render as waterfall rows: every span is
1891
+ * immediately followed by its own subtree, siblings in start order. So
1892
+ * indenting each row by its `depth` yields the real nesting the row above
1893
+ * a `depth`-`n+1` row is genuinely its parent.
1894
+ *
1895
+ * This is a tree walk, not a sort, because no ordering on `(offsetMs,
1896
+ * depth)` can produce it. Given a parent, its child `a`, `a`'s child `a1`
1897
+ * and `a`'s sibling `b` all at offset 0, that comparator yields
1898
+ * `parent, a, b, a1` — which renders `a1` indented beneath `b`, under a
1899
+ * parent it does not belong to.
1900
+ *
1901
+ * **Why they tie is not millisecond resolution.** On the Workers runtime
1902
+ * `Date.now()` is pinned to the time of the last I/O — a Spectre mitigation,
1903
+ * not a bug — so it does not advance at all across pure computation. Every
1904
+ * duration in this package is `Date.now() - startTs`, which means a span
1905
+ * wrapping CPU-only work reports `0`, and a parent whose child performed no
1906
+ * I/O shares its exact start and end. See `docs/concepts/observability`
1907
+ * ("Span durations on Workers"); the practical consequence is that a `0 ms`
1908
+ * span means "no I/O happened here", not "this was fast".
1869
1909
  */
1870
1910
  spans: TraceSpan[];
1871
1911
  startTs: number;
@@ -1965,4 +2005,61 @@ declare const resolveTraceAnchor: (traceparent: string | undefined) => {
1965
2005
  sampled: boolean;
1966
2006
  traceId: string;
1967
2007
  };
1968
- export { AUTH_METRICS_BUCKETS_TABLE, AUTH_METRICS_BUCKET_MS, AUTH_METRICS_BUCKET_RETENTION, AUTH_METRICS_TABLE, type AiRunBinding, type AppendRequestLogEntry, type AuthMetrics, type AuthMetricsBucket, type ContextFetch, type ContextLogLevel, type ContextMetrics, type ContextTracer, DEFAULT_EXPLAIN_ISSUE_MODEL, type DanglingReference, type DanglingReferenceResult, type DatabaseInstrumentation, type DatabaseTally, type DatabaseTelemetryDeps, type ErrorIssue, type ExplainIssueArgs, type ExplainIssueDegradedReason, type ExplainIssueGrounding, type ExplainIssueResult, FUNCTION_METRICS_BUCKETS_TABLE, FUNCTION_METRICS_BUCKET_MS, FUNCTION_METRICS_BUCKET_RETENTION, FUNCTION_METRICS_INDEX_TABLE, FUNCTION_METRICS_MAX_PATHS, FUNCTION_METRICS_READ_LIMIT, FUNCTION_METRICS_SCANS_TABLE, FUNCTION_METRICS_TABLE, type FoldedTraces, type FunctionMetricBucket, type FunctionMetricBucketsResult, type FunctionMetricIndexHit, type HostSpanLike, type HostTracingLike, type HostTracingResolver, ISSUE_SEVERITIES, ISSUE_STATE_TABLE, ISSUE_STATUSES, type IndexHit, type IssueSeverity, type IssueState, type IssueStatePatch, type IssueStatus, type IssuesResult, LogBuffer, type LogEntry, type LogEventInput, type LogLevel, MIN_ADMIN_TOKEN_LENGTH, MIN_AUTH_SECRET_LENGTH, MetricBuffer, type MetricEvent, type MetricHistoryOptions, type MetricHistoryPoint, type MetricHistoryResult, type MetricHistorySeries, type MetricKind, type MetricSeries, type MetricsDeps, type QueryInsightBucket, type QueryInsightEntry, type QueryInsightsResult, type QueryStatEntry, REQUEST_LOG_TABLE, type ReadIssuesOptions, type ReadRequestLogOptions, type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, upsertIssueState };
2008
+ export { AUTH_METRICS_BUCKETS_TABLE, AUTH_METRICS_BUCKET_MS, AUTH_METRICS_BUCKET_RETENTION, AUTH_METRICS_TABLE, type AiRunBinding, type AppendRequestLogEntry,
2009
+ /**
2010
+ * `@lunora/observability` — host-neutral telemetry storage and read models.
2011
+ *
2012
+ * Logs, traces, metrics, issue grouping and the security-audit view: the data
2013
+ * behind the Studio's observability pages. None of it is Cloudflare-specific —
2014
+ * it reads and writes through the SQL handle the engine hands it, and it lived
2015
+ * inside `@lunora/do` only because that is where the Durable Object it
2016
+ * instruments happens to live.
2017
+ *
2018
+ * The dependency runs `@lunora/do` → here → `@lunora/shard-engine`, never the
2019
+ * reverse, which is what makes this reusable by a second host rather than
2020
+ * merely relocated.
2021
+ *
2022
+ * This barrel is deliberately curated rather than `export *`. A star export
2023
+ * would promote every module internal to permanent public API — the exact
2024
+ * mistake `@lunora/do`'s own barrel documents having made once with the search
2025
+ * core. What is exported here is what a consumer actually needs.
2026
+ */
2027
+ type AuthMetrics,
2028
+ /**
2029
+ * `@lunora/observability` — host-neutral telemetry storage and read models.
2030
+ *
2031
+ * Logs, traces, metrics, issue grouping and the security-audit view: the data
2032
+ * behind the Studio's observability pages. None of it is Cloudflare-specific —
2033
+ * it reads and writes through the SQL handle the engine hands it, and it lived
2034
+ * inside `@lunora/do` only because that is where the Durable Object it
2035
+ * instruments happens to live.
2036
+ *
2037
+ * The dependency runs `@lunora/do` → here → `@lunora/shard-engine`, never the
2038
+ * reverse, which is what makes this reusable by a second host rather than
2039
+ * merely relocated.
2040
+ *
2041
+ * This barrel is deliberately curated rather than `export *`. A star export
2042
+ * would promote every module internal to permanent public API — the exact
2043
+ * mistake `@lunora/do`'s own barrel documents having made once with the search
2044
+ * core. What is exported here is what a consumer actually needs.
2045
+ */
2046
+ type AuthMetricsBucket, type ContextFetch, type ContextLogLevel, type ContextMetrics, type ContextTracer, DEFAULT_EXPLAIN_ISSUE_MODEL, type DanglingReference, type DanglingReferenceResult, type DatabaseInstrumentation, type DatabaseTally, type DatabaseTelemetryDeps, type ErrorIssue, type ExplainIssueArgs, type ExplainIssueDegradedReason, type ExplainIssueGrounding, type ExplainIssueResult, FUNCTION_METRICS_BUCKETS_TABLE, FUNCTION_METRICS_BUCKET_MS, FUNCTION_METRICS_BUCKET_RETENTION, FUNCTION_METRICS_INDEX_TABLE, FUNCTION_METRICS_MAX_PATHS, FUNCTION_METRICS_READ_LIMIT, FUNCTION_METRICS_SCANS_TABLE, FUNCTION_METRICS_TABLE, type FoldedTraces, type FunctionMetricBucket, type FunctionMetricBucketsResult, type FunctionMetricIndexHit, type HostSpanLike, type HostTracingLike, type HostTracingResolver, ISSUE_SEVERITIES, ISSUE_STATE_TABLE, ISSUE_STATUSES, type IndexHit, type IssueSeverity, type IssueState, type IssueStatePatch, type IssueStatus, type IssuesResult, LogBuffer, type LogEntry, type LogEventInput, type LogLevel, MIN_ADMIN_TOKEN_LENGTH, MIN_AUTH_SECRET_LENGTH, MetricBuffer, type MetricEvent, type MetricHistoryOptions, type MetricHistoryPoint, type MetricHistoryResult, type MetricHistorySeries, type MetricKind, type MetricSeries, type MetricsDeps, type QueryInsightBucket, type QueryInsightEntry, type QueryInsightsResult, type QueryStatEntry, REQUEST_LOG_TABLE, type ReadIssuesOptions, type ReadRequestLogOptions,
2047
+ /**
2048
+ * `@lunora/observability` — host-neutral telemetry storage and read models.
2049
+ *
2050
+ * Logs, traces, metrics, issue grouping and the security-audit view: the data
2051
+ * behind the Studio's observability pages. None of it is Cloudflare-specific —
2052
+ * it reads and writes through the SQL handle the engine hands it, and it lived
2053
+ * inside `@lunora/do` only because that is where the Durable Object it
2054
+ * instruments happens to live.
2055
+ *
2056
+ * The dependency runs `@lunora/do` → here → `@lunora/shard-engine`, never the
2057
+ * reverse, which is what makes this reusable by a second host rather than
2058
+ * merely relocated.
2059
+ *
2060
+ * This barrel is deliberately curated rather than `export *`. A star export
2061
+ * would promote every module internal to permanent public API — the exact
2062
+ * mistake `@lunora/do`'s own barrel documents having made once with the search
2063
+ * core. What is exported here is what a consumer actually needs.
2064
+ */
2065
+ type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, upsertIssueState };
package/dist/index.d.ts CHANGED
@@ -64,9 +64,9 @@ declare const ensureAuthMetricsTables: (sql: SqlExec) => void;
64
64
  * `failures` advances only when `outcome === "fail"`. `since_ms` is set once on
65
65
  * the first attempt and never moved (so it stays a true first-seen marker).
66
66
  *
67
- * Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements plus a bounded
68
- * `DELETE`, all keyed by primary key cheap enough to fire off the auth
69
- * response path without blocking it.
67
+ * Exactly two `INSERT … ON CONFLICT … DO UPDATE` statements, all keyed by
68
+ * primary key, plus a bounded `DELETE` that runs once per bucket window
69
+ * cheap enough to fire off the auth response path without blocking it.
70
70
  */
71
71
  declare const recordAuthEvent: (sql: SqlExec, input: RecordAuthEventInput) => void;
72
72
  /**
@@ -605,7 +605,7 @@ declare const createSpanCollector: (ids: {
605
605
  *
606
606
  * **DO async-context caveat (EXPERIMENTAL, partially workerd-validated).**
607
607
  * `tracing.enterSpan` is now confirmed to EXIST and RUN inside a real Durable
608
- * Object under `@cloudflare/vitest-pool-workers` (see
608
+ * Object under `@cloudflare/vitest-plugin` (see
609
609
  * `__tests__/workerd/context-telemetry-cf-bridge.workerd.test.ts`): it resolves
610
610
  * from `cloudflare:workers`, its callback executes and returns the body value
611
611
  * without throwing, `span.isTraced` is a real boolean, and — the key additive
@@ -625,6 +625,14 @@ declare const createTracer: (deps: TracerDeps) => ContextTracer;
625
625
  interface TracedFetchDeps {
626
626
  /** The trace the CLIENT spans belong to. */
627
627
  anchor: TraceAnchor;
628
+ /**
629
+ * Whether to record a failed fetch's error message verbatim rather than
630
+ * redacted. Same dev-only escape hatch as {@link TracerDeps.captureRaw}, and
631
+ * the same reason: a `fetch` TypeError embeds the request URL, so a key in a
632
+ * query string would otherwise reach the collector in the clear on the very
633
+ * span whose `url.full` is scrubbed by `redactUrl`.
634
+ */
635
+ captureRaw?: boolean;
628
636
  /** Function path the spans are attributed to. */
629
637
  functionPath: string;
630
638
  /**
@@ -911,7 +919,7 @@ interface RecordFunctionMetricInput {
911
919
  * dispatch used no declared index, keeping the hot path unchanged.
912
920
  */
913
921
  indexHits?: ReadonlyArray<IndexHit>;
914
- /** The `&lt;file>:&lt;function>` identifier. */
922
+ /** The `<file>:<function>` identifier. */
915
923
  path: string;
916
924
  /**
917
925
  * Distinct tables this dispatch full-scanned (read with no index / point
@@ -1040,7 +1048,7 @@ interface AiRunBinding {
1040
1048
  }
1041
1049
  /** Parsed `__lunora_admin__:explainIssue` payload: the folded Issue's identifying facts, plus an optional model override. */
1042
1050
  interface ExplainIssueArgs {
1043
- /** The Issue's culprit (`&lt;file>:&lt;function>` or `container:&lt;name>`), for grounding context. */
1051
+ /** The Issue's culprit (`<file>:<function>` or `container:<name>`), for grounding context. */
1044
1052
  culprit?: string;
1045
1053
  /** Per-request model-id override; falls back to the caller's `defaultModel`, then {@link DEFAULT_EXPLAIN_ISSUE_MODEL}. */
1046
1054
  model?: string;
@@ -1189,13 +1197,15 @@ type LogLevel = ContextLogLevel;
1189
1197
  */
1190
1198
  interface LogEntry {
1191
1199
  exitCode?: number;
1192
- /** Structured fields from a `ctx.log.&lt;level>(message, fields)` / `ctx.log.with(fields)` call, when present. */
1200
+ /** Structured fields from a `ctx.log.<level>(message, fields)` / `ctx.log.with(fields)` call, when present. */
1193
1201
  fields?: Record<string, unknown>;
1194
1202
  functionPath?: string;
1195
1203
  instance?: string;
1196
1204
  level: LogLevel;
1197
1205
  message: string;
1198
1206
  timestamp: number;
1207
+ /** Trace the line was emitted under; absent outside a dispatch (container lifecycle, hibernation-path errors). What the Studio joins a log line to its waterfall on. */
1208
+ traceId?: string;
1199
1209
  }
1200
1210
  /**
1201
1211
  * A bounded, in-memory ring buffer of recent {@link LogEntry} records.
@@ -1480,7 +1490,7 @@ interface RequestLogEntry {
1480
1490
  durationMs: number;
1481
1491
  /** Error message when `outcome === "error"`, redacted like args/identity; absent on success. */
1482
1492
  errorMessage?: string;
1483
- /** The `&lt;file>:&lt;function>` identifier dispatched, e.g. `messages:list`. */
1493
+ /** The `<file>:<function>` identifier dispatched, e.g. `messages:list`. */
1484
1494
  functionPath: string;
1485
1495
  /** Identity-claim envelope forwarded by the runtime, JSON-decoded; leaf values are redacted (the claims are PII), so only the shape survives. Absent for anonymous requests. Correlate on `userId` instead. */
1486
1496
  identity?: Record<string, unknown>;
@@ -1498,6 +1508,8 @@ interface RequestLogEntry {
1498
1508
  tablesRead: string[];
1499
1509
  /** Tables the handler wrote (from the change tracker); empty for a read-only dispatch. */
1500
1510
  tablesWritten: string[];
1511
+ /** W3C trace id (32-hex) of the dispatch; `undefined` on a row appended before this column existed. See the module docstring on the retention asymmetry. */
1512
+ traceId?: string;
1501
1513
  /** Wall-clock millis when the dispatch completed. */
1502
1514
  ts: number;
1503
1515
  /** Acting userId forwarded by the runtime, or `undefined` when anonymous. */
@@ -1516,6 +1528,7 @@ interface AppendRequestLogEntry {
1516
1528
  subscriptionsReRun?: number;
1517
1529
  tablesRead?: string[];
1518
1530
  tablesWritten?: string[];
1531
+ traceId?: string;
1519
1532
  ts: number;
1520
1533
  userId?: string;
1521
1534
  }
@@ -1528,7 +1541,7 @@ interface RequestLogWriteOptions {
1528
1541
  }
1529
1542
  /** Filters for {@link readRequestLog}, all AND-combined; every value is a bound SQL parameter, so nothing here injects SQL. */
1530
1543
  interface ReadRequestLogOptions {
1531
- /** Functions whose path begins with this prefix (a `&lt;file>:` or `&lt;file>:&lt;fn>` correlation). */
1544
+ /** Functions whose path begins with this prefix (a `<file>:` or `<file>:<fn>` correlation). */
1532
1545
  functionPathPrefix?: string;
1533
1546
  /** Upper bound on returned rows, clamped to [1, 10000]. */
1534
1547
  limit?: number;
@@ -1558,7 +1571,7 @@ interface ErrorIssue {
1558
1571
  assignee?: string;
1559
1572
  /** Number of `error` rows folded into this Issue within the scanned window. */
1560
1573
  count: number;
1561
- /** The `&lt;file>:&lt;function>` (or `container:&lt;name>`) the errors came from. */
1574
+ /** The `<file>:<function>` (or `container:<name>`) the errors came from. */
1562
1575
  culprit: string;
1563
1576
  /** Wall-clock millis of the oldest folded row. */
1564
1577
  firstSeen: number;
@@ -1597,7 +1610,7 @@ interface IssuesResult {
1597
1610
  }
1598
1611
  /** Filters for {@link readErrorIssues}; forwarded to {@link readRequestLog} with `outcome` forced to `error`. */
1599
1612
  interface ReadIssuesOptions {
1600
- /** Functions whose path begins with this prefix (a `&lt;file>:` or `&lt;file>:&lt;fn>` correlation). */
1613
+ /** Functions whose path begins with this prefix (a `<file>:` or `<file>:<fn>` correlation). */
1601
1614
  functionPathPrefix?: string;
1602
1615
  /** Upper bound on error rows scanned before grouping, clamped to [1, 10000]. */
1603
1616
  limit?: number;
@@ -1622,7 +1635,7 @@ interface ReadIssuesOptions {
1622
1635
  * STRING — which is what `errorMessage`/log `fields`-as-rendered-text are —
1623
1636
  * only pattern-shaped matches apply: emails, long digit runs / structured
1624
1637
  * numeric IDs (credit-card, phone, SSN, AWS-access-key-style), and an explicit
1625
- * `Bearer &lt;token>` / `token=…`-shaped substring. A free-text `password=hunter2`
1638
+ * `Bearer <token>` / `token=…`-shaped substring. A free-text `password=hunter2`
1626
1639
  * or a bare provider API key embedded in prose (e.g. `sk-live-…`) is NOT
1627
1640
  * caught on a plain string — there is no key to match against, and neither is
1628
1641
  * a recognized value pattern. So this is a PII-pattern net for rendered text,
@@ -1651,12 +1664,17 @@ declare const redactArgs: (value: unknown, captureRaw?: boolean) => unknown;
1651
1664
  *
1652
1665
  * `error_fingerprint` is the {@link fingerprintError} grouping hash captured
1653
1666
  * from the RAW `error_message` at write time, before {@link appendRequestLogEntry}
1654
- * redacts it — see that function's docstring. It is added via a guarded
1655
- * `ALTER TABLE` rather than baked into the `CREATE`, mirroring
1667
+ * redacts it — see that function's docstring. `trace_id` is the dispatch's W3C
1668
+ * trace id, the correlation key to the span ring and to whatever collector
1669
+ * `otlpSink` ships to.
1670
+ *
1671
+ * Both are also added via a guarded `ALTER TABLE`, mirroring
1656
1672
  * `function-metrics.ts`'s `ensureFunctionMetricsTables`, so a shard whose
1657
- * `__lunora_reqlog__` predates this column gains it on the next call without a
1673
+ * `__lunora_reqlog__` predates a column gains it on the next call without a
1658
1674
  * migration. SQLite has no `ADD COLUMN IF NOT EXISTS`, so the duplicate-column
1659
- * error from a re-run (or the freshly-created schema above) is swallowed.
1675
+ * error from a re-run (or from the freshly-created schema above) is swallowed
1676
+ * per column — the loop is what keeps one column's duplicate from skipping the
1677
+ * next column's add.
1660
1678
  */
1661
1679
  declare const ensureRequestLogTable: (sql: SqlExec) => void;
1662
1680
  /**
@@ -1672,8 +1690,8 @@ declare const ensureRequestLogTable: (sql: SqlExec) => void;
1672
1690
  * it's redacted below, and the resulting hash is persisted in
1673
1691
  * `error_fingerprint`. `readErrorIssues` groups off that stored hash instead of
1674
1692
  * recomputing `fingerprintError` from the (redacted) `error_message` column, so
1675
- * masking a PII-bearing value — e.g. two different `&lt;n>`-bucketed IDs that
1676
- * redact to two different tag lengths (`&lt;DL>` vs `&lt;BANKACC>`) — can't split an
1693
+ * masking a PII-bearing value — e.g. two different `<n>`-bucketed IDs that
1694
+ * redact to two different tag lengths (`<DL>` vs `<BANKACC>`) — can't split an
1677
1695
  * existing Issue or change its identity.
1678
1696
  */
1679
1697
  declare const appendRequestLogEntry: (sql: SqlExec, entry: AppendRequestLogEntry, options?: RequestLogWriteOptions) => void;
@@ -1702,7 +1720,7 @@ declare const emitRequestLogEvent: (entry: AppendRequestLogEntry, options?: Requ
1702
1720
  */
1703
1721
  type LogEventInput = LogEvent;
1704
1722
  /**
1705
- * Split a `ctx.log.&lt;level>(...)` call's raw arguments into a display `message`
1723
+ * Split a `ctx.log.<level>(...)` call's raw arguments into a display `message`
1706
1724
  * and optional structured `fields`. The structured form — a message string plus
1707
1725
  * a plain-object fields bag — is matched only for exactly `(string, object)`;
1708
1726
  * every other shape is console-style and rendered whole (so existing
@@ -1842,6 +1860,15 @@ interface TraceSpan {
1842
1860
  message: string;
1843
1861
  type: string;
1844
1862
  };
1863
+ /**
1864
+ * Timestamped occurrences inside the span — `span.addEvent(...)` and
1865
+ * `span.recordException(...)`. Carried through so a handled retry or a
1866
+ * swallowed exception is visible on the span it happened in, which is the
1867
+ * only place it is interpretable. Absent when the body recorded none.
1868
+ */
1869
+ events?: SpanEventPoint[];
1870
+ /** OTel `SpanKind`; absent means `"internal"`. */
1871
+ kind?: OtlpSpanKind;
1845
1872
  name: string;
1846
1873
  /** Start of this span relative to the trace's start, in ms. */
1847
1874
  offsetMs: number;
@@ -1860,12 +1887,25 @@ interface TraceSummary {
1860
1887
  rootName: string;
1861
1888
  shardKey?: string;
1862
1889
  /**
1863
- * Spans ordered by `(offsetMs, depth)`, ready to render as waterfall rows.
1864
- * Start time alone is not enough to order them: spans are recorded on
1865
- * completion and `startTs` has millisecond resolution, so a parent and its
1866
- * child routinely tie. Breaking that tie by depth makes the sequence a valid
1867
- * pre-order traversal of the span tree, so indenting each row by its `depth`
1868
- * yields the nesting without a separate tree walk.
1890
+ * Spans in **pre-order**, ready to render as waterfall rows: every span is
1891
+ * immediately followed by its own subtree, siblings in start order. So
1892
+ * indenting each row by its `depth` yields the real nesting the row above
1893
+ * a `depth`-`n+1` row is genuinely its parent.
1894
+ *
1895
+ * This is a tree walk, not a sort, because no ordering on `(offsetMs,
1896
+ * depth)` can produce it. Given a parent, its child `a`, `a`'s child `a1`
1897
+ * and `a`'s sibling `b` all at offset 0, that comparator yields
1898
+ * `parent, a, b, a1` — which renders `a1` indented beneath `b`, under a
1899
+ * parent it does not belong to.
1900
+ *
1901
+ * **Why they tie is not millisecond resolution.** On the Workers runtime
1902
+ * `Date.now()` is pinned to the time of the last I/O — a Spectre mitigation,
1903
+ * not a bug — so it does not advance at all across pure computation. Every
1904
+ * duration in this package is `Date.now() - startTs`, which means a span
1905
+ * wrapping CPU-only work reports `0`, and a parent whose child performed no
1906
+ * I/O shares its exact start and end. See `docs/concepts/observability`
1907
+ * ("Span durations on Workers"); the practical consequence is that a `0 ms`
1908
+ * span means "no I/O happened here", not "this was fast".
1869
1909
  */
1870
1910
  spans: TraceSpan[];
1871
1911
  startTs: number;
@@ -1965,4 +2005,61 @@ declare const resolveTraceAnchor: (traceparent: string | undefined) => {
1965
2005
  sampled: boolean;
1966
2006
  traceId: string;
1967
2007
  };
1968
- export { AUTH_METRICS_BUCKETS_TABLE, AUTH_METRICS_BUCKET_MS, AUTH_METRICS_BUCKET_RETENTION, AUTH_METRICS_TABLE, type AiRunBinding, type AppendRequestLogEntry, type AuthMetrics, type AuthMetricsBucket, type ContextFetch, type ContextLogLevel, type ContextMetrics, type ContextTracer, DEFAULT_EXPLAIN_ISSUE_MODEL, type DanglingReference, type DanglingReferenceResult, type DatabaseInstrumentation, type DatabaseTally, type DatabaseTelemetryDeps, type ErrorIssue, type ExplainIssueArgs, type ExplainIssueDegradedReason, type ExplainIssueGrounding, type ExplainIssueResult, FUNCTION_METRICS_BUCKETS_TABLE, FUNCTION_METRICS_BUCKET_MS, FUNCTION_METRICS_BUCKET_RETENTION, FUNCTION_METRICS_INDEX_TABLE, FUNCTION_METRICS_MAX_PATHS, FUNCTION_METRICS_READ_LIMIT, FUNCTION_METRICS_SCANS_TABLE, FUNCTION_METRICS_TABLE, type FoldedTraces, type FunctionMetricBucket, type FunctionMetricBucketsResult, type FunctionMetricIndexHit, type HostSpanLike, type HostTracingLike, type HostTracingResolver, ISSUE_SEVERITIES, ISSUE_STATE_TABLE, ISSUE_STATUSES, type IndexHit, type IssueSeverity, type IssueState, type IssueStatePatch, type IssueStatus, type IssuesResult, LogBuffer, type LogEntry, type LogEventInput, type LogLevel, MIN_ADMIN_TOKEN_LENGTH, MIN_AUTH_SECRET_LENGTH, MetricBuffer, type MetricEvent, type MetricHistoryOptions, type MetricHistoryPoint, type MetricHistoryResult, type MetricHistorySeries, type MetricKind, type MetricSeries, type MetricsDeps, type QueryInsightBucket, type QueryInsightEntry, type QueryInsightsResult, type QueryStatEntry, REQUEST_LOG_TABLE, type ReadIssuesOptions, type ReadRequestLogOptions, type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, upsertIssueState };
2008
+ export { AUTH_METRICS_BUCKETS_TABLE, AUTH_METRICS_BUCKET_MS, AUTH_METRICS_BUCKET_RETENTION, AUTH_METRICS_TABLE, type AiRunBinding, type AppendRequestLogEntry,
2009
+ /**
2010
+ * `@lunora/observability` — host-neutral telemetry storage and read models.
2011
+ *
2012
+ * Logs, traces, metrics, issue grouping and the security-audit view: the data
2013
+ * behind the Studio's observability pages. None of it is Cloudflare-specific —
2014
+ * it reads and writes through the SQL handle the engine hands it, and it lived
2015
+ * inside `@lunora/do` only because that is where the Durable Object it
2016
+ * instruments happens to live.
2017
+ *
2018
+ * The dependency runs `@lunora/do` → here → `@lunora/shard-engine`, never the
2019
+ * reverse, which is what makes this reusable by a second host rather than
2020
+ * merely relocated.
2021
+ *
2022
+ * This barrel is deliberately curated rather than `export *`. A star export
2023
+ * would promote every module internal to permanent public API — the exact
2024
+ * mistake `@lunora/do`'s own barrel documents having made once with the search
2025
+ * core. What is exported here is what a consumer actually needs.
2026
+ */
2027
+ type AuthMetrics,
2028
+ /**
2029
+ * `@lunora/observability` — host-neutral telemetry storage and read models.
2030
+ *
2031
+ * Logs, traces, metrics, issue grouping and the security-audit view: the data
2032
+ * behind the Studio's observability pages. None of it is Cloudflare-specific —
2033
+ * it reads and writes through the SQL handle the engine hands it, and it lived
2034
+ * inside `@lunora/do` only because that is where the Durable Object it
2035
+ * instruments happens to live.
2036
+ *
2037
+ * The dependency runs `@lunora/do` → here → `@lunora/shard-engine`, never the
2038
+ * reverse, which is what makes this reusable by a second host rather than
2039
+ * merely relocated.
2040
+ *
2041
+ * This barrel is deliberately curated rather than `export *`. A star export
2042
+ * would promote every module internal to permanent public API — the exact
2043
+ * mistake `@lunora/do`'s own barrel documents having made once with the search
2044
+ * core. What is exported here is what a consumer actually needs.
2045
+ */
2046
+ type AuthMetricsBucket, type ContextFetch, type ContextLogLevel, type ContextMetrics, type ContextTracer, DEFAULT_EXPLAIN_ISSUE_MODEL, type DanglingReference, type DanglingReferenceResult, type DatabaseInstrumentation, type DatabaseTally, type DatabaseTelemetryDeps, type ErrorIssue, type ExplainIssueArgs, type ExplainIssueDegradedReason, type ExplainIssueGrounding, type ExplainIssueResult, FUNCTION_METRICS_BUCKETS_TABLE, FUNCTION_METRICS_BUCKET_MS, FUNCTION_METRICS_BUCKET_RETENTION, FUNCTION_METRICS_INDEX_TABLE, FUNCTION_METRICS_MAX_PATHS, FUNCTION_METRICS_READ_LIMIT, FUNCTION_METRICS_SCANS_TABLE, FUNCTION_METRICS_TABLE, type FoldedTraces, type FunctionMetricBucket, type FunctionMetricBucketsResult, type FunctionMetricIndexHit, type HostSpanLike, type HostTracingLike, type HostTracingResolver, ISSUE_SEVERITIES, ISSUE_STATE_TABLE, ISSUE_STATUSES, type IndexHit, type IssueSeverity, type IssueState, type IssueStatePatch, type IssueStatus, type IssuesResult, LogBuffer, type LogEntry, type LogEventInput, type LogLevel, MIN_ADMIN_TOKEN_LENGTH, MIN_AUTH_SECRET_LENGTH, MetricBuffer, type MetricEvent, type MetricHistoryOptions, type MetricHistoryPoint, type MetricHistoryResult, type MetricHistorySeries, type MetricKind, type MetricSeries, type MetricsDeps, type QueryInsightBucket, type QueryInsightEntry, type QueryInsightsResult, type QueryStatEntry, REQUEST_LOG_TABLE, type ReadIssuesOptions, type ReadRequestLogOptions,
2047
+ /**
2048
+ * `@lunora/observability` — host-neutral telemetry storage and read models.
2049
+ *
2050
+ * Logs, traces, metrics, issue grouping and the security-audit view: the data
2051
+ * behind the Studio's observability pages. None of it is Cloudflare-specific —
2052
+ * it reads and writes through the SQL handle the engine hands it, and it lived
2053
+ * inside `@lunora/do` only because that is where the Durable Object it
2054
+ * instruments happens to live.
2055
+ *
2056
+ * The dependency runs `@lunora/do` → here → `@lunora/shard-engine`, never the
2057
+ * reverse, which is what makes this reusable by a second host rather than
2058
+ * merely relocated.
2059
+ *
2060
+ * This barrel is deliberately curated rather than `export *`. A star export
2061
+ * would promote every module internal to permanent public API — the exact
2062
+ * mistake `@lunora/do`'s own barrel documents having made once with the search
2063
+ * core. What is exported here is what a consumer actually needs.
2064
+ */
2065
+ type RecordAuthEventInput, type RecordFunctionMetricInput, type RequestLogEntry, type RequestLogResult, type RequestLogWriteOptions, type RequestOutcome, type SecurityAuditResult, type SecurityFinding, type SecurityFindingKind, type SecurityFindingLevel, SpanBuffer, type SpanCollection, type SpanCollector, type SpanEvent, type SpanEventPoint, type SpanHandle, type OtlpSpanKind as SpanKind, type SpanLink, type SpanOptions, type TraceAnchor, type TraceSpan, type TraceSummary, type TracedFetchDeps, type TracerDeps, appendRequestLogEntry, buildSecurityAudit, createDatabaseTally, createMetrics, createSpanCollector, createTracedFetch, createTracer, dispatchRootSpan, emitLogEvent, emitRequestLogEvent, ensureAuthMetricsTables, ensureFunctionMetricsTables, ensureRequestLogTable, explainIssue, findDanglingReferences, foldTraces, formatTally, instrumentDatabase, mergeScanAttribution, parseExplainIssueArgs, parseLogArgs, readAuthMetrics, readErrorIssues, readFunctionMetricBuckets, readFunctionMetricIndexHits, readFunctionMetricScans, readFunctionMetrics, readFunctionMetricsTotals, readMetricHistory, readQueryInsights, readQueryMetrics, readRequestLog, recordAuthEvent, recordFunctionMetric, recordMetricHistory, recordQueryMetric, redactArgs, resolveTraceAnchor, upsertIssueState };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as T,AUTH_METRICS_BUCKET_RETENTION as o,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-C2V-DiGu.mjs";import{createMetrics as S,createSpanCollector as I,createTracedFetch as i,createTracer as n,dispatchRootSpan as M}from"./packem_shared/createMetrics-BXNmqy0o.mjs";import{createDatabaseTally as A,formatTally as C,instrumentDatabase as N}from"./packem_shared/createDatabaseTally-DBs7wDeF.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as p,FUNCTION_METRICS_BUCKET_MS as d,FUNCTION_METRICS_BUCKET_RETENTION as f,FUNCTION_METRICS_INDEX_TABLE as R,FUNCTION_METRICS_MAX_PATHS as L,FUNCTION_METRICS_READ_LIMIT as m,FUNCTION_METRICS_SCANS_TABLE as x,FUNCTION_METRICS_TABLE as B,ensureFunctionMetricsTables as F,mergeScanAttribution as l,readFunctionMetricBuckets as g,readFunctionMetricIndexHits as O,readFunctionMetricScans as H,readFunctionMetrics as y,readFunctionMetricsTotals as D,recordFunctionMetric as K}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-BB8kcFBe.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as h,explainIssue as q,parseExplainIssueArgs as v}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-xF11R4vX.mjs";import{ISSUE_SEVERITIES as G,ISSUE_STATE_TABLE as X,ISSUE_STATUSES as k,upsertIssueState as P}from"./packem_shared/ISSUE_SEVERITIES-Js6lGUG5.mjs";import{LogBuffer as V}from"./packem_shared/LogBuffer-bIvCelI-.mjs";import{M as j}from"./packem_shared/metric-buffer-CdgXal7w.mjs";import{readMetricHistory as J,recordMetricHistory as Y}from"./packem_shared/readMetricHistory-CVcUgQEL.mjs";import{readQueryInsights as $,readQueryMetrics as ee,recordQueryMetric as re}from"./packem_shared/readQueryInsights-DN07YcQy.mjs";import{d as Te,k as oe,K as ae,w as se,m as Ee,C as _e,W as ce,U as Se,c as Ie}from"./packem_shared/request-log-BwFic6VV.mjs";import{MIN_ADMIN_TOKEN_LENGTH as ne,MIN_AUTH_SECRET_LENGTH as Me,buildSecurityAudit as ue}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-T-zuwRVR.mjs";import{SpanBuffer as Ce,foldTraces as Ne}from"./packem_shared/SpanBuffer-BR6Ff0M-.mjs";import{findDanglingReferences as pe}from"./packem_shared/findDanglingReferences-D-x9LvY0.mjs";import{r as fe}from"./packem_shared/trace-context-DrdF960P.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,T as AUTH_METRICS_BUCKET_MS,o as AUTH_METRICS_BUCKET_RETENTION,a as AUTH_METRICS_TABLE,h as DEFAULT_EXPLAIN_ISSUE_MODEL,p as FUNCTION_METRICS_BUCKETS_TABLE,d as FUNCTION_METRICS_BUCKET_MS,f as FUNCTION_METRICS_BUCKET_RETENTION,R as FUNCTION_METRICS_INDEX_TABLE,L as FUNCTION_METRICS_MAX_PATHS,m as FUNCTION_METRICS_READ_LIMIT,x as FUNCTION_METRICS_SCANS_TABLE,B as FUNCTION_METRICS_TABLE,G as ISSUE_SEVERITIES,X as ISSUE_STATE_TABLE,k as ISSUE_STATUSES,V as LogBuffer,ne as MIN_ADMIN_TOKEN_LENGTH,Me as MIN_AUTH_SECRET_LENGTH,j as MetricBuffer,Te as REQUEST_LOG_TABLE,Ce as SpanBuffer,oe as appendRequestLogEntry,ue as buildSecurityAudit,A as createDatabaseTally,S as createMetrics,I as createSpanCollector,i as createTracedFetch,n as createTracer,M as dispatchRootSpan,ae as emitLogEvent,se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,Ee as ensureRequestLogTable,q as explainIssue,pe as findDanglingReferences,Ne as foldTraces,C as formatTally,N as instrumentDatabase,l as mergeScanAttribution,v as parseExplainIssueArgs,_e as parseLogArgs,E as readAuthMetrics,ce as readErrorIssues,g as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,H as readFunctionMetricScans,y as readFunctionMetrics,D as readFunctionMetricsTotals,J as readMetricHistory,$ as readQueryInsights,ee as readQueryMetrics,Se as readRequestLog,_ as recordAuthEvent,K as recordFunctionMetric,Y as recordMetricHistory,re as recordQueryMetric,Ie as redactArgs,fe as resolveTraceAnchor,P as upsertIssueState};
1
+ import{AUTH_METRICS_BUCKETS_TABLE as t,AUTH_METRICS_BUCKET_MS as T,AUTH_METRICS_BUCKET_RETENTION as o,AUTH_METRICS_TABLE as a,ensureAuthMetricsTables as s,readAuthMetrics as E,recordAuthEvent as _}from"./packem_shared/AUTH_METRICS_BUCKETS_TABLE-CeplWoRm.mjs";import{createMetrics as S,createSpanCollector as I,createTracedFetch as i,createTracer as n,dispatchRootSpan as M}from"./packem_shared/createMetrics-B366_-Qf.mjs";import{createDatabaseTally as A,formatTally as C,instrumentDatabase as N}from"./packem_shared/createDatabaseTally-DCMuBKoP.mjs";import{FUNCTION_METRICS_BUCKETS_TABLE as f,FUNCTION_METRICS_BUCKET_MS as U,FUNCTION_METRICS_BUCKET_RETENTION as d,FUNCTION_METRICS_INDEX_TABLE as R,FUNCTION_METRICS_MAX_PATHS as L,FUNCTION_METRICS_READ_LIMIT as m,FUNCTION_METRICS_SCANS_TABLE as x,FUNCTION_METRICS_TABLE as B,ensureFunctionMetricsTables as F,mergeScanAttribution as l,readFunctionMetricBuckets as g,readFunctionMetricIndexHits as O,readFunctionMetricScans as H,readFunctionMetrics as y,readFunctionMetricsTotals as b,recordFunctionMetric as D}from"./packem_shared/FUNCTION_METRICS_BUCKETS_TABLE-ChlIe0vF.mjs";import{DEFAULT_EXPLAIN_ISSUE_MODEL as K,explainIssue as q,parseExplainIssueArgs as v}from"./packem_shared/DEFAULT_EXPLAIN_ISSUE_MODEL-BGGX6k5D.mjs";import{ISSUE_SEVERITIES as G,ISSUE_STATE_TABLE as X,ISSUE_STATUSES as P,upsertIssueState as k}from"./packem_shared/ISSUE_SEVERITIES-gLC4VEPQ.mjs";import{LogBuffer as j}from"./packem_shared/LogBuffer-bIvCelI-.mjs";import{M as z}from"./packem_shared/metric-buffer-Bx0XbypU.mjs";import{readMetricHistory as W,recordMetricHistory as Y}from"./packem_shared/readMetricHistory-TKfnwFNv.mjs";import{readQueryInsights as $,readQueryMetrics as ee,recordQueryMetric as re}from"./packem_shared/readQueryInsights-D37H7MII.mjs";import{R as Te,a as oe,e as ae,b as se,c as Ee,p as _e,r as ce,d as Se,f as Ie}from"./packem_shared/request-log-COB2xhns.mjs";import{MIN_ADMIN_TOKEN_LENGTH as ne,MIN_AUTH_SECRET_LENGTH as Me,buildSecurityAudit as ue}from"./packem_shared/MIN_ADMIN_TOKEN_LENGTH-CidkqOQ1.mjs";import{SpanBuffer as Ce,foldTraces as Ne}from"./packem_shared/SpanBuffer-zjqCAuGp.mjs";import{findDanglingReferences as fe}from"./packem_shared/findDanglingReferences-Dxl42LBT.mjs";import{r as de}from"./packem_shared/trace-context-DfJZi_g2.mjs";export{t as AUTH_METRICS_BUCKETS_TABLE,T as AUTH_METRICS_BUCKET_MS,o as AUTH_METRICS_BUCKET_RETENTION,a as AUTH_METRICS_TABLE,K as DEFAULT_EXPLAIN_ISSUE_MODEL,f as FUNCTION_METRICS_BUCKETS_TABLE,U as FUNCTION_METRICS_BUCKET_MS,d as FUNCTION_METRICS_BUCKET_RETENTION,R as FUNCTION_METRICS_INDEX_TABLE,L as FUNCTION_METRICS_MAX_PATHS,m as FUNCTION_METRICS_READ_LIMIT,x as FUNCTION_METRICS_SCANS_TABLE,B as FUNCTION_METRICS_TABLE,G as ISSUE_SEVERITIES,X as ISSUE_STATE_TABLE,P as ISSUE_STATUSES,j as LogBuffer,ne as MIN_ADMIN_TOKEN_LENGTH,Me as MIN_AUTH_SECRET_LENGTH,z as MetricBuffer,Te as REQUEST_LOG_TABLE,Ce as SpanBuffer,oe as appendRequestLogEntry,ue as buildSecurityAudit,A as createDatabaseTally,S as createMetrics,I as createSpanCollector,i as createTracedFetch,n as createTracer,M as dispatchRootSpan,ae as emitLogEvent,se as emitRequestLogEvent,s as ensureAuthMetricsTables,F as ensureFunctionMetricsTables,Ee as ensureRequestLogTable,q as explainIssue,fe as findDanglingReferences,Ne as foldTraces,C as formatTally,N as instrumentDatabase,l as mergeScanAttribution,v as parseExplainIssueArgs,_e as parseLogArgs,E as readAuthMetrics,ce as readErrorIssues,g as readFunctionMetricBuckets,O as readFunctionMetricIndexHits,H as readFunctionMetricScans,y as readFunctionMetrics,b as readFunctionMetricsTotals,W as readMetricHistory,$ as readQueryInsights,ee as readQueryMetrics,Se as readRequestLog,_ as recordAuthEvent,D as recordFunctionMetric,Y as recordMetricHistory,re as recordQueryMetric,Ie as redactArgs,de as resolveTraceAnchor,k as upsertIssueState};