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