@burdenoff/be-sdk 2026.518.2 → 2026.521.1

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 (87) hide show
  1. package/dist/EventQueueFactory-PVXBZCT5.js +6 -0
  2. package/dist/{EventQueueFactory-6UJ3UIP4.js.map → EventQueueFactory-PVXBZCT5.js.map} +1 -1
  3. package/dist/auth/index.js +2 -2
  4. package/dist/cache/index.js +1 -1
  5. package/dist/{chunk-EZOXXSD4.js → chunk-2BG75H2K.js} +4 -4
  6. package/dist/{chunk-EZOXXSD4.js.map → chunk-2BG75H2K.js.map} +1 -1
  7. package/dist/{chunk-UNPJMENC.js → chunk-7NUQXGA7.js} +3 -3
  8. package/dist/{chunk-UNPJMENC.js.map → chunk-7NUQXGA7.js.map} +1 -1
  9. package/dist/{chunk-4XAEES25.js → chunk-ACYGOENW.js} +4 -850
  10. package/dist/chunk-ACYGOENW.js.map +1 -0
  11. package/dist/{chunk-MOCUBSTW.js → chunk-B7I4TABG.js} +2 -2
  12. package/dist/{chunk-MOCUBSTW.js.map → chunk-B7I4TABG.js.map} +1 -1
  13. package/dist/{chunk-O2MEBPDT.js → chunk-BNJFEOGH.js} +2 -2
  14. package/dist/chunk-BNJFEOGH.js.map +1 -0
  15. package/dist/{chunk-S5S6OBS6.js → chunk-BRYRHBAC.js} +3 -3
  16. package/dist/{chunk-S5S6OBS6.js.map → chunk-BRYRHBAC.js.map} +1 -1
  17. package/dist/{chunk-UBXFIIAW.js → chunk-BTQREMD4.js} +2 -2
  18. package/dist/{chunk-UBXFIIAW.js.map → chunk-BTQREMD4.js.map} +1 -1
  19. package/dist/{chunk-3F4SLVRL.js → chunk-DMPS4Y53.js} +3 -3
  20. package/dist/{chunk-3F4SLVRL.js.map → chunk-DMPS4Y53.js.map} +1 -1
  21. package/dist/{chunk-SNEOLWXT.js → chunk-E5USZ2MR.js} +2 -2
  22. package/dist/{chunk-SNEOLWXT.js.map → chunk-E5USZ2MR.js.map} +1 -1
  23. package/dist/{chunk-TM5RQ6P2.js → chunk-KGCISIBX.js} +22 -4
  24. package/dist/chunk-KGCISIBX.js.map +1 -0
  25. package/dist/{chunk-OJDXWHRJ.js → chunk-LD7ETTWG.js} +8 -7
  26. package/dist/chunk-LD7ETTWG.js.map +1 -0
  27. package/dist/{chunk-MVHOP4IG.js → chunk-MHNA7IS7.js} +2 -2
  28. package/dist/{chunk-MVHOP4IG.js.map → chunk-MHNA7IS7.js.map} +1 -1
  29. package/dist/{chunk-V2VEENJ2.js → chunk-PDSV3TFO.js} +3 -3
  30. package/dist/chunk-PDSV3TFO.js.map +1 -0
  31. package/dist/{chunk-CFUKZDDU.js → chunk-PPIDJP2W.js} +3 -3
  32. package/dist/chunk-PPIDJP2W.js.map +1 -0
  33. package/dist/{chunk-SO57HNXV.js → chunk-QRWTLPW5.js} +13 -7
  34. package/dist/chunk-QRWTLPW5.js.map +1 -0
  35. package/dist/chunk-REF7PANB.js +852 -0
  36. package/dist/chunk-REF7PANB.js.map +1 -0
  37. package/dist/{chunk-VLEOOG2L.js → chunk-SVONGBQR.js} +3 -3
  38. package/dist/{chunk-VLEOOG2L.js.map → chunk-SVONGBQR.js.map} +1 -1
  39. package/dist/{chunk-BESBOSX2.js → chunk-TGTJ653K.js} +4 -4
  40. package/dist/chunk-TGTJ653K.js.map +1 -0
  41. package/dist/{chunk-WCBKW3CL.js → chunk-X4GSV6NV.js} +5 -5
  42. package/dist/{chunk-WCBKW3CL.js.map → chunk-X4GSV6NV.js.map} +1 -1
  43. package/dist/{chunk-RRFNSBDZ.js → chunk-X4NELQLV.js} +3 -3
  44. package/dist/chunk-X4NELQLV.js.map +1 -0
  45. package/dist/event-queue/index.js +4 -4
  46. package/dist/export/index.js +3 -3
  47. package/dist/gateway/index.js +2 -2
  48. package/dist/gateway/security/index.js +1 -1
  49. package/dist/graph/index.d.ts +1 -1
  50. package/dist/graph/index.js +5 -5
  51. package/dist/graphql/index.js +2 -2
  52. package/dist/{index-CygU_fXS.d.ts → index-Cz9_vPi7.d.ts} +1 -0
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.js +23 -22
  55. package/dist/index.js.map +1 -1
  56. package/dist/init/index.js +3 -3
  57. package/dist/instrumentation/index.js +2 -1
  58. package/dist/metrics/index.d.ts +17 -0
  59. package/dist/metrics/index.js +53 -0
  60. package/dist/metrics/index.js.map +1 -0
  61. package/dist/pino-logger-NVZXQPWO.js +5 -0
  62. package/dist/{pino-logger-RYLGXPHZ.js.map → pino-logger-NVZXQPWO.js.map} +1 -1
  63. package/dist/prisma/index.js +4 -4
  64. package/dist/rbac/index.js +1 -1
  65. package/dist/{sdk-THO3IWEE.js → sdk-UWFH5PY7.js} +2 -2
  66. package/dist/{sdk-THO3IWEE.js.map → sdk-UWFH5PY7.js.map} +1 -1
  67. package/dist/server/index.js +3 -3
  68. package/dist/server/index.js.map +1 -1
  69. package/dist/telemetry/index.js +6 -5
  70. package/dist/telemetry/index.js.map +1 -1
  71. package/dist/tracker/index.js +2 -2
  72. package/dist/utils/index.js +1 -1
  73. package/dist/workspace-guard-524GBJQ6.js +5 -0
  74. package/dist/{workspace-guard-LHBNK4TG.js.map → workspace-guard-524GBJQ6.js.map} +1 -1
  75. package/package.json +3 -3
  76. package/dist/EventQueueFactory-6UJ3UIP4.js +0 -6
  77. package/dist/chunk-4XAEES25.js.map +0 -1
  78. package/dist/chunk-BESBOSX2.js.map +0 -1
  79. package/dist/chunk-CFUKZDDU.js.map +0 -1
  80. package/dist/chunk-O2MEBPDT.js.map +0 -1
  81. package/dist/chunk-OJDXWHRJ.js.map +0 -1
  82. package/dist/chunk-RRFNSBDZ.js.map +0 -1
  83. package/dist/chunk-SO57HNXV.js.map +0 -1
  84. package/dist/chunk-TM5RQ6P2.js.map +0 -1
  85. package/dist/chunk-V2VEENJ2.js.map +0 -1
  86. package/dist/pino-logger-RYLGXPHZ.js +0 -5
  87. package/dist/workspace-guard-LHBNK4TG.js +0 -5
@@ -1,3 +1,4 @@
1
+ import { updateInstrumentationConfig, resetMetricsRegistry, resetInstrumentationConfig, isMetricsRegistryInitialized, isInstrumentationConfigInitialized, isFeatureEnabled, initializeMetricsRegistry, initializeInstrumentationConfig, getMetricsRegistry, getInstrumentationConfig, createUpDownCounter, createHistogram, createGauge, createCounter, buildTracingConfig, buildMetricsConfig, buildInstrumentationConfig, buildGraphQLConfig, buildFeatureFlags, buildDatabaseConfig, MetricsRegistry, ENV_VARS, DEFAULT_TRACING_CONFIG, DEFAULT_METRICS_CONFIG, DEFAULT_LOGGING_CONFIG, DEFAULT_HTTP_CONFIG, DEFAULT_GRAPHQL_CONFIG, DEFAULT_FEATURE_FLAGS, DEFAULT_EVENT_QUEUE_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_CACHE_CONFIG } from './chunk-REF7PANB.js';
1
2
  import { logger } from './chunk-CBZNP6RF.js';
2
3
  import { __export, __name } from './chunk-XE4OXN2W.js';
3
4
  import { createRequire } from 'module';
@@ -72,853 +73,6 @@ __export(instrumentation_exports, {
72
73
  withSpan: () => withSpan
73
74
  });
74
75
 
75
- // src/instrumentation/config.ts
76
- var ENV_VARS = {
77
- // Master switch
78
- INSTRUMENTATION_ENABLED: "INSTRUMENTATION_ENABLED",
79
- // Feature flags
80
- INSTRUMENTATION_TRACING: "INSTRUMENTATION_TRACING",
81
- INSTRUMENTATION_METRICS: "INSTRUMENTATION_METRICS",
82
- INSTRUMENTATION_LOGGING: "INSTRUMENTATION_LOGGING",
83
- INSTRUMENTATION_GRAPHQL: "INSTRUMENTATION_GRAPHQL",
84
- INSTRUMENTATION_DATABASE: "INSTRUMENTATION_DATABASE",
85
- INSTRUMENTATION_HTTP: "INSTRUMENTATION_HTTP",
86
- INSTRUMENTATION_CACHE: "INSTRUMENTATION_CACHE",
87
- INSTRUMENTATION_EVENT_QUEUE: "INSTRUMENTATION_EVENT_QUEUE",
88
- // Tracing
89
- OTEL_SERVICE_NAME: "OTEL_SERVICE_NAME",
90
- OTEL_SERVICE_VERSION: "OTEL_SERVICE_VERSION",
91
- OTEL_ENVIRONMENT: "OTEL_ENVIRONMENT",
92
- OTEL_EXPORTER_OTLP_ENDPOINT: "OTEL_EXPORTER_OTLP_ENDPOINT",
93
- OTEL_EXPORTER_TYPE: "OTEL_EXPORTER_TYPE",
94
- OTEL_SAMPLING_RATE: "OTEL_SAMPLING_RATE",
95
- OTEL_PROPAGATION_FORMAT: "OTEL_PROPAGATION_FORMAT",
96
- // Metrics
97
- METRICS_EXPORTER_TYPE: "METRICS_EXPORTER_TYPE",
98
- METRICS_PROMETHEUS_ENDPOINT: "METRICS_PROMETHEUS_ENDPOINT",
99
- METRICS_PROMETHEUS_PORT: "METRICS_PROMETHEUS_PORT",
100
- METRICS_COLLECT_INTERVAL: "METRICS_COLLECT_INTERVAL",
101
- METRICS_DEFAULT_ENABLED: "METRICS_DEFAULT_ENABLED",
102
- METRICS_PREFIX: "METRICS_PREFIX",
103
- // Database
104
- DB_INSTRUMENTATION_INCLUDE_STATEMENT: "DB_INSTRUMENTATION_INCLUDE_STATEMENT",
105
- DB_INSTRUMENTATION_SLOW_QUERY_THRESHOLD: "DB_INSTRUMENTATION_SLOW_QUERY_THRESHOLD",
106
- // GraphQL
107
- GRAPHQL_INSTRUMENTATION_INCLUDE_DOCUMENT: "GRAPHQL_INSTRUMENTATION_INCLUDE_DOCUMENT",
108
- GRAPHQL_INSTRUMENTATION_INCLUDE_VARIABLES: "GRAPHQL_INSTRUMENTATION_INCLUDE_VARIABLES",
109
- GRAPHQL_INSTRUMENTATION_INCLUDE_RESOLVERS: "GRAPHQL_INSTRUMENTATION_INCLUDE_RESOLVERS"
110
- };
111
- function getEnvBoolean(key, defaultValue) {
112
- const value = process.env[key];
113
- if (value === void 0 || value === "") return defaultValue;
114
- return value.toLowerCase() === "true" || value === "1";
115
- }
116
- __name(getEnvBoolean, "getEnvBoolean");
117
- function getEnvNumber(key, defaultValue) {
118
- const value = process.env[key];
119
- if (value === void 0 || value === "") return defaultValue;
120
- const parsed = parseFloat(value);
121
- return isNaN(parsed) ? defaultValue : parsed;
122
- }
123
- __name(getEnvNumber, "getEnvNumber");
124
- function getEnvString(key, defaultValue) {
125
- const value = process.env[key];
126
- return value !== void 0 && value !== "" ? value : defaultValue;
127
- }
128
- __name(getEnvString, "getEnvString");
129
- var DEFAULT_FEATURE_FLAGS = {
130
- tracing: true,
131
- metrics: true,
132
- logging: true,
133
- graphql: true,
134
- database: true,
135
- http: true,
136
- cache: true,
137
- eventQueue: true
138
- };
139
- var DEFAULT_TRACING_CONFIG = {
140
- enabled: true,
141
- serviceName: "unknown-service",
142
- serviceVersion: "1.0.0",
143
- environment: "development",
144
- exporterType: "none",
145
- samplingRate: 1,
146
- propagationFormat: "w3c",
147
- resourceAttributes: {},
148
- ignoredRoutes: [
149
- "/health",
150
- "/ready",
151
- "/live",
152
- "/metrics"
153
- ],
154
- ignoredOperations: [
155
- "IntrospectionQuery"
156
- ]
157
- };
158
- var DEFAULT_METRICS_CONFIG = {
159
- enabled: true,
160
- serviceName: "unknown-service",
161
- exporterType: "none",
162
- prometheusEndpoint: "/metrics",
163
- prometheusPort: 9090,
164
- collectInterval: 6e4,
165
- defaultMetrics: true,
166
- metricPrefix: ""
167
- };
168
- var DEFAULT_LOGGING_CONFIG = {
169
- enabled: true,
170
- includeTraceId: true,
171
- includeSpanId: true,
172
- includeTraceFlags: false,
173
- level: "info"
174
- };
175
- var DEFAULT_GRAPHQL_CONFIG = {
176
- enabled: true,
177
- includeDocument: false,
178
- includeVariables: false,
179
- includeResult: false,
180
- documentDepth: 3,
181
- ignoredOperations: [
182
- "IntrospectionQuery"
183
- ],
184
- includeResolvers: true,
185
- resolverSpanDepth: 3
186
- };
187
- var DEFAULT_DATABASE_CONFIG = {
188
- enabled: true,
189
- includeStatement: false,
190
- includeParameters: false,
191
- includeRowCount: true,
192
- slowQueryThreshold: 1e3,
193
- ignoredOperations: []
194
- };
195
- var DEFAULT_HTTP_CONFIG = {
196
- enabled: true,
197
- includeRequestHeaders: false,
198
- includeResponseHeaders: false,
199
- includeRequestBody: false,
200
- includeResponseBody: false,
201
- redactedHeaders: [
202
- "authorization",
203
- "cookie",
204
- "set-cookie",
205
- "x-api-key"
206
- ],
207
- ignoredRoutes: [
208
- "/health",
209
- "/ready",
210
- "/live",
211
- "/metrics"
212
- ],
213
- maxBodySize: 10240
214
- };
215
- var DEFAULT_CACHE_CONFIG = {
216
- enabled: true,
217
- includeKey: true,
218
- includeValueSize: true,
219
- includeTTL: true
220
- };
221
- var DEFAULT_EVENT_QUEUE_CONFIG = {
222
- enabled: true,
223
- includePayload: false,
224
- includeHeaders: true,
225
- maxPayloadSize: 1024
226
- };
227
- var globalConfig = null;
228
- function buildFeatureFlags(overrides) {
229
- return {
230
- tracing: getEnvBoolean(ENV_VARS.INSTRUMENTATION_TRACING, DEFAULT_FEATURE_FLAGS.tracing),
231
- metrics: getEnvBoolean(ENV_VARS.INSTRUMENTATION_METRICS, DEFAULT_FEATURE_FLAGS.metrics),
232
- logging: getEnvBoolean(ENV_VARS.INSTRUMENTATION_LOGGING, DEFAULT_FEATURE_FLAGS.logging),
233
- graphql: getEnvBoolean(ENV_VARS.INSTRUMENTATION_GRAPHQL, DEFAULT_FEATURE_FLAGS.graphql),
234
- database: getEnvBoolean(ENV_VARS.INSTRUMENTATION_DATABASE, DEFAULT_FEATURE_FLAGS.database),
235
- http: getEnvBoolean(ENV_VARS.INSTRUMENTATION_HTTP, DEFAULT_FEATURE_FLAGS.http),
236
- cache: getEnvBoolean(ENV_VARS.INSTRUMENTATION_CACHE, DEFAULT_FEATURE_FLAGS.cache),
237
- eventQueue: getEnvBoolean(ENV_VARS.INSTRUMENTATION_EVENT_QUEUE, DEFAULT_FEATURE_FLAGS.eventQueue),
238
- ...overrides
239
- };
240
- }
241
- __name(buildFeatureFlags, "buildFeatureFlags");
242
- function buildTracingConfig(serviceName, overrides) {
243
- return {
244
- enabled: getEnvBoolean(ENV_VARS.INSTRUMENTATION_TRACING, DEFAULT_TRACING_CONFIG.enabled),
245
- serviceName: getEnvString(ENV_VARS.OTEL_SERVICE_NAME, serviceName),
246
- serviceVersion: getEnvString(ENV_VARS.OTEL_SERVICE_VERSION, DEFAULT_TRACING_CONFIG.serviceVersion),
247
- environment: getEnvString(ENV_VARS.OTEL_ENVIRONMENT, process.env["NODE_ENV"] || "development"),
248
- exporterEndpoint: process.env[ENV_VARS.OTEL_EXPORTER_OTLP_ENDPOINT],
249
- exporterType: getEnvString(ENV_VARS.OTEL_EXPORTER_TYPE, DEFAULT_TRACING_CONFIG.exporterType),
250
- samplingRate: getEnvNumber(ENV_VARS.OTEL_SAMPLING_RATE, DEFAULT_TRACING_CONFIG.samplingRate),
251
- propagationFormat: getEnvString(ENV_VARS.OTEL_PROPAGATION_FORMAT, DEFAULT_TRACING_CONFIG.propagationFormat),
252
- resourceAttributes: DEFAULT_TRACING_CONFIG.resourceAttributes,
253
- ignoredRoutes: DEFAULT_TRACING_CONFIG.ignoredRoutes,
254
- ignoredOperations: DEFAULT_TRACING_CONFIG.ignoredOperations,
255
- ...overrides
256
- };
257
- }
258
- __name(buildTracingConfig, "buildTracingConfig");
259
- function buildMetricsConfig(serviceName, overrides) {
260
- return {
261
- enabled: getEnvBoolean(ENV_VARS.INSTRUMENTATION_METRICS, DEFAULT_METRICS_CONFIG.enabled),
262
- serviceName: getEnvString(ENV_VARS.OTEL_SERVICE_NAME, serviceName),
263
- exporterEndpoint: process.env[ENV_VARS.OTEL_EXPORTER_OTLP_ENDPOINT],
264
- exporterType: getEnvString(ENV_VARS.METRICS_EXPORTER_TYPE, DEFAULT_METRICS_CONFIG.exporterType),
265
- prometheusEndpoint: getEnvString(ENV_VARS.METRICS_PROMETHEUS_ENDPOINT, DEFAULT_METRICS_CONFIG.prometheusEndpoint),
266
- prometheusPort: getEnvNumber(ENV_VARS.METRICS_PROMETHEUS_PORT, DEFAULT_METRICS_CONFIG.prometheusPort),
267
- collectInterval: getEnvNumber(ENV_VARS.METRICS_COLLECT_INTERVAL, DEFAULT_METRICS_CONFIG.collectInterval),
268
- defaultMetrics: getEnvBoolean(ENV_VARS.METRICS_DEFAULT_ENABLED, DEFAULT_METRICS_CONFIG.defaultMetrics),
269
- metricPrefix: getEnvString(ENV_VARS.METRICS_PREFIX, DEFAULT_METRICS_CONFIG.metricPrefix),
270
- ...overrides
271
- };
272
- }
273
- __name(buildMetricsConfig, "buildMetricsConfig");
274
- function buildDatabaseConfig(overrides) {
275
- return {
276
- enabled: getEnvBoolean(ENV_VARS.INSTRUMENTATION_DATABASE, DEFAULT_DATABASE_CONFIG.enabled),
277
- includeStatement: getEnvBoolean(ENV_VARS.DB_INSTRUMENTATION_INCLUDE_STATEMENT, DEFAULT_DATABASE_CONFIG.includeStatement),
278
- includeParameters: DEFAULT_DATABASE_CONFIG.includeParameters,
279
- includeRowCount: DEFAULT_DATABASE_CONFIG.includeRowCount,
280
- slowQueryThreshold: getEnvNumber(ENV_VARS.DB_INSTRUMENTATION_SLOW_QUERY_THRESHOLD, DEFAULT_DATABASE_CONFIG.slowQueryThreshold),
281
- ignoredOperations: DEFAULT_DATABASE_CONFIG.ignoredOperations,
282
- ...overrides
283
- };
284
- }
285
- __name(buildDatabaseConfig, "buildDatabaseConfig");
286
- function buildGraphQLConfig(overrides) {
287
- return {
288
- enabled: getEnvBoolean(ENV_VARS.INSTRUMENTATION_GRAPHQL, DEFAULT_GRAPHQL_CONFIG.enabled),
289
- includeDocument: getEnvBoolean(ENV_VARS.GRAPHQL_INSTRUMENTATION_INCLUDE_DOCUMENT, DEFAULT_GRAPHQL_CONFIG.includeDocument),
290
- includeVariables: getEnvBoolean(ENV_VARS.GRAPHQL_INSTRUMENTATION_INCLUDE_VARIABLES, DEFAULT_GRAPHQL_CONFIG.includeVariables),
291
- includeResult: DEFAULT_GRAPHQL_CONFIG.includeResult,
292
- documentDepth: DEFAULT_GRAPHQL_CONFIG.documentDepth,
293
- ignoredOperations: DEFAULT_GRAPHQL_CONFIG.ignoredOperations,
294
- includeResolvers: getEnvBoolean(ENV_VARS.GRAPHQL_INSTRUMENTATION_INCLUDE_RESOLVERS, DEFAULT_GRAPHQL_CONFIG.includeResolvers),
295
- resolverSpanDepth: DEFAULT_GRAPHQL_CONFIG.resolverSpanDepth,
296
- ...overrides
297
- };
298
- }
299
- __name(buildGraphQLConfig, "buildGraphQLConfig");
300
- function buildInstrumentationConfig(serviceName, overrides) {
301
- const enabled = getEnvBoolean(ENV_VARS.INSTRUMENTATION_ENABLED, true);
302
- return {
303
- enabled,
304
- features: buildFeatureFlags(overrides?.features),
305
- tracing: buildTracingConfig(serviceName, overrides?.tracing),
306
- metrics: buildMetricsConfig(serviceName, overrides?.metrics),
307
- logging: {
308
- ...DEFAULT_LOGGING_CONFIG,
309
- ...overrides?.logging
310
- },
311
- graphql: buildGraphQLConfig(overrides?.graphql),
312
- database: buildDatabaseConfig(overrides?.database),
313
- http: {
314
- ...DEFAULT_HTTP_CONFIG,
315
- ...overrides?.http
316
- },
317
- cache: {
318
- ...DEFAULT_CACHE_CONFIG,
319
- ...overrides?.cache
320
- },
321
- eventQueue: {
322
- ...DEFAULT_EVENT_QUEUE_CONFIG,
323
- ...overrides?.eventQueue
324
- }
325
- };
326
- }
327
- __name(buildInstrumentationConfig, "buildInstrumentationConfig");
328
- function initializeInstrumentationConfig(serviceName, overrides) {
329
- globalConfig = buildInstrumentationConfig(serviceName, overrides);
330
- return globalConfig;
331
- }
332
- __name(initializeInstrumentationConfig, "initializeInstrumentationConfig");
333
- function getInstrumentationConfig() {
334
- if (!globalConfig) {
335
- throw new Error("Instrumentation config not initialized. Call initializeInstrumentationConfig() first.");
336
- }
337
- return globalConfig;
338
- }
339
- __name(getInstrumentationConfig, "getInstrumentationConfig");
340
- function isInstrumentationConfigInitialized() {
341
- return globalConfig !== null;
342
- }
343
- __name(isInstrumentationConfigInitialized, "isInstrumentationConfigInitialized");
344
- function isFeatureEnabled(feature) {
345
- if (!globalConfig) return false;
346
- return globalConfig.enabled && globalConfig.features[feature];
347
- }
348
- __name(isFeatureEnabled, "isFeatureEnabled");
349
- function updateInstrumentationConfig(updates) {
350
- if (!globalConfig) {
351
- throw new Error("Instrumentation config not initialized. Call initializeInstrumentationConfig() first.");
352
- }
353
- globalConfig = {
354
- ...globalConfig,
355
- ...updates
356
- };
357
- return globalConfig;
358
- }
359
- __name(updateInstrumentationConfig, "updateInstrumentationConfig");
360
- function resetInstrumentationConfig() {
361
- globalConfig = null;
362
- }
363
- __name(resetInstrumentationConfig, "resetInstrumentationConfig");
364
-
365
- // src/instrumentation/metrics-collector.ts
366
- function getLabelKey(labels) {
367
- if (!labels || Object.keys(labels).length === 0) return "";
368
- return Object.entries(labels).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}=${v}`).join(",");
369
- }
370
- __name(getLabelKey, "getLabelKey");
371
- var InMemoryCounter = class InMemoryCounter2 {
372
- static {
373
- __name(this, "InMemoryCounter");
374
- }
375
- values = /* @__PURE__ */ new Map();
376
- name;
377
- description;
378
- constructor(name, description) {
379
- this.name = name;
380
- this.description = description;
381
- }
382
- add(value, labels) {
383
- const key = getLabelKey(labels);
384
- const current = this.values.get(key) || 0;
385
- this.values.set(key, current + value);
386
- }
387
- inc(labels) {
388
- this.add(1, labels);
389
- }
390
- getValue(labels) {
391
- const key = getLabelKey(labels);
392
- return this.values.get(key) || 0;
393
- }
394
- getName() {
395
- return this.name;
396
- }
397
- getDescription() {
398
- return this.description;
399
- }
400
- getAllValues() {
401
- return new Map(this.values);
402
- }
403
- reset() {
404
- this.values.clear();
405
- }
406
- };
407
- var InMemoryHistogram = class InMemoryHistogram2 {
408
- static {
409
- __name(this, "InMemoryHistogram");
410
- }
411
- values = /* @__PURE__ */ new Map();
412
- name;
413
- description;
414
- boundaries;
415
- constructor(name, description, boundaries) {
416
- this.name = name;
417
- this.description = description;
418
- this.boundaries = boundaries || [
419
- 5,
420
- 10,
421
- 25,
422
- 50,
423
- 100,
424
- 250,
425
- 500,
426
- 1e3,
427
- 2500,
428
- 5e3,
429
- 1e4
430
- ];
431
- }
432
- record(value, labels) {
433
- const key = getLabelKey(labels);
434
- const existing = this.values.get(key) || [];
435
- existing.push(value);
436
- if (existing.length > 1e4) {
437
- existing.shift();
438
- }
439
- this.values.set(key, existing);
440
- }
441
- getData(labels) {
442
- const key = getLabelKey(labels);
443
- const values = this.values.get(key) || [];
444
- if (values.length === 0) {
445
- return {
446
- count: 0,
447
- sum: 0,
448
- min: 0,
449
- max: 0,
450
- avg: 0,
451
- buckets: /* @__PURE__ */ new Map(),
452
- percentiles: {
453
- p50: 0,
454
- p75: 0,
455
- p90: 0,
456
- p95: 0,
457
- p99: 0
458
- }
459
- };
460
- }
461
- const sorted = [
462
- ...values
463
- ].sort((a, b) => a - b);
464
- const sum = values.reduce((a, b) => a + b, 0);
465
- const buckets = /* @__PURE__ */ new Map();
466
- for (const boundary of this.boundaries) {
467
- buckets.set(boundary, values.filter((v) => v <= boundary).length);
468
- }
469
- buckets.set(Infinity, values.length);
470
- const percentile = /* @__PURE__ */ __name((p) => {
471
- const index = Math.ceil(p / 100 * sorted.length) - 1;
472
- return sorted[Math.max(0, index)] || 0;
473
- }, "percentile");
474
- return {
475
- count: values.length,
476
- sum,
477
- min: sorted[0] || 0,
478
- max: sorted[sorted.length - 1] || 0,
479
- avg: sum / values.length,
480
- buckets,
481
- percentiles: {
482
- p50: percentile(50),
483
- p75: percentile(75),
484
- p90: percentile(90),
485
- p95: percentile(95),
486
- p99: percentile(99)
487
- }
488
- };
489
- }
490
- getName() {
491
- return this.name;
492
- }
493
- getDescription() {
494
- return this.description;
495
- }
496
- getAllData() {
497
- const result = /* @__PURE__ */ new Map();
498
- for (const [key] of this.values) {
499
- result.set(key, this.getData(key ? this.parseLabels(key) : void 0));
500
- }
501
- return result;
502
- }
503
- parseLabels(key) {
504
- const labels = {};
505
- for (const part of key.split(",")) {
506
- const [k, v] = part.split("=");
507
- if (k && v) labels[k] = v;
508
- }
509
- return labels;
510
- }
511
- reset() {
512
- this.values.clear();
513
- }
514
- };
515
- var InMemoryGauge = class InMemoryGauge2 {
516
- static {
517
- __name(this, "InMemoryGauge");
518
- }
519
- values = /* @__PURE__ */ new Map();
520
- name;
521
- description;
522
- constructor(name, description) {
523
- this.name = name;
524
- this.description = description;
525
- }
526
- set(value, labels) {
527
- const key = getLabelKey(labels);
528
- this.values.set(key, value);
529
- }
530
- // eslint-disable-next-line sonarjs/no-identical-functions -- Shared implementation across metric types by design
531
- add(value, labels) {
532
- const key = getLabelKey(labels);
533
- const current = this.values.get(key) || 0;
534
- this.values.set(key, current + value);
535
- }
536
- sub(value, labels) {
537
- this.add(-value, labels);
538
- }
539
- getValue(labels) {
540
- const key = getLabelKey(labels);
541
- return this.values.get(key) || 0;
542
- }
543
- getName() {
544
- return this.name;
545
- }
546
- getDescription() {
547
- return this.description;
548
- }
549
- getAllValues() {
550
- return new Map(this.values);
551
- }
552
- reset() {
553
- this.values.clear();
554
- }
555
- };
556
- var InMemoryUpDownCounter = class InMemoryUpDownCounter2 {
557
- static {
558
- __name(this, "InMemoryUpDownCounter");
559
- }
560
- values = /* @__PURE__ */ new Map();
561
- name;
562
- description;
563
- constructor(name, description) {
564
- this.name = name;
565
- this.description = description;
566
- }
567
- // eslint-disable-next-line sonarjs/no-identical-functions -- Shared implementation across metric types by design
568
- add(value, labels) {
569
- const key = getLabelKey(labels);
570
- const current = this.values.get(key) || 0;
571
- this.values.set(key, current + value);
572
- }
573
- getValue(labels) {
574
- const key = getLabelKey(labels);
575
- return this.values.get(key) || 0;
576
- }
577
- getName() {
578
- return this.name;
579
- }
580
- getDescription() {
581
- return this.description;
582
- }
583
- getAllValues() {
584
- return new Map(this.values);
585
- }
586
- reset() {
587
- this.values.clear();
588
- }
589
- };
590
- var NoOpCounter = class NoOpCounter2 {
591
- static {
592
- __name(this, "NoOpCounter");
593
- }
594
- add() {
595
- }
596
- inc() {
597
- }
598
- getValue() {
599
- return 0;
600
- }
601
- };
602
- var NoOpHistogram = class NoOpHistogram2 {
603
- static {
604
- __name(this, "NoOpHistogram");
605
- }
606
- record() {
607
- }
608
- getData() {
609
- return {
610
- count: 0,
611
- sum: 0,
612
- min: 0,
613
- max: 0,
614
- avg: 0,
615
- buckets: /* @__PURE__ */ new Map(),
616
- percentiles: {
617
- p50: 0,
618
- p75: 0,
619
- p90: 0,
620
- p95: 0,
621
- p99: 0
622
- }
623
- };
624
- }
625
- };
626
- var NoOpGauge = class NoOpGauge2 {
627
- static {
628
- __name(this, "NoOpGauge");
629
- }
630
- set() {
631
- }
632
- add() {
633
- }
634
- sub() {
635
- }
636
- getValue() {
637
- return 0;
638
- }
639
- };
640
- var NoOpUpDownCounter = class NoOpUpDownCounter2 {
641
- static {
642
- __name(this, "NoOpUpDownCounter");
643
- }
644
- add() {
645
- }
646
- getValue() {
647
- return 0;
648
- }
649
- };
650
- var MetricsRegistry = class {
651
- static {
652
- __name(this, "MetricsRegistry");
653
- }
654
- counters = /* @__PURE__ */ new Map();
655
- histograms = /* @__PURE__ */ new Map();
656
- gauges = /* @__PURE__ */ new Map();
657
- upDownCounters = /* @__PURE__ */ new Map();
658
- serviceName;
659
- metricPrefix;
660
- constructor(serviceName, metricPrefix = "") {
661
- this.serviceName = serviceName;
662
- this.metricPrefix = metricPrefix;
663
- }
664
- /**
665
- * Get service name
666
- */
667
- getServiceName() {
668
- return this.serviceName;
669
- }
670
- /**
671
- * Check if metrics are enabled
672
- */
673
- isEnabled() {
674
- return isInstrumentationConfigInitialized() && isFeatureEnabled("metrics");
675
- }
676
- /**
677
- * Get prefixed metric name
678
- */
679
- getPrefixedName(name) {
680
- return this.metricPrefix ? `${this.metricPrefix}_${name}` : name;
681
- }
682
- /**
683
- * Create or get a counter
684
- */
685
- createCounter(name, description) {
686
- if (!this.isEnabled()) {
687
- return new NoOpCounter();
688
- }
689
- const prefixedName = this.getPrefixedName(name);
690
- let counter = this.counters.get(prefixedName);
691
- if (!counter) {
692
- counter = new InMemoryCounter(prefixedName, description);
693
- this.counters.set(prefixedName, counter);
694
- }
695
- return counter;
696
- }
697
- /**
698
- * Create or get a histogram
699
- */
700
- createHistogram(name, description, boundaries) {
701
- if (!this.isEnabled()) {
702
- return new NoOpHistogram();
703
- }
704
- const prefixedName = this.getPrefixedName(name);
705
- let histogram = this.histograms.get(prefixedName);
706
- if (!histogram) {
707
- histogram = new InMemoryHistogram(prefixedName, description, boundaries);
708
- this.histograms.set(prefixedName, histogram);
709
- }
710
- return histogram;
711
- }
712
- /**
713
- * Create or get a gauge
714
- */
715
- createGauge(name, description) {
716
- if (!this.isEnabled()) {
717
- return new NoOpGauge();
718
- }
719
- const prefixedName = this.getPrefixedName(name);
720
- let gauge = this.gauges.get(prefixedName);
721
- if (!gauge) {
722
- gauge = new InMemoryGauge(prefixedName, description);
723
- this.gauges.set(prefixedName, gauge);
724
- }
725
- return gauge;
726
- }
727
- /**
728
- * Create or get an up-down counter
729
- */
730
- createUpDownCounter(name, description) {
731
- if (!this.isEnabled()) {
732
- return new NoOpUpDownCounter();
733
- }
734
- const prefixedName = this.getPrefixedName(name);
735
- let counter = this.upDownCounters.get(prefixedName);
736
- if (!counter) {
737
- counter = new InMemoryUpDownCounter(prefixedName, description);
738
- this.upDownCounters.set(prefixedName, counter);
739
- }
740
- return counter;
741
- }
742
- /**
743
- * Create metric from definition
744
- */
745
- createFromDefinition(definition) {
746
- switch (definition.type) {
747
- case "counter":
748
- return this.createCounter(definition.name, definition.description);
749
- case "histogram":
750
- return this.createHistogram(definition.name, definition.description, definition.boundaries);
751
- case "gauge":
752
- return this.createGauge(definition.name, definition.description);
753
- case "upDownCounter":
754
- return this.createUpDownCounter(definition.name, definition.description);
755
- default:
756
- throw new Error(`Unknown metric type: ${definition.type}`);
757
- }
758
- }
759
- /**
760
- * Get all metrics data
761
- */
762
- getAllMetrics() {
763
- return {
764
- counters: Array.from(this.counters.values()).map((c) => ({
765
- name: c.getName(),
766
- description: c.getDescription(),
767
- values: c.getAllValues()
768
- })),
769
- histograms: Array.from(this.histograms.values()).map((h) => ({
770
- name: h.getName(),
771
- description: h.getDescription(),
772
- data: h.getAllData()
773
- })),
774
- gauges: Array.from(this.gauges.values()).map((g) => ({
775
- name: g.getName(),
776
- description: g.getDescription(),
777
- values: g.getAllValues()
778
- })),
779
- upDownCounters: Array.from(this.upDownCounters.values()).map((c) => ({
780
- name: c.getName(),
781
- description: c.getDescription(),
782
- values: c.getAllValues()
783
- }))
784
- };
785
- }
786
- /**
787
- * Export counter metrics to Prometheus format
788
- */
789
- exportCountersToPrometheus(lines) {
790
- for (const counter of this.counters.values()) {
791
- lines.push(`# HELP ${counter.getName()} ${counter.getDescription()}`);
792
- lines.push(`# TYPE ${counter.getName()} counter`);
793
- for (const [labels, value] of counter.getAllValues()) {
794
- const labelStr = labels ? `{${labels}}` : "";
795
- lines.push(`${counter.getName()}${labelStr} ${value}`);
796
- }
797
- }
798
- }
799
- /**
800
- * Export histogram metrics to Prometheus format
801
- */
802
- exportHistogramsToPrometheus(lines) {
803
- for (const histogram of this.histograms.values()) {
804
- lines.push(`# HELP ${histogram.getName()} ${histogram.getDescription()}`);
805
- lines.push(`# TYPE ${histogram.getName()} histogram`);
806
- for (const [labels, data] of histogram.getAllData()) {
807
- const labelStr = labels ? `,${labels}` : "";
808
- for (const [le, count] of data.buckets) {
809
- const leStr = le === Infinity ? "+Inf" : le.toString();
810
- lines.push(`${histogram.getName()}_bucket{le="${leStr}"${labelStr}} ${count}`);
811
- }
812
- lines.push(`${histogram.getName()}_sum{${labels || ""}} ${data.sum}`);
813
- lines.push(`${histogram.getName()}_count{${labels || ""}} ${data.count}`);
814
- }
815
- }
816
- }
817
- /**
818
- * Export gauge metrics to Prometheus format
819
- */
820
- exportGaugesToPrometheus(lines) {
821
- for (const gauge of this.gauges.values()) {
822
- lines.push(`# HELP ${gauge.getName()} ${gauge.getDescription()}`);
823
- lines.push(`# TYPE ${gauge.getName()} gauge`);
824
- for (const [labels, value] of gauge.getAllValues()) {
825
- const labelStr = labels ? `{${labels}}` : "";
826
- lines.push(`${gauge.getName()}${labelStr} ${value}`);
827
- }
828
- }
829
- }
830
- /**
831
- * Export up-down counter metrics to Prometheus format (as gauges)
832
- */
833
- exportUpDownCountersToPrometheus(lines) {
834
- for (const counter of this.upDownCounters.values()) {
835
- lines.push(`# HELP ${counter.getName()} ${counter.getDescription()}`);
836
- lines.push(`# TYPE ${counter.getName()} gauge`);
837
- for (const [labels, value] of counter.getAllValues()) {
838
- const labelStr = labels ? `{${labels}}` : "";
839
- lines.push(`${counter.getName()}${labelStr} ${value}`);
840
- }
841
- }
842
- }
843
- /**
844
- * Export metrics in Prometheus format
845
- */
846
- toPrometheusFormat() {
847
- const lines = [];
848
- this.exportCountersToPrometheus(lines);
849
- this.exportHistogramsToPrometheus(lines);
850
- this.exportGaugesToPrometheus(lines);
851
- this.exportUpDownCountersToPrometheus(lines);
852
- return lines.join("\n");
853
- }
854
- /**
855
- * Reset all metrics
856
- */
857
- reset() {
858
- for (const counter of this.counters.values()) {
859
- counter.reset();
860
- }
861
- for (const histogram of this.histograms.values()) {
862
- histogram.reset();
863
- }
864
- for (const gauge of this.gauges.values()) {
865
- gauge.reset();
866
- }
867
- for (const counter of this.upDownCounters.values()) {
868
- counter.reset();
869
- }
870
- }
871
- /**
872
- * Clear all metrics (remove registrations)
873
- */
874
- clear() {
875
- this.counters.clear();
876
- this.histograms.clear();
877
- this.gauges.clear();
878
- this.upDownCounters.clear();
879
- }
880
- };
881
- var globalRegistry = null;
882
- function initializeMetricsRegistry(serviceName, metricPrefix = "") {
883
- globalRegistry = new MetricsRegistry(serviceName, metricPrefix);
884
- return globalRegistry;
885
- }
886
- __name(initializeMetricsRegistry, "initializeMetricsRegistry");
887
- function getMetricsRegistry() {
888
- if (!globalRegistry) {
889
- globalRegistry = new MetricsRegistry("unknown-service");
890
- }
891
- return globalRegistry;
892
- }
893
- __name(getMetricsRegistry, "getMetricsRegistry");
894
- function isMetricsRegistryInitialized() {
895
- return globalRegistry !== null;
896
- }
897
- __name(isMetricsRegistryInitialized, "isMetricsRegistryInitialized");
898
- function resetMetricsRegistry() {
899
- if (globalRegistry) {
900
- globalRegistry.clear();
901
- }
902
- globalRegistry = null;
903
- }
904
- __name(resetMetricsRegistry, "resetMetricsRegistry");
905
- function createCounter(name, description) {
906
- return getMetricsRegistry().createCounter(name, description);
907
- }
908
- __name(createCounter, "createCounter");
909
- function createHistogram(name, description, boundaries) {
910
- return getMetricsRegistry().createHistogram(name, description, boundaries);
911
- }
912
- __name(createHistogram, "createHistogram");
913
- function createGauge(name, description) {
914
- return getMetricsRegistry().createGauge(name, description);
915
- }
916
- __name(createGauge, "createGauge");
917
- function createUpDownCounter(name, description) {
918
- return getMetricsRegistry().createUpDownCounter(name, description);
919
- }
920
- __name(createUpDownCounter, "createUpDownCounter");
921
-
922
76
  // src/instrumentation/tracer.ts
923
77
  var SpanStatus = /* @__PURE__ */ (function(SpanStatus2) {
924
78
  SpanStatus2[SpanStatus2["UNSET"] = 0] = "UNSET";
@@ -2439,6 +1593,6 @@ function setupInstrumentation(serviceName, options) {
2439
1593
  }
2440
1594
  __name(setupInstrumentation, "setupInstrumentation");
2441
1595
 
2442
- export { DEFAULT_CACHE_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_EVENT_QUEUE_CONFIG, DEFAULT_FEATURE_FLAGS, DEFAULT_GRAPHQL_CONFIG, DEFAULT_HTTP_CONFIG, DEFAULT_LOGGING_CONFIG, DEFAULT_METRICS_CONFIG, DEFAULT_TRACING_CONFIG, ENV_VARS, Instrument, Log, Metric, MetricsRegistry, STANDARD_METRICS, SpanKind, SpanStatus, Trace, Tracer, buildDatabaseConfig, buildFeatureFlags, buildGraphQLConfig, buildInstrumentationConfig, buildMetricsConfig, buildTracingConfig, createApolloInlineTracePlugin, createCounter, createGauge, createGraphQLInstrumentationPlugin, createHistogram, createPrometheusPlugin, createUpDownCounter, extractOperationInfo, extractTraceContext, getGraphQLOperationFromContext, getGraphQLSpanFromContext, getInstrumentationConfig, getLogger, getMetricsRegistry, getTraceContext, getTracer, initializeInstrumentation, initializeInstrumentationConfig, initializeMetricsRegistry, initializeTracer, injectTraceContext, instrumentResolver, instrumentResolverMap, instrumentation_exports, instrumented, isApolloInlineTraceAvailable, isFeatureEnabled, isInstrumentationConfigInitialized, isInstrumentationInitialized, isMetricsRegistryInitialized, isPrometheusAvailable, isTracerInitialized, resetInstrumentation, resetInstrumentationConfig, resetMetricsRegistry, setActiveTelemetryLogger, setupInstrumentation, startSpan, traced, updateInstrumentationConfig, withSpan };
2443
- //# sourceMappingURL=chunk-4XAEES25.js.map
2444
- //# sourceMappingURL=chunk-4XAEES25.js.map
1596
+ export { Instrument, Log, Metric, STANDARD_METRICS, SpanKind, SpanStatus, Trace, Tracer, createApolloInlineTracePlugin, createGraphQLInstrumentationPlugin, createPrometheusPlugin, extractOperationInfo, extractTraceContext, getGraphQLOperationFromContext, getGraphQLSpanFromContext, getLogger, getTraceContext, getTracer, initializeInstrumentation, initializeTracer, injectTraceContext, instrumentResolver, instrumentResolverMap, instrumentation_exports, instrumented, isApolloInlineTraceAvailable, isInstrumentationInitialized, isPrometheusAvailable, isTracerInitialized, resetInstrumentation, setActiveTelemetryLogger, setupInstrumentation, startSpan, traced, withSpan };
1597
+ //# sourceMappingURL=chunk-ACYGOENW.js.map
1598
+ //# sourceMappingURL=chunk-ACYGOENW.js.map