@geekmidas/telescope 10.0.0-alpha.54 → 10.0.0-alpha.56
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/README.md +14 -14
- package/dist/{MetricsAggregator-BxBLQUPj.d.cts → MetricsAggregator-BJdIvfEv.d.mts} +2 -2
- package/dist/{MetricsAggregator-BxBLQUPj.d.cts.map → MetricsAggregator-BJdIvfEv.d.mts.map} +1 -1
- package/dist/{MetricsAggregator-j9wmZ0K_.d.mts → MetricsAggregator-CnC3oT5q.d.cts} +2 -2
- package/dist/{MetricsAggregator-j9wmZ0K_.d.mts.map → MetricsAggregator-CnC3oT5q.d.cts.map} +1 -1
- package/dist/{Telescope-BcrWTaar.d.mts → Telescope-BVfDvVvY.d.mts} +3 -3
- package/dist/{Telescope-BcrWTaar.d.mts.map → Telescope-BVfDvVvY.d.mts.map} +1 -1
- package/dist/{Telescope-DnCMZT7V.d.cts → Telescope-DeqSHfuB.d.cts} +3 -3
- package/dist/{Telescope-DnCMZT7V.d.cts.map → Telescope-DeqSHfuB.d.cts.map} +1 -1
- package/dist/Telescope.d.cts +1 -1
- package/dist/Telescope.d.mts +1 -1
- package/dist/adapters/lambda.d.cts +1 -1
- package/dist/adapters/lambda.d.mts +1 -1
- package/dist/adapters/middy.d.cts +1 -1
- package/dist/adapters/middy.d.mts +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/logger/console.d.cts +1 -1
- package/dist/logger/console.d.mts +1 -1
- package/dist/logger/pino.d.cts +1 -1
- package/dist/logger/pino.d.mts +1 -1
- package/dist/metrics/MetricsAggregator.d.cts +1 -1
- package/dist/metrics/MetricsAggregator.d.mts +1 -1
- package/dist/metrics/index.d.cts +1 -1
- package/dist/metrics/index.d.mts +1 -1
- package/dist/otlp/index.d.cts +1 -1
- package/dist/otlp/index.d.mts +1 -1
- package/dist/otlp/receiver.d.cts +2 -2
- package/dist/otlp/receiver.d.mts +2 -2
- package/dist/otlp/transformer.d.cts +1 -1
- package/dist/otlp/transformer.d.mts +1 -1
- package/dist/redact.d.cts +1 -1
- package/dist/redact.d.mts +1 -1
- package/dist/server/hono.cjs +11 -23
- package/dist/server/hono.cjs.map +1 -1
- package/dist/server/hono.d.cts +11 -3
- package/dist/server/hono.d.cts.map +1 -1
- package/dist/server/hono.d.mts +11 -3
- package/dist/server/hono.d.mts.map +1 -1
- package/dist/server/hono.mjs +11 -23
- package/dist/server/hono.mjs.map +1 -1
- package/dist/storage/kysely.d.cts +1 -1
- package/dist/storage/kysely.d.mts +1 -1
- package/dist/storage/memory.d.cts +1 -1
- package/dist/storage/memory.d.mts +1 -1
- package/dist/{transformer-DlESim6Q.d.cts → transformer-BtqjAs0b.d.cts} +2 -2
- package/dist/{transformer-BBBXCjHP.d.mts.map → transformer-BtqjAs0b.d.cts.map} +1 -1
- package/dist/{transformer-BBBXCjHP.d.mts → transformer-DI6t8-YA.d.mts} +2 -2
- package/dist/{transformer-DlESim6Q.d.cts.map → transformer-DI6t8-YA.d.mts.map} +1 -1
- package/dist/{types-a9Vistj1.d.cts → types-BVujq4zd.d.cts} +2 -2
- package/dist/{types-a9Vistj1.d.cts.map → types-BVujq4zd.d.cts.map} +1 -1
- package/dist/{types-a9Vistj1.d.mts → types-BVujq4zd.d.mts} +2 -2
- package/dist/{types-a9Vistj1.d.mts.map → types-BVujq4zd.d.mts.map} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +4 -7
- package/dist/ui-assets.cjs +0 -32
- package/dist/ui-assets.cjs.map +0 -1
- package/dist/ui-assets.d.cts +0 -11
- package/dist/ui-assets.d.cts.map +0 -1
- package/dist/ui-assets.d.mts +0 -11
- package/dist/ui-assets.d.mts.map +0 -1
- package/dist/ui-assets.mjs +0 -29
- package/dist/ui-assets.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @geekmidas/telescope
|
|
2
2
|
|
|
3
|
-
Laravel Telescope-style debugging and monitoring for web applications. Capture
|
|
3
|
+
Laravel Telescope-style debugging and monitoring for web applications. Capture HTTP requests, exceptions and logs, and read them back as a JSON API with a WebSocket feed. Headless: there is no dashboard — build whatever UI you want on the JSON.
|
|
4
4
|
|
|
5
5
|
**Framework-agnostic core** with adapters for Hono, AWS Lambda, and more.
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ pnpm add @geekmidas/telescope
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { Hono } from 'hono';
|
|
19
19
|
import { Telescope, InMemoryStorage } from '@geekmidas/telescope';
|
|
20
|
-
import {
|
|
20
|
+
import { createApi, createMiddleware } from '@geekmidas/telescope/server/hono';
|
|
21
21
|
|
|
22
22
|
const telescope = new Telescope({
|
|
23
23
|
storage: new InMemoryStorage(),
|
|
@@ -28,8 +28,8 @@ const app = new Hono();
|
|
|
28
28
|
// Add middleware to capture requests
|
|
29
29
|
app.use('*', createMiddleware(telescope));
|
|
30
30
|
|
|
31
|
-
// Mount the
|
|
32
|
-
app.route('/__telescope',
|
|
31
|
+
// Mount the JSON API
|
|
32
|
+
app.route('/__telescope', createApi(telescope));
|
|
33
33
|
|
|
34
34
|
// Your routes
|
|
35
35
|
app.get('/users', (c) => c.json({ users: [] }));
|
|
@@ -37,7 +37,7 @@ app.get('/users', (c) => c.json({ users: [] }));
|
|
|
37
37
|
export default app;
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
Read the data at `http://localhost:3000/__telescope/api/requests` (and `/api/exceptions`, `/api/logs`, …).
|
|
41
41
|
|
|
42
42
|
### Framework-Agnostic Core
|
|
43
43
|
|
|
@@ -80,7 +80,7 @@ try {
|
|
|
80
80
|
- **Request Recording**: Capture HTTP requests with headers, body, query params, and response
|
|
81
81
|
- **Exception Tracking**: Record exceptions with stack traces and source context
|
|
82
82
|
- **Log Aggregation**: Collect application logs with context
|
|
83
|
-
- **Real-time Updates**: WebSocket
|
|
83
|
+
- **Real-time Updates**: a WebSocket feed of new entries
|
|
84
84
|
- **Storage Agnostic**: Use in-memory for dev, database for production
|
|
85
85
|
- **Hono Integration**: First-class middleware and route mounting
|
|
86
86
|
- **Lambda Integration**: Wrapper and Middy middleware for AWS Lambda with auto-flush
|
|
@@ -95,7 +95,7 @@ const telescope = new Telescope({
|
|
|
95
95
|
// Optional: Enable/disable telescope (default: true)
|
|
96
96
|
enabled: true,
|
|
97
97
|
|
|
98
|
-
// Optional:
|
|
98
|
+
// Optional: where the JSON API is mounted (default: '/__telescope')
|
|
99
99
|
path: '/__telescope',
|
|
100
100
|
|
|
101
101
|
// Optional: Record request/response bodies (default: true)
|
|
@@ -344,7 +344,7 @@ telescope.destroy();
|
|
|
344
344
|
Import from `@geekmidas/telescope/server/hono`:
|
|
345
345
|
|
|
346
346
|
```typescript
|
|
347
|
-
import {
|
|
347
|
+
import { createApi, createMiddleware, setupWebSocket, getRequestId } from '@geekmidas/telescope/server/hono';
|
|
348
348
|
```
|
|
349
349
|
|
|
350
350
|
#### `createMiddleware(telescope)`
|
|
@@ -355,12 +355,12 @@ Returns Hono middleware that captures requests and responses.
|
|
|
355
355
|
app.use('*', createMiddleware(telescope));
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
#### `
|
|
358
|
+
#### `createApi(telescope)`
|
|
359
359
|
|
|
360
|
-
Returns a Hono app
|
|
360
|
+
Returns a Hono app serving the JSON API under `/api`.
|
|
361
361
|
|
|
362
362
|
```typescript
|
|
363
|
-
app.route('/__telescope',
|
|
363
|
+
app.route('/__telescope', createApi(telescope));
|
|
364
364
|
```
|
|
365
365
|
|
|
366
366
|
#### `setupWebSocket(app, telescope, upgradeWebSocket)`
|
|
@@ -371,7 +371,7 @@ Set up WebSocket routes for real-time updates.
|
|
|
371
371
|
import { createNodeWebSocket } from '@hono/node-ws';
|
|
372
372
|
|
|
373
373
|
const { upgradeWebSocket } = createNodeWebSocket({ app });
|
|
374
|
-
setupWebSocket(
|
|
374
|
+
setupWebSocket(createApi(telescope), telescope, upgradeWebSocket);
|
|
375
375
|
```
|
|
376
376
|
|
|
377
377
|
#### `getRequestId(c)`
|
|
@@ -542,9 +542,9 @@ const requestLogger = logger.withRequestId('req-abc123');
|
|
|
542
542
|
requestLogger.info('Processing request');
|
|
543
543
|
```
|
|
544
544
|
|
|
545
|
-
##
|
|
545
|
+
## JSON API
|
|
546
546
|
|
|
547
|
-
|
|
547
|
+
`createApi` serves a read API at the path it is mounted on:
|
|
548
548
|
|
|
549
549
|
| Endpoint | Description |
|
|
550
550
|
|----------|-------------|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as RequestEntry, g as StatusDistribution, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions } from "./types-
|
|
1
|
+
import { f as RequestEntry, g as StatusDistribution, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions } from "./types-BVujq4zd.mjs";
|
|
2
2
|
//#region src/metrics/MetricsAggregator.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for MetricsAggregator
|
|
@@ -55,4 +55,4 @@ declare class MetricsAggregator {
|
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
export { MetricsAggregatorOptions as n, MetricsAggregator as t };
|
|
58
|
-
//# sourceMappingURL=MetricsAggregator-
|
|
58
|
+
//# sourceMappingURL=MetricsAggregator-BJdIvfEv.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricsAggregator-
|
|
1
|
+
{"version":3,"file":"MetricsAggregator-BJdIvfEv.d.mts","names":[],"sources":["../src/metrics/MetricsAggregator.ts"],"mappings":";;;;;UAgBiB;;EAEhB;;EAEA;;EAEA;;cAwBY;UACJ;UACA;UACA;UAEA;EAGR,YAAY,UAAS;;;;EAOrB,OAAO,OAAO;;;;EAiBd,WAAW,UAAS,sBAA2B;;;;EAwD/C,mBAAmB,UAAS,sBAA2B;;;;EAiCvD,sBAAsB,UAAS,sBAA2B;;;;EAwB1D,mBACC,gBACA,cACA,UAAS,sBACP;;;;EAyEH;UAUQ;UAMA;UAuCA;UAuCA;UAsDA;UAmBA;UAgBA;UAMA;UAcA;UAqDA;UAiBA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as RequestEntry, g as StatusDistribution, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions } from "./types-
|
|
1
|
+
import { f as RequestEntry, g as StatusDistribution, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions } from "./types-BVujq4zd.cjs";
|
|
2
2
|
//#region src/metrics/MetricsAggregator.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for MetricsAggregator
|
|
@@ -55,4 +55,4 @@ declare class MetricsAggregator {
|
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
export { MetricsAggregatorOptions as n, MetricsAggregator as t };
|
|
58
|
-
//# sourceMappingURL=MetricsAggregator-
|
|
58
|
+
//# sourceMappingURL=MetricsAggregator-CnC3oT5q.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricsAggregator-
|
|
1
|
+
{"version":3,"file":"MetricsAggregator-CnC3oT5q.d.cts","names":[],"sources":["../src/metrics/MetricsAggregator.ts"],"mappings":";;;;;UAgBiB;;EAEhB;;EAEA;;EAEA;;cAwBY;UACJ;UACA;UACA;UAEA;EAGR,YAAY,UAAS;;;;EAOrB,OAAO,OAAO;;;;EAiBd,WAAW,UAAS,sBAA2B;;;;EAwD/C,mBAAmB,UAAS,sBAA2B;;;;EAiCvD,sBAAsB,UAAS,sBAA2B;;;;EAwB1D,mBACC,gBACA,cACA,UAAS,sBACP;;;;EAyEH;UAUQ;UAMA;UAuCA;UAuCA;UAsDA;UAmBA;UAgBA;UAMA;UAcA;UAqDA;UAiBA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as TelescopeEvent, a as LogEntry, c as MetricsSnapshot, f as RequestEntry, g as StatusDistribution, i as ExceptionEntry, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, u as QueryOptions, x as TelescopeStats, y as TelescopeOptions } from "./types-
|
|
2
|
-
import { n as MetricsAggregatorOptions } from "./MetricsAggregator-
|
|
1
|
+
import { _ as TelescopeEvent, a as LogEntry, c as MetricsSnapshot, f as RequestEntry, g as StatusDistribution, i as ExceptionEntry, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, u as QueryOptions, x as TelescopeStats, y as TelescopeOptions } from "./types-BVujq4zd.mjs";
|
|
2
|
+
import { n as MetricsAggregatorOptions } from "./MetricsAggregator-BJdIvfEv.mjs";
|
|
3
3
|
//#region src/Telescope.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Framework-agnostic Telescope class for debugging and monitoring applications.
|
|
@@ -166,4 +166,4 @@ declare class Telescope {
|
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
export { Telescope as t };
|
|
169
|
-
//# sourceMappingURL=Telescope-
|
|
169
|
+
//# sourceMappingURL=Telescope-BVfDvVvY.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Telescope-
|
|
1
|
+
{"version":3,"file":"Telescope-BVfDvVvY.d.mts","names":["_$__types0.TelescopeStats"],"sources":["../src/Telescope.ts"],"mappings":";;;;;;;cA4Ba;UACJ;UACA;UACA;UACA;UACA;UACA;UACA;EAER,YACC,SAAS;IAAqB,UAAU;;;;;EAuBnC,cACL,OAAO,KAAK,oCACV;;;;UA+BW;;;;;;;;;;;EAsBR,IACL,SAAS;IACR;IACA;IACA,UAAU;IACV;OAEC;;;;EAsBG,MACL,iBACA,UAAU,yBACV,qBACE;;;;EAOG,KACL,iBACA,UAAU,yBACV,qBACE;;;;EAOG,KACL,iBACA,UAAU,yBACV,qBACE;;;;EAOG,MACL,iBACA,UAAU,yBACV,qBACE;UAIW;;;;EA4BR,UAAU,OAAO,OAAO,qBAAqB;;;;EA8B7C,YAAY,UAAU,eAAe,QAAQ;;;;EAO7C,WAAW,aAAa,QAAQ;;;;EAOhC,cAAc,UAAU,eAAe,QAAQ;;;;EAO/C,aAAa,aAAa,QAAQ;;;;EAOlC,QAAQ,UAAU,eAAe,QAAQ;;;;EAOzC,YAAQ,QAPyBA;;;;EAkBvC,WAAW,UAAU,sBAAsB;;;;EAO3C,mBAAmB,UAAU,sBAAsB;;;;EAOnD,mBACC,gBACA,cACA,UAAU,sBACR;;;;EAOH,sBAAsB,UAAU,sBAAsB;;;;EAOtD;;;;EAOA,sBAAsB;;;;;;;EAuBtB,sBAAsB;;;;EAoBtB;;;;EAcA,YAAY,IAAI;;;;EAYhB,eAAe,IAAI;;;;EAOnB,UAAU,OAAO;;;;EAkBX,MAAM,WAAW,OAAO;;;;EAO9B;;;;MAeI;;;;MAOA;;;;MAOA;;;;MAOA;;;;EAOJ,aAAa;UAqBL;UAeA;UA2CM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as TelescopeEvent, a as LogEntry, c as MetricsSnapshot, f as RequestEntry, g as StatusDistribution, i as ExceptionEntry, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, u as QueryOptions, x as TelescopeStats, y as TelescopeOptions } from "./types-
|
|
2
|
-
import { n as MetricsAggregatorOptions } from "./MetricsAggregator-
|
|
1
|
+
import { _ as TelescopeEvent, a as LogEntry, c as MetricsSnapshot, f as RequestEntry, g as StatusDistribution, i as ExceptionEntry, n as EndpointDetails, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, u as QueryOptions, x as TelescopeStats, y as TelescopeOptions } from "./types-BVujq4zd.cjs";
|
|
2
|
+
import { n as MetricsAggregatorOptions } from "./MetricsAggregator-CnC3oT5q.cjs";
|
|
3
3
|
//#region src/Telescope.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Framework-agnostic Telescope class for debugging and monitoring applications.
|
|
@@ -166,4 +166,4 @@ declare class Telescope {
|
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
export { Telescope as t };
|
|
169
|
-
//# sourceMappingURL=Telescope-
|
|
169
|
+
//# sourceMappingURL=Telescope-DeqSHfuB.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Telescope-
|
|
1
|
+
{"version":3,"file":"Telescope-DeqSHfuB.d.cts","names":["_$__types0.TelescopeStats"],"sources":["../src/Telescope.ts"],"mappings":";;;;;;;cA4Ba;UACJ;UACA;UACA;UACA;UACA;UACA;UACA;EAER,YACC,SAAS;IAAqB,UAAU;;;;;EAuBnC,cACL,OAAO,KAAK,oCACV;;;;UA+BW;;;;;;;;;;;EAsBR,IACL,SAAS;IACR;IACA;IACA,UAAU;IACV;OAEC;;;;EAsBG,MACL,iBACA,UAAU,yBACV,qBACE;;;;EAOG,KACL,iBACA,UAAU,yBACV,qBACE;;;;EAOG,KACL,iBACA,UAAU,yBACV,qBACE;;;;EAOG,MACL,iBACA,UAAU,yBACV,qBACE;UAIW;;;;EA4BR,UAAU,OAAO,OAAO,qBAAqB;;;;EA8B7C,YAAY,UAAU,eAAe,QAAQ;;;;EAO7C,WAAW,aAAa,QAAQ;;;;EAOhC,cAAc,UAAU,eAAe,QAAQ;;;;EAO/C,aAAa,aAAa,QAAQ;;;;EAOlC,QAAQ,UAAU,eAAe,QAAQ;;;;EAOzC,YAAQ,QAPyBA;;;;EAkBvC,WAAW,UAAU,sBAAsB;;;;EAO3C,mBAAmB,UAAU,sBAAsB;;;;EAOnD,mBACC,gBACA,cACA,UAAU,sBACR;;;;EAOH,sBAAsB,UAAU,sBAAsB;;;;EAOtD;;;;EAOA,sBAAsB;;;;;;;EAuBtB,sBAAsB;;;;EAoBtB;;;;EAcA,YAAY,IAAI;;;;EAYhB,eAAe,IAAI;;;;EAOnB,UAAU,OAAO;;;;EAkBX,MAAM,WAAW,OAAO;;;;EAO9B;;;;MAeI;;;;MAOA;;;;MAOA;;;;MAOA;;;;EAOJ,aAAa;UAqBL;UAeA;UA2CM"}
|
package/dist/Telescope.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Telescope } from "./Telescope-
|
|
1
|
+
import { t as Telescope } from "./Telescope-DeqSHfuB.cjs";
|
|
2
2
|
export { Telescope };
|
package/dist/Telescope.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Telescope } from "./Telescope-
|
|
1
|
+
import { t as Telescope } from "./Telescope-BVfDvVvY.mjs";
|
|
2
2
|
export { Telescope };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-DeqSHfuB.cjs";
|
|
2
2
|
import { AdapterRequestContext, AdapterResponseContext, LambdaAdapterConfig, TelescopeAdapter } from "./types.cjs";
|
|
3
3
|
import { TelescopeMiddlewareOptions, createTelescopeHandler, telescopeMiddleware } from "./middy.cjs";
|
|
4
4
|
import { Context } from "aws-lambda";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-BVfDvVvY.mjs";
|
|
2
2
|
import { AdapterRequestContext, AdapterResponseContext, LambdaAdapterConfig, TelescopeAdapter } from "./types.mjs";
|
|
3
3
|
import { TelescopeMiddlewareOptions, createTelescopeHandler, telescopeMiddleware } from "./middy.mjs";
|
|
4
4
|
import { Context } from "aws-lambda";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-DeqSHfuB.cjs";
|
|
2
2
|
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context } from "aws-lambda";
|
|
3
3
|
import { MiddlewareObj } from "@middy/core";
|
|
4
4
|
//#region src/adapters/middy.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-BVfDvVvY.mjs";
|
|
2
2
|
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context } from "aws-lambda";
|
|
3
3
|
import { MiddlewareObj } from "@middy/core";
|
|
4
4
|
//#region src/adapters/middy.d.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as TimeRange, S as TelescopeStorage, _ as TelescopeEvent, a as LogEntry, d as RequestContext, f as RequestEntry, g as StatusDistribution, h as StackFrame, i as ExceptionEntry, l as NormalizedTelescopeOptions, m as SourceContext, o as MetricsBucket, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, t as EndpointBucket, u as QueryOptions, v as TelescopeEventType, w as TimeSeriesPoint, x as TelescopeStats, y as TelescopeOptions } from "./types-
|
|
2
|
-
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "./MetricsAggregator-
|
|
3
|
-
import { t as Telescope } from "./Telescope-
|
|
1
|
+
import { C as TimeRange, S as TelescopeStorage, _ as TelescopeEvent, a as LogEntry, d as RequestContext, f as RequestEntry, g as StatusDistribution, h as StackFrame, i as ExceptionEntry, l as NormalizedTelescopeOptions, m as SourceContext, o as MetricsBucket, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, t as EndpointBucket, u as QueryOptions, v as TelescopeEventType, w as TimeSeriesPoint, x as TelescopeStats, y as TelescopeOptions } from "./types-BVujq4zd.cjs";
|
|
2
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "./MetricsAggregator-CnC3oT5q.cjs";
|
|
3
|
+
import { t as Telescope } from "./Telescope-DeqSHfuB.cjs";
|
|
4
4
|
import { InMemoryStorage, InMemoryStorageOptions } from "./storage/memory.cjs";
|
|
5
5
|
export { type EndpointBucket, type EndpointMetrics, type ExceptionEntry, InMemoryStorage, type InMemoryStorageOptions, type LogEntry, MetricsAggregator, type MetricsAggregatorOptions, type MetricsBucket, type MetricsQueryOptions, type NormalizedTelescopeOptions, type QueryOptions, type RequestContext, type RequestEntry, type RequestMetrics, type SourceContext, type StackFrame, type StatusDistribution, Telescope, type TelescopeEvent, type TelescopeEventType, type TelescopeOptions, type TelescopeStats, type TelescopeStorage, type TimeRange, type TimeSeriesPoint };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as TimeRange, S as TelescopeStorage, _ as TelescopeEvent, a as LogEntry, d as RequestContext, f as RequestEntry, g as StatusDistribution, h as StackFrame, i as ExceptionEntry, l as NormalizedTelescopeOptions, m as SourceContext, o as MetricsBucket, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, t as EndpointBucket, u as QueryOptions, v as TelescopeEventType, w as TimeSeriesPoint, x as TelescopeStats, y as TelescopeOptions } from "./types-
|
|
2
|
-
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "./MetricsAggregator-
|
|
3
|
-
import { t as Telescope } from "./Telescope-
|
|
1
|
+
import { C as TimeRange, S as TelescopeStorage, _ as TelescopeEvent, a as LogEntry, d as RequestContext, f as RequestEntry, g as StatusDistribution, h as StackFrame, i as ExceptionEntry, l as NormalizedTelescopeOptions, m as SourceContext, o as MetricsBucket, p as RequestMetrics, r as EndpointMetrics, s as MetricsQueryOptions, t as EndpointBucket, u as QueryOptions, v as TelescopeEventType, w as TimeSeriesPoint, x as TelescopeStats, y as TelescopeOptions } from "./types-BVujq4zd.mjs";
|
|
2
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "./MetricsAggregator-BJdIvfEv.mjs";
|
|
3
|
+
import { t as Telescope } from "./Telescope-BVfDvVvY.mjs";
|
|
4
4
|
import { InMemoryStorage, InMemoryStorageOptions } from "./storage/memory.mjs";
|
|
5
5
|
export { type EndpointBucket, type EndpointMetrics, type ExceptionEntry, InMemoryStorage, type InMemoryStorageOptions, type LogEntry, MetricsAggregator, type MetricsAggregatorOptions, type MetricsBucket, type MetricsQueryOptions, type NormalizedTelescopeOptions, type QueryOptions, type RequestContext, type RequestEntry, type RequestMetrics, type SourceContext, type StackFrame, type StatusDistribution, Telescope, type TelescopeEvent, type TelescopeEventType, type TelescopeOptions, type TelescopeStats, type TelescopeStorage, type TimeRange, type TimeSeriesPoint };
|
package/dist/logger/pino.d.cts
CHANGED
package/dist/logger/pino.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-
|
|
1
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-CnC3oT5q.cjs";
|
|
2
2
|
export { MetricsAggregator, MetricsAggregatorOptions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-
|
|
1
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-BJdIvfEv.mjs";
|
|
2
2
|
export { MetricsAggregator, MetricsAggregatorOptions };
|
package/dist/metrics/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-
|
|
1
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-CnC3oT5q.cjs";
|
|
2
2
|
export { MetricsAggregator, type MetricsAggregatorOptions };
|
package/dist/metrics/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-
|
|
1
|
+
import { n as MetricsAggregatorOptions, t as MetricsAggregator } from "../MetricsAggregator-BJdIvfEv.mjs";
|
|
2
2
|
export { MetricsAggregator, type MetricsAggregatorOptions };
|
package/dist/otlp/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { C as LogRecord, E as Resource, I as SpanKind, N as SeverityNumber, P as Span, f as ExportMetricsServiceRequest, g as ExportTraceServiceResponse, h as ExportTraceServiceRequest, l as ExportLogsServiceRequest, p as ExportMetricsServiceResponse, u as ExportLogsServiceResponse, w as Metric, x as KeyValue, z as SpanStatusCode } from "../types-DVETVdpa.cjs";
|
|
2
|
-
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-
|
|
2
|
+
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-BtqjAs0b.cjs";
|
|
3
3
|
import { MetricsHandler, OTLPReceiver, OTLPReceiverOptions } from "./receiver.cjs";
|
|
4
4
|
export { type ExportLogsServiceRequest, type ExportLogsServiceResponse, type ExportMetricsServiceRequest, type ExportMetricsServiceResponse, type ExportTraceServiceRequest, type ExportTraceServiceResponse, type KeyValue, type LogRecord, type Metric, type MetricDataPoint, type MetricsHandler, OTLPReceiver, type OTLPReceiverOptions, type Resource, SeverityNumber, type Span, SpanKind, SpanStatusCode, transformLogs, transformMetrics, transformTraces };
|
package/dist/otlp/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { C as LogRecord, E as Resource, I as SpanKind, N as SeverityNumber, P as Span, f as ExportMetricsServiceRequest, g as ExportTraceServiceResponse, h as ExportTraceServiceRequest, l as ExportLogsServiceRequest, p as ExportMetricsServiceResponse, u as ExportLogsServiceResponse, w as Metric, x as KeyValue, z as SpanStatusCode } from "../types-DVETVdpa.mjs";
|
|
2
|
-
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-
|
|
2
|
+
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-DI6t8-YA.mjs";
|
|
3
3
|
import { MetricsHandler, OTLPReceiver, OTLPReceiverOptions } from "./receiver.mjs";
|
|
4
4
|
export { type ExportLogsServiceRequest, type ExportLogsServiceResponse, type ExportMetricsServiceRequest, type ExportMetricsServiceResponse, type ExportTraceServiceRequest, type ExportTraceServiceResponse, type KeyValue, type LogRecord, type Metric, type MetricDataPoint, type MetricsHandler, OTLPReceiver, type OTLPReceiverOptions, type Resource, SeverityNumber, type Span, SpanKind, SpanStatusCode, transformLogs, transformMetrics, transformTraces };
|
package/dist/otlp/receiver.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-DeqSHfuB.cjs";
|
|
2
2
|
import { f as ExportMetricsServiceRequest, g as ExportTraceServiceResponse, h as ExportTraceServiceRequest, l as ExportLogsServiceRequest, p as ExportMetricsServiceResponse, u as ExportLogsServiceResponse } from "../types-DVETVdpa.cjs";
|
|
3
|
-
import { t as MetricDataPoint } from "../transformer-
|
|
3
|
+
import { t as MetricDataPoint } from "../transformer-BtqjAs0b.cjs";
|
|
4
4
|
//#region src/otlp/receiver.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Callback for handling OTLP metrics
|
package/dist/otlp/receiver.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-BVfDvVvY.mjs";
|
|
2
2
|
import { f as ExportMetricsServiceRequest, g as ExportTraceServiceResponse, h as ExportTraceServiceRequest, l as ExportLogsServiceRequest, p as ExportMetricsServiceResponse, u as ExportLogsServiceResponse } from "../types-DVETVdpa.mjs";
|
|
3
|
-
import { t as MetricDataPoint } from "../transformer-
|
|
3
|
+
import { t as MetricDataPoint } from "../transformer-DI6t8-YA.mjs";
|
|
4
4
|
//#region src/otlp/receiver.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Callback for handling OTLP metrics
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-
|
|
1
|
+
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-BtqjAs0b.cjs";
|
|
2
2
|
export { MetricDataPoint, transformLogs, transformMetrics, transformTraces };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-
|
|
1
|
+
import { i as transformTraces, n as transformLogs, r as transformMetrics, t as MetricDataPoint } from "../transformer-DI6t8-YA.mjs";
|
|
2
2
|
export { MetricDataPoint, transformLogs, transformMetrics, transformTraces };
|
package/dist/redact.d.cts
CHANGED
package/dist/redact.d.mts
CHANGED
package/dist/server/hono.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ui_assets = require("../ui-assets.cjs");
|
|
3
2
|
let hono = require("hono");
|
|
4
3
|
//#region src/server/hono.ts
|
|
5
4
|
let _flushTelemetry = null;
|
|
@@ -136,9 +135,17 @@ function parseMetricsQueryOptions(c) {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
/**
|
|
139
|
-
*
|
|
138
|
+
* Telescope's JSON API: requests, exceptions, logs, stats and metrics under
|
|
139
|
+
* `/api/*`. Headless — there is no dashboard; anything can be built on the
|
|
140
|
+
* JSON, and live updates come from the WebSocket feed (`setupWebSocket`).
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* app.route('/__telescope', createApi(telescope));
|
|
145
|
+
* // GET /__telescope/api/requests
|
|
146
|
+
* ```
|
|
140
147
|
*/
|
|
141
|
-
function
|
|
148
|
+
function createApi(telescope) {
|
|
142
149
|
const app = new hono.Hono();
|
|
143
150
|
app.get("/api/requests", async (c) => {
|
|
144
151
|
const options = parseQueryOptions(c);
|
|
@@ -197,25 +204,6 @@ function createUI(telescope) {
|
|
|
197
204
|
telescope.resetMetrics();
|
|
198
205
|
return c.json({ success: true });
|
|
199
206
|
});
|
|
200
|
-
app.get("/assets/:filename", (c) => {
|
|
201
|
-
const assetPath = `assets/${c.req.param("filename")}`;
|
|
202
|
-
const asset = require_ui_assets.getAsset(assetPath);
|
|
203
|
-
if (asset) return c.body(asset.content, 200, {
|
|
204
|
-
"Content-Type": asset.contentType,
|
|
205
|
-
"Cache-Control": "public, max-age=31536000, immutable"
|
|
206
|
-
});
|
|
207
|
-
return c.notFound();
|
|
208
|
-
});
|
|
209
|
-
app.get("/", (c) => {
|
|
210
|
-
const html = require_ui_assets.getIndexHtml();
|
|
211
|
-
if (!html) return c.text("Telescope UI not available. Run \"pnpm build:ui\" first.", 500);
|
|
212
|
-
return c.html(html);
|
|
213
|
-
});
|
|
214
|
-
app.get("/*", (c) => {
|
|
215
|
-
const html = require_ui_assets.getIndexHtml();
|
|
216
|
-
if (!html) return c.text("Telescope UI not available. Run \"pnpm build:ui\" first.", 500);
|
|
217
|
-
return c.html(html);
|
|
218
|
-
});
|
|
219
207
|
return app;
|
|
220
208
|
}
|
|
221
209
|
/**
|
|
@@ -252,8 +240,8 @@ function getRequestId(c) {
|
|
|
252
240
|
return getTelescopeContext(c)?.requestId;
|
|
253
241
|
}
|
|
254
242
|
//#endregion
|
|
243
|
+
exports.createApi = createApi;
|
|
255
244
|
exports.createMiddleware = createMiddleware;
|
|
256
|
-
exports.createUI = createUI;
|
|
257
245
|
exports.getFlushTelemetryFn = getFlushTelemetry;
|
|
258
246
|
exports.getRequestId = getRequestId;
|
|
259
247
|
exports.getTelescopeContext = getTelescopeContext;
|
package/dist/server/hono.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.cjs","names":["Hono","getAsset","getIndexHtml"],"sources":["../../src/server/hono.ts"],"sourcesContent":["import type { Context, MiddlewareHandler, Next } from 'hono';\nimport { Hono } from 'hono';\nimport type {\n\tHonoAdapterConfig,\n\tTelescopeHonoContext,\n} from '../adapters/types';\nimport type { Telescope } from '../Telescope';\nimport type { MetricsQueryOptions, QueryOptions } from '../types';\nimport { getAsset, getIndexHtml } from '../ui-assets';\n\n// Lazy-loaded telemetry flush function (only loads @opentelemetry/* when actually used)\nlet _flushTelemetry: (() => Promise<void>) | null = null;\nasync function getFlushTelemetry(): Promise<() => Promise<void>> {\n\tif (!_flushTelemetry) {\n\t\tconst { flushTelemetry } = await import('../instrumentation/core');\n\t\t_flushTelemetry = flushTelemetry;\n\t}\n\treturn _flushTelemetry;\n}\n\nconst CONTEXT_KEY = 'telescope-context';\n\n/** Default Hono adapter configuration */\nconst _DEFAULT_CONFIG: HonoAdapterConfig = {\n\tenvironment: 'server',\n};\n\n/**\n * Options for the Telescope Hono middleware\n */\nexport interface TelescopeMiddlewareOptions {\n\t/**\n\t * Whether to flush telemetry after each request.\n\t * Enable this for serverless environments (Lambda, Edge).\n\t * @default false\n\t */\n\tflushOnResponse?: boolean;\n}\n\n/**\n * Create Hono middleware that captures requests and responses\n */\nexport function createMiddleware(\n\ttelescope: Telescope,\n\toptions: TelescopeMiddlewareOptions = {},\n): MiddlewareHandler {\n\tconst { flushOnResponse = false } = options;\n\n\treturn async (c: Context, next: Next) => {\n\t\tif (!telescope.enabled) {\n\t\t\treturn next();\n\t\t}\n\n\t\tif (telescope.shouldIgnore(c.req.path)) {\n\t\t\treturn next();\n\t\t}\n\n\t\tconst startTime = performance.now();\n\n\t\t// Capture request data\n\t\tconst headers: Record<string, string> = {};\n\t\tc.req.raw.headers.forEach((value, key) => {\n\t\t\theaders[key] = value;\n\t\t});\n\n\t\tconst url = new URL(c.req.url);\n\t\tconst query: Record<string, string> = {};\n\t\turl.searchParams.forEach((value, key) => {\n\t\t\tquery[key] = value;\n\t\t});\n\n\t\tlet body: unknown;\n\t\tlet requestSize: number | undefined;\n\n\t\t// Get request size from Content-Length header\n\t\tconst contentLength = c.req.header('content-length');\n\t\tif (contentLength) {\n\t\t\trequestSize = parseInt(contentLength, 10);\n\t\t}\n\n\t\tif (\n\t\t\ttelescope.recordBody &&\n\t\t\t['POST', 'PUT', 'PATCH'].includes(c.req.method)\n\t\t) {\n\t\t\ttry {\n\t\t\t\tconst contentType = c.req.header('content-type') || '';\n\t\t\t\t// Clone the request to avoid consuming the body stream\n\t\t\t\tconst clonedRequest = c.req.raw.clone();\n\t\t\t\tif (contentType.includes('application/json')) {\n\t\t\t\t\tbody = await clonedRequest.json();\n\t\t\t\t} else if (contentType.includes('application/x-www-form-urlencoded')) {\n\t\t\t\t\tbody = Object.fromEntries((await clonedRequest.formData()).entries());\n\t\t\t\t} else if (contentType.includes('text/')) {\n\t\t\t\t\tbody = await clonedRequest.text();\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore body parsing errors\n\t\t\t}\n\t\t}\n\n\t\tconst ip = c.req.header('x-forwarded-for') || c.req.header('x-real-ip');\n\n\t\ttry {\n\t\t\tawait next();\n\n\t\t\t// Capture response data\n\t\t\tconst duration = performance.now() - startTime;\n\n\t\t\tconst responseHeaders: Record<string, string> = {};\n\t\t\tc.res.headers.forEach((value, key) => {\n\t\t\t\tresponseHeaders[key] = value;\n\t\t\t});\n\n\t\t\tlet responseBody: unknown;\n\t\t\tlet responseSize: number | undefined;\n\n\t\t\t// Get response size - prefer Content-Length header, fallback to body size\n\t\t\tconst responseContentLength = c.res.headers.get('content-length');\n\t\t\tif (responseContentLength) {\n\t\t\t\tresponseSize = parseInt(responseContentLength, 10);\n\t\t\t}\n\n\t\t\tif (telescope.recordBody) {\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = c.res.headers.get('content-type') || '';\n\t\t\t\t\tif (contentType.includes('application/json')) {\n\t\t\t\t\t\tconst cloned = c.res.clone();\n\t\t\t\t\t\tconst text = await cloned.text();\n\t\t\t\t\t\tresponseSize ??= Buffer.byteLength(text, 'utf8');\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresponseBody = JSON.parse(text);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tresponseBody = text;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore body parsing errors\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst requestId = await telescope.recordRequest({\n\t\t\t\tmethod: c.req.method,\n\t\t\t\tpath: c.req.path,\n\t\t\t\turl: c.req.url,\n\t\t\t\theaders,\n\t\t\t\tbody,\n\t\t\t\tquery,\n\t\t\t\tstatus: c.res.status,\n\t\t\t\tresponseHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tduration,\n\t\t\t\tip,\n\t\t\t\trequestSize,\n\t\t\t\tresponseSize,\n\t\t\t});\n\n\t\t\t// Store context for access by other middleware\n\t\t\tconst ctx: TelescopeHonoContext = {\n\t\t\t\trequestId,\n\t\t\t\tstartTime,\n\t\t\t};\n\t\t\tc.set(CONTEXT_KEY, ctx);\n\n\t\t\t// Flush telemetry for serverless environments\n\t\t\tif (flushOnResponse) {\n\t\t\t\tconst flushTelemetry = await getFlushTelemetry();\n\t\t\t\tawait flushTelemetry();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait telescope.exception(error as Error);\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\n/**\n * Parse query options from Hono context\n */\nfunction parseQueryOptions(c: Context): QueryOptions {\n\tconst limit = parseInt(c.req.query('limit') || '50', 10);\n\tconst offset = parseInt(c.req.query('offset') || '0', 10);\n\tconst search = c.req.query('search');\n\tconst before = c.req.query('before');\n\tconst after = c.req.query('after');\n\tconst tags = c.req.query('tags')?.split(',').filter(Boolean);\n\tconst method = c.req.query('method');\n\tconst status = c.req.query('status');\n\tconst level = c.req.query('level') as\n\t\t| 'debug'\n\t\t| 'info'\n\t\t| 'warn'\n\t\t| 'error'\n\t\t| undefined;\n\n\treturn {\n\t\tlimit: Math.min(limit, 100),\n\t\toffset,\n\t\tsearch,\n\t\tbefore: before ? new Date(before) : undefined,\n\t\tafter: after ? new Date(after) : undefined,\n\t\ttags,\n\t\tmethod: method || undefined,\n\t\tstatus: status || undefined,\n\t\tlevel: level || undefined,\n\t};\n}\n\n/**\n * Parse metrics query options from Hono context\n */\nfunction parseMetricsQueryOptions(c: Context): MetricsQueryOptions {\n\tconst start = c.req.query('start');\n\tconst end = c.req.query('end');\n\tconst bucketSize = c.req.query('bucketSize');\n\tconst limit = c.req.query('limit');\n\n\treturn {\n\t\trange:\n\t\t\tstart && end ? { start: new Date(start), end: new Date(end) } : undefined,\n\t\tbucketSize: bucketSize ? parseInt(bucketSize, 10) : undefined,\n\t\tlimit: limit ? parseInt(limit, 10) : undefined,\n\t};\n}\n\n/**\n * Create Hono app with dashboard UI and API routes\n */\nexport function createUI(telescope: Telescope): Hono {\n\tconst app = new Hono();\n\n\t// API routes\n\tapp.get('/api/requests', async (c) => {\n\t\tconst options = parseQueryOptions(c);\n\t\tconst requests = await telescope.getRequests(options);\n\t\treturn c.json(requests);\n\t});\n\n\tapp.get('/api/requests/:id', async (c) => {\n\t\tconst request = await telescope.getRequest(c.req.param('id'));\n\t\tif (!request) {\n\t\t\treturn c.json({ error: 'Request not found' }, 404);\n\t\t}\n\t\treturn c.json(request);\n\t});\n\n\tapp.get('/api/exceptions', async (c) => {\n\t\tconst options = parseQueryOptions(c);\n\t\tconst exceptions = await telescope.getExceptions(options);\n\t\treturn c.json(exceptions);\n\t});\n\n\tapp.get('/api/exceptions/:id', async (c) => {\n\t\tconst exception = await telescope.getException(c.req.param('id'));\n\t\tif (!exception) {\n\t\t\treturn c.json({ error: 'Exception not found' }, 404);\n\t\t}\n\t\treturn c.json(exception);\n\t});\n\n\tapp.get('/api/logs', async (c) => {\n\t\tconst options = parseQueryOptions(c);\n\t\tconst logs = await telescope.getLogs(options);\n\t\treturn c.json(logs);\n\t});\n\n\tapp.get('/api/stats', async (c) => {\n\t\tconst stats = await telescope.getStats();\n\t\treturn c.json(stats);\n\t});\n\n\t// Metrics API\n\tapp.get('/api/metrics', (c) => {\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst metrics = telescope.getMetrics(options);\n\t\treturn c.json(metrics);\n\t});\n\n\tapp.get('/api/metrics/endpoints', (c) => {\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst endpoints = telescope.getEndpointMetrics(options);\n\t\treturn c.json(endpoints);\n\t});\n\n\t// Endpoint details - method and path are query params to avoid URL encoding issues\n\tapp.get('/api/metrics/endpoint', (c) => {\n\t\tconst method = c.req.query('method');\n\t\tconst path = c.req.query('path');\n\n\t\tif (!method || !path) {\n\t\t\treturn c.json({ error: 'method and path are required' }, 400);\n\t\t}\n\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst details = telescope.getEndpointDetails(method, path, options);\n\n\t\tif (!details) {\n\t\t\treturn c.json({ error: 'Endpoint not found' }, 404);\n\t\t}\n\n\t\treturn c.json(details);\n\t});\n\n\tapp.get('/api/metrics/status', (c) => {\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst distribution = telescope.getStatusDistribution(options);\n\t\treturn c.json(distribution);\n\t});\n\n\tapp.delete('/api/metrics', (c) => {\n\t\ttelescope.resetMetrics();\n\t\treturn c.json({ success: true });\n\t});\n\n\t// Static assets\n\tapp.get('/assets/:filename', (c) => {\n\t\tconst filename = c.req.param('filename');\n\t\tconst assetPath = `assets/${filename}`;\n\t\tconst asset = getAsset(assetPath);\n\t\tif (asset) {\n\t\t\treturn c.body(asset.content, 200, {\n\t\t\t\t'Content-Type': asset.contentType,\n\t\t\t\t'Cache-Control': 'public, max-age=31536000, immutable',\n\t\t\t});\n\t\t}\n\t\treturn c.notFound();\n\t});\n\n\t// Dashboard UI - serve React app\n\tapp.get('/', (c) => {\n\t\tconst html = getIndexHtml();\n\t\tif (!html) {\n\t\t\treturn c.text(\n\t\t\t\t'Telescope UI not available. Run \"pnpm build:ui\" first.',\n\t\t\t\t500,\n\t\t\t);\n\t\t}\n\t\treturn c.html(html);\n\t});\n\n\tapp.get('/*', (c) => {\n\t\t// SPA fallback - serve index.html for client-side routing\n\t\tconst html = getIndexHtml();\n\t\tif (!html) {\n\t\t\treturn c.text(\n\t\t\t\t'Telescope UI not available. Run \"pnpm build:ui\" first.',\n\t\t\t\t500,\n\t\t\t);\n\t\t}\n\t\treturn c.html(html);\n\t});\n\n\treturn app;\n}\n\n/**\n * Options for setupWebSocket\n */\nexport interface WebSocketOptions {\n\t/**\n\t * Enable real-time metrics broadcasting (default: true)\n\t */\n\tbroadcastMetrics?: boolean;\n\t/**\n\t * Metrics broadcast interval in milliseconds (default: 5000)\n\t */\n\tmetricsBroadcastInterval?: number;\n}\n\n/**\n * Set up WebSocket routes for real-time updates.\n * Requires @hono/node-ws for Node.js or Bun's built-in WebSocket.\n */\nexport function setupWebSocket(\n\tapp: Hono,\n\ttelescope: Telescope,\n\tupgradeWebSocket: (handler: any) => any,\n\toptions: WebSocketOptions = {},\n): void {\n\tconst { broadcastMetrics = true, metricsBroadcastInterval = 5000 } = options;\n\n\t// Start metrics broadcast if enabled\n\tif (broadcastMetrics) {\n\t\ttelescope.startMetricsBroadcast(metricsBroadcastInterval);\n\t}\n\n\tapp.get(\n\t\t'/ws',\n\t\tupgradeWebSocket(() => ({\n\t\t\tonOpen: (_event: Event, ws: WebSocket) => {\n\t\t\t\ttelescope.addWsClient(ws);\n\t\t\t},\n\t\t\tonClose: (_event: Event, ws: WebSocket) => {\n\t\t\t\ttelescope.removeWsClient(ws);\n\t\t\t},\n\t\t\tonMessage: (event: MessageEvent, ws: WebSocket) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst data = JSON.parse(event.data);\n\t\t\t\t\tif (data.type === 'ping') {\n\t\t\t\t\t\tws.send(JSON.stringify({ type: 'pong' }));\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore invalid messages\n\t\t\t\t}\n\t\t\t},\n\t\t})),\n\t);\n}\n\n/**\n * Get the Telescope context from Hono context (set by middleware)\n */\nexport function getTelescopeContext(\n\tc: Context,\n): TelescopeHonoContext | undefined {\n\treturn c.get(CONTEXT_KEY);\n}\n\n/**\n * Get the request ID from Hono context (set by middleware)\n */\nexport function getRequestId(c: Context): string | undefined {\n\treturn getTelescopeContext(c)?.requestId;\n}\n\n// Re-export types and utilities\nexport type { Telescope };\nexport type {\n\tHonoAdapterConfig,\n\tTelescopeHonoContext,\n} from '../adapters/types';\n\n/**\n * Get the flushTelemetry function (lazy-loaded to avoid requiring @opentelemetry/* at import time).\n * Use this for serverless environments where you need to flush telemetry before the process freezes.\n *\n * @example\n * ```typescript\n * const flushTelemetry = await getFlushTelemetryFn();\n * await flushTelemetry();\n * ```\n */\nexport { getFlushTelemetry as getFlushTelemetryFn };\n"],"mappings":";;;;AAWA,IAAI,kBAAgD;AACpD,eAAe,oBAAkD;CAChE,IAAI,CAAC,iBAAiB;EACrB,MAAM,EAAE,mBAAmB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,6BAAA,CAAA;EACjC,kBAAkB;CACnB;CACA,OAAO;AACR;AAEA,MAAM,cAAc;;;;AAsBpB,SAAgB,iBACf,WACA,UAAsC,CAAC,GACnB;CACpB,MAAM,EAAE,kBAAkB,UAAU;CAEpC,OAAO,OAAO,GAAY,SAAe;EACxC,IAAI,CAAC,UAAU,SACd,OAAO,KAAK;EAGb,IAAI,UAAU,aAAa,EAAE,IAAI,IAAI,GACpC,OAAO,KAAK;EAGb,MAAM,YAAY,YAAY,IAAI;EAGlC,MAAM,UAAkC,CAAC;EACzC,EAAE,IAAI,IAAI,QAAQ,SAAS,OAAO,QAAQ;GACzC,QAAQ,OAAO;EAChB,CAAC;EAED,MAAM,MAAM,IAAI,IAAI,EAAE,IAAI,GAAG;EAC7B,MAAM,QAAgC,CAAC;EACvC,IAAI,aAAa,SAAS,OAAO,QAAQ;GACxC,MAAM,OAAO;EACd,CAAC;EAED,IAAI;EACJ,IAAI;EAGJ,MAAM,gBAAgB,EAAE,IAAI,OAAO,gBAAgB;EACnD,IAAI,eACH,cAAc,SAAS,eAAe,EAAE;EAGzC,IACC,UAAU,cACV;GAAC;GAAQ;GAAO;EAAO,CAAC,CAAC,SAAS,EAAE,IAAI,MAAM,GAE9C,IAAI;GACH,MAAM,cAAc,EAAE,IAAI,OAAO,cAAc,KAAK;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EAAE,KACR,4DACA,GACD;EAED,OAAO,EAAE,KAAK,IAAI;CACnB,CAAC;CAED,IAAI,IAAI,OAAO,MAAM;EAEpB,MAAM,OAAOA,kBAAAA,aAAa;EAC1B,IAAI,CAAC,MACJ,OAAO,EAAE,KACR,4DACA,GACD;EAED,OAAO,EAAE,KAAK,IAAI;CACnB,CAAC;CAED,OAAO;AACR;;;;;AAoBA,SAAgB,eACf,KACA,WACA,kBACA,UAA4B,CAAC,GACtB;CACP,MAAM,EAAE,mBAAmB,MAAM,2BAA2B,QAAS;CAGrE,IAAI,kBACH,UAAU,sBAAsB,wBAAwB;CAGzD,IAAI,IACH,OACA,wBAAwB;EACvB,SAAS,QAAe,OAAkB;GACzC,UAAU,YAAY,EAAE;EACzB;EACA,UAAU,QAAe,OAAkB;GAC1C,UAAU,eAAe,EAAE;EAC5B;EACA,YAAY,OAAqB,OAAkB;GAClD,IAAI;IAEH,IADa,KAAK,MAAM,MAAM,IACvB,CAAC,CAAC,SAAS,QACjB,GAAG,KAAK,KAAK,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC;GAE1C,QAAQ,CAER;EACD;CACD,EAAE,CACH;AACD;;;;AAKA,SAAgB,oBACf,GACmC;CACnC,OAAO,EAAE,IAAI,WAAW;AACzB;;;;AAKA,SAAgB,aAAa,GAAgC;CAC5D,OAAO,oBAAoB,CAAC,CAAC,EAAE;AAChC"}
|
|
1
|
+
{"version":3,"file":"hono.cjs","names":["Hono"],"sources":["../../src/server/hono.ts"],"sourcesContent":["import type { Context, MiddlewareHandler, Next } from 'hono';\nimport { Hono } from 'hono';\nimport type {\n\tHonoAdapterConfig,\n\tTelescopeHonoContext,\n} from '../adapters/types';\nimport type { Telescope } from '../Telescope';\nimport type { MetricsQueryOptions, QueryOptions } from '../types';\n\n// Lazy-loaded telemetry flush function (only loads @opentelemetry/* when actually used)\nlet _flushTelemetry: (() => Promise<void>) | null = null;\nasync function getFlushTelemetry(): Promise<() => Promise<void>> {\n\tif (!_flushTelemetry) {\n\t\tconst { flushTelemetry } = await import('../instrumentation/core');\n\t\t_flushTelemetry = flushTelemetry;\n\t}\n\treturn _flushTelemetry;\n}\n\nconst CONTEXT_KEY = 'telescope-context';\n\n/** Default Hono adapter configuration */\nconst _DEFAULT_CONFIG: HonoAdapterConfig = {\n\tenvironment: 'server',\n};\n\n/**\n * Options for the Telescope Hono middleware\n */\nexport interface TelescopeMiddlewareOptions {\n\t/**\n\t * Whether to flush telemetry after each request.\n\t * Enable this for serverless environments (Lambda, Edge).\n\t * @default false\n\t */\n\tflushOnResponse?: boolean;\n}\n\n/**\n * Create Hono middleware that captures requests and responses\n */\nexport function createMiddleware(\n\ttelescope: Telescope,\n\toptions: TelescopeMiddlewareOptions = {},\n): MiddlewareHandler {\n\tconst { flushOnResponse = false } = options;\n\n\treturn async (c: Context, next: Next) => {\n\t\tif (!telescope.enabled) {\n\t\t\treturn next();\n\t\t}\n\n\t\tif (telescope.shouldIgnore(c.req.path)) {\n\t\t\treturn next();\n\t\t}\n\n\t\tconst startTime = performance.now();\n\n\t\t// Capture request data\n\t\tconst headers: Record<string, string> = {};\n\t\tc.req.raw.headers.forEach((value, key) => {\n\t\t\theaders[key] = value;\n\t\t});\n\n\t\tconst url = new URL(c.req.url);\n\t\tconst query: Record<string, string> = {};\n\t\turl.searchParams.forEach((value, key) => {\n\t\t\tquery[key] = value;\n\t\t});\n\n\t\tlet body: unknown;\n\t\tlet requestSize: number | undefined;\n\n\t\t// Get request size from Content-Length header\n\t\tconst contentLength = c.req.header('content-length');\n\t\tif (contentLength) {\n\t\t\trequestSize = parseInt(contentLength, 10);\n\t\t}\n\n\t\tif (\n\t\t\ttelescope.recordBody &&\n\t\t\t['POST', 'PUT', 'PATCH'].includes(c.req.method)\n\t\t) {\n\t\t\ttry {\n\t\t\t\tconst contentType = c.req.header('content-type') || '';\n\t\t\t\t// Clone the request to avoid consuming the body stream\n\t\t\t\tconst clonedRequest = c.req.raw.clone();\n\t\t\t\tif (contentType.includes('application/json')) {\n\t\t\t\t\tbody = await clonedRequest.json();\n\t\t\t\t} else if (contentType.includes('application/x-www-form-urlencoded')) {\n\t\t\t\t\tbody = Object.fromEntries((await clonedRequest.formData()).entries());\n\t\t\t\t} else if (contentType.includes('text/')) {\n\t\t\t\t\tbody = await clonedRequest.text();\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore body parsing errors\n\t\t\t}\n\t\t}\n\n\t\tconst ip = c.req.header('x-forwarded-for') || c.req.header('x-real-ip');\n\n\t\ttry {\n\t\t\tawait next();\n\n\t\t\t// Capture response data\n\t\t\tconst duration = performance.now() - startTime;\n\n\t\t\tconst responseHeaders: Record<string, string> = {};\n\t\t\tc.res.headers.forEach((value, key) => {\n\t\t\t\tresponseHeaders[key] = value;\n\t\t\t});\n\n\t\t\tlet responseBody: unknown;\n\t\t\tlet responseSize: number | undefined;\n\n\t\t\t// Get response size - prefer Content-Length header, fallback to body size\n\t\t\tconst responseContentLength = c.res.headers.get('content-length');\n\t\t\tif (responseContentLength) {\n\t\t\t\tresponseSize = parseInt(responseContentLength, 10);\n\t\t\t}\n\n\t\t\tif (telescope.recordBody) {\n\t\t\t\ttry {\n\t\t\t\t\tconst contentType = c.res.headers.get('content-type') || '';\n\t\t\t\t\tif (contentType.includes('application/json')) {\n\t\t\t\t\t\tconst cloned = c.res.clone();\n\t\t\t\t\t\tconst text = await cloned.text();\n\t\t\t\t\t\tresponseSize ??= Buffer.byteLength(text, 'utf8');\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresponseBody = JSON.parse(text);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tresponseBody = text;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore body parsing errors\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst requestId = await telescope.recordRequest({\n\t\t\t\tmethod: c.req.method,\n\t\t\t\tpath: c.req.path,\n\t\t\t\turl: c.req.url,\n\t\t\t\theaders,\n\t\t\t\tbody,\n\t\t\t\tquery,\n\t\t\t\tstatus: c.res.status,\n\t\t\t\tresponseHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tduration,\n\t\t\t\tip,\n\t\t\t\trequestSize,\n\t\t\t\tresponseSize,\n\t\t\t});\n\n\t\t\t// Store context for access by other middleware\n\t\t\tconst ctx: TelescopeHonoContext = {\n\t\t\t\trequestId,\n\t\t\t\tstartTime,\n\t\t\t};\n\t\t\tc.set(CONTEXT_KEY, ctx);\n\n\t\t\t// Flush telemetry for serverless environments\n\t\t\tif (flushOnResponse) {\n\t\t\t\tconst flushTelemetry = await getFlushTelemetry();\n\t\t\t\tawait flushTelemetry();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tawait telescope.exception(error as Error);\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\n/**\n * Parse query options from Hono context\n */\nfunction parseQueryOptions(c: Context): QueryOptions {\n\tconst limit = parseInt(c.req.query('limit') || '50', 10);\n\tconst offset = parseInt(c.req.query('offset') || '0', 10);\n\tconst search = c.req.query('search');\n\tconst before = c.req.query('before');\n\tconst after = c.req.query('after');\n\tconst tags = c.req.query('tags')?.split(',').filter(Boolean);\n\tconst method = c.req.query('method');\n\tconst status = c.req.query('status');\n\tconst level = c.req.query('level') as\n\t\t| 'debug'\n\t\t| 'info'\n\t\t| 'warn'\n\t\t| 'error'\n\t\t| undefined;\n\n\treturn {\n\t\tlimit: Math.min(limit, 100),\n\t\toffset,\n\t\tsearch,\n\t\tbefore: before ? new Date(before) : undefined,\n\t\tafter: after ? new Date(after) : undefined,\n\t\ttags,\n\t\tmethod: method || undefined,\n\t\tstatus: status || undefined,\n\t\tlevel: level || undefined,\n\t};\n}\n\n/**\n * Parse metrics query options from Hono context\n */\nfunction parseMetricsQueryOptions(c: Context): MetricsQueryOptions {\n\tconst start = c.req.query('start');\n\tconst end = c.req.query('end');\n\tconst bucketSize = c.req.query('bucketSize');\n\tconst limit = c.req.query('limit');\n\n\treturn {\n\t\trange:\n\t\t\tstart && end ? { start: new Date(start), end: new Date(end) } : undefined,\n\t\tbucketSize: bucketSize ? parseInt(bucketSize, 10) : undefined,\n\t\tlimit: limit ? parseInt(limit, 10) : undefined,\n\t};\n}\n\n/**\n * Telescope's JSON API: requests, exceptions, logs, stats and metrics under\n * `/api/*`. Headless — there is no dashboard; anything can be built on the\n * JSON, and live updates come from the WebSocket feed (`setupWebSocket`).\n *\n * @example\n * ```typescript\n * app.route('/__telescope', createApi(telescope));\n * // GET /__telescope/api/requests\n * ```\n */\nexport function createApi(telescope: Telescope): Hono {\n\tconst app = new Hono();\n\n\t// API routes\n\tapp.get('/api/requests', async (c) => {\n\t\tconst options = parseQueryOptions(c);\n\t\tconst requests = await telescope.getRequests(options);\n\t\treturn c.json(requests);\n\t});\n\n\tapp.get('/api/requests/:id', async (c) => {\n\t\tconst request = await telescope.getRequest(c.req.param('id'));\n\t\tif (!request) {\n\t\t\treturn c.json({ error: 'Request not found' }, 404);\n\t\t}\n\t\treturn c.json(request);\n\t});\n\n\tapp.get('/api/exceptions', async (c) => {\n\t\tconst options = parseQueryOptions(c);\n\t\tconst exceptions = await telescope.getExceptions(options);\n\t\treturn c.json(exceptions);\n\t});\n\n\tapp.get('/api/exceptions/:id', async (c) => {\n\t\tconst exception = await telescope.getException(c.req.param('id'));\n\t\tif (!exception) {\n\t\t\treturn c.json({ error: 'Exception not found' }, 404);\n\t\t}\n\t\treturn c.json(exception);\n\t});\n\n\tapp.get('/api/logs', async (c) => {\n\t\tconst options = parseQueryOptions(c);\n\t\tconst logs = await telescope.getLogs(options);\n\t\treturn c.json(logs);\n\t});\n\n\tapp.get('/api/stats', async (c) => {\n\t\tconst stats = await telescope.getStats();\n\t\treturn c.json(stats);\n\t});\n\n\t// Metrics API\n\tapp.get('/api/metrics', (c) => {\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst metrics = telescope.getMetrics(options);\n\t\treturn c.json(metrics);\n\t});\n\n\tapp.get('/api/metrics/endpoints', (c) => {\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst endpoints = telescope.getEndpointMetrics(options);\n\t\treturn c.json(endpoints);\n\t});\n\n\t// Endpoint details - method and path are query params to avoid URL encoding issues\n\tapp.get('/api/metrics/endpoint', (c) => {\n\t\tconst method = c.req.query('method');\n\t\tconst path = c.req.query('path');\n\n\t\tif (!method || !path) {\n\t\t\treturn c.json({ error: 'method and path are required' }, 400);\n\t\t}\n\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst details = telescope.getEndpointDetails(method, path, options);\n\n\t\tif (!details) {\n\t\t\treturn c.json({ error: 'Endpoint not found' }, 404);\n\t\t}\n\n\t\treturn c.json(details);\n\t});\n\n\tapp.get('/api/metrics/status', (c) => {\n\t\tconst options = parseMetricsQueryOptions(c);\n\t\tconst distribution = telescope.getStatusDistribution(options);\n\t\treturn c.json(distribution);\n\t});\n\n\tapp.delete('/api/metrics', (c) => {\n\t\ttelescope.resetMetrics();\n\t\treturn c.json({ success: true });\n\t});\n\n\treturn app;\n}\n\n/**\n * Options for setupWebSocket\n */\nexport interface WebSocketOptions {\n\t/**\n\t * Enable real-time metrics broadcasting (default: true)\n\t */\n\tbroadcastMetrics?: boolean;\n\t/**\n\t * Metrics broadcast interval in milliseconds (default: 5000)\n\t */\n\tmetricsBroadcastInterval?: number;\n}\n\n/**\n * Set up WebSocket routes for real-time updates.\n * Requires @hono/node-ws for Node.js or Bun's built-in WebSocket.\n */\nexport function setupWebSocket(\n\tapp: Hono,\n\ttelescope: Telescope,\n\tupgradeWebSocket: (handler: any) => any,\n\toptions: WebSocketOptions = {},\n): void {\n\tconst { broadcastMetrics = true, metricsBroadcastInterval = 5000 } = options;\n\n\t// Start metrics broadcast if enabled\n\tif (broadcastMetrics) {\n\t\ttelescope.startMetricsBroadcast(metricsBroadcastInterval);\n\t}\n\n\tapp.get(\n\t\t'/ws',\n\t\tupgradeWebSocket(() => ({\n\t\t\tonOpen: (_event: Event, ws: WebSocket) => {\n\t\t\t\ttelescope.addWsClient(ws);\n\t\t\t},\n\t\t\tonClose: (_event: Event, ws: WebSocket) => {\n\t\t\t\ttelescope.removeWsClient(ws);\n\t\t\t},\n\t\t\tonMessage: (event: MessageEvent, ws: WebSocket) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst data = JSON.parse(event.data);\n\t\t\t\t\tif (data.type === 'ping') {\n\t\t\t\t\t\tws.send(JSON.stringify({ type: 'pong' }));\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore invalid messages\n\t\t\t\t}\n\t\t\t},\n\t\t})),\n\t);\n}\n\n/**\n * Get the Telescope context from Hono context (set by middleware)\n */\nexport function getTelescopeContext(\n\tc: Context,\n): TelescopeHonoContext | undefined {\n\treturn c.get(CONTEXT_KEY);\n}\n\n/**\n * Get the request ID from Hono context (set by middleware)\n */\nexport function getRequestId(c: Context): string | undefined {\n\treturn getTelescopeContext(c)?.requestId;\n}\n\n// Re-export types and utilities\nexport type { Telescope };\nexport type {\n\tHonoAdapterConfig,\n\tTelescopeHonoContext,\n} from '../adapters/types';\n\n/**\n * Get the flushTelemetry function (lazy-loaded to avoid requiring @opentelemetry/* at import time).\n * Use this for serverless environments where you need to flush telemetry before the process freezes.\n *\n * @example\n * ```typescript\n * const flushTelemetry = await getFlushTelemetryFn();\n * await flushTelemetry();\n * ```\n */\nexport { getFlushTelemetry as getFlushTelemetryFn };\n"],"mappings":";;;AAUA,IAAI,kBAAgD;AACpD,eAAe,oBAAkD;CAChE,IAAI,CAAC,iBAAiB;EACrB,MAAM,EAAE,mBAAmB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,6BAAA,CAAA;EACjC,kBAAkB;CACnB;CACA,OAAO;AACR;AAEA,MAAM,cAAc;;;;AAsBpB,SAAgB,iBACf,WACA,UAAsC,CAAC,GACnB;CACpB,MAAM,EAAE,kBAAkB,UAAU;CAEpC,OAAO,OAAO,GAAY,SAAe;EACxC,IAAI,CAAC,UAAU,SAC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ACtB,CAAC;CAED,IAAI,IAAI,wBAAwB,MAAM;EACrC,MAAM,UAAU,yBAAyB,CAAC;EAC1C,MAAM,eAAe,UAAU,sBAAsB,OAAO;EAC5D,OAAO,EAAE,KAAK,YAAY;CAC3B,CAAC;CAED,IAAI,OAAO,iBAAiB,MAAM;EACjC,UAAU,aAAa;EACvB,OAAO,EAAE,KAAK,EAAE,SAAS,KAAK,CAAC;CAChC,CAAC;CAED,OAAO;AACR;;;;;AAoBA,SAAgB,eACf,KACA,WACA,kBACA,UAA4B,CAAC,GACtB;CACP,MAAM,EAAE,mBAAmB,MAAM,2BAA2B,QAAS;CAGrE,IAAI,kBACH,UAAU,sBAAsB,wBAAwB;CAGzD,IAAI,IACH,OACA,wBAAwB;EACvB,SAAS,QAAe,OAAkB;GACzC,UAAU,YAAY,EAAE;EACzB;EACA,UAAU,QAAe,OAAkB;GAC1C,UAAU,eAAe,EAAE;EAC5B;EACA,YAAY,OAAqB,OAAkB;GAClD,IAAI;IAEH,IADa,KAAK,MAAM,MAAM,IACvB,CAAC,CAAC,SAAS,QACjB,GAAG,KAAK,KAAK,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC;GAE1C,QAAQ,CAER;EACD;CACD,EAAE,CACH;AACD;;;;AAKA,SAAgB,oBACf,GACmC;CACnC,OAAO,EAAE,IAAI,WAAW;AACzB;;;;AAKA,SAAgB,aAAa,GAAgC;CAC5D,OAAO,oBAAoB,CAAC,CAAC,EAAE;AAChC"}
|
package/dist/server/hono.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-DeqSHfuB.cjs";
|
|
2
2
|
import { HonoAdapterConfig, TelescopeHonoContext } from "../adapters/types.cjs";
|
|
3
3
|
import { Context, Hono, MiddlewareHandler } from "hono";
|
|
4
4
|
//#region src/server/hono.d.ts
|
|
@@ -19,9 +19,17 @@ export interface TelescopeMiddlewareOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function createMiddleware(telescope: Telescope, options?: TelescopeMiddlewareOptions): MiddlewareHandler;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Telescope's JSON API: requests, exceptions, logs, stats and metrics under
|
|
23
|
+
* `/api/*`. Headless — there is no dashboard; anything can be built on the
|
|
24
|
+
* JSON, and live updates come from the WebSocket feed (`setupWebSocket`).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* app.route('/__telescope', createApi(telescope));
|
|
29
|
+
* // GET /__telescope/api/requests
|
|
30
|
+
* ```
|
|
23
31
|
*/
|
|
24
|
-
export declare function
|
|
32
|
+
export declare function createApi(telescope: Telescope): Hono;
|
|
25
33
|
/**
|
|
26
34
|
* Options for setupWebSocket
|
|
27
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.cts","names":[],"sources":["../../src/server/hono.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"hono.d.cts","names":[],"sources":["../../src/server/hono.ts"],"mappings":";;;;iBAWe,qBAAqB,cAAc;;;;iBAkBjC;;;;;;EAMhB;;;;;wBAMe,iBACf,WAAW,WACX,UAAS,6BACP;;;;;;;;;;;;wBA8La,UAAU,WAAW,YAAY;;;;iBA4FhC;;;;EAIhB;;;;EAIA;;;;;;wBAOe,eACf,KAAK,MACL,WAAW,WACX,mBAAmB,sBACnB,UAAS;;;;wBAmCM,oBACf,GAAG,UACD;;;;wBAOa,aAAa,GAAG"}
|
package/dist/server/hono.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Telescope } from "../Telescope-
|
|
1
|
+
import { t as Telescope } from "../Telescope-BVfDvVvY.mjs";
|
|
2
2
|
import { HonoAdapterConfig, TelescopeHonoContext } from "../adapters/types.mjs";
|
|
3
3
|
import { Context, Hono, MiddlewareHandler } from "hono";
|
|
4
4
|
//#region src/server/hono.d.ts
|
|
@@ -19,9 +19,17 @@ export interface TelescopeMiddlewareOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function createMiddleware(telescope: Telescope, options?: TelescopeMiddlewareOptions): MiddlewareHandler;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Telescope's JSON API: requests, exceptions, logs, stats and metrics under
|
|
23
|
+
* `/api/*`. Headless — there is no dashboard; anything can be built on the
|
|
24
|
+
* JSON, and live updates come from the WebSocket feed (`setupWebSocket`).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* app.route('/__telescope', createApi(telescope));
|
|
29
|
+
* // GET /__telescope/api/requests
|
|
30
|
+
* ```
|
|
23
31
|
*/
|
|
24
|
-
export declare function
|
|
32
|
+
export declare function createApi(telescope: Telescope): Hono;
|
|
25
33
|
/**
|
|
26
34
|
* Options for setupWebSocket
|
|
27
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.mts","names":[],"sources":["../../src/server/hono.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"hono.d.mts","names":[],"sources":["../../src/server/hono.ts"],"mappings":";;;;iBAWe,qBAAqB,cAAc;;;;iBAkBjC;;;;;;EAMhB;;;;;wBAMe,iBACf,WAAW,WACX,UAAS,6BACP;;;;;;;;;;;;wBA8La,UAAU,WAAW,YAAY;;;;iBA4FhC;;;;EAIhB;;;;EAIA;;;;;;wBAOe,eACf,KAAK,MACL,WAAW,WACX,mBAAmB,sBACnB,UAAS;;;;wBAmCM,oBACf,GAAG,UACD;;;;wBAOa,aAAa,GAAG"}
|