reroute-js 0.45.3 → 0.45.5
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/cli/bin.d.ts +1 -1
- package/cli/bin.js +150 -63
- package/cli/bin.js.map +6 -6
- package/cli/index.d.ts +1 -1
- package/cli/index.js +4 -4
- package/cli/index.js.map +1 -1
- package/cli/src/cli.d.ts +1 -1
- package/cli/src/commands/analyze.d.ts +1 -1
- package/cli/src/commands/build.d.ts +1 -1
- package/cli/src/commands/dev.d.ts +1 -1
- package/cli/src/commands/dev.d.ts.map +1 -1
- package/cli/src/commands/gen.d.ts +1 -1
- package/cli/src/commands/index.d.ts +1 -1
- package/cli/src/commands/init.d.ts +1 -1
- package/cli/src/commands/lib/assets.d.ts +1 -1
- package/cli/src/commands/lib/bundler.d.ts +1 -1
- package/cli/src/commands/lib/command.d.ts +1 -1
- package/cli/src/commands/lib/env.d.ts +1 -1
- package/cli/src/commands/lib/index.d.ts +1 -1
- package/cli/src/commands/lib/log.d.ts +1 -1
- package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
- package/cli/src/commands/lib/markdown/index.d.ts +1 -1
- package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
- package/cli/src/commands/lib/production.d.ts +1 -1
- package/cli/src/commands/lib/server.d.ts +1 -1
- package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
- package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
- package/cli/src/commands/lib/tailwind.d.ts +1 -1
- package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
- package/cli/src/commands/lib/version.d.ts +1 -1
- package/cli/src/commands/og.d.ts +1 -1
- package/cli/src/commands/start.d.ts +1 -1
- package/cli/src/commands/start.d.ts.map +1 -1
- package/cli/src/index.d.ts +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +76 -21
- package/core/index.js.map +4 -4
- package/core/src/bundler/hash.d.ts +1 -1
- package/core/src/bundler/index.d.ts +1 -1
- package/core/src/config.d.ts +1 -1
- package/core/src/content/discovery.d.ts +1 -1
- package/core/src/content/index.d.ts +1 -1
- package/core/src/content/metadata.d.ts +1 -1
- package/core/src/index.d.ts +1 -1
- package/core/src/llms/extractor.d.ts +1 -1
- package/core/src/llms/formatter.d.ts +1 -1
- package/core/src/llms/full-generator.d.ts +1 -1
- package/core/src/llms/index-generator.d.ts +1 -1
- package/core/src/llms/index.d.ts +1 -1
- package/core/src/og/discovery.d.ts +1 -1
- package/core/src/og/index.d.ts +1 -1
- package/core/src/og/meta.d.ts +1 -1
- package/core/src/og/render.d.ts +1 -1
- package/core/src/og/types.d.ts +1 -1
- package/core/src/robots/discovery.d.ts +1 -1
- package/core/src/robots/generator.d.ts +1 -1
- package/core/src/robots/index.d.ts +1 -1
- package/core/src/robots/policies.d.ts +1 -1
- package/core/src/rss/discovery.d.ts +1 -1
- package/core/src/rss/generator.d.ts +1 -1
- package/core/src/rss/index.d.ts +1 -1
- package/core/src/sitemap/discovery.d.ts +1 -1
- package/core/src/sitemap/generator.d.ts +1 -1
- package/core/src/sitemap/index.d.ts +1 -1
- package/core/src/ssr/index.d.ts +1 -1
- package/core/src/ssr/lib/cache.d.ts +22 -2
- package/core/src/ssr/lib/cache.d.ts.map +1 -1
- package/core/src/ssr/lib/collections.d.ts +1 -1
- package/core/src/ssr/lib/compression.d.ts +1 -1
- package/core/src/ssr/lib/compute/content.d.ts +1 -1
- package/core/src/ssr/lib/compute/index.d.ts +1 -1
- package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
- package/core/src/ssr/lib/compute/routes.d.ts +1 -1
- package/core/src/ssr/lib/data.d.ts +1 -1
- package/core/src/ssr/lib/html.d.ts +1 -1
- package/core/src/ssr/lib/imports.d.ts +1 -1
- package/core/src/ssr/lib/index.d.ts +1 -1
- package/core/src/ssr/lib/layouts.d.ts +1 -1
- package/core/src/ssr/lib/metadata.d.ts +1 -1
- package/core/src/ssr/lib/mime.d.ts +1 -1
- package/core/src/ssr/lib/modules.d.ts +1 -1
- package/core/src/ssr/lib/path.d.ts +1 -1
- package/core/src/ssr/lib/preload.d.ts +1 -1
- package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
- package/core/src/ssr/lib/scripts/data.d.ts +1 -1
- package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
- package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
- package/core/src/ssr/lib/scripts/index.d.ts +1 -1
- package/core/src/ssr/lib/seed.d.ts +1 -1
- package/core/src/ssr/lib/serialize.d.ts +1 -1
- package/core/src/ssr/lib/setup.d.ts +1 -1
- package/core/src/ssr/lib/styles.d.ts +1 -1
- package/core/src/ssr/lib/template.d.ts +1 -1
- package/core/src/ssr/lib/types.d.ts +1 -1
- package/core/src/ssr/render.d.ts +1 -1
- package/core/src/ssr/stream.d.ts +1 -1
- package/elysia/index.d.ts +1 -1
- package/elysia/index.js +180 -86
- package/elysia/index.js.map +6 -6
- package/elysia/src/index.d.ts +1 -1
- package/elysia/src/libs/assets.d.ts +1 -1
- package/elysia/src/libs/cache.d.ts +1 -1
- package/elysia/src/libs/caching.d.ts +1 -1
- package/elysia/src/libs/http.d.ts +1 -1
- package/elysia/src/libs/image.d.ts +1 -1
- package/elysia/src/libs/index.d.ts +1 -1
- package/elysia/src/libs/llms.d.ts +1 -1
- package/elysia/src/libs/response.d.ts +1 -1
- package/elysia/src/libs/serving.d.ts +1 -1
- package/elysia/src/plugin.d.ts +1 -1
- package/elysia/src/plugin.d.ts.map +1 -1
- package/elysia/src/routes/artifacts.d.ts +1 -1
- package/elysia/src/routes/content.d.ts +1 -1
- package/elysia/src/routes/image.d.ts +1 -1
- package/elysia/src/routes/index.d.ts +1 -1
- package/elysia/src/routes/internal.d.ts +1 -1
- package/elysia/src/routes/llms.d.ts +1 -1
- package/elysia/src/routes/og.d.ts +1 -1
- package/elysia/src/routes/og.d.ts.map +1 -1
- package/elysia/src/routes/redirects.d.ts +1 -1
- package/elysia/src/routes/robots.d.ts +1 -1
- package/elysia/src/routes/rss.d.ts +1 -1
- package/elysia/src/routes/search.d.ts +1 -1
- package/elysia/src/routes/sitemap.d.ts +1 -1
- package/elysia/src/routes/ssr.d.ts +1 -1
- package/elysia/src/routes/static.d.ts +1 -1
- package/elysia/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.js +2 -2
- package/react/index.js.map +1 -1
- package/react/src/components/ClientOnly.d.ts +1 -1
- package/react/src/components/ContentRoute.d.ts +1 -1
- package/react/src/components/Image.d.ts +1 -1
- package/react/src/components/LazyRoute.d.ts +1 -1
- package/react/src/components/Link.d.ts +1 -1
- package/react/src/components/Markdown.d.ts +1 -1
- package/react/src/components/Outlet.d.ts +1 -1
- package/react/src/components/index.d.ts +1 -1
- package/react/src/hooks/index.d.ts +1 -1
- package/react/src/hooks/useContent.d.ts +1 -1
- package/react/src/hooks/useData.d.ts +1 -1
- package/react/src/hooks/useFeed.d.ts +1 -1
- package/react/src/hooks/useLayoutData.d.ts +1 -1
- package/react/src/hooks/useLlms.d.ts +1 -1
- package/react/src/hooks/useNavigate.d.ts +1 -1
- package/react/src/hooks/useParams.d.ts +1 -1
- package/react/src/hooks/useRouter.d.ts +1 -1
- package/react/src/hooks/useSearch.d.ts +1 -1
- package/react/src/hooks/useSearchParams.d.ts +1 -1
- package/react/src/hooks/useToc.d.ts +1 -1
- package/react/src/index.d.ts +1 -1
- package/react/src/lib/collection.d.ts +1 -1
- package/react/src/lib/content.d.ts +1 -1
- package/react/src/lib/head.d.ts +1 -1
- package/react/src/lib/index.d.ts +1 -1
- package/react/src/lib/lazy-route.d.ts +1 -1
- package/react/src/lib/route-loader.d.ts +1 -1
- package/react/src/providers/ContentProvider.d.ts +1 -1
- package/react/src/providers/RerouteProvider.d.ts +1 -1
- package/react/src/providers/RouterProvider.d.ts +1 -1
- package/react/src/providers/index.d.ts +1 -1
- package/react/src/types/any.d.ts +1 -1
- package/react/src/types/index.d.ts +1 -1
- package/react/src/types/router.d.ts +1 -1
- package/telemetry/react.d.ts +1 -1
- package/telemetry/react.js +2 -17
- package/telemetry/react.js.map +2 -2
- package/telemetry/server.d.ts +1 -1
- package/telemetry/server.js +102 -18
- package/telemetry/server.js.map +4 -4
- package/telemetry/src/react/api.d.ts +1 -1
- package/telemetry/src/react/context.d.ts +1 -1
- package/telemetry/src/react/index.d.ts +1 -1
- package/telemetry/src/react/telemetry.d.ts +1 -1
- package/telemetry/src/server/context.d.ts +1 -1
- package/telemetry/src/server/headers/extractor.d.ts +1 -1
- package/telemetry/src/server/headers/index.d.ts +1 -1
- package/telemetry/src/server/headers/presets.d.ts +1 -1
- package/telemetry/src/server/index.d.ts +1 -1
- package/telemetry/src/server/instrumentation.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts +1 -1
- package/telemetry/src/server/plugin.d.ts.map +1 -1
- package/telemetry/src/server/sourcemap.d.ts +1 -1
package/telemetry/server.js.map
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"/**\n * Telemetry utilities for instrumenting operations\n *\n * This module provides helpers to create spans for custom instrumentation:\n * - API endpoints\n * - Database queries\n * - External service calls\n * - Business logic operations\n */\n\nimport { context, type Span, SpanStatusCode, trace } from '@opentelemetry/api';\n\n// Check if OpenTelemetry is available (lazy loaded to avoid requiring it)\nlet otelAvailable: boolean | undefined;\n\nfunction isOtelAvailable(): boolean {\n\tif (otelAvailable !== undefined) return otelAvailable;\n\n\ttry {\n\t\t// Check if @opentelemetry/api is available\n\t\trequire('@opentelemetry/api');\n\t\totelAvailable = true;\n\t\treturn true;\n\t} catch {\n\t\totelAvailable = false;\n\t\treturn false;\n\t}\n}\n\n/**\n * No-op span implementation when OpenTelemetry is not available\n * Implements the Span interface but all methods do nothing\n */\nclass NoopSpan implements Span {\n\tspanContext() {\n\t\treturn {\n\t\t\ttraceId: '',\n\t\t\tspanId: '',\n\t\t\ttraceFlags: 0,\n\t\t};\n\t}\n\tsetAttribute() {\n\t\treturn this;\n\t}\n\tsetAttributes() {\n\t\treturn this;\n\t}\n\taddEvent() {\n\t\treturn this;\n\t}\n\taddLink() {\n\t\treturn this;\n\t}\n\taddLinks() {\n\t\treturn this;\n\t}\n\tsetStatus() {\n\t\treturn this;\n\t}\n\tupdateName() {\n\t\treturn this;\n\t}\n\tend() {}\n\tisRecording() {\n\t\treturn false;\n\t}\n\trecordException() {}\n}\n\n// Singleton instance\nconst noopSpan = new NoopSpan();\n\n/**\n * Execute a function within a named span for distributed tracing\n *\n * @example\n * ```ts\n * const result = await withSpan('database.query', async (span) => {\n * span.setAttribute('query', 'SELECT * FROM users');\n * return await db.query('SELECT * FROM users');\n * });\n * ```\n */\nexport async function withSpan<T>(\n\tname: string,\n\tfn: (span: Span) => Promise<T>,\n\tattributes?: Record<string, string | number | boolean>,\n): Promise<T> {\n\tif (!isOtelAvailable()) {\n\t\treturn fn(noopSpan);\n\t}\n\n\tconst tracer = trace.getTracer('reroute');\n\treturn tracer.startActiveSpan(name, { attributes }, async (span) => {\n\t\ttry {\n\t\t\tconst result = await fn(span);\n\t\t\tspan.end();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tspan.recordException(error as Error);\n\t\t\tspan.setStatus({\n\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t\tspan.end();\n\t\t\tthrow error;\n\t\t}\n\t});\n}\n\n/**\n * Execute a synchronous function within a named span\n */\nexport function withSpanSync<T>(\n\tname: string,\n\tfn: (span: Span) => T,\n\tattributes?: Record<string, string | number | boolean>,\n): T {\n\tif (!isOtelAvailable()) {\n\t\treturn fn(noopSpan);\n\t}\n\n\tconst tracer = trace.getTracer('reroute');\n\treturn tracer.startActiveSpan(name, { attributes }, (span) => {\n\t\ttry {\n\t\t\tconst result = fn(span);\n\t\t\tspan.end();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tspan.recordException(error as Error);\n\t\t\tspan.setStatus({\n\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t\tspan.end();\n\t\t\tthrow error;\n\t\t}\n\t});\n}\n\n/**\n * Add attributes to the current active span (if available)\n */\nexport function setSpanAttributes(\n\tattributes: Record<string, string | number | boolean>,\n) {\n\tif (!isOtelAvailable()) return;\n\n\tconst span = trace.getActiveSpan();\n\tif (span) {\n\t\tspan.setAttributes(attributes);\n\t}\n}\n\n/**\n * Record an event in the current active span\n */\nexport function addSpanEvent(\n\tname: string,\n\tattributes?: Record<string, string | number | boolean>,\n) {\n\tif (!isOtelAvailable()) return;\n\n\tconst span = trace.getActiveSpan();\n\tif (span) {\n\t\tspan.addEvent(name, attributes);\n\t}\n}\n\n/**\n * Execute a function within the context of a parent span\n * This ensures child spans created inside the function are properly nested\n *\n * @example\n * ```ts\n * const parentSpan = store.telemetrySpan;\n * await withParentSpan(parentSpan, async () => {\n * // Any spans created here will be children of parentSpan\n * await withSpan('child.operation', async () => {...});\n * });\n * ```\n */\nexport async function withParentSpan<T>(\n\tparentSpan: Span | undefined | null,\n\tfn: () => Promise<T>,\n): Promise<T> {\n\tif (!(isOtelAvailable() && parentSpan)) {\n\t\treturn fn();\n\t}\n\n\t// Set the parent span as active in the context\n\tconst ctx = trace.setSpan(context.active(), parentSpan);\n\treturn context.with(ctx, fn);\n}\n\n/**\n * Execute a synchronous function within the context of a parent span\n */\nexport function withParentSpanSync<T>(\n\tparentSpan: Span | undefined | null,\n\tfn: () => T,\n): T {\n\tif (!(isOtelAvailable() && parentSpan)) {\n\t\treturn fn();\n\t}\n\n\tconst ctx = trace.setSpan(context.active(), parentSpan);\n\treturn context.with(ctx, fn);\n}\n\n/**\n * Extract W3C Trace Context from incoming HTTP request headers\n * Returns the extracted context or undefined if not available\n *\n * @example\n * ```ts\n * const traceContext = extractTraceContext(request.headers);\n * ```\n */\nexport function extractTraceContext(\n\theaders: Headers | Record<string, string | undefined>,\n): ReturnType<typeof context.active> | undefined {\n\tif (!isOtelAvailable()) return undefined;\n\n\ttry {\n\t\tconst { propagation } = require('@opentelemetry/api');\n\n\t\t// Create a carrier object that matches the W3C Trace Context format\n\t\tconst carrier: Record<string, string | undefined> = {};\n\n\t\tif (headers instanceof Headers) {\n\t\t\tcarrier.traceparent = headers.get('traceparent') || undefined;\n\t\t\tcarrier.tracestate = headers.get('tracestate') || undefined;\n\t\t} else {\n\t\t\tcarrier.traceparent = headers.traceparent;\n\t\t\tcarrier.tracestate = headers.tracestate;\n\t\t}\n\n\t\t// If no traceparent header, return undefined\n\t\tif (!carrier.traceparent) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Extract context from carrier\n\t\treturn propagation.extract(context.active(), carrier);\n\t} catch (error) {\n\t\tconsole.error('[telemetry] Failed to extract trace context:', error);\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Get the trace context from a span for injection into browser\n * Returns an object with traceparent and tracestate (if available)\n *\n * @example\n * ```ts\n * const span = store.telemetrySpan;\n * const traceContext = getTraceContextForInjection(span);\n * // Inject into HTML: <script>window.__TRACE_CONTEXT__ = {...traceContext};</script>\n * ```\n */\nexport function getTraceContextForInjection(\n\tspan: Span | undefined | null,\n): { traceparent?: string; tracestate?: string } | undefined {\n\tif (!(isOtelAvailable() && span)) return undefined;\n\n\ttry {\n\t\tconst { propagation } = require('@opentelemetry/api');\n\t\tconst carrier: Record<string, string | undefined> = {};\n\n\t\t// Set the span as active and inject context\n\t\tconst ctx = trace.setSpan(context.active(), span);\n\t\tpropagation.inject(ctx, carrier);\n\n\t\treturn {\n\t\t\ttraceparent: carrier.traceparent,\n\t\t\ttracestate: carrier.tracestate,\n\t\t};\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t'[telemetry] Failed to get trace context for injection:',\n\t\t\terror,\n\t\t);\n\t\treturn undefined;\n\t}\n}\n",
|
|
10
10
|
"import { pathToFileURL } from 'node:url';\nimport type { ComponentType } from 'react';\n\n// biome-ignore lint/suspicious/noExplicitAny: The user document\ntype Doc = any;\ninterface StreamingOptions {\n\tenabled?: boolean;\n\tdefaultSkeleton?: ComponentType | string;\n\tdefaultLayoutSkeleton?: ComponentType | string;\n\ttimeout?: number;\n}\n\ninterface StaticOptions {\n\t/**\n\t * Patterns to ignore when serving static files\n\t * @default ['.DS_Store', '.git', '.env']\n\t */\n\tignorePatterns?: (string | RegExp)[];\n\t/**\n\t * Custom headers to add to static file responses\n\t */\n\theaders?: Record<string, string>;\n\t/**\n\t * Cache duration in seconds for static assets\n\t * @default 3600 (1 hour)\n\t */\n\tmaxAge?: number;\n\t/**\n\t * Cache-Control directive\n\t * @default 'public'\n\t */\n\tdirective?: string;\n}\n\ninterface ImageOptions {\n\t/**\n\t * Cache duration in seconds for optimized images\n\t * @default 31536000 (1 year)\n\t */\n\tmaxAge?: number;\n\t/**\n\t * Allowed external domains for image optimization\n\t * @default []\n\t */\n\tallowedDomains?: string[];\n\t/**\n\t * Maximum image width in pixels\n\t * @default 3840\n\t */\n\tmaxWidth?: number;\n\t/**\n\t * Maximum image height in pixels\n\t * @default 2160\n\t */\n\tmaxHeight?: number;\n}\n\n/**\n * Sitemap configuration options\n */\ninterface SitemapOptions {\n\t/** Enable sitemap generation (default: false) */\n\tenabled?: boolean;\n\n\t/** Base URL for sitemap generation (e.g., 'https://example.com') - required when enabled */\n\tbaseUrl?: string;\n\n\t/**\n\t * Maximum URLs per sitemap file before pagination (default: 50000)\n\t * When exceeded, creates multiple sitemap files with a sitemap index\n\t * Set lower for testing (e.g., 10) to verify pagination works\n\t */\n\tmaxUrlsPerPage?: number;\n\n\t/**\n\t * Completely exclude specific routes from the sitemap\n\t * Routes listed here will not appear in the sitemap at all\n\t * @example ['/admin', '/api']\n\t */\n\texcludeRoutes?: string[];\n\n\t/**\n\t * Exclude specific routes from SSR data array discovery\n\t * Routes listed here will still appear in the sitemap as single entries,\n\t * but won't generate multiple URLs from arrays found in their SSR data\n\t * @example ['/download', '/pricing'] - these routes appear once, not per array item\n\t */\n\texcludeDiscovery?: string[];\n\n\t/**\n\t * Extract urls from ssr.data result (full control over data shape)\n\t * If provided, this takes precedence over automatic array discovery\n\t * @param data - Full ssr.data result\n\t * @param routePattern - The route pattern (e.g., '/changelog')\n\t * @returns Array of items to process, or null/undefined to skip this route\n\t */\n\textractUrls?: (data: Doc, routePattern: string) => Doc[] | null | undefined;\n\n\t/**\n\t * Extract URL segment from ssr.data items\n\t * @param item - Data item from ssr.data result\n\t * @param routePattern - The route pattern (e.g., '/changelog')\n\t * @returns URL segment to append to routePattern (e.g., '0.1.0' -> '/changelog/0.1.0'),\n\t * null/undefined to use default extraction, or false to skip this item entirely\n\t */\n\textractUrl?: (\n\t\titem: Doc,\n\t\troutePattern: string,\n\t) => string | null | undefined | false;\n\n\t/**\n\t * Extract lastmod date from ssr.data items\n\t * @param item - Data item from ssr.data result\n\t * @returns ISO date string or undefined\n\t */\n\textractLastmod?: (item: Doc) => string | undefined;\n\n\t/** Default changefreq for URLs */\n\tchangefreq?:\n\t\t| 'always'\n\t\t| 'hourly'\n\t\t| 'daily'\n\t\t| 'weekly'\n\t\t| 'monthly'\n\t\t| 'yearly'\n\t\t| 'never';\n\n\t/** Default priority for URLs */\n\tpriority?: number;\n}\n\n/**\n * RSS feed configuration options\n */\ninterface RSSOptions {\n\t/** Enable RSS feed generation (default: false) */\n\tenabled?: boolean;\n\n\t/** Base URL for RSS feeds (e.g., 'https://example.com') - required when enabled */\n\tbaseUrl?: string;\n\n\t/** Feed title (e.g., 'My Blog') */\n\ttitle?: string;\n\n\t/** Feed description */\n\tdescription?: string;\n\n\t/** Maximum number of items per feed (default: 50) */\n\tlimit?: number;\n\n\t/** Feed format: 'rss' or 'atom' (default: 'rss') */\n\tformat?: 'rss' | 'atom';\n\n\t/**\n\t * Completely exclude specific routes from the RSS feed\n\t * Routes listed here will not appear in the feed at all\n\t * @example ['/admin', '/api']\n\t */\n\texcludeRoutes?: string[];\n\n\t/**\n\t * Exclude specific routes from SSR data array discovery\n\t * Routes listed here won't generate multiple feed items from arrays in their SSR data,\n\t * but may still generate a single feed item if appropriate\n\t * @example ['/download', '/pricing'] - won't generate items per array entry\n\t */\n\texcludeDiscovery?: string[];\n\n\t/**\n\t * Extract items from ssr.data result (full control over data shape)\n\t * If provided, this takes precedence over automatic array discovery\n\t * @param data - Full ssr.data result\n\t * @param routePattern - The route pattern (e.g., '/changelog')\n\t * @returns Array of items to process, or null/undefined to skip this route\n\t */\n\textractUrls?: (data: Doc, routePattern: string) => Doc[] | null | undefined;\n\n\t/**\n\t * Extract URL segment from ssr.data items (same as sitemap)\n\t * @returns URL segment, null/undefined for default extraction, or false to skip item\n\t */\n\textractUrl?: (\n\t\titem: Doc,\n\t\troutePattern: string,\n\t) => string | null | undefined | false;\n\n\t/**\n\t * Extract publication date from items\n\t */\n\textractPubDate?: (item: Doc) => string | undefined;\n\n\t/**\n\t * Extract author from items\n\t */\n\textractAuthor?: (item: Doc) => string | undefined;\n\n\t/**\n\t * Extract content/body from items\n\t */\n\textractContent?: (item: Doc) => string | undefined;\n\n\t/**\n\t * Extract description/summary from items\n\t * Falls back to item.description or item.excerpt if not provided\n\t */\n\textractDescription?: (item: Doc) => string | undefined;\n}\n\n/**\n * Markdown configuration options\n */\ninterface MarkdownOptions {\n\t/**\n\t * Custom components to use when rendering markdown\n\t * Path to a module that exports a components object compatible with Streamdown\n\t * @example './src/client/lib/markdown-components'\n\t */\n\tcomponents?: string;\n\n\t/** Enable GitHub Flavored Markdown (default: true if remark-gfm is installed) */\n\tenableGfm?: boolean;\n\n\t/** Shiki theme for syntax highlighting (default: 'github-dark') */\n\ttheme?: string;\n}\n\n/**\n * Search index configuration options\n */\ninterface SearchOptions {\n\t/** Enable search index generation (default: false) */\n\tenabled?: boolean;\n\n\t/**\n\t * Collections to include in search index\n\t * @default [] - all collections will be indexed\n\t * @example ['blog', 'docs']\n\t */\n\tcollections?: string[];\n\n\t/**\n\t * Include full content text in search (increases index size significantly)\n\t * @default false - only index headings and metadata\n\t */\n\tincludeContent?: boolean;\n\n\t/**\n\t * Maximum content length to index per item (characters)\n\t * @default 5000 - prevents huge content from bloating index\n\t */\n\tcontentLimit?: number;\n\n\t/**\n\t * Fields to index from frontmatter metadata\n\t * @default ['title', 'description', 'excerpt', 'tags']\n\t */\n\tmetaFields?: string[];\n\n\t/**\n\t * Minimum heading level to index (1-6)\n\t * @default 1 - index all headings\n\t */\n\tminHeadingLevel?: number;\n\n\t/**\n\t * Maximum heading level to index (1-6)\n\t * @default 6 - index all headings\n\t */\n\tmaxHeadingLevel?: number;\n\n\t/**\n\t * Default page size for paginated results\n\t * @default 20\n\t */\n\tdefaultPageSize?: number;\n\n\t/**\n\t * Maximum allowed page size (prevents excessive results)\n\t * @default 100\n\t */\n\tmaxPageSize?: number;\n}\n\ninterface OGImageFont {\n\t/** Font family name (e.g., 'Inter') */\n\tname: string;\n\t/** Path to font file (TTF, OTF, or WOFF) relative to project root */\n\tpath: string;\n\t/** Font weight (e.g., 400, 700, 900) */\n\tweight?: number;\n\t/** Font style (default: 'normal') */\n\tstyle?:\n\t\t| 'normal'\n\t\t| 'italic'\n\t\t| 'bold'\n\t\t| 'bold-italic'\n\t\t| 'medium'\n\t\t| 'medium-italic'\n\t\t| 'semibold'\n\t\t| 'semibold-italic'\n\t\t| 'light'\n\t\t| 'light-italic'\n\t\t| 'thin'\n\t\t| 'thin-italic'\n\t\t| 'black'\n\t\t| 'black-italic'\n\t\t| 'extra-bold'\n\t\t| 'extra-bold-italic'\n\t\t| 'extra-light'\n\t\t| 'extra-light-italic'\n\t\t| 'extra-medium'\n\t\t| 'extra-medium-italic'\n\t\t| 'extra-semibold'\n\t\t| 'extra-semibold-italic'\n\t\t| 'extra-light'\n\t\t| 'extra-light-italic'\n\t\t| 'extra-medium'\n\t\t| 'extra-medium-italic'\n\t\t| 'extra-semibold'\n\t\t| 'extra-semibold-italic';\n\tdata?: ArrayBuffer | undefined;\n}\n\n/**\n * Open Graph and social meta tags configuration\n */\ninterface OGOptions {\n\t/**\n\t * Site name used for og:site_name meta tag\n\t * This appears as the website name in social media shares\n\t * @example 'My Awesome Site'\n\t */\n\tsiteName?: string;\n\n\t/**\n\t * Default site description used as fallback for og:description\n\t * when a page doesn't define its own description\n\t * @example 'A modern web application built with Reroute'\n\t */\n\tsiteDescription?: string;\n\n\t/**\n\t * Default Open Graph type for pages without explicit og:type\n\t * Common types: 'website', 'article', 'product', 'profile'\n\t * @default 'website'\n\t * @see https://ogp.me/#types\n\t */\n\tdefaultType?: string;\n\n\t/**\n\t * Twitter/X handle for twitter:site meta tag (with or without @)\n\t * @example '@mysite' or 'mysite'\n\t */\n\ttwitterSite?: string;\n\n\t/**\n\t * Twitter/X card type (default: 'summary_large_image')\n\t * @default 'summary_large_image'\n\t */\n\ttwitterCard?: 'summary' | 'summary_large_image' | 'app' | 'player';\n\n\t/**\n\t * Default locale for og:locale meta tag\n\t * @example 'en_US', 'en_GB', 'es_ES'\n\t */\n\tlocale?: string;\n}\n\n/**\n * OG Image generation configuration options\n */\ninterface OGImageOptions {\n\t/** Enable OG image generation (default: false) */\n\tenabled?: boolean;\n\n\t/** Base URL for absolute OG image URLs (e.g., 'https://example.com') - required when enabled */\n\tbaseUrl?: string;\n\n\t/** Path to default template component or 'default' for built-in template */\n\tdefaultTemplate?: string;\n\n\t/** Image width in pixels (default: 1200) */\n\twidth?: number;\n\n\t/** Image height in pixels (default: 630) */\n\theight?: number;\n\n\t/** Cache duration in seconds (default: 3600 = 1 hour) */\n\tmaxAge?: number;\n\n\t/** Default avatar/logo URL (can be external or local path) */\n\tavatar?: string;\n\n\t/** Site name to display */\n\tsiteName?: string;\n\n\t/** Custom fonts to load for OG images */\n\tfonts?: OGImageFont[];\n}\n\n/**\n * LLMs content configuration options\n */\ninterface LLMsOptions {\n\t/** Enable LLM content features (default: false) */\n\tenabled?: boolean;\n\n\t/** Base URL for absolute URLs in llms.txt index (e.g., 'https://example.com') */\n\tbaseUrl?: string;\n\n\t/** Enable .txt extension for routes (default: true when enabled) */\n\tenableTextExtension?: boolean;\n\n\t/** Enable .md extension for routes (default: true when enabled) */\n\tenableMarkdownExtension?: boolean;\n\n\t/** Enable Accept header content negotiation (default: true when enabled) */\n\tenableContentNegotiation?: boolean;\n\n\t/** Enable /llms.txt index generation (default: true when enabled) */\n\tenableIndex?: boolean;\n\n\t/** Enable /llms-full.txt generation (default: true when enabled) */\n\tenableFullContent?: boolean;\n\n\t/** Cache duration in seconds for LLM content (default: 86400 = 24 hours, or falls back to options.maxAge) */\n\tmaxAge?: number;\n\n\t/** Cache duration in seconds for llms-full.txt specifically (default: 604800 = 7 days, or falls back to llms.maxAge) */\n\tmaxAgeFull?: number;\n\n\t/** Maximum items in full content bundle (default: 10000) */\n\tmaxItems?: number;\n\n\t/** Maximum file size for full content in bytes (default: 50MB) */\n\tmaxSize?: number;\n\n\t/**\n\t * Exclude specific routes from LLM features\n\t * Supports strings (exact match or substring), RegExp, or custom functions\n\t * @example ['/admin', '/api', /^\\/private/, (path) => path.includes('draft')]\n\t */\n\texcludeRoutes?: (string | RegExp | ((pathname: string) => boolean))[];\n\n\t/**\n\t * Exclude collections from LLM features\n\t * @example ['drafts', 'private']\n\t */\n\texcludeCollections?: string[];\n\n\t/** Site name for index header */\n\tsiteName?: string;\n\n\t/** Site description for index header (brief context for LLMs) */\n\tsiteDescription?: string;\n\n\t/**\n\t * Per-collection customization for titles and descriptions\n\t * @example\n\t * ```ts\n\t * collections: {\n\t * blog: {\n\t * title: 'My Awesome Blog',\n\t * description: 'Insights and tutorials about web development'\n\t * },\n\t * docs: {\n\t * title: 'Documentation',\n\t * description: 'Complete API reference and guides'\n\t * }\n\t * }\n\t * ```\n\t */\n\tcollections?: Record<\n\t\tstring,\n\t\t{\n\t\t\t/** Custom title for this collection's LLMS index */\n\t\t\ttitle?: string;\n\t\t\t/** Custom description for this collection's LLMS index */\n\t\t\tdescription?: string;\n\t\t}\n\t>;\n}\n\n/**\n * Robots policy for specific user-agents\n */\ninterface RobotsPolicy {\n\t/** User-Agent (e.g., '*', 'Googlebot', 'GPTBot') */\n\tuserAgent: string;\n\n\t/** Paths to explicitly allow */\n\tallow?: string[];\n\n\t/** Paths to disallow */\n\tdisallow?: string[];\n\n\t/** Crawl delay for this user-agent (seconds) */\n\tcrawlDelay?: number;\n}\n\n/**\n * Robots.txt generation configuration options\n */\ninterface RobotsOptions {\n\t/** Enable robots.txt generation (default: false) */\n\tenabled?: boolean;\n\n\t/** Base URL for sitemap reference (e.g., 'https://example.com') - required when enabled */\n\tbaseUrl?: string;\n\n\t/** Cache duration in seconds (default: 86400 = 24 hours) */\n\tmaxAge?: number;\n\n\t/** Custom policies per user-agent (default: permissive) */\n\tpolicies?: RobotsPolicy[];\n\n\t/** Auto-reference sitemap.xml if sitemap is enabled (default: true) */\n\treferenceSitemap?: boolean;\n\n\t/** Auto-disallow routes excluded from sitemap (default: true) */\n\tsitemapExclusion?: boolean;\n\n\t/** Auto-disallow old redirect source paths (default: true) */\n\tredirectExclusion?: boolean;\n\n\t/** Additional raw text appended to robots.txt */\n\tcustomRules?: string;\n\n\t/** Global crawl delay in seconds (optional) */\n\tcrawlDelay?: number;\n}\n\n/**\n * Telemetry proxy configuration for forwarding browser telemetry\n */\ninterface TelemetryProxyOptions {\n\t/**\n\t * Enable browser telemetry proxy (default: true when proxy config exists)\n\t * Creates endpoints to forward browser traces/metrics/logs to OTLP backend\n\t * This avoids CORS issues and ad blockers\n\t */\n\tenabled?: boolean;\n\n\t/**\n\t * Base path for proxy endpoints (default: '/__reroute_telemetry')\n\t * Creates:\n\t * - {pathname}/v1/traces\n\t * - {pathname}/v1/metrics\n\t * - {pathname}/v1/logs\n\t * - {pathname}/health\n\t */\n\tpathname?: string;\n\n\t/**\n\t * Enable verbose logging for proxy requests\n\t * @default false\n\t */\n\tverbose?: boolean;\n\n\t/**\n\t * Custom handler for proxy requests (advanced)\n\t * If provided, replaces default OTLP forwarding logic\n\t *\n\t * @example\n\t * ```ts\n\t * handler: async ({ body, endpoint, headers }) => {\n\t * // Custom logic: filter, transform, or route to different backends\n\t * await fetch(`https://custom-backend${endpoint}`, {\n\t * method: 'POST',\n\t * headers,\n\t * body: JSON.stringify(body),\n\t * });\n\t * return { status: 200 };\n\t * }\n\t * ```\n\t */\n\thandler?: (params: {\n\t\tbody: unknown;\n\t\tendpoint: string;\n\t\theaders: Record<string, string>;\n\t\totlpEndpoint: string;\n\t}) => Promise<{ status: number }>;\n}\n\n/**\n * Browser telemetry configuration options\n */\ninterface BrowserTelemetryOptions {\n\t/**\n\t * Enable browser telemetry\n\t * @default true\n\t */\n\tenabled?: boolean;\n\n\t/**\n\t * Service name for browser telemetry\n\t * @default 'reroute-app-browser'\n\t */\n\tserviceName?: string;\n\n\t/**\n\t * Service version\n\t * @default '1.0.0'\n\t */\n\tserviceVersion?: string;\n\n\t/**\n\t * OTLP endpoint URL (use relative URL for same-origin proxy)\n\t * @default '/__reroute_telemetry'\n\t */\n\totlpEndpoint?: string;\n\n\t/**\n\t * API key for authentication (optional)\n\t */\n\tapiKey?: string;\n\n\t/**\n\t * Deployment environment (e.g., 'production', 'staging', 'development')\n\t * @default 'development'\n\t */\n\tenvironment?: string;\n\n\t/**\n\t * Enable console.error capture\n\t * @default true\n\t */\n\tenableConsoleCapture?: boolean;\n\n\t/**\n\t * Ignore specific routes/URLs from breadcrumbs and network tracking\n\t *\n\t * Note: Functions are NOT supported for browser telemetry (closures cannot be serialized)\n\t * Use strings or regex patterns instead\n\t *\n\t * @example\n\t * ```ts\n\t * ignoreRoutes: [\n\t * '/bundles/', // String prefix match\n\t * /\\.(js|css|png)$/, // Regex pattern\n\t * /^\\/assets\\//, // Regex for path prefix\n\t * ]\n\t * ```\n\t */\n\tignoreRoutes?: Array<string | RegExp>;\n}\n\n/**\n * Telemetry configuration options for OpenTelemetry integration\n */\ninterface TelemetryOptions {\n\t/**\n\t * Enable server telemetry collection (default: false)\n\t * Must be explicitly enabled to start collecting traces, metrics, and logs\n\t */\n\tenabled?: boolean;\n\n\t/**\n\t * Browser telemetry configuration\n\t * Configure browser-side telemetry separately from server\n\t */\n\tbrowser?: BrowserTelemetryOptions;\n\n\t/**\n\t * Service name for server telemetry\n\t * @default 'reroute-app'\n\t */\n\tserviceName?: string;\n\n\t/**\n\t * Service version\n\t * @default process.env.npm_package_version || '1.0.0'\n\t */\n\tserviceVersion?: string;\n\n\t/**\n\t * OTLP endpoint URL\n\t * @default process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318'\n\t */\n\totlpEndpoint?: string;\n\n\t/**\n\t * API key for authentication (optional, only needed for SigNoz Cloud)\n\t */\n\tapiKey?: string;\n\n\t/**\n\t * Deployment environment (e.g., 'production', 'staging', 'development')\n\t * Used as a deployment.environment attribute on all telemetry\n\t * @default process.env.NODE_ENV || 'development'\n\t */\n\tenvironment?: string;\n\n\t/**\n\t * Metric export interval in milliseconds\n\t * @default 5000\n\t */\n\tmetricsInterval?: number;\n\n\t/**\n\t * Browser telemetry proxy configuration\n\t * When configured, creates endpoints to forward browser telemetry to OTLP backend\n\t * This avoids CORS issues and ad blockers\n\t */\n\tproxy?: TelemetryProxyOptions;\n\n\t/**\n\t * Ignore specific routes from telemetry collection\n\t * Supports flexible pattern matching:\n\t * - String: Matches if pathname contains the string (e.g., '/assets' matches '/assets/logo.png')\n\t * - RegExp: Tests pathname against regex (e.g., /\\.(js|css)$/ matches file extensions)\n\t * - Function: Custom logic with pathname and method (server-side only)\n\t *\n\t * Note: For browser telemetry, only strings and regex are supported (functions use closures that cannot be serialized)\n\t *\n\t * @example\n\t * ```ts\n\t * ignoreRoutes: [\n\t * '/health', // String match\n\t * /\\.(js|css|png|jpg|svg|ico|woff2?)$/, // Regex for static assets\n\t * (pathname) => pathname.startsWith('/assets/'), // Function (server-side only)\n\t * (pathname, method) => method === 'OPTIONS', // Access to HTTP method (server-side only)\n\t * ]\n\t * ```\n\t */\n\tignoreRoutes?: (\n\t\t| string\n\t\t| RegExp\n\t\t| ((pathname: string, method: string) => boolean)\n\t)[];\n\n\t/**\n\t * Enable distributed tracing (default: true)\n\t * Captures request flows across services with OpenTelemetry traces\n\t */\n\tenableTraces?: boolean;\n\n\t/**\n\t * Enable metrics collection (default: true)\n\t * Captures counters, gauges, and histograms for request volume, duration, etc.\n\t */\n\tenableMetrics?: boolean;\n\n\t/**\n\t * Enable structured logging (default: true)\n\t * Captures log events with structured attributes for better querying\n\t */\n\tenableLogs?: boolean;\n\n\t/**\n\t * Enable system metrics collection (default: true)\n\t * Captures CPU usage, memory consumption, and process metrics\n\t */\n\tenableSystemMetrics?: boolean;\n\n\t/**\n\t * Enable console.error and console.warn capture (default: true)\n\t * Automatically creates telemetry spans for console.error/warn calls\n\t * Useful for catching errors that are logged but not thrown\n\t */\n\tenableConsoleCapture?: boolean;\n\n\t/**\n\t * Sample rate for regular requests (default: 1.0)\n\t * Controls what percentage of requests to track (0.0 = 0%, 1.0 = 100%)\n\t *\n\t * Use sampling to reduce telemetry volume and costs on high-traffic applications:\n\t * - 1.0 = Track every request (100%)\n\t * - 0.5 = Track half of requests (50%)\n\t * - 0.1 = Track 10% of requests\n\t * - 0.01 = Track 1% of requests\n\t *\n\t * Sampling uses random selection, so a 10% sample of 100,000 requests\n\t * still provides ~10,000 data points for statistical analysis\n\t *\n\t * @example sampleRate: 0.1 // Track 10% of requests\n\t */\n\tsampleRate?: number;\n\n\t/**\n\t * Sample rate for error requests (default: 1.0)\n\t * Controls what percentage of errors to track (0.0 = 0%, 1.0 = 100%)\n\t *\n\t * Typically set higher than sampleRate since errors are more important to track.\n\t * Common pattern: low sample rate for normal requests, 100% for errors\n\t *\n\t * @example\n\t * ```ts\n\t * sampleRate: 0.1, // Track 10% of normal requests\n\t * errorSampleRate: 1.0, // Track 100% of errors\n\t * ```\n\t */\n\terrorSampleRate?: number;\n\n\t/**\n\t * Capture and map HTTP headers to custom telemetry attributes\n\t * Provides fine-grained control over header extraction and attribute naming\n\t *\n\t * Use presets for common scenarios or define custom mappings for any header\n\t *\n\t * @example\n\t * ```ts\n\t * import { RerouteHeaders, CloudflareHeaders } from 'reroute-js/telemetry/server';\n\t *\n\t * capture: [\n\t * ...RerouteHeaders.http(), // user-agent, referer, accept-language, etc.\n\t * ...CloudflareHeaders.geo(), // Cloudflare geolocation (IP, country, city, etc.)\n\t * { header: 'x-custom', as: 'custom.value' }, // Custom mapping\n\t * ]\n\t * ```\n\t */\n\tcapture?: Array<{ header: string; as: string }>;\n\n\t/**\n\t * Custom attributes to add to all spans and logs\n\t * Useful for tagging telemetry with environment, region, version, etc.\n\t *\n\t * @example\n\t * ```ts\n\t * customAttributes: {\n\t * environment: 'production',\n\t * region: 'us-east-1',\n\t * version: '1.2.3',\n\t * }\n\t * ```\n\t */\n\tcustomAttributes?: Record<string, string | number | boolean>;\n\n\t/**\n\t * Source map configuration for production error tracking\n\t * When enabled, error stack traces are mapped to original source files\n\t * instead of compiled/minified code\n\t *\n\t * @example\n\t * ```ts\n\t * sourcemaps: {\n\t * enabled: true, // Enable sourcemap resolution\n\t * }\n\t * ```\n\t */\n\tsourcemaps?: {\n\t\t/**\n\t\t * Enable sourcemap resolution\n\t\t * @default true in production, false in development\n\t\t */\n\t\tenabled?: boolean;\n\t};\n}\n\n/**\n * Redirect handler function that can dynamically determine destination\n * @param url - The original URL object\n * @returns The destination path/url or null to skip redirect\n */\ntype RedirectHandler = (url: URL) => string | null | Promise<string | null>;\n\n/**\n * Individual redirect rule\n */\ninterface RedirectRule {\n\t/** Enable or disable this redirect rule (default: true) */\n\tenabled?: boolean;\n\t/** Source path (string or regex pattern) */\n\tsource: string | RegExp;\n\t/** Destination path or handler function */\n\tdestination: string | RedirectHandler;\n\t/** HTTP status code (301 = permanent, 302 = temporary, 307 = preserve method, 308 = permanent preserve method) */\n\tstatus?: 301 | 302 | 307 | 308;\n\t/** Whether source is a regex pattern (auto-detected if source is RegExp) */\n\tregex?: boolean;\n}\n\n/**\n * Server-side caching configuration\n * Controls internal LRU cache for rendered HTML and data\n */\ninterface ServerOptions {\n\t/**\n\t * Enable server-side caching\n\t * @default true\n\t */\n\tcache?: boolean;\n\n\t/**\n\t * Cache duration in seconds for server-side cache\n\t * @default 3600 (1 hour)\n\t */\n\tmaxAge?: number;\n}\n\n/**\n * Browser caching configuration\n * Controls Cache-Control headers sent to browsers\n */\ninterface BrowserOptions {\n\t/**\n\t * Enable sending Cache-Control headers to browsers\n\t * Set to false when running behind a CDN like Cloudflare that handles caching\n\t * @default true\n\t */\n\tcache?: boolean;\n\n\t/**\n\t * Cache duration in seconds for browser caching\n\t * @default 300 (5 minutes)\n\t */\n\tmaxAge?: number;\n\n\t/**\n\t * Cache-Control directive ('public' | 'private')\n\t * @default 'public'\n\t */\n\tdirective?: 'public' | 'private';\n}\n\ninterface AppOptions {\n\t/** App component path (e.g., './src/client/App') */\n\tsrc?: string;\n\n\t/**\n\t * Base URL for the application (e.g., 'https://example.com')\n\t * Used for canonical URLs, social meta tags, and other absolute URLs\n\t */\n\tbaseUrl?: string;\n\n\t/** Custom HTML to inject into <head> */\n\thead?: string;\n\n\t/** HTML lang attribute @default 'en' */\n\tlang?: string;\n\n\t/** Root element ID @default 'root' */\n\tappId?: string;\n\n\t/** Enable automatic canonical URL generation @default true when baseUrl is set */\n\tautoCanonical?: boolean;\n\n\t/**\n\t * Suffix to append to all page titles (e.g., ' | My Site')\n\t * Applied automatically to page titles and og:title meta tags\n\t */\n\ttitleSuffix?: string;\n\n\t/** Minify HTML output */\n\tminify?: boolean;\n\n\t/** Enable compression for SSR responses @default true */\n\tcompression?: boolean;\n\n\t/** Enable detailed performance logging */\n\tdebug?: boolean;\n\n\t/** Cache duration for JS bundles in seconds @default 31536000 (1 year) */\n\tbundleMaxAge?: number;\n}\n\ninterface RerouteConfig {\n\tapp?: AppOptions;\n\tstatic?: StaticOptions;\n\tstreaming?: StreamingOptions;\n\tredirects?: RedirectRule[];\n\timage?: ImageOptions;\n\tog?: OGOptions;\n\togImage?: OGImageOptions;\n\tsitemap?: SitemapOptions;\n\trss?: RSSOptions;\n\tmarkdown?: MarkdownOptions;\n\tsearch?: SearchOptions;\n\tllms?: LLMsOptions;\n\trobots?: RobotsOptions;\n\ttelemetry?: TelemetryOptions;\n\n\t/**\n\t * Server-side caching configuration\n\t * Controls internal LRU cache for rendered HTML\n\t *\n\t * @example\n\t * ```ts\n\t * // Disable server caching\n\t * server: { cache: false }\n\t *\n\t * // Custom server cache TTL\n\t * server: { cache: true, maxAge: 3600 }\n\t * ```\n\t */\n\tserver?: ServerOptions;\n\n\t/**\n\t * Browser caching configuration\n\t * Controls Cache-Control headers sent to browsers\n\t *\n\t * @example\n\t * ```ts\n\t * // Disable browser caching (recommended when using Cloudflare)\n\t * browser: { cache: false }\n\t *\n\t * // Custom browser cache settings\n\t * browser: { cache: true, maxAge: 60, directive: 'private' }\n\t * ```\n\t */\n\tbrowser?: BrowserOptions;\n}\n\nfunction defineConfig(config: RerouteConfig): RerouteConfig {\n\treturn config;\n}\n\nasync function loadConfig(cwd: string): Promise<RerouteConfig> {\n\t// Check for bundled config first (compiled binary support)\n\tconst bundledConfig = (globalThis as Record<string, unknown>)\n\t\t.__REROUTE_CONFIG__ as RerouteConfig | undefined;\n\tif (bundledConfig) {\n\t\treturn bundledConfig;\n\t}\n\n\t// Fallback to filesystem read (dev mode)\n\tconst configPath = `${cwd}/reroute.config.ts`;\n\tconst configFile = Bun.file(configPath);\n\n\tif (!(await configFile.exists())) {\n\t\treturn {};\n\t}\n\n\ttry {\n\t\tconst mod = await import(\n\t\t\t`${pathToFileURL(configPath).href}?t=${Date.now()}`\n\t\t);\n\t\treturn (mod.default || mod) as RerouteConfig;\n\t} catch (error) {\n\t\tconsole.warn('[reroute] Failed to load reroute.config.ts:', error);\n\t\treturn {};\n\t}\n}\n\nexport {\n\tdefineConfig,\n\tloadConfig,\n\ttype AppOptions,\n\ttype BrowserOptions,\n\ttype ImageOptions,\n\ttype LLMsOptions,\n\ttype MarkdownOptions,\n\ttype OGOptions,\n\ttype OGImageOptions,\n\ttype OGImageFont,\n\ttype RedirectRule,\n\ttype RerouteConfig,\n\ttype RobotsOptions,\n\ttype RobotsPolicy,\n\ttype RSSOptions,\n\ttype SearchOptions,\n\ttype ServerOptions,\n\ttype SitemapOptions,\n\ttype StaticOptions,\n\ttype StreamingOptions,\n\ttype TelemetryOptions,\n\ttype TelemetryProxyOptions,\n\ttype BrowserTelemetryOptions,\n};\n",
|
|
11
11
|
"export * from './discovery';\nexport * from './metadata';\n",
|
|
12
|
-
"import type { CacheEntry } from './types';\n\n/**\n * Simple in-memory cache for SSR data.\n * Thread-safe for single-process usage.\n */\nclass SSRDataCache {\n\tprivate cache: Map<string, CacheEntry<unknown>> = new Map();\n\tprivate static cleanupInterval: NodeJS.Timeout | null = null;\n\n\tconstructor() {\n\t\t// Run cleanup every 60 seconds to remove expired entries\n\t\tif (!SSRDataCache.cleanupInterval) {\n\t\t\tSSRDataCache.cleanupInterval = setInterval(() => {\n\t\t\t\tthis.cleanup();\n\t\t\t}, 60_000);\n\t\t}\n\t}\n\n\t/**\n\t * Get cached data if available and not expired\n\t */\n\tget<T>(key: string): T | undefined {\n\t\tconst entry = this.cache.get(key);\n\t\tif (!entry) return undefined;\n\n\t\tconst age = Date.now() - entry.timestamp;\n\t\tif (age > entry.maxAge) {\n\t\t\tthis.cache.delete(key);\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn entry.data as T;\n\t}\n\n\t/**\n\t * Set data in cache with maxAge (in milliseconds)\n\t */\n\tset<T>(key: string, data: T, maxAge: number): void {\n\t\tif (maxAge <= 0) return;\n\n\t\tthis.cache.set(key, {\n\t\t\tdata,\n\t\t\ttimestamp: Date.now(),\n\t\t\tmaxAge,\n\t\t});\n\t}\n\n\t/**\n\t * Check if key exists and is not expired\n\t */\n\thas(key: string): boolean {\n\t\treturn this.get(key) !== undefined;\n\t}\n\n\t/**\n\t * Clear all cached data\n\t */\n\tclear(): void {\n\t\tthis.cache.clear();\n\t}\n\n\t/**\n\t * Remove expired entries\n\t */\n\tprivate cleanup(): void {\n\t\tconst now = Date.now();\n\t\tfor (const [key, entry] of this.cache.entries()) {\n\t\t\tif (now - entry.timestamp > entry.maxAge) {\n\t\t\t\tthis.cache.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get cache stats (useful for debugging)\n\t */\n\tstats(): { size: number; keys: string[] } {\n\t\treturn {\n\t\t\tsize: this.cache.size,\n\t\t\tkeys: Array.from(this.cache.keys()),\n\t\t};\n\t}\n\n\t/**\n\t * Cleanup interval on shutdown\n\t */\n\tdestroy(): void {\n\t\tif (SSRDataCache.cleanupInterval) {\n\t\t\tclearInterval(SSRDataCache.cleanupInterval);\n\t\t\tSSRDataCache.cleanupInterval = null;\n\t\t}\n\t\tthis.clear();\n\t}\n}\n\n/**\n * Simple LRU Cache implementation.\n * Used for caching responses and data across requests.\n * NOTE: This does NOT support TTL - use TTLCache for time-based expiration.\n */\nexport class LRUCache<K, V> {\n\tprivate cache: Map<K, V> = new Map();\n\tprivate maxSize: number;\n\n\tconstructor(maxSize = 100) {\n\t\tthis.maxSize = maxSize;\n\t}\n\n\tget(key: K): V | undefined {\n\t\tconst value = this.cache.get(key);\n\t\tif (value !== undefined) {\n\t\t\t// Move to end (most recently used)\n\t\t\tthis.cache.delete(key);\n\t\t\tthis.cache.set(key, value);\n\t\t}\n\t\treturn value;\n\t}\n\n\tset(key: K, value: V): void {\n\t\tthis.cache.delete(key);\n\n\t\tif (this.cache.size >= this.maxSize) {\n\t\t\tconst firstKey = this.cache.keys().next().value;\n\t\t\tthis.cache.delete(firstKey as K);\n\t\t}\n\n\t\tthis.cache.set(key, value);\n\t}\n\n\thas(key: K): boolean {\n\t\treturn this.cache.has(key);\n\t}\n\n\tclear(): void {\n\t\tthis.cache.clear();\n\t}\n}\n\n/**\n * TTL-based cache with automatic expiration and size limits.\n * Use this for content caching where entries should expire after a set time.\n */\nexport class TTLCache<K, V> {\n\tprivate cache: Map<K, { value: V; exp: number }> = new Map();\n\tprivate maxSize: number;\n\tprivate defaultTtlMs: number;\n\tprivate cleanupInterval: NodeJS.Timeout | null = null;\n\n\t/**\n\t * @param maxSize Maximum number of entries (default: 100)\n\t * @param defaultTtlMs Default TTL in milliseconds (default: 300000 = 5 min)\n\t * @param cleanupIntervalMs How often to run cleanup (default: 60000 = 1 min)\n\t */\n\tconstructor(\n\t\tmaxSize = 100,\n\t\tdefaultTtlMs = 300_000,\n\t\tcleanupIntervalMs = 60_000,\n\t) {\n\t\tthis.maxSize = maxSize;\n\t\tthis.defaultTtlMs = defaultTtlMs;\n\n\t\t// Periodic cleanup of expired entries\n\t\tthis.cleanupInterval = setInterval(() => {\n\t\t\tthis.cleanup();\n\t\t}, cleanupIntervalMs);\n\n\t\t// Prevent interval from keeping process alive\n\t\tif (this.cleanupInterval.unref) {\n\t\t\tthis.cleanupInterval.unref();\n\t\t}\n\t}\n\n\t/**\n\t * Get value if exists and not expired\n\t */\n\tget(key: K): V | undefined {\n\t\tconst entry = this.cache.get(key);\n\t\tif (!entry) return undefined;\n\n\t\tif (entry.exp <= Date.now()) {\n\t\t\tthis.cache.delete(key);\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn entry.value;\n\t}\n\n\t/**\n\t * Set value with optional custom TTL\n\t * @param key Cache key\n\t * @param value Value to cache\n\t * @param ttlMs Optional TTL in milliseconds (uses default if not provided)\n\t */\n\tset(key: K, value: V, ttlMs?: number): void {\n\t\t// Remove existing entry
|
|
12
|
+
"import type { CacheEntry } from './types';\n\n/**\n * Simple in-memory cache for SSR data.\n * Thread-safe for single-process usage.\n */\nclass SSRDataCache {\n\tprivate cache: Map<string, CacheEntry<unknown>> = new Map();\n\tprivate static cleanupInterval: NodeJS.Timeout | null = null;\n\n\tconstructor() {\n\t\t// Run cleanup every 60 seconds to remove expired entries\n\t\tif (!SSRDataCache.cleanupInterval) {\n\t\t\tSSRDataCache.cleanupInterval = setInterval(() => {\n\t\t\t\tthis.cleanup();\n\t\t\t}, 60_000);\n\t\t}\n\t}\n\n\t/**\n\t * Get cached data if available and not expired\n\t */\n\tget<T>(key: string): T | undefined {\n\t\tconst entry = this.cache.get(key);\n\t\tif (!entry) return undefined;\n\n\t\tconst age = Date.now() - entry.timestamp;\n\t\tif (age > entry.maxAge) {\n\t\t\tthis.cache.delete(key);\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn entry.data as T;\n\t}\n\n\t/**\n\t * Set data in cache with maxAge (in milliseconds)\n\t */\n\tset<T>(key: string, data: T, maxAge: number): void {\n\t\tif (maxAge <= 0) return;\n\n\t\tthis.cache.set(key, {\n\t\t\tdata,\n\t\t\ttimestamp: Date.now(),\n\t\t\tmaxAge,\n\t\t});\n\t}\n\n\t/**\n\t * Check if key exists and is not expired\n\t */\n\thas(key: string): boolean {\n\t\treturn this.get(key) !== undefined;\n\t}\n\n\t/**\n\t * Clear all cached data\n\t */\n\tclear(): void {\n\t\tthis.cache.clear();\n\t}\n\n\t/**\n\t * Remove expired entries\n\t */\n\tprivate cleanup(): void {\n\t\tconst now = Date.now();\n\t\tfor (const [key, entry] of this.cache.entries()) {\n\t\t\tif (now - entry.timestamp > entry.maxAge) {\n\t\t\t\tthis.cache.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get cache stats (useful for debugging)\n\t */\n\tstats(): { size: number; keys: string[] } {\n\t\treturn {\n\t\t\tsize: this.cache.size,\n\t\t\tkeys: Array.from(this.cache.keys()),\n\t\t};\n\t}\n\n\t/**\n\t * Cleanup interval on shutdown\n\t */\n\tdestroy(): void {\n\t\tif (SSRDataCache.cleanupInterval) {\n\t\t\tclearInterval(SSRDataCache.cleanupInterval);\n\t\t\tSSRDataCache.cleanupInterval = null;\n\t\t}\n\t\tthis.clear();\n\t}\n}\n\n/**\n * Simple LRU Cache implementation.\n * Used for caching responses and data across requests.\n * NOTE: This does NOT support TTL - use TTLCache for time-based expiration.\n */\nexport class LRUCache<K, V> {\n\tprivate cache: Map<K, V> = new Map();\n\tprivate maxSize: number;\n\n\tconstructor(maxSize = 100) {\n\t\tthis.maxSize = maxSize;\n\t}\n\n\tget(key: K): V | undefined {\n\t\tconst value = this.cache.get(key);\n\t\tif (value !== undefined) {\n\t\t\t// Move to end (most recently used)\n\t\t\tthis.cache.delete(key);\n\t\t\tthis.cache.set(key, value);\n\t\t}\n\t\treturn value;\n\t}\n\n\tset(key: K, value: V): void {\n\t\tthis.cache.delete(key);\n\n\t\tif (this.cache.size >= this.maxSize) {\n\t\t\tconst firstKey = this.cache.keys().next().value;\n\t\t\tthis.cache.delete(firstKey as K);\n\t\t}\n\n\t\tthis.cache.set(key, value);\n\t}\n\n\thas(key: K): boolean {\n\t\treturn this.cache.has(key);\n\t}\n\n\tclear(): void {\n\t\tthis.cache.clear();\n\t}\n}\n\n/**\n * TTL-based cache with automatic expiration and size limits.\n * Use this for content caching where entries should expire after a set time.\n */\nexport class TTLCache<K, V> {\n\tprivate cache: Map<K, { value: V; exp: number; size?: number }> = new Map();\n\tprivate maxSize: number;\n\tprivate defaultTtlMs: number;\n\tprivate cleanupInterval: NodeJS.Timeout | null = null;\n\tprivate maxMemoryBytes: number | null = null;\n\tprivate currentMemoryBytes = 0;\n\n\t/**\n\t * @param maxSize Maximum number of entries (default: 100)\n\t * @param defaultTtlMs Default TTL in milliseconds (default: 300000 = 5 min)\n\t * @param cleanupIntervalMs How often to run cleanup (default: 60000 = 1 min)\n\t * @param maxMemoryMB Optional maximum memory in MB (e.g., 1000 = 1GB)\n\t */\n\tconstructor(\n\t\tmaxSize = 100,\n\t\tdefaultTtlMs = 300_000,\n\t\tcleanupIntervalMs = 60_000,\n\t\tmaxMemoryMB?: number,\n\t) {\n\t\tthis.maxSize = maxSize;\n\t\tthis.defaultTtlMs = defaultTtlMs;\n\t\tthis.maxMemoryBytes = maxMemoryMB ? maxMemoryMB * 1024 * 1024 : null;\n\n\t\t// Periodic cleanup of expired entries\n\t\tthis.cleanupInterval = setInterval(() => {\n\t\t\tthis.cleanup();\n\t\t}, cleanupIntervalMs);\n\n\t\t// Prevent interval from keeping process alive\n\t\tif (this.cleanupInterval.unref) {\n\t\t\tthis.cleanupInterval.unref();\n\t\t}\n\t}\n\n\t/**\n\t * Get value if exists and not expired\n\t */\n\tget(key: K): V | undefined {\n\t\tconst entry = this.cache.get(key);\n\t\tif (!entry) return undefined;\n\n\t\tif (entry.exp <= Date.now()) {\n\t\t\tthis.cache.delete(key);\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn entry.value;\n\t}\n\n\t/**\n\t * Estimate size of value in bytes\n\t */\n\tprivate estimateSize(value: V): number {\n\t\tif (value instanceof Buffer || value instanceof ArrayBuffer) {\n\t\t\treturn value.byteLength;\n\t\t}\n\t\tif (typeof value === 'string') {\n\t\t\treturn value.length * 2; // UTF-16 encoding\n\t\t}\n\t\t// For objects, use rough estimate\n\t\ttry {\n\t\t\treturn JSON.stringify(value).length * 2;\n\t\t} catch {\n\t\t\treturn 1024; // Default estimate\n\t\t}\n\t}\n\n\t/**\n\t * Set value with optional custom TTL\n\t * @param key Cache key\n\t * @param value Value to cache\n\t * @param ttlMs Optional TTL in milliseconds (uses default if not provided)\n\t */\n\tset(key: K, value: V, ttlMs?: number): void {\n\t\t// Calculate size of new entry\n\t\tconst entrySize = this.estimateSize(value);\n\n\t\t// Remove existing entry and update memory tracking\n\t\tconst existing = this.cache.get(key);\n\t\tif (existing) {\n\t\t\tthis.cache.delete(key);\n\t\t\tif (existing.size) {\n\t\t\t\tthis.currentMemoryBytes -= existing.size;\n\t\t\t}\n\t\t}\n\n\t\t// Evict entries if over memory limit\n\t\tif (\n\t\t\tthis.maxMemoryBytes &&\n\t\t\tthis.currentMemoryBytes + entrySize > this.maxMemoryBytes\n\t\t) {\n\t\t\tthis.evictForMemory(entrySize);\n\t\t}\n\n\t\t// Evict oldest entry if at capacity\n\t\tif (this.cache.size >= this.maxSize) {\n\t\t\tconst firstKey = this.cache.keys().next().value;\n\t\t\tif (firstKey !== undefined) {\n\t\t\t\tconst evicted = this.cache.get(firstKey);\n\t\t\t\tthis.cache.delete(firstKey);\n\t\t\t\tif (evicted?.size) {\n\t\t\t\t\tthis.currentMemoryBytes -= evicted.size;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.cache.set(key, {\n\t\t\tvalue,\n\t\t\texp: Date.now() + (ttlMs ?? this.defaultTtlMs),\n\t\t\tsize: entrySize,\n\t\t});\n\t\tthis.currentMemoryBytes += entrySize;\n\t}\n\n\t/**\n\t * Check if key exists and is not expired\n\t */\n\thas(key: K): boolean {\n\t\treturn this.get(key) !== undefined;\n\t}\n\n\t/**\n\t * Evict entries to free up memory\n\t */\n\tprivate evictForMemory(neededBytes: number): void {\n\t\tif (!this.maxMemoryBytes) return;\n\t\tconst targetBytes = this.maxMemoryBytes * 0.7; // Evict down to 70%\n\t\tconst keys = Array.from(this.cache.keys());\n\n\t\tfor (const key of keys) {\n\t\t\tif (this.currentMemoryBytes + neededBytes <= targetBytes) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst entry = this.cache.get(key);\n\t\t\tif (entry) {\n\t\t\t\tthis.cache.delete(key);\n\t\t\t\tif (entry.size) {\n\t\t\t\t\tthis.currentMemoryBytes -= entry.size;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Delete a specific key\n\t */\n\tdelete(key: K): boolean {\n\t\tconst entry = this.cache.get(key);\n\t\tconst deleted = this.cache.delete(key);\n\t\tif (deleted && entry?.size) {\n\t\t\tthis.currentMemoryBytes -= entry.size;\n\t\t}\n\t\treturn deleted;\n\t}\n\n\t/**\n\t * Clear all entries\n\t */\n\tclear(): void {\n\t\tthis.cache.clear();\n\t\tthis.currentMemoryBytes = 0;\n\t}\n\n\t/**\n\t * Get current cache size (including potentially expired entries)\n\t */\n\tget size(): number {\n\t\treturn this.cache.size;\n\t}\n\n\t/**\n\t * Get cache statistics including memory usage\n\t */\n\tstats(): {\n\t\tentries: number;\n\t\tmemoryMB: number;\n\t\tmaxMemoryMB: number | null;\n\t\tmemoryUsagePercent: number | null;\n\t} {\n\t\tconst memoryMB = this.currentMemoryBytes / (1024 * 1024);\n\t\tconst maxMemoryMB = this.maxMemoryBytes\n\t\t\t? this.maxMemoryBytes / (1024 * 1024)\n\t\t\t: null;\n\t\tconst memoryUsagePercent = maxMemoryMB\n\t\t\t? (memoryMB / maxMemoryMB) * 100\n\t\t\t: null;\n\n\t\treturn {\n\t\t\tentries: this.cache.size,\n\t\t\tmemoryMB: Math.round(memoryMB * 100) / 100,\n\t\t\tmaxMemoryMB: maxMemoryMB ? Math.round(maxMemoryMB) : null,\n\t\t\tmemoryUsagePercent: memoryUsagePercent\n\t\t\t\t? Math.round(memoryUsagePercent)\n\t\t\t\t: null,\n\t\t};\n\t}\n\n\t/**\n\t * Remove expired entries\n\t */\n\tprivate cleanup(): void {\n\t\tconst now = Date.now();\n\t\tfor (const [key, entry] of this.cache.entries()) {\n\t\t\tif (entry.exp <= now) {\n\t\t\t\tthis.cache.delete(key);\n\t\t\t\tif (entry.size) {\n\t\t\t\t\tthis.currentMemoryBytes -= entry.size;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stop cleanup interval (call on shutdown)\n\t */\n\tdestroy(): void {\n\t\tif (this.cleanupInterval) {\n\t\t\tclearInterval(this.cleanupInterval);\n\t\t\tthis.cleanupInterval = null;\n\t\t}\n\t\tthis.clear();\n\t}\n}\n\n// Global singleton instances using globalThis for hot reload survival\nconst getGlobalCache = (): SSRDataCache => {\n\tconst g = globalThis as typeof globalThis & {\n\t\t__REROUTE_SSR_CACHE__?: SSRDataCache;\n\t};\n\n\tif (!g.__REROUTE_SSR_CACHE__) {\n\t\tg.__REROUTE_SSR_CACHE__ = new SSRDataCache();\n\t}\n\n\treturn g.__REROUTE_SSR_CACHE__;\n};\n\nconst getGlobalStatusCache = (): SSRDataCache => {\n\tconst g = globalThis as typeof globalThis & {\n\t\t__REROUTE_STATUS_CACHE__?: SSRDataCache;\n\t};\n\n\tif (!g.__REROUTE_STATUS_CACHE__) {\n\t\tg.__REROUTE_STATUS_CACHE__ = new SSRDataCache();\n\t}\n\n\treturn g.__REROUTE_STATUS_CACHE__;\n};\n\nconst ssrCache = getGlobalCache();\nconst statusCache = getGlobalStatusCache();\n\nexport { ssrCache, statusCache, SSRDataCache };\n",
|
|
13
13
|
"import { dynamicImport } from './imports';\nimport { join } from './path';\nimport type { Doc } from './types';\n\n/**\n * Load content collections for SSR rendering\n */\nexport async function loadCollections(\n\tcwd: string,\n\tisWatchMode: boolean,\n): Promise<Record<string, unknown[]>> {\n\ttry {\n\t\tconst p = join(cwd, '.reroute', 'content.ts');\n\t\tconst mod = await dynamicImport(p, isWatchMode);\n\t\treturn (mod?.byCollection || {}) as Record<string, unknown[]>;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/**\n * Set global collections for SSR\n */\nexport function setGlobalCollections(\n\tbyCollectionForSSR: Record<string, unknown[]>,\n): void {\n\ttry {\n\t\t(globalThis as Doc).__REROUTE_COLLECTIONS__ = byCollectionForSSR;\n\t} catch {\n\t\t// Ignore errors in restricted environments\n\t}\n}\n",
|
|
14
14
|
"import { ssrCache, statusCache } from '../cache';\nimport { toPromise } from '../imports';\nimport type { ComputeOptions, Doc, SSR, SSRContext } from '../types';\n\ntype ContentComputeResult = {\n\tdata: Record<string, unknown>;\n\terror?: string;\n\tstatusOverride?: number;\n\tpendingTasks: Promise<unknown>[];\n};\n\nfunction checkStatusCache(\n\tstatusCacheKey: string,\n\tmaxAgeMs: number,\n): number | undefined {\n\tif (maxAgeMs <= 0) return undefined;\n\treturn statusCache.get<number>(statusCacheKey);\n}\n\nfunction checkDataCache(cacheKey: string, maxAgeMs: number): unknown {\n\tif (maxAgeMs <= 0) return undefined;\n\treturn ssrCache.get(cacheKey);\n}\n\nfunction createDataTask(\n\tdataFn: NonNullable<SSR['data']>,\n\tpathname: string,\n\tparts: string[],\n\tsearchParams: URLSearchParams | undefined,\n\tset: { status: number },\n\theaders?: Record<string, string>,\n): Promise<unknown> {\n\treturn toPromise(\n\t\tdataFn({\n\t\t\tpathname,\n\t\t\tparams: { name: parts[1] },\n\t\t\tset,\n\t\t\tsearchParams,\n\t\t\theaders,\n\t\t} satisfies SSRContext),\n\t).catch((err) => {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\tconst error = `SSR data() failed: ${msg}`;\n\t\tconsole.error(`[reroute] ${error}`);\n\t\tthrow err;\n\t});\n}\n\nfunction handleStreamingMode(\n\tssrData: Record<string, unknown>,\n\tpathname: string,\n\ttask: Promise<unknown>,\n\tset: { status: number },\n\tcacheKey: string,\n\tstatusCacheKey: string,\n\tmaxAgeMs: number,\n\tpendingTasks: Promise<unknown>[],\n): void {\n\tssrData[pathname] = task;\n\n\tconst storeTask = task.then((value) => {\n\t\tif (set.status !== 200) {\n\t\t\t// statusOverride handled by caller\n\t\t}\n\t\tif (maxAgeMs > 0) {\n\t\t\tstatusCache.set(statusCacheKey, set.status, maxAgeMs);\n\t\t}\n\t\tif (maxAgeMs > 0 && set.status === 200) {\n\t\t\tssrCache.set(cacheKey, value, maxAgeMs);\n\t\t}\n\t\treturn value;\n\t});\n\n\tpendingTasks.push(\n\t\tstoreTask\n\t\t\t.then((value) => {\n\t\t\t\tssrData[pathname] = value;\n\t\t\t})\n\t\t\t.catch(() => {}),\n\t);\n}\n\nasync function handleNonStreamingMode(\n\tssrData: Record<string, unknown>,\n\tpathname: string,\n\ttask: Promise<unknown>,\n\tcacheKey: string,\n\tstatusCacheKey: string,\n\tmaxAgeMs: number,\n): Promise<unknown> {\n\tconst result = await task;\n\tssrData[pathname] = result;\n\n\tif (maxAgeMs > 0) {\n\t\tstatusCache.set(\n\t\t\tstatusCacheKey,\n\t\t\t(result as { status?: number }).status || 200,\n\t\t\tmaxAgeMs,\n\t\t);\n\t}\n\tif (maxAgeMs > 0) {\n\t\tssrCache.set(cacheKey, result, maxAgeMs);\n\t}\n\n\treturn result;\n}\n\n/**\n * Compute SSR data for content pages (e.g., /blog/my-post).\n * Content pages export ssr.data via __REROUTE_SSR_EXPORTS__.\n *\n * @param sharedSsrData - In streaming mode, the shared ssrData object that gets passed to React.\n * Promise resolution callbacks must update THIS object directly.\n */\nexport async function computeContentData(\n\tpathname: string,\n\toptions: ComputeOptions,\n\tsearchParams?: URLSearchParams,\n\tsharedSsrData?: Record<string, unknown>,\n): Promise<ContentComputeResult> {\n\tconst streaming = options.streaming === true;\n\tconst ssrData: Record<string, unknown> =\n\t\tstreaming && sharedSsrData ? sharedSsrData : {};\n\tconst pendingTasks: Promise<unknown>[] = [];\n\tlet error: string | undefined;\n\tlet statusOverride: number | undefined;\n\n\tconst maxAge = options.maxAge || 0;\n\tconst maxAgeMs = maxAge * 1000;\n\n\ttry {\n\t\tconst parts = pathname.split('/').filter(Boolean);\n\t\tif (parts.length < 2) {\n\t\t\treturn { data: ssrData, pendingTasks };\n\t\t}\n\n\t\tconst g = globalThis as Doc;\n\t\tconst key = `${parts[0]}:${parts[1]}`;\n\t\tconst exp = g.__REROUTE_SSR_EXPORTS__?.[key] as { ssr?: SSR } | undefined;\n\n\t\tconst dataFn = exp?.ssr?.data;\n\n\t\tif (typeof dataFn !== 'function') {\n\t\t\treturn { data: ssrData, pendingTasks };\n\t\t}\n\n\t\tconst cacheKey = `content:${pathname}:${parts[1]}`;\n\t\tconst statusCacheKey = `status:${cacheKey}`;\n\n\t\tconst cachedStatus = checkStatusCache(statusCacheKey, maxAgeMs);\n\t\tif (cachedStatus && cachedStatus !== 200) {\n\t\t\tstatusOverride = cachedStatus;\n\t\t}\n\n\t\tconst cached = checkDataCache(cacheKey, maxAgeMs);\n\t\tif (cached !== undefined) {\n\t\t\tssrData[pathname] = cached;\n\t\t\treturn { data: ssrData, statusOverride, pendingTasks };\n\t\t}\n\n\t\tconst set = { status: 200 };\n\t\tconst task = createDataTask(\n\t\t\tdataFn,\n\t\t\tpathname,\n\t\t\tparts,\n\t\t\tsearchParams,\n\t\t\tset,\n\t\t\toptions.headers,\n\t\t);\n\n\t\tif (streaming) {\n\t\t\thandleStreamingMode(\n\t\t\t\tssrData,\n\t\t\t\tpathname,\n\t\t\t\ttask,\n\t\t\t\tset,\n\t\t\t\tcacheKey,\n\t\t\t\tstatusCacheKey,\n\t\t\t\tmaxAgeMs,\n\t\t\t\tpendingTasks,\n\t\t\t);\n\t\t\tif (set.status !== 200) {\n\t\t\t\tstatusOverride = set.status;\n\t\t\t}\n\t\t} else {\n\t\t\tawait handleNonStreamingMode(\n\t\t\t\tssrData,\n\t\t\t\tpathname,\n\t\t\t\ttask,\n\t\t\t\tcacheKey,\n\t\t\t\tstatusCacheKey,\n\t\t\t\tmaxAgeMs,\n\t\t\t);\n\t\t\tif (set.status !== 200) {\n\t\t\t\tstatusOverride = set.status;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// Return what we have on error\n\t}\n\n\treturn { data: ssrData, error, statusOverride, pendingTasks };\n}\n",
|
|
15
15
|
"import { ssrCache, statusCache } from '../cache';\nimport { dynamicImport, toPromise } from '../imports';\nimport {\n\tcreateLayoutCacheKey,\n\tcreateLayoutDataKey,\n\tgetMatchingLayouts,\n} from '../layouts';\nimport { join } from '../path';\nimport type { ComputeOptions, Doc, SSR, SSRContext } from '../types';\n\ntype LayoutComputeResult = {\n\tdata: Record<string, unknown>;\n\tstatusOverride?: number;\n\tpendingTasks: Promise<unknown>[];\n};\n\nasync function loadLayoutSSRExport(\n\tlayout: Doc,\n\tclientDir: string,\n\tisWatchMode: boolean,\n): Promise<SSR | undefined> {\n\tlet ssrExport = (layout as Doc)?.ssr as SSR | undefined;\n\n\tif (!ssrExport) {\n\t\tconst abs = join(clientDir, 'routes', String(layout.path));\n\t\tconst mod = await dynamicImport(abs, isWatchMode);\n\t\tssrExport = (mod as Doc)?.ssr as SSR | undefined;\n\t}\n\n\treturn ssrExport;\n}\n\nfunction checkLayoutCache(\n\tcacheKey: string,\n\tstatusCacheKey: string,\n\tmaxAgeMs: number,\n): { cachedData?: unknown; cachedStatus?: number } {\n\tconst cachedStatus =\n\t\tmaxAgeMs > 0 ? statusCache.get<number>(statusCacheKey) : undefined;\n\tconst cachedData = maxAgeMs > 0 ? ssrCache.get(cacheKey) : undefined;\n\n\treturn { cachedData, cachedStatus };\n}\n\nfunction createLayoutDataTask(\n\tdataFn: NonNullable<SSR['data']>,\n\tpathname: string,\n\tsearchParams: URLSearchParams | undefined,\n\tlayoutPattern: string,\n\theaders?: Record<string, string>,\n): Promise<unknown> {\n\tconst set = { status: 200 };\n\treturn toPromise(\n\t\tdataFn({\n\t\t\tpathname,\n\t\t\tparams: {},\n\t\t\tset,\n\t\t\tsearchParams,\n\t\t\theaders,\n\t\t} satisfies SSRContext),\n\t).catch((err) => {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\tconsole.error(\n\t\t\t`[reroute] Layout SSR data() failed for ${layoutPattern}:`,\n\t\t\tmsg,\n\t\t);\n\t\tthrow err;\n\t});\n}\n\nfunction handleLayoutStreamingMode(\n\tssrData: Record<string, unknown>,\n\tlayoutKey: string,\n\ttask: Promise<unknown>,\n\tset: { status: number },\n\tcacheKey: string,\n\tstatusCacheKey: string,\n\tmaxAgeMs: number,\n\tpendingTasks: Promise<unknown>[],\n): void {\n\tssrData[layoutKey] = task;\n\n\t// Ensure global store mirrors streaming promises so useLayoutData() can suspend\n\t// and later resume once the promise resolves.\n\tconst g = globalThis as unknown as Record<string, Record<string, unknown>>;\n\tg.__REROUTE_DATA__ = g.__REROUTE_DATA__ || {};\n\tg.__REROUTE_DATA__[layoutKey] = task;\n\n\tconst storeTask = task.then((value) => {\n\t\tif (maxAgeMs > 0) {\n\t\t\tstatusCache.set(statusCacheKey, set.status, maxAgeMs);\n\t\t}\n\t\tif (maxAgeMs > 0 && set.status === 200) {\n\t\t\tssrCache.set(cacheKey, value, maxAgeMs);\n\t\t}\n\t\treturn value;\n\t});\n\n\tpendingTasks.push(\n\t\tstoreTask\n\t\t\t.then((value) => {\n\t\t\t\tssrData[layoutKey] = value;\n\t\t\t\t// Keep global store in sync after resolution for Suspense retries\n\t\t\t\tif (g.__REROUTE_DATA__) {\n\t\t\t\t\tg.__REROUTE_DATA__[layoutKey] = value;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(() => {}),\n\t);\n}\n\nasync function handleLayoutNonStreamingMode(\n\tssrData: Record<string, unknown>,\n\tlayoutKey: string,\n\ttask: Promise<unknown>,\n\tcacheKey: string,\n\tstatusCacheKey: string,\n\tmaxAgeMs: number,\n): Promise<unknown> {\n\tconst result = await task;\n\tssrData[layoutKey] = result;\n\n\tif (maxAgeMs > 0) {\n\t\tstatusCache.set(\n\t\t\tstatusCacheKey,\n\t\t\t(result as { status?: number }).status || 200,\n\t\t\tmaxAgeMs,\n\t\t);\n\t}\n\tif (maxAgeMs > 0) {\n\t\tssrCache.set(cacheKey, result, maxAgeMs);\n\t}\n\n\treturn result;\n}\n\nasync function processLayout(\n\tlayout: Doc,\n\tpathname: string,\n\tclientDir: string,\n\tisWatchMode: boolean,\n\tstreaming: boolean,\n\tmaxAgeMs: number,\n\tsearchParams: URLSearchParams | undefined,\n\tssrData: Record<string, unknown>,\n\tpendingTasks: Promise<unknown>[],\n\theaders?: Record<string, string>,\n): Promise<number | undefined> {\n\tif (typeof layout?.path !== 'string') return undefined;\n\n\tconst ssrExport = await loadLayoutSSRExport(layout, clientDir, isWatchMode);\n\tconst dataFn = ssrExport?.data;\n\n\tif (typeof dataFn !== 'function') return undefined;\n\n\tconst pattern = String(layout.pattern || '/');\n\tconst layoutKey = createLayoutDataKey(pattern);\n\tconst cacheKey = createLayoutCacheKey(pattern, pathname);\n\tconst statusCacheKey = `status:${cacheKey}`;\n\n\tconst { cachedData, cachedStatus } = checkLayoutCache(\n\t\tcacheKey,\n\t\tstatusCacheKey,\n\t\tmaxAgeMs,\n\t);\n\n\tif (cachedStatus && cachedStatus !== 200) {\n\t\treturn cachedStatus;\n\t}\n\n\tif (cachedData !== undefined) {\n\t\tssrData[layoutKey] = cachedData;\n\t\treturn undefined;\n\t}\n\n\tconst set = { status: 200 };\n\tconst task = createLayoutDataTask(\n\t\tdataFn,\n\t\tpathname,\n\t\tsearchParams,\n\t\tpattern,\n\t\theaders,\n\t);\n\n\tif (streaming) {\n\t\thandleLayoutStreamingMode(\n\t\t\tssrData,\n\t\t\tlayoutKey,\n\t\t\ttask,\n\t\t\tset,\n\t\t\tcacheKey,\n\t\t\tstatusCacheKey,\n\t\t\tmaxAgeMs,\n\t\t\tpendingTasks,\n\t\t);\n\t} else {\n\t\tawait handleLayoutNonStreamingMode(\n\t\t\tssrData,\n\t\t\tlayoutKey,\n\t\t\ttask,\n\t\t\tcacheKey,\n\t\t\tstatusCacheKey,\n\t\t\tmaxAgeMs,\n\t\t);\n\t}\n\n\treturn set.status !== 200 ? set.status : undefined;\n}\n\n/**\n * Compute SSR data from all matching layouts for a pathname.\n * Executes layout ssr.data() functions in hierarchical order (root → nested).\n *\n * @param sharedSsrData - In streaming mode, the shared ssrData object that gets passed to React.\n * Promise resolution callbacks must update THIS object directly.\n */\nexport async function computeLayoutData(\n\tpathname: string,\n\tclientDir: string,\n\t_cwd: string,\n\tisWatchMode: boolean,\n\toptions: ComputeOptions,\n\tsearchParams?: URLSearchParams,\n\troutesModule?: Doc,\n\tsharedSsrData?: Record<string, unknown>,\n): Promise<LayoutComputeResult> {\n\tconst streaming = options.streaming === true;\n\tconst ssrData: Record<string, unknown> =\n\t\tstreaming && sharedSsrData ? sharedSsrData : {};\n\tconst pendingTasks: Promise<unknown>[] = [];\n\tlet statusOverride: number | undefined;\n\n\tconst maxAge = options.maxAge || 0;\n\tconst maxAgeMs = maxAge * 1000;\n\n\ttry {\n\t\tconst layouts = routesModule?.layouts as Doc[] | undefined;\n\t\tconst matchingLayouts = getMatchingLayouts(pathname, layouts);\n\n\t\tfor (const layout of matchingLayouts) {\n\t\t\ttry {\n\t\t\t\tconst layoutStatus = await processLayout(\n\t\t\t\t\tlayout,\n\t\t\t\t\tpathname,\n\t\t\t\t\tclientDir,\n\t\t\t\t\tisWatchMode,\n\t\t\t\t\tstreaming,\n\t\t\t\t\tmaxAgeMs,\n\t\t\t\t\tsearchParams,\n\t\t\t\t\tssrData,\n\t\t\t\t\tpendingTasks,\n\t\t\t\t\toptions.headers,\n\t\t\t\t);\n\n\t\t\t\tif (layoutStatus && !statusOverride) {\n\t\t\t\t\tstatusOverride = layoutStatus;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Continue to next layout on error\n\t\t\t}\n\t\t}\n\t} catch {\n\t\t// Return empty data on failure\n\t}\n\n\treturn { data: ssrData, statusOverride, pendingTasks };\n}\n\n/**\n * Merge layout data into route data for non-streaming mode.\n * Users can call useData() without knowing about layout keys.\n */\nexport function mergeLayoutData(\n\tssrData: Record<string, unknown>,\n\tpathname: string,\n): void {\n\tconst layoutKeys = Object.keys(ssrData).filter((key) =>\n\t\tkey.startsWith('__layout:'),\n\t);\n\n\tconst layoutData: Record<string, unknown> = {};\n\tfor (const key of layoutKeys) {\n\t\tObject.assign(layoutData, ssrData[key] as Record<string, unknown>);\n\t}\n\n\tif (pathname in ssrData) {\n\t\tssrData[pathname] = {\n\t\t\t...layoutData,\n\t\t\t...(typeof ssrData[pathname] === 'object' && ssrData[pathname] !== null\n\t\t\t\t? (ssrData[pathname] as Record<string, unknown>)\n\t\t\t\t: {}),\n\t\t};\n\t} else if (Object.keys(layoutData).length > 0) {\n\t\tssrData[pathname] = layoutData;\n\t}\n}\n",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"export * from './bundler';\nexport * from './config';\nexport * from './content';\nexport * from './llms';\nexport * from './og';\nexport * from './robots';\nexport * from './rss';\nexport * from './sitemap';\nexport * from './ssr';\n",
|
|
40
40
|
"export * from './src';\n",
|
|
41
41
|
"import { promises as fs } from 'node:fs';\nimport { join } from 'node:path';\nimport { SourceMapConsumer } from 'source-map';\n\ninterface SourceMappedPosition {\n\tsource: string | null;\n\tline: number | null;\n\tcolumn: number | null;\n\tname: string | null;\n}\n\ninterface StackFrame {\n\traw: string;\n\tfunctionName?: string;\n\tfileName?: string;\n\tlineNumber?: number;\n\tcolumnNumber?: number;\n\tmapped?: SourceMappedPosition;\n}\n\n/**\n * Cache for loaded sourcemaps\n */\nconst sourcemapCache = new Map<string, SourceMapConsumer>();\n\n/**\n * Parse a stack trace line into a structured frame\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Stack frame parsing requires many conditions\nfunction parseStackFrame(line: string): StackFrame {\n\t// Common stack trace patterns:\n\t// at functionName (file:line:column)\n\t// at file:line:column\n\t// at <anonymous>\n\n\tconst patterns = [\n\t\t// Chrome/V8: at functionName (file:line:column)\n\t\t/^\\s*at\\s+(.+?)\\s+\\((.+?):(\\d+):(\\d+)\\)/,\n\t\t// Chrome/V8: at file:line:column\n\t\t/^\\s*at\\s+(.+?):(\\d+):(\\d+)/,\n\t\t// Firefox: functionName@file:line:column\n\t\t/^(.+?)@(.+?):(\\d+):(\\d+)/,\n\t];\n\n\tfor (const pattern of patterns) {\n\t\tconst match = line.match(pattern);\n\t\tif (match) {\n\t\t\tif (match.length === 5 && match[2]) {\n\t\t\t\t// Pattern with function name\n\t\t\t\treturn {\n\t\t\t\t\traw: line,\n\t\t\t\t\tfunctionName: match[1].trim(),\n\t\t\t\t\tfileName: match[2],\n\t\t\t\t\tlineNumber: Number.parseInt(match[3], 10),\n\t\t\t\t\tcolumnNumber: Number.parseInt(match[4], 10),\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (match.length === 4 && match[1]) {\n\t\t\t\t// Pattern without function name or Firefox pattern\n\t\t\t\tconst hasAt = line.includes('@');\n\t\t\t\treturn {\n\t\t\t\t\traw: line,\n\t\t\t\t\tfunctionName: hasAt ? match[1] : undefined,\n\t\t\t\t\tfileName: hasAt ? match[2] : match[1],\n\t\t\t\t\tlineNumber: Number.parseInt(hasAt ? match[3] : match[2], 10),\n\t\t\t\t\tcolumnNumber: Number.parseInt(hasAt ? match[4] : match[3], 10),\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { raw: line };\n}\n\n/**\n * Find and load a sourcemap for a given file\n */\nasync function loadSourceMap(\n\tfileName: string,\n\trerouteDir?: string,\n): Promise<SourceMapConsumer | null> {\n\t// Check cache first\n\tif (sourcemapCache.has(fileName)) {\n\t\treturn sourcemapCache.get(fileName) || null;\n\t}\n\n\ttry {\n\t\t// Common locations to check for sourcemaps\n\t\tconst possiblePaths: string[] = [];\n\n\t\t// If we have a .reroute directory, look there\n\t\tif (rerouteDir) {\n\t\t\t// Extract just the filename from the path\n\t\t\tconst baseName = fileName.split('/').pop() || fileName;\n\t\t\tpossiblePaths.push(join(rerouteDir, 'bundles', `${baseName}.map`));\n\t\t}\n\n\t\t// Also try adjacent to the file\n\t\tpossiblePaths.push(`${fileName}.map`);\n\n\t\tfor (const mapPath of possiblePaths) {\n\t\t\ttry {\n\t\t\t\tconst mapContent = await fs.readFile(mapPath, 'utf-8');\n\t\t\t\tconst consumer = await new SourceMapConsumer(mapContent);\n\t\t\t\tsourcemapCache.set(fileName, consumer);\n\t\t\t\treturn consumer;\n\t\t\t} catch {}\n\t\t}\n\n\t\treturn null;\n\t} catch (error) {\n\t\tconsole.error(\n\t\t\t`[sourcemap] Failed to load sourcemap for ${fileName}:`,\n\t\t\terror,\n\t\t);\n\t\treturn null;\n\t}\n}\n\n/**\n * Map a position using a sourcemap consumer\n */\nfunction mapPosition(\n\tconsumer: SourceMapConsumer,\n\tline: number,\n\tcolumn: number,\n): SourceMappedPosition {\n\tconst pos = consumer.originalPositionFor({ line, column });\n\treturn {\n\t\tsource: pos.source,\n\t\tline: pos.line,\n\t\tcolumn: pos.column,\n\t\tname: pos.name,\n\t};\n}\n\n/**\n * Process a stack trace and resolve source positions\n */\nexport async function resolveStackTrace(\n\tstack: string,\n\toptions: {\n\t\trerouteDir?: string;\n\t\tcwd?: string;\n\t} = {},\n): Promise<{\n\toriginal: string;\n\tframes: StackFrame[];\n\tmapped: string;\n}> {\n\tconst lines = stack.split('\\n');\n\tconst frames: StackFrame[] = [];\n\n\tfor (const line of lines) {\n\t\tconst frame = parseStackFrame(line);\n\t\tif (frame?.fileName && frame.lineNumber && frame.columnNumber) {\n\t\t\ttry {\n\t\t\t\tconst consumer = await loadSourceMap(\n\t\t\t\t\tframe.fileName,\n\t\t\t\t\toptions.rerouteDir,\n\t\t\t\t);\n\t\t\t\tif (consumer) {\n\t\t\t\t\tframe.mapped = mapPosition(\n\t\t\t\t\t\tconsumer,\n\t\t\t\t\t\tframe.lineNumber,\n\t\t\t\t\t\tframe.columnNumber,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (_error) {\n\t\t\t\t// Keep frame without mapping\n\t\t\t}\n\t\t}\n\t\tframes.push(frame);\n\t}\n\n\t// Generate mapped stack trace\n\tconst mappedLines = frames.map((frame) => {\n\t\tif (frame.mapped?.source && frame.mapped.line !== null) {\n\t\t\tconst location = `${frame.mapped.source}:${frame.mapped.line}:${frame.mapped.column ?? 0}`;\n\t\t\tif (frame.mapped.name || frame.functionName) {\n\t\t\t\treturn ` at ${frame.mapped.name || frame.functionName} (${location})`;\n\t\t\t}\n\t\t\treturn ` at ${location}`;\n\t\t}\n\t\treturn frame.raw;\n\t});\n\n\treturn {\n\t\toriginal: stack,\n\t\tframes,\n\t\tmapped: mappedLines.join('\\n'),\n\t};\n}\n\n/**\n * Enhance error with source-mapped stack trace\n * Adds a `sourceMappedStack` property to the error object\n */\nexport async function enhanceError(\n\terror: Error,\n\toptions: {\n\t\trerouteDir?: string;\n\t\tcwd?: string;\n\t} = {},\n): Promise<Error & { sourceMappedStack?: string; stackFrames?: StackFrame[] }> {\n\tif (!error.stack) return error;\n\n\ttry {\n\t\tconst result = await resolveStackTrace(error.stack, options);\n\t\t// Attach enhanced info to the error object\n\t\t(\n\t\t\terror as Error & {\n\t\t\t\tsourceMappedStack?: string;\n\t\t\t\tstackFrames?: StackFrame[];\n\t\t\t}\n\t\t).sourceMappedStack = result.mapped;\n\t\t(error as Error & { stackFrames?: StackFrame[] }).stackFrames =\n\t\t\tresult.frames;\n\t} catch {\n\t\t// Silently fail - source mapping is optional\n\t}\n\n\treturn error;\n}\n\n/**\n * Clear the sourcemap cache (useful for development)\n */\nexport function clearSourceMapCache(): void {\n\tfor (const consumer of sourcemapCache.values()) {\n\t\tconsumer.destroy();\n\t}\n\tsourcemapCache.clear();\n}\n\n/**\n * Format stack frames for display\n */\nexport function formatStackFrames(frames: StackFrame[]): string {\n\treturn frames\n\t\t.map((frame) => {\n\t\t\tif (frame.mapped?.source && frame.mapped.line !== null) {\n\t\t\t\tconst location = `${frame.mapped.source}:${frame.mapped.line}:${frame.mapped.column ?? 0}`;\n\t\t\t\tif (frame.mapped.name || frame.functionName) {\n\t\t\t\t\treturn ` at ${frame.mapped.name || frame.functionName} (${location})`;\n\t\t\t\t}\n\t\t\t\treturn ` at ${location}`;\n\t\t\t}\n\t\t\treturn frame.raw;\n\t\t})\n\t\t.join('\\n');\n}\n",
|
|
42
|
-
"import os from 'node:os';\nimport {\n\ttype Counter,\n\tcontext,\n\ttype Histogram,\n\tmetrics,\n\ttype Span,\n\tSpanStatusCode,\n\ttrace,\n\ttype UpDownCounter,\n} from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-proto';\nimport { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport {\n\tBatchLogRecordProcessor,\n\tLoggerProvider,\n} from '@opentelemetry/sdk-logs';\nimport {\n\tMeterProvider,\n\tPeriodicExportingMetricReader,\n} from '@opentelemetry/sdk-metrics';\nimport {\n\tBatchSpanProcessor,\n\tNodeTracerProvider,\n} from '@opentelemetry/sdk-trace-node';\nimport {\n\tATTR_SERVICE_NAME,\n\tATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { ATTR_HOST_NAME } from '@opentelemetry/semantic-conventions/incubating';\nimport type { Elysia } from 'elysia';\nimport { loadConfig, type TelemetryOptions } from 'reroute-js/core';\nimport { getContextAttributesForTelemetry } from './context';\nimport { extractHeaders } from './headers/extractor';\nimport { extractTraceContext } from './instrumentation';\nimport { enhanceError } from './sourcemap';\n\n/**\n * Server telemetry options\n * Extends TelemetryOptions from config - all options can be set in reroute.config.ts\n * or passed directly here (direct options override config values)\n */\nexport interface ServerTelemetryOptions extends TelemetryOptions {}\n\n// Helper to extract error details\nfunction getErrorDetails(error: unknown): {\n\tname: string;\n\tmessage: string;\n\tstack: string;\n} {\n\tif (error instanceof Error) {\n\t\treturn {\n\t\t\tname: error.name,\n\t\t\tmessage: error.message,\n\t\t\tstack: error.stack || '',\n\t\t};\n\t}\n\n\tif (typeof error === 'object' && error !== null) {\n\t\tconst err = error as Record<string, unknown>;\n\t\treturn {\n\t\t\tname: String(err.name || err.code || 'UnknownError'),\n\t\t\tmessage: String(err.message || err.error || JSON.stringify(error)),\n\t\t\tstack: String(err.stack || ''),\n\t\t};\n\t}\n\n\treturn {\n\t\tname: 'UnknownError',\n\t\tmessage: String(error),\n\t\tstack: '',\n\t};\n}\n\n/**\n * Check if a route should be ignored based on ignore patterns\n * Supports strings, RegExp, and custom functions\n */\nfunction shouldIgnoreRoute(\n\tpatterns: (\n\t\t| string\n\t\t| RegExp\n\t\t| ((pathname: string, method: string) => boolean)\n\t)[],\n\tpathname: string,\n\tmethod: string,\n): boolean {\n\treturn patterns.some((pattern) => {\n\t\tif (typeof pattern === 'string') {\n\t\t\treturn pathname.includes(pattern);\n\t\t}\n\t\tif (pattern instanceof RegExp) {\n\t\t\treturn pattern.test(pathname);\n\t\t}\n\t\tif (typeof pattern === 'function') {\n\t\t\treturn pattern(pathname, method);\n\t\t}\n\t\treturn false;\n\t});\n}\n\n/**\n * Determine if a request should be sampled based on sample rate\n * @param rate - Sample rate between 0.0 and 1.0\n * @returns true if request should be sampled\n */\nfunction shouldSample(rate: number): boolean {\n\treturn Math.random() < rate;\n}\n\n/**\n * Server-side telemetry plugin for Elysia\n *\n * Automatically captures:\n * - HTTP requests and responses\n * - Errors with full stack traces\n * - System metrics (CPU, memory)\n * - Request/response sizes\n * - Active connections\n *\n * Configuration is loaded from reroute.config.ts automatically.\n * Direct options override config values.\n *\n * @example\n * ```typescript\n * import { Elysia } from 'elysia';\n * import { telemetry } from 'reroute-js/telemetry/server';\n *\n * new Elysia()\n * .use(telemetry({\n * serviceName: 'My App',\n * }))\n * .listen(3000);\n * ```\n */\nexport function telemetry(options: ServerTelemetryOptions = {}) {\n\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Telemetry initialization with config loading and feature toggles\n\treturn async (app: Elysia) => {\n\t\t// Load reroute.config.ts automatically\n\t\tconst cwd =\n\t\t\ttypeof process !== 'undefined' && typeof process.cwd === 'function'\n\t\t\t\t? process.cwd()\n\t\t\t\t: '/';\n\t\tconst config = await loadConfig(cwd);\n\n\t\t// Merge config with direct options (direct options take precedence)\n\t\tconst merged = {\n\t\t\t...config.telemetry,\n\t\t\t...options,\n\t\t};\n\n\t\t// Check if telemetry is enabled (default: false)\n\t\tconst TELEMETRY_ENABLED = merged.enabled ?? false;\n\t\tif (!TELEMETRY_ENABLED) {\n\t\t\tconsole.log(\n\t\t\t\t'[telemetry] Disabled - set enabled: true in config or options to enable',\n\t\t\t);\n\t\t\t// Return app unchanged when disabled\n\t\t\treturn app;\n\t\t}\n\n\t\t// Extract configuration values\n\t\tconst SERVICE_NAME = merged.serviceName || 'reroute-app';\n\t\tconst SERVICE_VERSION =\n\t\t\tmerged.serviceVersion || process.env.npm_package_version || '1.0.0';\n\t\tconst OTLP_ENDPOINT =\n\t\t\tmerged.otlpEndpoint ||\n\t\t\tprocess.env.OTEL_EXPORTER_OTLP_ENDPOINT ||\n\t\t\t'http://localhost:4318';\n\t\tconst METRICS_INTERVAL = merged.metricsInterval ?? 5000;\n\n\t\t// Handle proxy configuration\n\t\tconst proxyConfig = merged.proxy;\n\t\tconst ENABLE_PROXY = proxyConfig?.enabled ?? !!proxyConfig;\n\t\tconst PROXY_PATHNAME = proxyConfig?.pathname ?? '/__reroute_telemetry';\n\t\tconst PROXY_VERBOSE = proxyConfig?.verbose ?? false;\n\t\tconst PROXY_HANDLER = proxyConfig?.handler;\n\n\t\t// Feature toggles (default: true when telemetry is enabled)\n\t\tconst ENABLE_TRACES = merged.enableTraces ?? true;\n\t\tconst ENABLE_METRICS = merged.enableMetrics ?? true;\n\t\tconst ENABLE_LOGS = merged.enableLogs ?? true;\n\t\tconst ENABLE_SYSTEM_METRICS = merged.enableSystemMetrics ?? true;\n\n\t\t// Sampling configuration\n\t\tconst SAMPLE_RATE = merged.sampleRate ?? 1.0;\n\t\tconst ERROR_SAMPLE_RATE = merged.errorSampleRate ?? 1.0;\n\n\t\t// Route filtering\n\t\tconst IGNORE_ROUTES = merged.ignoreRoutes || [];\n\n\t\t// Header capture and custom attributes\n\t\tconst CAPTURE_MAPPINGS = merged.capture || [];\n\t\tconst CUSTOM_ATTRIBUTES = merged.customAttributes || {};\n\n\t\tconsole.log(`[telemetry] Initializing with endpoint: ${OTLP_ENDPOINT}`);\n\t\tconsole.log(\n\t\t\t`[telemetry] Features - Traces: ${ENABLE_TRACES}, Metrics: ${ENABLE_METRICS}, Logs: ${ENABLE_LOGS}`,\n\t\t);\n\t\tif (SAMPLE_RATE < 1.0) {\n\t\t\tconsole.log(\n\t\t\t\t`[telemetry] Sampling - Requests: ${SAMPLE_RATE * 100}%, Errors: ${ERROR_SAMPLE_RATE * 100}%`,\n\t\t\t);\n\t\t}\n\t\tif (ENABLE_PROXY) {\n\t\t\tconsole.log(\n\t\t\t\t`[telemetry] Browser telemetry proxy enabled at ${PROXY_PATHNAME}/*`,\n\t\t\t);\n\t\t}\n\n\t\t// Secure headers for API authentication (optional)\n\t\tconst otlpHeaders: Record<string, string> = {};\n\t\tif (merged.apiKey || process.env.SIGNOZ_API_KEY) {\n\t\t\totlpHeaders.Authorization = `Bearer ${merged.apiKey || process.env.SIGNOZ_API_KEY}`;\n\t\t}\n\n\t\t// Configure OTLP exporters with timeouts (conditionally based on feature toggles)\n\t\tconst traceExporter = ENABLE_TRACES\n\t\t\t? new OTLPTraceExporter({\n\t\t\t\t\turl: `${OTLP_ENDPOINT}/v1/traces`,\n\t\t\t\t\theaders:\n\t\t\t\t\t\tObject.keys(otlpHeaders).length > 0 ? otlpHeaders : undefined,\n\t\t\t\t\ttimeoutMillis: 5000, // 5 second timeout\n\t\t\t\t})\n\t\t\t: null;\n\n\t\tconst logExporter = ENABLE_LOGS\n\t\t\t? new OTLPLogExporter({\n\t\t\t\t\turl: `${OTLP_ENDPOINT}/v1/logs`,\n\t\t\t\t\theaders:\n\t\t\t\t\t\tObject.keys(otlpHeaders).length > 0 ? otlpHeaders : undefined,\n\t\t\t\t\ttimeoutMillis: 5000, // 5 second timeout\n\t\t\t\t})\n\t\t\t: null;\n\n\t\tconst metricExporter = ENABLE_METRICS\n\t\t\t? new OTLPMetricExporter({\n\t\t\t\t\turl: `${OTLP_ENDPOINT}/v1/metrics`,\n\t\t\t\t\theaders:\n\t\t\t\t\t\tObject.keys(otlpHeaders).length > 0 ? otlpHeaders : undefined,\n\t\t\t\t\ttimeoutMillis: 5000, // 5 second timeout\n\t\t\t\t})\n\t\t\t: null;\n\n\t\t// Create resource with service information\n\t\t// In Docker, prefer env var over os.hostname() (which returns container ID)\n\t\tconst HOSTNAME =\n\t\t\tprocess.env.OTEL_RESOURCE_ATTRIBUTES?.match(/host\\.name=([^,]+)/)?.[1] ||\n\t\t\tprocess.env.HOSTNAME ||\n\t\t\tos.hostname();\n\n\t\tconst resource = resourceFromAttributes({\n\t\t\t[ATTR_SERVICE_NAME]: SERVICE_NAME,\n\t\t\t[ATTR_SERVICE_VERSION]: SERVICE_VERSION,\n\t\t\t[ATTR_HOST_NAME]: HOSTNAME,\n\t\t});\n\n\t\t// Set up Traces with error handling (only if enabled)\n\t\tif (ENABLE_TRACES && traceExporter) {\n\t\t\ttry {\n\t\t\t\tconst tracerProvider = new NodeTracerProvider({\n\t\t\t\t\tresource,\n\t\t\t\t\tspanProcessors: [new BatchSpanProcessor(traceExporter)],\n\t\t\t\t});\n\t\t\t\ttracerProvider.register();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to initialize tracer:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Set up Logs with error handling (only if enabled)\n\t\tlet logger: ReturnType<LoggerProvider['getLogger']> | null = null;\n\t\tif (ENABLE_LOGS && logExporter) {\n\t\t\ttry {\n\t\t\t\tconst loggerProvider = new LoggerProvider({\n\t\t\t\t\tresource,\n\t\t\t\t\tprocessors: [new BatchLogRecordProcessor(logExporter)],\n\t\t\t\t});\n\t\t\t\tlogs.setGlobalLoggerProvider(loggerProvider);\n\t\t\t\tlogger = loggerProvider.getLogger(SERVICE_NAME, SERVICE_VERSION);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to initialize logger:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Set up Metrics with error handling (only if enabled)\n\t\tlet meter: ReturnType<MeterProvider['getMeter']> | null = null;\n\t\tif (ENABLE_METRICS && metricExporter) {\n\t\t\ttry {\n\t\t\t\tconst meterProvider = new MeterProvider({\n\t\t\t\t\tresource,\n\t\t\t\t\treaders: [\n\t\t\t\t\t\tnew PeriodicExportingMetricReader({\n\t\t\t\t\t\t\texporter: metricExporter,\n\t\t\t\t\t\t\texportIntervalMillis: METRICS_INTERVAL,\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\tmetrics.setGlobalMeterProvider(meterProvider);\n\t\t\t\tmeter = meterProvider.getMeter(SERVICE_NAME, SERVICE_VERSION);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to initialize meter:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Create HTTP metrics with null checks\n\t\tlet httpRequestCounter: Counter | null = null;\n\t\tlet httpRequestDuration: Histogram | null = null;\n\t\tlet httpErrorCounter: Counter | null = null;\n\t\tlet httpActiveRequests: UpDownCounter | null = null;\n\t\tlet activeConnections: UpDownCounter | null = null;\n\n\t\tif (meter) {\n\t\t\ttry {\n\t\t\t\thttpRequestCounter = meter.createCounter('http.server.request.count', {\n\t\t\t\t\tdescription: 'Total HTTP requests',\n\t\t\t\t\tunit: 'requests',\n\t\t\t\t});\n\n\t\t\t\thttpRequestDuration = meter.createHistogram(\n\t\t\t\t\t'http.server.request.duration',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'HTTP request duration',\n\t\t\t\t\t\tunit: 'milliseconds',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\thttpErrorCounter = meter.createCounter('http.server.error.count', {\n\t\t\t\t\tdescription: 'Total HTTP errors',\n\t\t\t\t\tunit: 'errors',\n\t\t\t\t});\n\n\t\t\t\thttpActiveRequests = meter.createUpDownCounter(\n\t\t\t\t\t'http.server.active_requests',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'Active HTTP requests',\n\t\t\t\t\t\tunit: 'requests',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tactiveConnections = meter.createUpDownCounter(\n\t\t\t\t\t'app.connections.active',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'Active connections',\n\t\t\t\t\t\tunit: 'connections',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to create HTTP metrics:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Create system metrics (optional) with error handling\n\t\tif (ENABLE_SYSTEM_METRICS && meter) {\n\t\t\ttry {\n\t\t\t\t// Reuse HOSTNAME from resource (already computed above)\n\n\t\t\t\tconst memoryUsage = meter.createObservableGauge('app.memory.usage', {\n\t\t\t\t\tdescription: 'Process memory usage',\n\t\t\t\t\tunit: 'bytes',\n\t\t\t\t});\n\n\t\t\t\tmemoryUsage.addCallback((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst usage = process.memoryUsage();\n\t\t\t\t\t\tresult.observe(usage.heapUsed, {\n\t\t\t\t\t\t\ttype: 'heap',\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresult.observe(usage.rss, { type: 'rss', 'host.name': HOSTNAME });\n\t\t\t\t\t\tresult.observe(usage.external, {\n\t\t\t\t\t\t\ttype: 'external',\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] Memory usage callback failed:', error);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tconst systemCpuUsage = meter.createObservableGauge(\n\t\t\t\t\t'system.cpu.utilization',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'System CPU utilization',\n\t\t\t\t\t\tunit: '1',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tsystemCpuUsage.addCallback((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst cpus = os.cpus();\n\t\t\t\t\t\tlet totalIdle = 0;\n\t\t\t\t\t\tlet totalTick = 0;\n\n\t\t\t\t\t\tcpus.forEach((cpu) => {\n\t\t\t\t\t\t\tconst times = cpu.times;\n\t\t\t\t\t\t\ttotalIdle += times.idle;\n\t\t\t\t\t\t\ttotalTick +=\n\t\t\t\t\t\t\t\ttimes.user + times.nice + times.sys + times.idle + times.irq;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst usage = 1 - totalIdle / totalTick;\n\t\t\t\t\t\tresult.observe(usage, {\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] CPU usage callback failed:', error);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tconst systemMemoryUsage = meter.createObservableGauge(\n\t\t\t\t\t'system.memory.utilization',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'System memory utilization',\n\t\t\t\t\t\tunit: '1',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tsystemMemoryUsage.addCallback((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst totalMem = os.totalmem();\n\t\t\t\t\t\tconst freeMem = os.freemem();\n\t\t\t\t\t\tconst usage = (totalMem - freeMem) / totalMem;\n\n\t\t\t\t\t\tresult.observe(usage, {\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] System memory callback failed:', error);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to create system metrics:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Graceful shutdown with error handling\n\t\tconst shutdown = async () => {\n\t\t\tconsole.log('[telemetry] Shutting down...');\n\t\t\ttry {\n\t\t\t\t// Note: We can't reference loggerProvider/meterProvider here since they're in try blocks\n\t\t\t\t// The providers will be cleaned up automatically\n\t\t\t\tawait logs.disable();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Shutdown error:', error);\n\t\t\t}\n\t\t};\n\n\t\tprocess.on('SIGTERM', async () => {\n\t\t\tawait shutdown();\n\t\t\tprocess.exit(0);\n\t\t});\n\n\t\t// Initialize tracer for manual span creation\n\t\tlet tracer: ReturnType<typeof trace.getTracer> | null = null;\n\t\tif (ENABLE_TRACES && traceExporter) {\n\t\t\ttracer = trace.getTracer(SERVICE_NAME, SERVICE_VERSION);\n\t\t}\n\n\t\t// Setup global console.error capture for automatic error telemetry\n\t\t// This captures errors that are caught and logged but not thrown\n\t\tconst ENABLE_CONSOLE_CAPTURE = merged.enableConsoleCapture ?? true;\n\t\tif (ENABLE_CONSOLE_CAPTURE && tracer) {\n\t\t\tconst originalError = console.error;\n\t\t\tconst originalWarn = console.warn;\n\n\t\t\t// Don't override if already captured (e.g., in tests)\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\tif (!(originalError as any).__telemetry_captured__) {\n\t\t\t\tconst errorTracer = trace.getTracer('console-error');\n\n\t\t\t\t/** biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Console error capture */\n\t\t\t\tconsole.error = (...args: unknown[]) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Create a span for this console.error\n\t\t\t\t\t\tconst span = errorTracer.startSpan('server.console.error');\n\n\t\t\t\t\t\t// Try to extract error information\n\t\t\t\t\t\tconst firstArg = args[0];\n\t\t\t\t\t\tlet errorMessage = args.map(String).join(' ');\n\t\t\t\t\t\tlet errorStack = '';\n\t\t\t\t\t\tlet errorType = 'ConsoleError';\n\n\t\t\t\t\t\tif (firstArg instanceof Error) {\n\t\t\t\t\t\t\terrorMessage = firstArg.message;\n\t\t\t\t\t\t\terrorStack = firstArg.stack || '';\n\t\t\t\t\t\t\terrorType = firstArg.name;\n\n\t\t\t\t\t\t\t// Enhance error with source maps if available\n\t\t\t\t\t\t\tconst rerouteDir = '.reroute';\n\t\t\t\t\t\t\tif (rerouteDir && firstArg.stack) {\n\t\t\t\t\t\t\t\tenhanceError(firstArg, { rerouteDir })\n\t\t\t\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\t\t\t\tconst enhancedError = firstArg as Error & {\n\t\t\t\t\t\t\t\t\t\t\tsourceMappedStack?: string;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif (enhancedError.sourceMappedStack) {\n\t\t\t\t\t\t\t\t\t\t\terrorStack = enhancedError.sourceMappedStack;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\t\t\t// Silently fail sourcemap enhancement\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\t\tmessage: errorMessage,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t'log.level': 'error',\n\t\t\t\t\t\t\t'log.message': errorMessage,\n\t\t\t\t\t\t\t'error.type': errorType,\n\t\t\t\t\t\t\t...(errorStack ? { 'error.stack': errorStack } : {}),\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t...getContextAttributesForTelemetry(),\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (firstArg instanceof Error) {\n\t\t\t\t\t\t\tspan.recordException(firstArg);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tspan.end();\n\n\t\t\t\t\t\t// Also emit as log if logger is available\n\t\t\t\t\t\tif (logger) {\n\t\t\t\t\t\t\tlogger.emit({\n\t\t\t\t\t\t\t\tseverityNumber: SeverityNumber.ERROR,\n\t\t\t\t\t\t\t\tseverityText: 'ERROR',\n\t\t\t\t\t\t\t\tbody: errorMessage,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'log.level': 'error',\n\t\t\t\t\t\t\t\t\t'error.type': errorType,\n\t\t\t\t\t\t\t\t\t...(errorStack ? { 'error.stack': errorStack } : {}),\n\t\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Silently fail - don't break console.error\n\t\t\t\t\t}\n\n\t\t\t\t\t// Call original console.error\n\t\t\t\t\toriginalError.apply(console, args);\n\t\t\t\t};\n\n\t\t\t\t// Mark as captured to prevent double-wrapping\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\t\t(console.error as any).__telemetry_captured__ = true;\n\n\t\t\t\tconsole.log('[telemetry] Console error capture enabled');\n\t\t\t}\n\n\t\t\t// Also capture console.warn for completeness\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\tif (!(originalWarn as any).__telemetry_captured__) {\n\t\t\t\tconst warnTracer = trace.getTracer('console-warn');\n\n\t\t\t\tconsole.warn = (...args: unknown[]) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst span = warnTracer.startSpan('server.console.warn');\n\t\t\t\t\t\tconst message = args.map(String).join(' ');\n\n\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t'log.level': 'warn',\n\t\t\t\t\t\t\t'log.message': message,\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t...getContextAttributesForTelemetry(),\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tspan.end();\n\n\t\t\t\t\t\tif (logger) {\n\t\t\t\t\t\t\tlogger.emit({\n\t\t\t\t\t\t\t\tseverityNumber: SeverityNumber.WARN,\n\t\t\t\t\t\t\t\tseverityText: 'WARN',\n\t\t\t\t\t\t\t\tbody: message,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'log.level': 'warn',\n\t\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Silently fail\n\t\t\t\t\t}\n\n\t\t\t\t\toriginalWarn.apply(console, args);\n\t\t\t\t};\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\t\t(console.warn as any).__telemetry_captured__ = true;\n\t\t\t}\n\t\t}\n\n\t\tapp = app\n\t\t\t// Track incoming requests\n\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Request tracking with filtering and sampling\n\t\t\t.onBeforeHandle(({ request, store }) => {\n\t\t\t\tconst startTime = Date.now();\n\t\t\t\tconst url = new URL(request.url);\n\t\t\t\tconst route = url.pathname;\n\t\t\t\tconst method = request.method;\n\n\t\t\t\t(store as Record<string, unknown>).startTime = startTime;\n\t\t\t\t(store as Record<string, unknown>).route = route;\n\n\t\t\t\t// Check if route should be ignored\n\t\t\t\tconst shouldIgnore =\n\t\t\t\t\tIGNORE_ROUTES.length > 0 &&\n\t\t\t\t\tshouldIgnoreRoute(IGNORE_ROUTES, route, method);\n\t\t\t\t(store as Record<string, unknown>).shouldIgnoreTelemetry = shouldIgnore;\n\n\t\t\t\t// Apply sampling (skip if ignored or not sampled)\n\t\t\t\tif (!shouldIgnore) {\n\t\t\t\t\tconst sampled = shouldSample(SAMPLE_RATE);\n\t\t\t\t\t(store as Record<string, unknown>).isSampled = sampled;\n\t\t\t\t\tif (!sampled) {\n\t\t\t\t\t\t(store as Record<string, unknown>).shouldIgnoreTelemetry = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Extract incoming trace context from browser (if present)\n\t\t\t\t// This allows browser spans to link to server spans\n\t\t\t\tconst incomingContext = extractTraceContext(request.headers);\n\n\t\t\t\t// Create manual span for request if traces enabled and not ignored\n\t\t\t\tif (\n\t\t\t\t\ttracer &&\n\t\t\t\t\t!(store as Record<string, unknown>).shouldIgnoreTelemetry\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Extract mapped headers early for span creation\n\t\t\t\t\t\tconst mappedHeaders =\n\t\t\t\t\t\t\tCAPTURE_MAPPINGS.length > 0\n\t\t\t\t\t\t\t\t? extractHeaders(request.headers, CAPTURE_MAPPINGS)\n\t\t\t\t\t\t\t\t: {};\n\n\t\t\t\t\t\t// Create span within extracted context (if available)\n\t\t\t\t\t\tconst createSpan = () => {\n\t\t\t\t\t\t\treturn tracer.startSpan(`${method} ${route}`, {\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t\t\t\t\t'host.address': url.host,\n\t\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t\t...mappedHeaders,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst span = incomingContext\n\t\t\t\t\t\t\t? context.with(incomingContext, createSpan)\n\t\t\t\t\t\t\t: createSpan();\n\n\t\t\t\t\t\t// Add session attributes if any\n\t\t\t\t\t\tconst sessionAttrs = getContextAttributesForTelemetry();\n\t\t\t\t\t\tif (Object.keys(sessionAttrs).length > 0) {\n\t\t\t\t\t\t\tspan.setAttributes(sessionAttrs);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t(store as Record<string, unknown>).telemetrySpan = span;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] Failed to create span:', error);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Always track active connections for metrics accuracy\n\t\t\t\ttry {\n\t\t\t\t\tactiveConnections?.add(1);\n\t\t\t\t\thttpActiveRequests?.add(1, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\troute,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to track active requests:', error);\n\t\t\t\t}\n\n\t\t\t\t// Skip detailed telemetry if ignored or not sampled\n\t\t\t\tif ((store as Record<string, unknown>).shouldIgnoreTelemetry) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Capture mapped headers\n\t\t\t\tconst mappedHeaders =\n\t\t\t\t\tCAPTURE_MAPPINGS.length > 0\n\t\t\t\t\t\t? extractHeaders(request.headers, CAPTURE_MAPPINGS)\n\t\t\t\t\t\t: {};\n\n\t\t\t\t// Build attributes with custom attributes and captured headers\n\t\t\t\tconst baseAttributes = {\n\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t'http.route': route,\n\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t'host.address': url.host,\n\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t...mappedHeaders,\n\t\t\t\t};\n\n\t\t\t\t// Log incoming request - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\tlogger?.emit({\n\t\t\t\t\t\tseverityNumber: SeverityNumber.INFO,\n\t\t\t\t\t\tseverityText: 'INFO',\n\t\t\t\t\t\tbody: `→ ${method} ${route}`,\n\t\t\t\t\t\tattributes: baseAttributes,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to log incoming request:', error);\n\t\t\t\t}\n\n\t\t\t\t// Increment request counter - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\thttpRequestCounter?.add(1, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'[telemetry] Failed to increment request counter:',\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t// Handle errors with full context\n\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Error handling with context\n\t\t\t.onError(async ({ error, request, set, store }) => {\n\t\t\t\tconst errorDetails = getErrorDetails(error);\n\t\t\t\tconst duration =\n\t\t\t\t\tDate.now() -\n\t\t\t\t\t(((store as Record<string, unknown>).startTime as number) ||\n\t\t\t\t\t\tDate.now());\n\n\t\t\t\t// Check if this error should be sampled (errors have their own sample rate)\n\t\t\t\tconst url = new URL(request.url);\n\t\t\t\tconst route = url.pathname;\n\t\t\t\tconst method = request.method;\n\t\t\t\tconst shouldIgnore =\n\t\t\t\t\tIGNORE_ROUTES.length > 0 &&\n\t\t\t\t\tshouldIgnoreRoute(IGNORE_ROUTES, route, method);\n\n\t\t\t\t// Apply error sampling (separate from regular request sampling)\n\t\t\t\tconst errorSampled = shouldSample(ERROR_SAMPLE_RATE);\n\t\t\t\tconst skipTelemetry = shouldIgnore || !errorSampled;\n\n\t\t\t\t// Record exception in manual span - wrapped in try/catch to prevent blocking\n\t\t\t\tif (!skipTelemetry) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst span = (store as Record<string, unknown>).telemetrySpan as\n\t\t\t\t\t\t\t| Span\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tif (span) {\n\t\t\t\t\t\t\tconst errorObj =\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(errorDetails.message);\n\n\t\t\t\t\t\t\t// Enhance error with source maps if available\n\t\t\t\t\t\t\tconst rerouteDir = '.reroute';\n\t\t\t\t\t\t\tif (rerouteDir && errorObj.stack) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait enhanceError(errorObj, { rerouteDir });\n\t\t\t\t\t\t\t\t} catch (smError) {\n\t\t\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\t\t'[telemetry] Sourcemap enhancement failed:',\n\t\t\t\t\t\t\t\t\t\tsmError,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tspan.recordException(errorObj);\n\t\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\t\t\tmessage: `${errorDetails.name}: ${errorDetails.message}`,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst enhancedError = errorObj as Error & {\n\t\t\t\t\t\t\t\tsourceMappedStack?: string;\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst stackToUse =\n\t\t\t\t\t\t\t\tenhancedError.sourceMappedStack || errorDetails.stack;\n\n\t\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t'error.type': errorDetails.name,\n\t\t\t\t\t\t\t\t'error.message': errorDetails.message,\n\t\t\t\t\t\t\t\t'error.stack': errorDetails.stack,\n\t\t\t\t\t\t\t\t...(enhancedError.sourceMappedStack\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t'error.stack.decoded': enhancedError.sourceMappedStack,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t'http.response.status_code':\n\t\t\t\t\t\t\t\t\ttypeof set.status === 'number' ? set.status : 500,\n\t\t\t\t\t\t\t\t'http.duration_ms': duration,\n\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t...getContextAttributesForTelemetry(),\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tspan.addEvent('exception', {\n\t\t\t\t\t\t\t\t'exception.type': errorDetails.name,\n\t\t\t\t\t\t\t\t'exception.message': errorDetails.message,\n\t\t\t\t\t\t\t\t'exception.stacktrace': stackToUse,\n\t\t\t\t\t\t\t\t'exception.escaped': 'false',\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t// End the span here since onAfterResponse won't handle errors\n\t\t\t\t\t\t\tspan.end();\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (spanError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t'[telemetry] Failed to record exception in span:',\n\t\t\t\t\t\t\tspanError,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Log error - wrapped in try/catch to prevent blocking\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlogger?.emit({\n\t\t\t\t\t\t\tseverityNumber: SeverityNumber.ERROR,\n\t\t\t\t\t\t\tseverityText: 'ERROR',\n\t\t\t\t\t\t\tbody: `${errorDetails.name}: ${errorDetails.message}`,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t'error.type': errorDetails.name,\n\t\t\t\t\t\t\t\t'error.message': errorDetails.message,\n\t\t\t\t\t\t\t\t'error.stack': errorDetails.stack,\n\t\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t\t\t\t'http.response.status_code':\n\t\t\t\t\t\t\t\t\ttypeof set.status === 'number' ? set.status : 500,\n\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (logError) {\n\t\t\t\t\t\tconsole.error('[telemetry] Failed to log error:', logError);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Increment error counter - wrapped in try/catch to prevent blocking\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst statusCode =\n\t\t\t\t\t\t\ttypeof set.status === 'number' ? set.status : 500;\n\t\t\t\t\t\thttpErrorCounter?.add(1, {\n\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\t'error.type': errorDetails.name,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\thttpRequestDuration?.record(duration, {\n\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (metricsError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t'[telemetry] Failed to record error metrics:',\n\t\t\t\t\t\t\tmetricsError,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t// Record response metrics\n\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Response metrics recording\n\t\t\t.onAfterResponse(({ request, set, store }) => {\n\t\t\t\tconst url = new URL(request.url);\n\t\t\t\tconst pathname = url.pathname;\n\t\t\t\tconst method = request.method;\n\t\t\t\tconst statusCode = typeof set.status === 'number' ? set.status : 200;\n\t\t\t\tconst duration =\n\t\t\t\t\tDate.now() -\n\t\t\t\t\t(((store as Record<string, unknown>).startTime as number) ||\n\t\t\t\t\t\tDate.now());\n\t\t\t\tconst route =\n\t\t\t\t\t((store as Record<string, unknown>).route as string) || pathname;\n\n\t\t\t\t// Always decrement active connections for metrics accuracy\n\t\t\t\ttry {\n\t\t\t\t\tactiveConnections?.add(-1);\n\t\t\t\t\thttpActiveRequests?.add(-1, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\troute,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'[telemetry] Failed to decrement active requests:',\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Skip detailed telemetry if ignored or not sampled (set in onBeforeHandle)\n\t\t\t\tconst shouldIgnoreTelemetry = (store as Record<string, unknown>)\n\t\t\t\t\t.shouldIgnoreTelemetry;\n\t\t\t\tif (shouldIgnoreTelemetry) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// End manual span with final attributes\n\t\t\t\ttry {\n\t\t\t\t\tconst span = (store as Record<string, unknown>).telemetrySpan as\n\t\t\t\t\t\t| Span\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (span) {\n\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\t'http.duration_ms': duration,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (statusCode >= 400) {\n\t\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\t\t\tmessage: `HTTP ${statusCode}`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tspan.setAttribute('error', true);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tspan.end();\n\t\t\t\t\t}\n\t\t\t\t} catch (spanError) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to end span:', spanError);\n\t\t\t\t}\n\n\t\t\t\t// Log response - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\tconst isError = statusCode >= 400;\n\t\t\t\t\tlogger?.emit({\n\t\t\t\t\t\tseverityNumber: isError\n\t\t\t\t\t\t\t? SeverityNumber.ERROR\n\t\t\t\t\t\t\t: SeverityNumber.INFO,\n\t\t\t\t\t\tseverityText: isError ? 'ERROR' : 'INFO',\n\t\t\t\t\t\tbody: `← ${method} ${route} → ${statusCode} (${duration}ms)`,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\t'http.duration_ms': duration,\n\t\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t\t\t'host.address': url.host,\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t} catch (logError) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to log response:', logError);\n\t\t\t\t}\n\n\t\t\t\t// Record metrics - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\thttpRequestDuration?.record(duration, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t});\n\t\t\t\t} catch (metricsError) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'[telemetry] Failed to record request duration:',\n\t\t\t\t\t\tmetricsError,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t// Optionally add error inspector endpoint for source-mapped stack traces\n\t\tif (merged.sourcemaps?.enabled !== false) {\n\t\t\tconst rerouteDir = '.reroute';\n\n\t\t\tapp.post('/__reroute_telemetry/inspect', async ({ body }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { stack } = body as { stack?: string };\n\t\t\t\t\tif (!stack) {\n\t\t\t\t\t\treturn { error: 'Missing stack trace' };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { resolveStackTrace } = await import('./sourcemap');\n\t\t\t\t\tconst result = await resolveStackTrace(stack, { rerouteDir });\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\toriginal: result.original,\n\t\t\t\t\t\tmapped: result.mapped,\n\t\t\t\t\t\tframes: result.frames,\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('[telemetry] Error inspection failed:', error);\n\t\t\t\t\treturn {\n\t\t\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Optionally add browser telemetry proxy\n\t\tif (ENABLE_PROXY) {\n\t\t\tconst API_KEY = merged.apiKey || process.env.SIGNOZ_API_KEY;\n\n\t\t\t// Proxy handler function\n\t\t\tconst handleProxy = async (\n\t\t\t\tendpoint: string,\n\t\t\t\trequestBody: unknown,\n\t\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Proxy forwarding with error handling\n\t\t\t): Promise<{ status: number }> => {\n\t\t\t\tconst headers: Record<string, string> = {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t};\n\n\t\t\t\tif (API_KEY) {\n\t\t\t\t\theaders.Authorization = `Bearer ${API_KEY}`;\n\t\t\t\t}\n\n\t\t\t\t// Use custom handler if provided\n\t\t\t\tif (PROXY_HANDLER) {\n\t\t\t\t\treturn await PROXY_HANDLER({\n\t\t\t\t\t\tbody: requestBody,\n\t\t\t\t\t\tendpoint,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\totlpEndpoint: OTLP_ENDPOINT,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Default handler: forward to OTLP endpoint\n\t\t\t\ttry {\n\t\t\t\t\tconst controller = new AbortController();\n\t\t\t\t\tconst timeoutId = setTimeout(() => controller.abort(), 5000);\n\n\t\t\t\t\tconst response = await fetch(`${OTLP_ENDPOINT}${endpoint}`, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tbody: JSON.stringify(requestBody),\n\t\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t\t});\n\n\t\t\t\t\tclearTimeout(timeoutId);\n\n\t\t\t\t\tif (PROXY_VERBOSE) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`[telemetry-proxy]${endpoint} forwarded: ${response.status}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!response.ok && PROXY_VERBOSE) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[telemetry-proxy] OTLP error: ${response.status} ${response.statusText}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { status: 200 };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (PROXY_VERBOSE) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[telemetry-proxy] Failed to forward${endpoint}:`,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn { status: 200 };\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tapp\n\t\t\t\t.post(\n\t\t\t\t\t`${PROXY_PATHNAME}/v1/traces`,\n\t\t\t\t\tasync function forwardBrowserTraces({ body }) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await handleProxy('/v1/traces', body);\n\t\t\t\t\t\t\treturn new Response(null, { status: result.status });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('[telemetry-proxy] Handler error:', error);\n\t\t\t\t\t\t\treturn new Response(null, { status: 200 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.post(\n\t\t\t\t\t`${PROXY_PATHNAME}/v1/metrics`,\n\t\t\t\t\tasync function forwardBrowserMetrics({ body }) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await handleProxy('/v1/metrics', body);\n\t\t\t\t\t\t\treturn new Response(null, { status: result.status });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('[telemetry-proxy] Handler error:', error);\n\t\t\t\t\t\t\treturn new Response(null, { status: 200 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.post(\n\t\t\t\t\t`${PROXY_PATHNAME}/v1/logs`,\n\t\t\t\t\tasync function forwardBrowserLogs({ body }) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await handleProxy('/v1/logs', body);\n\t\t\t\t\t\t\treturn new Response(null, { status: result.status });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('[telemetry-proxy] Handler error:', error);\n\t\t\t\t\t\t\treturn new Response(null, { status: 200 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.get(`${PROXY_PATHNAME}/health`, () => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'ok',\n\t\t\t\t\t\totlpEndpoint: OTLP_ENDPOINT,\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t}\n\n\t\treturn app;\n\t};\n}\n",
|
|
42
|
+
"import os from 'node:os';\nimport {\n\ttype Counter,\n\tcontext,\n\ttype Histogram,\n\tmetrics,\n\ttype Span,\n\tSpanStatusCode,\n\ttrace,\n\ttype UpDownCounter,\n} from '@opentelemetry/api';\nimport { logs, SeverityNumber } from '@opentelemetry/api-logs';\nimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-proto';\nimport { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport {\n\tBatchLogRecordProcessor,\n\tLoggerProvider,\n} from '@opentelemetry/sdk-logs';\nimport {\n\tMeterProvider,\n\tPeriodicExportingMetricReader,\n} from '@opentelemetry/sdk-metrics';\nimport {\n\tBatchSpanProcessor,\n\tNodeTracerProvider,\n} from '@opentelemetry/sdk-trace-node';\nimport {\n\tATTR_SERVICE_NAME,\n\tATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { ATTR_HOST_NAME } from '@opentelemetry/semantic-conventions/incubating';\nimport type { Elysia } from 'elysia';\nimport { loadConfig, type TelemetryOptions } from 'reroute-js/core';\nimport { getContextAttributesForTelemetry } from './context';\nimport { extractHeaders } from './headers/extractor';\nimport { extractTraceContext } from './instrumentation';\nimport { enhanceError } from './sourcemap';\n\n/**\n * Server telemetry options\n * Extends TelemetryOptions from config - all options can be set in reroute.config.ts\n * or passed directly here (direct options override config values)\n */\nexport interface ServerTelemetryOptions extends TelemetryOptions {}\n\n// Helper to extract error details\nfunction getErrorDetails(error: unknown): {\n\tname: string;\n\tmessage: string;\n\tstack: string;\n} {\n\tif (error instanceof Error) {\n\t\treturn {\n\t\t\tname: error.name,\n\t\t\tmessage: error.message,\n\t\t\tstack: error.stack || '',\n\t\t};\n\t}\n\n\tif (typeof error === 'object' && error !== null) {\n\t\tconst err = error as Record<string, unknown>;\n\t\treturn {\n\t\t\tname: String(err.name || err.code || 'UnknownError'),\n\t\t\tmessage: String(err.message || err.error || JSON.stringify(error)),\n\t\t\tstack: String(err.stack || ''),\n\t\t};\n\t}\n\n\treturn {\n\t\tname: 'UnknownError',\n\t\tmessage: String(error),\n\t\tstack: '',\n\t};\n}\n\n/**\n * Check if a route should be ignored based on ignore patterns\n * Supports strings, RegExp, and custom functions\n */\nfunction shouldIgnoreRoute(\n\tpatterns: (\n\t\t| string\n\t\t| RegExp\n\t\t| ((pathname: string, method: string) => boolean)\n\t)[],\n\tpathname: string,\n\tmethod: string,\n): boolean {\n\treturn patterns.some((pattern) => {\n\t\tif (typeof pattern === 'string') {\n\t\t\treturn pathname.includes(pattern);\n\t\t}\n\t\tif (pattern instanceof RegExp) {\n\t\t\treturn pattern.test(pathname);\n\t\t}\n\t\tif (typeof pattern === 'function') {\n\t\t\treturn pattern(pathname, method);\n\t\t}\n\t\treturn false;\n\t});\n}\n\n/**\n * Determine if a request should be sampled based on sample rate\n * Uses deterministic sampling based on trace ID for consistency\n * @param rate - Sample rate between 0.0 and 1.0\n * @param traceId - Trace ID for deterministic sampling (optional)\n * @returns true if request should be sampled\n */\nfunction shouldSample(rate: number, traceId?: string): boolean {\n\tif (rate >= 1.0) return true;\n\tif (rate <= 0.0) return false;\n\n\t// Use deterministic sampling if trace ID provided\n\tif (traceId) {\n\t\t// Convert first 8 chars of trace ID to number for consistent sampling\n\t\tconst hash = Number.parseInt(traceId.slice(0, 8), 16);\n\t\treturn hash % 100 < rate * 100;\n\t}\n\n\t// Fall back to random sampling\n\treturn Math.random() < rate;\n}\n\n/**\n * Server-side telemetry plugin for Elysia\n *\n * Automatically captures:\n * - HTTP requests and responses\n * - Errors with full stack traces\n * - System metrics (CPU, memory)\n * - Request/response sizes\n * - Active connections\n *\n * Configuration is loaded from reroute.config.ts automatically.\n * Direct options override config values.\n *\n * @example\n * ```typescript\n * import { Elysia } from 'elysia';\n * import { telemetry } from 'reroute-js/telemetry/server';\n *\n * new Elysia()\n * .use(telemetry({\n * serviceName: 'My App',\n * }))\n * .listen(3000);\n * ```\n */\nexport function telemetry(options: ServerTelemetryOptions = {}) {\n\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Telemetry initialization with config loading and feature toggles\n\treturn async (app: Elysia) => {\n\t\t// Load reroute.config.ts automatically\n\t\tconst cwd =\n\t\t\ttypeof process !== 'undefined' && typeof process.cwd === 'function'\n\t\t\t\t? process.cwd()\n\t\t\t\t: '/';\n\t\tconst config = await loadConfig(cwd);\n\n\t\t// Merge config with direct options (direct options take precedence)\n\t\tconst merged = {\n\t\t\t...config.telemetry,\n\t\t\t...options,\n\t\t};\n\n\t\t// Check if telemetry is enabled (default: false)\n\t\tconst TELEMETRY_ENABLED = merged.enabled ?? false;\n\t\tif (!TELEMETRY_ENABLED) {\n\t\t\tconsole.log(\n\t\t\t\t'[telemetry] Disabled - set enabled: true in config or options to enable',\n\t\t\t);\n\t\t\t// Return app unchanged when disabled\n\t\t\treturn app;\n\t\t}\n\n\t\t// Extract configuration values\n\t\tconst SERVICE_NAME = merged.serviceName || 'reroute-app';\n\t\tconst SERVICE_VERSION =\n\t\t\tmerged.serviceVersion || process.env.npm_package_version || '1.0.0';\n\t\tconst OTLP_ENDPOINT =\n\t\t\tmerged.otlpEndpoint ||\n\t\t\tprocess.env.OTEL_EXPORTER_OTLP_ENDPOINT ||\n\t\t\t'http://localhost:4318';\n\t\tconst METRICS_INTERVAL = merged.metricsInterval ?? 5000;\n\n\t\t// Handle proxy configuration\n\t\tconst proxyConfig = merged.proxy;\n\t\tconst ENABLE_PROXY = proxyConfig?.enabled ?? !!proxyConfig;\n\t\tconst PROXY_PATHNAME = proxyConfig?.pathname ?? '/__reroute_telemetry';\n\t\tconst PROXY_VERBOSE = proxyConfig?.verbose ?? false;\n\t\tconst PROXY_HANDLER = proxyConfig?.handler;\n\n\t\t// Feature toggles (default: true when telemetry is enabled)\n\t\tconst ENABLE_TRACES = merged.enableTraces ?? true;\n\t\tconst ENABLE_METRICS = merged.enableMetrics ?? true;\n\t\tconst ENABLE_LOGS = merged.enableLogs ?? true;\n\t\tconst ENABLE_SYSTEM_METRICS = merged.enableSystemMetrics ?? true;\n\n\t\t// Sampling configuration\n\t\t// Default: Sample 20% of normal traffic, 100% of errors\n\t\t// This reduces telemetry volume by 80% while keeping all errors\n\t\tconst SAMPLE_RATE = merged.sampleRate ?? 0.2;\n\t\tconst ERROR_SAMPLE_RATE = merged.errorSampleRate ?? 1.0;\n\n\t\t// Route filtering\n\t\tconst IGNORE_ROUTES = merged.ignoreRoutes || [];\n\n\t\t// Header capture and custom attributes\n\t\tconst CAPTURE_MAPPINGS = merged.capture || [];\n\t\tconst CUSTOM_ATTRIBUTES = merged.customAttributes || {};\n\n\t\tconsole.log(`[telemetry] Initializing with endpoint: ${OTLP_ENDPOINT}`);\n\t\tconsole.log(\n\t\t\t`[telemetry] Features - Traces: ${ENABLE_TRACES}, Metrics: ${ENABLE_METRICS}, Logs: ${ENABLE_LOGS}`,\n\t\t);\n\t\tif (SAMPLE_RATE < 1.0) {\n\t\t\tconsole.log(\n\t\t\t\t`[telemetry] Sampling - Requests: ${SAMPLE_RATE * 100}%, Errors: ${ERROR_SAMPLE_RATE * 100}%`,\n\t\t\t);\n\t\t}\n\t\tif (ENABLE_PROXY) {\n\t\t\tconsole.log(\n\t\t\t\t`[telemetry] Browser telemetry proxy enabled at ${PROXY_PATHNAME}/*`,\n\t\t\t);\n\t\t}\n\n\t\t// Secure headers for API authentication (optional)\n\t\tconst otlpHeaders: Record<string, string> = {};\n\t\tif (merged.apiKey || process.env.SIGNOZ_API_KEY) {\n\t\t\totlpHeaders.Authorization = `Bearer ${merged.apiKey || process.env.SIGNOZ_API_KEY}`;\n\t\t}\n\n\t\t// Configure OTLP exporters with timeouts (conditionally based on feature toggles)\n\t\tconst traceExporter = ENABLE_TRACES\n\t\t\t? new OTLPTraceExporter({\n\t\t\t\t\turl: `${OTLP_ENDPOINT}/v1/traces`,\n\t\t\t\t\theaders:\n\t\t\t\t\t\tObject.keys(otlpHeaders).length > 0 ? otlpHeaders : undefined,\n\t\t\t\t\ttimeoutMillis: 5000, // 5 second timeout\n\t\t\t\t})\n\t\t\t: null;\n\n\t\tconst logExporter = ENABLE_LOGS\n\t\t\t? new OTLPLogExporter({\n\t\t\t\t\turl: `${OTLP_ENDPOINT}/v1/logs`,\n\t\t\t\t\theaders:\n\t\t\t\t\t\tObject.keys(otlpHeaders).length > 0 ? otlpHeaders : undefined,\n\t\t\t\t\ttimeoutMillis: 5000, // 5 second timeout\n\t\t\t\t})\n\t\t\t: null;\n\n\t\tconst metricExporter = ENABLE_METRICS\n\t\t\t? new OTLPMetricExporter({\n\t\t\t\t\turl: `${OTLP_ENDPOINT}/v1/metrics`,\n\t\t\t\t\theaders:\n\t\t\t\t\t\tObject.keys(otlpHeaders).length > 0 ? otlpHeaders : undefined,\n\t\t\t\t\ttimeoutMillis: 5000, // 5 second timeout\n\t\t\t\t})\n\t\t\t: null;\n\n\t\t// Create resource with service information\n\t\t// In Docker, prefer env var over os.hostname() (which returns container ID)\n\t\tconst HOSTNAME =\n\t\t\tprocess.env.OTEL_RESOURCE_ATTRIBUTES?.match(/host\\.name=([^,]+)/)?.[1] ||\n\t\t\tprocess.env.HOSTNAME ||\n\t\t\tos.hostname();\n\n\t\tconst resource = resourceFromAttributes({\n\t\t\t[ATTR_SERVICE_NAME]: SERVICE_NAME,\n\t\t\t[ATTR_SERVICE_VERSION]: SERVICE_VERSION,\n\t\t\t[ATTR_HOST_NAME]: HOSTNAME,\n\t\t});\n\n\t\t// Set up Traces with error handling (only if enabled)\n\t\tif (ENABLE_TRACES && traceExporter) {\n\t\t\ttry {\n\t\t\t\tconst tracerProvider = new NodeTracerProvider({\n\t\t\t\t\tresource,\n\t\t\t\t\t// Note: We use middleware-level sampling instead of SDK sampling\n\t\t\t\t\t// This allows us to preserve 100% of errors while sampling normal traffic\n\t\t\t\t\tspanProcessors: [new BatchSpanProcessor(traceExporter)],\n\t\t\t\t});\n\t\t\t\ttracerProvider.register();\n\n\t\t\t\tif (SAMPLE_RATE < 1.0 || ERROR_SAMPLE_RATE < 1.0) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`[telemetry] Middleware sampling: ${SAMPLE_RATE * 100}% normal, ${ERROR_SAMPLE_RATE * 100}% errors`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to initialize tracer:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Set up Logs with error handling (only if enabled)\n\t\tlet logger: ReturnType<LoggerProvider['getLogger']> | null = null;\n\t\tif (ENABLE_LOGS && logExporter) {\n\t\t\ttry {\n\t\t\t\tconst loggerProvider = new LoggerProvider({\n\t\t\t\t\tresource,\n\t\t\t\t\tprocessors: [new BatchLogRecordProcessor(logExporter)],\n\t\t\t\t});\n\t\t\t\tlogs.setGlobalLoggerProvider(loggerProvider);\n\t\t\t\tlogger = loggerProvider.getLogger(SERVICE_NAME, SERVICE_VERSION);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to initialize logger:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Set up Metrics with error handling (only if enabled)\n\t\tlet meter: ReturnType<MeterProvider['getMeter']> | null = null;\n\t\tif (ENABLE_METRICS && metricExporter) {\n\t\t\ttry {\n\t\t\t\tconst meterProvider = new MeterProvider({\n\t\t\t\t\tresource,\n\t\t\t\t\treaders: [\n\t\t\t\t\t\tnew PeriodicExportingMetricReader({\n\t\t\t\t\t\t\texporter: metricExporter,\n\t\t\t\t\t\t\texportIntervalMillis: METRICS_INTERVAL,\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\tmetrics.setGlobalMeterProvider(meterProvider);\n\t\t\t\tmeter = meterProvider.getMeter(SERVICE_NAME, SERVICE_VERSION);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to initialize meter:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Create HTTP metrics with null checks\n\t\tlet httpRequestCounter: Counter | null = null;\n\t\tlet httpRequestDuration: Histogram | null = null;\n\t\tlet httpErrorCounter: Counter | null = null;\n\t\tlet httpActiveRequests: UpDownCounter | null = null;\n\t\tlet activeConnections: UpDownCounter | null = null;\n\n\t\tif (meter) {\n\t\t\ttry {\n\t\t\t\thttpRequestCounter = meter.createCounter('http.server.request.count', {\n\t\t\t\t\tdescription: 'Total HTTP requests',\n\t\t\t\t\tunit: 'requests',\n\t\t\t\t});\n\n\t\t\t\thttpRequestDuration = meter.createHistogram(\n\t\t\t\t\t'http.server.request.duration',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'HTTP request duration',\n\t\t\t\t\t\tunit: 'milliseconds',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\thttpErrorCounter = meter.createCounter('http.server.error.count', {\n\t\t\t\t\tdescription: 'Total HTTP errors',\n\t\t\t\t\tunit: 'errors',\n\t\t\t\t});\n\n\t\t\t\thttpActiveRequests = meter.createUpDownCounter(\n\t\t\t\t\t'http.server.active_requests',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'Active HTTP requests',\n\t\t\t\t\t\tunit: 'requests',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tactiveConnections = meter.createUpDownCounter(\n\t\t\t\t\t'app.connections.active',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'Active connections',\n\t\t\t\t\t\tunit: 'connections',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to create HTTP metrics:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Create system metrics (optional) with error handling\n\t\tif (ENABLE_SYSTEM_METRICS && meter) {\n\t\t\ttry {\n\t\t\t\t// Reuse HOSTNAME from resource (already computed above)\n\n\t\t\t\tconst memoryUsage = meter.createObservableGauge('app.memory.usage', {\n\t\t\t\t\tdescription: 'Process memory usage',\n\t\t\t\t\tunit: 'bytes',\n\t\t\t\t});\n\n\t\t\t\tmemoryUsage.addCallback((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst usage = process.memoryUsage();\n\t\t\t\t\t\tresult.observe(usage.heapUsed, {\n\t\t\t\t\t\t\ttype: 'heap',\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresult.observe(usage.rss, { type: 'rss', 'host.name': HOSTNAME });\n\t\t\t\t\t\tresult.observe(usage.external, {\n\t\t\t\t\t\t\ttype: 'external',\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] Memory usage callback failed:', error);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tconst systemCpuUsage = meter.createObservableGauge(\n\t\t\t\t\t'system.cpu.utilization',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'System CPU utilization',\n\t\t\t\t\t\tunit: '1',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tsystemCpuUsage.addCallback((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst cpus = os.cpus();\n\t\t\t\t\t\tlet totalIdle = 0;\n\t\t\t\t\t\tlet totalTick = 0;\n\n\t\t\t\t\t\tcpus.forEach((cpu) => {\n\t\t\t\t\t\t\tconst times = cpu.times;\n\t\t\t\t\t\t\ttotalIdle += times.idle;\n\t\t\t\t\t\t\ttotalTick +=\n\t\t\t\t\t\t\t\ttimes.user + times.nice + times.sys + times.idle + times.irq;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst usage = 1 - totalIdle / totalTick;\n\t\t\t\t\t\tresult.observe(usage, {\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] CPU usage callback failed:', error);\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tconst systemMemoryUsage = meter.createObservableGauge(\n\t\t\t\t\t'system.memory.utilization',\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription: 'System memory utilization',\n\t\t\t\t\t\tunit: '1',\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tsystemMemoryUsage.addCallback((result) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst totalMem = os.totalmem();\n\t\t\t\t\t\tconst freeMem = os.freemem();\n\t\t\t\t\t\tconst usage = (totalMem - freeMem) / totalMem;\n\n\t\t\t\t\t\tresult.observe(usage, {\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t'host.name': HOSTNAME,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] System memory callback failed:', error);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Failed to create system metrics:', error);\n\t\t\t}\n\t\t}\n\n\t\t// Graceful shutdown with error handling\n\t\tconst shutdown = async () => {\n\t\t\tconsole.log('[telemetry] Shutting down...');\n\t\t\ttry {\n\t\t\t\t// Note: We can't reference loggerProvider/meterProvider here since they're in try blocks\n\t\t\t\t// The providers will be cleaned up automatically\n\t\t\t\tawait logs.disable();\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('[telemetry] Shutdown error:', error);\n\t\t\t}\n\t\t};\n\n\t\tprocess.on('SIGTERM', async () => {\n\t\t\tawait shutdown();\n\t\t\tprocess.exit(0);\n\t\t});\n\n\t\t// Initialize tracer for manual span creation\n\t\tlet tracer: ReturnType<typeof trace.getTracer> | null = null;\n\t\tif (ENABLE_TRACES && traceExporter) {\n\t\t\ttracer = trace.getTracer(SERVICE_NAME, SERVICE_VERSION);\n\t\t}\n\n\t\t// Setup global console.error capture for automatic error telemetry\n\t\t// This captures errors that are caught and logged but not thrown\n\t\tconst ENABLE_CONSOLE_CAPTURE = merged.enableConsoleCapture ?? true;\n\t\tif (ENABLE_CONSOLE_CAPTURE && tracer) {\n\t\t\tconst originalError = console.error;\n\t\t\tconst originalWarn = console.warn;\n\n\t\t\t// Don't override if already captured (e.g., in tests)\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\tif (!(originalError as any).__telemetry_captured__) {\n\t\t\t\tconst errorTracer = trace.getTracer('console-error');\n\n\t\t\t\t/** biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Console error capture */\n\t\t\t\tconsole.error = (...args: unknown[]) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Create a span for this console.error\n\t\t\t\t\t\tconst span = errorTracer.startSpan('server.console.error');\n\n\t\t\t\t\t\t// Try to extract error information\n\t\t\t\t\t\tconst firstArg = args[0];\n\t\t\t\t\t\tlet errorMessage = args.map(String).join(' ');\n\t\t\t\t\t\tlet errorStack = '';\n\t\t\t\t\t\tlet errorType = 'ConsoleError';\n\n\t\t\t\t\t\tif (firstArg instanceof Error) {\n\t\t\t\t\t\t\terrorMessage = firstArg.message;\n\t\t\t\t\t\t\terrorStack = firstArg.stack || '';\n\t\t\t\t\t\t\terrorType = firstArg.name;\n\n\t\t\t\t\t\t\t// Enhance error with source maps if available\n\t\t\t\t\t\t\tconst rerouteDir = '.reroute';\n\t\t\t\t\t\t\tif (rerouteDir && firstArg.stack) {\n\t\t\t\t\t\t\t\tenhanceError(firstArg, { rerouteDir })\n\t\t\t\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\t\t\t\tconst enhancedError = firstArg as Error & {\n\t\t\t\t\t\t\t\t\t\t\tsourceMappedStack?: string;\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\tif (enhancedError.sourceMappedStack) {\n\t\t\t\t\t\t\t\t\t\t\terrorStack = enhancedError.sourceMappedStack;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t\t\t\t\t// Silently fail sourcemap enhancement\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\t\tmessage: errorMessage,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t'log.level': 'error',\n\t\t\t\t\t\t\t'log.message': errorMessage,\n\t\t\t\t\t\t\t'error.type': errorType,\n\t\t\t\t\t\t\t...(errorStack ? { 'error.stack': errorStack } : {}),\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t...getContextAttributesForTelemetry(),\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (firstArg instanceof Error) {\n\t\t\t\t\t\t\tspan.recordException(firstArg);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tspan.end();\n\n\t\t\t\t\t\t// Also emit as log if logger is available\n\t\t\t\t\t\tif (logger) {\n\t\t\t\t\t\t\tlogger.emit({\n\t\t\t\t\t\t\t\tseverityNumber: SeverityNumber.ERROR,\n\t\t\t\t\t\t\t\tseverityText: 'ERROR',\n\t\t\t\t\t\t\t\tbody: errorMessage,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'log.level': 'error',\n\t\t\t\t\t\t\t\t\t'error.type': errorType,\n\t\t\t\t\t\t\t\t\t...(errorStack ? { 'error.stack': errorStack } : {}),\n\t\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Silently fail - don't break console.error\n\t\t\t\t\t}\n\n\t\t\t\t\t// Call original console.error\n\t\t\t\t\toriginalError.apply(console, args);\n\t\t\t\t};\n\n\t\t\t\t// Mark as captured to prevent double-wrapping\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\t\t(console.error as any).__telemetry_captured__ = true;\n\n\t\t\t\tconsole.log('[telemetry] Console error capture enabled');\n\t\t\t}\n\n\t\t\t// Also capture console.warn for completeness\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\tif (!(originalWarn as any).__telemetry_captured__) {\n\t\t\t\tconst warnTracer = trace.getTracer('console-warn');\n\n\t\t\t\tconsole.warn = (...args: unknown[]) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst span = warnTracer.startSpan('server.console.warn');\n\t\t\t\t\t\tconst message = args.map(String).join(' ');\n\n\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t'log.level': 'warn',\n\t\t\t\t\t\t\t'log.message': message,\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t...getContextAttributesForTelemetry(),\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tspan.end();\n\n\t\t\t\t\t\tif (logger) {\n\t\t\t\t\t\t\tlogger.emit({\n\t\t\t\t\t\t\t\tseverityNumber: SeverityNumber.WARN,\n\t\t\t\t\t\t\t\tseverityText: 'WARN',\n\t\t\t\t\t\t\t\tbody: message,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'log.level': 'warn',\n\t\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Silently fail\n\t\t\t\t\t}\n\n\t\t\t\t\toriginalWarn.apply(console, args);\n\t\t\t\t};\n\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Console capture\n\t\t\t\t(console.warn as any).__telemetry_captured__ = true;\n\t\t\t}\n\t\t}\n\n\t\tapp = app\n\t\t\t// Track incoming requests\n\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Request tracking with filtering and sampling\n\t\t\t.onBeforeHandle(({ request, store }) => {\n\t\t\t\tconst startTime = Date.now();\n\t\t\t\tconst url = new URL(request.url);\n\t\t\t\tconst route = url.pathname;\n\t\t\t\tconst method = request.method;\n\n\t\t\t\t(store as Record<string, unknown>).startTime = startTime;\n\t\t\t\t(store as Record<string, unknown>).route = route;\n\n\t\t\t\t// Check if route should be ignored\n\t\t\t\tconst shouldIgnore =\n\t\t\t\t\tIGNORE_ROUTES.length > 0 &&\n\t\t\t\t\tshouldIgnoreRoute(IGNORE_ROUTES, route, method);\n\t\t\t\t(store as Record<string, unknown>).shouldIgnoreTelemetry = shouldIgnore;\n\n\t\t\t\t// Extract incoming trace context from browser (if present)\n\t\t\t\t// This allows browser spans to link to server spans\n\t\t\t\tconst incomingContext = extractTraceContext(request.headers);\n\n\t\t\t\t// Apply sampling (skip if ignored or not sampled)\n\t\t\t\t// Use trace ID for deterministic sampling if available\n\t\t\t\tconst traceId = incomingContext\n\t\t\t\t\t? (trace.getSpan(incomingContext)?.spanContext().traceId ?? undefined)\n\t\t\t\t\t: undefined;\n\n\t\t\t\tif (!shouldIgnore) {\n\t\t\t\t\tconst sampled = shouldSample(SAMPLE_RATE, traceId);\n\t\t\t\t\t(store as Record<string, unknown>).isSampled = sampled;\n\t\t\t\t\tif (!sampled) {\n\t\t\t\t\t\t(store as Record<string, unknown>).shouldIgnoreTelemetry = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Create manual span for request if traces enabled and not ignored\n\t\t\t\tif (\n\t\t\t\t\ttracer &&\n\t\t\t\t\t!(store as Record<string, unknown>).shouldIgnoreTelemetry\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Extract mapped headers early for span creation\n\t\t\t\t\t\tconst mappedHeaders =\n\t\t\t\t\t\t\tCAPTURE_MAPPINGS.length > 0\n\t\t\t\t\t\t\t\t? extractHeaders(request.headers, CAPTURE_MAPPINGS)\n\t\t\t\t\t\t\t\t: {};\n\n\t\t\t\t\t\t// Create span within extracted context (if available)\n\t\t\t\t\t\tconst createSpan = () => {\n\t\t\t\t\t\t\treturn tracer.startSpan(`${method} ${route}`, {\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t\t\t\t\t'host.address': url.host,\n\t\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t\t...mappedHeaders,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst span = incomingContext\n\t\t\t\t\t\t\t? context.with(incomingContext, createSpan)\n\t\t\t\t\t\t\t: createSpan();\n\n\t\t\t\t\t\t// Add session attributes if any\n\t\t\t\t\t\tconst sessionAttrs = getContextAttributesForTelemetry();\n\t\t\t\t\t\tif (Object.keys(sessionAttrs).length > 0) {\n\t\t\t\t\t\t\tspan.setAttributes(sessionAttrs);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t(store as Record<string, unknown>).telemetrySpan = span;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error('[telemetry] Failed to create span:', error);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Always track active connections for metrics accuracy\n\t\t\t\ttry {\n\t\t\t\t\tactiveConnections?.add(1);\n\t\t\t\t\thttpActiveRequests?.add(1, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\troute,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to track active requests:', error);\n\t\t\t\t}\n\n\t\t\t\t// Skip detailed telemetry if ignored or not sampled\n\t\t\t\tif ((store as Record<string, unknown>).shouldIgnoreTelemetry) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Capture mapped headers\n\t\t\t\tconst mappedHeaders =\n\t\t\t\t\tCAPTURE_MAPPINGS.length > 0\n\t\t\t\t\t\t? extractHeaders(request.headers, CAPTURE_MAPPINGS)\n\t\t\t\t\t\t: {};\n\n\t\t\t\t// Build attributes with custom attributes and captured headers\n\t\t\t\tconst baseAttributes = {\n\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t'http.route': route,\n\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t'host.address': url.host,\n\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t...mappedHeaders,\n\t\t\t\t};\n\n\t\t\t\t// Log incoming request - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\tlogger?.emit({\n\t\t\t\t\t\tseverityNumber: SeverityNumber.INFO,\n\t\t\t\t\t\tseverityText: 'INFO',\n\t\t\t\t\t\tbody: `→ ${method} ${route}`,\n\t\t\t\t\t\tattributes: baseAttributes,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to log incoming request:', error);\n\t\t\t\t}\n\n\t\t\t\t// Increment request counter - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\thttpRequestCounter?.add(1, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'[telemetry] Failed to increment request counter:',\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t// Handle errors with full context\n\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Error handling with context\n\t\t\t.onError(async ({ error, request, set, store }) => {\n\t\t\t\tconst errorDetails = getErrorDetails(error);\n\t\t\t\tconst duration =\n\t\t\t\t\tDate.now() -\n\t\t\t\t\t(((store as Record<string, unknown>).startTime as number) ||\n\t\t\t\t\t\tDate.now());\n\n\t\t\t\t// Check if this error should be sampled (errors have their own sample rate)\n\t\t\t\tconst url = new URL(request.url);\n\t\t\t\tconst route = url.pathname;\n\t\t\t\tconst method = request.method;\n\t\t\t\tconst shouldIgnore =\n\t\t\t\t\tIGNORE_ROUTES.length > 0 &&\n\t\t\t\t\tshouldIgnoreRoute(IGNORE_ROUTES, route, method);\n\n\t\t\t\t// Apply error sampling (separate from regular request sampling)\n\t\t\t\t// Always sample errors if ERROR_SAMPLE_RATE = 1.0 (default)\n\t\t\t\tconst span = (store as Record<string, unknown>).telemetrySpan as\n\t\t\t\t\t| Span\n\t\t\t\t\t| undefined;\n\t\t\t\tconst traceId = span?.spanContext().traceId;\n\t\t\t\tconst errorSampled = shouldSample(ERROR_SAMPLE_RATE, traceId);\n\t\t\t\tconst skipTelemetry = shouldIgnore || !errorSampled;\n\n\t\t\t\t// Record exception in manual span - wrapped in try/catch to prevent blocking\n\t\t\t\tif (!skipTelemetry) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst span = (store as Record<string, unknown>).telemetrySpan as\n\t\t\t\t\t\t\t| Span\n\t\t\t\t\t\t\t| undefined;\n\t\t\t\t\t\tif (span) {\n\t\t\t\t\t\t\tconst errorObj =\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(errorDetails.message);\n\n\t\t\t\t\t\t\t// Enhance error with source maps if available\n\t\t\t\t\t\t\tconst rerouteDir = '.reroute';\n\t\t\t\t\t\t\tif (rerouteDir && errorObj.stack) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait enhanceError(errorObj, { rerouteDir });\n\t\t\t\t\t\t\t\t} catch (smError) {\n\t\t\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\t\t'[telemetry] Sourcemap enhancement failed:',\n\t\t\t\t\t\t\t\t\t\tsmError,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tspan.recordException(errorObj);\n\t\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\t\t\tmessage: `${errorDetails.name}: ${errorDetails.message}`,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst enhancedError = errorObj as Error & {\n\t\t\t\t\t\t\t\tsourceMappedStack?: string;\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst stackToUse =\n\t\t\t\t\t\t\t\tenhancedError.sourceMappedStack || errorDetails.stack;\n\n\t\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t'error.type': errorDetails.name,\n\t\t\t\t\t\t\t\t'error.message': errorDetails.message,\n\t\t\t\t\t\t\t\t'error.stack': errorDetails.stack,\n\t\t\t\t\t\t\t\t...(enhancedError.sourceMappedStack\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t'error.stack.decoded': enhancedError.sourceMappedStack,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t'http.response.status_code':\n\t\t\t\t\t\t\t\t\ttypeof set.status === 'number' ? set.status : 500,\n\t\t\t\t\t\t\t\t'http.duration_ms': duration,\n\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t\t...getContextAttributesForTelemetry(),\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tspan.addEvent('exception', {\n\t\t\t\t\t\t\t\t'exception.type': errorDetails.name,\n\t\t\t\t\t\t\t\t'exception.message': errorDetails.message,\n\t\t\t\t\t\t\t\t'exception.stacktrace': stackToUse,\n\t\t\t\t\t\t\t\t'exception.escaped': 'false',\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t// End the span here since onAfterResponse won't handle errors\n\t\t\t\t\t\t\tspan.end();\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (spanError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t'[telemetry] Failed to record exception in span:',\n\t\t\t\t\t\t\tspanError,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Log error - wrapped in try/catch to prevent blocking\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlogger?.emit({\n\t\t\t\t\t\t\tseverityNumber: SeverityNumber.ERROR,\n\t\t\t\t\t\t\tseverityText: 'ERROR',\n\t\t\t\t\t\t\tbody: `${errorDetails.name}: ${errorDetails.message}`,\n\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t'error.type': errorDetails.name,\n\t\t\t\t\t\t\t\t'error.message': errorDetails.message,\n\t\t\t\t\t\t\t\t'error.stack': errorDetails.stack,\n\t\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t\t\t\t'http.response.status_code':\n\t\t\t\t\t\t\t\t\ttypeof set.status === 'number' ? set.status : 500,\n\t\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (logError) {\n\t\t\t\t\t\tconsole.error('[telemetry] Failed to log error:', logError);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Increment error counter - wrapped in try/catch to prevent blocking\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst statusCode =\n\t\t\t\t\t\t\ttypeof set.status === 'number' ? set.status : 500;\n\t\t\t\t\t\thttpErrorCounter?.add(1, {\n\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\t'error.type': errorDetails.name,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\thttpRequestDuration?.record(duration, {\n\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (metricsError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t'[telemetry] Failed to record error metrics:',\n\t\t\t\t\t\t\tmetricsError,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t// Record response metrics\n\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Response metrics recording\n\t\t\t.onAfterResponse(({ request, set, store }) => {\n\t\t\t\tconst url = new URL(request.url);\n\t\t\t\tconst pathname = url.pathname;\n\t\t\t\tconst method = request.method;\n\t\t\t\tconst statusCode = typeof set.status === 'number' ? set.status : 200;\n\t\t\t\tconst duration =\n\t\t\t\t\tDate.now() -\n\t\t\t\t\t(((store as Record<string, unknown>).startTime as number) ||\n\t\t\t\t\t\tDate.now());\n\t\t\t\tconst route =\n\t\t\t\t\t((store as Record<string, unknown>).route as string) || pathname;\n\n\t\t\t\t// Always decrement active connections for metrics accuracy\n\t\t\t\ttry {\n\t\t\t\t\tactiveConnections?.add(-1);\n\t\t\t\t\thttpActiveRequests?.add(-1, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\troute,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'[telemetry] Failed to decrement active requests:',\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Skip detailed telemetry if ignored or not sampled (set in onBeforeHandle)\n\t\t\t\tconst shouldIgnoreTelemetry = (store as Record<string, unknown>)\n\t\t\t\t\t.shouldIgnoreTelemetry;\n\t\t\t\tif (shouldIgnoreTelemetry) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// End manual span with final attributes\n\t\t\t\ttry {\n\t\t\t\t\tconst span = (store as Record<string, unknown>).telemetrySpan as\n\t\t\t\t\t\t| Span\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tif (span) {\n\t\t\t\t\t\tspan.setAttributes({\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\t'http.duration_ms': duration,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (statusCode >= 400) {\n\t\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\t\tcode: SpanStatusCode.ERROR,\n\t\t\t\t\t\t\t\tmessage: `HTTP ${statusCode}`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tspan.setAttribute('error', true);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tspan.end();\n\t\t\t\t\t}\n\t\t\t\t} catch (spanError) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to end span:', spanError);\n\t\t\t\t}\n\n\t\t\t\t// Log response - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\tconst isError = statusCode >= 400;\n\t\t\t\t\tlogger?.emit({\n\t\t\t\t\t\tseverityNumber: isError\n\t\t\t\t\t\t\t? SeverityNumber.ERROR\n\t\t\t\t\t\t\t: SeverityNumber.INFO,\n\t\t\t\t\t\tseverityText: isError ? 'ERROR' : 'INFO',\n\t\t\t\t\t\tbody: `← ${method} ${route} → ${statusCode} (${duration}ms)`,\n\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t\t'http.request.url': request.url,\n\t\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t\t'http.duration_ms': duration,\n\t\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t\t\t'host.address': url.host,\n\t\t\t\t\t\t\t'service.name': SERVICE_NAME,\n\t\t\t\t\t\t\t...CUSTOM_ATTRIBUTES,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t} catch (logError) {\n\t\t\t\t\tconsole.error('[telemetry] Failed to log response:', logError);\n\t\t\t\t}\n\n\t\t\t\t// Record metrics - wrapped in try/catch to prevent blocking\n\t\t\t\ttry {\n\t\t\t\t\thttpRequestDuration?.record(duration, {\n\t\t\t\t\t\t'http.request.method': method,\n\t\t\t\t\t\t'http.route': route,\n\t\t\t\t\t\t'http.response.status_code': statusCode,\n\t\t\t\t\t\t'http.request.scheme': url.protocol.replace(':', ''),\n\t\t\t\t\t});\n\t\t\t\t} catch (metricsError) {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t'[telemetry] Failed to record request duration:',\n\t\t\t\t\t\tmetricsError,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t// Optionally add error inspector endpoint for source-mapped stack traces\n\t\tif (merged.sourcemaps?.enabled !== false) {\n\t\t\tconst rerouteDir = '.reroute';\n\n\t\t\tapp.post('/__reroute_telemetry/inspect', async ({ body }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { stack } = body as { stack?: string };\n\t\t\t\t\tif (!stack) {\n\t\t\t\t\t\treturn { error: 'Missing stack trace' };\n\t\t\t\t\t}\n\n\t\t\t\t\tconst { resolveStackTrace } = await import('./sourcemap');\n\t\t\t\t\tconst result = await resolveStackTrace(stack, { rerouteDir });\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\toriginal: result.original,\n\t\t\t\t\t\tmapped: result.mapped,\n\t\t\t\t\t\tframes: result.frames,\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('[telemetry] Error inspection failed:', error);\n\t\t\t\t\treturn {\n\t\t\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// Optionally add browser telemetry proxy\n\t\tif (ENABLE_PROXY) {\n\t\t\tconst API_KEY = merged.apiKey || process.env.SIGNOZ_API_KEY;\n\n\t\t\t// Proxy handler function\n\t\t\tconst handleProxy = async (\n\t\t\t\tendpoint: string,\n\t\t\t\trequestBody: unknown,\n\t\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Proxy forwarding with error handling\n\t\t\t): Promise<{ status: number }> => {\n\t\t\t\tconst headers: Record<string, string> = {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t};\n\n\t\t\t\tif (API_KEY) {\n\t\t\t\t\theaders.Authorization = `Bearer ${API_KEY}`;\n\t\t\t\t}\n\n\t\t\t\t// Use custom handler if provided\n\t\t\t\tif (PROXY_HANDLER) {\n\t\t\t\t\treturn await PROXY_HANDLER({\n\t\t\t\t\t\tbody: requestBody,\n\t\t\t\t\t\tendpoint,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\totlpEndpoint: OTLP_ENDPOINT,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Default handler: forward to OTLP endpoint\n\t\t\t\ttry {\n\t\t\t\t\tconst controller = new AbortController();\n\t\t\t\t\tconst timeoutId = setTimeout(() => controller.abort(), 5000);\n\n\t\t\t\t\tconst response = await fetch(`${OTLP_ENDPOINT}${endpoint}`, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tbody: JSON.stringify(requestBody),\n\t\t\t\t\t\tsignal: controller.signal,\n\t\t\t\t\t});\n\n\t\t\t\t\tclearTimeout(timeoutId);\n\n\t\t\t\t\tif (PROXY_VERBOSE) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`[telemetry-proxy]${endpoint} forwarded: ${response.status}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!response.ok && PROXY_VERBOSE) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[telemetry-proxy] OTLP error: ${response.status} ${response.statusText}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { status: 200 };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (PROXY_VERBOSE) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`[telemetry-proxy] Failed to forward${endpoint}:`,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn { status: 200 };\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tapp\n\t\t\t\t.post(\n\t\t\t\t\t`${PROXY_PATHNAME}/v1/traces`,\n\t\t\t\t\tasync function forwardBrowserTraces({ body }) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await handleProxy('/v1/traces', body);\n\t\t\t\t\t\t\treturn new Response(null, { status: result.status });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('[telemetry-proxy] Handler error:', error);\n\t\t\t\t\t\t\treturn new Response(null, { status: 200 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.post(\n\t\t\t\t\t`${PROXY_PATHNAME}/v1/metrics`,\n\t\t\t\t\tasync function forwardBrowserMetrics({ body }) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await handleProxy('/v1/metrics', body);\n\t\t\t\t\t\t\treturn new Response(null, { status: result.status });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('[telemetry-proxy] Handler error:', error);\n\t\t\t\t\t\t\treturn new Response(null, { status: 200 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.post(\n\t\t\t\t\t`${PROXY_PATHNAME}/v1/logs`,\n\t\t\t\t\tasync function forwardBrowserLogs({ body }) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await handleProxy('/v1/logs', body);\n\t\t\t\t\t\t\treturn new Response(null, { status: result.status });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconsole.error('[telemetry-proxy] Handler error:', error);\n\t\t\t\t\t\t\treturn new Response(null, { status: 200 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\t.get(`${PROXY_PATHNAME}/health`, () => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'ok',\n\t\t\t\t\t\totlpEndpoint: OTLP_ENDPOINT,\n\t\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t}\n\n\t\treturn app;\n\t};\n}\n",
|
|
43
43
|
"export * from './context';\nexport * from './headers';\nexport * from './instrumentation';\nexport * from './plugin';\nexport * from './sourcemap';\n",
|
|
44
44
|
"export * from './src/server';\n"
|
|
45
45
|
],
|
|
46
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AA8BO,SAAS,UAAU,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