alepha 0.13.0 → 0.13.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 (195) hide show
  1. package/dist/api-jobs/index.d.ts +26 -26
  2. package/dist/api-users/index.d.ts +1 -1
  3. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  4. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  5. package/dist/cli/index.d.ts +3 -11
  6. package/dist/cli/index.js +106 -74
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/email/index.js +71 -73
  9. package/dist/email/index.js.map +1 -1
  10. package/dist/orm/index.d.ts +1 -1
  11. package/dist/orm/index.js.map +1 -1
  12. package/dist/queue/index.d.ts +4 -4
  13. package/dist/retry/index.d.ts +1 -1
  14. package/dist/retry/index.js +2 -2
  15. package/dist/retry/index.js.map +1 -1
  16. package/dist/scheduler/index.d.ts +6 -6
  17. package/dist/security/index.d.ts +28 -28
  18. package/dist/server/index.js +1 -1
  19. package/dist/server/index.js.map +1 -1
  20. package/dist/server-health/index.d.ts +17 -17
  21. package/dist/server-metrics/index.js +170 -174
  22. package/dist/server-metrics/index.js.map +1 -1
  23. package/dist/server-security/index.d.ts +9 -9
  24. package/dist/vite/index.js +4 -5
  25. package/dist/vite/index.js.map +1 -1
  26. package/dist/websocket/index.d.ts +7 -7
  27. package/package.json +52 -103
  28. package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
  29. package/src/cli/assets/appRouterTs.ts +9 -0
  30. package/src/cli/assets/indexHtml.ts +2 -1
  31. package/src/cli/assets/mainBrowserTs.ts +10 -0
  32. package/src/cli/commands/CoreCommands.ts +6 -5
  33. package/src/cli/commands/DrizzleCommands.ts +65 -57
  34. package/src/cli/commands/VerifyCommands.ts +1 -1
  35. package/src/cli/services/ProjectUtils.ts +44 -38
  36. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  37. package/src/retry/descriptors/$retry.ts +5 -3
  38. package/src/server/providers/NodeHttpServerProvider.ts +1 -1
  39. package/src/vite/helpers/boot.ts +3 -3
  40. package/dist/api-files/index.cjs +0 -1293
  41. package/dist/api-files/index.cjs.map +0 -1
  42. package/dist/api-files/index.d.cts +0 -829
  43. package/dist/api-jobs/index.cjs +0 -274
  44. package/dist/api-jobs/index.cjs.map +0 -1
  45. package/dist/api-jobs/index.d.cts +0 -654
  46. package/dist/api-notifications/index.cjs +0 -380
  47. package/dist/api-notifications/index.cjs.map +0 -1
  48. package/dist/api-notifications/index.d.cts +0 -289
  49. package/dist/api-parameters/index.cjs +0 -66
  50. package/dist/api-parameters/index.cjs.map +0 -1
  51. package/dist/api-parameters/index.d.cts +0 -84
  52. package/dist/api-users/index.cjs +0 -6009
  53. package/dist/api-users/index.cjs.map +0 -1
  54. package/dist/api-users/index.d.cts +0 -4740
  55. package/dist/api-verifications/index.cjs +0 -407
  56. package/dist/api-verifications/index.cjs.map +0 -1
  57. package/dist/api-verifications/index.d.cts +0 -207
  58. package/dist/batch/index.cjs +0 -408
  59. package/dist/batch/index.cjs.map +0 -1
  60. package/dist/batch/index.d.cts +0 -330
  61. package/dist/bin/index.cjs +0 -17
  62. package/dist/bin/index.cjs.map +0 -1
  63. package/dist/bin/index.d.cts +0 -1
  64. package/dist/bucket/index.cjs +0 -303
  65. package/dist/bucket/index.cjs.map +0 -1
  66. package/dist/bucket/index.d.cts +0 -355
  67. package/dist/cache/index.cjs +0 -241
  68. package/dist/cache/index.cjs.map +0 -1
  69. package/dist/cache/index.d.cts +0 -202
  70. package/dist/cache-redis/index.cjs +0 -84
  71. package/dist/cache-redis/index.cjs.map +0 -1
  72. package/dist/cache-redis/index.d.cts +0 -40
  73. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  74. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  75. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  76. package/dist/cli/index.cjs +0 -1241
  77. package/dist/cli/index.cjs.map +0 -1
  78. package/dist/cli/index.d.cts +0 -422
  79. package/dist/command/index.cjs +0 -693
  80. package/dist/command/index.cjs.map +0 -1
  81. package/dist/command/index.d.cts +0 -340
  82. package/dist/core/index.cjs +0 -2264
  83. package/dist/core/index.cjs.map +0 -1
  84. package/dist/core/index.d.cts +0 -1927
  85. package/dist/datetime/index.cjs +0 -318
  86. package/dist/datetime/index.cjs.map +0 -1
  87. package/dist/datetime/index.d.cts +0 -145
  88. package/dist/email/index.cjs +0 -10874
  89. package/dist/email/index.cjs.map +0 -1
  90. package/dist/email/index.d.cts +0 -186
  91. package/dist/fake/index.cjs +0 -34641
  92. package/dist/fake/index.cjs.map +0 -1
  93. package/dist/fake/index.d.cts +0 -74
  94. package/dist/file/index.cjs +0 -1212
  95. package/dist/file/index.cjs.map +0 -1
  96. package/dist/file/index.d.cts +0 -698
  97. package/dist/lock/index.cjs +0 -226
  98. package/dist/lock/index.cjs.map +0 -1
  99. package/dist/lock/index.d.cts +0 -361
  100. package/dist/lock-redis/index.cjs +0 -113
  101. package/dist/lock-redis/index.cjs.map +0 -1
  102. package/dist/lock-redis/index.d.cts +0 -24
  103. package/dist/logger/index.cjs +0 -521
  104. package/dist/logger/index.cjs.map +0 -1
  105. package/dist/logger/index.d.cts +0 -281
  106. package/dist/orm/index.cjs +0 -2986
  107. package/dist/orm/index.cjs.map +0 -1
  108. package/dist/orm/index.d.cts +0 -2213
  109. package/dist/queue/index.cjs +0 -1044
  110. package/dist/queue/index.cjs.map +0 -1
  111. package/dist/queue/index.d.cts +0 -1265
  112. package/dist/queue-redis/index.cjs +0 -873
  113. package/dist/queue-redis/index.cjs.map +0 -1
  114. package/dist/queue-redis/index.d.cts +0 -82
  115. package/dist/redis/index.cjs +0 -153
  116. package/dist/redis/index.cjs.map +0 -1
  117. package/dist/redis/index.d.cts +0 -82
  118. package/dist/retry/index.cjs +0 -146
  119. package/dist/retry/index.cjs.map +0 -1
  120. package/dist/retry/index.d.cts +0 -172
  121. package/dist/router/index.cjs +0 -111
  122. package/dist/router/index.cjs.map +0 -1
  123. package/dist/router/index.d.cts +0 -46
  124. package/dist/scheduler/index.cjs +0 -576
  125. package/dist/scheduler/index.cjs.map +0 -1
  126. package/dist/scheduler/index.d.cts +0 -145
  127. package/dist/security/index.cjs +0 -2402
  128. package/dist/security/index.cjs.map +0 -1
  129. package/dist/security/index.d.cts +0 -598
  130. package/dist/server/index.cjs +0 -1680
  131. package/dist/server/index.cjs.map +0 -1
  132. package/dist/server/index.d.cts +0 -810
  133. package/dist/server-auth/index.cjs +0 -3146
  134. package/dist/server-auth/index.cjs.map +0 -1
  135. package/dist/server-auth/index.d.cts +0 -1164
  136. package/dist/server-cache/index.cjs +0 -252
  137. package/dist/server-cache/index.cjs.map +0 -1
  138. package/dist/server-cache/index.d.cts +0 -164
  139. package/dist/server-compress/index.cjs +0 -141
  140. package/dist/server-compress/index.cjs.map +0 -1
  141. package/dist/server-compress/index.d.cts +0 -38
  142. package/dist/server-cookies/index.cjs +0 -234
  143. package/dist/server-cookies/index.cjs.map +0 -1
  144. package/dist/server-cookies/index.d.cts +0 -144
  145. package/dist/server-cors/index.cjs +0 -201
  146. package/dist/server-cors/index.cjs.map +0 -1
  147. package/dist/server-cors/index.d.cts +0 -140
  148. package/dist/server-health/index.cjs +0 -62
  149. package/dist/server-health/index.cjs.map +0 -1
  150. package/dist/server-health/index.d.cts +0 -58
  151. package/dist/server-helmet/index.cjs +0 -131
  152. package/dist/server-helmet/index.cjs.map +0 -1
  153. package/dist/server-helmet/index.d.cts +0 -97
  154. package/dist/server-links/index.cjs +0 -992
  155. package/dist/server-links/index.cjs.map +0 -1
  156. package/dist/server-links/index.d.cts +0 -513
  157. package/dist/server-metrics/index.cjs +0 -4535
  158. package/dist/server-metrics/index.cjs.map +0 -1
  159. package/dist/server-metrics/index.d.cts +0 -35
  160. package/dist/server-multipart/index.cjs +0 -237
  161. package/dist/server-multipart/index.cjs.map +0 -1
  162. package/dist/server-multipart/index.d.cts +0 -50
  163. package/dist/server-proxy/index.cjs +0 -186
  164. package/dist/server-proxy/index.cjs.map +0 -1
  165. package/dist/server-proxy/index.d.cts +0 -234
  166. package/dist/server-rate-limit/index.cjs +0 -241
  167. package/dist/server-rate-limit/index.cjs.map +0 -1
  168. package/dist/server-rate-limit/index.d.cts +0 -183
  169. package/dist/server-security/index.cjs +0 -316
  170. package/dist/server-security/index.cjs.map +0 -1
  171. package/dist/server-security/index.d.cts +0 -173
  172. package/dist/server-static/index.cjs +0 -170
  173. package/dist/server-static/index.cjs.map +0 -1
  174. package/dist/server-static/index.d.cts +0 -121
  175. package/dist/server-swagger/index.cjs +0 -1021
  176. package/dist/server-swagger/index.cjs.map +0 -1
  177. package/dist/server-swagger/index.d.cts +0 -382
  178. package/dist/sms/index.cjs +0 -221
  179. package/dist/sms/index.cjs.map +0 -1
  180. package/dist/sms/index.d.cts +0 -130
  181. package/dist/thread/index.cjs +0 -350
  182. package/dist/thread/index.cjs.map +0 -1
  183. package/dist/thread/index.d.cts +0 -260
  184. package/dist/topic/index.cjs +0 -282
  185. package/dist/topic/index.cjs.map +0 -1
  186. package/dist/topic/index.d.cts +0 -523
  187. package/dist/topic-redis/index.cjs +0 -71
  188. package/dist/topic-redis/index.cjs.map +0 -1
  189. package/dist/topic-redis/index.d.cts +0 -42
  190. package/dist/vite/index.cjs +0 -1077
  191. package/dist/vite/index.cjs.map +0 -1
  192. package/dist/vite/index.d.cts +0 -542
  193. package/dist/websocket/index.cjs +0 -1117
  194. package/dist/websocket/index.cjs.map +0 -1
  195. package/dist/websocket/index.d.cts +0 -861
@@ -1,4535 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res) => function() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
- };
9
- var __commonJS = (cb, mod) => function() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
- };
12
- var __export = (all, symbols) => {
13
- let target = {};
14
- for (var name in all) {
15
- __defProp(target, name, {
16
- get: all[name],
17
- enumerable: true
18
- });
19
- }
20
- if (symbols) {
21
- __defProp(target, Symbol.toStringTag, { value: "Module" });
22
- }
23
- return target;
24
- };
25
- var __copyProps = (to, from, except, desc) => {
26
- if (from && typeof from === "object" || typeof from === "function") {
27
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
28
- key = keys[i];
29
- if (!__hasOwnProp.call(to, key) && key !== except) {
30
- __defProp(to, key, {
31
- get: ((k) => from[k]).bind(null, key),
32
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
33
- });
34
- }
35
- }
36
- }
37
- return to;
38
- };
39
- var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
-
41
- //#endregion
42
- let alepha = require("alepha");
43
- let alepha_server = require("alepha/server");
44
-
45
- //#region ../../node_modules/prom-client/lib/util.js
46
- var require_util = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/util.js": ((exports) => {
47
- exports.getValueAsString = function getValueString(value) {
48
- if (Number.isNaN(value)) return "Nan";
49
- else if (!Number.isFinite(value)) if (value < 0) return "-Inf";
50
- else return "+Inf";
51
- else return `${value}`;
52
- };
53
- exports.removeLabels = function removeLabels$4(hashMap, labels, sortedLabelNames) {
54
- const hash = hashObject$5(labels, sortedLabelNames);
55
- delete hashMap[hash];
56
- };
57
- exports.setValue = function setValue$2(hashMap, value, labels) {
58
- const hash = hashObject$5(labels);
59
- hashMap[hash] = {
60
- value: typeof value === "number" ? value : 0,
61
- labels: labels || {}
62
- };
63
- return hashMap;
64
- };
65
- exports.setValueDelta = function setValueDelta$1(hashMap, deltaValue, labels, hash = "") {
66
- const value = typeof deltaValue === "number" ? deltaValue : 0;
67
- if (hashMap[hash]) hashMap[hash].value += value;
68
- else hashMap[hash] = {
69
- value,
70
- labels
71
- };
72
- return hashMap;
73
- };
74
- exports.getLabels = function(labelNames, args) {
75
- if (typeof args[0] === "object") return args[0];
76
- if (labelNames.length !== args.length) throw new Error(`Invalid number of arguments (${args.length}): "${args.join(", ")}" for label names (${labelNames.length}): "${labelNames.join(", ")}".`);
77
- const acc = {};
78
- for (let i = 0; i < labelNames.length; i++) acc[labelNames[i]] = args[i];
79
- return acc;
80
- };
81
- function fastHashObject(keys, labels) {
82
- if (keys.length === 0) return "";
83
- let hash = "";
84
- for (let i = 0; i < keys.length; i++) {
85
- const key = keys[i];
86
- const value = labels[key];
87
- if (value === void 0) continue;
88
- hash += `${key}:${value},`;
89
- }
90
- return hash;
91
- }
92
- function hashObject$5(labels, labelNames) {
93
- if (labelNames) return fastHashObject(labelNames, labels);
94
- const keys = Object.keys(labels);
95
- if (keys.length > 1) keys.sort();
96
- return fastHashObject(keys, labels);
97
- }
98
- exports.hashObject = hashObject$5;
99
- exports.isObject = function isObject$5(obj) {
100
- return obj !== null && typeof obj === "object";
101
- };
102
- exports.nowTimestamp = function nowTimestamp$2() {
103
- return Date.now() / 1e3;
104
- };
105
- var Grouper$2 = class extends Map {
106
- /**
107
- * Adds the `value` to the `key`'s array of values.
108
- * @param {*} key Key to set.
109
- * @param {*} value Value to add to `key`'s array.
110
- * @returns {undefined} undefined.
111
- */
112
- add(key, value) {
113
- if (this.has(key)) this.get(key).push(value);
114
- else this.set(key, [value]);
115
- }
116
- };
117
- exports.Grouper = Grouper$2;
118
- }) });
119
-
120
- //#endregion
121
- //#region ../../node_modules/prom-client/lib/registry.js
122
- var require_registry = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/registry.js": ((exports, module) => {
123
- const { getValueAsString } = require_util();
124
- var Registry$3 = class Registry$3 {
125
- static get PROMETHEUS_CONTENT_TYPE() {
126
- return "text/plain; version=0.0.4; charset=utf-8";
127
- }
128
- static get OPENMETRICS_CONTENT_TYPE() {
129
- return "application/openmetrics-text; version=1.0.0; charset=utf-8";
130
- }
131
- constructor(regContentType = Registry$3.PROMETHEUS_CONTENT_TYPE) {
132
- this._metrics = {};
133
- this._collectors = [];
134
- this._defaultLabels = {};
135
- if (regContentType !== Registry$3.PROMETHEUS_CONTENT_TYPE && regContentType !== Registry$3.OPENMETRICS_CONTENT_TYPE) throw new TypeError(`Content type ${regContentType} is unsupported`);
136
- this._contentType = regContentType;
137
- }
138
- getMetricsAsArray() {
139
- return Object.values(this._metrics);
140
- }
141
- async getMetricsAsString(metrics$2) {
142
- const metric = typeof metrics$2.getForPromString === "function" ? await metrics$2.getForPromString() : await metrics$2.get();
143
- const name = escapeString(metric.name);
144
- const values$1 = [`# HELP ${name} ${escapeString(metric.help)}`, `# TYPE ${name} ${metric.type}`];
145
- const defaultLabels = Object.keys(this._defaultLabels).length > 0 ? this._defaultLabels : null;
146
- const isOpenMetrics = this.contentType === Registry$3.OPENMETRICS_CONTENT_TYPE;
147
- for (const val of metric.values || []) {
148
- let { metricName = name, labels = {} } = val;
149
- const { sharedLabels = {} } = val;
150
- if (isOpenMetrics && metric.type === "counter") metricName = `${metricName}_total`;
151
- if (defaultLabels) labels = {
152
- ...labels,
153
- ...defaultLabels,
154
- ...labels
155
- };
156
- const formattedLabels = formatLabels(labels, sharedLabels);
157
- const flattenedShared = flattenSharedLabels(sharedLabels);
158
- const labelParts = [...formattedLabels, flattenedShared].filter(Boolean);
159
- const labelsString = labelParts.length ? `{${labelParts.join(",")}}` : "";
160
- let fullMetricLine = `${metricName}${labelsString} ${getValueAsString(val.value)}`;
161
- const { exemplar } = val;
162
- if (exemplar && isOpenMetrics) {
163
- const formattedExemplars = formatLabels(exemplar.labelSet);
164
- fullMetricLine += ` # {${formattedExemplars.join(",")}} ${getValueAsString(exemplar.value)} ${exemplar.timestamp}`;
165
- }
166
- values$1.push(fullMetricLine);
167
- }
168
- return values$1.join("\n");
169
- }
170
- async metrics() {
171
- const isOpenMetrics = this.contentType === Registry$3.OPENMETRICS_CONTENT_TYPE;
172
- const promises = this.getMetricsAsArray().map((metric) => {
173
- if (isOpenMetrics && metric.type === "counter") metric.name = standardizeCounterName(metric.name);
174
- return this.getMetricsAsString(metric);
175
- });
176
- const resolves = await Promise.all(promises);
177
- return isOpenMetrics ? `${resolves.join("\n")}\n# EOF\n` : `${resolves.join("\n\n")}\n`;
178
- }
179
- registerMetric(metric) {
180
- if (this._metrics[metric.name] && this._metrics[metric.name] !== metric) throw new Error(`A metric with the name ${metric.name} has already been registered.`);
181
- this._metrics[metric.name] = metric;
182
- }
183
- clear() {
184
- this._metrics = {};
185
- this._defaultLabels = {};
186
- }
187
- async getMetricsAsJSON() {
188
- const metrics$2 = [];
189
- const defaultLabelNames = Object.keys(this._defaultLabels);
190
- const promises = [];
191
- for (const metric of this.getMetricsAsArray()) promises.push(metric.get());
192
- const resolves = await Promise.all(promises);
193
- for (const item of resolves) {
194
- if (item.values && defaultLabelNames.length > 0) for (const val of item.values) {
195
- val.labels = Object.assign({}, val.labels);
196
- for (const labelName of defaultLabelNames) val.labels[labelName] = val.labels[labelName] || this._defaultLabels[labelName];
197
- }
198
- metrics$2.push(item);
199
- }
200
- return metrics$2;
201
- }
202
- removeSingleMetric(name) {
203
- delete this._metrics[name];
204
- }
205
- getSingleMetricAsString(name) {
206
- return this.getMetricsAsString(this._metrics[name]);
207
- }
208
- getSingleMetric(name) {
209
- return this._metrics[name];
210
- }
211
- setDefaultLabels(labels) {
212
- this._defaultLabels = labels;
213
- }
214
- resetMetrics() {
215
- for (const metric in this._metrics) this._metrics[metric].reset();
216
- }
217
- get contentType() {
218
- return this._contentType;
219
- }
220
- setContentType(metricsContentType) {
221
- if (metricsContentType === Registry$3.OPENMETRICS_CONTENT_TYPE || metricsContentType === Registry$3.PROMETHEUS_CONTENT_TYPE) this._contentType = metricsContentType;
222
- else throw new Error(`Content type ${metricsContentType} is unsupported`);
223
- }
224
- static merge(registers) {
225
- const regType = registers[0].contentType;
226
- for (const reg of registers) if (reg.contentType !== regType) throw new Error("Registers can only be merged if they have the same content type");
227
- const mergedRegistry = new Registry$3(regType);
228
- registers.reduce((acc, reg) => acc.concat(reg.getMetricsAsArray()), []).forEach(mergedRegistry.registerMetric, mergedRegistry);
229
- return mergedRegistry;
230
- }
231
- };
232
- function formatLabels(labels, exclude) {
233
- const { hasOwnProperty } = Object.prototype;
234
- const formatted = [];
235
- for (const [name, value] of Object.entries(labels)) if (!exclude || !hasOwnProperty.call(exclude, name)) formatted.push(`${name}="${escapeLabelValue(value)}"`);
236
- return formatted;
237
- }
238
- const sharedLabelCache = /* @__PURE__ */ new WeakMap();
239
- function flattenSharedLabels(labels) {
240
- const cached = sharedLabelCache.get(labels);
241
- if (cached) return cached;
242
- const flattened = formatLabels(labels).join(",");
243
- sharedLabelCache.set(labels, flattened);
244
- return flattened;
245
- }
246
- function escapeLabelValue(str) {
247
- if (typeof str !== "string") return str;
248
- return escapeString(str).replace(/"/g, "\\\"");
249
- }
250
- function escapeString(str) {
251
- return str.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
252
- }
253
- function standardizeCounterName(name) {
254
- return name.replace(/_total$/, "");
255
- }
256
- module.exports = Registry$3;
257
- module.exports.globalRegistry = new Registry$3();
258
- }) });
259
-
260
- //#endregion
261
- //#region ../../node_modules/prom-client/lib/validation.js
262
- var require_validation = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/validation.js": ((exports) => {
263
- const util$4 = require("util");
264
- const metricRegexp = /^[a-zA-Z_:][a-zA-Z0-9_:]*$/;
265
- const labelRegexp = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
266
- exports.validateMetricName = function(name) {
267
- return metricRegexp.test(name);
268
- };
269
- exports.validateLabelName = function(names = []) {
270
- return names.every((name) => labelRegexp.test(name));
271
- };
272
- exports.validateLabel = function validateLabel$4(savedLabels, labels) {
273
- for (const label in labels) if (!savedLabels.includes(label)) throw new Error(`Added label "${label}" is not included in initial labelset: ${util$4.inspect(savedLabels)}`);
274
- };
275
- }) });
276
-
277
- //#endregion
278
- //#region ../../node_modules/prom-client/lib/metric.js
279
- var require_metric = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metric.js": ((exports, module) => {
280
- const Registry$2 = require_registry();
281
- const { isObject: isObject$4 } = require_util();
282
- const { validateMetricName, validateLabelName } = require_validation();
283
- /**
284
- * @abstract
285
- */
286
- var Metric$4 = class {
287
- constructor(config, defaults = {}) {
288
- if (!isObject$4(config)) throw new TypeError("constructor expected a config object");
289
- Object.assign(this, {
290
- labelNames: [],
291
- registers: [Registry$2.globalRegistry],
292
- aggregator: "sum",
293
- enableExemplars: false
294
- }, defaults, config);
295
- if (!this.registers) this.registers = [Registry$2.globalRegistry];
296
- if (!this.help) throw new Error("Missing mandatory help parameter");
297
- if (!this.name) throw new Error("Missing mandatory name parameter");
298
- if (!validateMetricName(this.name)) throw new Error("Invalid metric name");
299
- if (!validateLabelName(this.labelNames)) throw new Error("Invalid label name");
300
- if (this.collect && typeof this.collect !== "function") throw new Error("Optional \"collect\" parameter must be a function");
301
- if (this.labelNames) this.sortedLabelNames = [...this.labelNames].sort();
302
- else this.sortedLabelNames = [];
303
- this.reset();
304
- for (const register of this.registers) {
305
- if (this.enableExemplars && register.contentType === Registry$2.PROMETHEUS_CONTENT_TYPE) throw new TypeError("Exemplars are supported only on OpenMetrics registries");
306
- register.registerMetric(this);
307
- }
308
- }
309
- reset() {}
310
- };
311
- module.exports = { Metric: Metric$4 };
312
- }) });
313
-
314
- //#endregion
315
- //#region ../../node_modules/prom-client/lib/exemplar.js
316
- var require_exemplar = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/exemplar.js": ((exports, module) => {
317
- /**
318
- * Class representing an OpenMetrics exemplar.
319
- *
320
- * @property {object} labelSet
321
- * @property {number} value
322
- * @property {number} [timestamp]
323
- * */
324
- var Exemplar$2 = class {
325
- constructor(labelSet = {}, value = null) {
326
- this.labelSet = labelSet;
327
- this.value = value;
328
- }
329
- /**
330
- * Validation for the label set format.
331
- * https://github.com/OpenObservability/OpenMetrics/blob/d99b705f611b75fec8f450b05e344e02eea6921d/specification/OpenMetrics.md#exemplars
332
- *
333
- * @param {object} labelSet - Exemplar labels.
334
- * @throws {RangeError}
335
- * @return {void}
336
- */
337
- validateExemplarLabelSet(labelSet) {
338
- let res = "";
339
- for (const [labelName, labelValue] of Object.entries(labelSet)) res += `${labelName}${labelValue}`;
340
- if (res.length > 128) throw new RangeError("Label set size must be smaller than 128 UTF-8 chars");
341
- }
342
- };
343
- module.exports = Exemplar$2;
344
- }) });
345
-
346
- //#endregion
347
- //#region ../../node_modules/prom-client/lib/counter.js
348
- /**
349
- * Counter metric
350
- */
351
- var require_counter = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/counter.js": ((exports, module) => {
352
- const util$3 = require("util");
353
- const { hashObject: hashObject$4, isObject: isObject$3, getLabels: getLabels$3, removeLabels: removeLabels$3, nowTimestamp: nowTimestamp$1 } = require_util();
354
- const { validateLabel: validateLabel$3 } = require_validation();
355
- const { Metric: Metric$3 } = require_metric();
356
- const Exemplar$1 = require_exemplar();
357
- var Counter$1 = class extends Metric$3 {
358
- constructor(config) {
359
- super(config);
360
- this.type = "counter";
361
- this.defaultLabels = {};
362
- this.defaultValue = 1;
363
- this.defaultExemplarLabelSet = {};
364
- if (config.enableExemplars) {
365
- this.enableExemplars = true;
366
- this.inc = this.incWithExemplar;
367
- } else this.inc = this.incWithoutExemplar;
368
- }
369
- /**
370
- * Increment counter
371
- * @param {object} labels - What label you want to be incremented
372
- * @param {Number} value - Value to increment, if omitted increment with 1
373
- * @returns {object} results - object with information about the inc operation
374
- * @returns {string} results.labelHash - hash representation of the labels
375
- */
376
- incWithoutExemplar(labels, value) {
377
- let hash = "";
378
- if (isObject$3(labels)) {
379
- hash = hashObject$4(labels, this.sortedLabelNames);
380
- validateLabel$3(this.labelNames, labels);
381
- } else {
382
- value = labels;
383
- labels = {};
384
- }
385
- if (value && !Number.isFinite(value)) throw new TypeError(`Value is not a valid number: ${util$3.format(value)}`);
386
- if (value < 0) throw new Error("It is not possible to decrease a counter");
387
- if (value === null || value === void 0) value = 1;
388
- setValue$1(this.hashMap, value, labels, hash);
389
- return { labelHash: hash };
390
- }
391
- /**
392
- * Increment counter with exemplar, same as inc but accepts labels for an
393
- * exemplar.
394
- * If no label is provided the current exemplar labels are kept unchanged
395
- * (defaults to empty set).
396
- *
397
- * @param {object} incOpts - Object with options about what metric to increase
398
- * @param {object} incOpts.labels - What label you want to be incremented,
399
- * defaults to null (metric with no labels)
400
- * @param {Number} incOpts.value - Value to increment, defaults to 1
401
- * @param {object} incOpts.exemplarLabels - Key-value labels for the
402
- * exemplar, defaults to empty set {}
403
- * @returns {void}
404
- */
405
- incWithExemplar({ labels = this.defaultLabels, value = this.defaultValue, exemplarLabels = this.defaultExemplarLabelSet } = {}) {
406
- const res = this.incWithoutExemplar(labels, value);
407
- this.updateExemplar(exemplarLabels, value, res.labelHash);
408
- }
409
- updateExemplar(exemplarLabels, value, hash) {
410
- if (exemplarLabels === this.defaultExemplarLabelSet) return;
411
- if (!isObject$3(this.hashMap[hash].exemplar)) this.hashMap[hash].exemplar = new Exemplar$1();
412
- this.hashMap[hash].exemplar.validateExemplarLabelSet(exemplarLabels);
413
- this.hashMap[hash].exemplar.labelSet = exemplarLabels;
414
- this.hashMap[hash].exemplar.value = value ? value : 1;
415
- this.hashMap[hash].exemplar.timestamp = nowTimestamp$1();
416
- }
417
- /**
418
- * Reset counter
419
- * @returns {void}
420
- */
421
- reset() {
422
- this.hashMap = {};
423
- if (this.labelNames.length === 0) setValue$1(this.hashMap, 0);
424
- }
425
- async get() {
426
- if (this.collect) {
427
- const v = this.collect();
428
- if (v instanceof Promise) await v;
429
- }
430
- return {
431
- help: this.help,
432
- name: this.name,
433
- type: this.type,
434
- values: Object.values(this.hashMap),
435
- aggregator: this.aggregator
436
- };
437
- }
438
- labels(...args) {
439
- const labels = getLabels$3(this.labelNames, args) || {};
440
- return { inc: this.inc.bind(this, labels) };
441
- }
442
- remove(...args) {
443
- const labels = getLabels$3(this.labelNames, args) || {};
444
- validateLabel$3(this.labelNames, labels);
445
- return removeLabels$3.call(this, this.hashMap, labels, this.sortedLabelNames);
446
- }
447
- };
448
- function setValue$1(hashMap, value, labels = {}, hash = "") {
449
- if (hashMap[hash]) hashMap[hash].value += value;
450
- else hashMap[hash] = {
451
- value,
452
- labels
453
- };
454
- return hashMap;
455
- }
456
- module.exports = Counter$1;
457
- }) });
458
-
459
- //#endregion
460
- //#region ../../node_modules/prom-client/lib/gauge.js
461
- /**
462
- * Gauge metric
463
- */
464
- var require_gauge = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/gauge.js": ((exports, module) => {
465
- const util$2 = require("util");
466
- const { setValue, setValueDelta, getLabels: getLabels$2, hashObject: hashObject$3, isObject: isObject$2, removeLabels: removeLabels$2 } = require_util();
467
- const { validateLabel: validateLabel$2 } = require_validation();
468
- const { Metric: Metric$2 } = require_metric();
469
- var Gauge$12 = class extends Metric$2 {
470
- constructor(config) {
471
- super(config);
472
- this.type = "gauge";
473
- }
474
- /**
475
- * Set a gauge to a value
476
- * @param {object} labels - Object with labels and their values
477
- * @param {Number} value - Value to set the gauge to, must be positive
478
- * @returns {void}
479
- */
480
- set(labels, value) {
481
- value = getValueArg(labels, value);
482
- labels = getLabelArg(labels);
483
- set(this, labels, value);
484
- }
485
- /**
486
- * Reset gauge
487
- * @returns {void}
488
- */
489
- reset() {
490
- this.hashMap = {};
491
- if (this.labelNames.length === 0) setValue(this.hashMap, 0, {});
492
- }
493
- /**
494
- * Increment a gauge value
495
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
496
- * @param {Number} value - Value to increment - if omitted, increment with 1
497
- * @returns {void}
498
- */
499
- inc(labels, value) {
500
- value = getValueArg(labels, value);
501
- labels = getLabelArg(labels);
502
- if (value === void 0) value = 1;
503
- setDelta(this, labels, value);
504
- }
505
- /**
506
- * Decrement a gauge value
507
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
508
- * @param {Number} value - Value to decrement - if omitted, decrement with 1
509
- * @returns {void}
510
- */
511
- dec(labels, value) {
512
- value = getValueArg(labels, value);
513
- labels = getLabelArg(labels);
514
- if (value === void 0) value = 1;
515
- setDelta(this, labels, -value);
516
- }
517
- /**
518
- * Set the gauge to current unix epoch
519
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
520
- * @returns {void}
521
- */
522
- setToCurrentTime(labels) {
523
- const now = Date.now() / 1e3;
524
- if (labels === void 0) this.set(now);
525
- else this.set(labels, now);
526
- }
527
- /**
528
- * Start a timer
529
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
530
- * @returns {function} - Invoke this function to set the duration in seconds since you started the timer.
531
- * @example
532
- * var done = gauge.startTimer();
533
- * makeXHRRequest(function(err, response) {
534
- * done(); //Duration of the request will be saved
535
- * });
536
- */
537
- startTimer(labels) {
538
- const start = process.hrtime();
539
- return (endLabels) => {
540
- const delta = process.hrtime(start);
541
- const value = delta[0] + delta[1] / 1e9;
542
- this.set(Object.assign({}, labels, endLabels), value);
543
- return value;
544
- };
545
- }
546
- async get() {
547
- if (this.collect) {
548
- const v = this.collect();
549
- if (v instanceof Promise) await v;
550
- }
551
- return {
552
- help: this.help,
553
- name: this.name,
554
- type: this.type,
555
- values: Object.values(this.hashMap),
556
- aggregator: this.aggregator
557
- };
558
- }
559
- _getValue(labels) {
560
- const hash = hashObject$3(labels || {}, this.sortedLabelNames);
561
- return this.hashMap[hash] ? this.hashMap[hash].value : 0;
562
- }
563
- labels(...args) {
564
- const labels = getLabels$2(this.labelNames, args);
565
- validateLabel$2(this.labelNames, labels);
566
- return {
567
- inc: this.inc.bind(this, labels),
568
- dec: this.dec.bind(this, labels),
569
- set: this.set.bind(this, labels),
570
- setToCurrentTime: this.setToCurrentTime.bind(this, labels),
571
- startTimer: this.startTimer.bind(this, labels)
572
- };
573
- }
574
- remove(...args) {
575
- const labels = getLabels$2(this.labelNames, args);
576
- validateLabel$2(this.labelNames, labels);
577
- removeLabels$2.call(this, this.hashMap, labels, this.sortedLabelNames);
578
- }
579
- };
580
- function set(gauge, labels, value) {
581
- if (typeof value !== "number") throw new TypeError(`Value is not a valid number: ${util$2.format(value)}`);
582
- validateLabel$2(gauge.labelNames, labels);
583
- setValue(gauge.hashMap, value, labels);
584
- }
585
- function setDelta(gauge, labels, delta) {
586
- if (typeof delta !== "number") throw new TypeError(`Delta is not a valid number: ${util$2.format(delta)}`);
587
- validateLabel$2(gauge.labelNames, labels);
588
- const hash = hashObject$3(labels, gauge.sortedLabelNames);
589
- setValueDelta(gauge.hashMap, delta, labels, hash);
590
- }
591
- function getLabelArg(labels) {
592
- return isObject$2(labels) ? labels : {};
593
- }
594
- function getValueArg(labels, value) {
595
- return isObject$2(labels) ? value : labels;
596
- }
597
- module.exports = Gauge$12;
598
- }) });
599
-
600
- //#endregion
601
- //#region ../../node_modules/prom-client/lib/histogram.js
602
- /**
603
- * Histogram
604
- */
605
- var require_histogram = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/histogram.js": ((exports, module) => {
606
- const util$1 = require("util");
607
- const { getLabels: getLabels$1, hashObject: hashObject$2, isObject: isObject$1, removeLabels: removeLabels$1, nowTimestamp } = require_util();
608
- const { validateLabel: validateLabel$1 } = require_validation();
609
- const { Metric: Metric$1 } = require_metric();
610
- const Exemplar = require_exemplar();
611
- var Histogram$2 = class extends Metric$1 {
612
- constructor(config) {
613
- super(config, { buckets: [
614
- .005,
615
- .01,
616
- .025,
617
- .05,
618
- .1,
619
- .25,
620
- .5,
621
- 1,
622
- 2.5,
623
- 5,
624
- 10
625
- ] });
626
- this.type = "histogram";
627
- this.defaultLabels = {};
628
- this.defaultExemplarLabelSet = {};
629
- this.enableExemplars = false;
630
- for (const label of this.labelNames) if (label === "le") throw new Error("le is a reserved label keyword");
631
- this.upperBounds = this.buckets;
632
- this.bucketValues = this.upperBounds.reduce((acc, upperBound) => {
633
- acc[upperBound] = 0;
634
- return acc;
635
- }, {});
636
- if (config.enableExemplars) {
637
- this.enableExemplars = true;
638
- this.bucketExemplars = this.upperBounds.reduce((acc, upperBound) => {
639
- acc[upperBound] = null;
640
- return acc;
641
- }, {});
642
- Object.freeze(this.bucketExemplars);
643
- this.observe = this.observeWithExemplar;
644
- } else this.observe = this.observeWithoutExemplar;
645
- Object.freeze(this.bucketValues);
646
- Object.freeze(this.upperBounds);
647
- if (this.labelNames.length === 0) this.hashMap = { [hashObject$2({})]: createBaseValues({}, this.bucketValues, this.bucketExemplars) };
648
- }
649
- /**
650
- * Observe a value in histogram
651
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
652
- * @param {Number} value - Value to observe in the histogram
653
- * @returns {void}
654
- */
655
- observeWithoutExemplar(labels, value) {
656
- observe$1.call(this, labels === 0 ? 0 : labels || {})(value);
657
- }
658
- observeWithExemplar({ labels = this.defaultLabels, value, exemplarLabels = this.defaultExemplarLabelSet } = {}) {
659
- observe$1.call(this, labels === 0 ? 0 : labels || {})(value);
660
- this.updateExemplar(labels, value, exemplarLabels);
661
- }
662
- updateExemplar(labels, value, exemplarLabels) {
663
- if (Object.keys(exemplarLabels).length === 0) return;
664
- const hash = hashObject$2(labels, this.sortedLabelNames);
665
- const bound = findBound(this.upperBounds, value);
666
- const { bucketExemplars } = this.hashMap[hash];
667
- let exemplar = bucketExemplars[bound];
668
- if (!isObject$1(exemplar)) {
669
- exemplar = new Exemplar();
670
- bucketExemplars[bound] = exemplar;
671
- }
672
- exemplar.validateExemplarLabelSet(exemplarLabels);
673
- exemplar.labelSet = exemplarLabels;
674
- exemplar.value = value;
675
- exemplar.timestamp = nowTimestamp();
676
- }
677
- async get() {
678
- const data = await this.getForPromString();
679
- data.values = data.values.map(splayLabels);
680
- return data;
681
- }
682
- async getForPromString() {
683
- if (this.collect) {
684
- const v = this.collect();
685
- if (v instanceof Promise) await v;
686
- }
687
- const values$1 = Object.values(this.hashMap).map(extractBucketValuesForExport(this)).reduce(addSumAndCountForExport(this), []);
688
- return {
689
- name: this.name,
690
- help: this.help,
691
- type: this.type,
692
- values: values$1,
693
- aggregator: this.aggregator
694
- };
695
- }
696
- reset() {
697
- this.hashMap = {};
698
- }
699
- /**
700
- * Initialize the metrics for the given combination of labels to zero
701
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
702
- * @returns {void}
703
- */
704
- zero(labels) {
705
- const hash = hashObject$2(labels, this.sortedLabelNames);
706
- this.hashMap[hash] = createBaseValues(labels, this.bucketValues, this.bucketExemplars);
707
- }
708
- /**
709
- * Start a timer that could be used to logging durations
710
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
711
- * @param {object} exemplarLabels - Object with labels for exemplar where key is the label key and value is label value. Can only be one level deep
712
- * @returns {function} - Function to invoke when you want to stop the timer and observe the duration in seconds
713
- * @example
714
- * var end = histogram.startTimer();
715
- * makeExpensiveXHRRequest(function(err, res) {
716
- * const duration = end(); //Observe the duration of expensiveXHRRequest and returns duration in seconds
717
- * console.log('Duration', duration);
718
- * });
719
- */
720
- startTimer(labels, exemplarLabels) {
721
- return this.enableExemplars ? startTimerWithExemplar.call(this, labels, exemplarLabels)() : startTimer$1.call(this, labels)();
722
- }
723
- labels(...args) {
724
- const labels = getLabels$1(this.labelNames, args);
725
- validateLabel$1(this.labelNames, labels);
726
- return {
727
- observe: observe$1.call(this, labels),
728
- startTimer: startTimer$1.call(this, labels)
729
- };
730
- }
731
- remove(...args) {
732
- const labels = getLabels$1(this.labelNames, args);
733
- validateLabel$1(this.labelNames, labels);
734
- removeLabels$1.call(this, this.hashMap, labels, this.sortedLabelNames);
735
- }
736
- };
737
- function startTimer$1(startLabels) {
738
- return () => {
739
- const start = process.hrtime();
740
- return (endLabels) => {
741
- const delta = process.hrtime(start);
742
- const value = delta[0] + delta[1] / 1e9;
743
- this.observe(Object.assign({}, startLabels, endLabels), value);
744
- return value;
745
- };
746
- };
747
- }
748
- function startTimerWithExemplar(startLabels, startExemplarLabels) {
749
- return () => {
750
- const start = process.hrtime();
751
- return (endLabels, endExemplarLabels) => {
752
- const delta = process.hrtime(start);
753
- const value = delta[0] + delta[1] / 1e9;
754
- this.observe({
755
- labels: Object.assign({}, startLabels, endLabels),
756
- value,
757
- exemplarLabels: Object.assign({}, startExemplarLabels, endExemplarLabels)
758
- });
759
- return value;
760
- };
761
- };
762
- }
763
- function setValuePair(labels, value, metricName, exemplar, sharedLabels = {}) {
764
- return {
765
- labels,
766
- sharedLabels,
767
- value,
768
- metricName,
769
- exemplar
770
- };
771
- }
772
- function findBound(upperBounds, value) {
773
- for (let i = 0; i < upperBounds.length; i++) {
774
- const bound = upperBounds[i];
775
- if (value <= bound) return bound;
776
- }
777
- return -1;
778
- }
779
- function observe$1(labels) {
780
- return (value) => {
781
- const labelValuePair = convertLabelsAndValues$1(labels, value);
782
- validateLabel$1(this.labelNames, labelValuePair.labels);
783
- if (!Number.isFinite(labelValuePair.value)) throw new TypeError(`Value is not a valid number: ${util$1.format(labelValuePair.value)}`);
784
- const hash = hashObject$2(labelValuePair.labels, this.sortedLabelNames);
785
- let valueFromMap = this.hashMap[hash];
786
- if (!valueFromMap) valueFromMap = createBaseValues(labelValuePair.labels, this.bucketValues, this.bucketExemplars);
787
- const b = findBound(this.upperBounds, labelValuePair.value);
788
- valueFromMap.sum += labelValuePair.value;
789
- valueFromMap.count += 1;
790
- if (Object.prototype.hasOwnProperty.call(valueFromMap.bucketValues, b)) valueFromMap.bucketValues[b] += 1;
791
- this.hashMap[hash] = valueFromMap;
792
- };
793
- }
794
- function createBaseValues(labels, bucketValues, bucketExemplars) {
795
- const result = {
796
- labels,
797
- bucketValues: { ...bucketValues },
798
- sum: 0,
799
- count: 0
800
- };
801
- if (bucketExemplars) result.bucketExemplars = { ...bucketExemplars };
802
- return result;
803
- }
804
- function convertLabelsAndValues$1(labels, value) {
805
- return isObject$1(labels) ? {
806
- labels,
807
- value
808
- } : {
809
- value: labels,
810
- labels: {}
811
- };
812
- }
813
- function extractBucketValuesForExport(histogram) {
814
- const name = `${histogram.name}_bucket`;
815
- return (bucketData) => {
816
- let acc = 0;
817
- return {
818
- buckets: histogram.upperBounds.map((upperBound) => {
819
- acc += bucketData.bucketValues[upperBound];
820
- return setValuePair({ le: upperBound }, acc, name, bucketData.bucketExemplars ? bucketData.bucketExemplars[upperBound] : null, bucketData.labels);
821
- }),
822
- data: bucketData
823
- };
824
- };
825
- }
826
- function addSumAndCountForExport(histogram) {
827
- return (acc, d) => {
828
- acc.push(...d.buckets);
829
- acc.push(setValuePair({ le: "+Inf" }, d.data.count, `${histogram.name}_bucket`, d.data.bucketExemplars ? d.data.bucketExemplars["-1"] : null, d.data.labels), setValuePair({}, d.data.sum, `${histogram.name}_sum`, void 0, d.data.labels), setValuePair({}, d.data.count, `${histogram.name}_count`, void 0, d.data.labels));
830
- return acc;
831
- };
832
- }
833
- function splayLabels(bucket) {
834
- const { sharedLabels, labels, ...newBucket } = bucket;
835
- for (const label of Object.keys(sharedLabels)) labels[label] = sharedLabels[label];
836
- newBucket.labels = labels;
837
- return newBucket;
838
- }
839
- module.exports = Histogram$2;
840
- }) });
841
-
842
- //#endregion
843
- //#region ../../node_modules/bintrees/lib/treebase.js
844
- var require_treebase = /* @__PURE__ */ __commonJS({ "../../node_modules/bintrees/lib/treebase.js": ((exports, module) => {
845
- function TreeBase$2() {}
846
- TreeBase$2.prototype.clear = function() {
847
- this._root = null;
848
- this.size = 0;
849
- };
850
- TreeBase$2.prototype.find = function(data) {
851
- var res = this._root;
852
- while (res !== null) {
853
- var c = this._comparator(data, res.data);
854
- if (c === 0) return res.data;
855
- else res = res.get_child(c > 0);
856
- }
857
- return null;
858
- };
859
- TreeBase$2.prototype.findIter = function(data) {
860
- var res = this._root;
861
- var iter = this.iterator();
862
- while (res !== null) {
863
- var c = this._comparator(data, res.data);
864
- if (c === 0) {
865
- iter._cursor = res;
866
- return iter;
867
- } else {
868
- iter._ancestors.push(res);
869
- res = res.get_child(c > 0);
870
- }
871
- }
872
- return null;
873
- };
874
- TreeBase$2.prototype.lowerBound = function(item) {
875
- var cur = this._root;
876
- var iter = this.iterator();
877
- var cmp = this._comparator;
878
- while (cur !== null) {
879
- var c = cmp(item, cur.data);
880
- if (c === 0) {
881
- iter._cursor = cur;
882
- return iter;
883
- }
884
- iter._ancestors.push(cur);
885
- cur = cur.get_child(c > 0);
886
- }
887
- for (var i = iter._ancestors.length - 1; i >= 0; --i) {
888
- cur = iter._ancestors[i];
889
- if (cmp(item, cur.data) < 0) {
890
- iter._cursor = cur;
891
- iter._ancestors.length = i;
892
- return iter;
893
- }
894
- }
895
- iter._ancestors.length = 0;
896
- return iter;
897
- };
898
- TreeBase$2.prototype.upperBound = function(item) {
899
- var iter = this.lowerBound(item);
900
- var cmp = this._comparator;
901
- while (iter.data() !== null && cmp(iter.data(), item) === 0) iter.next();
902
- return iter;
903
- };
904
- TreeBase$2.prototype.min = function() {
905
- var res = this._root;
906
- if (res === null) return null;
907
- while (res.left !== null) res = res.left;
908
- return res.data;
909
- };
910
- TreeBase$2.prototype.max = function() {
911
- var res = this._root;
912
- if (res === null) return null;
913
- while (res.right !== null) res = res.right;
914
- return res.data;
915
- };
916
- TreeBase$2.prototype.iterator = function() {
917
- return new Iterator(this);
918
- };
919
- TreeBase$2.prototype.each = function(cb) {
920
- var it = this.iterator(), data;
921
- while ((data = it.next()) !== null) if (cb(data) === false) return;
922
- };
923
- TreeBase$2.prototype.reach = function(cb) {
924
- var it = this.iterator(), data;
925
- while ((data = it.prev()) !== null) if (cb(data) === false) return;
926
- };
927
- function Iterator(tree) {
928
- this._tree = tree;
929
- this._ancestors = [];
930
- this._cursor = null;
931
- }
932
- Iterator.prototype.data = function() {
933
- return this._cursor !== null ? this._cursor.data : null;
934
- };
935
- Iterator.prototype.next = function() {
936
- if (this._cursor === null) {
937
- var root = this._tree._root;
938
- if (root !== null) this._minNode(root);
939
- } else if (this._cursor.right === null) {
940
- var save;
941
- do {
942
- save = this._cursor;
943
- if (this._ancestors.length) this._cursor = this._ancestors.pop();
944
- else {
945
- this._cursor = null;
946
- break;
947
- }
948
- } while (this._cursor.right === save);
949
- } else {
950
- this._ancestors.push(this._cursor);
951
- this._minNode(this._cursor.right);
952
- }
953
- return this._cursor !== null ? this._cursor.data : null;
954
- };
955
- Iterator.prototype.prev = function() {
956
- if (this._cursor === null) {
957
- var root = this._tree._root;
958
- if (root !== null) this._maxNode(root);
959
- } else if (this._cursor.left === null) {
960
- var save;
961
- do {
962
- save = this._cursor;
963
- if (this._ancestors.length) this._cursor = this._ancestors.pop();
964
- else {
965
- this._cursor = null;
966
- break;
967
- }
968
- } while (this._cursor.left === save);
969
- } else {
970
- this._ancestors.push(this._cursor);
971
- this._maxNode(this._cursor.left);
972
- }
973
- return this._cursor !== null ? this._cursor.data : null;
974
- };
975
- Iterator.prototype._minNode = function(start) {
976
- while (start.left !== null) {
977
- this._ancestors.push(start);
978
- start = start.left;
979
- }
980
- this._cursor = start;
981
- };
982
- Iterator.prototype._maxNode = function(start) {
983
- while (start.right !== null) {
984
- this._ancestors.push(start);
985
- start = start.right;
986
- }
987
- this._cursor = start;
988
- };
989
- module.exports = TreeBase$2;
990
- }) });
991
-
992
- //#endregion
993
- //#region ../../node_modules/bintrees/lib/rbtree.js
994
- var require_rbtree = /* @__PURE__ */ __commonJS({ "../../node_modules/bintrees/lib/rbtree.js": ((exports, module) => {
995
- var TreeBase$1 = require_treebase();
996
- function Node$1(data) {
997
- this.data = data;
998
- this.left = null;
999
- this.right = null;
1000
- this.red = true;
1001
- }
1002
- Node$1.prototype.get_child = function(dir) {
1003
- return dir ? this.right : this.left;
1004
- };
1005
- Node$1.prototype.set_child = function(dir, val) {
1006
- if (dir) this.right = val;
1007
- else this.left = val;
1008
- };
1009
- function RBTree$1(comparator) {
1010
- this._root = null;
1011
- this._comparator = comparator;
1012
- this.size = 0;
1013
- }
1014
- RBTree$1.prototype = new TreeBase$1();
1015
- RBTree$1.prototype.insert = function(data) {
1016
- var ret$1 = false;
1017
- if (this._root === null) {
1018
- this._root = new Node$1(data);
1019
- ret$1 = true;
1020
- this.size++;
1021
- } else {
1022
- var head = new Node$1(void 0);
1023
- var dir = 0;
1024
- var last = 0;
1025
- var gp = null;
1026
- var ggp = head;
1027
- var p = null;
1028
- var node = this._root;
1029
- ggp.right = this._root;
1030
- while (true) {
1031
- if (node === null) {
1032
- node = new Node$1(data);
1033
- p.set_child(dir, node);
1034
- ret$1 = true;
1035
- this.size++;
1036
- } else if (is_red(node.left) && is_red(node.right)) {
1037
- node.red = true;
1038
- node.left.red = false;
1039
- node.right.red = false;
1040
- }
1041
- if (is_red(node) && is_red(p)) {
1042
- var dir2 = ggp.right === gp;
1043
- if (node === p.get_child(last)) ggp.set_child(dir2, single_rotate(gp, !last));
1044
- else ggp.set_child(dir2, double_rotate(gp, !last));
1045
- }
1046
- var cmp = this._comparator(node.data, data);
1047
- if (cmp === 0) break;
1048
- last = dir;
1049
- dir = cmp < 0;
1050
- if (gp !== null) ggp = gp;
1051
- gp = p;
1052
- p = node;
1053
- node = node.get_child(dir);
1054
- }
1055
- this._root = head.right;
1056
- }
1057
- this._root.red = false;
1058
- return ret$1;
1059
- };
1060
- RBTree$1.prototype.remove = function(data) {
1061
- if (this._root === null) return false;
1062
- var head = new Node$1(void 0);
1063
- var node = head;
1064
- node.right = this._root;
1065
- var p = null;
1066
- var gp = null;
1067
- var found = null;
1068
- var dir = 1;
1069
- while (node.get_child(dir) !== null) {
1070
- var last = dir;
1071
- gp = p;
1072
- p = node;
1073
- node = node.get_child(dir);
1074
- var cmp = this._comparator(data, node.data);
1075
- dir = cmp > 0;
1076
- if (cmp === 0) found = node;
1077
- if (!is_red(node) && !is_red(node.get_child(dir))) {
1078
- if (is_red(node.get_child(!dir))) {
1079
- var sr = single_rotate(node, dir);
1080
- p.set_child(last, sr);
1081
- p = sr;
1082
- } else if (!is_red(node.get_child(!dir))) {
1083
- var sibling = p.get_child(!last);
1084
- if (sibling !== null) if (!is_red(sibling.get_child(!last)) && !is_red(sibling.get_child(last))) {
1085
- p.red = false;
1086
- sibling.red = true;
1087
- node.red = true;
1088
- } else {
1089
- var dir2 = gp.right === p;
1090
- if (is_red(sibling.get_child(last))) gp.set_child(dir2, double_rotate(p, last));
1091
- else if (is_red(sibling.get_child(!last))) gp.set_child(dir2, single_rotate(p, last));
1092
- var gpc = gp.get_child(dir2);
1093
- gpc.red = true;
1094
- node.red = true;
1095
- gpc.left.red = false;
1096
- gpc.right.red = false;
1097
- }
1098
- }
1099
- }
1100
- }
1101
- if (found !== null) {
1102
- found.data = node.data;
1103
- p.set_child(p.right === node, node.get_child(node.left === null));
1104
- this.size--;
1105
- }
1106
- this._root = head.right;
1107
- if (this._root !== null) this._root.red = false;
1108
- return found !== null;
1109
- };
1110
- function is_red(node) {
1111
- return node !== null && node.red;
1112
- }
1113
- function single_rotate(root, dir) {
1114
- var save = root.get_child(!dir);
1115
- root.set_child(!dir, save.get_child(dir));
1116
- save.set_child(dir, root);
1117
- root.red = true;
1118
- save.red = false;
1119
- return save;
1120
- }
1121
- function double_rotate(root, dir) {
1122
- root.set_child(!dir, single_rotate(root.get_child(!dir), !dir));
1123
- return single_rotate(root, dir);
1124
- }
1125
- module.exports = RBTree$1;
1126
- }) });
1127
-
1128
- //#endregion
1129
- //#region ../../node_modules/bintrees/lib/bintree.js
1130
- var require_bintree = /* @__PURE__ */ __commonJS({ "../../node_modules/bintrees/lib/bintree.js": ((exports, module) => {
1131
- var TreeBase = require_treebase();
1132
- function Node(data) {
1133
- this.data = data;
1134
- this.left = null;
1135
- this.right = null;
1136
- }
1137
- Node.prototype.get_child = function(dir) {
1138
- return dir ? this.right : this.left;
1139
- };
1140
- Node.prototype.set_child = function(dir, val) {
1141
- if (dir) this.right = val;
1142
- else this.left = val;
1143
- };
1144
- function BinTree(comparator) {
1145
- this._root = null;
1146
- this._comparator = comparator;
1147
- this.size = 0;
1148
- }
1149
- BinTree.prototype = new TreeBase();
1150
- BinTree.prototype.insert = function(data) {
1151
- if (this._root === null) {
1152
- this._root = new Node(data);
1153
- this.size++;
1154
- return true;
1155
- }
1156
- var dir = 0;
1157
- var p = null;
1158
- var node = this._root;
1159
- while (true) {
1160
- if (node === null) {
1161
- node = new Node(data);
1162
- p.set_child(dir, node);
1163
- ret = true;
1164
- this.size++;
1165
- return true;
1166
- }
1167
- if (this._comparator(node.data, data) === 0) return false;
1168
- dir = this._comparator(node.data, data) < 0;
1169
- p = node;
1170
- node = node.get_child(dir);
1171
- }
1172
- };
1173
- BinTree.prototype.remove = function(data) {
1174
- if (this._root === null) return false;
1175
- var head = new Node(void 0);
1176
- var node = head;
1177
- node.right = this._root;
1178
- var p = null;
1179
- var found = null;
1180
- var dir = 1;
1181
- while (node.get_child(dir) !== null) {
1182
- p = node;
1183
- node = node.get_child(dir);
1184
- var cmp = this._comparator(data, node.data);
1185
- dir = cmp > 0;
1186
- if (cmp === 0) found = node;
1187
- }
1188
- if (found !== null) {
1189
- found.data = node.data;
1190
- p.set_child(p.right === node, node.get_child(node.left === null));
1191
- this._root = head.right;
1192
- this.size--;
1193
- return true;
1194
- } else return false;
1195
- };
1196
- module.exports = BinTree;
1197
- }) });
1198
-
1199
- //#endregion
1200
- //#region ../../node_modules/bintrees/index.js
1201
- var require_bintrees = /* @__PURE__ */ __commonJS({ "../../node_modules/bintrees/index.js": ((exports, module) => {
1202
- module.exports = {
1203
- RBTree: require_rbtree(),
1204
- BinTree: require_bintree()
1205
- };
1206
- }) });
1207
-
1208
- //#endregion
1209
- //#region ../../node_modules/tdigest/tdigest.js
1210
- var require_tdigest = /* @__PURE__ */ __commonJS({ "../../node_modules/tdigest/tdigest.js": ((exports, module) => {
1211
- var RBTree = require_bintrees().RBTree;
1212
- function TDigest$1(delta, K, CX) {
1213
- this.discrete = delta === false;
1214
- this.delta = delta || .01;
1215
- this.K = K === void 0 ? 25 : K;
1216
- this.CX = CX === void 0 ? 1.1 : CX;
1217
- this.centroids = new RBTree(compare_centroid_means);
1218
- this.nreset = 0;
1219
- this.reset();
1220
- }
1221
- TDigest$1.prototype.reset = function() {
1222
- this.centroids.clear();
1223
- this.n = 0;
1224
- this.nreset += 1;
1225
- this.last_cumulate = 0;
1226
- };
1227
- TDigest$1.prototype.size = function() {
1228
- return this.centroids.size;
1229
- };
1230
- TDigest$1.prototype.toArray = function(everything) {
1231
- var result = [];
1232
- if (everything) {
1233
- this._cumulate(true);
1234
- this.centroids.each(function(c) {
1235
- result.push(c);
1236
- });
1237
- } else this.centroids.each(function(c) {
1238
- result.push({
1239
- mean: c.mean,
1240
- n: c.n
1241
- });
1242
- });
1243
- return result;
1244
- };
1245
- TDigest$1.prototype.summary = function() {
1246
- return [
1247
- (this.discrete ? "exact " : "approximating ") + this.n + " samples using " + this.size() + " centroids",
1248
- "min = " + this.percentile(0),
1249
- "Q1 = " + this.percentile(.25),
1250
- "Q2 = " + this.percentile(.5),
1251
- "Q3 = " + this.percentile(.75),
1252
- "max = " + this.percentile(1)
1253
- ].join("\n");
1254
- };
1255
- function compare_centroid_means(a, b) {
1256
- return a.mean > b.mean ? 1 : a.mean < b.mean ? -1 : 0;
1257
- }
1258
- function compare_centroid_mean_cumns(a, b) {
1259
- return a.mean_cumn - b.mean_cumn;
1260
- }
1261
- TDigest$1.prototype.push = function(x, n) {
1262
- n = n || 1;
1263
- x = Array.isArray(x) ? x : [x];
1264
- for (var i = 0; i < x.length; i++) this._digest(x[i], n);
1265
- };
1266
- TDigest$1.prototype.push_centroid = function(c) {
1267
- c = Array.isArray(c) ? c : [c];
1268
- for (var i = 0; i < c.length; i++) this._digest(c[i].mean, c[i].n);
1269
- };
1270
- TDigest$1.prototype._cumulate = function(exact) {
1271
- if (this.n === this.last_cumulate || !exact && this.CX && this.CX > this.n / this.last_cumulate) return;
1272
- var cumn = 0;
1273
- this.centroids.each(function(c) {
1274
- c.mean_cumn = cumn + c.n / 2;
1275
- cumn = c.cumn = cumn + c.n;
1276
- });
1277
- this.n = this.last_cumulate = cumn;
1278
- };
1279
- TDigest$1.prototype.find_nearest = function(x) {
1280
- if (this.size() === 0) return null;
1281
- var iter = this.centroids.lowerBound({ mean: x });
1282
- var c = iter.data() === null ? iter.prev() : iter.data();
1283
- if (c.mean === x || this.discrete) return c;
1284
- var prev = iter.prev();
1285
- if (prev && Math.abs(prev.mean - x) < Math.abs(c.mean - x)) return prev;
1286
- else return c;
1287
- };
1288
- TDigest$1.prototype._new_centroid = function(x, n, cumn) {
1289
- var c = {
1290
- mean: x,
1291
- n,
1292
- cumn
1293
- };
1294
- this.centroids.insert(c);
1295
- this.n += n;
1296
- return c;
1297
- };
1298
- TDigest$1.prototype._addweight = function(nearest, x, n) {
1299
- if (x !== nearest.mean) nearest.mean += n * (x - nearest.mean) / (nearest.n + n);
1300
- nearest.cumn += n;
1301
- nearest.mean_cumn += n / 2;
1302
- nearest.n += n;
1303
- this.n += n;
1304
- };
1305
- TDigest$1.prototype._digest = function(x, n) {
1306
- var min = this.centroids.min();
1307
- var max = this.centroids.max();
1308
- var nearest = this.find_nearest(x);
1309
- if (nearest && nearest.mean === x) this._addweight(nearest, x, n);
1310
- else if (nearest === min) this._new_centroid(x, n, 0);
1311
- else if (nearest === max) this._new_centroid(x, n, this.n);
1312
- else if (this.discrete) this._new_centroid(x, n, nearest.cumn);
1313
- else {
1314
- var p = nearest.mean_cumn / this.n;
1315
- if (Math.floor(4 * this.n * this.delta * p * (1 - p)) - nearest.n >= n) this._addweight(nearest, x, n);
1316
- else this._new_centroid(x, n, nearest.cumn);
1317
- }
1318
- this._cumulate(false);
1319
- if (!this.discrete && this.K && this.size() > this.K / this.delta) this.compress();
1320
- };
1321
- TDigest$1.prototype.bound_mean = function(x) {
1322
- var iter = this.centroids.upperBound({ mean: x });
1323
- var lower = iter.prev();
1324
- return [lower, lower.mean === x ? lower : iter.next()];
1325
- };
1326
- TDigest$1.prototype.p_rank = function(x_or_xlist) {
1327
- var ps = (Array.isArray(x_or_xlist) ? x_or_xlist : [x_or_xlist]).map(this._p_rank, this);
1328
- return Array.isArray(x_or_xlist) ? ps : ps[0];
1329
- };
1330
- TDigest$1.prototype._p_rank = function(x) {
1331
- if (this.size() === 0) return;
1332
- else if (x < this.centroids.min().mean) return 0;
1333
- else if (x > this.centroids.max().mean) return 1;
1334
- this._cumulate(true);
1335
- var bound = this.bound_mean(x);
1336
- var lower = bound[0], upper = bound[1];
1337
- if (this.discrete) return lower.cumn / this.n;
1338
- else {
1339
- var cumn = lower.mean_cumn;
1340
- if (lower !== upper) cumn += (x - lower.mean) * (upper.mean_cumn - lower.mean_cumn) / (upper.mean - lower.mean);
1341
- return cumn / this.n;
1342
- }
1343
- };
1344
- TDigest$1.prototype.bound_mean_cumn = function(cumn) {
1345
- this.centroids._comparator = compare_centroid_mean_cumns;
1346
- var iter = this.centroids.upperBound({ mean_cumn: cumn });
1347
- this.centroids._comparator = compare_centroid_means;
1348
- var lower = iter.prev();
1349
- return [lower, lower && lower.mean_cumn === cumn ? lower : iter.next()];
1350
- };
1351
- TDigest$1.prototype.percentile = function(p_or_plist) {
1352
- var qs = (Array.isArray(p_or_plist) ? p_or_plist : [p_or_plist]).map(this._percentile, this);
1353
- return Array.isArray(p_or_plist) ? qs : qs[0];
1354
- };
1355
- TDigest$1.prototype._percentile = function(p) {
1356
- if (this.size() === 0) return;
1357
- this._cumulate(true);
1358
- var h = this.n * p;
1359
- var bound = this.bound_mean_cumn(h);
1360
- var lower = bound[0], upper = bound[1];
1361
- if (upper === lower || lower === null || upper === null) return (lower || upper).mean;
1362
- else if (!this.discrete) return lower.mean + (h - lower.mean_cumn) * (upper.mean - lower.mean) / (upper.mean_cumn - lower.mean_cumn);
1363
- else if (h <= lower.cumn) return lower.mean;
1364
- else return upper.mean;
1365
- };
1366
- function pop_random(choices) {
1367
- var idx = Math.floor(Math.random() * choices.length);
1368
- return choices.splice(idx, 1)[0];
1369
- }
1370
- TDigest$1.prototype.compress = function() {
1371
- if (this.compressing) return;
1372
- var points = this.toArray();
1373
- this.reset();
1374
- this.compressing = true;
1375
- while (points.length > 0) this.push_centroid(pop_random(points));
1376
- this._cumulate(true);
1377
- this.compressing = false;
1378
- };
1379
- function Digest(config) {
1380
- this.config = config || {};
1381
- this.mode = this.config.mode || "auto";
1382
- TDigest$1.call(this, this.mode === "cont" ? config.delta : false);
1383
- this.digest_ratio = this.config.ratio || .9;
1384
- this.digest_thresh = this.config.thresh || 1e3;
1385
- this.n_unique = 0;
1386
- }
1387
- Digest.prototype = Object.create(TDigest$1.prototype);
1388
- Digest.prototype.constructor = Digest;
1389
- Digest.prototype.push = function(x_or_xlist) {
1390
- TDigest$1.prototype.push.call(this, x_or_xlist);
1391
- this.check_continuous();
1392
- };
1393
- Digest.prototype._new_centroid = function(x, n, cumn) {
1394
- this.n_unique += 1;
1395
- TDigest$1.prototype._new_centroid.call(this, x, n, cumn);
1396
- };
1397
- Digest.prototype._addweight = function(nearest, x, n) {
1398
- if (nearest.n === 1) this.n_unique -= 1;
1399
- TDigest$1.prototype._addweight.call(this, nearest, x, n);
1400
- };
1401
- Digest.prototype.check_continuous = function() {
1402
- if (this.mode !== "auto" || this.size() < this.digest_thresh) return false;
1403
- if (this.n_unique / this.size() > this.digest_ratio) {
1404
- this.mode = "cont";
1405
- this.discrete = false;
1406
- this.delta = this.config.delta || .01;
1407
- this.compress();
1408
- return true;
1409
- }
1410
- return false;
1411
- };
1412
- module.exports = {
1413
- "TDigest": TDigest$1,
1414
- "Digest": Digest
1415
- };
1416
- }) });
1417
-
1418
- //#endregion
1419
- //#region ../../node_modules/prom-client/lib/timeWindowQuantiles.js
1420
- var require_timeWindowQuantiles = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/timeWindowQuantiles.js": ((exports, module) => {
1421
- const { TDigest } = require_tdigest();
1422
- var TimeWindowQuantiles = class {
1423
- constructor(maxAgeSeconds, ageBuckets) {
1424
- this.maxAgeSeconds = maxAgeSeconds || 0;
1425
- this.ageBuckets = ageBuckets || 0;
1426
- this.shouldRotate = maxAgeSeconds && ageBuckets;
1427
- this.ringBuffer = Array(ageBuckets).fill(new TDigest());
1428
- this.currentBuffer = 0;
1429
- this.lastRotateTimestampMillis = Date.now();
1430
- this.durationBetweenRotatesMillis = maxAgeSeconds * 1e3 / ageBuckets || Infinity;
1431
- }
1432
- size() {
1433
- return rotate.call(this).size();
1434
- }
1435
- percentile(quantile) {
1436
- return rotate.call(this).percentile(quantile);
1437
- }
1438
- push(value) {
1439
- rotate.call(this);
1440
- this.ringBuffer.forEach((bucket) => {
1441
- bucket.push(value);
1442
- });
1443
- }
1444
- reset() {
1445
- this.ringBuffer.forEach((bucket) => {
1446
- bucket.reset();
1447
- });
1448
- }
1449
- compress() {
1450
- this.ringBuffer.forEach((bucket) => {
1451
- bucket.compress();
1452
- });
1453
- }
1454
- };
1455
- function rotate() {
1456
- let timeSinceLastRotateMillis = Date.now() - this.lastRotateTimestampMillis;
1457
- while (timeSinceLastRotateMillis > this.durationBetweenRotatesMillis && this.shouldRotate) {
1458
- this.ringBuffer[this.currentBuffer] = new TDigest();
1459
- if (++this.currentBuffer >= this.ringBuffer.length) this.currentBuffer = 0;
1460
- timeSinceLastRotateMillis -= this.durationBetweenRotatesMillis;
1461
- this.lastRotateTimestampMillis += this.durationBetweenRotatesMillis;
1462
- }
1463
- return this.ringBuffer[this.currentBuffer];
1464
- }
1465
- module.exports = TimeWindowQuantiles;
1466
- }) });
1467
-
1468
- //#endregion
1469
- //#region ../../node_modules/prom-client/lib/summary.js
1470
- /**
1471
- * Summary
1472
- */
1473
- var require_summary = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/summary.js": ((exports, module) => {
1474
- const util = require("util");
1475
- const { getLabels, hashObject: hashObject$1, removeLabels } = require_util();
1476
- const { validateLabel } = require_validation();
1477
- const { Metric } = require_metric();
1478
- const timeWindowQuantiles = require_timeWindowQuantiles();
1479
- const DEFAULT_COMPRESS_COUNT = 1e3;
1480
- var Summary = class extends Metric {
1481
- constructor(config) {
1482
- super(config, {
1483
- percentiles: [
1484
- .01,
1485
- .05,
1486
- .5,
1487
- .9,
1488
- .95,
1489
- .99,
1490
- .999
1491
- ],
1492
- compressCount: DEFAULT_COMPRESS_COUNT,
1493
- hashMap: {}
1494
- });
1495
- this.type = "summary";
1496
- for (const label of this.labelNames) if (label === "quantile") throw new Error("quantile is a reserved label keyword");
1497
- if (this.labelNames.length === 0) this.hashMap = { [hashObject$1({})]: {
1498
- labels: {},
1499
- td: new timeWindowQuantiles(this.maxAgeSeconds, this.ageBuckets),
1500
- count: 0,
1501
- sum: 0
1502
- } };
1503
- }
1504
- /**
1505
- * Observe a value
1506
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
1507
- * @param {Number} value - Value to observe
1508
- * @returns {void}
1509
- */
1510
- observe(labels, value) {
1511
- observe.call(this, labels === 0 ? 0 : labels || {})(value);
1512
- }
1513
- async get() {
1514
- if (this.collect) {
1515
- const v = this.collect();
1516
- if (v instanceof Promise) await v;
1517
- }
1518
- const hashKeys = Object.keys(this.hashMap);
1519
- const values$1 = [];
1520
- hashKeys.forEach((hashKey) => {
1521
- const s = this.hashMap[hashKey];
1522
- if (s) if (this.pruneAgedBuckets && s.td.size() === 0) delete this.hashMap[hashKey];
1523
- else {
1524
- extractSummariesForExport(s, this.percentiles).forEach((v) => {
1525
- values$1.push(v);
1526
- });
1527
- values$1.push(getSumForExport(s, this));
1528
- values$1.push(getCountForExport(s, this));
1529
- }
1530
- });
1531
- return {
1532
- name: this.name,
1533
- help: this.help,
1534
- type: this.type,
1535
- values: values$1,
1536
- aggregator: this.aggregator
1537
- };
1538
- }
1539
- reset() {
1540
- Object.values(this.hashMap).forEach((s) => {
1541
- s.td.reset();
1542
- s.count = 0;
1543
- s.sum = 0;
1544
- });
1545
- }
1546
- /**
1547
- * Start a timer that could be used to logging durations
1548
- * @param {object} labels - Object with labels where key is the label key and value is label value. Can only be one level deep
1549
- * @returns {function} - Function to invoke when you want to stop the timer and observe the duration in seconds
1550
- * @example
1551
- * var end = summary.startTimer();
1552
- * makeExpensiveXHRRequest(function(err, res) {
1553
- * end(); //Observe the duration of expensiveXHRRequest
1554
- * });
1555
- */
1556
- startTimer(labels) {
1557
- return startTimer.call(this, labels)();
1558
- }
1559
- labels(...args) {
1560
- const labels = getLabels(this.labelNames, args);
1561
- validateLabel(this.labelNames, labels);
1562
- return {
1563
- observe: observe.call(this, labels),
1564
- startTimer: startTimer.call(this, labels)
1565
- };
1566
- }
1567
- remove(...args) {
1568
- const labels = getLabels(this.labelNames, args);
1569
- validateLabel(this.labelNames, labels);
1570
- removeLabels.call(this, this.hashMap, labels, this.sortedLabelNames);
1571
- }
1572
- };
1573
- function extractSummariesForExport(summaryOfLabels, percentiles) {
1574
- summaryOfLabels.td.compress();
1575
- return percentiles.map((percentile) => {
1576
- const percentileValue = summaryOfLabels.td.percentile(percentile);
1577
- return {
1578
- labels: Object.assign({ quantile: percentile }, summaryOfLabels.labels),
1579
- value: percentileValue ? percentileValue : 0
1580
- };
1581
- });
1582
- }
1583
- function getCountForExport(value, summary) {
1584
- return {
1585
- metricName: `${summary.name}_count`,
1586
- labels: value.labels,
1587
- value: value.count
1588
- };
1589
- }
1590
- function getSumForExport(value, summary) {
1591
- return {
1592
- metricName: `${summary.name}_sum`,
1593
- labels: value.labels,
1594
- value: value.sum
1595
- };
1596
- }
1597
- function startTimer(startLabels) {
1598
- return () => {
1599
- const start = process.hrtime();
1600
- return (endLabels) => {
1601
- const delta = process.hrtime(start);
1602
- const value = delta[0] + delta[1] / 1e9;
1603
- this.observe(Object.assign({}, startLabels, endLabels), value);
1604
- return value;
1605
- };
1606
- };
1607
- }
1608
- function observe(labels) {
1609
- return (value) => {
1610
- const labelValuePair = convertLabelsAndValues(labels, value);
1611
- validateLabel(this.labelNames, labels);
1612
- if (!Number.isFinite(labelValuePair.value)) throw new TypeError(`Value is not a valid number: ${util.format(labelValuePair.value)}`);
1613
- const hash = hashObject$1(labelValuePair.labels, this.sortedLabelNames);
1614
- let summaryOfLabel = this.hashMap[hash];
1615
- if (!summaryOfLabel) summaryOfLabel = {
1616
- labels: labelValuePair.labels,
1617
- td: new timeWindowQuantiles(this.maxAgeSeconds, this.ageBuckets),
1618
- count: 0,
1619
- sum: 0
1620
- };
1621
- summaryOfLabel.td.push(labelValuePair.value);
1622
- summaryOfLabel.count++;
1623
- if (summaryOfLabel.count % this.compressCount === 0) summaryOfLabel.td.compress();
1624
- summaryOfLabel.sum += labelValuePair.value;
1625
- this.hashMap[hash] = summaryOfLabel;
1626
- };
1627
- }
1628
- function convertLabelsAndValues(labels, value) {
1629
- if (value === void 0) return {
1630
- value: labels,
1631
- labels: {}
1632
- };
1633
- return {
1634
- labels,
1635
- value
1636
- };
1637
- }
1638
- module.exports = Summary;
1639
- }) });
1640
-
1641
- //#endregion
1642
- //#region ../../node_modules/prom-client/lib/pushgateway.js
1643
- var require_pushgateway = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/pushgateway.js": ((exports, module) => {
1644
- const url = require("url");
1645
- const http = require("http");
1646
- const https = require("https");
1647
- const { gzipSync } = require("zlib");
1648
- const { globalRegistry } = require_registry();
1649
- var Pushgateway = class {
1650
- constructor(gatewayUrl, options, registry) {
1651
- if (!registry) registry = globalRegistry;
1652
- this.registry = registry;
1653
- this.gatewayUrl = gatewayUrl;
1654
- const { requireJobName, ...requestOptions } = {
1655
- requireJobName: true,
1656
- ...options
1657
- };
1658
- this.requireJobName = requireJobName;
1659
- this.requestOptions = requestOptions;
1660
- }
1661
- pushAdd(params = {}) {
1662
- if (this.requireJobName && !params.jobName) throw new Error("Missing jobName parameter");
1663
- return useGateway.call(this, "POST", params.jobName, params.groupings);
1664
- }
1665
- push(params = {}) {
1666
- if (this.requireJobName && !params.jobName) throw new Error("Missing jobName parameter");
1667
- return useGateway.call(this, "PUT", params.jobName, params.groupings);
1668
- }
1669
- delete(params = {}) {
1670
- if (this.requireJobName && !params.jobName) throw new Error("Missing jobName parameter");
1671
- return useGateway.call(this, "DELETE", params.jobName, params.groupings);
1672
- }
1673
- };
1674
- async function useGateway(method, job, groupings) {
1675
- const gatewayUrlParsed = url.parse(this.gatewayUrl);
1676
- const path = `${gatewayUrlParsed.pathname && gatewayUrlParsed.pathname !== "/" ? gatewayUrlParsed.pathname : ""}/metrics${job ? `/job/${encodeURIComponent(job)}${generateGroupings(groupings)}` : ""}`;
1677
- const target = url.resolve(this.gatewayUrl, path);
1678
- const requestParams = url.parse(target);
1679
- const httpModule = isHttps(requestParams.href) ? https : http;
1680
- const options = Object.assign(requestParams, this.requestOptions, { method });
1681
- return new Promise((resolve, reject) => {
1682
- if (method === "DELETE" && options.headers) delete options.headers["Content-Encoding"];
1683
- const req = httpModule.request(options, (resp) => {
1684
- let body = "";
1685
- resp.setEncoding("utf8");
1686
- resp.on("data", (chunk) => {
1687
- body += chunk;
1688
- });
1689
- resp.on("end", () => {
1690
- if (resp.statusCode >= 400) reject(/* @__PURE__ */ new Error(`push failed with status ${resp.statusCode}, ${body}`));
1691
- else resolve({
1692
- resp,
1693
- body
1694
- });
1695
- });
1696
- });
1697
- req.on("error", (err) => {
1698
- reject(err);
1699
- });
1700
- req.on("timeout", () => {
1701
- req.destroy(/* @__PURE__ */ new Error("Pushgateway request timed out"));
1702
- });
1703
- if (method !== "DELETE") this.registry.metrics().then((metrics$2) => {
1704
- if (options.headers && options.headers["Content-Encoding"] === "gzip") metrics$2 = gzipSync(metrics$2);
1705
- req.write(metrics$2);
1706
- req.end();
1707
- }).catch((err) => {
1708
- reject(err);
1709
- });
1710
- else req.end();
1711
- });
1712
- }
1713
- function generateGroupings(groupings) {
1714
- if (!groupings) return "";
1715
- return Object.keys(groupings).map((key) => `/${encodeURIComponent(key)}/${encodeURIComponent(groupings[key])}`).join("");
1716
- }
1717
- function isHttps(href) {
1718
- return href.search(/^https/) !== -1;
1719
- }
1720
- module.exports = Pushgateway;
1721
- }) });
1722
-
1723
- //#endregion
1724
- //#region ../../node_modules/prom-client/lib/bucketGenerators.js
1725
- var require_bucketGenerators = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/bucketGenerators.js": ((exports) => {
1726
- exports.linearBuckets = (start, width, count) => {
1727
- if (count < 1) throw new Error("Linear buckets needs a positive count");
1728
- const buckets = new Array(count);
1729
- for (let i = 0; i < count; i++) buckets[i] = start + i * width;
1730
- return buckets;
1731
- };
1732
- exports.exponentialBuckets = (start, factor, count) => {
1733
- if (start <= 0) throw new Error("Exponential buckets needs a positive start");
1734
- if (count < 1) throw new Error("Exponential buckets needs a positive count");
1735
- if (factor <= 1) throw new Error("Exponential buckets needs a factor greater than 1");
1736
- const buckets = new Array(count);
1737
- for (let i = 0; i < count; i++) {
1738
- buckets[i] = start;
1739
- start *= factor;
1740
- }
1741
- return buckets;
1742
- };
1743
- }) });
1744
-
1745
- //#endregion
1746
- //#region ../../node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
1747
- var _globalThis;
1748
- var init_globalThis = __esm({ "../../node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js": (() => {
1749
- _globalThis = typeof globalThis === "object" ? globalThis : global;
1750
- }) });
1751
-
1752
- //#endregion
1753
- //#region ../../node_modules/@opentelemetry/api/build/esm/platform/node/index.js
1754
- var init_node = __esm({ "../../node_modules/@opentelemetry/api/build/esm/platform/node/index.js": (() => {
1755
- init_globalThis();
1756
- }) });
1757
-
1758
- //#endregion
1759
- //#region ../../node_modules/@opentelemetry/api/build/esm/platform/index.js
1760
- var init_platform = __esm({ "../../node_modules/@opentelemetry/api/build/esm/platform/index.js": (() => {
1761
- init_node();
1762
- }) });
1763
-
1764
- //#endregion
1765
- //#region ../../node_modules/@opentelemetry/api/build/esm/version.js
1766
- var VERSION;
1767
- var init_version = __esm({ "../../node_modules/@opentelemetry/api/build/esm/version.js": (() => {
1768
- VERSION = "1.9.0";
1769
- }) });
1770
-
1771
- //#endregion
1772
- //#region ../../node_modules/@opentelemetry/api/build/esm/internal/semver.js
1773
- /**
1774
- * Create a function to test an API version to see if it is compatible with the provided ownVersion.
1775
- *
1776
- * The returned function has the following semantics:
1777
- * - Exact match is always compatible
1778
- * - Major versions must match exactly
1779
- * - 1.x package cannot use global 2.x package
1780
- * - 2.x package cannot use global 1.x package
1781
- * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API
1782
- * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects
1783
- * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3
1784
- * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor
1785
- * - Patch and build tag differences are not considered at this time
1786
- *
1787
- * @param ownVersion version which should be checked against
1788
- */
1789
- function _makeCompatibilityCheck(ownVersion) {
1790
- var acceptedVersions = new Set([ownVersion]);
1791
- var rejectedVersions = /* @__PURE__ */ new Set();
1792
- var myVersionMatch = ownVersion.match(re);
1793
- if (!myVersionMatch) return function() {
1794
- return false;
1795
- };
1796
- var ownVersionParsed = {
1797
- major: +myVersionMatch[1],
1798
- minor: +myVersionMatch[2],
1799
- patch: +myVersionMatch[3],
1800
- prerelease: myVersionMatch[4]
1801
- };
1802
- if (ownVersionParsed.prerelease != null) return function isExactmatch(globalVersion) {
1803
- return globalVersion === ownVersion;
1804
- };
1805
- function _reject(v) {
1806
- rejectedVersions.add(v);
1807
- return false;
1808
- }
1809
- function _accept(v) {
1810
- acceptedVersions.add(v);
1811
- return true;
1812
- }
1813
- return function isCompatible$1(globalVersion) {
1814
- if (acceptedVersions.has(globalVersion)) return true;
1815
- if (rejectedVersions.has(globalVersion)) return false;
1816
- var globalVersionMatch = globalVersion.match(re);
1817
- if (!globalVersionMatch) return _reject(globalVersion);
1818
- var globalVersionParsed = {
1819
- major: +globalVersionMatch[1],
1820
- minor: +globalVersionMatch[2],
1821
- patch: +globalVersionMatch[3],
1822
- prerelease: globalVersionMatch[4]
1823
- };
1824
- if (globalVersionParsed.prerelease != null) return _reject(globalVersion);
1825
- if (ownVersionParsed.major !== globalVersionParsed.major) return _reject(globalVersion);
1826
- if (ownVersionParsed.major === 0) {
1827
- if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) return _accept(globalVersion);
1828
- return _reject(globalVersion);
1829
- }
1830
- if (ownVersionParsed.minor <= globalVersionParsed.minor) return _accept(globalVersion);
1831
- return _reject(globalVersion);
1832
- };
1833
- }
1834
- var re, isCompatible;
1835
- var init_semver = __esm({ "../../node_modules/@opentelemetry/api/build/esm/internal/semver.js": (() => {
1836
- init_version();
1837
- re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
1838
- isCompatible = _makeCompatibilityCheck(VERSION);
1839
- }) });
1840
-
1841
- //#endregion
1842
- //#region ../../node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
1843
- function registerGlobal(type, instance, diag$2, allowOverride) {
1844
- var _a;
1845
- if (allowOverride === void 0) allowOverride = false;
1846
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : { version: VERSION };
1847
- if (!allowOverride && api[type]) {
1848
- var err = /* @__PURE__ */ new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
1849
- diag$2.error(err.stack || err.message);
1850
- return false;
1851
- }
1852
- if (api.version !== VERSION) {
1853
- var err = /* @__PURE__ */ new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
1854
- diag$2.error(err.stack || err.message);
1855
- return false;
1856
- }
1857
- api[type] = instance;
1858
- diag$2.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
1859
- return true;
1860
- }
1861
- function getGlobal(type) {
1862
- var _a, _b;
1863
- var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
1864
- if (!globalVersion || !isCompatible(globalVersion)) return;
1865
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
1866
- }
1867
- function unregisterGlobal(type, diag$2) {
1868
- diag$2.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
1869
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
1870
- if (api) delete api[type];
1871
- }
1872
- var major, GLOBAL_OPENTELEMETRY_API_KEY, _global;
1873
- var init_global_utils = __esm({ "../../node_modules/@opentelemetry/api/build/esm/internal/global-utils.js": (() => {
1874
- init_platform();
1875
- init_version();
1876
- init_semver();
1877
- major = VERSION.split(".")[0];
1878
- GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
1879
- _global = _globalThis;
1880
- }) });
1881
-
1882
- //#endregion
1883
- //#region ../../node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
1884
- function logProxy(funcName, namespace, args) {
1885
- var logger = getGlobal("diag");
1886
- if (!logger) return;
1887
- args.unshift(namespace);
1888
- return logger[funcName].apply(logger, __spreadArray$3([], __read$4(args), false));
1889
- }
1890
- var __read$4, __spreadArray$3, DiagComponentLogger;
1891
- var init_ComponentLogger = __esm({ "../../node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js": (() => {
1892
- init_global_utils();
1893
- __read$4 = void 0 && (void 0).__read || function(o, n) {
1894
- var m = typeof Symbol === "function" && o[Symbol.iterator];
1895
- if (!m) return o;
1896
- var i = m.call(o), r, ar = [], e;
1897
- try {
1898
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1899
- } catch (error) {
1900
- e = { error };
1901
- } finally {
1902
- try {
1903
- if (r && !r.done && (m = i["return"])) m.call(i);
1904
- } finally {
1905
- if (e) throw e.error;
1906
- }
1907
- }
1908
- return ar;
1909
- };
1910
- __spreadArray$3 = void 0 && (void 0).__spreadArray || function(to, from, pack) {
1911
- if (pack || arguments.length === 2) {
1912
- for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
1913
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1914
- ar[i] = from[i];
1915
- }
1916
- }
1917
- return to.concat(ar || Array.prototype.slice.call(from));
1918
- };
1919
- DiagComponentLogger = function() {
1920
- function DiagComponentLogger$1(props) {
1921
- this._namespace = props.namespace || "DiagComponentLogger";
1922
- }
1923
- DiagComponentLogger$1.prototype.debug = function() {
1924
- var args = [];
1925
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
1926
- return logProxy("debug", this._namespace, args);
1927
- };
1928
- DiagComponentLogger$1.prototype.error = function() {
1929
- var args = [];
1930
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
1931
- return logProxy("error", this._namespace, args);
1932
- };
1933
- DiagComponentLogger$1.prototype.info = function() {
1934
- var args = [];
1935
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
1936
- return logProxy("info", this._namespace, args);
1937
- };
1938
- DiagComponentLogger$1.prototype.warn = function() {
1939
- var args = [];
1940
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
1941
- return logProxy("warn", this._namespace, args);
1942
- };
1943
- DiagComponentLogger$1.prototype.verbose = function() {
1944
- var args = [];
1945
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
1946
- return logProxy("verbose", this._namespace, args);
1947
- };
1948
- return DiagComponentLogger$1;
1949
- }();
1950
- }) });
1951
-
1952
- //#endregion
1953
- //#region ../../node_modules/@opentelemetry/api/build/esm/diag/types.js
1954
- var DiagLogLevel;
1955
- var init_types = __esm({ "../../node_modules/@opentelemetry/api/build/esm/diag/types.js": (() => {
1956
- ;
1957
- (function(DiagLogLevel$1) {
1958
- /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
1959
- DiagLogLevel$1[DiagLogLevel$1["NONE"] = 0] = "NONE";
1960
- /** Identifies an error scenario */
1961
- DiagLogLevel$1[DiagLogLevel$1["ERROR"] = 30] = "ERROR";
1962
- /** Identifies a warning scenario */
1963
- DiagLogLevel$1[DiagLogLevel$1["WARN"] = 50] = "WARN";
1964
- /** General informational log message */
1965
- DiagLogLevel$1[DiagLogLevel$1["INFO"] = 60] = "INFO";
1966
- /** General debug log message */
1967
- DiagLogLevel$1[DiagLogLevel$1["DEBUG"] = 70] = "DEBUG";
1968
- /**
1969
- * Detailed trace level logging should only be used for development, should only be set
1970
- * in a development environment.
1971
- */
1972
- DiagLogLevel$1[DiagLogLevel$1["VERBOSE"] = 80] = "VERBOSE";
1973
- /** Used to set the logging level to include all logging */
1974
- DiagLogLevel$1[DiagLogLevel$1["ALL"] = 9999] = "ALL";
1975
- })(DiagLogLevel || (DiagLogLevel = {}));
1976
- }) });
1977
-
1978
- //#endregion
1979
- //#region ../../node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
1980
- function createLogLevelDiagLogger(maxLevel, logger) {
1981
- if (maxLevel < DiagLogLevel.NONE) maxLevel = DiagLogLevel.NONE;
1982
- else if (maxLevel > DiagLogLevel.ALL) maxLevel = DiagLogLevel.ALL;
1983
- logger = logger || {};
1984
- function _filterFunc(funcName, theLevel) {
1985
- var theFunc = logger[funcName];
1986
- if (typeof theFunc === "function" && maxLevel >= theLevel) return theFunc.bind(logger);
1987
- return function() {};
1988
- }
1989
- return {
1990
- error: _filterFunc("error", DiagLogLevel.ERROR),
1991
- warn: _filterFunc("warn", DiagLogLevel.WARN),
1992
- info: _filterFunc("info", DiagLogLevel.INFO),
1993
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
1994
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
1995
- };
1996
- }
1997
- var init_logLevelLogger = __esm({ "../../node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js": (() => {
1998
- init_types();
1999
- }) });
2000
-
2001
- //#endregion
2002
- //#region ../../node_modules/@opentelemetry/api/build/esm/api/diag.js
2003
- var __read$3, __spreadArray$2, API_NAME$4, DiagAPI;
2004
- var init_diag = __esm({ "../../node_modules/@opentelemetry/api/build/esm/api/diag.js": (() => {
2005
- init_ComponentLogger();
2006
- init_logLevelLogger();
2007
- init_types();
2008
- init_global_utils();
2009
- __read$3 = void 0 && (void 0).__read || function(o, n) {
2010
- var m = typeof Symbol === "function" && o[Symbol.iterator];
2011
- if (!m) return o;
2012
- var i = m.call(o), r, ar = [], e;
2013
- try {
2014
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2015
- } catch (error) {
2016
- e = { error };
2017
- } finally {
2018
- try {
2019
- if (r && !r.done && (m = i["return"])) m.call(i);
2020
- } finally {
2021
- if (e) throw e.error;
2022
- }
2023
- }
2024
- return ar;
2025
- };
2026
- __spreadArray$2 = void 0 && (void 0).__spreadArray || function(to, from, pack) {
2027
- if (pack || arguments.length === 2) {
2028
- for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
2029
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
2030
- ar[i] = from[i];
2031
- }
2032
- }
2033
- return to.concat(ar || Array.prototype.slice.call(from));
2034
- };
2035
- API_NAME$4 = "diag";
2036
- DiagAPI = function() {
2037
- /**
2038
- * Private internal constructor
2039
- * @private
2040
- */
2041
- function DiagAPI$1() {
2042
- function _logProxy(funcName) {
2043
- return function() {
2044
- var args = [];
2045
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
2046
- var logger = getGlobal("diag");
2047
- if (!logger) return;
2048
- return logger[funcName].apply(logger, __spreadArray$2([], __read$3(args), false));
2049
- };
2050
- }
2051
- var self = this;
2052
- var setLogger = function(logger, optionsOrLogLevel) {
2053
- var _a, _b, _c;
2054
- if (optionsOrLogLevel === void 0) optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
2055
- if (logger === self) {
2056
- var err = /* @__PURE__ */ new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
2057
- self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
2058
- return false;
2059
- }
2060
- if (typeof optionsOrLogLevel === "number") optionsOrLogLevel = { logLevel: optionsOrLogLevel };
2061
- var oldLogger = getGlobal("diag");
2062
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
2063
- if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
2064
- var stack = (_c = (/* @__PURE__ */ new Error()).stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
2065
- oldLogger.warn("Current logger will be overwritten from " + stack);
2066
- newLogger.warn("Current logger will overwrite one already registered from " + stack);
2067
- }
2068
- return registerGlobal("diag", newLogger, self, true);
2069
- };
2070
- self.setLogger = setLogger;
2071
- self.disable = function() {
2072
- unregisterGlobal(API_NAME$4, self);
2073
- };
2074
- self.createComponentLogger = function(options) {
2075
- return new DiagComponentLogger(options);
2076
- };
2077
- self.verbose = _logProxy("verbose");
2078
- self.debug = _logProxy("debug");
2079
- self.info = _logProxy("info");
2080
- self.warn = _logProxy("warn");
2081
- self.error = _logProxy("error");
2082
- }
2083
- /** Get the singleton instance of the DiagAPI API */
2084
- DiagAPI$1.instance = function() {
2085
- if (!this._instance) this._instance = new DiagAPI$1();
2086
- return this._instance;
2087
- };
2088
- return DiagAPI$1;
2089
- }();
2090
- }) });
2091
-
2092
- //#endregion
2093
- //#region ../../node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js
2094
- var __read$2, __values, BaggageImpl;
2095
- var init_baggage_impl = __esm({ "../../node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js": (() => {
2096
- __read$2 = void 0 && (void 0).__read || function(o, n) {
2097
- var m = typeof Symbol === "function" && o[Symbol.iterator];
2098
- if (!m) return o;
2099
- var i = m.call(o), r, ar = [], e;
2100
- try {
2101
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2102
- } catch (error) {
2103
- e = { error };
2104
- } finally {
2105
- try {
2106
- if (r && !r.done && (m = i["return"])) m.call(i);
2107
- } finally {
2108
- if (e) throw e.error;
2109
- }
2110
- }
2111
- return ar;
2112
- };
2113
- __values = void 0 && (void 0).__values || function(o) {
2114
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2115
- if (m) return m.call(o);
2116
- if (o && typeof o.length === "number") return { next: function() {
2117
- if (o && i >= o.length) o = void 0;
2118
- return {
2119
- value: o && o[i++],
2120
- done: !o
2121
- };
2122
- } };
2123
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2124
- };
2125
- BaggageImpl = function() {
2126
- function BaggageImpl$1(entries) {
2127
- this._entries = entries ? new Map(entries) : /* @__PURE__ */ new Map();
2128
- }
2129
- BaggageImpl$1.prototype.getEntry = function(key) {
2130
- var entry = this._entries.get(key);
2131
- if (!entry) return;
2132
- return Object.assign({}, entry);
2133
- };
2134
- BaggageImpl$1.prototype.getAllEntries = function() {
2135
- return Array.from(this._entries.entries()).map(function(_a) {
2136
- var _b = __read$2(_a, 2);
2137
- return [_b[0], _b[1]];
2138
- });
2139
- };
2140
- BaggageImpl$1.prototype.setEntry = function(key, entry) {
2141
- var newBaggage = new BaggageImpl$1(this._entries);
2142
- newBaggage._entries.set(key, entry);
2143
- return newBaggage;
2144
- };
2145
- BaggageImpl$1.prototype.removeEntry = function(key) {
2146
- var newBaggage = new BaggageImpl$1(this._entries);
2147
- newBaggage._entries.delete(key);
2148
- return newBaggage;
2149
- };
2150
- BaggageImpl$1.prototype.removeEntries = function() {
2151
- var e_1, _a;
2152
- var keys = [];
2153
- for (var _i = 0; _i < arguments.length; _i++) keys[_i] = arguments[_i];
2154
- var newBaggage = new BaggageImpl$1(this._entries);
2155
- try {
2156
- for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
2157
- var key = keys_1_1.value;
2158
- newBaggage._entries.delete(key);
2159
- }
2160
- } catch (e_1_1) {
2161
- e_1 = { error: e_1_1 };
2162
- } finally {
2163
- try {
2164
- if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
2165
- } finally {
2166
- if (e_1) throw e_1.error;
2167
- }
2168
- }
2169
- return newBaggage;
2170
- };
2171
- BaggageImpl$1.prototype.clear = function() {
2172
- return new BaggageImpl$1();
2173
- };
2174
- return BaggageImpl$1;
2175
- }();
2176
- }) });
2177
-
2178
- //#endregion
2179
- //#region ../../node_modules/@opentelemetry/api/build/esm/baggage/internal/symbol.js
2180
- var baggageEntryMetadataSymbol;
2181
- var init_symbol = __esm({ "../../node_modules/@opentelemetry/api/build/esm/baggage/internal/symbol.js": (() => {
2182
- baggageEntryMetadataSymbol = Symbol("BaggageEntryMetadata");
2183
- }) });
2184
-
2185
- //#endregion
2186
- //#region ../../node_modules/@opentelemetry/api/build/esm/baggage/utils.js
2187
- /**
2188
- * Create a new Baggage with optional entries
2189
- *
2190
- * @param entries An array of baggage entries the new baggage should contain
2191
- */
2192
- function createBaggage(entries) {
2193
- if (entries === void 0) entries = {};
2194
- return new BaggageImpl(new Map(Object.entries(entries)));
2195
- }
2196
- /**
2197
- * Create a serializable BaggageEntryMetadata object from a string.
2198
- *
2199
- * @param str string metadata. Format is currently not defined by the spec and has no special meaning.
2200
- *
2201
- */
2202
- function baggageEntryMetadataFromString(str) {
2203
- if (typeof str !== "string") {
2204
- diag$1.error("Cannot create baggage metadata from unknown type: " + typeof str);
2205
- str = "";
2206
- }
2207
- return {
2208
- __TYPE__: baggageEntryMetadataSymbol,
2209
- toString: function() {
2210
- return str;
2211
- }
2212
- };
2213
- }
2214
- var diag$1;
2215
- var init_utils$1 = __esm({ "../../node_modules/@opentelemetry/api/build/esm/baggage/utils.js": (() => {
2216
- init_diag();
2217
- init_baggage_impl();
2218
- init_symbol();
2219
- diag$1 = DiagAPI.instance();
2220
- }) });
2221
-
2222
- //#endregion
2223
- //#region ../../node_modules/@opentelemetry/api/build/esm/context/context.js
2224
- /** Get a key to uniquely identify a context value */
2225
- function createContextKey(description) {
2226
- return Symbol.for(description);
2227
- }
2228
- var BaseContext, ROOT_CONTEXT;
2229
- var init_context$1 = __esm({ "../../node_modules/@opentelemetry/api/build/esm/context/context.js": (() => {
2230
- BaseContext = function() {
2231
- /**
2232
- * Construct a new context which inherits values from an optional parent context.
2233
- *
2234
- * @param parentContext a context from which to inherit values
2235
- */
2236
- function BaseContext$1(parentContext) {
2237
- var self = this;
2238
- self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
2239
- self.getValue = function(key) {
2240
- return self._currentContext.get(key);
2241
- };
2242
- self.setValue = function(key, value) {
2243
- var context$1 = new BaseContext$1(self._currentContext);
2244
- context$1._currentContext.set(key, value);
2245
- return context$1;
2246
- };
2247
- self.deleteValue = function(key) {
2248
- var context$1 = new BaseContext$1(self._currentContext);
2249
- context$1._currentContext.delete(key);
2250
- return context$1;
2251
- };
2252
- }
2253
- return BaseContext$1;
2254
- }();
2255
- ROOT_CONTEXT = new BaseContext();
2256
- }) });
2257
-
2258
- //#endregion
2259
- //#region ../../node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js
2260
- var consoleMap, DiagConsoleLogger;
2261
- var init_consoleLogger = __esm({ "../../node_modules/@opentelemetry/api/build/esm/diag/consoleLogger.js": (() => {
2262
- consoleMap = [
2263
- {
2264
- n: "error",
2265
- c: "error"
2266
- },
2267
- {
2268
- n: "warn",
2269
- c: "warn"
2270
- },
2271
- {
2272
- n: "info",
2273
- c: "info"
2274
- },
2275
- {
2276
- n: "debug",
2277
- c: "debug"
2278
- },
2279
- {
2280
- n: "verbose",
2281
- c: "trace"
2282
- }
2283
- ];
2284
- DiagConsoleLogger = function() {
2285
- function DiagConsoleLogger$1() {
2286
- function _consoleFunc(funcName) {
2287
- return function() {
2288
- var args = [];
2289
- for (var _i = 0; _i < arguments.length; _i++) args[_i] = arguments[_i];
2290
- if (console) {
2291
- var theFunc = console[funcName];
2292
- if (typeof theFunc !== "function") theFunc = console.log;
2293
- if (typeof theFunc === "function") return theFunc.apply(console, args);
2294
- }
2295
- };
2296
- }
2297
- for (var i = 0; i < consoleMap.length; i++) this[consoleMap[i].n] = _consoleFunc(consoleMap[i].c);
2298
- }
2299
- return DiagConsoleLogger$1;
2300
- }();
2301
- }) });
2302
-
2303
- //#endregion
2304
- //#region ../../node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js
2305
- /**
2306
- * Create a no-op Meter
2307
- */
2308
- function createNoopMeter() {
2309
- return NOOP_METER;
2310
- }
2311
- var __extends, NoopMeter, NoopMetric, NoopCounterMetric, NoopUpDownCounterMetric, NoopGaugeMetric, NoopHistogramMetric, NoopObservableMetric, NoopObservableCounterMetric, NoopObservableGaugeMetric, NoopObservableUpDownCounterMetric, NOOP_METER, NOOP_COUNTER_METRIC, NOOP_GAUGE_METRIC, NOOP_HISTOGRAM_METRIC, NOOP_UP_DOWN_COUNTER_METRIC, NOOP_OBSERVABLE_COUNTER_METRIC, NOOP_OBSERVABLE_GAUGE_METRIC, NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
2312
- var init_NoopMeter = __esm({ "../../node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js": (() => {
2313
- __extends = void 0 && (void 0).__extends || (function() {
2314
- var extendStatics = function(d, b) {
2315
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d$1, b$1) {
2316
- d$1.__proto__ = b$1;
2317
- } || function(d$1, b$1) {
2318
- for (var p in b$1) if (Object.prototype.hasOwnProperty.call(b$1, p)) d$1[p] = b$1[p];
2319
- };
2320
- return extendStatics(d, b);
2321
- };
2322
- return function(d, b) {
2323
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2324
- extendStatics(d, b);
2325
- function __() {
2326
- this.constructor = d;
2327
- }
2328
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2329
- };
2330
- })();
2331
- NoopMeter = function() {
2332
- function NoopMeter$1() {}
2333
- /**
2334
- * @see {@link Meter.createGauge}
2335
- */
2336
- NoopMeter$1.prototype.createGauge = function(_name, _options) {
2337
- return NOOP_GAUGE_METRIC;
2338
- };
2339
- /**
2340
- * @see {@link Meter.createHistogram}
2341
- */
2342
- NoopMeter$1.prototype.createHistogram = function(_name, _options) {
2343
- return NOOP_HISTOGRAM_METRIC;
2344
- };
2345
- /**
2346
- * @see {@link Meter.createCounter}
2347
- */
2348
- NoopMeter$1.prototype.createCounter = function(_name, _options) {
2349
- return NOOP_COUNTER_METRIC;
2350
- };
2351
- /**
2352
- * @see {@link Meter.createUpDownCounter}
2353
- */
2354
- NoopMeter$1.prototype.createUpDownCounter = function(_name, _options) {
2355
- return NOOP_UP_DOWN_COUNTER_METRIC;
2356
- };
2357
- /**
2358
- * @see {@link Meter.createObservableGauge}
2359
- */
2360
- NoopMeter$1.prototype.createObservableGauge = function(_name, _options) {
2361
- return NOOP_OBSERVABLE_GAUGE_METRIC;
2362
- };
2363
- /**
2364
- * @see {@link Meter.createObservableCounter}
2365
- */
2366
- NoopMeter$1.prototype.createObservableCounter = function(_name, _options) {
2367
- return NOOP_OBSERVABLE_COUNTER_METRIC;
2368
- };
2369
- /**
2370
- * @see {@link Meter.createObservableUpDownCounter}
2371
- */
2372
- NoopMeter$1.prototype.createObservableUpDownCounter = function(_name, _options) {
2373
- return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
2374
- };
2375
- /**
2376
- * @see {@link Meter.addBatchObservableCallback}
2377
- */
2378
- NoopMeter$1.prototype.addBatchObservableCallback = function(_callback, _observables) {};
2379
- /**
2380
- * @see {@link Meter.removeBatchObservableCallback}
2381
- */
2382
- NoopMeter$1.prototype.removeBatchObservableCallback = function(_callback) {};
2383
- return NoopMeter$1;
2384
- }();
2385
- NoopMetric = function() {
2386
- function NoopMetric$1() {}
2387
- return NoopMetric$1;
2388
- }();
2389
- NoopCounterMetric = function(_super) {
2390
- __extends(NoopCounterMetric$1, _super);
2391
- function NoopCounterMetric$1() {
2392
- return _super !== null && _super.apply(this, arguments) || this;
2393
- }
2394
- NoopCounterMetric$1.prototype.add = function(_value, _attributes) {};
2395
- return NoopCounterMetric$1;
2396
- }(NoopMetric);
2397
- NoopUpDownCounterMetric = function(_super) {
2398
- __extends(NoopUpDownCounterMetric$1, _super);
2399
- function NoopUpDownCounterMetric$1() {
2400
- return _super !== null && _super.apply(this, arguments) || this;
2401
- }
2402
- NoopUpDownCounterMetric$1.prototype.add = function(_value, _attributes) {};
2403
- return NoopUpDownCounterMetric$1;
2404
- }(NoopMetric);
2405
- NoopGaugeMetric = function(_super) {
2406
- __extends(NoopGaugeMetric$1, _super);
2407
- function NoopGaugeMetric$1() {
2408
- return _super !== null && _super.apply(this, arguments) || this;
2409
- }
2410
- NoopGaugeMetric$1.prototype.record = function(_value, _attributes) {};
2411
- return NoopGaugeMetric$1;
2412
- }(NoopMetric);
2413
- NoopHistogramMetric = function(_super) {
2414
- __extends(NoopHistogramMetric$1, _super);
2415
- function NoopHistogramMetric$1() {
2416
- return _super !== null && _super.apply(this, arguments) || this;
2417
- }
2418
- NoopHistogramMetric$1.prototype.record = function(_value, _attributes) {};
2419
- return NoopHistogramMetric$1;
2420
- }(NoopMetric);
2421
- NoopObservableMetric = function() {
2422
- function NoopObservableMetric$1() {}
2423
- NoopObservableMetric$1.prototype.addCallback = function(_callback) {};
2424
- NoopObservableMetric$1.prototype.removeCallback = function(_callback) {};
2425
- return NoopObservableMetric$1;
2426
- }();
2427
- NoopObservableCounterMetric = function(_super) {
2428
- __extends(NoopObservableCounterMetric$1, _super);
2429
- function NoopObservableCounterMetric$1() {
2430
- return _super !== null && _super.apply(this, arguments) || this;
2431
- }
2432
- return NoopObservableCounterMetric$1;
2433
- }(NoopObservableMetric);
2434
- NoopObservableGaugeMetric = function(_super) {
2435
- __extends(NoopObservableGaugeMetric$1, _super);
2436
- function NoopObservableGaugeMetric$1() {
2437
- return _super !== null && _super.apply(this, arguments) || this;
2438
- }
2439
- return NoopObservableGaugeMetric$1;
2440
- }(NoopObservableMetric);
2441
- NoopObservableUpDownCounterMetric = function(_super) {
2442
- __extends(NoopObservableUpDownCounterMetric$1, _super);
2443
- function NoopObservableUpDownCounterMetric$1() {
2444
- return _super !== null && _super.apply(this, arguments) || this;
2445
- }
2446
- return NoopObservableUpDownCounterMetric$1;
2447
- }(NoopObservableMetric);
2448
- NOOP_METER = new NoopMeter();
2449
- NOOP_COUNTER_METRIC = new NoopCounterMetric();
2450
- NOOP_GAUGE_METRIC = new NoopGaugeMetric();
2451
- NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();
2452
- NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
2453
- NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableCounterMetric();
2454
- NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableGaugeMetric();
2455
- NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableUpDownCounterMetric();
2456
- }) });
2457
-
2458
- //#endregion
2459
- //#region ../../node_modules/@opentelemetry/api/build/esm/metrics/Metric.js
2460
- var ValueType;
2461
- var init_Metric = __esm({ "../../node_modules/@opentelemetry/api/build/esm/metrics/Metric.js": (() => {
2462
- ;
2463
- (function(ValueType$1) {
2464
- ValueType$1[ValueType$1["INT"] = 0] = "INT";
2465
- ValueType$1[ValueType$1["DOUBLE"] = 1] = "DOUBLE";
2466
- })(ValueType || (ValueType = {}));
2467
- }) });
2468
-
2469
- //#endregion
2470
- //#region ../../node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js
2471
- var defaultTextMapGetter, defaultTextMapSetter;
2472
- var init_TextMapPropagator = __esm({ "../../node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js": (() => {
2473
- defaultTextMapGetter = {
2474
- get: function(carrier, key) {
2475
- if (carrier == null) return;
2476
- return carrier[key];
2477
- },
2478
- keys: function(carrier) {
2479
- if (carrier == null) return [];
2480
- return Object.keys(carrier);
2481
- }
2482
- };
2483
- defaultTextMapSetter = { set: function(carrier, key, value) {
2484
- if (carrier == null) return;
2485
- carrier[key] = value;
2486
- } };
2487
- }) });
2488
-
2489
- //#endregion
2490
- //#region ../../node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
2491
- var __read$1, __spreadArray$1, NoopContextManager;
2492
- var init_NoopContextManager = __esm({ "../../node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js": (() => {
2493
- init_context$1();
2494
- __read$1 = void 0 && (void 0).__read || function(o, n) {
2495
- var m = typeof Symbol === "function" && o[Symbol.iterator];
2496
- if (!m) return o;
2497
- var i = m.call(o), r, ar = [], e;
2498
- try {
2499
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2500
- } catch (error) {
2501
- e = { error };
2502
- } finally {
2503
- try {
2504
- if (r && !r.done && (m = i["return"])) m.call(i);
2505
- } finally {
2506
- if (e) throw e.error;
2507
- }
2508
- }
2509
- return ar;
2510
- };
2511
- __spreadArray$1 = void 0 && (void 0).__spreadArray || function(to, from, pack) {
2512
- if (pack || arguments.length === 2) {
2513
- for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
2514
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
2515
- ar[i] = from[i];
2516
- }
2517
- }
2518
- return to.concat(ar || Array.prototype.slice.call(from));
2519
- };
2520
- NoopContextManager = function() {
2521
- function NoopContextManager$1() {}
2522
- NoopContextManager$1.prototype.active = function() {
2523
- return ROOT_CONTEXT;
2524
- };
2525
- NoopContextManager$1.prototype.with = function(_context, fn, thisArg) {
2526
- var args = [];
2527
- for (var _i = 3; _i < arguments.length; _i++) args[_i - 3] = arguments[_i];
2528
- return fn.call.apply(fn, __spreadArray$1([thisArg], __read$1(args), false));
2529
- };
2530
- NoopContextManager$1.prototype.bind = function(_context, target) {
2531
- return target;
2532
- };
2533
- NoopContextManager$1.prototype.enable = function() {
2534
- return this;
2535
- };
2536
- NoopContextManager$1.prototype.disable = function() {
2537
- return this;
2538
- };
2539
- return NoopContextManager$1;
2540
- }();
2541
- }) });
2542
-
2543
- //#endregion
2544
- //#region ../../node_modules/@opentelemetry/api/build/esm/api/context.js
2545
- var __read, __spreadArray, API_NAME$3, NOOP_CONTEXT_MANAGER, ContextAPI;
2546
- var init_context = __esm({ "../../node_modules/@opentelemetry/api/build/esm/api/context.js": (() => {
2547
- init_NoopContextManager();
2548
- init_global_utils();
2549
- init_diag();
2550
- __read = void 0 && (void 0).__read || function(o, n) {
2551
- var m = typeof Symbol === "function" && o[Symbol.iterator];
2552
- if (!m) return o;
2553
- var i = m.call(o), r, ar = [], e;
2554
- try {
2555
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2556
- } catch (error) {
2557
- e = { error };
2558
- } finally {
2559
- try {
2560
- if (r && !r.done && (m = i["return"])) m.call(i);
2561
- } finally {
2562
- if (e) throw e.error;
2563
- }
2564
- }
2565
- return ar;
2566
- };
2567
- __spreadArray = void 0 && (void 0).__spreadArray || function(to, from, pack) {
2568
- if (pack || arguments.length === 2) {
2569
- for (var i = 0, l = from.length, ar; i < l; i++) if (ar || !(i in from)) {
2570
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
2571
- ar[i] = from[i];
2572
- }
2573
- }
2574
- return to.concat(ar || Array.prototype.slice.call(from));
2575
- };
2576
- API_NAME$3 = "context";
2577
- NOOP_CONTEXT_MANAGER = new NoopContextManager();
2578
- ContextAPI = function() {
2579
- /** Empty private constructor prevents end users from constructing a new instance of the API */
2580
- function ContextAPI$1() {}
2581
- /** Get the singleton instance of the Context API */
2582
- ContextAPI$1.getInstance = function() {
2583
- if (!this._instance) this._instance = new ContextAPI$1();
2584
- return this._instance;
2585
- };
2586
- /**
2587
- * Set the current context manager.
2588
- *
2589
- * @returns true if the context manager was successfully registered, else false
2590
- */
2591
- ContextAPI$1.prototype.setGlobalContextManager = function(contextManager) {
2592
- return registerGlobal(API_NAME$3, contextManager, DiagAPI.instance());
2593
- };
2594
- /**
2595
- * Get the currently active context
2596
- */
2597
- ContextAPI$1.prototype.active = function() {
2598
- return this._getContextManager().active();
2599
- };
2600
- /**
2601
- * Execute a function with an active context
2602
- *
2603
- * @param context context to be active during function execution
2604
- * @param fn function to execute in a context
2605
- * @param thisArg optional receiver to be used for calling fn
2606
- * @param args optional arguments forwarded to fn
2607
- */
2608
- ContextAPI$1.prototype.with = function(context$1, fn, thisArg) {
2609
- var _a;
2610
- var args = [];
2611
- for (var _i = 3; _i < arguments.length; _i++) args[_i - 3] = arguments[_i];
2612
- return (_a = this._getContextManager()).with.apply(_a, __spreadArray([
2613
- context$1,
2614
- fn,
2615
- thisArg
2616
- ], __read(args), false));
2617
- };
2618
- /**
2619
- * Bind a context to a target function or event emitter
2620
- *
2621
- * @param context context to bind to the event emitter or function. Defaults to the currently active context
2622
- * @param target function or event emitter to bind
2623
- */
2624
- ContextAPI$1.prototype.bind = function(context$1, target) {
2625
- return this._getContextManager().bind(context$1, target);
2626
- };
2627
- ContextAPI$1.prototype._getContextManager = function() {
2628
- return getGlobal(API_NAME$3) || NOOP_CONTEXT_MANAGER;
2629
- };
2630
- /** Disable and remove the global context manager */
2631
- ContextAPI$1.prototype.disable = function() {
2632
- this._getContextManager().disable();
2633
- unregisterGlobal(API_NAME$3, DiagAPI.instance());
2634
- };
2635
- return ContextAPI$1;
2636
- }();
2637
- }) });
2638
-
2639
- //#endregion
2640
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
2641
- var TraceFlags;
2642
- var init_trace_flags = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js": (() => {
2643
- ;
2644
- (function(TraceFlags$1) {
2645
- /** Represents no flag set. */
2646
- TraceFlags$1[TraceFlags$1["NONE"] = 0] = "NONE";
2647
- /** Bit to represent whether trace is sampled in trace flags. */
2648
- TraceFlags$1[TraceFlags$1["SAMPLED"] = 1] = "SAMPLED";
2649
- })(TraceFlags || (TraceFlags = {}));
2650
- }) });
2651
-
2652
- //#endregion
2653
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
2654
- var INVALID_SPANID, INVALID_TRACEID, INVALID_SPAN_CONTEXT;
2655
- var init_invalid_span_constants = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js": (() => {
2656
- init_trace_flags();
2657
- INVALID_SPANID = "0000000000000000";
2658
- INVALID_TRACEID = "00000000000000000000000000000000";
2659
- INVALID_SPAN_CONTEXT = {
2660
- traceId: INVALID_TRACEID,
2661
- spanId: INVALID_SPANID,
2662
- traceFlags: TraceFlags.NONE
2663
- };
2664
- }) });
2665
-
2666
- //#endregion
2667
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
2668
- var NonRecordingSpan;
2669
- var init_NonRecordingSpan = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js": (() => {
2670
- init_invalid_span_constants();
2671
- NonRecordingSpan = function() {
2672
- function NonRecordingSpan$1(_spanContext) {
2673
- if (_spanContext === void 0) _spanContext = INVALID_SPAN_CONTEXT;
2674
- this._spanContext = _spanContext;
2675
- }
2676
- NonRecordingSpan$1.prototype.spanContext = function() {
2677
- return this._spanContext;
2678
- };
2679
- NonRecordingSpan$1.prototype.setAttribute = function(_key, _value) {
2680
- return this;
2681
- };
2682
- NonRecordingSpan$1.prototype.setAttributes = function(_attributes) {
2683
- return this;
2684
- };
2685
- NonRecordingSpan$1.prototype.addEvent = function(_name, _attributes) {
2686
- return this;
2687
- };
2688
- NonRecordingSpan$1.prototype.addLink = function(_link) {
2689
- return this;
2690
- };
2691
- NonRecordingSpan$1.prototype.addLinks = function(_links) {
2692
- return this;
2693
- };
2694
- NonRecordingSpan$1.prototype.setStatus = function(_status) {
2695
- return this;
2696
- };
2697
- NonRecordingSpan$1.prototype.updateName = function(_name) {
2698
- return this;
2699
- };
2700
- NonRecordingSpan$1.prototype.end = function(_endTime) {};
2701
- NonRecordingSpan$1.prototype.isRecording = function() {
2702
- return false;
2703
- };
2704
- NonRecordingSpan$1.prototype.recordException = function(_exception, _time) {};
2705
- return NonRecordingSpan$1;
2706
- }();
2707
- }) });
2708
-
2709
- //#endregion
2710
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
2711
- /**
2712
- * Return the span if one exists
2713
- *
2714
- * @param context context to get span from
2715
- */
2716
- function getSpan(context$1) {
2717
- return context$1.getValue(SPAN_KEY) || void 0;
2718
- }
2719
- /**
2720
- * Gets the span from the current context, if one exists.
2721
- */
2722
- function getActiveSpan() {
2723
- return getSpan(ContextAPI.getInstance().active());
2724
- }
2725
- /**
2726
- * Set the span on a context
2727
- *
2728
- * @param context context to use as parent
2729
- * @param span span to set active
2730
- */
2731
- function setSpan(context$1, span) {
2732
- return context$1.setValue(SPAN_KEY, span);
2733
- }
2734
- /**
2735
- * Remove current span stored in the context
2736
- *
2737
- * @param context context to delete span from
2738
- */
2739
- function deleteSpan(context$1) {
2740
- return context$1.deleteValue(SPAN_KEY);
2741
- }
2742
- /**
2743
- * Wrap span context in a NoopSpan and set as span in a new
2744
- * context
2745
- *
2746
- * @param context context to set active span on
2747
- * @param spanContext span context to be wrapped
2748
- */
2749
- function setSpanContext(context$1, spanContext) {
2750
- return setSpan(context$1, new NonRecordingSpan(spanContext));
2751
- }
2752
- /**
2753
- * Get the span context of the span if it exists.
2754
- *
2755
- * @param context context to get values from
2756
- */
2757
- function getSpanContext(context$1) {
2758
- var _a;
2759
- return (_a = getSpan(context$1)) === null || _a === void 0 ? void 0 : _a.spanContext();
2760
- }
2761
- var SPAN_KEY;
2762
- var init_context_utils = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/context-utils.js": (() => {
2763
- init_context$1();
2764
- init_NonRecordingSpan();
2765
- init_context();
2766
- SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
2767
- }) });
2768
-
2769
- //#endregion
2770
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
2771
- function isValidTraceId(traceId) {
2772
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
2773
- }
2774
- function isValidSpanId(spanId) {
2775
- return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
2776
- }
2777
- /**
2778
- * Returns true if this {@link SpanContext} is valid.
2779
- * @return true if this {@link SpanContext} is valid.
2780
- */
2781
- function isSpanContextValid(spanContext) {
2782
- return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
2783
- }
2784
- /**
2785
- * Wrap the given {@link SpanContext} in a new non-recording {@link Span}
2786
- *
2787
- * @param spanContext span context to be wrapped
2788
- * @returns a new non-recording {@link Span} with the provided context
2789
- */
2790
- function wrapSpanContext(spanContext) {
2791
- return new NonRecordingSpan(spanContext);
2792
- }
2793
- var VALID_TRACEID_REGEX, VALID_SPANID_REGEX;
2794
- var init_spancontext_utils = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js": (() => {
2795
- init_invalid_span_constants();
2796
- init_NonRecordingSpan();
2797
- VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
2798
- VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
2799
- }) });
2800
-
2801
- //#endregion
2802
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
2803
- function isSpanContext(spanContext) {
2804
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
2805
- }
2806
- var contextApi, NoopTracer;
2807
- var init_NoopTracer = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js": (() => {
2808
- init_context();
2809
- init_context_utils();
2810
- init_NonRecordingSpan();
2811
- init_spancontext_utils();
2812
- contextApi = ContextAPI.getInstance();
2813
- NoopTracer = function() {
2814
- function NoopTracer$1() {}
2815
- NoopTracer$1.prototype.startSpan = function(name, options, context$1) {
2816
- if (context$1 === void 0) context$1 = contextApi.active();
2817
- if (Boolean(options === null || options === void 0 ? void 0 : options.root)) return new NonRecordingSpan();
2818
- var parentFromContext = context$1 && getSpanContext(context$1);
2819
- if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) return new NonRecordingSpan(parentFromContext);
2820
- else return new NonRecordingSpan();
2821
- };
2822
- NoopTracer$1.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
2823
- var opts;
2824
- var ctx;
2825
- var fn;
2826
- if (arguments.length < 2) return;
2827
- else if (arguments.length === 2) fn = arg2;
2828
- else if (arguments.length === 3) {
2829
- opts = arg2;
2830
- fn = arg3;
2831
- } else {
2832
- opts = arg2;
2833
- ctx = arg3;
2834
- fn = arg4;
2835
- }
2836
- var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
2837
- var span = this.startSpan(name, opts, parentContext);
2838
- var contextWithSpanSet = setSpan(parentContext, span);
2839
- return contextApi.with(contextWithSpanSet, fn, void 0, span);
2840
- };
2841
- return NoopTracer$1;
2842
- }();
2843
- }) });
2844
-
2845
- //#endregion
2846
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
2847
- var NOOP_TRACER, ProxyTracer;
2848
- var init_ProxyTracer = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js": (() => {
2849
- init_NoopTracer();
2850
- NOOP_TRACER = new NoopTracer();
2851
- ProxyTracer = function() {
2852
- function ProxyTracer$1(_provider, name, version$2, options) {
2853
- this._provider = _provider;
2854
- this.name = name;
2855
- this.version = version$2;
2856
- this.options = options;
2857
- }
2858
- ProxyTracer$1.prototype.startSpan = function(name, options, context$1) {
2859
- return this._getTracer().startSpan(name, options, context$1);
2860
- };
2861
- ProxyTracer$1.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
2862
- var tracer = this._getTracer();
2863
- return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
2864
- };
2865
- /**
2866
- * Try to get a tracer from the proxy tracer provider.
2867
- * If the proxy tracer provider has no delegate, return a noop tracer.
2868
- */
2869
- ProxyTracer$1.prototype._getTracer = function() {
2870
- if (this._delegate) return this._delegate;
2871
- var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
2872
- if (!tracer) return NOOP_TRACER;
2873
- this._delegate = tracer;
2874
- return this._delegate;
2875
- };
2876
- return ProxyTracer$1;
2877
- }();
2878
- }) });
2879
-
2880
- //#endregion
2881
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
2882
- var NoopTracerProvider;
2883
- var init_NoopTracerProvider = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js": (() => {
2884
- init_NoopTracer();
2885
- NoopTracerProvider = function() {
2886
- function NoopTracerProvider$1() {}
2887
- NoopTracerProvider$1.prototype.getTracer = function(_name, _version, _options) {
2888
- return new NoopTracer();
2889
- };
2890
- return NoopTracerProvider$1;
2891
- }();
2892
- }) });
2893
-
2894
- //#endregion
2895
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
2896
- var NOOP_TRACER_PROVIDER, ProxyTracerProvider;
2897
- var init_ProxyTracerProvider = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js": (() => {
2898
- init_ProxyTracer();
2899
- init_NoopTracerProvider();
2900
- NOOP_TRACER_PROVIDER = new NoopTracerProvider();
2901
- ProxyTracerProvider = function() {
2902
- function ProxyTracerProvider$1() {}
2903
- /**
2904
- * Get a {@link ProxyTracer}
2905
- */
2906
- ProxyTracerProvider$1.prototype.getTracer = function(name, version$2, options) {
2907
- var _a;
2908
- return (_a = this.getDelegateTracer(name, version$2, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version$2, options);
2909
- };
2910
- ProxyTracerProvider$1.prototype.getDelegate = function() {
2911
- var _a;
2912
- return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
2913
- };
2914
- /**
2915
- * Set the delegate tracer provider
2916
- */
2917
- ProxyTracerProvider$1.prototype.setDelegate = function(delegate) {
2918
- this._delegate = delegate;
2919
- };
2920
- ProxyTracerProvider$1.prototype.getDelegateTracer = function(name, version$2, options) {
2921
- var _a;
2922
- return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version$2, options);
2923
- };
2924
- return ProxyTracerProvider$1;
2925
- }();
2926
- }) });
2927
-
2928
- //#endregion
2929
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/SamplingResult.js
2930
- var SamplingDecision;
2931
- var init_SamplingResult = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/SamplingResult.js": (() => {
2932
- ;
2933
- (function(SamplingDecision$1) {
2934
- /**
2935
- * `Span.isRecording() === false`, span will not be recorded and all events
2936
- * and attributes will be dropped.
2937
- */
2938
- SamplingDecision$1[SamplingDecision$1["NOT_RECORD"] = 0] = "NOT_RECORD";
2939
- /**
2940
- * `Span.isRecording() === true`, but `Sampled` flag in {@link TraceFlags}
2941
- * MUST NOT be set.
2942
- */
2943
- SamplingDecision$1[SamplingDecision$1["RECORD"] = 1] = "RECORD";
2944
- /**
2945
- * `Span.isRecording() === true` AND `Sampled` flag in {@link TraceFlags}
2946
- * MUST be set.
2947
- */
2948
- SamplingDecision$1[SamplingDecision$1["RECORD_AND_SAMPLED"] = 2] = "RECORD_AND_SAMPLED";
2949
- })(SamplingDecision || (SamplingDecision = {}));
2950
- }) });
2951
-
2952
- //#endregion
2953
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/span_kind.js
2954
- var SpanKind;
2955
- var init_span_kind = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/span_kind.js": (() => {
2956
- ;
2957
- (function(SpanKind$1) {
2958
- /** Default value. Indicates that the span is used internally. */
2959
- SpanKind$1[SpanKind$1["INTERNAL"] = 0] = "INTERNAL";
2960
- /**
2961
- * Indicates that the span covers server-side handling of an RPC or other
2962
- * remote request.
2963
- */
2964
- SpanKind$1[SpanKind$1["SERVER"] = 1] = "SERVER";
2965
- /**
2966
- * Indicates that the span covers the client-side wrapper around an RPC or
2967
- * other remote request.
2968
- */
2969
- SpanKind$1[SpanKind$1["CLIENT"] = 2] = "CLIENT";
2970
- /**
2971
- * Indicates that the span describes producer sending a message to a
2972
- * broker. Unlike client and server, there is no direct critical path latency
2973
- * relationship between producer and consumer spans.
2974
- */
2975
- SpanKind$1[SpanKind$1["PRODUCER"] = 3] = "PRODUCER";
2976
- /**
2977
- * Indicates that the span describes consumer receiving a message from a
2978
- * broker. Unlike client and server, there is no direct critical path latency
2979
- * relationship between producer and consumer spans.
2980
- */
2981
- SpanKind$1[SpanKind$1["CONSUMER"] = 4] = "CONSUMER";
2982
- })(SpanKind || (SpanKind = {}));
2983
- }) });
2984
-
2985
- //#endregion
2986
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/status.js
2987
- var SpanStatusCode;
2988
- var init_status = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/status.js": (() => {
2989
- ;
2990
- (function(SpanStatusCode$1) {
2991
- /**
2992
- * The default status.
2993
- */
2994
- SpanStatusCode$1[SpanStatusCode$1["UNSET"] = 0] = "UNSET";
2995
- /**
2996
- * The operation has been validated by an Application developer or
2997
- * Operator to have completed successfully.
2998
- */
2999
- SpanStatusCode$1[SpanStatusCode$1["OK"] = 1] = "OK";
3000
- /**
3001
- * The operation contains an error.
3002
- */
3003
- SpanStatusCode$1[SpanStatusCode$1["ERROR"] = 2] = "ERROR";
3004
- })(SpanStatusCode || (SpanStatusCode = {}));
3005
- }) });
3006
-
3007
- //#endregion
3008
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-validators.js
3009
- /**
3010
- * Key is opaque string up to 256 characters printable. It MUST begin with a
3011
- * lowercase letter, and can only contain lowercase letters a-z, digits 0-9,
3012
- * underscores _, dashes -, asterisks *, and forward slashes /.
3013
- * For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the
3014
- * vendor name. Vendors SHOULD set the tenant ID at the beginning of the key.
3015
- * see https://www.w3.org/TR/trace-context/#key
3016
- */
3017
- function validateKey(key) {
3018
- return VALID_KEY_REGEX.test(key);
3019
- }
3020
- /**
3021
- * Value is opaque string up to 256 characters printable ASCII RFC0020
3022
- * characters (i.e., the range 0x20 to 0x7E) except comma , and =.
3023
- */
3024
- function validateValue(value) {
3025
- return VALID_VALUE_BASE_REGEX.test(value) && !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value);
3026
- }
3027
- var VALID_KEY_CHAR_RANGE, VALID_KEY, VALID_VENDOR_KEY, VALID_KEY_REGEX, VALID_VALUE_BASE_REGEX, INVALID_VALUE_COMMA_EQUAL_REGEX;
3028
- var init_tracestate_validators = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-validators.js": (() => {
3029
- VALID_KEY_CHAR_RANGE = "[_0-9a-z-*/]";
3030
- VALID_KEY = "[a-z]" + VALID_KEY_CHAR_RANGE + "{0,255}";
3031
- VALID_VENDOR_KEY = "[a-z0-9]" + VALID_KEY_CHAR_RANGE + "{0,240}@[a-z]" + VALID_KEY_CHAR_RANGE + "{0,13}";
3032
- VALID_KEY_REGEX = /* @__PURE__ */ new RegExp("^(?:" + VALID_KEY + "|" + VALID_VENDOR_KEY + ")$");
3033
- VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/;
3034
- INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/;
3035
- }) });
3036
-
3037
- //#endregion
3038
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-impl.js
3039
- var MAX_TRACE_STATE_ITEMS, MAX_TRACE_STATE_LEN, LIST_MEMBERS_SEPARATOR, LIST_MEMBER_KEY_VALUE_SPLITTER, TraceStateImpl;
3040
- var init_tracestate_impl = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/internal/tracestate-impl.js": (() => {
3041
- init_tracestate_validators();
3042
- MAX_TRACE_STATE_ITEMS = 32;
3043
- MAX_TRACE_STATE_LEN = 512;
3044
- LIST_MEMBERS_SEPARATOR = ",";
3045
- LIST_MEMBER_KEY_VALUE_SPLITTER = "=";
3046
- TraceStateImpl = function() {
3047
- function TraceStateImpl$1(rawTraceState) {
3048
- this._internalState = /* @__PURE__ */ new Map();
3049
- if (rawTraceState) this._parse(rawTraceState);
3050
- }
3051
- TraceStateImpl$1.prototype.set = function(key, value) {
3052
- var traceState = this._clone();
3053
- if (traceState._internalState.has(key)) traceState._internalState.delete(key);
3054
- traceState._internalState.set(key, value);
3055
- return traceState;
3056
- };
3057
- TraceStateImpl$1.prototype.unset = function(key) {
3058
- var traceState = this._clone();
3059
- traceState._internalState.delete(key);
3060
- return traceState;
3061
- };
3062
- TraceStateImpl$1.prototype.get = function(key) {
3063
- return this._internalState.get(key);
3064
- };
3065
- TraceStateImpl$1.prototype.serialize = function() {
3066
- var _this = this;
3067
- return this._keys().reduce(function(agg, key) {
3068
- agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + _this.get(key));
3069
- return agg;
3070
- }, []).join(LIST_MEMBERS_SEPARATOR);
3071
- };
3072
- TraceStateImpl$1.prototype._parse = function(rawTraceState) {
3073
- if (rawTraceState.length > MAX_TRACE_STATE_LEN) return;
3074
- this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce(function(agg, part) {
3075
- var listMember = part.trim();
3076
- var i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
3077
- if (i !== -1) {
3078
- var key = listMember.slice(0, i);
3079
- var value = listMember.slice(i + 1, part.length);
3080
- if (validateKey(key) && validateValue(value)) agg.set(key, value);
3081
- }
3082
- return agg;
3083
- }, /* @__PURE__ */ new Map());
3084
- if (this._internalState.size > MAX_TRACE_STATE_ITEMS) this._internalState = new Map(Array.from(this._internalState.entries()).reverse().slice(0, MAX_TRACE_STATE_ITEMS));
3085
- };
3086
- TraceStateImpl$1.prototype._keys = function() {
3087
- return Array.from(this._internalState.keys()).reverse();
3088
- };
3089
- TraceStateImpl$1.prototype._clone = function() {
3090
- var traceState = new TraceStateImpl$1();
3091
- traceState._internalState = new Map(this._internalState);
3092
- return traceState;
3093
- };
3094
- return TraceStateImpl$1;
3095
- }();
3096
- }) });
3097
-
3098
- //#endregion
3099
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace/internal/utils.js
3100
- function createTraceState(rawTraceState) {
3101
- return new TraceStateImpl(rawTraceState);
3102
- }
3103
- var init_utils = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace/internal/utils.js": (() => {
3104
- init_tracestate_impl();
3105
- }) });
3106
-
3107
- //#endregion
3108
- //#region ../../node_modules/@opentelemetry/api/build/esm/context-api.js
3109
- var context;
3110
- var init_context_api = __esm({ "../../node_modules/@opentelemetry/api/build/esm/context-api.js": (() => {
3111
- init_context();
3112
- context = ContextAPI.getInstance();
3113
- }) });
3114
-
3115
- //#endregion
3116
- //#region ../../node_modules/@opentelemetry/api/build/esm/diag-api.js
3117
- var diag;
3118
- var init_diag_api = __esm({ "../../node_modules/@opentelemetry/api/build/esm/diag-api.js": (() => {
3119
- init_diag();
3120
- diag = DiagAPI.instance();
3121
- }) });
3122
-
3123
- //#endregion
3124
- //#region ../../node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js
3125
- var NoopMeterProvider, NOOP_METER_PROVIDER;
3126
- var init_NoopMeterProvider = __esm({ "../../node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js": (() => {
3127
- init_NoopMeter();
3128
- NoopMeterProvider = function() {
3129
- function NoopMeterProvider$1() {}
3130
- NoopMeterProvider$1.prototype.getMeter = function(_name, _version, _options) {
3131
- return NOOP_METER;
3132
- };
3133
- return NoopMeterProvider$1;
3134
- }();
3135
- NOOP_METER_PROVIDER = new NoopMeterProvider();
3136
- }) });
3137
-
3138
- //#endregion
3139
- //#region ../../node_modules/@opentelemetry/api/build/esm/api/metrics.js
3140
- var API_NAME$2, MetricsAPI;
3141
- var init_metrics = __esm({ "../../node_modules/@opentelemetry/api/build/esm/api/metrics.js": (() => {
3142
- init_NoopMeterProvider();
3143
- init_global_utils();
3144
- init_diag();
3145
- API_NAME$2 = "metrics";
3146
- MetricsAPI = function() {
3147
- /** Empty private constructor prevents end users from constructing a new instance of the API */
3148
- function MetricsAPI$1() {}
3149
- /** Get the singleton instance of the Metrics API */
3150
- MetricsAPI$1.getInstance = function() {
3151
- if (!this._instance) this._instance = new MetricsAPI$1();
3152
- return this._instance;
3153
- };
3154
- /**
3155
- * Set the current global meter provider.
3156
- * Returns true if the meter provider was successfully registered, else false.
3157
- */
3158
- MetricsAPI$1.prototype.setGlobalMeterProvider = function(provider) {
3159
- return registerGlobal(API_NAME$2, provider, DiagAPI.instance());
3160
- };
3161
- /**
3162
- * Returns the global meter provider.
3163
- */
3164
- MetricsAPI$1.prototype.getMeterProvider = function() {
3165
- return getGlobal(API_NAME$2) || NOOP_METER_PROVIDER;
3166
- };
3167
- /**
3168
- * Returns a meter from the global meter provider.
3169
- */
3170
- MetricsAPI$1.prototype.getMeter = function(name, version$2, options) {
3171
- return this.getMeterProvider().getMeter(name, version$2, options);
3172
- };
3173
- /** Remove the global meter provider */
3174
- MetricsAPI$1.prototype.disable = function() {
3175
- unregisterGlobal(API_NAME$2, DiagAPI.instance());
3176
- };
3177
- return MetricsAPI$1;
3178
- }();
3179
- }) });
3180
-
3181
- //#endregion
3182
- //#region ../../node_modules/@opentelemetry/api/build/esm/metrics-api.js
3183
- var metrics$1;
3184
- var init_metrics_api = __esm({ "../../node_modules/@opentelemetry/api/build/esm/metrics-api.js": (() => {
3185
- init_metrics();
3186
- metrics$1 = MetricsAPI.getInstance();
3187
- }) });
3188
-
3189
- //#endregion
3190
- //#region ../../node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js
3191
- var NoopTextMapPropagator;
3192
- var init_NoopTextMapPropagator = __esm({ "../../node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js": (() => {
3193
- NoopTextMapPropagator = function() {
3194
- function NoopTextMapPropagator$1() {}
3195
- /** Noop inject function does nothing */
3196
- NoopTextMapPropagator$1.prototype.inject = function(_context, _carrier) {};
3197
- /** Noop extract function does nothing and returns the input context */
3198
- NoopTextMapPropagator$1.prototype.extract = function(context$1, _carrier) {
3199
- return context$1;
3200
- };
3201
- NoopTextMapPropagator$1.prototype.fields = function() {
3202
- return [];
3203
- };
3204
- return NoopTextMapPropagator$1;
3205
- }();
3206
- }) });
3207
-
3208
- //#endregion
3209
- //#region ../../node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js
3210
- /**
3211
- * Retrieve the current baggage from the given context
3212
- *
3213
- * @param {Context} Context that manage all context values
3214
- * @returns {Baggage} Extracted baggage from the context
3215
- */
3216
- function getBaggage(context$1) {
3217
- return context$1.getValue(BAGGAGE_KEY) || void 0;
3218
- }
3219
- /**
3220
- * Retrieve the current baggage from the active/current context
3221
- *
3222
- * @returns {Baggage} Extracted baggage from the context
3223
- */
3224
- function getActiveBaggage() {
3225
- return getBaggage(ContextAPI.getInstance().active());
3226
- }
3227
- /**
3228
- * Store a baggage in the given context
3229
- *
3230
- * @param {Context} Context that manage all context values
3231
- * @param {Baggage} baggage that will be set in the actual context
3232
- */
3233
- function setBaggage(context$1, baggage) {
3234
- return context$1.setValue(BAGGAGE_KEY, baggage);
3235
- }
3236
- /**
3237
- * Delete the baggage stored in the given context
3238
- *
3239
- * @param {Context} Context that manage all context values
3240
- */
3241
- function deleteBaggage(context$1) {
3242
- return context$1.deleteValue(BAGGAGE_KEY);
3243
- }
3244
- var BAGGAGE_KEY;
3245
- var init_context_helpers = __esm({ "../../node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js": (() => {
3246
- init_context();
3247
- init_context$1();
3248
- BAGGAGE_KEY = createContextKey("OpenTelemetry Baggage Key");
3249
- }) });
3250
-
3251
- //#endregion
3252
- //#region ../../node_modules/@opentelemetry/api/build/esm/api/propagation.js
3253
- var API_NAME$1, NOOP_TEXT_MAP_PROPAGATOR, PropagationAPI;
3254
- var init_propagation = __esm({ "../../node_modules/@opentelemetry/api/build/esm/api/propagation.js": (() => {
3255
- init_global_utils();
3256
- init_NoopTextMapPropagator();
3257
- init_TextMapPropagator();
3258
- init_context_helpers();
3259
- init_utils$1();
3260
- init_diag();
3261
- API_NAME$1 = "propagation";
3262
- NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator();
3263
- PropagationAPI = function() {
3264
- /** Empty private constructor prevents end users from constructing a new instance of the API */
3265
- function PropagationAPI$1() {
3266
- this.createBaggage = createBaggage;
3267
- this.getBaggage = getBaggage;
3268
- this.getActiveBaggage = getActiveBaggage;
3269
- this.setBaggage = setBaggage;
3270
- this.deleteBaggage = deleteBaggage;
3271
- }
3272
- /** Get the singleton instance of the Propagator API */
3273
- PropagationAPI$1.getInstance = function() {
3274
- if (!this._instance) this._instance = new PropagationAPI$1();
3275
- return this._instance;
3276
- };
3277
- /**
3278
- * Set the current propagator.
3279
- *
3280
- * @returns true if the propagator was successfully registered, else false
3281
- */
3282
- PropagationAPI$1.prototype.setGlobalPropagator = function(propagator) {
3283
- return registerGlobal(API_NAME$1, propagator, DiagAPI.instance());
3284
- };
3285
- /**
3286
- * Inject context into a carrier to be propagated inter-process
3287
- *
3288
- * @param context Context carrying tracing data to inject
3289
- * @param carrier carrier to inject context into
3290
- * @param setter Function used to set values on the carrier
3291
- */
3292
- PropagationAPI$1.prototype.inject = function(context$1, carrier, setter) {
3293
- if (setter === void 0) setter = defaultTextMapSetter;
3294
- return this._getGlobalPropagator().inject(context$1, carrier, setter);
3295
- };
3296
- /**
3297
- * Extract context from a carrier
3298
- *
3299
- * @param context Context which the newly created context will inherit from
3300
- * @param carrier Carrier to extract context from
3301
- * @param getter Function used to extract keys from a carrier
3302
- */
3303
- PropagationAPI$1.prototype.extract = function(context$1, carrier, getter) {
3304
- if (getter === void 0) getter = defaultTextMapGetter;
3305
- return this._getGlobalPropagator().extract(context$1, carrier, getter);
3306
- };
3307
- /**
3308
- * Return a list of all fields which may be used by the propagator.
3309
- */
3310
- PropagationAPI$1.prototype.fields = function() {
3311
- return this._getGlobalPropagator().fields();
3312
- };
3313
- /** Remove the global propagator */
3314
- PropagationAPI$1.prototype.disable = function() {
3315
- unregisterGlobal(API_NAME$1, DiagAPI.instance());
3316
- };
3317
- PropagationAPI$1.prototype._getGlobalPropagator = function() {
3318
- return getGlobal(API_NAME$1) || NOOP_TEXT_MAP_PROPAGATOR;
3319
- };
3320
- return PropagationAPI$1;
3321
- }();
3322
- }) });
3323
-
3324
- //#endregion
3325
- //#region ../../node_modules/@opentelemetry/api/build/esm/propagation-api.js
3326
- var propagation;
3327
- var init_propagation_api = __esm({ "../../node_modules/@opentelemetry/api/build/esm/propagation-api.js": (() => {
3328
- init_propagation();
3329
- propagation = PropagationAPI.getInstance();
3330
- }) });
3331
-
3332
- //#endregion
3333
- //#region ../../node_modules/@opentelemetry/api/build/esm/api/trace.js
3334
- var API_NAME, TraceAPI;
3335
- var init_trace = __esm({ "../../node_modules/@opentelemetry/api/build/esm/api/trace.js": (() => {
3336
- init_global_utils();
3337
- init_ProxyTracerProvider();
3338
- init_spancontext_utils();
3339
- init_context_utils();
3340
- init_diag();
3341
- API_NAME = "trace";
3342
- TraceAPI = function() {
3343
- /** Empty private constructor prevents end users from constructing a new instance of the API */
3344
- function TraceAPI$1() {
3345
- this._proxyTracerProvider = new ProxyTracerProvider();
3346
- this.wrapSpanContext = wrapSpanContext;
3347
- this.isSpanContextValid = isSpanContextValid;
3348
- this.deleteSpan = deleteSpan;
3349
- this.getSpan = getSpan;
3350
- this.getActiveSpan = getActiveSpan;
3351
- this.getSpanContext = getSpanContext;
3352
- this.setSpan = setSpan;
3353
- this.setSpanContext = setSpanContext;
3354
- }
3355
- /** Get the singleton instance of the Trace API */
3356
- TraceAPI$1.getInstance = function() {
3357
- if (!this._instance) this._instance = new TraceAPI$1();
3358
- return this._instance;
3359
- };
3360
- /**
3361
- * Set the current global tracer.
3362
- *
3363
- * @returns true if the tracer provider was successfully registered, else false
3364
- */
3365
- TraceAPI$1.prototype.setGlobalTracerProvider = function(provider) {
3366
- var success = registerGlobal(API_NAME, this._proxyTracerProvider, DiagAPI.instance());
3367
- if (success) this._proxyTracerProvider.setDelegate(provider);
3368
- return success;
3369
- };
3370
- /**
3371
- * Returns the global tracer provider.
3372
- */
3373
- TraceAPI$1.prototype.getTracerProvider = function() {
3374
- return getGlobal(API_NAME) || this._proxyTracerProvider;
3375
- };
3376
- /**
3377
- * Returns a tracer from the global tracer provider.
3378
- */
3379
- TraceAPI$1.prototype.getTracer = function(name, version$2) {
3380
- return this.getTracerProvider().getTracer(name, version$2);
3381
- };
3382
- /** Remove the global tracer provider */
3383
- TraceAPI$1.prototype.disable = function() {
3384
- unregisterGlobal(API_NAME, DiagAPI.instance());
3385
- this._proxyTracerProvider = new ProxyTracerProvider();
3386
- };
3387
- return TraceAPI$1;
3388
- }();
3389
- }) });
3390
-
3391
- //#endregion
3392
- //#region ../../node_modules/@opentelemetry/api/build/esm/trace-api.js
3393
- var trace;
3394
- var init_trace_api = __esm({ "../../node_modules/@opentelemetry/api/build/esm/trace-api.js": (() => {
3395
- init_trace();
3396
- trace = TraceAPI.getInstance();
3397
- }) });
3398
-
3399
- //#endregion
3400
- //#region ../../node_modules/@opentelemetry/api/build/esm/index.js
3401
- var esm_exports = /* @__PURE__ */ __export({
3402
- DiagConsoleLogger: () => DiagConsoleLogger,
3403
- DiagLogLevel: () => DiagLogLevel,
3404
- INVALID_SPANID: () => INVALID_SPANID,
3405
- INVALID_SPAN_CONTEXT: () => INVALID_SPAN_CONTEXT,
3406
- INVALID_TRACEID: () => INVALID_TRACEID,
3407
- ProxyTracer: () => ProxyTracer,
3408
- ProxyTracerProvider: () => ProxyTracerProvider,
3409
- ROOT_CONTEXT: () => ROOT_CONTEXT,
3410
- SamplingDecision: () => SamplingDecision,
3411
- SpanKind: () => SpanKind,
3412
- SpanStatusCode: () => SpanStatusCode,
3413
- TraceFlags: () => TraceFlags,
3414
- ValueType: () => ValueType,
3415
- baggageEntryMetadataFromString: () => baggageEntryMetadataFromString,
3416
- context: () => context,
3417
- createContextKey: () => createContextKey,
3418
- createNoopMeter: () => createNoopMeter,
3419
- createTraceState: () => createTraceState,
3420
- default: () => esm_default,
3421
- defaultTextMapGetter: () => defaultTextMapGetter,
3422
- defaultTextMapSetter: () => defaultTextMapSetter,
3423
- diag: () => diag,
3424
- isSpanContextValid: () => isSpanContextValid,
3425
- isValidSpanId: () => isValidSpanId,
3426
- isValidTraceId: () => isValidTraceId,
3427
- metrics: () => metrics$1,
3428
- propagation: () => propagation,
3429
- trace: () => trace
3430
- });
3431
- var esm_default;
3432
- var init_esm = __esm({ "../../node_modules/@opentelemetry/api/build/esm/index.js": (() => {
3433
- init_utils$1();
3434
- init_context$1();
3435
- init_consoleLogger();
3436
- init_types();
3437
- init_NoopMeter();
3438
- init_Metric();
3439
- init_TextMapPropagator();
3440
- init_ProxyTracer();
3441
- init_ProxyTracerProvider();
3442
- init_SamplingResult();
3443
- init_span_kind();
3444
- init_status();
3445
- init_trace_flags();
3446
- init_utils();
3447
- init_spancontext_utils();
3448
- init_invalid_span_constants();
3449
- init_context_api();
3450
- init_diag_api();
3451
- init_metrics_api();
3452
- init_propagation_api();
3453
- init_trace_api();
3454
- esm_default = {
3455
- context,
3456
- diag,
3457
- metrics: metrics$1,
3458
- propagation,
3459
- trace
3460
- };
3461
- }) });
3462
-
3463
- //#endregion
3464
- //#region ../../node_modules/prom-client/lib/metrics/processCpuTotal.js
3465
- var require_processCpuTotal = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processCpuTotal.js": ((exports, module) => {
3466
- const OtelApi = (init_esm(), __toCommonJS(esm_exports));
3467
- const Counter = require_counter();
3468
- const PROCESS_CPU_USER_SECONDS = "process_cpu_user_seconds_total";
3469
- const PROCESS_CPU_SYSTEM_SECONDS = "process_cpu_system_seconds_total";
3470
- const PROCESS_CPU_SECONDS = "process_cpu_seconds_total";
3471
- module.exports = (registry, config = {}) => {
3472
- const registers = registry ? [registry] : void 0;
3473
- const namePrefix = config.prefix ? config.prefix : "";
3474
- const labels = config.labels ? config.labels : {};
3475
- const exemplars = config.enableExemplars ? config.enableExemplars : false;
3476
- const labelNames = Object.keys(labels);
3477
- let lastCpuUsage = process.cpuUsage();
3478
- const cpuUserUsageCounter = new Counter({
3479
- name: namePrefix + PROCESS_CPU_USER_SECONDS,
3480
- help: "Total user CPU time spent in seconds.",
3481
- enableExemplars: exemplars,
3482
- registers,
3483
- labelNames,
3484
- collect() {
3485
- const cpuUsage = process.cpuUsage();
3486
- const userUsageMicros = cpuUsage.user - lastCpuUsage.user;
3487
- const systemUsageMicros = cpuUsage.system - lastCpuUsage.system;
3488
- lastCpuUsage = cpuUsage;
3489
- if (this.enableExemplars) {
3490
- let exemplarLabels = {};
3491
- const currentSpan = OtelApi.trace.getSpan(OtelApi.context.active());
3492
- if (currentSpan) exemplarLabels = {
3493
- traceId: currentSpan.spanContext().traceId,
3494
- spanId: currentSpan.spanContext().spanId
3495
- };
3496
- cpuUserUsageCounter.inc({
3497
- labels,
3498
- value: userUsageMicros / 1e6,
3499
- exemplarLabels
3500
- });
3501
- cpuSystemUsageCounter.inc({
3502
- labels,
3503
- value: systemUsageMicros / 1e6,
3504
- exemplarLabels
3505
- });
3506
- cpuUsageCounter.inc({
3507
- labels,
3508
- value: (userUsageMicros + systemUsageMicros) / 1e6,
3509
- exemplarLabels
3510
- });
3511
- } else {
3512
- cpuUserUsageCounter.inc(labels, userUsageMicros / 1e6);
3513
- cpuSystemUsageCounter.inc(labels, systemUsageMicros / 1e6);
3514
- cpuUsageCounter.inc(labels, (userUsageMicros + systemUsageMicros) / 1e6);
3515
- }
3516
- }
3517
- });
3518
- const cpuSystemUsageCounter = new Counter({
3519
- name: namePrefix + PROCESS_CPU_SYSTEM_SECONDS,
3520
- help: "Total system CPU time spent in seconds.",
3521
- enableExemplars: exemplars,
3522
- registers,
3523
- labelNames
3524
- });
3525
- const cpuUsageCounter = new Counter({
3526
- name: namePrefix + PROCESS_CPU_SECONDS,
3527
- help: "Total user and system CPU time spent in seconds.",
3528
- enableExemplars: exemplars,
3529
- registers,
3530
- labelNames
3531
- });
3532
- };
3533
- module.exports.metricNames = [
3534
- PROCESS_CPU_USER_SECONDS,
3535
- PROCESS_CPU_SYSTEM_SECONDS,
3536
- PROCESS_CPU_SECONDS
3537
- ];
3538
- }) });
3539
-
3540
- //#endregion
3541
- //#region ../../node_modules/prom-client/lib/metrics/processStartTime.js
3542
- var require_processStartTime = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processStartTime.js": ((exports, module) => {
3543
- const Gauge$11 = require_gauge();
3544
- const startInSeconds = Math.round(Date.now() / 1e3 - process.uptime());
3545
- const PROCESS_START_TIME = "process_start_time_seconds";
3546
- module.exports = (registry, config = {}) => {
3547
- const namePrefix = config.prefix ? config.prefix : "";
3548
- const labels = config.labels ? config.labels : {};
3549
- const labelNames = Object.keys(labels);
3550
- new Gauge$11({
3551
- name: namePrefix + PROCESS_START_TIME,
3552
- help: "Start time of the process since unix epoch in seconds.",
3553
- registers: registry ? [registry] : void 0,
3554
- labelNames,
3555
- aggregator: "omit",
3556
- collect() {
3557
- this.set(labels, startInSeconds);
3558
- }
3559
- });
3560
- };
3561
- module.exports.metricNames = [PROCESS_START_TIME];
3562
- }) });
3563
-
3564
- //#endregion
3565
- //#region ../../node_modules/prom-client/lib/metrics/osMemoryHeapLinux.js
3566
- var require_osMemoryHeapLinux = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/osMemoryHeapLinux.js": ((exports, module) => {
3567
- const Gauge$10 = require_gauge();
3568
- const fs$2 = require("fs");
3569
- const values = [
3570
- "VmSize",
3571
- "VmRSS",
3572
- "VmData"
3573
- ];
3574
- const PROCESS_RESIDENT_MEMORY$1 = "process_resident_memory_bytes";
3575
- const PROCESS_VIRTUAL_MEMORY = "process_virtual_memory_bytes";
3576
- const PROCESS_HEAP = "process_heap_bytes";
3577
- function structureOutput(input) {
3578
- return input.split("\n").reduce((acc, string) => {
3579
- if (!values.some((value$1) => string.startsWith(value$1))) return acc;
3580
- const split = string.split(":");
3581
- let value = split[1].trim();
3582
- value = value.substr(0, value.length - 3);
3583
- value = Number(value) * 1024;
3584
- acc[split[0]] = value;
3585
- return acc;
3586
- }, {});
3587
- }
3588
- module.exports = (registry, config = {}) => {
3589
- const registers = registry ? [registry] : void 0;
3590
- const namePrefix = config.prefix ? config.prefix : "";
3591
- const labels = config.labels ? config.labels : {};
3592
- const labelNames = Object.keys(labels);
3593
- const residentMemGauge = new Gauge$10({
3594
- name: namePrefix + PROCESS_RESIDENT_MEMORY$1,
3595
- help: "Resident memory size in bytes.",
3596
- registers,
3597
- labelNames,
3598
- collect() {
3599
- try {
3600
- const structuredOutput = structureOutput(fs$2.readFileSync("/proc/self/status", "utf8"));
3601
- residentMemGauge.set(labels, structuredOutput.VmRSS);
3602
- virtualMemGauge.set(labels, structuredOutput.VmSize);
3603
- heapSizeMemGauge.set(labels, structuredOutput.VmData);
3604
- } catch {}
3605
- }
3606
- });
3607
- const virtualMemGauge = new Gauge$10({
3608
- name: namePrefix + PROCESS_VIRTUAL_MEMORY,
3609
- help: "Virtual memory size in bytes.",
3610
- registers,
3611
- labelNames
3612
- });
3613
- const heapSizeMemGauge = new Gauge$10({
3614
- name: namePrefix + PROCESS_HEAP,
3615
- help: "Process heap size in bytes.",
3616
- registers,
3617
- labelNames
3618
- });
3619
- };
3620
- module.exports.metricNames = [
3621
- PROCESS_RESIDENT_MEMORY$1,
3622
- PROCESS_VIRTUAL_MEMORY,
3623
- PROCESS_HEAP
3624
- ];
3625
- }) });
3626
-
3627
- //#endregion
3628
- //#region ../../node_modules/prom-client/lib/metrics/helpers/safeMemoryUsage.js
3629
- var require_safeMemoryUsage = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/helpers/safeMemoryUsage.js": ((exports, module) => {
3630
- function safeMemoryUsage$2() {
3631
- try {
3632
- return process.memoryUsage();
3633
- } catch {
3634
- return;
3635
- }
3636
- }
3637
- module.exports = safeMemoryUsage$2;
3638
- }) });
3639
-
3640
- //#endregion
3641
- //#region ../../node_modules/prom-client/lib/metrics/osMemoryHeap.js
3642
- var require_osMemoryHeap = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/osMemoryHeap.js": ((exports, module) => {
3643
- const Gauge$9 = require_gauge();
3644
- const linuxVariant = require_osMemoryHeapLinux();
3645
- const safeMemoryUsage$1 = require_safeMemoryUsage();
3646
- const PROCESS_RESIDENT_MEMORY = "process_resident_memory_bytes";
3647
- function notLinuxVariant(registry, config = {}) {
3648
- const namePrefix = config.prefix ? config.prefix : "";
3649
- const labels = config.labels ? config.labels : {};
3650
- const labelNames = Object.keys(labels);
3651
- new Gauge$9({
3652
- name: namePrefix + PROCESS_RESIDENT_MEMORY,
3653
- help: "Resident memory size in bytes.",
3654
- registers: registry ? [registry] : void 0,
3655
- labelNames,
3656
- collect() {
3657
- const memUsage = safeMemoryUsage$1();
3658
- if (memUsage) this.set(labels, memUsage.rss);
3659
- }
3660
- });
3661
- }
3662
- module.exports = (registry, config) => process.platform === "linux" ? linuxVariant(registry, config) : notLinuxVariant(registry, config);
3663
- module.exports.metricNames = process.platform === "linux" ? linuxVariant.metricNames : [PROCESS_RESIDENT_MEMORY];
3664
- }) });
3665
-
3666
- //#endregion
3667
- //#region ../../node_modules/prom-client/lib/metrics/processOpenFileDescriptors.js
3668
- var require_processOpenFileDescriptors = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processOpenFileDescriptors.js": ((exports, module) => {
3669
- const Gauge$8 = require_gauge();
3670
- const fs$1 = require("fs");
3671
- const process$1 = require("process");
3672
- const PROCESS_OPEN_FDS = "process_open_fds";
3673
- module.exports = (registry, config = {}) => {
3674
- if (process$1.platform !== "linux") return;
3675
- const namePrefix = config.prefix ? config.prefix : "";
3676
- const labels = config.labels ? config.labels : {};
3677
- const labelNames = Object.keys(labels);
3678
- new Gauge$8({
3679
- name: namePrefix + PROCESS_OPEN_FDS,
3680
- help: "Number of open file descriptors.",
3681
- registers: registry ? [registry] : void 0,
3682
- labelNames,
3683
- collect() {
3684
- try {
3685
- const fds = fs$1.readdirSync("/proc/self/fd");
3686
- this.set(labels, fds.length - 1);
3687
- } catch {}
3688
- }
3689
- });
3690
- };
3691
- module.exports.metricNames = [PROCESS_OPEN_FDS];
3692
- }) });
3693
-
3694
- //#endregion
3695
- //#region ../../node_modules/prom-client/lib/metrics/processMaxFileDescriptors.js
3696
- var require_processMaxFileDescriptors = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processMaxFileDescriptors.js": ((exports, module) => {
3697
- const Gauge$7 = require_gauge();
3698
- const fs = require("fs");
3699
- const PROCESS_MAX_FDS = "process_max_fds";
3700
- let maxFds;
3701
- module.exports = (registry, config = {}) => {
3702
- if (maxFds === void 0) try {
3703
- const lines = fs.readFileSync("/proc/self/limits", "utf8").split("\n");
3704
- for (const line of lines) if (line.startsWith("Max open files")) {
3705
- const parts = line.split(/ +/);
3706
- maxFds = Number(parts[1]);
3707
- break;
3708
- }
3709
- } catch {
3710
- return;
3711
- }
3712
- if (maxFds === void 0) return;
3713
- const namePrefix = config.prefix ? config.prefix : "";
3714
- const labels = config.labels ? config.labels : {};
3715
- const labelNames = Object.keys(labels);
3716
- new Gauge$7({
3717
- name: namePrefix + PROCESS_MAX_FDS,
3718
- help: "Maximum number of open file descriptors.",
3719
- registers: registry ? [registry] : void 0,
3720
- labelNames,
3721
- collect() {
3722
- if (maxFds !== void 0) this.set(labels, maxFds);
3723
- }
3724
- });
3725
- };
3726
- module.exports.metricNames = [PROCESS_MAX_FDS];
3727
- }) });
3728
-
3729
- //#endregion
3730
- //#region ../../node_modules/prom-client/lib/metrics/eventLoopLag.js
3731
- var require_eventLoopLag = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/eventLoopLag.js": ((exports, module) => {
3732
- const Gauge$6 = require_gauge();
3733
- let perf_hooks$1;
3734
- try {
3735
- perf_hooks$1 = require("perf_hooks");
3736
- } catch {}
3737
- const NODEJS_EVENTLOOP_LAG = "nodejs_eventloop_lag_seconds";
3738
- const NODEJS_EVENTLOOP_LAG_MIN = "nodejs_eventloop_lag_min_seconds";
3739
- const NODEJS_EVENTLOOP_LAG_MAX = "nodejs_eventloop_lag_max_seconds";
3740
- const NODEJS_EVENTLOOP_LAG_MEAN = "nodejs_eventloop_lag_mean_seconds";
3741
- const NODEJS_EVENTLOOP_LAG_STDDEV = "nodejs_eventloop_lag_stddev_seconds";
3742
- const NODEJS_EVENTLOOP_LAG_P50 = "nodejs_eventloop_lag_p50_seconds";
3743
- const NODEJS_EVENTLOOP_LAG_P90 = "nodejs_eventloop_lag_p90_seconds";
3744
- const NODEJS_EVENTLOOP_LAG_P99 = "nodejs_eventloop_lag_p99_seconds";
3745
- function reportEventloopLag(start, gauge, labels) {
3746
- const delta = process.hrtime(start);
3747
- const seconds = (delta[0] * 1e9 + delta[1]) / 1e9;
3748
- gauge.set(labels, seconds);
3749
- }
3750
- module.exports = (registry, config = {}) => {
3751
- const namePrefix = config.prefix ? config.prefix : "";
3752
- const labels = config.labels ? config.labels : {};
3753
- const labelNames = Object.keys(labels);
3754
- const registers = registry ? [registry] : void 0;
3755
- let collect = () => {
3756
- const start = process.hrtime();
3757
- setImmediate(reportEventloopLag, start, lag, labels);
3758
- };
3759
- if (perf_hooks$1 && perf_hooks$1.monitorEventLoopDelay) try {
3760
- const histogram = perf_hooks$1.monitorEventLoopDelay({ resolution: config.eventLoopMonitoringPrecision });
3761
- histogram.enable();
3762
- collect = () => {
3763
- const start = process.hrtime();
3764
- setImmediate(reportEventloopLag, start, lag, labels);
3765
- lagMin.set(labels, histogram.min / 1e9);
3766
- lagMax.set(labels, histogram.max / 1e9);
3767
- lagMean.set(labels, histogram.mean / 1e9);
3768
- lagStddev.set(labels, histogram.stddev / 1e9);
3769
- lagP50.set(labels, histogram.percentile(50) / 1e9);
3770
- lagP90.set(labels, histogram.percentile(90) / 1e9);
3771
- lagP99.set(labels, histogram.percentile(99) / 1e9);
3772
- histogram.reset();
3773
- };
3774
- } catch (e) {
3775
- if (e.code === "ERR_NOT_IMPLEMENTED") return;
3776
- throw e;
3777
- }
3778
- const lag = new Gauge$6({
3779
- name: namePrefix + NODEJS_EVENTLOOP_LAG,
3780
- help: "Lag of event loop in seconds.",
3781
- registers,
3782
- labelNames,
3783
- aggregator: "average",
3784
- collect
3785
- });
3786
- const lagMin = new Gauge$6({
3787
- name: namePrefix + NODEJS_EVENTLOOP_LAG_MIN,
3788
- help: "The minimum recorded event loop delay.",
3789
- registers,
3790
- labelNames,
3791
- aggregator: "min"
3792
- });
3793
- const lagMax = new Gauge$6({
3794
- name: namePrefix + NODEJS_EVENTLOOP_LAG_MAX,
3795
- help: "The maximum recorded event loop delay.",
3796
- registers,
3797
- labelNames,
3798
- aggregator: "max"
3799
- });
3800
- const lagMean = new Gauge$6({
3801
- name: namePrefix + NODEJS_EVENTLOOP_LAG_MEAN,
3802
- help: "The mean of the recorded event loop delays.",
3803
- registers,
3804
- labelNames,
3805
- aggregator: "average"
3806
- });
3807
- const lagStddev = new Gauge$6({
3808
- name: namePrefix + NODEJS_EVENTLOOP_LAG_STDDEV,
3809
- help: "The standard deviation of the recorded event loop delays.",
3810
- registers,
3811
- labelNames,
3812
- aggregator: "average"
3813
- });
3814
- const lagP50 = new Gauge$6({
3815
- name: namePrefix + NODEJS_EVENTLOOP_LAG_P50,
3816
- help: "The 50th percentile of the recorded event loop delays.",
3817
- registers,
3818
- labelNames,
3819
- aggregator: "average"
3820
- });
3821
- const lagP90 = new Gauge$6({
3822
- name: namePrefix + NODEJS_EVENTLOOP_LAG_P90,
3823
- help: "The 90th percentile of the recorded event loop delays.",
3824
- registers,
3825
- labelNames,
3826
- aggregator: "average"
3827
- });
3828
- const lagP99 = new Gauge$6({
3829
- name: namePrefix + NODEJS_EVENTLOOP_LAG_P99,
3830
- help: "The 99th percentile of the recorded event loop delays.",
3831
- registers,
3832
- labelNames,
3833
- aggregator: "average"
3834
- });
3835
- };
3836
- module.exports.metricNames = [
3837
- NODEJS_EVENTLOOP_LAG,
3838
- NODEJS_EVENTLOOP_LAG_MIN,
3839
- NODEJS_EVENTLOOP_LAG_MAX,
3840
- NODEJS_EVENTLOOP_LAG_MEAN,
3841
- NODEJS_EVENTLOOP_LAG_STDDEV,
3842
- NODEJS_EVENTLOOP_LAG_P50,
3843
- NODEJS_EVENTLOOP_LAG_P90,
3844
- NODEJS_EVENTLOOP_LAG_P99
3845
- ];
3846
- }) });
3847
-
3848
- //#endregion
3849
- //#region ../../node_modules/prom-client/lib/metrics/helpers/processMetricsHelpers.js
3850
- var require_processMetricsHelpers = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/helpers/processMetricsHelpers.js": ((exports, module) => {
3851
- function aggregateByObjectName$2(list) {
3852
- const data = {};
3853
- for (let i = 0; i < list.length; i++) {
3854
- const listElement = list[i];
3855
- if (!listElement || typeof listElement.constructor === "undefined") continue;
3856
- if (Object.hasOwnProperty.call(data, listElement.constructor.name)) data[listElement.constructor.name] += 1;
3857
- else data[listElement.constructor.name] = 1;
3858
- }
3859
- return data;
3860
- }
3861
- function updateMetrics$3(gauge, data, labels) {
3862
- gauge.reset();
3863
- for (const key in data) gauge.set(Object.assign({ type: key }, labels || {}), data[key]);
3864
- }
3865
- module.exports = {
3866
- aggregateByObjectName: aggregateByObjectName$2,
3867
- updateMetrics: updateMetrics$3
3868
- };
3869
- }) });
3870
-
3871
- //#endregion
3872
- //#region ../../node_modules/prom-client/lib/metrics/processHandles.js
3873
- var require_processHandles = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processHandles.js": ((exports, module) => {
3874
- const { aggregateByObjectName: aggregateByObjectName$1 } = require_processMetricsHelpers();
3875
- const { updateMetrics: updateMetrics$2 } = require_processMetricsHelpers();
3876
- const Gauge$5 = require_gauge();
3877
- const NODEJS_ACTIVE_HANDLES = "nodejs_active_handles";
3878
- const NODEJS_ACTIVE_HANDLES_TOTAL = "nodejs_active_handles_total";
3879
- module.exports = (registry, config = {}) => {
3880
- if (typeof process._getActiveHandles !== "function") return;
3881
- const registers = registry ? [registry] : void 0;
3882
- const namePrefix = config.prefix ? config.prefix : "";
3883
- const labels = config.labels ? config.labels : {};
3884
- const labelNames = Object.keys(labels);
3885
- new Gauge$5({
3886
- name: namePrefix + NODEJS_ACTIVE_HANDLES,
3887
- help: "Number of active libuv handles grouped by handle type. Every handle type is C++ class name.",
3888
- labelNames: ["type", ...labelNames],
3889
- registers,
3890
- collect() {
3891
- const handles = process._getActiveHandles();
3892
- updateMetrics$2(this, aggregateByObjectName$1(handles), labels);
3893
- }
3894
- });
3895
- new Gauge$5({
3896
- name: namePrefix + NODEJS_ACTIVE_HANDLES_TOTAL,
3897
- help: "Total number of active handles.",
3898
- registers,
3899
- labelNames,
3900
- collect() {
3901
- const handles = process._getActiveHandles();
3902
- this.set(labels, handles.length);
3903
- }
3904
- });
3905
- };
3906
- module.exports.metricNames = [NODEJS_ACTIVE_HANDLES, NODEJS_ACTIVE_HANDLES_TOTAL];
3907
- }) });
3908
-
3909
- //#endregion
3910
- //#region ../../node_modules/prom-client/lib/metrics/processRequests.js
3911
- var require_processRequests = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processRequests.js": ((exports, module) => {
3912
- const Gauge$4 = require_gauge();
3913
- const { aggregateByObjectName } = require_processMetricsHelpers();
3914
- const { updateMetrics: updateMetrics$1 } = require_processMetricsHelpers();
3915
- const NODEJS_ACTIVE_REQUESTS = "nodejs_active_requests";
3916
- const NODEJS_ACTIVE_REQUESTS_TOTAL = "nodejs_active_requests_total";
3917
- module.exports = (registry, config = {}) => {
3918
- if (typeof process._getActiveRequests !== "function") return;
3919
- const namePrefix = config.prefix ? config.prefix : "";
3920
- const labels = config.labels ? config.labels : {};
3921
- const labelNames = Object.keys(labels);
3922
- new Gauge$4({
3923
- name: namePrefix + NODEJS_ACTIVE_REQUESTS,
3924
- help: "Number of active libuv requests grouped by request type. Every request type is C++ class name.",
3925
- labelNames: ["type", ...labelNames],
3926
- registers: registry ? [registry] : void 0,
3927
- collect() {
3928
- const requests$1 = process._getActiveRequests();
3929
- updateMetrics$1(this, aggregateByObjectName(requests$1), labels);
3930
- }
3931
- });
3932
- new Gauge$4({
3933
- name: namePrefix + NODEJS_ACTIVE_REQUESTS_TOTAL,
3934
- help: "Total number of active requests.",
3935
- registers: registry ? [registry] : void 0,
3936
- labelNames,
3937
- collect() {
3938
- const requests$1 = process._getActiveRequests();
3939
- this.set(labels, requests$1.length);
3940
- }
3941
- });
3942
- };
3943
- module.exports.metricNames = [NODEJS_ACTIVE_REQUESTS, NODEJS_ACTIVE_REQUESTS_TOTAL];
3944
- }) });
3945
-
3946
- //#endregion
3947
- //#region ../../node_modules/prom-client/lib/metrics/processResources.js
3948
- var require_processResources = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/processResources.js": ((exports, module) => {
3949
- const Gauge$3 = require_gauge();
3950
- const { updateMetrics } = require_processMetricsHelpers();
3951
- const NODEJS_ACTIVE_RESOURCES = "nodejs_active_resources";
3952
- const NODEJS_ACTIVE_RESOURCES_TOTAL = "nodejs_active_resources_total";
3953
- module.exports = (registry, config = {}) => {
3954
- if (typeof process.getActiveResourcesInfo !== "function") return;
3955
- const namePrefix = config.prefix ? config.prefix : "";
3956
- const labels = config.labels ? config.labels : {};
3957
- const labelNames = Object.keys(labels);
3958
- new Gauge$3({
3959
- name: namePrefix + NODEJS_ACTIVE_RESOURCES,
3960
- help: "Number of active resources that are currently keeping the event loop alive, grouped by async resource type.",
3961
- labelNames: ["type", ...labelNames],
3962
- registers: registry ? [registry] : void 0,
3963
- collect() {
3964
- const resources = process.getActiveResourcesInfo();
3965
- const data = {};
3966
- for (let i = 0; i < resources.length; i++) {
3967
- const resource = resources[i];
3968
- if (Object.hasOwn(data, resource)) data[resource] += 1;
3969
- else data[resource] = 1;
3970
- }
3971
- updateMetrics(this, data, labels);
3972
- }
3973
- });
3974
- new Gauge$3({
3975
- name: namePrefix + NODEJS_ACTIVE_RESOURCES_TOTAL,
3976
- help: "Total number of active resources.",
3977
- registers: registry ? [registry] : void 0,
3978
- labelNames,
3979
- collect() {
3980
- const resources = process.getActiveResourcesInfo();
3981
- this.set(labels, resources.length);
3982
- }
3983
- });
3984
- };
3985
- module.exports.metricNames = [NODEJS_ACTIVE_RESOURCES, NODEJS_ACTIVE_RESOURCES_TOTAL];
3986
- }) });
3987
-
3988
- //#endregion
3989
- //#region ../../node_modules/prom-client/lib/metrics/heapSizeAndUsed.js
3990
- var require_heapSizeAndUsed = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/heapSizeAndUsed.js": ((exports, module) => {
3991
- const Gauge$2 = require_gauge();
3992
- const safeMemoryUsage = require_safeMemoryUsage();
3993
- const NODEJS_HEAP_SIZE_TOTAL = "nodejs_heap_size_total_bytes";
3994
- const NODEJS_HEAP_SIZE_USED = "nodejs_heap_size_used_bytes";
3995
- const NODEJS_EXTERNAL_MEMORY = "nodejs_external_memory_bytes";
3996
- module.exports = (registry, config = {}) => {
3997
- if (typeof process.memoryUsage !== "function") return;
3998
- const labels = config.labels ? config.labels : {};
3999
- const labelNames = Object.keys(labels);
4000
- const registers = registry ? [registry] : void 0;
4001
- const namePrefix = config.prefix ? config.prefix : "";
4002
- const collect = () => {
4003
- const memUsage = safeMemoryUsage();
4004
- if (memUsage) {
4005
- heapSizeTotal.set(labels, memUsage.heapTotal);
4006
- heapSizeUsed.set(labels, memUsage.heapUsed);
4007
- if (memUsage.external !== void 0) externalMemUsed.set(labels, memUsage.external);
4008
- }
4009
- };
4010
- const heapSizeTotal = new Gauge$2({
4011
- name: namePrefix + NODEJS_HEAP_SIZE_TOTAL,
4012
- help: "Process heap size from Node.js in bytes.",
4013
- registers,
4014
- labelNames,
4015
- collect
4016
- });
4017
- const heapSizeUsed = new Gauge$2({
4018
- name: namePrefix + NODEJS_HEAP_SIZE_USED,
4019
- help: "Process heap size used from Node.js in bytes.",
4020
- registers,
4021
- labelNames
4022
- });
4023
- const externalMemUsed = new Gauge$2({
4024
- name: namePrefix + NODEJS_EXTERNAL_MEMORY,
4025
- help: "Node.js external memory size in bytes.",
4026
- registers,
4027
- labelNames
4028
- });
4029
- };
4030
- module.exports.metricNames = [
4031
- NODEJS_HEAP_SIZE_TOTAL,
4032
- NODEJS_HEAP_SIZE_USED,
4033
- NODEJS_EXTERNAL_MEMORY
4034
- ];
4035
- }) });
4036
-
4037
- //#endregion
4038
- //#region ../../node_modules/prom-client/lib/metrics/heapSpacesSizeAndUsed.js
4039
- var require_heapSpacesSizeAndUsed = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/heapSpacesSizeAndUsed.js": ((exports, module) => {
4040
- const Gauge$1 = require_gauge();
4041
- const v8 = require("v8");
4042
- const METRICS = [
4043
- "total",
4044
- "used",
4045
- "available"
4046
- ];
4047
- const NODEJS_HEAP_SIZE = {};
4048
- METRICS.forEach((metricType) => {
4049
- NODEJS_HEAP_SIZE[metricType] = `nodejs_heap_space_size_${metricType}_bytes`;
4050
- });
4051
- module.exports = (registry, config = {}) => {
4052
- try {
4053
- v8.getHeapSpaceStatistics();
4054
- } catch (e) {
4055
- if (e.code === "ERR_NOT_IMPLEMENTED") return;
4056
- throw e;
4057
- }
4058
- const registers = registry ? [registry] : void 0;
4059
- const namePrefix = config.prefix ? config.prefix : "";
4060
- const labels = config.labels ? config.labels : {};
4061
- const labelNames = ["space", ...Object.keys(labels)];
4062
- const gauges = {};
4063
- METRICS.forEach((metricType) => {
4064
- gauges[metricType] = new Gauge$1({
4065
- name: namePrefix + NODEJS_HEAP_SIZE[metricType],
4066
- help: `Process heap space size ${metricType} from Node.js in bytes.`,
4067
- labelNames,
4068
- registers
4069
- });
4070
- });
4071
- gauges.total.collect = () => {
4072
- for (const space of v8.getHeapSpaceStatistics()) {
4073
- const spaceName = space.space_name.substr(0, space.space_name.indexOf("_space"));
4074
- gauges.total.set({
4075
- space: spaceName,
4076
- ...labels
4077
- }, space.space_size);
4078
- gauges.used.set({
4079
- space: spaceName,
4080
- ...labels
4081
- }, space.space_used_size);
4082
- gauges.available.set({
4083
- space: spaceName,
4084
- ...labels
4085
- }, space.space_available_size);
4086
- }
4087
- };
4088
- };
4089
- module.exports.metricNames = Object.values(NODEJS_HEAP_SIZE);
4090
- }) });
4091
-
4092
- //#endregion
4093
- //#region ../../node_modules/prom-client/lib/metrics/version.js
4094
- var require_version = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/version.js": ((exports, module) => {
4095
- const Gauge = require_gauge();
4096
- const version$1 = process.version;
4097
- const versionSegments = version$1.slice(1).split(".").map(Number);
4098
- const NODE_VERSION_INFO = "nodejs_version_info";
4099
- module.exports = (registry, config = {}) => {
4100
- const namePrefix = config.prefix ? config.prefix : "";
4101
- const labels = config.labels ? config.labels : {};
4102
- const labelNames = Object.keys(labels);
4103
- new Gauge({
4104
- name: namePrefix + NODE_VERSION_INFO,
4105
- help: "Node.js version info.",
4106
- labelNames: [
4107
- "version",
4108
- "major",
4109
- "minor",
4110
- "patch",
4111
- ...labelNames
4112
- ],
4113
- registers: registry ? [registry] : void 0,
4114
- aggregator: "first",
4115
- collect() {
4116
- this.labels(version$1, versionSegments[0], versionSegments[1], versionSegments[2], ...Object.values(labels)).set(1);
4117
- }
4118
- });
4119
- };
4120
- module.exports.metricNames = [NODE_VERSION_INFO];
4121
- }) });
4122
-
4123
- //#endregion
4124
- //#region ../../node_modules/prom-client/lib/metrics/gc.js
4125
- var require_gc = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metrics/gc.js": ((exports, module) => {
4126
- const Histogram$1 = require_histogram();
4127
- let perf_hooks;
4128
- try {
4129
- perf_hooks = require("perf_hooks");
4130
- } catch {}
4131
- const NODEJS_GC_DURATION_SECONDS = "nodejs_gc_duration_seconds";
4132
- const DEFAULT_GC_DURATION_BUCKETS = [
4133
- .001,
4134
- .01,
4135
- .1,
4136
- 1,
4137
- 2,
4138
- 5
4139
- ];
4140
- const kinds = [];
4141
- if (perf_hooks && perf_hooks.constants) {
4142
- kinds[perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR] = "major";
4143
- kinds[perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR] = "minor";
4144
- kinds[perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL] = "incremental";
4145
- kinds[perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB] = "weakcb";
4146
- }
4147
- module.exports = (registry, config = {}) => {
4148
- if (!perf_hooks) return;
4149
- const namePrefix = config.prefix ? config.prefix : "";
4150
- const labels = config.labels ? config.labels : {};
4151
- const labelNames = Object.keys(labels);
4152
- const buckets = config.gcDurationBuckets ? config.gcDurationBuckets : DEFAULT_GC_DURATION_BUCKETS;
4153
- const gcHistogram = new Histogram$1({
4154
- name: namePrefix + NODEJS_GC_DURATION_SECONDS,
4155
- help: "Garbage collection duration by kind, one of major, minor, incremental or weakcb.",
4156
- labelNames: ["kind", ...labelNames],
4157
- enableExemplars: false,
4158
- buckets,
4159
- registers: registry ? [registry] : void 0
4160
- });
4161
- new perf_hooks.PerformanceObserver((list) => {
4162
- const entry = list.getEntries()[0];
4163
- const kind = entry.detail ? kinds[entry.detail.kind] : kinds[entry.kind];
4164
- gcHistogram.observe(Object.assign({ kind }, labels), entry.duration / 1e3);
4165
- }).observe({ entryTypes: ["gc"] });
4166
- };
4167
- module.exports.metricNames = [NODEJS_GC_DURATION_SECONDS];
4168
- }) });
4169
-
4170
- //#endregion
4171
- //#region ../../node_modules/prom-client/lib/defaultMetrics.js
4172
- var require_defaultMetrics = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/defaultMetrics.js": ((exports, module) => {
4173
- const { isObject } = require_util();
4174
- const processCpuTotal = require_processCpuTotal();
4175
- const processStartTime = require_processStartTime();
4176
- const osMemoryHeap = require_osMemoryHeap();
4177
- const processOpenFileDescriptors = require_processOpenFileDescriptors();
4178
- const processMaxFileDescriptors = require_processMaxFileDescriptors();
4179
- const eventLoopLag = require_eventLoopLag();
4180
- const processHandles = require_processHandles();
4181
- const processRequests = require_processRequests();
4182
- const processResources = require_processResources();
4183
- const heapSizeAndUsed = require_heapSizeAndUsed();
4184
- const heapSpacesSizeAndUsed = require_heapSpacesSizeAndUsed();
4185
- const version = require_version();
4186
- const gc = require_gc();
4187
- const metrics = {
4188
- processCpuTotal,
4189
- processStartTime,
4190
- osMemoryHeap,
4191
- processOpenFileDescriptors,
4192
- processMaxFileDescriptors,
4193
- eventLoopLag,
4194
- ...typeof process.getActiveResourcesInfo === "function" ? { processResources } : {},
4195
- processHandles,
4196
- processRequests,
4197
- heapSizeAndUsed,
4198
- heapSpacesSizeAndUsed,
4199
- version,
4200
- gc
4201
- };
4202
- const metricsList = Object.keys(metrics);
4203
- module.exports = function collectDefaultMetrics$1(config) {
4204
- if (config !== null && config !== void 0 && !isObject(config)) throw new TypeError("config must be null, undefined, or an object");
4205
- config = {
4206
- eventLoopMonitoringPrecision: 10,
4207
- ...config
4208
- };
4209
- for (const metric of Object.values(metrics)) metric(config.register, config);
4210
- };
4211
- module.exports.metricsList = metricsList;
4212
- }) });
4213
-
4214
- //#endregion
4215
- //#region ../../node_modules/prom-client/lib/metricAggregators.js
4216
- var require_metricAggregators = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/metricAggregators.js": ((exports) => {
4217
- const { Grouper: Grouper$1, hashObject } = require_util();
4218
- /**
4219
- * Returns a new function that applies the `aggregatorFn` to the values.
4220
- * @param {Function} aggregatorFn function to apply to values.
4221
- * @return {Function} aggregator function
4222
- */
4223
- function AggregatorFactory(aggregatorFn) {
4224
- return (metrics$2) => {
4225
- if (metrics$2.length === 0) return;
4226
- const result = {
4227
- help: metrics$2[0].help,
4228
- name: metrics$2[0].name,
4229
- type: metrics$2[0].type,
4230
- values: [],
4231
- aggregator: metrics$2[0].aggregator
4232
- };
4233
- const byLabels = new Grouper$1();
4234
- metrics$2.forEach((metric) => {
4235
- metric.values.forEach((value) => {
4236
- const key = hashObject(value.labels);
4237
- byLabels.add(`${value.metricName}_${key}`, value);
4238
- });
4239
- });
4240
- byLabels.forEach((values$1) => {
4241
- if (values$1.length === 0) return;
4242
- const valObj = {
4243
- value: aggregatorFn(values$1),
4244
- labels: values$1[0].labels
4245
- };
4246
- if (values$1[0].metricName) valObj.metricName = values$1[0].metricName;
4247
- result.values.push(valObj);
4248
- });
4249
- return result;
4250
- };
4251
- }
4252
- exports.AggregatorFactory = AggregatorFactory;
4253
- /**
4254
- * Functions that can be used to aggregate metrics from multiple registries.
4255
- */
4256
- exports.aggregators = {
4257
- sum: AggregatorFactory((v) => v.reduce((p, c) => p + c.value, 0)),
4258
- first: AggregatorFactory((v) => v[0].value),
4259
- omit: () => {},
4260
- average: AggregatorFactory((v) => v.reduce((p, c) => p + c.value, 0) / v.length),
4261
- min: AggregatorFactory((v) => v.reduce((p, c) => Math.min(p, c.value), Infinity)),
4262
- max: AggregatorFactory((v) => v.reduce((p, c) => Math.max(p, c.value), -Infinity))
4263
- };
4264
- }) });
4265
-
4266
- //#endregion
4267
- //#region ../../node_modules/prom-client/lib/cluster.js
4268
- var require_cluster = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/lib/cluster.js": ((exports, module) => {
4269
- /**
4270
- * Extends the Registry class with a `clusterMetrics` method that returns
4271
- * aggregated metrics for all workers.
4272
- *
4273
- * In cluster workers, listens for and responds to requests for metrics by the
4274
- * cluster master.
4275
- */
4276
- const Registry$1 = require_registry();
4277
- const { Grouper } = require_util();
4278
- const { aggregators } = require_metricAggregators();
4279
- let cluster = () => {
4280
- const data = require("cluster");
4281
- cluster = () => data;
4282
- return data;
4283
- };
4284
- const GET_METRICS_REQ = "prom-client:getMetricsReq";
4285
- const GET_METRICS_RES = "prom-client:getMetricsRes";
4286
- let registries = [Registry$1.globalRegistry];
4287
- let requestCtr = 0;
4288
- let listenersAdded = false;
4289
- const requests = /* @__PURE__ */ new Map();
4290
- var AggregatorRegistry = class extends Registry$1 {
4291
- constructor(regContentType = Registry$1.PROMETHEUS_CONTENT_TYPE) {
4292
- super(regContentType);
4293
- addListeners();
4294
- }
4295
- /**
4296
- * Gets aggregated metrics for all workers. The optional callback and
4297
- * returned Promise resolve with the same value; either may be used.
4298
- * @return {Promise<string>} Promise that resolves with the aggregated
4299
- * metrics.
4300
- */
4301
- clusterMetrics() {
4302
- const requestId = requestCtr++;
4303
- return new Promise((resolve, reject) => {
4304
- let settled = false;
4305
- function done(err, result) {
4306
- if (settled) return;
4307
- settled = true;
4308
- if (err) reject(err);
4309
- else resolve(result);
4310
- }
4311
- const request = {
4312
- responses: [],
4313
- pending: 0,
4314
- done,
4315
- errorTimeout: setTimeout(() => {
4316
- const err = /* @__PURE__ */ new Error("Operation timed out.");
4317
- request.done(err);
4318
- }, 5e3)
4319
- };
4320
- requests.set(requestId, request);
4321
- const message = {
4322
- type: GET_METRICS_REQ,
4323
- requestId
4324
- };
4325
- for (const id in cluster().workers) if (cluster().workers[id].isConnected()) {
4326
- cluster().workers[id].send(message);
4327
- request.pending++;
4328
- }
4329
- if (request.pending === 0) {
4330
- clearTimeout(request.errorTimeout);
4331
- process.nextTick(() => done(null, ""));
4332
- }
4333
- });
4334
- }
4335
- get contentType() {
4336
- return super.contentType;
4337
- }
4338
- /**
4339
- * Creates a new Registry instance from an array of metrics that were
4340
- * created by `registry.getMetricsAsJSON()`. Metrics are aggregated using
4341
- * the method specified by their `aggregator` property, or by summation if
4342
- * `aggregator` is undefined.
4343
- * @param {Array} metricsArr Array of metrics, each of which created by
4344
- * `registry.getMetricsAsJSON()`.
4345
- * @param {string} registryType content type of the new registry. Defaults
4346
- * to PROMETHEUS_CONTENT_TYPE.
4347
- * @return {Registry} aggregated registry.
4348
- */
4349
- static aggregate(metricsArr, registryType = Registry$1.PROMETHEUS_CONTENT_TYPE) {
4350
- const aggregatedRegistry = new Registry$1();
4351
- const metricsByName = new Grouper();
4352
- aggregatedRegistry.setContentType(registryType);
4353
- metricsArr.forEach((metrics$2) => {
4354
- metrics$2.forEach((metric) => {
4355
- metricsByName.add(metric.name, metric);
4356
- });
4357
- });
4358
- metricsByName.forEach((metrics$2) => {
4359
- const aggregatorName = metrics$2[0].aggregator;
4360
- const aggregatorFn = aggregators[aggregatorName];
4361
- if (typeof aggregatorFn !== "function") throw new Error(`'${aggregatorName}' is not a defined aggregator.`);
4362
- const aggregatedMetric = aggregatorFn(metrics$2);
4363
- if (aggregatedMetric) {
4364
- const aggregatedMetricWrapper = Object.assign({ get: () => aggregatedMetric }, aggregatedMetric);
4365
- aggregatedRegistry.registerMetric(aggregatedMetricWrapper);
4366
- }
4367
- });
4368
- return aggregatedRegistry;
4369
- }
4370
- /**
4371
- * Sets the registry or registries to be aggregated. Call from workers to
4372
- * use a registry/registries other than the default global registry.
4373
- * @param {Array<Registry>|Registry} regs Registry or registries to be
4374
- * aggregated.
4375
- * @return {void}
4376
- */
4377
- static setRegistries(regs) {
4378
- if (!Array.isArray(regs)) regs = [regs];
4379
- regs.forEach((reg) => {
4380
- if (!(reg instanceof Registry$1)) throw new TypeError(`Expected Registry, got ${typeof reg}`);
4381
- });
4382
- registries = regs;
4383
- }
4384
- };
4385
- /**
4386
- * Adds event listeners for cluster aggregation. Idempotent (safe to call more
4387
- * than once).
4388
- * @return {void}
4389
- */
4390
- function addListeners() {
4391
- if (listenersAdded) return;
4392
- listenersAdded = true;
4393
- if (cluster().isMaster) cluster().on("message", (worker, message) => {
4394
- if (message.type === GET_METRICS_RES) {
4395
- const request = requests.get(message.requestId);
4396
- if (message.error) {
4397
- request.done(new Error(message.error));
4398
- return;
4399
- }
4400
- message.metrics.forEach((registry) => request.responses.push(registry));
4401
- request.pending--;
4402
- if (request.pending === 0) {
4403
- requests.delete(message.requestId);
4404
- clearTimeout(request.errorTimeout);
4405
- const promString = AggregatorRegistry.aggregate(request.responses).metrics();
4406
- request.done(null, promString);
4407
- }
4408
- }
4409
- });
4410
- if (cluster().isWorker) process.on("message", (message) => {
4411
- if (message.type === GET_METRICS_REQ) Promise.all(registries.map((r) => r.getMetricsAsJSON())).then((metrics$2) => {
4412
- process.send({
4413
- type: GET_METRICS_RES,
4414
- requestId: message.requestId,
4415
- metrics: metrics$2
4416
- });
4417
- }).catch((error) => {
4418
- process.send({
4419
- type: GET_METRICS_RES,
4420
- requestId: message.requestId,
4421
- error: error.message
4422
- });
4423
- });
4424
- });
4425
- }
4426
- module.exports = AggregatorRegistry;
4427
- }) });
4428
-
4429
- //#endregion
4430
- //#region ../../node_modules/prom-client/index.js
4431
- /**
4432
- * Prometheus client
4433
- * @module Prometheus client
4434
- */
4435
- var require_prom_client = /* @__PURE__ */ __commonJS({ "../../node_modules/prom-client/index.js": ((exports) => {
4436
- exports.register = require_registry().globalRegistry;
4437
- exports.Registry = require_registry();
4438
- Object.defineProperty(exports, "contentType", {
4439
- configurable: false,
4440
- enumerable: true,
4441
- get() {
4442
- return exports.register.contentType;
4443
- },
4444
- set(value) {
4445
- exports.register.setContentType(value);
4446
- }
4447
- });
4448
- exports.prometheusContentType = exports.Registry.PROMETHEUS_CONTENT_TYPE;
4449
- exports.openMetricsContentType = exports.Registry.OPENMETRICS_CONTENT_TYPE;
4450
- exports.validateMetricName = require_validation().validateMetricName;
4451
- exports.Counter = require_counter();
4452
- exports.Gauge = require_gauge();
4453
- exports.Histogram = require_histogram();
4454
- exports.Summary = require_summary();
4455
- exports.Pushgateway = require_pushgateway();
4456
- exports.linearBuckets = require_bucketGenerators().linearBuckets;
4457
- exports.exponentialBuckets = require_bucketGenerators().exponentialBuckets;
4458
- exports.collectDefaultMetrics = require_defaultMetrics();
4459
- exports.aggregators = require_metricAggregators().aggregators;
4460
- exports.AggregatorRegistry = require_cluster();
4461
- }) });
4462
-
4463
- //#endregion
4464
- //#region src/server-metrics/providers/ServerMetricsProvider.ts
4465
- var import_prom_client = require_prom_client();
4466
- var ServerMetricsProvider = class {
4467
- register = new import_prom_client.Registry();
4468
- alepha = (0, alepha.$inject)(alepha.Alepha);
4469
- httpRequestDuration;
4470
- options = {};
4471
- metrics = (0, alepha_server.$route)({
4472
- method: "GET",
4473
- path: "/metrics",
4474
- silent: true,
4475
- handler: () => this.register.metrics()
4476
- });
4477
- onStart = (0, alepha.$hook)({
4478
- on: "start",
4479
- handler: () => {
4480
- (0, import_prom_client.collectDefaultMetrics)({
4481
- register: this.register,
4482
- ...this.options
4483
- });
4484
- this.httpRequestDuration = new import_prom_client.Histogram({
4485
- name: "http_request_duration_seconds",
4486
- help: "Duration of HTTP requests in seconds",
4487
- labelNames: [
4488
- "method",
4489
- "path",
4490
- "code"
4491
- ],
4492
- registers: [this.register]
4493
- });
4494
- }
4495
- });
4496
- onRequest = (0, alepha.$hook)({
4497
- on: "server:onRequest",
4498
- priority: "first",
4499
- handler: ({ request }) => {
4500
- const end = this.httpRequestDuration?.startTimer();
4501
- request.metadata.metricsTimer = end;
4502
- }
4503
- });
4504
- onResponse = (0, alepha.$hook)({
4505
- on: "server:onResponse",
4506
- priority: "last",
4507
- handler: ({ request, response, route }) => {
4508
- const timerEnd = request.metadata.metricsTimer;
4509
- if (timerEnd) timerEnd({
4510
- method: request.method,
4511
- path: route.path,
4512
- code: response.status
4513
- });
4514
- }
4515
- });
4516
- };
4517
-
4518
- //#endregion
4519
- //#region src/server-metrics/index.ts
4520
- /**
4521
- * This module provides prometheus metrics for the Alepha server.
4522
- * Metrics are exposed at the `/metrics` endpoint.
4523
- *
4524
- * @see {@link ServerMetricsProvider}
4525
- * @module alepha.server.metrics
4526
- */
4527
- const AlephaServerMetrics = (0, alepha.$module)({
4528
- name: "alepha.server.metrics",
4529
- services: [alepha_server.AlephaServer, ServerMetricsProvider]
4530
- });
4531
-
4532
- //#endregion
4533
- exports.AlephaServerMetrics = AlephaServerMetrics;
4534
- exports.ServerMetricsProvider = ServerMetricsProvider;
4535
- //# sourceMappingURL=index.cjs.map