@nodii/telemetry 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hono/index.d.ts +64 -0
- package/dist/hono/index.d.ts.map +1 -0
- package/dist/hono/index.js +217 -0
- package/dist/hono/index.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Context, MiddlewareHandler } from "hono";
|
|
2
|
+
/** Canonical inbound W3C trace-context header (lower-case; Hono headers are case-insensitive). */
|
|
3
|
+
export declare const TRACEPARENT_HEADER = "traceparent";
|
|
4
|
+
/** Options for {@link honoTelemetry}. */
|
|
5
|
+
export interface HonoTelemetryOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Honor an inbound W3C `traceparent` header so the SERVER span inherits
|
|
8
|
+
* the upstream `trace_id` (distributed trace continuity) instead of
|
|
9
|
+
* starting a fresh root trace. Default `true`.
|
|
10
|
+
*
|
|
11
|
+
* A malformed inbound traceparent does NOT throw — `tracer.span` starts a
|
|
12
|
+
* root span and records the raw value under
|
|
13
|
+
* `telemetry.inbound_traceparent_malformed` (see `tracer.ts`).
|
|
14
|
+
*
|
|
15
|
+
* Set `false` to always start the request as a fresh root SERVER span
|
|
16
|
+
* (e.g. when the edge is the trusted trace root and upstream values are
|
|
17
|
+
* not trustworthy).
|
|
18
|
+
*/
|
|
19
|
+
honorInboundTraceparent?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Header to read the inbound traceparent from. Defaults to `traceparent`.
|
|
22
|
+
*/
|
|
23
|
+
traceparentHeader?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Customize the SERVER span name. Defaults to the OTel HTTP-semconv
|
|
26
|
+
* low-cardinality form: `"<METHOD> <route-template>"` when Hono resolved
|
|
27
|
+
* a route template (e.g. `"GET /users/:id"`), else `"<METHOD>"`. Override
|
|
28
|
+
* for services that want a different naming scheme.
|
|
29
|
+
*
|
|
30
|
+
* Avoid putting the raw `url.path` in the span name — that is HIGH
|
|
31
|
+
* cardinality (one name per id) and the per-OTel-semconv reason the
|
|
32
|
+
* default uses the route template, not the concrete path.
|
|
33
|
+
*/
|
|
34
|
+
spanName?: (c: Context) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Extra static attributes stamped on every SERVER span (e.g. a deploy
|
|
37
|
+
* marker). Per-request attributes should be added by downstream handlers
|
|
38
|
+
* via `getActiveSpan()` / `withSpanAttributes`.
|
|
39
|
+
*/
|
|
40
|
+
attributes?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Hono middleware factory that opens ONE OTel SERVER span per HTTP request
|
|
44
|
+
* and runs the rest of the pipeline INSIDE that span's context, so:
|
|
45
|
+
* - every inbound request emits an HTTP SERVER span even on `Bun.serve`
|
|
46
|
+
* (which bypasses `@opentelemetry/instrumentation-http`) — D154;
|
|
47
|
+
* - child business spans + pg-query/outbox spans nest under it (the span
|
|
48
|
+
* is the active stack parent for the downstream scope);
|
|
49
|
+
* - the OTel HTTP semantic-convention attributes are stamped
|
|
50
|
+
* (`http.request.method`, `url.path`, `url.scheme`,
|
|
51
|
+
* `http.response.status_code`, `http.route`, …);
|
|
52
|
+
* - span status maps from the response: `5xx` → ERROR (D27), and a
|
|
53
|
+
* thrown handler error is recorded + re-thrown so the framework's own
|
|
54
|
+
* error handler still runs.
|
|
55
|
+
*
|
|
56
|
+
* Mount it FIRST in the pipeline (before auth / context) so it wraps the
|
|
57
|
+
* full request duration, mirroring edge's `requestContext()`:
|
|
58
|
+
*
|
|
59
|
+
* import { honoTelemetry } from "@nodii/telemetry/hono";
|
|
60
|
+
* const app = new Hono();
|
|
61
|
+
* app.use("*", honoTelemetry());
|
|
62
|
+
*/
|
|
63
|
+
export declare function honoTelemetry(options?: HonoTelemetryOptions): MiddlewareHandler;
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAgBvD,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;IAClC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAyED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,GAAE,oBAAyB,GACjC,iBAAiB,CAmGnB"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// `@nodii/telemetry/hono` — the HTTP SERVER-span middleware for Bun-served
|
|
2
|
+
// Hono apps (D154: HTTP auto-instrumentation ON-by-default).
|
|
3
|
+
//
|
|
4
|
+
// Spec: `global/15-telemetry-doctrine.md` § 7.1 (D154 — HTTP+gRPC server
|
|
5
|
+
// spans ON by default) + `nodii-libs/features/telemetry.md` § 5.9
|
|
6
|
+
// (Hono middleware adapter) + § 5.11 (auto-instrumentation defaults).
|
|
7
|
+
//
|
|
8
|
+
// WHY THIS EXISTS (the gap it closes):
|
|
9
|
+
// `@opentelemetry/instrumentation-http` works by monkey-patching Node's
|
|
10
|
+
// built-in `http`/`https` modules. `Bun.serve` does NOT route through
|
|
11
|
+
// those modules — it has its own native HTTP server — so the standard
|
|
12
|
+
// OTel HTTP instrumentation NEVER fires on a Bun process. Every
|
|
13
|
+
// Bun-based Nodii service (auth, hr, edge, …) therefore emits ZERO HTTP
|
|
14
|
+
// SERVER spans despite D154 mandating HTTP instrumentation on-by-default
|
|
15
|
+
// (verified empirically: auth 0 server spans, hr 0 server spans).
|
|
16
|
+
//
|
|
17
|
+
// This middleware restores the D154 guarantee at the framework layer:
|
|
18
|
+
// one OTel SERVER span per inbound HTTP request, with the OTel HTTP
|
|
19
|
+
// semantic-convention attributes, run with the rest of the Hono pipeline
|
|
20
|
+
// nested INSIDE the span's context so child business spans (and the
|
|
21
|
+
// pg-query / outbox spans) parent correctly onto the request span.
|
|
22
|
+
//
|
|
23
|
+
// It GENERALIZES the bespoke `edge.request` request-span bridge that
|
|
24
|
+
// `nodii-edge`'s `requestContext()` middleware hand-rolls today (see
|
|
25
|
+
// `nodii-edge/src/lib/middleware/request-context.ts`). Once a service
|
|
26
|
+
// adopts this adapter, edge can retire its private copy.
|
|
27
|
+
//
|
|
28
|
+
// REAL SPANS (R1): the span is produced by the lib's own `tracer.span`,
|
|
29
|
+
// which routes through the mandatory-attribute SpanProcessor (D26) and the
|
|
30
|
+
// installed OTLP exporter (`installOtlpAdapter` → `_setSpanEmitter`). There
|
|
31
|
+
// is NO Noop path here — when no OTLP adapter is installed the span still
|
|
32
|
+
// flows to whatever emitter is set (the default no-op emitter is a
|
|
33
|
+
// TEST-ONLY seam, never a production default; production calls
|
|
34
|
+
// `installOtlpAdapter`).
|
|
35
|
+
//
|
|
36
|
+
// SCOPE: TS only. Hono is a TypeScript framework, so this lives behind a
|
|
37
|
+
// TS subpath exactly like `/lambda` + `/worker`. The Python (FastAPI /
|
|
38
|
+
// starlette) and Go HTTP middleware are SEPARATE adapters in their
|
|
39
|
+
// respective language trees (§ 5.9) and are OUT OF SCOPE for this file.
|
|
40
|
+
import { ATTR_ERROR_TYPE, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, ATTR_NETWORK_PROTOCOL_VERSION, ATTR_SERVER_ADDRESS, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL, } from "@opentelemetry/semantic-conventions";
|
|
41
|
+
import { tracer } from "../tracer.js";
|
|
42
|
+
/** Canonical inbound W3C trace-context header (lower-case; Hono headers are case-insensitive). */
|
|
43
|
+
export const TRACEPARENT_HEADER = "traceparent";
|
|
44
|
+
/** Prefer the proxy-forwarded scheme; fall back to the request URL; default `https`. */
|
|
45
|
+
function urlScheme(c) {
|
|
46
|
+
const fwd = c.req.header("x-forwarded-proto");
|
|
47
|
+
if (fwd) {
|
|
48
|
+
const first = fwd.split(",")[0];
|
|
49
|
+
if (first)
|
|
50
|
+
return first.trim();
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return new URL(c.req.url).protocol.replace(":", "");
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return "https";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** The `url.query` component (without the leading `?`), or undefined when absent. */
|
|
60
|
+
function urlQuery(c) {
|
|
61
|
+
try {
|
|
62
|
+
const q = new URL(c.req.url).search;
|
|
63
|
+
return q ? q.slice(1) : undefined;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolve the low-cardinality route TEMPLATE for the request (e.g.
|
|
71
|
+
* `/users/:id`), or `undefined` when no concrete handler route matched
|
|
72
|
+
* (e.g. a 404, where only the `/*` middleware route is present).
|
|
73
|
+
*
|
|
74
|
+
* `c.req.routePath` is only meaningful AFTER `next()` (once the matching
|
|
75
|
+
* handler has run). Because this middleware needs the template at
|
|
76
|
+
* span-OPEN (before `next()`), it reads `c.req.matchedRoutes` — which Hono
|
|
77
|
+
* populates at match time, before dispatch — and takes the most specific
|
|
78
|
+
* matched route: the last one whose path is NOT a `/*` / `/` middleware
|
|
79
|
+
* wildcard and whose method is NOT the `ALL` middleware pseudo-method.
|
|
80
|
+
*/
|
|
81
|
+
function resolveRouteTemplate(c) {
|
|
82
|
+
const matched = c.req
|
|
83
|
+
.matchedRoutes;
|
|
84
|
+
if (Array.isArray(matched)) {
|
|
85
|
+
for (let i = matched.length - 1; i >= 0; i--) {
|
|
86
|
+
const r = matched[i];
|
|
87
|
+
const p = r?.path;
|
|
88
|
+
if (p && p !== "/*" && p !== "/" && r?.method !== "ALL")
|
|
89
|
+
return p;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
// Fallback for Hono builds without `matchedRoutes`: `routePath` (only set
|
|
94
|
+
// post-match, so this path is for the post-`next()` re-read).
|
|
95
|
+
const route = c.req.routePath;
|
|
96
|
+
if (route && route !== "/*" && route !== "/")
|
|
97
|
+
return route;
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Default SERVER span name per OTel HTTP semconv: `"<METHOD> <route>"`
|
|
102
|
+
* (low cardinality — uses the route TEMPLATE, never the concrete path)
|
|
103
|
+
* when Hono matched a concrete handler route, else just `"<METHOD>"`.
|
|
104
|
+
*/
|
|
105
|
+
function defaultSpanName(c) {
|
|
106
|
+
const method = c.req.method;
|
|
107
|
+
const route = resolveRouteTemplate(c);
|
|
108
|
+
return route ? `${method} ${route}` : method;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Hono middleware factory that opens ONE OTel SERVER span per HTTP request
|
|
112
|
+
* and runs the rest of the pipeline INSIDE that span's context, so:
|
|
113
|
+
* - every inbound request emits an HTTP SERVER span even on `Bun.serve`
|
|
114
|
+
* (which bypasses `@opentelemetry/instrumentation-http`) — D154;
|
|
115
|
+
* - child business spans + pg-query/outbox spans nest under it (the span
|
|
116
|
+
* is the active stack parent for the downstream scope);
|
|
117
|
+
* - the OTel HTTP semantic-convention attributes are stamped
|
|
118
|
+
* (`http.request.method`, `url.path`, `url.scheme`,
|
|
119
|
+
* `http.response.status_code`, `http.route`, …);
|
|
120
|
+
* - span status maps from the response: `5xx` → ERROR (D27), and a
|
|
121
|
+
* thrown handler error is recorded + re-thrown so the framework's own
|
|
122
|
+
* error handler still runs.
|
|
123
|
+
*
|
|
124
|
+
* Mount it FIRST in the pipeline (before auth / context) so it wraps the
|
|
125
|
+
* full request duration, mirroring edge's `requestContext()`:
|
|
126
|
+
*
|
|
127
|
+
* import { honoTelemetry } from "@nodii/telemetry/hono";
|
|
128
|
+
* const app = new Hono();
|
|
129
|
+
* app.use("*", honoTelemetry());
|
|
130
|
+
*/
|
|
131
|
+
export function honoTelemetry(options = {}) {
|
|
132
|
+
const honorInbound = options.honorInboundTraceparent ?? true;
|
|
133
|
+
const traceparentHeader = options.traceparentHeader ?? TRACEPARENT_HEADER;
|
|
134
|
+
const nameOf = options.spanName ?? defaultSpanName;
|
|
135
|
+
const staticAttrs = options.attributes;
|
|
136
|
+
return async (c, next) => {
|
|
137
|
+
const inboundTraceparent = honorInbound
|
|
138
|
+
? c.req.header(traceparentHeader)
|
|
139
|
+
: undefined;
|
|
140
|
+
// Build the entry attributes per the OTel HTTP semconv. Status code +
|
|
141
|
+
// route are set AFTER `next()` (route may only resolve once matched;
|
|
142
|
+
// status is the response status).
|
|
143
|
+
const scheme = urlScheme(c);
|
|
144
|
+
const query = urlQuery(c);
|
|
145
|
+
const host = c.req.header("host");
|
|
146
|
+
const userAgent = c.req.header("user-agent");
|
|
147
|
+
const entryAttrs = {
|
|
148
|
+
[ATTR_HTTP_REQUEST_METHOD]: c.req.method,
|
|
149
|
+
[ATTR_URL_PATH]: c.req.path,
|
|
150
|
+
[ATTR_URL_SCHEME]: scheme,
|
|
151
|
+
...(query !== undefined ? { [ATTR_URL_QUERY]: query } : {}),
|
|
152
|
+
...(host ? { [ATTR_SERVER_ADDRESS]: host } : {}),
|
|
153
|
+
...(userAgent ? { [ATTR_USER_AGENT_ORIGINAL]: userAgent } : {}),
|
|
154
|
+
[ATTR_NETWORK_PROTOCOL_VERSION]: "1.1",
|
|
155
|
+
...(staticAttrs ?? {}),
|
|
156
|
+
};
|
|
157
|
+
await tracer.span(
|
|
158
|
+
// Span name is resolved at span-OPEN against the request line; the
|
|
159
|
+
// route template is also stamped post-`next()` once matched.
|
|
160
|
+
nameOf(c), async (span) => {
|
|
161
|
+
// Run the rest of the Hono pipeline INSIDE the SERVER span so
|
|
162
|
+
// downstream `tracer.span` calls nest under it (the lib's active
|
|
163
|
+
// span stack makes this span the parent for the downstream scope).
|
|
164
|
+
//
|
|
165
|
+
// NOTE on error capture: when a handler throws, Hono CATCHES it
|
|
166
|
+
// inside its own dispatch (compose) — whether or not an `onError`
|
|
167
|
+
// handler is registered — sets `c.error` + a 500 response, and
|
|
168
|
+
// `next()` RESOLVES normally (it does NOT re-throw past us). So the
|
|
169
|
+
// canonical way to observe the handler exception from middleware is
|
|
170
|
+
// `c.error` after `next()`, NOT a try/catch here. The try/catch is
|
|
171
|
+
// kept as a belt-and-suspenders for the rare case where an error
|
|
172
|
+
// genuinely propagates out of `next()` (e.g. a middleware that
|
|
173
|
+
// throws AFTER the response is built).
|
|
174
|
+
try {
|
|
175
|
+
await next();
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
span.recordException(err);
|
|
179
|
+
span.setAttribute(ATTR_ERROR_TYPE, err instanceof Error ? err.name : "Error");
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
// Post-pipeline: stamp the resolved route template + response
|
|
183
|
+
// status.
|
|
184
|
+
const route = resolveRouteTemplate(c);
|
|
185
|
+
if (route)
|
|
186
|
+
span.setAttribute(ATTR_HTTP_ROUTE, route);
|
|
187
|
+
// Capture the handler exception Hono stashed on `c.error` (present
|
|
188
|
+
// in both the `onError` and default-500 paths). This records the
|
|
189
|
+
// real `exception` span event + sets ERROR status per D27 — the
|
|
190
|
+
// information `instrumentation-http` would have captured.
|
|
191
|
+
const handlerError = c.error;
|
|
192
|
+
if (handlerError) {
|
|
193
|
+
span.recordException(handlerError);
|
|
194
|
+
span.setAttribute(ATTR_ERROR_TYPE, handlerError instanceof Error ? handlerError.name : "Error");
|
|
195
|
+
span.setStatus("ERROR");
|
|
196
|
+
}
|
|
197
|
+
const status = c.res.status;
|
|
198
|
+
span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, status);
|
|
199
|
+
// D27 HTTP status mapping: 5xx → ERROR; 4xx is a client error and
|
|
200
|
+
// stays UNSET (the server behaved correctly). `error.type` carries
|
|
201
|
+
// the status string on 5xx for filterable error analytics. (When a
|
|
202
|
+
// handler exception was already recorded above, the span is ERROR
|
|
203
|
+
// regardless; the status-derived `error.type` still applies on 5xx.)
|
|
204
|
+
if (status >= 500) {
|
|
205
|
+
span.setAttribute(ATTR_ERROR_TYPE, String(status));
|
|
206
|
+
span.setStatus("ERROR", `http_status_${status}`);
|
|
207
|
+
}
|
|
208
|
+
}, {
|
|
209
|
+
kind: "SERVER",
|
|
210
|
+
attributes: entryAttrs,
|
|
211
|
+
// Inherit the inbound trace when present (distributed continuity);
|
|
212
|
+
// malformed values fall back to root + a forensic attr (no throw).
|
|
213
|
+
...(inboundTraceparent ? { parent: inboundTraceparent } : {}),
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6DAA6D;AAC7D,EAAE;AACF,yEAAyE;AACzE,wEAAwE;AACxE,4EAA4E;AAC5E,EAAE;AACF,uCAAuC;AACvC,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,kEAAkE;AAClE,0EAA0E;AAC1E,2EAA2E;AAC3E,oEAAoE;AACpE,EAAE;AACF,wEAAwE;AACxE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,qEAAqE;AACrE,EAAE;AACF,uEAAuE;AAC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AAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAC5D,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;YAED,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;YAC5B,IAAI,CAAC,YAAY,CAAC,8BAA8B,EAAE,MAAM,CAAC,CAAC;YAC1D,kEAAkE;YAClE,mEAAmE;YACnE,mEAAmE;YACnE,kEAAkE;YAClE,qEAAqE;YACrE,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;gBAClB,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;gBACnD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,MAAM,EAAE,CAAC,CAAC;YACnD,CAAC;QACH,CAAC,EACD;YACE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,UAAU;YACtB,mEAAmE;YACnE,mEAAmE;YACnE,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9D,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,M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,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,YAAY,EACV,SAAS,EACT,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
// force-flush-on-return so spans/metrics/
|
|
14
14
|
// logs survive the post-handler freeze.
|
|
15
15
|
// First consumer: s2s-auth-service.
|
|
16
|
+
// - @nodii/telemetry/hono — HTTP SERVER-span middleware (D154). One
|
|
17
|
+
// OTel SERVER span per request for Bun-served
|
|
18
|
+
// Hono apps, which `instrumentation-http`
|
|
19
|
+
// BYPASSES (Bun.serve doesn't use Node http).
|
|
20
|
+
// Generalizes edge's bespoke `edge.request`
|
|
21
|
+
// request-span bridge. TS-only subpath.
|
|
16
22
|
//
|
|
17
23
|
// Not yet shipped (D44 § 6.5 lists them; no implementation exists yet —
|
|
18
24
|
// they are tracked as follow-on requests, NOT advertised as vapor):
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,EAAE;AACF,0EAA0E;AAC1E,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,mEAAmE;AACnE,0EAA0E;AAC1E,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,wEAAwE;AACxE,oEAAoE;AACpE,uEAAuE;AACvE,8DAA8D;AAC9D,mDAAmD;AACnD,EAAE;AACF,oEAAoE;AACpE,gBAAgB;AAChB,EAAE;AACF,oEAAoE;AACpE,gEAAgE;AAChE,0DAA0D;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAOnD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAWjD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAS5E,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,gCAAgC,EAChC,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,8BAA8B,EAC9B,KAAK,EACL,iBAAiB,EACjB,cAAc,GACf,MAAM,YAAY,CAAC;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,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nodii/telemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Substrate observability library for the Nodii microservice stack — OTel wrapper, log envelope, intent lifecycle, audit signal, agent registry, context propagation. Spec: planning hub docKey=telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"types": "./dist/lambda/index.d.ts",
|
|
28
28
|
"default": "./dist/lambda/index.js"
|
|
29
29
|
},
|
|
30
|
+
"./hono": {
|
|
31
|
+
"types": "./dist/hono/index.d.ts",
|
|
32
|
+
"default": "./dist/hono/index.js"
|
|
33
|
+
},
|
|
30
34
|
"./worker": {
|
|
31
35
|
"types": "./dist/worker/index.d.ts",
|
|
32
36
|
"default": "./dist/worker/index.js"
|