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