@oas-tools/oas-telemetry 0.7.1 → 0.8.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/.env.example +21 -2
  2. package/README.md +1 -2
  3. package/dist/cjs/config/bootConfig.cjs +19 -14
  4. package/dist/cjs/config/config.cjs +112 -125
  5. package/dist/cjs/config/config.types.cjs +1 -4
  6. package/dist/cjs/docs/openapi.yaml +158 -4
  7. package/dist/cjs/index.cjs +27 -30
  8. package/dist/cjs/routesManager.cjs +62 -70
  9. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +202 -190
  10. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +204 -99
  11. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +152 -116
  12. package/dist/cjs/telemetry/custom-implementations/instrumentations/logsInstrumentation.cjs +92 -0
  13. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Chunk.cjs +159 -0
  14. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Series.cjs +168 -0
  15. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.cjs +389 -0
  16. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/types.cjs +2 -0
  17. package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/utils.cjs +77 -0
  18. package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.cjs +65 -63
  19. package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.cjs +63 -62
  20. package/dist/cjs/telemetry/custom-implementations/utils/circular.cjs +47 -47
  21. package/dist/cjs/telemetry/custom-implementations/utils/storagePath.cjs +39 -0
  22. package/dist/cjs/telemetry/custom-implementations/wrappers.cjs +141 -138
  23. package/dist/cjs/telemetry/initializeTelemetry.cjs +35 -91
  24. package/dist/cjs/telemetry/telemetryConfigurator.cjs +70 -72
  25. package/dist/cjs/telemetry/telemetryRegistry.cjs +45 -31
  26. package/dist/cjs/tlm-ai/agent.cjs +49 -64
  27. package/dist/cjs/tlm-ai/aiController.cjs +54 -76
  28. package/dist/cjs/tlm-ai/aiRoutes.cjs +17 -20
  29. package/dist/cjs/tlm-ai/aiService.cjs +91 -95
  30. package/dist/cjs/tlm-ai/tools.cjs +177 -174
  31. package/dist/cjs/tlm-auth/authController.cjs +80 -123
  32. package/dist/cjs/tlm-auth/authMiddleware.cjs +25 -30
  33. package/dist/cjs/tlm-auth/authRoutes.cjs +11 -14
  34. package/dist/cjs/tlm-log/logController.cjs +171 -116
  35. package/dist/cjs/tlm-log/logRoutes.cjs +20 -20
  36. package/dist/cjs/tlm-metric/metricsController.cjs +211 -121
  37. package/dist/cjs/tlm-metric/metricsRoutes.cjs +23 -20
  38. package/dist/cjs/tlm-plugin/pluginController.cjs +128 -140
  39. package/dist/cjs/tlm-plugin/pluginProcess.cjs +89 -94
  40. package/dist/cjs/tlm-plugin/pluginRoutes.cjs +11 -14
  41. package/dist/cjs/tlm-plugin/pluginService.cjs +73 -74
  42. package/dist/cjs/tlm-trace/traceController.cjs +169 -117
  43. package/dist/cjs/tlm-trace/traceRoutes.cjs +20 -20
  44. package/dist/cjs/tlm-ui/uiRoutes.cjs +63 -32
  45. package/dist/cjs/tlm-util/utilController.cjs +68 -70
  46. package/dist/cjs/tlm-util/utilRoutes.cjs +51 -63
  47. package/dist/cjs/types/index.cjs +2 -5
  48. package/dist/cjs/utils/logger.cjs +38 -43
  49. package/dist/cjs/utils/regexUtils.cjs +22 -22
  50. package/dist/esm/config/bootConfig.js +6 -0
  51. package/dist/esm/config/config.js +1 -2
  52. package/dist/esm/docs/openapi.yaml +158 -4
  53. package/dist/esm/index.js +9 -8
  54. package/dist/esm/routesManager.js +6 -10
  55. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +47 -8
  56. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +164 -48
  57. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +69 -29
  58. package/dist/esm/telemetry/custom-implementations/instrumentations/logsInstrumentation.js +85 -0
  59. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Chunk.js +155 -0
  60. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Series.js +164 -0
  61. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.js +382 -0
  62. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/types.js +1 -0
  63. package/dist/esm/telemetry/custom-implementations/metrics/tsdb/utils.js +74 -0
  64. package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.js +2 -1
  65. package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.js +1 -1
  66. package/dist/esm/telemetry/custom-implementations/utils/storagePath.js +33 -0
  67. package/dist/esm/telemetry/custom-implementations/wrappers.js +5 -2
  68. package/dist/esm/telemetry/initializeTelemetry.js +27 -69
  69. package/dist/esm/telemetry/telemetryConfigurator.js +42 -40
  70. package/dist/esm/telemetry/telemetryRegistry.js +12 -1
  71. package/dist/esm/tlm-ai/agent.js +5 -3
  72. package/dist/esm/tlm-ai/aiController.js +3 -3
  73. package/dist/esm/tlm-ai/aiService.js +6 -2
  74. package/dist/esm/tlm-ai/tools.js +5 -9
  75. package/dist/esm/tlm-auth/authController.js +3 -2
  76. package/dist/esm/tlm-log/logController.js +84 -4
  77. package/dist/esm/tlm-log/logRoutes.js +5 -2
  78. package/dist/esm/tlm-metric/metricsController.js +172 -49
  79. package/dist/esm/tlm-metric/metricsRoutes.js +10 -4
  80. package/dist/esm/tlm-plugin/pluginController.js +6 -11
  81. package/dist/esm/tlm-plugin/pluginService.js +2 -4
  82. package/dist/esm/tlm-trace/traceController.js +102 -16
  83. package/dist/esm/tlm-trace/traceRoutes.js +5 -2
  84. package/dist/esm/tlm-ui/uiRoutes.js +5 -5
  85. package/dist/esm/tlm-util/utilController.js +3 -9
  86. package/dist/esm/tlm-util/utilRoutes.js +2 -2
  87. package/dist/types/config/bootConfig.d.ts +4 -0
  88. package/dist/types/config/config.d.ts +36 -7
  89. package/dist/types/config/config.types.d.ts +6 -0
  90. package/dist/types/index.d.ts +2 -3
  91. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +4 -1
  92. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +60 -15
  93. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +9 -4
  94. package/dist/types/telemetry/custom-implementations/instrumentations/logsInstrumentation.d.ts +23 -0
  95. package/dist/types/telemetry/custom-implementations/metrics/tsdb/Chunk.d.ts +49 -0
  96. package/dist/types/telemetry/custom-implementations/metrics/tsdb/Series.d.ts +67 -0
  97. package/dist/types/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.d.ts +69 -0
  98. package/dist/types/telemetry/custom-implementations/metrics/tsdb/types.d.ts +68 -0
  99. package/dist/types/telemetry/custom-implementations/metrics/tsdb/utils.d.ts +21 -0
  100. package/dist/types/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.d.ts +2 -2
  101. package/dist/types/telemetry/custom-implementations/utils/storagePath.d.ts +12 -0
  102. package/dist/types/telemetry/custom-implementations/wrappers.d.ts +1 -1
  103. package/dist/types/telemetry/telemetryConfigurator.d.ts +1 -1
  104. package/dist/types/telemetry/telemetryRegistry.d.ts +8 -0
  105. package/dist/types/tlm-ai/agent.d.ts +1 -1
  106. package/dist/types/tlm-ai/aiService.d.ts +1 -1
  107. package/dist/types/tlm-log/logController.d.ts +2 -0
  108. package/dist/types/tlm-metric/metricsController.d.ts +16 -2
  109. package/dist/types/tlm-trace/traceController.d.ts +3 -1
  110. package/dist/types/types/index.d.ts +2 -2
  111. package/dist/ui/assets/{ApiDocsPage-C_VVPPHa.js → ApiDocsPage-BFUrXE5F.js} +2 -2
  112. package/dist/ui/assets/CollapsibleCard-STA1GVQO.js +1 -0
  113. package/dist/ui/assets/DevToolsPage-BRSfZqO_.js +1 -0
  114. package/dist/ui/assets/LandingPage-DzeDy7q7.js +6 -0
  115. package/dist/ui/assets/LogsPage-BeiFrV2X.js +1 -0
  116. package/dist/ui/assets/{NotFoundPage-B3quk3P1.js → NotFoundPage-fRNOatbM.js} +1 -1
  117. package/dist/ui/assets/PluginCreatePage-Ch_RXsdf.js +50 -0
  118. package/dist/ui/assets/PluginPage-Cl65ZZ_n.js +27 -0
  119. package/dist/ui/assets/TraceSpansPage-BoK4M5Hh.js +6 -0
  120. package/dist/ui/assets/VirtualizedListPanel-zcj0v7DL.js +16 -0
  121. package/dist/ui/assets/alert-BkNVKxJN.js +1133 -0
  122. package/dist/ui/assets/badge-CN7FeufU.js +1 -0
  123. package/dist/ui/assets/{chevron-down-CPsvsmqj.js → chevron-down-CG--ounh.js} +1 -1
  124. package/dist/ui/assets/{chevron-up-Df9jMo1X.js → chevron-up-B6tzMAOm.js} +1 -1
  125. package/dist/ui/assets/{circle-alert-DOPQPvU8.js → circle-alert-BDF8Tq9y.js} +1 -1
  126. package/dist/ui/assets/dialog-BrpWNk36.js +15 -0
  127. package/dist/ui/assets/index-6xOVKwKn.js +305 -0
  128. package/dist/ui/assets/index-D6f1KjWV.css +1 -0
  129. package/dist/ui/assets/index-D96rVSkR.js +1 -0
  130. package/dist/ui/assets/info-99kuqpbx.js +6 -0
  131. package/dist/ui/assets/{input-Dzvg_ZEZ.js → input-B-01QDg_.js} +1 -1
  132. package/dist/ui/assets/label-CQLeZjM1.js +1 -0
  133. package/dist/ui/assets/{loader-circle-CrvlRy5o.js → loader-circle-BoDGk-BO.js} +1 -1
  134. package/dist/ui/assets/{loginPage-qa4V-B70.js → loginPage-8F4EEd1B.js} +1 -1
  135. package/dist/ui/assets/metrics-page-D1GxaB_c.css +1 -0
  136. package/dist/ui/assets/metrics-page-DPtteXqY.js +31 -0
  137. package/dist/ui/assets/popover-DS_8DYYt.js +11 -0
  138. package/dist/ui/assets/select-DYjegiXi.js +6 -0
  139. package/dist/ui/assets/separator-DGsRxIrl.js +6 -0
  140. package/dist/ui/assets/severityOptions-DEOvJqC9.js +11 -0
  141. package/dist/ui/assets/square-pen-DPhgYz6O.js +6 -0
  142. package/dist/ui/assets/switch-Di9NJH2A.js +1 -0
  143. package/dist/ui/assets/trace-DJq1miYa.js +1 -0
  144. package/dist/ui/assets/upload-BiLTpCnX.js +11 -0
  145. package/dist/ui/assets/{utilService-DNyqzwj0.js → utilService-CNZOmadC.js} +1 -1
  146. package/dist/ui/assets/wand-sparkles-CPoBNFFg.js +6 -0
  147. package/dist/ui/index.html +2 -2
  148. package/package.json +44 -48
  149. package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +0 -1
  150. package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +0 -1
  151. package/dist/ui/assets/LandingPage-CppFBA6K.js +0 -6
  152. package/dist/ui/assets/LogsPage-9Fq8GArS.js +0 -26
  153. package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +0 -50
  154. package/dist/ui/assets/PluginPage-DMDSihrZ.js +0 -27
  155. package/dist/ui/assets/alert-jQ9HCPIf.js +0 -1133
  156. package/dist/ui/assets/badge-CNq0-mH5.js +0 -1
  157. package/dist/ui/assets/card-DFAwwhN3.js +0 -1
  158. package/dist/ui/assets/index-BkD6DijD.js +0 -15
  159. package/dist/ui/assets/index-CERGVYZK.js +0 -292
  160. package/dist/ui/assets/index-CSIPf9qw.css +0 -1
  161. package/dist/ui/assets/label-DuVnkZ4q.js +0 -1
  162. package/dist/ui/assets/select-DhS8YUtJ.js +0 -1
  163. package/dist/ui/assets/separator-isK4chBP.js +0 -6
  164. package/dist/ui/assets/severityOptions-O38dSOfk.js +0 -11
  165. package/dist/ui/assets/switch-Z3mImG9n.js +0 -1
  166. package/dist/ui/assets/tabs-_77MUUQe.js +0 -16
  167. package/dist/ui/assets/upload-C1LT4Gkb.js +0 -16
@@ -1,12 +1,11 @@
1
- import { OasTlmConfig, DeepPartial, UserConfig } from './config.types';
1
+ import { OasTlmConfig, DeepPartial, UserConfig } from './config.types.js';
2
2
  import { BufferConfig, SpanExporter, SpanProcessor } from '@opentelemetry/sdk-trace-node';
3
3
  import { IMetricReader, MetricProducer } from '@opentelemetry/sdk-metrics';
4
4
  import { LogRecordExporter, LogRecordProcessor } from '@opentelemetry/sdk-logs';
5
5
  import { type PluginResource } from '../types/index.js';
6
- import { ViewOptions } from '@opentelemetry/sdk-metrics/build/src/view/View';
6
+ import { type ViewOptions } from '@opentelemetry/sdk-metrics/build/src/view/View.js';
7
7
  export declare const defaultConfig: {
8
8
  general: {
9
- baseUrl: string;
10
9
  specFileName: string | null;
11
10
  spec: string | null;
12
11
  uiPath: string;
@@ -61,10 +60,10 @@ export declare const defaultConfig: {
61
60
  enabled: boolean;
62
61
  extraPlugins: PluginResource[];
63
62
  };
63
+ instrumentations: any[];
64
64
  };
65
65
  export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTlmConfig, envConfig?: DeepPartial<OasTlmConfig>) => {
66
66
  general: {
67
- baseUrl: string;
68
67
  specFileName: string | null;
69
68
  spec: string | null;
70
69
  uiPath: string;
@@ -119,9 +118,9 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
119
118
  enabled: boolean;
120
119
  extraPlugins: PluginResource[];
121
120
  };
121
+ instrumentations: any[];
122
122
  } & UserConfig & {
123
123
  general?: {
124
- baseUrl?: string | undefined;
125
124
  specFileName?: string | null | undefined;
126
125
  spec?: string | null | undefined;
127
126
  uiPath?: string | undefined;
@@ -147,6 +146,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
147
146
  extraProcessors?: ({
148
147
  forceFlush?: {} | undefined;
149
148
  onStart?: {} | undefined;
149
+ onEnding?: {} | undefined;
150
150
  onEnd?: {} | undefined;
151
151
  shutdown?: {} | undefined;
152
152
  } | undefined)[] | undefined;
@@ -269,6 +269,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
269
269
  name?: string | undefined;
270
270
  message?: string | undefined;
271
271
  stack?: string | undefined;
272
+ cause?: unknown;
272
273
  } | null | undefined;
273
274
  readonly writableNeedDrain?: boolean | undefined;
274
275
  _write?: {} | undefined;
@@ -289,6 +290,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
289
290
  prependListener?: {} | undefined;
290
291
  prependOnceListener?: {} | undefined;
291
292
  removeListener?: {} | undefined;
293
+ [Symbol.asyncDispose]?: {} | undefined;
292
294
  pipe?: {} | undefined;
293
295
  compose?: {} | undefined;
294
296
  [EventEmitter.captureRejectionSymbol]?: {} | undefined;
@@ -317,6 +319,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
317
319
  name?: string | undefined;
318
320
  message?: string | undefined;
319
321
  stack?: string | undefined;
322
+ cause?: unknown;
320
323
  } | null | undefined;
321
324
  _construct?: {} | undefined;
322
325
  _read?: {} | undefined;
@@ -381,6 +384,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
381
384
  name?: string | undefined;
382
385
  message?: string | undefined;
383
386
  stack?: string | undefined;
387
+ cause?: unknown;
384
388
  } | null | undefined;
385
389
  _construct?: {} | undefined;
386
390
  _read?: {} | undefined;
@@ -430,10 +434,24 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
430
434
  eventNames?: {} | undefined;
431
435
  } | null | undefined;
432
436
  readonly channel?: {
433
- close?: {} | undefined;
434
- hasRef?: {} | undefined;
435
437
  ref?: {} | undefined;
436
438
  unref?: {} | undefined;
439
+ [EventEmitter.captureRejectionSymbol]?: {} | undefined;
440
+ addListener?: {} | undefined;
441
+ on?: {} | undefined;
442
+ once?: {} | undefined;
443
+ removeListener?: {} | undefined;
444
+ off?: {} | undefined;
445
+ removeAllListeners?: {} | undefined;
446
+ setMaxListeners?: {} | undefined;
447
+ getMaxListeners?: {} | undefined;
448
+ listeners?: {} | undefined;
449
+ rawListeners?: {} | undefined;
450
+ emit?: {} | undefined;
451
+ listenerCount?: {} | undefined;
452
+ prependListener?: {} | undefined;
453
+ prependOnceListener?: {} | undefined;
454
+ eventNames?: {} | undefined;
437
455
  } | null | undefined;
438
456
  readonly stdio?: [({
439
457
  readonly writable?: boolean | undefined;
@@ -450,6 +468,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
450
468
  name?: string | undefined;
451
469
  message?: string | undefined;
452
470
  stack?: string | undefined;
471
+ cause?: unknown;
453
472
  } | null | undefined;
454
473
  readonly writableNeedDrain?: boolean | undefined;
455
474
  _write?: {} | undefined;
@@ -470,6 +489,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
470
489
  prependListener?: {} | undefined;
471
490
  prependOnceListener?: {} | undefined;
472
491
  removeListener?: {} | undefined;
492
+ [Symbol.asyncDispose]?: {} | undefined;
473
493
  pipe?: {} | undefined;
474
494
  compose?: {} | undefined;
475
495
  [EventEmitter.captureRejectionSymbol]?: {} | undefined;
@@ -497,6 +517,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
497
517
  name?: string | undefined;
498
518
  message?: string | undefined;
499
519
  stack?: string | undefined;
520
+ cause?: unknown;
500
521
  } | null | undefined;
501
522
  _construct?: {} | undefined;
502
523
  _read?: {} | undefined;
@@ -560,6 +581,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
560
581
  name?: string | undefined;
561
582
  message?: string | undefined;
562
583
  stack?: string | undefined;
584
+ cause?: unknown;
563
585
  } | null | undefined;
564
586
  _construct?: {} | undefined;
565
587
  _read?: {} | undefined;
@@ -622,6 +644,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
622
644
  name?: string | undefined;
623
645
  message?: string | undefined;
624
646
  stack?: string | undefined;
647
+ cause?: unknown;
625
648
  } | null | undefined;
626
649
  readonly writableNeedDrain?: boolean | undefined;
627
650
  _write?: {} | undefined;
@@ -642,6 +665,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
642
665
  prependListener?: {} | undefined;
643
666
  prependOnceListener?: {} | undefined;
644
667
  removeListener?: {} | undefined;
668
+ [Symbol.asyncDispose]?: {} | undefined;
645
669
  pipe?: {} | undefined;
646
670
  compose?: {} | undefined;
647
671
  [EventEmitter.captureRejectionSymbol]?: {} | undefined;
@@ -669,6 +693,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
669
693
  name?: string | undefined;
670
694
  message?: string | undefined;
671
695
  stack?: string | undefined;
696
+ cause?: unknown;
672
697
  } | null | undefined;
673
698
  _construct?: {} | undefined;
674
699
  _read?: {} | undefined;
@@ -731,6 +756,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
731
756
  name?: string | undefined;
732
757
  message?: string | undefined;
733
758
  stack?: string | undefined;
759
+ cause?: unknown;
734
760
  } | null | undefined;
735
761
  readonly writableNeedDrain?: boolean | undefined;
736
762
  _write?: {} | undefined;
@@ -751,6 +777,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
751
777
  prependListener?: {} | undefined;
752
778
  prependOnceListener?: {} | undefined;
753
779
  removeListener?: {} | undefined;
780
+ [Symbol.asyncDispose]?: {} | undefined;
754
781
  pipe?: {} | undefined;
755
782
  compose?: {} | undefined;
756
783
  [EventEmitter.captureRejectionSymbol]?: {} | undefined;
@@ -778,6 +805,7 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
778
805
  name?: string | undefined;
779
806
  message?: string | undefined;
780
807
  stack?: string | undefined;
808
+ cause?: unknown;
781
809
  } | null | undefined;
782
810
  _construct?: {} | undefined;
783
811
  _read?: {} | undefined;
@@ -858,4 +886,5 @@ export declare const getConfig: (userConfig?: UserConfig, fallbackConfig?: OasTl
858
886
  } | undefined;
859
887
  } | undefined)[] | undefined;
860
888
  } | undefined;
889
+ instrumentations?: any[] | undefined;
861
890
  };
@@ -3,6 +3,7 @@ import { IMetricReader } from "@opentelemetry/sdk-metrics";
3
3
  import { SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-node";
4
4
  import { defaultConfig } from "./config.js";
5
5
  import { ViewOptions } from "@opentelemetry/sdk-metrics/build/src/view/View.js";
6
+ import { type Instrumentation } from "@opentelemetry/instrumentation";
6
7
  export type DeepPartial<T> = T extends object ? {
7
8
  [P in keyof T]?: DeepPartial<T[P]>;
8
9
  } : T;
@@ -31,4 +32,9 @@ export type UserConfig = {
31
32
  memoryExporter?: Partial<OasTlmConfig["logs"]["memoryExporter"]>;
32
33
  };
33
34
  plugins?: Partial<OasTlmConfig["plugins"]>;
35
+ /**
36
+ * User can register its own instrumentations to be used by oas-telemetry. oas-telemetry will assign the providers to these instrumentations.
37
+ * This is useful when the user wants to use instrumentations that are not included by default in oas-telemetry.
38
+ */
39
+ instrumentations?: Instrumentation[];
34
40
  };
@@ -1,10 +1,9 @@
1
1
  import "./config/bootConfig.js";
2
2
  import './telemetry/initializeTelemetry.js';
3
- import { Router } from 'express';
4
3
  import { UserConfig } from './config/config.types.js';
5
4
  /**
6
5
  * Returns the OAS-Telemetry middleware.
7
6
  * All parameters are optional. However, either `spec` or `specFileName` must be provided to enable endpoint filtering.
8
7
  */
9
- declare function oasTelemetry(oasTlmInputConfig?: UserConfig): Router;
10
- export = oasTelemetry;
8
+ declare function oasTelemetry(oasTlmInputConfig?: UserConfig): any;
9
+ export { oasTelemetry };
@@ -5,7 +5,10 @@ export declare class InMemoryDbLogExporter extends Enabler implements LogRecordE
5
5
  private _db;
6
6
  private _miniSearch;
7
7
  private _retentionTimeInSeconds;
8
+ private _storagePath;
9
+ private _initialized;
8
10
  constructor(retentionTimeInSeconds?: number);
11
+ private _ensureInitialized;
9
12
  /**
10
13
  * Export logs.
11
14
  * @param logs
@@ -20,7 +23,7 @@ export declare class InMemoryDbLogExporter extends Enabler implements LogRecordE
20
23
  find(findConfig: {
21
24
  query: any;
22
25
  messageSearch: string | null;
23
- limit: number;
26
+ limit?: number;
24
27
  sortOrder?: any;
25
28
  }): Promise<any[]>;
26
29
  insert(data: any[], callback: (err: any, newDocs: any[]) => void): void;
@@ -1,22 +1,67 @@
1
- import { PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics';
1
+ import { PushMetricExporter, ResourceMetrics, ScopeMetrics } from '@opentelemetry/sdk-metrics';
2
2
  import { Enabler } from '../wrappers.js';
3
+ import { Resource } from '@opentelemetry/resources';
4
+ import { FindMetricsRequest } from '../metrics/tsdb/types.js';
5
+ export interface ExporterConfig {
6
+ retentionTimeInSeconds?: number;
7
+ chunkSize?: number;
8
+ maxChunks?: number;
9
+ }
10
+ /**
11
+ * In-Memory TSDB Metric Exporter
12
+ * Series identified by: scope + metricName + attributes
13
+ */
3
14
  export declare class InMemoryDbMetricExporter extends Enabler implements PushMetricExporter {
4
- private _metrics;
5
- private _retentionTimeInSeconds;
6
- constructor(retentionTimeInSeconds?: number);
7
- export(metrics: ResourceMetrics, resultCallback: any): any;
15
+ private static readonly DEFAULT_CONFIG;
16
+ private readonly registry;
17
+ private readonly config;
18
+ private cachedResource;
19
+ private _storageFilePath;
20
+ private _autoSaveInterval;
21
+ private _storageLogged;
22
+ get rawDataDB(): any[];
23
+ constructor(config?: Partial<ExporterConfig>);
24
+ private _loadMetricsFromDisk;
25
+ private _startAutoSave;
26
+ private _saveMetricsToDisk;
27
+ export(resourceMetrics: ResourceMetrics, resultCallback: any): any;
8
28
  shutdown(): Promise<void>;
9
- forceFlush(): Promise<void>;
10
- find(search: any, callback: any): void;
11
29
  reset(): void;
12
- getFinishedMetrics(): import("@seald-io/nedb").Document<Record<string, any>>[];
13
- /**
14
- * Inserts metrics into the in-memory database.
15
- * @param metrics - The metrics to insert.
16
- * @param callback - The callback to execute after insertion.
17
- */
18
- insert(metrics: any[], callback: (err: any, newDocs: any[]) => void): void;
19
- set retentionTimeInSeconds(retentionTimeInSeconds: number);
30
+ forceFlush(): Promise<void>;
31
+ getCachedResource(): Resource | null;
32
+ set retentionTimeInSeconds(value: number);
20
33
  get retentionTimeInSeconds(): number;
34
+ getStats(): {
35
+ totalMetrics: number;
36
+ totalScopes: number;
37
+ totalSeries: number;
38
+ totalSamples: number;
39
+ memoryUsageBytes: number;
40
+ };
21
41
  private _startCleanupJob;
42
+ /**
43
+ * Find metrics by scope+metric queries with filters
44
+ * Supports both raw and otel formats
45
+ */
46
+ find(request: FindMetricsRequest): {
47
+ results: any[];
48
+ };
49
+ /**
50
+ * Export all metrics to NDJSON format (one chunk per line)
51
+ */
52
+ exportToNDJSON(): string;
53
+ /**
54
+ * Import metrics from NDJSON format
55
+ */
56
+ importFromNDJSON(ndjsonData: string): void;
57
+ /**
58
+ * Insert metrics in OpenTelemetry (OTEL) format directly into the registry
59
+ * @param scopeMetrics Array of ScopeMetrics (OTEL format)
60
+ */
61
+ insertOtel(scopeMetrics: ScopeMetrics[]): void;
62
+ /**
63
+ * Insert metrics in raw format (MetricQueryResult[]), converts to OTEL and delegates to insertOtel
64
+ * @param rawScopeMetrics Array of MetricQueryResult (raw format)
65
+ */
66
+ insertRaw(rawScopeMetrics: any[]): void;
22
67
  }
@@ -3,10 +3,11 @@ import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
3
3
  import { Enabler } from '../wrappers.js';
4
4
  export declare class InMemoryDbSpanExporter extends Enabler implements SpanExporter {
5
5
  private _spans;
6
- private _baseUrl;
7
6
  private _retentionTimeInSeconds;
7
+ private _storagePath;
8
+ private _initialized;
8
9
  constructor(retentionTimeInSeconds?: number);
9
- set baseUrl(baseUrl: string);
10
+ private _ensureInitialized;
10
11
  set retentionTimeInSeconds(retentionTimeInSeconds: number);
11
12
  get retentionTimeInSeconds(): number;
12
13
  export(readableSpans: ReadableSpan[], resultCallback: (arg0: {
@@ -14,12 +15,16 @@ export declare class InMemoryDbSpanExporter extends Enabler implements SpanExpor
14
15
  error?: Error;
15
16
  }) => void): void;
16
17
  shutdown(): Promise<void>;
18
+ reset(): void;
17
19
  /**
18
20
  * Exports any pending spans in the exporter
19
21
  */
20
22
  forceFlush(): Promise<void>;
21
- find(search: any, callback: any): void;
22
- reset(): void;
23
+ find(findConfig: {
24
+ query: any;
25
+ limit?: number;
26
+ sortOrder?: any;
27
+ }): Promise<any[]>;
23
28
  getFinishedSpans(): import("@seald-io/nedb").Document<Record<string, any>>[];
24
29
  /**
25
30
  * Inserts spans into the in-memory database.
@@ -0,0 +1,23 @@
1
+ import { InstrumentationBase } from '@opentelemetry/instrumentation';
2
+ import { LoggerProvider } from '@opentelemetry/api-logs';
3
+ export declare class LogsInstrumentation extends InstrumentationBase {
4
+ private _loggerProvider?;
5
+ private _otelLogger?;
6
+ constructor(config?: any);
7
+ /**
8
+ * No-op: this instrumentation does not patch modules loaded via require().
9
+ */
10
+ init(): never[];
11
+ /**
12
+ * Called by the SDK when the LoggerProvider is available.
13
+ * This is the correct way for an instrumentation to receive a logger provider.
14
+ */
15
+ setLoggerProvider(provider: LoggerProvider): void;
16
+ /**
17
+ * Called by the SDK after all providers have been registered.
18
+ */
19
+ enable(): void;
20
+ disable(): void;
21
+ private _patchConsole;
22
+ private _unpatchConsole;
23
+ }
@@ -0,0 +1,49 @@
1
+ import { HistogramValue } from './types.js';
2
+ export declare class Chunk {
3
+ private readonly maxSamples;
4
+ private readonly startTimes;
5
+ private readonly endTimes;
6
+ private readonly values;
7
+ private readonly histograms;
8
+ private cursor;
9
+ private minEndTime;
10
+ private maxEndTime;
11
+ private readonly isHistogram;
12
+ constructor(maxSamples?: number, isHistogram?: boolean);
13
+ /**
14
+ * Append a sample to the chunk.
15
+ * Returns true if successful or false if the chunk is full.
16
+ */
17
+ append(startTime: number, endTime: number, value: number | HistogramValue): boolean;
18
+ /**
19
+ * Binary search for first index with endTime >= targetTime
20
+ */
21
+ private _binarySearchStart;
22
+ /**
23
+ * Binary search for last index with endTime <= targetTime
24
+ */
25
+ private _binarySearchEnd;
26
+ /**
27
+ * Efficient slicing method for bulk operations.
28
+ * Always returns slices. Values can be either a Float64Array (numeric)
29
+ * or a JS array of HistogramValue objects (histogram series).
30
+ */
31
+ getSlices(startTime?: number, endTime?: number): {
32
+ startTimes: Float64Array;
33
+ endTimes: Float64Array;
34
+ values: Float64Array | (HistogramValue | null)[];
35
+ };
36
+ isFull(): boolean;
37
+ overlaps(startTime: number, endTime: number): boolean;
38
+ getStats(): {
39
+ samples: number;
40
+ maxSamples: number;
41
+ minEndTime: number;
42
+ maxEndTime: number;
43
+ memoryBytes: number;
44
+ };
45
+ getMemoryUsage(): number;
46
+ getMinTime(): number;
47
+ getMaxTime(): number;
48
+ size(): number;
49
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Series: Time-series storage with metadata and chunks
3
+ * One series per unique metric+labels combination
4
+ */
5
+ import { MetricMetadata, LabelSet, HistogramValue } from './types.js';
6
+ export declare class Series {
7
+ private readonly labelSet;
8
+ private readonly metadata;
9
+ private readonly chunks;
10
+ private readonly maxChunks;
11
+ private readonly chunkSize;
12
+ private readonly isHistogram;
13
+ constructor(labelSet: LabelSet, metadata: MetricMetadata, chunkSize?: number, maxChunks?: number);
14
+ /**
15
+ * Append a sample to the series
16
+ */
17
+ append(startTime: number, endTime: number, value: number | HistogramValue): void;
18
+ /**
19
+ * Query slices with options object. Example:
20
+ * querySlices({ startTime, endTime, includeStartTimes: true })
21
+ * includeStartTimes defaults to false.
22
+ * If both startTime and endTime are undefined, returns all data (no time filtering).
23
+ */
24
+ querySlices(options?: {
25
+ startTime?: number;
26
+ endTime?: number;
27
+ includeStartTimes?: boolean;
28
+ }): {
29
+ startTimes?: Float64Array;
30
+ endTimes: Float64Array;
31
+ values: Float64Array | (HistogramValue | null)[];
32
+ };
33
+ /**
34
+ * Remove chunks older than threshold
35
+ */
36
+ evictOldChunks(thresholdTime: number): number;
37
+ /**
38
+ * Get series metadata
39
+ */
40
+ getMetadata(): MetricMetadata;
41
+ getLabels(): Record<string, any>;
42
+ getOriginalAttributes(): Record<string, any>;
43
+ /**
44
+ * Get label hash
45
+ */
46
+ getLabelHash(): number;
47
+ getStats(): {
48
+ metricName: string;
49
+ labels: import("@opentelemetry/api").Attributes;
50
+ chunks: number;
51
+ samples: number;
52
+ memoryBytes: number;
53
+ oldestTime: number;
54
+ newestTime: number;
55
+ };
56
+ /**
57
+ * Check if series has any samples
58
+ */
59
+ isEmpty(): boolean;
60
+ /**
61
+ * Get time range covered by this series
62
+ */
63
+ getTimeRange(): {
64
+ min: number;
65
+ max: number;
66
+ };
67
+ }
@@ -0,0 +1,69 @@
1
+ import { ScopeMetricQuery, MetricQueryResult } from './types.js';
2
+ import { InstrumentationScope } from '@opentelemetry/core';
3
+ import { MetricDescriptor, ScopeMetrics } from '@opentelemetry/sdk-metrics';
4
+ export declare class SeriesRegistry {
5
+ private readonly series;
6
+ private readonly scopes;
7
+ private readonly metricMetadataMap;
8
+ private readonly metricIdIndex;
9
+ private readonly chunkSize;
10
+ private readonly maxChunks;
11
+ constructor(chunkSize?: number, maxChunks?: number);
12
+ /**
13
+ * Store entire ScopeMetrics array efficiently
14
+ * Replaces addSample - processes all metrics in one batch
15
+ */
16
+ storeScopeMetrics(scopeMetrics: ScopeMetrics[]): void;
17
+ query(scopeMetrics?: ScopeMetricQuery[], startTime?: number, endTime?: number): MetricQueryResult[];
18
+ /**
19
+ * Query single metric with attribute filters
20
+ */
21
+ private _querySingle;
22
+ /**
23
+ * Match series attributes against filters
24
+ * Supports exact match, negation (!), and regex (~)
25
+ */
26
+ private _matchesAttributeFilters;
27
+ evictOldData(retentionTimeNs: number): {
28
+ evictedChunks: number;
29
+ evictedSeries: number;
30
+ };
31
+ getStats(): {
32
+ totalMetrics: number;
33
+ totalScopes: number;
34
+ totalSeries: number;
35
+ totalSamples: number;
36
+ memoryUsageBytes: number;
37
+ };
38
+ reset(): void;
39
+ size(): number;
40
+ /**
41
+ * Serialize registry to NDJSON format (newline-delimited JSON)
42
+ * Each line is a complete record: metadata, scope, metric, or data point
43
+ * Format:
44
+ * {"type":"header","version":1,"timestamp":"...","stats":{...}}
45
+ * {"type":"scope","id":"...","data":{...}}
46
+ * {"type":"metric","id":"...","data":{...}}
47
+ * {"type":"series","id":"...","labelSet":{...},"chunks":[...]}
48
+ */
49
+ serializeToNDJSON(): string;
50
+ /**
51
+ * Deserialize from NDJSON format - restore from chunk lines
52
+ */
53
+ deserializeFromNDJSON(ndjsonData: string): void;
54
+ /**
55
+ * Save registry to disk as NDJSON (one chunk per line)
56
+ */
57
+ saveToDisk(filePath: string): void;
58
+ /**
59
+ * Load registry from disk (NDJSON format)
60
+ */
61
+ loadFromDisk(filePath: string): void;
62
+ }
63
+ export type MetricInfo = {
64
+ scope: InstrumentationScope;
65
+ metrics: Array<{
66
+ descriptor: MetricDescriptor;
67
+ series: string[];
68
+ }>;
69
+ };
@@ -0,0 +1,68 @@
1
+ import { InstrumentationScope } from "@opentelemetry/core";
2
+ import { MetricData, Histogram, MetricDescriptor } from "@opentelemetry/sdk-metrics";
3
+ import { Attributes } from "@opentelemetry/api";
4
+ export type MetricMetadata = Omit<MetricData, "dataPoints">;
5
+ export type HistogramValue = Histogram;
6
+ /**
7
+ * Label set for series identification
8
+ */
9
+ export interface LabelSet {
10
+ hash: number;
11
+ labels: Attributes;
12
+ originalAttributes: Attributes;
13
+ }
14
+ /**
15
+ * Series identifier: scope + metricName + attributes
16
+ */
17
+ export interface SeriesKey {
18
+ scopeId: string;
19
+ metricName: string;
20
+ attributesId: number;
21
+ }
22
+ /**
23
+ * Sample with startTime, endTime and value (matching OTEL format)
24
+ */
25
+ export interface Sample {
26
+ startTime: number;
27
+ endTime: number;
28
+ value: number | Histogram;
29
+ }
30
+ /**
31
+ * Raw TSDB format
32
+ */
33
+ export interface RawScopeMetric {
34
+ scope: InstrumentationScope;
35
+ metadata: MetricData;
36
+ series: Array<{
37
+ attributes: Attributes;
38
+ startTimes: number[];
39
+ endTimes: number[];
40
+ values: number[];
41
+ }>;
42
+ }
43
+ export interface ScopeMetricQuery {
44
+ scope: InstrumentationScope;
45
+ descriptor: {
46
+ name: string;
47
+ };
48
+ filters?: Record<string, string>;
49
+ }
50
+ export interface FindMetricsRequest {
51
+ scopeMetrics?: ScopeMetricQuery[];
52
+ from?: number;
53
+ to?: number;
54
+ format?: 'otel' | 'raw';
55
+ }
56
+ /**
57
+ * Query result for metrics
58
+ */
59
+ export interface MetricQueryResult {
60
+ scope: InstrumentationScope;
61
+ descriptor: MetricDescriptor;
62
+ series: Array<{
63
+ attributes: Attributes;
64
+ startTimes?: number[];
65
+ endTimes: number[];
66
+ values: number[] | (Histogram | null)[];
67
+ }>;
68
+ }
@@ -0,0 +1,21 @@
1
+ import { ScopeMetrics } from '@opentelemetry/sdk-metrics';
2
+ import { type MetricQueryResult } from './types.js';
3
+ /**
4
+ * Convert raw format to OpenTelemetry format
5
+ *
6
+ * Raw format structure (same for GET response and INSERT input):
7
+ * {
8
+ * scope: { name, version },
9
+ * descriptor: { unit, description, ... },
10
+ * series: [{ attributes, startTimes[], endTimes[], values[] }]
11
+ * }
12
+ *
13
+ * OTEL format structure:
14
+ * {
15
+ * scope: { name, version },
16
+ * metrics: [{ descriptor, dataPoints: [{ attributes, startTime, endTime, value }] }]
17
+ * }
18
+ *
19
+ * Groups dataPoints by endTime to reconstruct original exports
20
+ */
21
+ export declare function rawToOtel(rawScopeMetrics: MetricQueryResult[]): ScopeMetrics[];
@@ -1,6 +1,6 @@
1
1
  import type { Context } from '@opentelemetry/api';
2
2
  import type { LogRecordProcessor } from '@opentelemetry/sdk-logs';
3
- import type { LogRecord } from '@opentelemetry/sdk-logs';
3
+ import type { SdkLogRecord } from '@opentelemetry/sdk-logs';
4
4
  export declare class DynamicMultiLogRecordProcessor implements LogRecordProcessor {
5
5
  private _processors;
6
6
  private _forceFlushTimeoutMillis;
@@ -20,7 +20,7 @@ export declare class DynamicMultiLogRecordProcessor implements LogRecordProcesso
20
20
  /**
21
21
  * Called when a log record is emitted.
22
22
  */
23
- onEmit(logRecord: LogRecord, context?: Context): void;
23
+ onEmit(logRecord: SdkLogRecord, context?: Context): void;
24
24
  /**
25
25
  * Force flush all processors with timeout.
26
26
  */