@grow-codes/grafana-loki 0.1.0 → 0.2.0
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/AGENTS.md +53 -0
- package/lib/{chunk-553Q2KB5.cjs → chunk-VGAJJR3M.cjs} +2 -2
- package/lib/{chunk-553Q2KB5.cjs.map → chunk-VGAJJR3M.cjs.map} +1 -1
- package/lib/{chunk-KTHP35QG.js → chunk-ZH5T5C4R.js} +2 -2
- package/lib/{chunk-KTHP35QG.js.map → chunk-ZH5T5C4R.js.map} +1 -1
- package/lib/index.cjs +391 -142
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +124 -6
- package/lib/index.d.ts +124 -6
- package/lib/index.js +257 -15
- package/lib/index.js.map +1 -1
- package/lib/{query-CofVHbt1.d.cts → query-BYQW0k9P.d.cts} +2 -2
- package/lib/{query-CofVHbt1.d.ts → query-BYQW0k9P.d.ts} +2 -2
- package/lib/testing/index.cjs +14 -14
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.js +1 -1
- package/lib/testing/index.js.map +1 -1
- package/package.json +2 -1
package/lib/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVGAJJR3M_cjs = require('./chunk-VGAJJR3M.cjs');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var undici = require('undici');
|
|
6
6
|
var zlib = require('zlib');
|
|
7
7
|
var api = require('@opentelemetry/api');
|
|
8
8
|
var stream = require('stream');
|
|
9
|
+
var async_hooks = require('async_hooks');
|
|
10
|
+
var crypto = require('crypto');
|
|
9
11
|
var snappyjs = require('snappyjs');
|
|
10
12
|
var WebSocket = require('ws');
|
|
11
13
|
|
|
@@ -106,7 +108,7 @@ function redactUrl(url) {
|
|
|
106
108
|
}
|
|
107
109
|
function redactQueryString(text) {
|
|
108
110
|
return text.replace(
|
|
109
|
-
/([?&])([
|
|
111
|
+
/([?&])([^=&#?\s]+)=([^&#\s]*)/g,
|
|
110
112
|
(m, sep, k) => isSensitiveField(k) ? `${sep}${k}=${REDACTED}` : m
|
|
111
113
|
);
|
|
112
114
|
}
|
|
@@ -211,20 +213,33 @@ var UNIT_MS = {
|
|
|
211
213
|
m: 6e4,
|
|
212
214
|
h: 36e5
|
|
213
215
|
};
|
|
214
|
-
var
|
|
216
|
+
var DURATION_UNITS = ["ns", "us", "\xB5s", "ms", "s", "m", "h"];
|
|
215
217
|
function parseDuration(raw) {
|
|
216
218
|
const text = raw.trim();
|
|
217
219
|
if (/^\d+$/.test(text)) return Number(text);
|
|
218
220
|
if (text === "") return void 0;
|
|
219
|
-
DURATION_PART.lastIndex = 0;
|
|
220
221
|
let total = 0;
|
|
221
|
-
let
|
|
222
|
-
|
|
223
|
-
while (
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
let i = 0;
|
|
223
|
+
const isDigit = (at) => at < text.length && text.charCodeAt(at) >= 48 && text.charCodeAt(at) <= 57;
|
|
224
|
+
while (i < text.length) {
|
|
225
|
+
const start = i;
|
|
226
|
+
while (isDigit(i)) i += 1;
|
|
227
|
+
const intDigits = i - start;
|
|
228
|
+
if (text[i] === ".") {
|
|
229
|
+
i += 1;
|
|
230
|
+
const fracStart = i;
|
|
231
|
+
while (isDigit(i)) i += 1;
|
|
232
|
+
if (i === fracStart) return void 0;
|
|
233
|
+
} else if (intDigits === 0) {
|
|
234
|
+
return void 0;
|
|
235
|
+
}
|
|
236
|
+
const value = Number(text.slice(start, i));
|
|
237
|
+
const unit = DURATION_UNITS.find((u) => text.startsWith(u, i));
|
|
238
|
+
if (unit === void 0) return void 0;
|
|
239
|
+
total += value * UNIT_MS[unit];
|
|
240
|
+
i += unit.length;
|
|
226
241
|
}
|
|
227
|
-
return
|
|
242
|
+
return Math.round(total);
|
|
228
243
|
}
|
|
229
244
|
var TRUE_WORDS = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
230
245
|
var FALSE_WORDS = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
|
|
@@ -284,7 +299,7 @@ var EnvReader = class {
|
|
|
284
299
|
if (hit === void 0) return void 0;
|
|
285
300
|
const value = parse(hit.value);
|
|
286
301
|
if (value === void 0) {
|
|
287
|
-
throw new
|
|
302
|
+
throw new chunkVGAJJR3M_cjs.ConfigError(
|
|
288
303
|
`invalid value in environment variable ${hit.name}: expected ${expected}`
|
|
289
304
|
);
|
|
290
305
|
}
|
|
@@ -323,14 +338,14 @@ async function probeHealth(probe) {
|
|
|
323
338
|
try {
|
|
324
339
|
return await probe();
|
|
325
340
|
} catch (err) {
|
|
326
|
-
if (err instanceof
|
|
327
|
-
if (err.code ===
|
|
341
|
+
if (err instanceof chunkVGAJJR3M_cjs.LokiError) {
|
|
342
|
+
if (err.code === chunkVGAJJR3M_cjs.ErrorCode.Cancelled || err.code === chunkVGAJJR3M_cjs.ErrorCode.Config) throw err;
|
|
328
343
|
if (err.httpStatus !== void 0) {
|
|
329
344
|
return healthStatus("unhealthy", { httpStatus: err.httpStatus, error: err.code }, false);
|
|
330
345
|
}
|
|
331
346
|
return healthStatus("unreachable", { error: err.code }, false);
|
|
332
347
|
}
|
|
333
|
-
return healthStatus("unreachable", { error:
|
|
348
|
+
return healthStatus("unreachable", { error: chunkVGAJJR3M_cjs.ErrorCode.Unavailable }, false);
|
|
334
349
|
}
|
|
335
350
|
}
|
|
336
351
|
|
|
@@ -520,7 +535,7 @@ function validateCommonConfig(config) {
|
|
|
520
535
|
if (config.proxy !== void 0 && !isHttpUrl(config.proxy)) {
|
|
521
536
|
problems.push("proxy must be an http or https URL");
|
|
522
537
|
}
|
|
523
|
-
if (problems.length > 0) throw new
|
|
538
|
+
if (problems.length > 0) throw new chunkVGAJJR3M_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
|
|
524
539
|
}
|
|
525
540
|
function readCommonEnv(reader, vendor = {}) {
|
|
526
541
|
const out = {};
|
|
@@ -595,10 +610,10 @@ function secretValues(...values) {
|
|
|
595
610
|
}
|
|
596
611
|
|
|
597
612
|
// src/core/version.ts
|
|
598
|
-
var SDK_VERSION = "0.
|
|
613
|
+
var SDK_VERSION = "0.2.0";
|
|
599
614
|
var PACKAGE_KEY = "grafana-loki";
|
|
600
615
|
var LANGUAGE = "typescript";
|
|
601
|
-
var SDK_KIT_VERSION = "0.
|
|
616
|
+
var SDK_KIT_VERSION = "0.3.0";
|
|
602
617
|
|
|
603
618
|
// src/core/transport.ts
|
|
604
619
|
var DEFAULT_REQUEST_ID_HEADERS = [
|
|
@@ -688,7 +703,7 @@ var HttpTransport = class {
|
|
|
688
703
|
this.#logger = safeLogger(options.config.logger);
|
|
689
704
|
this.#hooks = options.config.hooks ?? {};
|
|
690
705
|
this.#fetch = undici.fetch;
|
|
691
|
-
this.#sleep = options.sleep ??
|
|
706
|
+
this.#sleep = options.sleep ?? chunkVGAJJR3M_cjs.sleep;
|
|
692
707
|
this.#now = options.now ?? Date.now;
|
|
693
708
|
this.#requestIdHeaders = options.requestIdHeaders ?? DEFAULT_REQUEST_ID_HEADERS;
|
|
694
709
|
this.#dispatcher = options.dispatcher;
|
|
@@ -699,6 +714,14 @@ var HttpTransport = class {
|
|
|
699
714
|
get closed() {
|
|
700
715
|
return this.#closed;
|
|
701
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Throws `CancelledError` (`"<operation>: client is closed"`, not retryable) once {@link close}
|
|
719
|
+
* was called (SPEC §2.4). Requests check this themselves; service methods that send no request
|
|
720
|
+
* (cached reads, local helpers) call it first.
|
|
721
|
+
*/
|
|
722
|
+
ensureOpen(operation) {
|
|
723
|
+
if (this.#closed) throw new chunkVGAJJR3M_cjs.CancelledError(`${operation}: client is closed`);
|
|
724
|
+
}
|
|
702
725
|
/** Builds the absolute URL for a path and query. */
|
|
703
726
|
buildUrl(path, query) {
|
|
704
727
|
let url;
|
|
@@ -754,16 +777,16 @@ var HttpTransport = class {
|
|
|
754
777
|
try {
|
|
755
778
|
return await this.#request(options);
|
|
756
779
|
} catch (err) {
|
|
757
|
-
if (err instanceof
|
|
780
|
+
if (err instanceof chunkVGAJJR3M_cjs.LokiError) err.message = this.redact(err.message);
|
|
758
781
|
throw err;
|
|
759
782
|
}
|
|
760
783
|
}
|
|
761
784
|
async #request(options) {
|
|
762
785
|
const method = (options.method ?? "GET").toUpperCase();
|
|
763
786
|
const operation = options.operation ?? `${method} ${options.path.split("?")[0] ?? ""}`;
|
|
764
|
-
|
|
787
|
+
this.ensureOpen(operation);
|
|
765
788
|
const signal = options.signal;
|
|
766
|
-
if (signal?.aborted === true) throw new
|
|
789
|
+
if (signal?.aborted === true) throw new chunkVGAJJR3M_cjs.CancelledError(`${operation}: cancelled`);
|
|
767
790
|
const url = this.buildUrl(options.path, options.query);
|
|
768
791
|
const safeUrl = redactUrl(url);
|
|
769
792
|
const headers = this.#buildHeaders(options);
|
|
@@ -777,7 +800,7 @@ var HttpTransport = class {
|
|
|
777
800
|
for (let attempt = 1; ; attempt++) {
|
|
778
801
|
const remaining = deadline - this.#now();
|
|
779
802
|
if (remaining <= 0) {
|
|
780
|
-
throw new
|
|
803
|
+
throw new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`);
|
|
781
804
|
}
|
|
782
805
|
const attemptTimeout = Math.min(requestTimeout, remaining);
|
|
783
806
|
const isTotal = attemptTimeout < requestTimeout;
|
|
@@ -833,7 +856,7 @@ var HttpTransport = class {
|
|
|
833
856
|
}
|
|
834
857
|
const retryAfter = res.status === 429 || res.status === 503 ? parseRetryAfter(res.headers.get("retry-after"), this.#now()) : void 0;
|
|
835
858
|
const reason = this.vendorText(res.text);
|
|
836
|
-
const defaultError =
|
|
859
|
+
const defaultError = chunkVGAJJR3M_cjs.errorForStatus(operation, res.status, {
|
|
837
860
|
...reason === void 0 ? {} : { reason },
|
|
838
861
|
...requestId === void 0 ? {} : { requestId },
|
|
839
862
|
...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter }
|
|
@@ -879,7 +902,7 @@ var HttpTransport = class {
|
|
|
879
902
|
attempt,
|
|
880
903
|
willRetry: false
|
|
881
904
|
});
|
|
882
|
-
throw new
|
|
905
|
+
throw new chunkVGAJJR3M_cjs.TimeoutError(
|
|
883
906
|
`${operation}: total timeout of ${totalTimeout} ms exceeded after ${attempt} attempts`,
|
|
884
907
|
{
|
|
885
908
|
cause: failure,
|
|
@@ -906,7 +929,7 @@ var HttpTransport = class {
|
|
|
906
929
|
waitMs: Math.round(waitMs)
|
|
907
930
|
});
|
|
908
931
|
await this.#sleep(waitMs, signal).catch((err) => {
|
|
909
|
-
throw err instanceof
|
|
932
|
+
throw err instanceof chunkVGAJJR3M_cjs.LokiError ? err : new chunkVGAJJR3M_cjs.CancelledError(`${operation}: cancelled`);
|
|
910
933
|
});
|
|
911
934
|
}
|
|
912
935
|
}
|
|
@@ -981,30 +1004,30 @@ var HttpTransport = class {
|
|
|
981
1004
|
try {
|
|
982
1005
|
return JSON.parse(text);
|
|
983
1006
|
} catch {
|
|
984
|
-
throw new
|
|
1007
|
+
throw new chunkVGAJJR3M_cjs.UnavailableError(`invalid JSON in response (HTTP ${status})`, {
|
|
985
1008
|
retryable: false,
|
|
986
1009
|
httpStatus: status
|
|
987
1010
|
});
|
|
988
1011
|
}
|
|
989
1012
|
}
|
|
990
1013
|
#classify(err, operation, timeoutMs, isTotal, totalTimeout) {
|
|
991
|
-
if (err instanceof
|
|
1014
|
+
if (err instanceof chunkVGAJJR3M_cjs.LokiError) return err;
|
|
992
1015
|
if (err instanceof AbortedAttempt) {
|
|
993
|
-
if (err.kind === CANCEL) return new
|
|
994
|
-
return isTotal ? new
|
|
1016
|
+
if (err.kind === CANCEL) return new chunkVGAJJR3M_cjs.CancelledError(`${operation}: cancelled`);
|
|
1017
|
+
return isTotal ? new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`) : new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: request timed out after ${timeoutMs} ms`);
|
|
995
1018
|
}
|
|
996
1019
|
const cause = redactError(err, this.#knownSecrets());
|
|
997
1020
|
const code = errorCode(err);
|
|
998
1021
|
if (code === "UND_ERR_CONNECT_TIMEOUT") {
|
|
999
|
-
return new
|
|
1022
|
+
return new chunkVGAJJR3M_cjs.TimeoutError(
|
|
1000
1023
|
`${operation}: connect timeout after ${this.#config.connectTimeoutMs} ms`,
|
|
1001
1024
|
{ cause }
|
|
1002
1025
|
);
|
|
1003
1026
|
}
|
|
1004
1027
|
if (code !== void 0 && TLS_CODE.test(code)) {
|
|
1005
|
-
return new
|
|
1028
|
+
return new chunkVGAJJR3M_cjs.UnavailableError(`${operation}: TLS error (${code})`, { cause, retryable: false });
|
|
1006
1029
|
}
|
|
1007
|
-
return new
|
|
1030
|
+
return new chunkVGAJJR3M_cjs.UnavailableError(
|
|
1008
1031
|
`${operation}: network error${code === void 0 ? "" : ` (${code})`}`,
|
|
1009
1032
|
{ cause }
|
|
1010
1033
|
);
|
|
@@ -1016,9 +1039,9 @@ var HttpTransport = class {
|
|
|
1016
1039
|
try {
|
|
1017
1040
|
mapped = classify(response);
|
|
1018
1041
|
} catch (err) {
|
|
1019
|
-
mapped = err instanceof
|
|
1042
|
+
mapped = err instanceof chunkVGAJJR3M_cjs.LokiError ? err : void 0;
|
|
1020
1043
|
}
|
|
1021
|
-
if (mapped instanceof
|
|
1044
|
+
if (mapped instanceof chunkVGAJJR3M_cjs.LokiError) return mapped;
|
|
1022
1045
|
}
|
|
1023
1046
|
return void 0;
|
|
1024
1047
|
}
|
|
@@ -1253,7 +1276,7 @@ var LokiConfig = class _LokiConfig {
|
|
|
1253
1276
|
}
|
|
1254
1277
|
if (this.bearerToken?.reveal().trim() === "") problems.push("bearerToken must not be blank");
|
|
1255
1278
|
if (problems.length > 0) {
|
|
1256
|
-
throw new
|
|
1279
|
+
throw new chunkVGAJJR3M_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
|
|
1257
1280
|
}
|
|
1258
1281
|
}
|
|
1259
1282
|
/** The `Authorization` header value, when credentials are configured. */
|
|
@@ -1384,14 +1407,14 @@ function resolveBatchOptions(options = {}) {
|
|
|
1384
1407
|
for (const key of POSITIVE) {
|
|
1385
1408
|
const v = resolved[key];
|
|
1386
1409
|
if (!Number.isFinite(v) || v <= 0)
|
|
1387
|
-
throw new
|
|
1410
|
+
throw new chunkVGAJJR3M_cjs.ConfigError(`logging.batch: ${key} must be a positive number`);
|
|
1388
1411
|
}
|
|
1389
1412
|
for (const key of NON_NEGATIVE) {
|
|
1390
1413
|
const v = resolved[key];
|
|
1391
|
-
if (!Number.isFinite(v) || v < 0) throw new
|
|
1414
|
+
if (!Number.isFinite(v) || v < 0) throw new chunkVGAJJR3M_cjs.ConfigError(`logging.batch: ${key} must be >= 0`);
|
|
1392
1415
|
}
|
|
1393
1416
|
if (!["drop_newest", "drop_oldest", "block"].includes(resolved.dropPolicy)) {
|
|
1394
|
-
throw new
|
|
1417
|
+
throw new chunkVGAJJR3M_cjs.ConfigError("logging.batch: dropPolicy must be drop_newest, drop_oldest or block");
|
|
1395
1418
|
}
|
|
1396
1419
|
return resolved;
|
|
1397
1420
|
}
|
|
@@ -1450,7 +1473,7 @@ var BatchProcessor = class {
|
|
|
1450
1473
|
this.#forceUntil = Math.max(this.#forceUntil, this.#enqueued + 1);
|
|
1451
1474
|
}
|
|
1452
1475
|
}
|
|
1453
|
-
const bytes =
|
|
1476
|
+
const bytes = chunkVGAJJR3M_cjs.logRecordByteSize(record);
|
|
1454
1477
|
this.#queue.push({ record, bytes });
|
|
1455
1478
|
this.#queuedBytes += bytes;
|
|
1456
1479
|
this.#enqueued += 1;
|
|
@@ -1616,7 +1639,7 @@ var BatchProcessor = class {
|
|
|
1616
1639
|
let timer;
|
|
1617
1640
|
const timeout = new Promise((_, reject) => {
|
|
1618
1641
|
timer = setTimeout(() => {
|
|
1619
|
-
const error = new
|
|
1642
|
+
const error = new chunkVGAJJR3M_cjs.TimeoutError(`logging.export: timed out after ${timeoutMs} ms`);
|
|
1620
1643
|
controller.abort(error);
|
|
1621
1644
|
reject(error);
|
|
1622
1645
|
}, timeoutMs);
|
|
@@ -1646,7 +1669,7 @@ var BatchProcessor = class {
|
|
|
1646
1669
|
let timer;
|
|
1647
1670
|
const timeout = new Promise((_, reject) => {
|
|
1648
1671
|
timer = setTimeout(() => {
|
|
1649
|
-
reject(new
|
|
1672
|
+
reject(new chunkVGAJJR3M_cjs.TimeoutError(`${operation}: timed out after ${timeoutMs} ms`));
|
|
1650
1673
|
}, timeoutMs);
|
|
1651
1674
|
timer.unref();
|
|
1652
1675
|
});
|
|
@@ -1772,7 +1795,7 @@ var BatchingLogClient = class {
|
|
|
1772
1795
|
#closing = null;
|
|
1773
1796
|
constructor(exporter, options = {}) {
|
|
1774
1797
|
this.#processor = new BatchProcessor(exporter, options.batch);
|
|
1775
|
-
this.#resource =
|
|
1798
|
+
this.#resource = chunkVGAJJR3M_cjs.toAttributes(options.resource ?? {});
|
|
1776
1799
|
const redaction = options.redaction ?? {};
|
|
1777
1800
|
this.#redaction = redaction === false ? null : redaction instanceof RedactionProcessor ? redaction : new RedactionProcessor(redaction);
|
|
1778
1801
|
this.#minSeverity = options.minSeverity ?? 9 /* Info */;
|
|
@@ -1818,8 +1841,8 @@ var BatchingLogClient = class {
|
|
|
1818
1841
|
if (isLogRecord(input)) {
|
|
1819
1842
|
record = {
|
|
1820
1843
|
...input,
|
|
1821
|
-
attributes:
|
|
1822
|
-
resource: { ...this.#resource, ...
|
|
1844
|
+
attributes: chunkVGAJJR3M_cjs.toAttributes(input.attributes),
|
|
1845
|
+
resource: { ...this.#resource, ...chunkVGAJJR3M_cjs.toAttributes(input.resource) }
|
|
1823
1846
|
};
|
|
1824
1847
|
record.observedTimestamp ??= now;
|
|
1825
1848
|
} else {
|
|
@@ -1828,17 +1851,17 @@ var BatchingLogClient = class {
|
|
|
1828
1851
|
timestamp: input.timestamp ?? now,
|
|
1829
1852
|
observedTimestamp: now,
|
|
1830
1853
|
severity,
|
|
1831
|
-
severityText:
|
|
1854
|
+
severityText: chunkVGAJJR3M_cjs.severityText(severity),
|
|
1832
1855
|
body: input.message,
|
|
1833
|
-
attributes:
|
|
1856
|
+
attributes: chunkVGAJJR3M_cjs.toAttributes(input.attributes ?? {}),
|
|
1834
1857
|
resource: { ...this.#resource }
|
|
1835
1858
|
};
|
|
1836
1859
|
if (input.traceId !== void 0) record.traceId = input.traceId;
|
|
1837
1860
|
if (input.spanId !== void 0) record.spanId = input.spanId;
|
|
1838
1861
|
if (input.traceFlags !== void 0) record.traceFlags = input.traceFlags;
|
|
1839
1862
|
}
|
|
1840
|
-
const traceId =
|
|
1841
|
-
const spanId = traceId === void 0 ? void 0 :
|
|
1863
|
+
const traceId = chunkVGAJJR3M_cjs.normalizeHexId(record.traceId, 32);
|
|
1864
|
+
const spanId = traceId === void 0 ? void 0 : chunkVGAJJR3M_cjs.normalizeHexId(record.spanId, 16);
|
|
1842
1865
|
delete record.traceId;
|
|
1843
1866
|
delete record.spanId;
|
|
1844
1867
|
if (traceId === void 0) delete record.traceFlags;
|
|
@@ -1856,7 +1879,7 @@ function pinoLevelToSeverity(level) {
|
|
|
1856
1879
|
if (level < 60) return 17 /* Error */;
|
|
1857
1880
|
return 21 /* Fatal */;
|
|
1858
1881
|
}
|
|
1859
|
-
return typeof level === "string" ?
|
|
1882
|
+
return typeof level === "string" ? chunkVGAJJR3M_cjs.parseSeverity(level) ?? 9 /* Info */ : 9 /* Info */;
|
|
1860
1883
|
}
|
|
1861
1884
|
function pinoLineToRecord(line, opts = {}) {
|
|
1862
1885
|
const consumed = /* @__PURE__ */ new Set();
|
|
@@ -1886,9 +1909,9 @@ function pinoLineToRecord(line, opts = {}) {
|
|
|
1886
1909
|
const record = {
|
|
1887
1910
|
timestamp: Number.isNaN(timestamp.getTime()) ? /* @__PURE__ */ new Date() : timestamp,
|
|
1888
1911
|
severity,
|
|
1889
|
-
severityText: typeof level === "string" ? level.toUpperCase() :
|
|
1912
|
+
severityText: typeof level === "string" ? level.toUpperCase() : chunkVGAJJR3M_cjs.severityText(severity),
|
|
1890
1913
|
body: typeof message === "string" ? message : message === void 0 ? "" : JSON.stringify(message),
|
|
1891
|
-
attributes: { ...opts.attributes, ...
|
|
1914
|
+
attributes: { ...opts.attributes, ...chunkVGAJJR3M_cjs.toAttributes(rest) },
|
|
1892
1915
|
resource
|
|
1893
1916
|
};
|
|
1894
1917
|
if (typeof traceId === "string") record.traceId = traceId;
|
|
@@ -1956,7 +1979,7 @@ var WINSTON_LEVELS = {
|
|
|
1956
1979
|
};
|
|
1957
1980
|
function winstonLevelToSeverity(level) {
|
|
1958
1981
|
const lower = level.toLowerCase();
|
|
1959
|
-
return WINSTON_LEVELS[lower] ??
|
|
1982
|
+
return WINSTON_LEVELS[lower] ?? chunkVGAJJR3M_cjs.parseSeverity(lower) ?? 9 /* Info */;
|
|
1960
1983
|
}
|
|
1961
1984
|
var WinstonTransport = class extends stream.Writable {
|
|
1962
1985
|
#client;
|
|
@@ -1985,7 +2008,7 @@ var WinstonTransport = class extends stream.Writable {
|
|
|
1985
2008
|
severity,
|
|
1986
2009
|
severityText: rawLevel.toUpperCase(),
|
|
1987
2010
|
body: typeof message === "string" ? message : message === void 0 ? "" : JSON.stringify(message),
|
|
1988
|
-
attributes: { ...this.#attributes, ...
|
|
2011
|
+
attributes: { ...this.#attributes, ...chunkVGAJJR3M_cjs.toAttributes(rest) },
|
|
1989
2012
|
resource: {}
|
|
1990
2013
|
};
|
|
1991
2014
|
}
|
|
@@ -2021,12 +2044,231 @@ var WinstonTransport = class extends stream.Writable {
|
|
|
2021
2044
|
}
|
|
2022
2045
|
};
|
|
2023
2046
|
|
|
2047
|
+
// src/logging-connect.ts
|
|
2048
|
+
var connectLogClient = ({
|
|
2049
|
+
resource,
|
|
2050
|
+
onDropped
|
|
2051
|
+
}) => {
|
|
2052
|
+
const client = LokiClient.fromEnv();
|
|
2053
|
+
const factory = client.logClient;
|
|
2054
|
+
if (typeof factory !== "function") {
|
|
2055
|
+
void client.close();
|
|
2056
|
+
return void 0;
|
|
2057
|
+
}
|
|
2058
|
+
const logs = factory.call(client, { resource, batch: { onDrop: onDropped } });
|
|
2059
|
+
return {
|
|
2060
|
+
logs,
|
|
2061
|
+
close: async () => {
|
|
2062
|
+
await logs.close();
|
|
2063
|
+
await client.close();
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
// src/logging/init.ts
|
|
2069
|
+
var LOG_SHIPPED_FIELD = "log_shipped";
|
|
2070
|
+
var requestContext = new async_hooks.AsyncLocalStorage();
|
|
2071
|
+
var GLOBAL_KEY = /* @__PURE__ */ Symbol.for(`grow-codes.${PACKAGE_KEY}.logging`);
|
|
2072
|
+
function withRequestId(requestId, fn) {
|
|
2073
|
+
return requestContext.run({ requestId }, fn);
|
|
2074
|
+
}
|
|
2075
|
+
function currentRequestId() {
|
|
2076
|
+
return requestContext.getStore()?.requestId;
|
|
2077
|
+
}
|
|
2078
|
+
function getLogging() {
|
|
2079
|
+
return globalThis[GLOBAL_KEY];
|
|
2080
|
+
}
|
|
2081
|
+
function first(env, ...names) {
|
|
2082
|
+
for (const name of names) {
|
|
2083
|
+
const value = env[name]?.trim();
|
|
2084
|
+
if (value !== void 0 && value !== "") return value;
|
|
2085
|
+
}
|
|
2086
|
+
return void 0;
|
|
2087
|
+
}
|
|
2088
|
+
function stdoutLine(record, marker) {
|
|
2089
|
+
const line = {
|
|
2090
|
+
time: record.timestamp.toISOString(),
|
|
2091
|
+
level: chunkVGAJJR3M_cjs.severityText(record.severity).toLowerCase(),
|
|
2092
|
+
msg: record.body
|
|
2093
|
+
};
|
|
2094
|
+
const resource = record.resource;
|
|
2095
|
+
if (resource["service.name"] !== void 0) line["service"] = resource["service.name"];
|
|
2096
|
+
if (resource["deployment.environment"] !== void 0)
|
|
2097
|
+
line["environment"] = resource["deployment.environment"];
|
|
2098
|
+
if (record.traceId !== void 0) line["trace_id"] = record.traceId;
|
|
2099
|
+
if (record.spanId !== void 0) line["span_id"] = record.spanId;
|
|
2100
|
+
for (const [key, value] of Object.entries(record.attributes)) if (!(key in line)) line[key] = value;
|
|
2101
|
+
if (marker !== void 0) line[LOG_SHIPPED_FIELD] = marker;
|
|
2102
|
+
return JSON.stringify(line);
|
|
2103
|
+
}
|
|
2104
|
+
function initLogging(opts = {}) {
|
|
2105
|
+
const existing = getLogging();
|
|
2106
|
+
if (existing !== void 0) return existing;
|
|
2107
|
+
const env = opts.env ?? process.env;
|
|
2108
|
+
const service = opts.service ?? first(env, "GROW_SERVICE_NAME", "OTEL_SERVICE_NAME") ?? "unknown_service";
|
|
2109
|
+
const environment = first(env, "GROW_ENVIRONMENT", "DEPLOYMENT_ENVIRONMENT");
|
|
2110
|
+
const resource = { "service.name": service };
|
|
2111
|
+
if (environment !== void 0) resource["deployment.environment"] = environment;
|
|
2112
|
+
const levelText = opts.level ?? first(env, "LOG_LEVEL", "GROW_LOG_LEVEL") ?? "info";
|
|
2113
|
+
const minSeverity = chunkVGAJJR3M_cjs.parseSeverity(levelText) ?? 9 /* Info */;
|
|
2114
|
+
const write = opts.write ?? ((line) => void process.stdout.write(`${line}
|
|
2115
|
+
`));
|
|
2116
|
+
const redaction = new RedactionProcessor(opts.redaction ?? {});
|
|
2117
|
+
const ship = opts.ship ?? first(env, "GROW_LOGGING_PROVIDER") === PACKAGE_KEY;
|
|
2118
|
+
let connection;
|
|
2119
|
+
if (ship) {
|
|
2120
|
+
try {
|
|
2121
|
+
const onDropped = (records) => {
|
|
2122
|
+
for (const record of records) {
|
|
2123
|
+
try {
|
|
2124
|
+
write(stdoutLine(record, "sdk_failed"));
|
|
2125
|
+
} catch {
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
connection = (opts.connect ?? connectLogClient)({ resource, env, onDropped });
|
|
2130
|
+
} catch (err) {
|
|
2131
|
+
write(
|
|
2132
|
+
stdoutLine(
|
|
2133
|
+
{
|
|
2134
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2135
|
+
severity: 13 /* Warn */,
|
|
2136
|
+
body: `logging: ${PACKAGE_KEY} transport not available, stdout only (${err.name})`,
|
|
2137
|
+
attributes: {},
|
|
2138
|
+
resource
|
|
2139
|
+
}
|
|
2140
|
+
)
|
|
2141
|
+
);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
const logs = connection?.logs;
|
|
2145
|
+
const shipped = logs !== void 0;
|
|
2146
|
+
const toStdout = opts.stdout ?? true;
|
|
2147
|
+
const sink = {
|
|
2148
|
+
send(input) {
|
|
2149
|
+
const requestId = currentRequestId();
|
|
2150
|
+
const attributes = chunkVGAJJR3M_cjs.toAttributes({
|
|
2151
|
+
...requestId === void 0 ? {} : { request_id: requestId },
|
|
2152
|
+
...input.attributes
|
|
2153
|
+
});
|
|
2154
|
+
const severity = input.severity ?? 9 /* Info */;
|
|
2155
|
+
const record = {
|
|
2156
|
+
timestamp: input.timestamp ?? /* @__PURE__ */ new Date(),
|
|
2157
|
+
severity,
|
|
2158
|
+
severityText: chunkVGAJJR3M_cjs.severityText(severity),
|
|
2159
|
+
body: input.message,
|
|
2160
|
+
attributes,
|
|
2161
|
+
resource
|
|
2162
|
+
};
|
|
2163
|
+
if (input.traceId !== void 0) record.traceId = input.traceId;
|
|
2164
|
+
if (input.spanId !== void 0) record.spanId = input.spanId;
|
|
2165
|
+
if (input.traceFlags !== void 0) record.traceFlags = input.traceFlags;
|
|
2166
|
+
if (toStdout) {
|
|
2167
|
+
try {
|
|
2168
|
+
write(stdoutLine(redaction.process(record), shipped ? "sdk" : void 0));
|
|
2169
|
+
} catch {
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
logs?.send(record);
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
let closing;
|
|
2176
|
+
const handle = {
|
|
2177
|
+
logger: new Logger(sink, { minSeverity }),
|
|
2178
|
+
logs,
|
|
2179
|
+
shipped,
|
|
2180
|
+
service,
|
|
2181
|
+
flush: (timeoutMs) => logs === void 0 ? Promise.resolve() : logs.flush(timeoutMs),
|
|
2182
|
+
close: () => {
|
|
2183
|
+
closing ??= (async () => {
|
|
2184
|
+
if (globalThis[GLOBAL_KEY] === handle) globalThis[GLOBAL_KEY] = void 0;
|
|
2185
|
+
await connection?.close();
|
|
2186
|
+
})();
|
|
2187
|
+
return closing;
|
|
2188
|
+
},
|
|
2189
|
+
canary: async (message, attributes = {}) => {
|
|
2190
|
+
if (logs === void 0) return false;
|
|
2191
|
+
logs.send({ message, severity: 9 /* Info */, attributes: { "foundation.canary": true, ...attributes } });
|
|
2192
|
+
await logs.flush(5e3).catch(() => void 0);
|
|
2193
|
+
return true;
|
|
2194
|
+
},
|
|
2195
|
+
pinoStream: () => pinoTee(write, logs, shipped, toStdout)
|
|
2196
|
+
};
|
|
2197
|
+
globalThis[GLOBAL_KEY] = handle;
|
|
2198
|
+
return handle;
|
|
2199
|
+
}
|
|
2200
|
+
function pinoTee(write, logs, shipped, toStdout) {
|
|
2201
|
+
const transport = logs === void 0 ? void 0 : createPinoTransport(logs, { flushOnEnd: false });
|
|
2202
|
+
return new stream.Writable({
|
|
2203
|
+
write(chunk, _encoding, callback) {
|
|
2204
|
+
const text = chunk.toString();
|
|
2205
|
+
if (toStdout) {
|
|
2206
|
+
for (const raw of text.split("\n")) {
|
|
2207
|
+
if (raw.trim() === "") continue;
|
|
2208
|
+
let out = raw;
|
|
2209
|
+
if (shipped) {
|
|
2210
|
+
try {
|
|
2211
|
+
out = JSON.stringify({ ...JSON.parse(raw), [LOG_SHIPPED_FIELD]: "sdk" });
|
|
2212
|
+
} catch {
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
write(out);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
if (transport === void 0) callback();
|
|
2219
|
+
else transport.write(chunk, callback);
|
|
2220
|
+
},
|
|
2221
|
+
final(callback) {
|
|
2222
|
+
if (transport === void 0) callback();
|
|
2223
|
+
else transport.end(callback);
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
function headerValue(value) {
|
|
2228
|
+
const v = Array.isArray(value) ? value[0] : value;
|
|
2229
|
+
return v === void 0 || v.trim() === "" ? void 0 : v.trim().slice(0, 128);
|
|
2230
|
+
}
|
|
2231
|
+
function requestLogger(opts = {}) {
|
|
2232
|
+
const header = (opts.header ?? "x-request-id").toLowerCase();
|
|
2233
|
+
const skip = opts.skip ?? ["/health/live", "/health/ready"];
|
|
2234
|
+
return (req, res, next) => {
|
|
2235
|
+
const requestId = headerValue(req.headers[header]) ?? crypto.randomUUID();
|
|
2236
|
+
res.setHeader(header, requestId);
|
|
2237
|
+
const path = (req.originalUrl ?? req.url ?? "/").split("?")[0] ?? "/";
|
|
2238
|
+
const start = performance.now();
|
|
2239
|
+
if (!skip.some((p) => path.startsWith(p))) {
|
|
2240
|
+
let done = false;
|
|
2241
|
+
const finish = () => {
|
|
2242
|
+
if (done) return;
|
|
2243
|
+
done = true;
|
|
2244
|
+
const logger = opts.logger ?? getLogging()?.logger;
|
|
2245
|
+
const status = res.statusCode;
|
|
2246
|
+
const attributes = {
|
|
2247
|
+
request_id: requestId,
|
|
2248
|
+
"http.method": req.method ?? "GET",
|
|
2249
|
+
"http.route": path,
|
|
2250
|
+
"http.status_code": status,
|
|
2251
|
+
duration_ms: Math.round((performance.now() - start) * 100) / 100
|
|
2252
|
+
};
|
|
2253
|
+
if (status >= 500) logger?.error("request completed", attributes);
|
|
2254
|
+
else if (status >= 400) logger?.warn("request completed", attributes);
|
|
2255
|
+
else logger?.info("request completed", attributes);
|
|
2256
|
+
};
|
|
2257
|
+
res.once("finish", finish);
|
|
2258
|
+
res.once("close", finish);
|
|
2259
|
+
}
|
|
2260
|
+
withRequestId(requestId, () => {
|
|
2261
|
+
next();
|
|
2262
|
+
});
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2024
2266
|
// src/time.ts
|
|
2025
2267
|
var NS_PER_MS = 1000000n;
|
|
2026
2268
|
var DIGITS = /^\d+$/;
|
|
2027
2269
|
function dateToNanos(date) {
|
|
2028
2270
|
const ms = date.getTime();
|
|
2029
|
-
if (!Number.isFinite(ms)) throw new
|
|
2271
|
+
if (!Number.isFinite(ms)) throw new chunkVGAJJR3M_cjs.ValidationError("invalid date");
|
|
2030
2272
|
return (BigInt(ms) * NS_PER_MS).toString();
|
|
2031
2273
|
}
|
|
2032
2274
|
function nanosToDate(ns) {
|
|
@@ -2035,18 +2277,18 @@ function nanosToDate(ns) {
|
|
|
2035
2277
|
}
|
|
2036
2278
|
function toNanos(value, field = "time") {
|
|
2037
2279
|
if (value instanceof Date) {
|
|
2038
|
-
if (Number.isNaN(value.getTime())) throw new
|
|
2280
|
+
if (Number.isNaN(value.getTime())) throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: invalid date`);
|
|
2039
2281
|
return dateToNanos(value);
|
|
2040
2282
|
}
|
|
2041
2283
|
if (typeof value === "bigint") {
|
|
2042
|
-
if (value < 0n) throw new
|
|
2284
|
+
if (value < 0n) throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: must not be negative`);
|
|
2043
2285
|
return value.toString();
|
|
2044
2286
|
}
|
|
2045
2287
|
const text = value.trim();
|
|
2046
2288
|
if (DIGITS.test(text)) return text;
|
|
2047
2289
|
const parsed = Date.parse(text);
|
|
2048
2290
|
if (text === "" || Number.isNaN(parsed)) {
|
|
2049
|
-
throw new
|
|
2291
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: expected a Date, bigint nanoseconds or RFC 3339 text`);
|
|
2050
2292
|
}
|
|
2051
2293
|
return dateToNanos(new Date(parsed));
|
|
2052
2294
|
}
|
|
@@ -2058,7 +2300,7 @@ function secondsToDate(seconds) {
|
|
|
2058
2300
|
}
|
|
2059
2301
|
function msToDuration(ms, field) {
|
|
2060
2302
|
if (!Number.isFinite(ms) || ms <= 0) {
|
|
2061
|
-
throw new
|
|
2303
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${field}: must be a positive number of milliseconds`);
|
|
2062
2304
|
}
|
|
2063
2305
|
return `${Math.round(ms)}ms`;
|
|
2064
2306
|
}
|
|
@@ -2089,19 +2331,19 @@ function isValidLabelName(name) {
|
|
|
2089
2331
|
}
|
|
2090
2332
|
function validateLabelName(name, what = "label name") {
|
|
2091
2333
|
if (!LABEL_NAME_PATTERN.test(name)) {
|
|
2092
|
-
throw new
|
|
2334
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(
|
|
2093
2335
|
`invalid ${what} ${JSON.stringify(name)}: must match [a-zA-Z_][a-zA-Z0-9_]*`
|
|
2094
2336
|
);
|
|
2095
2337
|
}
|
|
2096
2338
|
if (name.startsWith("__")) {
|
|
2097
|
-
throw new
|
|
2339
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`invalid ${what} ${JSON.stringify(name)}: "__" names are reserved`);
|
|
2098
2340
|
}
|
|
2099
2341
|
}
|
|
2100
2342
|
function validateLabels(labels) {
|
|
2101
2343
|
for (const [name, value] of Object.entries(labels)) {
|
|
2102
2344
|
validateLabelName(name);
|
|
2103
2345
|
if (typeof value !== "string" || value === "") {
|
|
2104
|
-
throw new
|
|
2346
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`label ${name}: value must be a non-empty string`);
|
|
2105
2347
|
}
|
|
2106
2348
|
}
|
|
2107
2349
|
}
|
|
@@ -2170,7 +2412,7 @@ function recordsToStreams(records, options = {}) {
|
|
|
2170
2412
|
};
|
|
2171
2413
|
for (const [k, v] of Object.entries(record.resource)) place(k, v);
|
|
2172
2414
|
for (const [k, v] of Object.entries(record.attributes)) place(k, v);
|
|
2173
|
-
const text = record.severityText !== "" ? record.severityText :
|
|
2415
|
+
const text = record.severityText !== "" ? record.severityText : chunkVGAJJR3M_cjs.severityText(record.severity);
|
|
2174
2416
|
if (allowed.has("level") && labels.level === void 0) labels.level = text.toLowerCase();
|
|
2175
2417
|
metadata.severity_text = text;
|
|
2176
2418
|
metadata.severity_number = String(record.severity);
|
|
@@ -2202,7 +2444,7 @@ async function exportWith(records, send) {
|
|
|
2202
2444
|
await send();
|
|
2203
2445
|
return { accepted: records.length, rejected: 0 };
|
|
2204
2446
|
} catch (error) {
|
|
2205
|
-
if (error instanceof
|
|
2447
|
+
if (error instanceof chunkVGAJJR3M_cjs.LokiError) return { accepted: 0, rejected: records.length, error };
|
|
2206
2448
|
throw error;
|
|
2207
2449
|
}
|
|
2208
2450
|
}
|
|
@@ -2411,13 +2653,13 @@ function quoteLogQL(value) {
|
|
|
2411
2653
|
}
|
|
2412
2654
|
function checkName(name, what) {
|
|
2413
2655
|
if (!LABEL_NAME_PATTERN.test(name)) {
|
|
2414
|
-
throw new
|
|
2656
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(
|
|
2415
2657
|
`LogQL: invalid ${what} ${JSON.stringify(name)}: must match [a-zA-Z_][a-zA-Z0-9_]*`
|
|
2416
2658
|
);
|
|
2417
2659
|
}
|
|
2418
2660
|
}
|
|
2419
2661
|
function formatNumber(value) {
|
|
2420
|
-
if (!Number.isFinite(value)) throw new
|
|
2662
|
+
if (!Number.isFinite(value)) throw new chunkVGAJJR3M_cjs.ValidationError("LogQL: numbers must be finite");
|
|
2421
2663
|
return value.toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 20 });
|
|
2422
2664
|
}
|
|
2423
2665
|
function matchesEmpty(m) {
|
|
@@ -2457,7 +2699,7 @@ var LogQL = class _LogQL {
|
|
|
2457
2699
|
/** Adds a stream-selector matcher (`=`, `!=`, `=~`, `!~`). */
|
|
2458
2700
|
label(name, op, value) {
|
|
2459
2701
|
checkName(name, "label name");
|
|
2460
|
-
if (!MATCH_OPS.has(op)) throw new
|
|
2702
|
+
if (!MATCH_OPS.has(op)) throw new chunkVGAJJR3M_cjs.ValidationError(`LogQL: invalid matcher operator ${op}`);
|
|
2461
2703
|
return new _LogQL([...this.#matchers, { name, op, value }], this.#stages);
|
|
2462
2704
|
}
|
|
2463
2705
|
#stage(text) {
|
|
@@ -2511,12 +2753,12 @@ var LogQL = class _LogQL {
|
|
|
2511
2753
|
checkName(field, "field name");
|
|
2512
2754
|
if (typeof value === "number") {
|
|
2513
2755
|
if (!NUMERIC_OPS.has(op)) {
|
|
2514
|
-
throw new
|
|
2756
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`LogQL: operator ${op} cannot compare numbers`);
|
|
2515
2757
|
}
|
|
2516
2758
|
return this.#stage(`| ${field} ${op} ${formatNumber(value)}`);
|
|
2517
2759
|
}
|
|
2518
2760
|
if (!MATCH_OPS.has(op)) {
|
|
2519
|
-
throw new
|
|
2761
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`LogQL: operator ${op} cannot compare strings`);
|
|
2520
2762
|
}
|
|
2521
2763
|
return this.#stage(`| ${field} ${op} ${quoteLogQL(value)}`);
|
|
2522
2764
|
}
|
|
@@ -2530,10 +2772,10 @@ var LogQL = class _LogQL {
|
|
|
2530
2772
|
*/
|
|
2531
2773
|
toString() {
|
|
2532
2774
|
if (this.#matchers.length === 0) {
|
|
2533
|
-
throw new
|
|
2775
|
+
throw new chunkVGAJJR3M_cjs.ValidationError("LogQL: a stream selector needs at least one matcher");
|
|
2534
2776
|
}
|
|
2535
2777
|
if (this.#matchers.every(matchesEmpty)) {
|
|
2536
|
-
throw new
|
|
2778
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(
|
|
2537
2779
|
"LogQL: the selector needs at least one matcher that does not match the empty value"
|
|
2538
2780
|
);
|
|
2539
2781
|
}
|
|
@@ -2569,7 +2811,7 @@ function encodeCursor(ns, skip) {
|
|
|
2569
2811
|
function decodeCursor(cursor) {
|
|
2570
2812
|
const text = Buffer.from(cursor, "base64url").toString("utf8");
|
|
2571
2813
|
const match = /^(\d+):(\d+)$/.exec(text);
|
|
2572
|
-
if (match === null) throw new
|
|
2814
|
+
if (match === null) throw new chunkVGAJJR3M_cjs.ValidationError("logging.search: invalid cursor");
|
|
2573
2815
|
return { ns: match[1], skip: Number(match[2]) };
|
|
2574
2816
|
}
|
|
2575
2817
|
var CONSUMED_METADATA = /* @__PURE__ */ new Set([
|
|
@@ -2581,10 +2823,10 @@ var CONSUMED_METADATA = /* @__PURE__ */ new Set([
|
|
|
2581
2823
|
"observed_timestamp"
|
|
2582
2824
|
]);
|
|
2583
2825
|
function severityFrom(md, labels) {
|
|
2584
|
-
const fromNumber = md.severity_number === void 0 ? null :
|
|
2585
|
-
const fromText = md.severity_text === void 0 ? null :
|
|
2586
|
-
const severity = fromNumber ?? fromText ?? (md.detected_level === void 0 ? null :
|
|
2587
|
-
return { severity, text: md.severity_text ??
|
|
2826
|
+
const fromNumber = md.severity_number === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(md.severity_number);
|
|
2827
|
+
const fromText = md.severity_text === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(md.severity_text);
|
|
2828
|
+
const severity = fromNumber ?? fromText ?? (md.detected_level === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(md.detected_level)) ?? (labels.level === void 0 ? null : chunkVGAJJR3M_cjs.parseSeverity(labels.level)) ?? 9 /* Info */;
|
|
2829
|
+
return { severity, text: md.severity_text ?? chunkVGAJJR3M_cjs.severityText(severity) };
|
|
2588
2830
|
}
|
|
2589
2831
|
function entryToLogRecord(labels, entry) {
|
|
2590
2832
|
const md = entry.structuredMetadata;
|
|
@@ -2637,7 +2879,7 @@ function mergeStreams(streams, order) {
|
|
|
2637
2879
|
});
|
|
2638
2880
|
return flat;
|
|
2639
2881
|
}
|
|
2640
|
-
var LokiLogQueryClient = class extends
|
|
2882
|
+
var LokiLogQueryClient = class extends chunkVGAJJR3M_cjs.BaseLogQueryClient {
|
|
2641
2883
|
#source;
|
|
2642
2884
|
constructor(source) {
|
|
2643
2885
|
super();
|
|
@@ -2652,7 +2894,7 @@ var LokiLogQueryClient = class extends chunk553Q2KB5_cjs.BaseLogQueryClient {
|
|
|
2652
2894
|
async search(query, opts = {}) {
|
|
2653
2895
|
const limit = opts.limit ?? 100;
|
|
2654
2896
|
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_QUERY_LIMIT) {
|
|
2655
|
-
throw new
|
|
2897
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`logging.search: limit must be an integer 1..${MAX_QUERY_LIMIT}`);
|
|
2656
2898
|
}
|
|
2657
2899
|
const order = opts.order ?? "desc";
|
|
2658
2900
|
let start = opts.start;
|
|
@@ -2763,7 +3005,7 @@ function isObject(v) {
|
|
|
2763
3005
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2764
3006
|
}
|
|
2765
3007
|
function bad(what) {
|
|
2766
|
-
throw new
|
|
3008
|
+
throw new chunkVGAJJR3M_cjs.UnavailableError(`unexpected response from Loki: ${what}`, { retryable: false });
|
|
2767
3009
|
}
|
|
2768
3010
|
function stringMap(v) {
|
|
2769
3011
|
const out = {};
|
|
@@ -2918,7 +3160,7 @@ function openTail(params, onFrame, callbacks = {}) {
|
|
|
2918
3160
|
const op = "tail";
|
|
2919
3161
|
return new Promise((resolve, reject) => {
|
|
2920
3162
|
if (params.signal?.aborted === true) {
|
|
2921
|
-
reject(new
|
|
3163
|
+
reject(new chunkVGAJJR3M_cjs.CancelledError(`${op}: cancelled`));
|
|
2922
3164
|
return;
|
|
2923
3165
|
}
|
|
2924
3166
|
let settled = false;
|
|
@@ -2959,7 +3201,7 @@ function openTail(params, onFrame, callbacks = {}) {
|
|
|
2959
3201
|
};
|
|
2960
3202
|
function onAbort() {
|
|
2961
3203
|
if (!settled) {
|
|
2962
|
-
fail(new
|
|
3204
|
+
fail(new chunkVGAJJR3M_cjs.CancelledError(`${op}: cancelled`));
|
|
2963
3205
|
ws.terminate();
|
|
2964
3206
|
} else {
|
|
2965
3207
|
handle.stop();
|
|
@@ -2973,7 +3215,7 @@ function openTail(params, onFrame, callbacks = {}) {
|
|
|
2973
3215
|
res.on("end", () => {
|
|
2974
3216
|
const status = res.statusCode ?? 0;
|
|
2975
3217
|
const reason = vendorText(Buffer.concat(chunks).toString("utf8"), params.redact);
|
|
2976
|
-
fail(
|
|
3218
|
+
fail(chunkVGAJJR3M_cjs.errorForStatus(op, status, reason === void 0 ? {} : { reason }));
|
|
2977
3219
|
socket.destroy();
|
|
2978
3220
|
req.destroy();
|
|
2979
3221
|
resolveClosed();
|
|
@@ -2993,7 +3235,7 @@ function openTail(params, onFrame, callbacks = {}) {
|
|
|
2993
3235
|
);
|
|
2994
3236
|
} catch (err) {
|
|
2995
3237
|
report(
|
|
2996
|
-
err instanceof
|
|
3238
|
+
err instanceof chunkVGAJJR3M_cjs.UnavailableError ? err : new chunkVGAJJR3M_cjs.UnavailableError(`${op}: malformed frame`, { retryable: false })
|
|
2997
3239
|
);
|
|
2998
3240
|
return;
|
|
2999
3241
|
}
|
|
@@ -3008,20 +3250,20 @@ function openTail(params, onFrame, callbacks = {}) {
|
|
|
3008
3250
|
ws.on("error", (err) => {
|
|
3009
3251
|
if (!settled) {
|
|
3010
3252
|
fail(
|
|
3011
|
-
/timed out/i.test(err.message) ? new
|
|
3253
|
+
/timed out/i.test(err.message) ? new chunkVGAJJR3M_cjs.TimeoutError(`${op}: connect timeout after ${params.connectTimeoutMs} ms`) : new chunkVGAJJR3M_cjs.UnavailableError(`${op}: ${params.redact(err.message)}`)
|
|
3012
3254
|
);
|
|
3013
3255
|
} else if (opened && !stopped) {
|
|
3014
|
-
report(new
|
|
3256
|
+
report(new chunkVGAJJR3M_cjs.UnavailableError(`${op}: ${params.redact(err.message)}`));
|
|
3015
3257
|
}
|
|
3016
3258
|
});
|
|
3017
3259
|
ws.on("close", (code, reasonBuf) => {
|
|
3018
3260
|
params.signal?.removeEventListener("abort", onAbort);
|
|
3019
3261
|
const reason = vendorText(reasonBuf.toString("utf8"), params.redact);
|
|
3020
3262
|
if (!settled) {
|
|
3021
|
-
fail(new
|
|
3263
|
+
fail(new chunkVGAJJR3M_cjs.UnavailableError(`${op}: connection closed before the upgrade (code ${code})`));
|
|
3022
3264
|
} else if (opened && !stopped && code !== 1e3) {
|
|
3023
3265
|
report(
|
|
3024
|
-
new
|
|
3266
|
+
new chunkVGAJJR3M_cjs.UnavailableError(
|
|
3025
3267
|
`${op}: connection closed (code ${code})${reason === void 0 ? "" : `: ${reason}`}`,
|
|
3026
3268
|
{ retryable: code === 1001 || code === 1006 }
|
|
3027
3269
|
)
|
|
@@ -3038,9 +3280,9 @@ var ENCODING_FLAGS_HEADER = "x-loki-response-encoding-flags";
|
|
|
3038
3280
|
var TENANT_HEADER = "x-scope-orgid";
|
|
3039
3281
|
var SHUTTING_DOWN = /ingester is shutting down/i;
|
|
3040
3282
|
function mapLokiError(err) {
|
|
3041
|
-
if (!(err instanceof
|
|
3283
|
+
if (!(err instanceof chunkVGAJJR3M_cjs.LokiError) || !SHUTTING_DOWN.test(err.message)) return err;
|
|
3042
3284
|
const message = err.message.includes("WAL") ? err.message : `${err.message} (the Loki ingester is stopping or its WAL disk is at least 90 % full)`;
|
|
3043
|
-
return new
|
|
3285
|
+
return new chunkVGAJJR3M_cjs.UnavailableError(message, {
|
|
3044
3286
|
...err.httpStatus === void 0 ? {} : { httpStatus: err.httpStatus },
|
|
3045
3287
|
...err.requestId === void 0 ? {} : { requestId: err.requestId },
|
|
3046
3288
|
...err.retryAfterMs === void 0 ? {} : { retryAfterMs: err.retryAfterMs },
|
|
@@ -3061,7 +3303,7 @@ function vectorToMatrix(result) {
|
|
|
3061
3303
|
};
|
|
3062
3304
|
}
|
|
3063
3305
|
function cleanRpcStatus(err) {
|
|
3064
|
-
if (!(err instanceof
|
|
3306
|
+
if (!(err instanceof chunkVGAJJR3M_cjs.LokiError)) return err;
|
|
3065
3307
|
const match = /^(.*?: )([\s\S]*)( \(HTTP \d+\))$/.exec(err.message);
|
|
3066
3308
|
if (match === null) return err;
|
|
3067
3309
|
const raw = match[2];
|
|
@@ -3072,12 +3314,12 @@ function cleanRpcStatus(err) {
|
|
|
3072
3314
|
}
|
|
3073
3315
|
function checkLimit(limit, op, max = Number.MAX_SAFE_INTEGER) {
|
|
3074
3316
|
if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > max)) {
|
|
3075
|
-
throw new
|
|
3317
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: limit must be an integer 1..${max}`);
|
|
3076
3318
|
}
|
|
3077
3319
|
}
|
|
3078
3320
|
function checkQuery(logql, op) {
|
|
3079
3321
|
if (typeof logql !== "string" || logql.trim() === "") {
|
|
3080
|
-
throw new
|
|
3322
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: query must not be empty`);
|
|
3081
3323
|
}
|
|
3082
3324
|
}
|
|
3083
3325
|
var LokiClient = class _LokiClient {
|
|
@@ -3130,7 +3372,7 @@ var LokiClient = class _LokiClient {
|
|
|
3130
3372
|
*/
|
|
3131
3373
|
withTenant(id) {
|
|
3132
3374
|
const problem = tenantIdProblem(id, this.config.multiTenantQueries);
|
|
3133
|
-
if (problem !== void 0) throw new
|
|
3375
|
+
if (problem !== void 0) throw new chunkVGAJJR3M_cjs.ValidationError(`withTenant: ${problem}`);
|
|
3134
3376
|
return new _LokiClient(this.config.with({ tenantId: id }), {}, { transport: this.#transport });
|
|
3135
3377
|
}
|
|
3136
3378
|
#tenantHeaders() {
|
|
@@ -3138,7 +3380,7 @@ var LokiClient = class _LokiClient {
|
|
|
3138
3380
|
}
|
|
3139
3381
|
async #request(options) {
|
|
3140
3382
|
if (this.#closed) {
|
|
3141
|
-
throw new
|
|
3383
|
+
throw new chunkVGAJJR3M_cjs.CancelledError(`${options.operation ?? options.path}: client is closed`);
|
|
3142
3384
|
}
|
|
3143
3385
|
try {
|
|
3144
3386
|
return await this.#transport.request({
|
|
@@ -3180,7 +3422,7 @@ var LokiClient = class _LokiClient {
|
|
|
3180
3422
|
});
|
|
3181
3423
|
return healthStatus("ok", {});
|
|
3182
3424
|
} catch (err) {
|
|
3183
|
-
if (err instanceof
|
|
3425
|
+
if (err instanceof chunkVGAJJR3M_cjs.LokiError && err.httpStatus === 503) {
|
|
3184
3426
|
const text = /^health: (.*) \(HTTP 503\)$/.exec(err.message)?.[1] ?? "unhealthy";
|
|
3185
3427
|
return healthStatus(text, { httpStatus: 503 }, false);
|
|
3186
3428
|
}
|
|
@@ -3219,7 +3461,7 @@ var LokiClient = class _LokiClient {
|
|
|
3219
3461
|
async serverVersion(options = {}) {
|
|
3220
3462
|
const info = await this.buildInfo(options);
|
|
3221
3463
|
if (info.version === "") {
|
|
3222
|
-
throw new
|
|
3464
|
+
throw new chunkVGAJJR3M_cjs.UnsupportedError("serverVersion: the service does not report a version");
|
|
3223
3465
|
}
|
|
3224
3466
|
return info.version;
|
|
3225
3467
|
}
|
|
@@ -3245,13 +3487,13 @@ var LokiClient = class _LokiClient {
|
|
|
3245
3487
|
return {
|
|
3246
3488
|
labels: s.labels,
|
|
3247
3489
|
entries: s.entries.map((e) => {
|
|
3248
|
-
if (typeof e.line !== "string") throw new
|
|
3490
|
+
if (typeof e.line !== "string") throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: line must be a string`);
|
|
3249
3491
|
for (const [k, v] of Object.entries(e.structuredMetadata ?? {})) {
|
|
3250
3492
|
if (k === "") {
|
|
3251
|
-
throw new
|
|
3493
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: structured metadata name must not be empty`);
|
|
3252
3494
|
}
|
|
3253
3495
|
if (typeof v !== "string") {
|
|
3254
|
-
throw new
|
|
3496
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: structured metadata ${k} must be a string`);
|
|
3255
3497
|
}
|
|
3256
3498
|
}
|
|
3257
3499
|
return { ...e, timestamp: toNanos(e.timestamp ?? now, "timestamp") };
|
|
@@ -3260,7 +3502,7 @@ var LokiClient = class _LokiClient {
|
|
|
3260
3502
|
});
|
|
3261
3503
|
const format = options.format ?? "json";
|
|
3262
3504
|
if (format !== "json" && format !== "protobuf") {
|
|
3263
|
-
throw new
|
|
3505
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: unknown format ${format}`);
|
|
3264
3506
|
}
|
|
3265
3507
|
let body;
|
|
3266
3508
|
const headers = {};
|
|
@@ -3293,7 +3535,7 @@ var LokiClient = class _LokiClient {
|
|
|
3293
3535
|
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
3294
3536
|
});
|
|
3295
3537
|
if (res.status === 260) {
|
|
3296
|
-
throw new
|
|
3538
|
+
throw new chunkVGAJJR3M_cjs.UnavailableError(
|
|
3297
3539
|
`${op}: ingestion is blocked by the Loki administrator (HTTP 260)`,
|
|
3298
3540
|
{
|
|
3299
3541
|
httpStatus: 260,
|
|
@@ -3339,7 +3581,7 @@ var LokiClient = class _LokiClient {
|
|
|
3339
3581
|
async query(logql, options = {}) {
|
|
3340
3582
|
checkQuery(logql, "query");
|
|
3341
3583
|
if (logql.trim().startsWith("{")) {
|
|
3342
|
-
throw new
|
|
3584
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(
|
|
3343
3585
|
"query: log queries cannot run as instant queries; use queryRange or search"
|
|
3344
3586
|
);
|
|
3345
3587
|
}
|
|
@@ -3422,7 +3664,7 @@ var LokiClient = class _LokiClient {
|
|
|
3422
3664
|
async series(matchers, options = {}) {
|
|
3423
3665
|
const list = typeof matchers === "string" ? [matchers] : [...matchers];
|
|
3424
3666
|
if (list.length === 0 || list.some((m) => m.trim() === "")) {
|
|
3425
|
-
throw new
|
|
3667
|
+
throw new chunkVGAJJR3M_cjs.ValidationError("series: at least one non-empty matcher is required");
|
|
3426
3668
|
}
|
|
3427
3669
|
return decodeSeries(
|
|
3428
3670
|
await this.#getJson(
|
|
@@ -3515,7 +3757,7 @@ var LokiClient = class _LokiClient {
|
|
|
3515
3757
|
);
|
|
3516
3758
|
const data = body?.data;
|
|
3517
3759
|
if (typeof data !== "string") {
|
|
3518
|
-
throw new
|
|
3760
|
+
throw new chunkVGAJJR3M_cjs.UnavailableError("formatQuery: unexpected response", { retryable: false });
|
|
3519
3761
|
}
|
|
3520
3762
|
return data;
|
|
3521
3763
|
}
|
|
@@ -3530,18 +3772,18 @@ var LokiClient = class _LokiClient {
|
|
|
3530
3772
|
const op = "tail";
|
|
3531
3773
|
checkQuery(logql, op);
|
|
3532
3774
|
if (!logql.trim().startsWith("{")) {
|
|
3533
|
-
throw new
|
|
3775
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: only log queries (starting with a selector) can be tailed`);
|
|
3534
3776
|
}
|
|
3535
3777
|
checkLimit(options.limit, op);
|
|
3536
3778
|
let delayFor;
|
|
3537
3779
|
if (options.delayForMs !== void 0) {
|
|
3538
3780
|
delayFor = Math.round(options.delayForMs / 1e3);
|
|
3539
3781
|
if (!Number.isFinite(delayFor) || delayFor < 0 || delayFor > 5) {
|
|
3540
|
-
throw new
|
|
3782
|
+
throw new chunkVGAJJR3M_cjs.ValidationError(`${op}: delayForMs must be between 0 and 5000`);
|
|
3541
3783
|
}
|
|
3542
3784
|
}
|
|
3543
3785
|
if (this.#closed || this.#transport.closed) {
|
|
3544
|
-
throw new
|
|
3786
|
+
throw new chunkVGAJJR3M_cjs.CancelledError(`${op}: client is closed`);
|
|
3545
3787
|
}
|
|
3546
3788
|
const url = this.#transport.buildUrl("/loki/api/v1/tail", {
|
|
3547
3789
|
query: logql,
|
|
@@ -3623,147 +3865,147 @@ var LokiClient = class _LokiClient {
|
|
|
3623
3865
|
|
|
3624
3866
|
Object.defineProperty(exports, "AuthenticationError", {
|
|
3625
3867
|
enumerable: true,
|
|
3626
|
-
get: function () { return
|
|
3868
|
+
get: function () { return chunkVGAJJR3M_cjs.AuthenticationError; }
|
|
3627
3869
|
});
|
|
3628
3870
|
Object.defineProperty(exports, "BaseLogQueryClient", {
|
|
3629
3871
|
enumerable: true,
|
|
3630
|
-
get: function () { return
|
|
3872
|
+
get: function () { return chunkVGAJJR3M_cjs.BaseLogQueryClient; }
|
|
3631
3873
|
});
|
|
3632
3874
|
Object.defineProperty(exports, "CancelledError", {
|
|
3633
3875
|
enumerable: true,
|
|
3634
|
-
get: function () { return
|
|
3876
|
+
get: function () { return chunkVGAJJR3M_cjs.CancelledError; }
|
|
3635
3877
|
});
|
|
3636
3878
|
Object.defineProperty(exports, "ConfigError", {
|
|
3637
3879
|
enumerable: true,
|
|
3638
|
-
get: function () { return
|
|
3880
|
+
get: function () { return chunkVGAJJR3M_cjs.ConfigError; }
|
|
3639
3881
|
});
|
|
3640
3882
|
Object.defineProperty(exports, "ConflictError", {
|
|
3641
3883
|
enumerable: true,
|
|
3642
|
-
get: function () { return
|
|
3884
|
+
get: function () { return chunkVGAJJR3M_cjs.ConflictError; }
|
|
3643
3885
|
});
|
|
3644
3886
|
Object.defineProperty(exports, "ErrorCode", {
|
|
3645
3887
|
enumerable: true,
|
|
3646
|
-
get: function () { return
|
|
3888
|
+
get: function () { return chunkVGAJJR3M_cjs.ErrorCode; }
|
|
3647
3889
|
});
|
|
3648
3890
|
Object.defineProperty(exports, "LokiError", {
|
|
3649
3891
|
enumerable: true,
|
|
3650
|
-
get: function () { return
|
|
3892
|
+
get: function () { return chunkVGAJJR3M_cjs.LokiError; }
|
|
3651
3893
|
});
|
|
3652
3894
|
Object.defineProperty(exports, "NotFoundError", {
|
|
3653
3895
|
enumerable: true,
|
|
3654
|
-
get: function () { return
|
|
3896
|
+
get: function () { return chunkVGAJJR3M_cjs.NotFoundError; }
|
|
3655
3897
|
});
|
|
3656
3898
|
Object.defineProperty(exports, "PermissionDeniedError", {
|
|
3657
3899
|
enumerable: true,
|
|
3658
|
-
get: function () { return
|
|
3900
|
+
get: function () { return chunkVGAJJR3M_cjs.PermissionDeniedError; }
|
|
3659
3901
|
});
|
|
3660
3902
|
Object.defineProperty(exports, "RateLimitError", {
|
|
3661
3903
|
enumerable: true,
|
|
3662
|
-
get: function () { return
|
|
3904
|
+
get: function () { return chunkVGAJJR3M_cjs.RateLimitError; }
|
|
3663
3905
|
});
|
|
3664
3906
|
Object.defineProperty(exports, "Severity", {
|
|
3665
3907
|
enumerable: true,
|
|
3666
|
-
get: function () { return
|
|
3908
|
+
get: function () { return chunkVGAJJR3M_cjs.Severity; }
|
|
3667
3909
|
});
|
|
3668
3910
|
Object.defineProperty(exports, "TimeoutError", {
|
|
3669
3911
|
enumerable: true,
|
|
3670
|
-
get: function () { return
|
|
3912
|
+
get: function () { return chunkVGAJJR3M_cjs.TimeoutError; }
|
|
3671
3913
|
});
|
|
3672
3914
|
Object.defineProperty(exports, "UnavailableError", {
|
|
3673
3915
|
enumerable: true,
|
|
3674
|
-
get: function () { return
|
|
3916
|
+
get: function () { return chunkVGAJJR3M_cjs.UnavailableError; }
|
|
3675
3917
|
});
|
|
3676
3918
|
Object.defineProperty(exports, "UnsupportedError", {
|
|
3677
3919
|
enumerable: true,
|
|
3678
|
-
get: function () { return
|
|
3920
|
+
get: function () { return chunkVGAJJR3M_cjs.UnsupportedError; }
|
|
3679
3921
|
});
|
|
3680
3922
|
Object.defineProperty(exports, "UnsupportedLogQueryClient", {
|
|
3681
3923
|
enumerable: true,
|
|
3682
|
-
get: function () { return
|
|
3924
|
+
get: function () { return chunkVGAJJR3M_cjs.UnsupportedLogQueryClient; }
|
|
3683
3925
|
});
|
|
3684
3926
|
Object.defineProperty(exports, "ValidationError", {
|
|
3685
3927
|
enumerable: true,
|
|
3686
|
-
get: function () { return
|
|
3928
|
+
get: function () { return chunkVGAJJR3M_cjs.ValidationError; }
|
|
3687
3929
|
});
|
|
3688
3930
|
Object.defineProperty(exports, "canonicalSeverity", {
|
|
3689
3931
|
enumerable: true,
|
|
3690
|
-
get: function () { return
|
|
3932
|
+
get: function () { return chunkVGAJJR3M_cjs.canonicalSeverity; }
|
|
3691
3933
|
});
|
|
3692
3934
|
Object.defineProperty(exports, "codeForStatus", {
|
|
3693
3935
|
enumerable: true,
|
|
3694
|
-
get: function () { return
|
|
3936
|
+
get: function () { return chunkVGAJJR3M_cjs.codeForStatus; }
|
|
3695
3937
|
});
|
|
3696
3938
|
Object.defineProperty(exports, "errorForCode", {
|
|
3697
3939
|
enumerable: true,
|
|
3698
|
-
get: function () { return
|
|
3940
|
+
get: function () { return chunkVGAJJR3M_cjs.errorForCode; }
|
|
3699
3941
|
});
|
|
3700
3942
|
Object.defineProperty(exports, "errorForStatus", {
|
|
3701
3943
|
enumerable: true,
|
|
3702
|
-
get: function () { return
|
|
3944
|
+
get: function () { return chunkVGAJJR3M_cjs.errorForStatus; }
|
|
3703
3945
|
});
|
|
3704
3946
|
Object.defineProperty(exports, "isLokiError", {
|
|
3705
3947
|
enumerable: true,
|
|
3706
|
-
get: function () { return
|
|
3948
|
+
get: function () { return chunkVGAJJR3M_cjs.isLokiError; }
|
|
3707
3949
|
});
|
|
3708
3950
|
Object.defineProperty(exports, "logRecordByteSize", {
|
|
3709
3951
|
enumerable: true,
|
|
3710
|
-
get: function () { return
|
|
3952
|
+
get: function () { return chunkVGAJJR3M_cjs.logRecordByteSize; }
|
|
3711
3953
|
});
|
|
3712
3954
|
Object.defineProperty(exports, "logRecordFromJson", {
|
|
3713
3955
|
enumerable: true,
|
|
3714
|
-
get: function () { return
|
|
3956
|
+
get: function () { return chunkVGAJJR3M_cjs.logRecordFromJson; }
|
|
3715
3957
|
});
|
|
3716
3958
|
Object.defineProperty(exports, "logRecordToJson", {
|
|
3717
3959
|
enumerable: true,
|
|
3718
|
-
get: function () { return
|
|
3960
|
+
get: function () { return chunkVGAJJR3M_cjs.logRecordToJson; }
|
|
3719
3961
|
});
|
|
3720
3962
|
Object.defineProperty(exports, "parseLogRecord", {
|
|
3721
3963
|
enumerable: true,
|
|
3722
|
-
get: function () { return
|
|
3964
|
+
get: function () { return chunkVGAJJR3M_cjs.parseLogRecord; }
|
|
3723
3965
|
});
|
|
3724
3966
|
Object.defineProperty(exports, "parseSeverity", {
|
|
3725
3967
|
enumerable: true,
|
|
3726
|
-
get: function () { return
|
|
3968
|
+
get: function () { return chunkVGAJJR3M_cjs.parseSeverity; }
|
|
3727
3969
|
});
|
|
3728
3970
|
Object.defineProperty(exports, "pollTail", {
|
|
3729
3971
|
enumerable: true,
|
|
3730
|
-
get: function () { return
|
|
3972
|
+
get: function () { return chunkVGAJJR3M_cjs.pollTail; }
|
|
3731
3973
|
});
|
|
3732
3974
|
Object.defineProperty(exports, "pollUntil", {
|
|
3733
3975
|
enumerable: true,
|
|
3734
|
-
get: function () { return
|
|
3976
|
+
get: function () { return chunkVGAJJR3M_cjs.pollUntil; }
|
|
3735
3977
|
});
|
|
3736
3978
|
Object.defineProperty(exports, "reasonForCode", {
|
|
3737
3979
|
enumerable: true,
|
|
3738
|
-
get: function () { return
|
|
3980
|
+
get: function () { return chunkVGAJJR3M_cjs.reasonForCode; }
|
|
3739
3981
|
});
|
|
3740
3982
|
Object.defineProperty(exports, "serializeLogRecord", {
|
|
3741
3983
|
enumerable: true,
|
|
3742
|
-
get: function () { return
|
|
3984
|
+
get: function () { return chunkVGAJJR3M_cjs.serializeLogRecord; }
|
|
3743
3985
|
});
|
|
3744
3986
|
Object.defineProperty(exports, "severityText", {
|
|
3745
3987
|
enumerable: true,
|
|
3746
|
-
get: function () { return
|
|
3988
|
+
get: function () { return chunkVGAJJR3M_cjs.severityText; }
|
|
3747
3989
|
});
|
|
3748
3990
|
Object.defineProperty(exports, "sleep", {
|
|
3749
3991
|
enumerable: true,
|
|
3750
|
-
get: function () { return
|
|
3992
|
+
get: function () { return chunkVGAJJR3M_cjs.sleep; }
|
|
3751
3993
|
});
|
|
3752
3994
|
Object.defineProperty(exports, "throwIfAborted", {
|
|
3753
3995
|
enumerable: true,
|
|
3754
|
-
get: function () { return
|
|
3996
|
+
get: function () { return chunkVGAJJR3M_cjs.throwIfAborted; }
|
|
3755
3997
|
});
|
|
3756
3998
|
Object.defineProperty(exports, "toAttrValue", {
|
|
3757
3999
|
enumerable: true,
|
|
3758
|
-
get: function () { return
|
|
4000
|
+
get: function () { return chunkVGAJJR3M_cjs.toAttrValue; }
|
|
3759
4001
|
});
|
|
3760
4002
|
Object.defineProperty(exports, "toAttributes", {
|
|
3761
4003
|
enumerable: true,
|
|
3762
|
-
get: function () { return
|
|
4004
|
+
get: function () { return chunkVGAJJR3M_cjs.toAttributes; }
|
|
3763
4005
|
});
|
|
3764
4006
|
Object.defineProperty(exports, "waitForLog", {
|
|
3765
4007
|
enumerable: true,
|
|
3766
|
-
get: function () { return
|
|
4008
|
+
get: function () { return chunkVGAJJR3M_cjs.waitForLog; }
|
|
3767
4009
|
});
|
|
3768
4010
|
exports.ALL_STREAMS_SELECTOR = ALL_STREAMS_SELECTOR;
|
|
3769
4011
|
exports.BatchProcessor = BatchProcessor;
|
|
@@ -3779,6 +4021,7 @@ exports.EnvReader = EnvReader;
|
|
|
3779
4021
|
exports.HttpTransport = HttpTransport;
|
|
3780
4022
|
exports.LABEL_NAME_PATTERN = LABEL_NAME_PATTERN;
|
|
3781
4023
|
exports.LANGUAGE = LANGUAGE;
|
|
4024
|
+
exports.LOG_SHIPPED_FIELD = LOG_SHIPPED_FIELD;
|
|
3782
4025
|
exports.LogQL = LogQL;
|
|
3783
4026
|
exports.Logger = Logger;
|
|
3784
4027
|
exports.LokiClient = LokiClient;
|
|
@@ -3806,6 +4049,7 @@ exports.WinstonTransport = WinstonTransport;
|
|
|
3806
4049
|
exports.attrToString = attrToString;
|
|
3807
4050
|
exports.createDispatcher = createDispatcher;
|
|
3808
4051
|
exports.createPinoTransport = createPinoTransport;
|
|
4052
|
+
exports.currentRequestId = currentRequestId;
|
|
3809
4053
|
exports.dateToNanos = dateToNanos;
|
|
3810
4054
|
exports.decodeBuildInfo = decodeBuildInfo;
|
|
3811
4055
|
exports.decodeCursor = decodeCursor;
|
|
@@ -3823,7 +4067,9 @@ exports.encodeCursor = encodeCursor;
|
|
|
3823
4067
|
exports.encodePushRequest = encodePushRequest;
|
|
3824
4068
|
exports.entryToLogRecord = entryToLogRecord;
|
|
3825
4069
|
exports.formatLabelSet = formatLabelSet;
|
|
4070
|
+
exports.getLogging = getLogging;
|
|
3826
4071
|
exports.healthStatus = healthStatus;
|
|
4072
|
+
exports.initLogging = initLogging;
|
|
3827
4073
|
exports.isHealthyWord = isHealthyWord;
|
|
3828
4074
|
exports.isIdempotentMethod = isIdempotentMethod;
|
|
3829
4075
|
exports.isRetryableStatus = isRetryableStatus;
|
|
@@ -3853,6 +4099,7 @@ exports.redactHeaders = redactHeaders;
|
|
|
3853
4099
|
exports.redactSecretsInText = redactSecretsInText;
|
|
3854
4100
|
exports.redactText = redactText;
|
|
3855
4101
|
exports.redactUrl = redactUrl;
|
|
4102
|
+
exports.requestLogger = requestLogger;
|
|
3856
4103
|
exports.resolveBatchOptions = resolveBatchOptions;
|
|
3857
4104
|
exports.resolveCommonConfig = resolveCommonConfig;
|
|
3858
4105
|
exports.safeCall = safeCall;
|
|
@@ -3861,6 +4108,7 @@ exports.secondsToDate = secondsToDate;
|
|
|
3861
4108
|
exports.secretValues = secretValues;
|
|
3862
4109
|
exports.silentLogger = silentLogger;
|
|
3863
4110
|
exports.snappyCompress = snappyCompress;
|
|
4111
|
+
exports.stdoutLine = stdoutLine;
|
|
3864
4112
|
exports.stringMap = stringMap;
|
|
3865
4113
|
exports.tenantIdProblem = tenantIdProblem;
|
|
3866
4114
|
exports.toNanos = toNanos;
|
|
@@ -3870,5 +4118,6 @@ exports.validateCommonConfig = validateCommonConfig;
|
|
|
3870
4118
|
exports.validateLabelName = validateLabelName;
|
|
3871
4119
|
exports.validateLabels = validateLabels;
|
|
3872
4120
|
exports.winstonLevelToSeverity = winstonLevelToSeverity;
|
|
4121
|
+
exports.withRequestId = withRequestId;
|
|
3873
4122
|
//# sourceMappingURL=index.cjs.map
|
|
3874
4123
|
//# sourceMappingURL=index.cjs.map
|