@stacksjs/bun-router 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/chunk-2mx7fq49.js +4 -0
  2. package/dist/chunk-a8p83068.js +103 -0
  3. package/dist/{chunk-cgptvjdf.js → chunk-y3xq6wq6.js} +1 -1
  4. package/dist/cli.js +4 -3
  5. package/dist/container/index.js +1149 -211
  6. package/dist/container/service-provider.d.ts +3 -3
  7. package/dist/development/performance-profiler.d.ts +3 -3
  8. package/dist/development/route-debugger.d.ts +1 -1
  9. package/dist/development/route-inspector.d.ts +2 -2
  10. package/dist/index.js +369 -2209
  11. package/dist/observability/integration.d.ts +1 -1
  12. package/dist/response/macros.d.ts +1 -1
  13. package/dist/router/index.d.ts +7 -7
  14. package/dist/router/router.d.ts +0 -32
  15. package/dist/testing/performance-testing.d.ts +2 -2
  16. package/dist/testing/test-client.d.ts +1 -1
  17. package/dist/testing/websocket-testing.d.ts +1 -1
  18. package/package.json +7 -7
  19. package/dist/chunk-1ahs68ys.js +0 -18
  20. package/dist/chunk-g3ybefhg.js +0 -1923
  21. package/src/auth.ts +0 -489
  22. package/src/cache/lru-cache.ts +0 -457
  23. package/src/cache/middleware-memoization.ts +0 -531
  24. package/src/cache/route-cache-warmer.ts +0 -486
  25. package/src/cache/sqlite-cache.ts +0 -783
  26. package/src/cache/streaming-cache.ts +0 -572
  27. package/src/cli/colors.ts +0 -29
  28. package/src/cli/index.ts +0 -287
  29. package/src/cli/middleware.ts +0 -291
  30. package/src/cli/openapi.ts +0 -407
  31. package/src/cli/router.ts +0 -188
  32. package/src/cli/routes.ts +0 -265
  33. package/src/cli/utils.ts +0 -531
  34. package/src/cli.ts +0 -5
  35. package/src/config.ts +0 -322
  36. package/src/container/container.ts +0 -786
  37. package/src/container/contextual-binding.ts +0 -606
  38. package/src/container/decorators.ts +0 -368
  39. package/src/container/index.ts +0 -49
  40. package/src/container/service-provider.ts +0 -596
  41. package/src/development/hot-reload.ts +0 -673
  42. package/src/development/index.ts +0 -499
  43. package/src/development/performance-profiler.ts +0 -717
  44. package/src/development/route-debugger.ts +0 -527
  45. package/src/development/route-inspector.ts +0 -749
  46. package/src/development/typescript-utilities.ts +0 -682
  47. package/src/docs.ts +0 -397
  48. package/src/errors/circuit-breaker.ts +0 -733
  49. package/src/errors/error-handler.ts +0 -569
  50. package/src/errors/error-reporting.ts +0 -672
  51. package/src/errors/exceptions.ts +0 -536
  52. package/src/errors/graceful-degradation.ts +0 -623
  53. package/src/errors/index.ts +0 -21
  54. package/src/errors/router-errors.ts +0 -632
  55. package/src/file-serving/static-files.ts +0 -718
  56. package/src/index.ts +0 -66
  57. package/src/middleware/auth.ts +0 -220
  58. package/src/middleware/content_security_policy.ts +0 -215
  59. package/src/middleware/cors.ts +0 -142
  60. package/src/middleware/csrf.ts +0 -166
  61. package/src/middleware/ddos_protection.ts +0 -279
  62. package/src/middleware/file_security.ts +0 -191
  63. package/src/middleware/file_upload.ts +0 -275
  64. package/src/middleware/helmet.ts +0 -268
  65. package/src/middleware/index.ts +0 -117
  66. package/src/middleware/input_validation.ts +0 -453
  67. package/src/middleware/json_body.ts +0 -37
  68. package/src/middleware/performance_alerting.ts +0 -540
  69. package/src/middleware/performance_dashboard.ts +0 -661
  70. package/src/middleware/performance_monitor.ts +0 -945
  71. package/src/middleware/pipeline.ts +0 -489
  72. package/src/middleware/rate_limit.ts +0 -251
  73. package/src/middleware/request_id.ts +0 -36
  74. package/src/middleware/request_signing.ts +0 -638
  75. package/src/middleware/request_tracer.ts +0 -653
  76. package/src/middleware/response_cache.ts +0 -778
  77. package/src/middleware/security.ts +0 -482
  78. package/src/middleware/security_suite.ts +0 -257
  79. package/src/middleware/session.ts +0 -91
  80. package/src/model-binding/index.ts +0 -18
  81. package/src/model-binding/model-middleware.ts +0 -425
  82. package/src/model-binding/model-registry.ts +0 -550
  83. package/src/model-binding.ts +0 -370
  84. package/src/model-resolver-factory.ts +0 -106
  85. package/src/observability/correlation.ts +0 -691
  86. package/src/observability/health-checks.ts +0 -729
  87. package/src/observability/index.ts +0 -184
  88. package/src/observability/integration.ts +0 -548
  89. package/src/observability/metrics.ts +0 -753
  90. package/src/observability/tracing.ts +0 -638
  91. package/src/optimization/bun-utilities.ts +0 -778
  92. package/src/query-builder-integration.ts +0 -137
  93. package/src/request/context.ts +0 -109
  94. package/src/request/enhanced-request.ts +0 -876
  95. package/src/request/macros.ts +0 -822
  96. package/src/response/macros.ts +0 -665
  97. package/src/response/response-factory.ts +0 -596
  98. package/src/router/api-routes.ts +0 -243
  99. package/src/router/file-based-routing.ts +0 -697
  100. package/src/router/file-streaming.ts +0 -383
  101. package/src/router/fluent-routing.ts +0 -866
  102. package/src/router/group-organization.ts +0 -229
  103. package/src/router/handler-resolver.ts +0 -327
  104. package/src/router/http-methods.ts +0 -407
  105. package/src/router/index.ts +0 -193
  106. package/src/router/middleware-groups.ts +0 -222
  107. package/src/router/middleware-integration.ts +0 -399
  108. package/src/router/middleware.ts +0 -234
  109. package/src/router/model-binding.ts +0 -215
  110. package/src/router/optimized-route-matching.ts +0 -302
  111. package/src/router/route-building.ts +0 -221
  112. package/src/router/route-compiler.ts +0 -691
  113. package/src/router/route-matching.ts +0 -368
  114. package/src/router/route-trie.ts +0 -450
  115. package/src/router/router.ts +0 -1616
  116. package/src/router/server.ts +0 -684
  117. package/src/router/validation-integration.ts +0 -449
  118. package/src/router/view-rendering.ts +0 -233
  119. package/src/router/websocket.ts +0 -100
  120. package/src/routing/route-caching.ts +0 -402
  121. package/src/routing/route-throttling.ts +0 -469
  122. package/src/routing/subdomain-routing.ts +0 -492
  123. package/src/session/database-store.ts +0 -109
  124. package/src/session/file-store.ts +0 -148
  125. package/src/session/index.ts +0 -244
  126. package/src/session/memory-store.ts +0 -88
  127. package/src/session/redis-store.ts +0 -93
  128. package/src/streaming/index.ts +0 -17
  129. package/src/streaming/sse-handler.ts +0 -482
  130. package/src/streaming/stream-handler.ts +0 -552
  131. package/src/testing/auth-testing.ts +0 -448
  132. package/src/testing/file-upload-testing.ts +0 -543
  133. package/src/testing/index.ts +0 -10
  134. package/src/testing/middleware-testing.ts +0 -322
  135. package/src/testing/model-binding-testing.ts +0 -645
  136. package/src/testing/performance-testing.ts +0 -738
  137. package/src/testing/test-client.ts +0 -310
  138. package/src/testing/test-request.ts +0 -315
  139. package/src/testing/test-response.ts +0 -332
  140. package/src/testing/types.ts +0 -224
  141. package/src/testing/websocket-testing.ts +0 -590
  142. package/src/types/controller-types.ts +0 -385
  143. package/src/types/core.ts +0 -683
  144. package/src/types/middleware-types.ts +0 -422
  145. package/src/types/request-response-augmentation.ts +0 -489
  146. package/src/types/route-inference.ts +0 -372
  147. package/src/types.ts +0 -2123
  148. package/src/url.ts +0 -131
  149. package/src/utils/index.ts +0 -1
  150. package/src/utils/query-preservation.ts +0 -201
  151. package/src/utils.ts +0 -395
  152. package/src/validation/validator.ts +0 -688
  153. package/src/websocket/clustering.ts +0 -769
@@ -1,548 +0,0 @@
1
- /**
2
- * Observability & Monitoring - Integration Layer
3
- *
4
- * Unified integration for tracing, metrics, health checks, and correlation
5
- */
6
-
7
- import type { EnhancedRequest } from '../types'
8
- import type { CorrelationConfig } from './correlation'
9
- import type { HealthCheckConfig } from './health-checks'
10
- import type { MetricConfig } from './metrics'
11
- import type { TraceConfig } from './tracing'
12
- import process from 'node:process'
13
- import {
14
- CorrelationEndpoints,
15
- createCorrelationMiddleware,
16
- initializeCorrelation,
17
- } from './correlation'
18
- import {
19
-
20
- HealthEndpoints,
21
- initializeHealthChecks,
22
- } from './health-checks'
23
- import {
24
- createMetricsHandler,
25
- createMetricsMiddleware,
26
- initializeMetrics,
27
-
28
- } from './metrics'
29
- import {
30
- createTracingMiddleware,
31
- initializeTracer,
32
-
33
- } from './tracing'
34
-
35
- export interface ObservabilityConfig {
36
- tracing?: TraceConfig
37
- metrics?: MetricConfig
38
- healthChecks?: HealthCheckConfig
39
- correlation?: CorrelationConfig
40
- enableTracing?: boolean
41
- enableMetrics?: boolean
42
- enableHealthChecks?: boolean
43
- enableCorrelation?: boolean
44
- endpoints?: {
45
- metrics?: string
46
- health?: string
47
- ready?: string
48
- live?: string
49
- startup?: string
50
- trace?: string
51
- correlationStats?: string
52
- }
53
- }
54
-
55
- /**
56
- * Observability manager - coordinates all observability features
57
- */
58
- export class ObservabilityManager {
59
- private config: ObservabilityConfig
60
- private initialized = false
61
-
62
- constructor(config: ObservabilityConfig = {}) {
63
- this.config = {
64
- enableTracing: true,
65
- enableMetrics: true,
66
- enableHealthChecks: true,
67
- enableCorrelation: true,
68
- endpoints: {
69
- metrics: '/metrics',
70
- health: '/health',
71
- ready: '/health/ready',
72
- live: '/health/live',
73
- startup: '/health/startup',
74
- trace: '/trace',
75
- correlationStats: '/correlation/stats',
76
- },
77
- ...config,
78
- }
79
- }
80
-
81
- /**
82
- * Initialize all observability components
83
- */
84
- initialize(): void {
85
- if (this.initialized) {
86
- console.warn('Observability already initialized')
87
- return
88
- }
89
-
90
- // Initialize tracing
91
- if (this.config.enableTracing && this.config.tracing) {
92
- initializeTracer(this.config.tracing)
93
- console.log('✓ Distributed tracing initialized')
94
- }
95
-
96
- // Initialize metrics
97
- if (this.config.enableMetrics) {
98
- initializeMetrics(this.config.metrics)
99
- console.log('✓ Metrics collection initialized')
100
- }
101
-
102
- // Initialize health checks
103
- if (this.config.enableHealthChecks) {
104
- initializeHealthChecks(this.config.healthChecks)
105
- console.log('✓ Health checks initialized')
106
- }
107
-
108
- // Initialize correlation
109
- if (this.config.enableCorrelation) {
110
- initializeCorrelation(this.config.correlation)
111
- console.log('✓ Request correlation initialized')
112
- }
113
-
114
- this.initialized = true
115
- console.log('🔍 Observability & Monitoring fully initialized')
116
- }
117
-
118
- /**
119
- * Create observability middleware stack
120
- */
121
- createMiddleware(): (req: EnhancedRequest, next: () => Promise<Response>) => Promise<Response> {
122
- const middlewares: Array<(req: EnhancedRequest, next: () => Promise<Response>) => Promise<Response>> = []
123
-
124
- // Add correlation middleware first (provides context for others)
125
- if (this.config.enableCorrelation) {
126
- middlewares.push(createCorrelationMiddleware(this.config.correlation))
127
- }
128
-
129
- // Add tracing middleware
130
- if (this.config.enableTracing) {
131
- middlewares.push(createTracingMiddleware(this.config.tracing))
132
- }
133
-
134
- // Add metrics middleware
135
- if (this.config.enableMetrics) {
136
- middlewares.push(createMetricsMiddleware(this.config.metrics))
137
- }
138
-
139
- return async (req: EnhancedRequest, next: () => Promise<Response>): Promise<Response> => {
140
- // Execute middleware stack
141
- let index = 0
142
-
143
- const executeNext = async (): Promise<Response> => {
144
- if (index >= middlewares.length) {
145
- return await next()
146
- }
147
-
148
- const middleware = middlewares[index++]!
149
- return await middleware(req, executeNext)
150
- }
151
-
152
- return await executeNext()
153
- }
154
- }
155
-
156
- /**
157
- * Create observability route handlers
158
- */
159
- createRouteHandlers(): Record<string, (req: EnhancedRequest) => Promise<Response>> {
160
- const handlers: Record<string, (req: EnhancedRequest) => Promise<Response>> = {}
161
-
162
- // Metrics endpoint
163
- if (this.config.enableMetrics && this.config.endpoints?.metrics) {
164
- handlers[this.config.endpoints.metrics] = createMetricsHandler()
165
- }
166
-
167
- // Health check endpoints
168
- if (this.config.enableHealthChecks) {
169
- if (this.config.endpoints?.health) {
170
- handlers[this.config.endpoints.health] = HealthEndpoints.health
171
- }
172
- if (this.config.endpoints?.ready) {
173
- handlers[this.config.endpoints.ready] = HealthEndpoints.ready
174
- }
175
- if (this.config.endpoints?.live) {
176
- handlers[this.config.endpoints.live] = HealthEndpoints.live
177
- }
178
- if (this.config.endpoints?.startup) {
179
- handlers[this.config.endpoints.startup] = HealthEndpoints.startup
180
- }
181
- }
182
-
183
- // Correlation endpoints
184
- if (this.config.enableCorrelation) {
185
- if (this.config.endpoints?.trace) {
186
- handlers[this.config.endpoints.trace] = CorrelationEndpoints.trace
187
- }
188
- if (this.config.endpoints?.correlationStats) {
189
- handlers[this.config.endpoints.correlationStats] = CorrelationEndpoints.stats
190
- }
191
- }
192
-
193
- return handlers
194
- }
195
-
196
- /**
197
- * Get observability status
198
- */
199
- getStatus(): {
200
- initialized: boolean
201
- components: {
202
- tracing: boolean
203
- metrics: boolean
204
- healthChecks: boolean
205
- correlation: boolean
206
- }
207
- endpoints: string[]
208
- } {
209
- const handlers = this.createRouteHandlers()
210
-
211
- return {
212
- initialized: this.initialized,
213
- components: {
214
- tracing: this.config.enableTracing || false,
215
- metrics: this.config.enableMetrics || false,
216
- healthChecks: this.config.enableHealthChecks || false,
217
- correlation: this.config.enableCorrelation || false,
218
- },
219
- endpoints: Object.keys(handlers),
220
- }
221
- }
222
- }
223
-
224
- /**
225
- * Global observability manager
226
- */
227
- let globalObservabilityManager: ObservabilityManager | null = null
228
-
229
- /**
230
- * Initialize global observability
231
- */
232
- export function initializeObservability(config?: ObservabilityConfig): ObservabilityManager {
233
- globalObservabilityManager = new ObservabilityManager(config)
234
- globalObservabilityManager.initialize()
235
- return globalObservabilityManager
236
- }
237
-
238
- /**
239
- * Get global observability manager
240
- */
241
- export function getObservabilityManager(): ObservabilityManager | null {
242
- return globalObservabilityManager
243
- }
244
-
245
- /**
246
- * Observability presets for common configurations
247
- */
248
- export const ObservabilityPresets = {
249
- /**
250
- * Development preset - console logging, basic metrics
251
- */
252
- development: (): ObservabilityConfig => ({
253
- enableTracing: true,
254
- enableMetrics: true,
255
- enableHealthChecks: true,
256
- enableCorrelation: true,
257
- tracing: {
258
- serviceName: 'bun-router-dev',
259
- environment: 'development',
260
- enableConsoleExporter: true,
261
- sampleRate: 1.0,
262
- },
263
- metrics: {
264
- enableDefaultMetrics: true,
265
- collectInterval: 15000,
266
- },
267
- healthChecks: {
268
- timeout: 3000,
269
- interval: 30000,
270
- },
271
- correlation: {
272
- enableLogging: true,
273
- logLevel: 'debug',
274
- },
275
- }),
276
-
277
- /**
278
- * Production preset - optimized for performance
279
- */
280
- production: (): ObservabilityConfig => ({
281
- enableTracing: true,
282
- enableMetrics: true,
283
- enableHealthChecks: true,
284
- enableCorrelation: true,
285
- tracing: {
286
- serviceName: 'bun-router',
287
- environment: 'production',
288
- enableConsoleExporter: false,
289
- enableOTLPExporter: true,
290
- sampleRate: 0.1, // 10% sampling
291
- },
292
- metrics: {
293
- enableDefaultMetrics: true,
294
- collectInterval: 30000,
295
- },
296
- healthChecks: {
297
- timeout: 5000,
298
- interval: 60000,
299
- },
300
- correlation: {
301
- enableLogging: false,
302
- },
303
- }),
304
-
305
- /**
306
- * Kubernetes preset - optimized for k8s deployment
307
- */
308
- kubernetes: (): ObservabilityConfig => ({
309
- enableTracing: true,
310
- enableMetrics: true,
311
- enableHealthChecks: true,
312
- enableCorrelation: true,
313
- tracing: {
314
- serviceName: process.env.SERVICE_NAME || 'bun-router',
315
- environment: process.env.ENVIRONMENT || 'production',
316
- enableOTLPExporter: true,
317
- otlpEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
318
- sampleRate: Number.parseFloat(process.env.OTEL_SAMPLE_RATE || '0.1'),
319
- },
320
- metrics: {
321
- prefix: process.env.METRICS_PREFIX,
322
- enableDefaultMetrics: true,
323
- collectInterval: 30000,
324
- },
325
- healthChecks: {
326
- timeout: 10000,
327
- gracePeriod: 30000,
328
- },
329
- correlation: {
330
- enableLogging: process.env.NODE_ENV !== 'production',
331
- },
332
- endpoints: {
333
- metrics: '/metrics',
334
- health: '/health',
335
- ready: '/health/ready',
336
- live: '/health/live',
337
- startup: '/health/startup',
338
- },
339
- }),
340
-
341
- /**
342
- * Microservices preset - enhanced correlation and tracing
343
- */
344
- microservices: (): ObservabilityConfig => ({
345
- enableTracing: true,
346
- enableMetrics: true,
347
- enableHealthChecks: true,
348
- enableCorrelation: true,
349
- tracing: {
350
- serviceName: process.env.SERVICE_NAME || 'bun-router-service',
351
- environment: process.env.ENVIRONMENT || 'production',
352
- enableJaegerExporter: true,
353
- jaegerEndpoint: process.env.JAEGER_ENDPOINT,
354
- sampleRate: 0.2, // Higher sampling for microservices
355
- },
356
- metrics: {
357
- enableDefaultMetrics: true,
358
- collectInterval: 15000,
359
- },
360
- healthChecks: {
361
- timeout: 5000,
362
- dependencies: [
363
- // Add your service dependencies here
364
- ],
365
- },
366
- correlation: {
367
- propagateHeaders: [
368
- 'x-correlation-id',
369
- 'x-request-id',
370
- 'x-trace-id',
371
- 'x-span-id',
372
- 'x-user-id',
373
- 'x-session-id',
374
- 'x-tenant-id',
375
- ],
376
- enableLogging: true,
377
- },
378
- }),
379
-
380
- /**
381
- * Minimal preset - basic observability
382
- */
383
- minimal: (): ObservabilityConfig => ({
384
- enableTracing: false,
385
- enableMetrics: true,
386
- enableHealthChecks: true,
387
- enableCorrelation: false,
388
- metrics: {
389
- enableDefaultMetrics: true,
390
- collectInterval: 60000,
391
- },
392
- healthChecks: {
393
- timeout: 3000,
394
- },
395
- endpoints: {
396
- metrics: '/metrics',
397
- health: '/health',
398
- },
399
- }),
400
- }
401
-
402
- /**
403
- * Router integration helpers
404
- */
405
- export const ObservabilityIntegration = {
406
- /**
407
- * Add observability to router
408
- */
409
- enhance: (router: any, config?: ObservabilityConfig): {
410
- manager: ObservabilityManager
411
- middleware: (req: EnhancedRequest, next: () => Promise<Response>) => Promise<Response>
412
- handlers: Record<string, (req: EnhancedRequest) => Promise<Response>>
413
- status: ReturnType<ObservabilityManager['getStatus']>
414
- } => {
415
- const manager = initializeObservability(config)
416
- const middleware = manager.createMiddleware()
417
- const handlers = manager.createRouteHandlers()
418
-
419
- // Add middleware to router
420
- router.use(middleware)
421
-
422
- // Add observability endpoints
423
- Object.entries(handlers).forEach(([path, handler]: [string, (_req: EnhancedRequest) => Promise<Response>]) => {
424
- router.get(path, handler)
425
- })
426
-
427
- const result: {
428
- manager: ObservabilityManager
429
- middleware: (req: EnhancedRequest, next: () => Promise<Response>) => Promise<Response>
430
- handlers: Record<string, (req: EnhancedRequest) => Promise<Response>>
431
- status: ReturnType<ObservabilityManager['getStatus']>
432
- } = {
433
- manager,
434
- middleware,
435
- handlers,
436
- status: manager.getStatus(),
437
- }
438
- return result
439
- },
440
-
441
- /**
442
- * Create observability-enabled route builder
443
- */
444
- createRouteBuilder: (config?: ObservabilityConfig) => {
445
- const manager = initializeObservability(config)
446
-
447
- return {
448
- /**
449
- * Create route with observability
450
- */
451
- route: (method: string, path: string, handler: (req: EnhancedRequest) => Promise<Response>): { method: string, path: string, handler: (req: EnhancedRequest) => Promise<Response> } => {
452
- const middleware = manager.createMiddleware()
453
-
454
- return {
455
- method,
456
- path,
457
- handler: async (req: EnhancedRequest) => {
458
- return await middleware(req, () => handler(req))
459
- },
460
- }
461
- },
462
-
463
- /**
464
- * Get observability endpoints
465
- */
466
- getEndpoints: (): Record<string, (req: EnhancedRequest) => Promise<Response>> => manager.createRouteHandlers(),
467
-
468
- /**
469
- * Get manager instance
470
- */
471
- getManager: (): ObservabilityManager => manager,
472
- }
473
- },
474
- }
475
-
476
- /**
477
- * Utility functions for observability
478
- */
479
- export const ObservabilityUtils = {
480
- /**
481
- * Create observability configuration from environment
482
- */
483
- fromEnvironment: (): ObservabilityConfig => {
484
- const preset = process.env.OBSERVABILITY_PRESET as keyof typeof ObservabilityPresets
485
-
486
- if (preset && ObservabilityPresets[preset]) {
487
- return ObservabilityPresets[preset]()
488
- }
489
-
490
- // Default configuration from environment variables
491
- return {
492
- enableTracing: process.env.ENABLE_TRACING !== 'false',
493
- enableMetrics: process.env.ENABLE_METRICS !== 'false',
494
- enableHealthChecks: process.env.ENABLE_HEALTH_CHECKS !== 'false',
495
- enableCorrelation: process.env.ENABLE_CORRELATION !== 'false',
496
- tracing: {
497
- serviceName: process.env.SERVICE_NAME || 'bun-router',
498
- environment: process.env.ENVIRONMENT || process.env.NODE_ENV || 'development',
499
- otlpEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
500
- jaegerEndpoint: process.env.JAEGER_ENDPOINT,
501
- sampleRate: Number.parseFloat(process.env.OTEL_SAMPLE_RATE || '1.0'),
502
- },
503
- metrics: {
504
- prefix: process.env.METRICS_PREFIX,
505
- collectInterval: Number.parseInt(process.env.METRICS_COLLECT_INTERVAL || '30000'),
506
- },
507
- correlation: {
508
- enableLogging: process.env.CORRELATION_LOGGING !== 'false',
509
- },
510
- }
511
- },
512
-
513
- /**
514
- * Validate observability configuration
515
- */
516
- validateConfig: (config: ObservabilityConfig): string[] => {
517
- const errors: string[] = []
518
-
519
- if (config.tracing?.sampleRate && (config.tracing.sampleRate < 0 || config.tracing.sampleRate > 1)) {
520
- errors.push('Tracing sample rate must be between 0 and 1')
521
- }
522
-
523
- if (config.metrics?.collectInterval && config.metrics.collectInterval < 1000) {
524
- errors.push('Metrics collect interval must be at least 1000ms')
525
- }
526
-
527
- if (config.healthChecks?.timeout && config.healthChecks.timeout < 100) {
528
- errors.push('Health check timeout must be at least 100ms')
529
- }
530
-
531
- return errors
532
- },
533
-
534
- /**
535
- * Get observability summary
536
- */
537
- getSummary: (): any => {
538
- const manager = getObservabilityManager()
539
- if (!manager) {
540
- return { status: 'not_initialized' }
541
- }
542
-
543
- return {
544
- status: 'initialized',
545
- ...manager.getStatus(),
546
- }
547
- },
548
- }