@zintrust/trace 1.6.5 → 1.6.6

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 (50) hide show
  1. package/dist/watchers/HttpWatcher.js +23 -8
  2. package/package.json +3 -2
  3. package/src/TraceConnection.ts +182 -0
  4. package/src/cli-register.ts +63 -0
  5. package/src/config.ts +383 -0
  6. package/src/context.ts +101 -0
  7. package/src/dashboard/handlers.ts +353 -0
  8. package/src/dashboard/routes.ts +114 -0
  9. package/src/dashboard/ui.ts +1262 -0
  10. package/src/dashboard/zintrust-debuger.svg +30 -0
  11. package/src/index.ts +102 -0
  12. package/src/ingest/TraceIngestGateway.ts +414 -0
  13. package/src/plugin.ts +9 -0
  14. package/src/register.ts +702 -0
  15. package/src/storage/ProxyTraceStorage.ts +190 -0
  16. package/src/storage/TraceContentBudget.ts +493 -0
  17. package/src/storage/TraceContentRedaction.ts +44 -0
  18. package/src/storage/TraceEntryFiltering.ts +50 -0
  19. package/src/storage/TraceServiceTag.ts +56 -0
  20. package/src/storage/TraceStorage.ts +543 -0
  21. package/src/storage/TraceWriteDiagnostics.ts +289 -0
  22. package/src/storage/index.ts +4 -0
  23. package/src/types.ts +430 -0
  24. package/src/ui.ts +9 -0
  25. package/src/utils/authTag.ts +20 -0
  26. package/src/utils/entryFilter.ts +131 -0
  27. package/src/utils/familyHash.ts +8 -0
  28. package/src/utils/redact.ts +112 -0
  29. package/src/utils/requestFilter.ts +79 -0
  30. package/src/utils/stackFrame.ts +44 -0
  31. package/src/watchers/AuthWatcher.ts +53 -0
  32. package/src/watchers/BatchWatcher.ts +55 -0
  33. package/src/watchers/CacheWatcher.ts +72 -0
  34. package/src/watchers/CommandWatcher.ts +58 -0
  35. package/src/watchers/DumpWatcher.ts +45 -0
  36. package/src/watchers/EventWatcher.ts +46 -0
  37. package/src/watchers/ExceptionWatcher.ts +130 -0
  38. package/src/watchers/GateWatcher.ts +53 -0
  39. package/src/watchers/HttpClientWatcher.ts +219 -0
  40. package/src/watchers/HttpWatcher.ts +249 -0
  41. package/src/watchers/JobWatcher.ts +124 -0
  42. package/src/watchers/LogWatcher.ts +120 -0
  43. package/src/watchers/MailWatcher.ts +65 -0
  44. package/src/watchers/MiddlewareWatcher.ts +54 -0
  45. package/src/watchers/ModelWatcher.ts +60 -0
  46. package/src/watchers/NotificationWatcher.ts +60 -0
  47. package/src/watchers/QueryWatcher.ts +105 -0
  48. package/src/watchers/RedisWatcher.ts +42 -0
  49. package/src/watchers/ScheduleWatcher.ts +57 -0
  50. package/src/watchers/ViewWatcher.ts +40 -0
@@ -0,0 +1,40 @@
1
+ import { TraceContext } from '../context';
2
+ import type { ITraceWatcher, ITraceWatcherConfig, ViewContent } from '../types';
3
+ import { EntryType } from '../types';
4
+ import { RequestFilter } from '../utils/requestFilter';
5
+
6
+ let _storage: ITraceWatcherConfig['storage'] | null = null;
7
+ let _ignoreRoutes: string[] = [];
8
+ let _ignorePaths: string[] = [];
9
+
10
+ const emit = (template: string, duration: number): void => {
11
+ if (!_storage) return;
12
+ if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths)) return;
13
+ const content: ViewContent = { template, duration, hostname: TraceContext.getHostname() };
14
+ _storage
15
+ .writeEntry({
16
+ uuid: crypto.randomUUID(),
17
+ batchId: TraceContext.getBatchId(),
18
+ type: EntryType.VIEW,
19
+ content,
20
+ tags: [template],
21
+ isLatest: true,
22
+ createdAt: TraceContext.now(),
23
+ })
24
+ .catch(() => undefined);
25
+ };
26
+
27
+ export const ViewWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze({
28
+ emit,
29
+ register({ storage, config }: ITraceWatcherConfig): () => void {
30
+ if (config.watchers.view === false) return () => undefined;
31
+ _storage = storage;
32
+ _ignoreRoutes = config.ignoreRoutes;
33
+ _ignorePaths = config.ignorePaths;
34
+ return () => {
35
+ _storage = null;
36
+ _ignoreRoutes = [];
37
+ _ignorePaths = [];
38
+ };
39
+ },
40
+ });