@zuplo/cli 7.7.8 → 7.7.9
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/node_modules/@posthog/core/dist/error-tracking/parsers/base.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/error-tracking/parsers/base.js +19 -2
- package/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs +19 -2
- package/node_modules/@posthog/core/dist/index.d.ts +7 -0
- package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/index.js +82 -21
- package/node_modules/@posthog/core/dist/index.mjs +4 -0
- package/node_modules/@posthog/core/dist/logs/index.d.ts +3 -2
- package/node_modules/@posthog/core/dist/logs/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/logs/index.js +28 -22
- package/node_modules/@posthog/core/dist/logs/index.mjs +29 -23
- package/node_modules/@posthog/core/dist/logs/logs-utils.js +1 -1
- package/node_modules/@posthog/core/dist/logs/logs-utils.mjs +2 -2
- package/node_modules/@posthog/core/dist/logs/types.d.ts +2 -2
- package/node_modules/@posthog/core/dist/metrics/index.d.ts +5 -2
- package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/metrics/index.js +28 -14
- package/node_modules/@posthog/core/dist/metrics/index.mjs +29 -15
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.js +1 -2
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs +2 -3
- package/node_modules/@posthog/core/dist/metrics/types.d.ts +7 -0
- package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +32 -4
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +68 -20
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +68 -20
- package/node_modules/@posthog/core/dist/traces/config.d.ts +13 -0
- package/node_modules/@posthog/core/dist/traces/config.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/config.js +101 -0
- package/node_modules/@posthog/core/dist/traces/config.mjs +63 -0
- package/node_modules/@posthog/core/dist/traces/context.d.ts +18 -0
- package/node_modules/@posthog/core/dist/traces/context.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/context.js +53 -0
- package/node_modules/@posthog/core/dist/traces/context.mjs +15 -0
- package/node_modules/@posthog/core/dist/traces/ids.d.ts +12 -0
- package/node_modules/@posthog/core/dist/traces/ids.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/ids.js +92 -0
- package/node_modules/@posthog/core/dist/traces/ids.mjs +42 -0
- package/node_modules/@posthog/core/dist/traces/index.d.ts +150 -0
- package/node_modules/@posthog/core/dist/traces/index.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/index.js +551 -0
- package/node_modules/@posthog/core/dist/traces/index.mjs +513 -0
- package/node_modules/@posthog/core/dist/traces/otlp.d.ts +24 -0
- package/node_modules/@posthog/core/dist/traces/otlp.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/otlp.js +158 -0
- package/node_modules/@posthog/core/dist/traces/otlp.mjs +108 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.d.ts +32 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.js +93 -0
- package/node_modules/@posthog/core/dist/traces/sanitize.mjs +43 -0
- package/node_modules/@posthog/core/dist/traces/span.d.ts +189 -0
- package/node_modules/@posthog/core/dist/traces/span.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/span.js +533 -0
- package/node_modules/@posthog/core/dist/traces/span.mjs +462 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.d.ts +51 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.js +116 -0
- package/node_modules/@posthog/core/dist/traces/traceparent.mjs +63 -0
- package/node_modules/@posthog/core/dist/traces/types.d.ts +114 -0
- package/node_modules/@posthog/core/dist/traces/types.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/traces/types.js +18 -0
- package/node_modules/@posthog/core/dist/traces/types.mjs +1 -0
- package/node_modules/@posthog/core/dist/utils/backoff.d.ts +23 -0
- package/node_modules/@posthog/core/dist/utils/backoff.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/utils/backoff.js +65 -0
- package/node_modules/@posthog/core/dist/utils/backoff.mjs +14 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.d.ts +26 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.js +67 -0
- package/node_modules/@posthog/core/dist/utils/flush-timer.mjs +29 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.d.ts +7 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/json-utils.js +27 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.mjs +25 -1
- package/node_modules/@posthog/core/dist/utils/otlp-resource.d.ts +13 -2
- package/node_modules/@posthog/core/dist/utils/otlp-resource.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/otlp-resource.js +34 -7
- package/node_modules/@posthog/core/dist/utils/otlp-resource.mjs +26 -2
- package/node_modules/@posthog/core/dist/utils/retry-after.d.ts +55 -0
- package/node_modules/@posthog/core/dist/utils/retry-after.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/utils/retry-after.js +95 -0
- package/node_modules/@posthog/core/dist/utils/retry-after.mjs +50 -0
- package/node_modules/@posthog/core/package.json +3 -3
- package/node_modules/@posthog/core/src/error-tracking/parsers/base.spec.ts +77 -7
- package/node_modules/@posthog/core/src/error-tracking/parsers/base.ts +42 -19
- package/node_modules/@posthog/core/src/index.ts +18 -0
- package/node_modules/@posthog/core/src/logs/index.spec.ts +490 -2
- package/node_modules/@posthog/core/src/logs/index.ts +63 -31
- package/node_modules/@posthog/core/src/logs/logs-utils.ts +2 -2
- package/node_modules/@posthog/core/src/logs/types.ts +2 -2
- package/node_modules/@posthog/core/src/metrics/index.spec.ts +304 -0
- package/node_modules/@posthog/core/src/metrics/index.ts +53 -16
- package/node_modules/@posthog/core/src/metrics/metrics-utils.ts +2 -3
- package/node_modules/@posthog/core/src/metrics/types.ts +10 -2
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +157 -38
- package/node_modules/@posthog/core/src/traces/config.spec.ts +271 -0
- package/node_modules/@posthog/core/src/traces/config.ts +142 -0
- package/node_modules/@posthog/core/src/traces/context.ts +30 -0
- package/node_modules/@posthog/core/src/traces/ids.spec.ts +115 -0
- package/node_modules/@posthog/core/src/traces/ids.ts +75 -0
- package/node_modules/@posthog/core/src/traces/index.spec.ts +3187 -0
- package/node_modules/@posthog/core/src/traces/index.ts +1060 -0
- package/node_modules/@posthog/core/src/traces/live-spans.spec.ts +69 -0
- package/node_modules/@posthog/core/src/traces/otlp.spec.ts +368 -0
- package/node_modules/@posthog/core/src/traces/otlp.ts +191 -0
- package/node_modules/@posthog/core/src/traces/sanitize.ts +116 -0
- package/node_modules/@posthog/core/src/traces/span.spec.ts +1122 -0
- package/node_modules/@posthog/core/src/traces/span.ts +822 -0
- package/node_modules/@posthog/core/src/traces/traceparent.spec.ts +184 -0
- package/node_modules/@posthog/core/src/traces/traceparent.ts +172 -0
- package/node_modules/@posthog/core/src/traces/types.ts +140 -0
- package/node_modules/@posthog/core/src/utils/backoff.ts +44 -0
- package/node_modules/@posthog/core/src/utils/flush-timer.ts +50 -0
- package/node_modules/@posthog/core/src/utils/json-utils.ts +33 -0
- package/node_modules/@posthog/core/src/utils/otlp-resource.spec.ts +55 -9
- package/node_modules/@posthog/core/src/utils/otlp-resource.ts +45 -4
- package/node_modules/@posthog/core/src/utils/retry-after.ts +135 -0
- package/node_modules/@posthog/types/dist/index.d.ts +1 -0
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +10 -5
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/traces.d.ts +387 -0
- package/node_modules/@posthog/types/dist/traces.d.ts.map +1 -0
- package/node_modules/@posthog/types/dist/traces.js +18 -0
- package/node_modules/@posthog/types/dist/traces.mjs +1 -0
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/index.ts +19 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +10 -5
- package/node_modules/@posthog/types/src/traces.ts +429 -0
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-DRQ5CMVC.js → chunk-KNAYKBEE.js} +80 -80
- package/node_modules/@zuplo/runtime/out/esm/chunk-KNAYKBEE.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-DRQ5CMVC.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DRQ5CMVC.js.LEGAL.txt → chunk-KNAYKBEE.js.LEGAL.txt} +0 -0
|
@@ -33,7 +33,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
const external_logs_utils_js_namespaceObject = require("./logs-utils.js");
|
|
34
34
|
const external_types_js_namespaceObject = require("../types.js");
|
|
35
35
|
const index_js_namespaceObject = require("../utils/index.js");
|
|
36
|
-
const
|
|
36
|
+
const flush_timer_js_namespaceObject = require("../utils/flush-timer.js");
|
|
37
|
+
const retry_after_js_namespaceObject = require("../utils/retry-after.js");
|
|
38
|
+
const backoff_js_namespaceObject = require("../utils/backoff.js");
|
|
37
39
|
class PostHogLogs {
|
|
38
40
|
constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve(), _scopeName){
|
|
39
41
|
this._instance = _instance;
|
|
@@ -43,10 +45,13 @@ class PostHogLogs {
|
|
|
43
45
|
this._onReady = _onReady;
|
|
44
46
|
this._waitForStoragePersist = _waitForStoragePersist;
|
|
45
47
|
this._scopeName = _scopeName;
|
|
48
|
+
this._flushTimer = new flush_timer_js_namespaceObject.FlushTimer(()=>this._flushInBackground());
|
|
46
49
|
this._flushPromise = null;
|
|
47
50
|
this._evictedSinceAdvance = 0;
|
|
48
51
|
this._queueGeneration = 0;
|
|
52
|
+
this._retryAfter = new retry_after_js_namespaceObject.RetryAfterWindow();
|
|
49
53
|
this._consecutiveFlushFailures = 0;
|
|
54
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
50
55
|
this._intervalWindowStart = 0;
|
|
51
56
|
this._intervalLogCount = 0;
|
|
52
57
|
this._droppedWarned = false;
|
|
@@ -62,15 +67,22 @@ class PostHogLogs {
|
|
|
62
67
|
this._instance.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue, []);
|
|
63
68
|
}
|
|
64
69
|
reset() {
|
|
65
|
-
this.
|
|
70
|
+
this._flushTimer.clear();
|
|
66
71
|
this._intervalWindowStart = 0;
|
|
67
72
|
this._intervalLogCount = 0;
|
|
68
73
|
this._droppedWarned = false;
|
|
69
74
|
this._consecutiveFlushFailures = 0;
|
|
75
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
76
|
+
this._retryAfter.reset();
|
|
70
77
|
this._maxBatchRecordsPerPost = this._config.maxBatchRecordsPerPost;
|
|
71
78
|
}
|
|
72
79
|
onReconnect() {
|
|
73
80
|
this._consecutiveFlushFailures = 0;
|
|
81
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
82
|
+
if (this._retryAfter.isOpen()) {
|
|
83
|
+
if (this._hasQueuedRecords()) this._armFlushTimer();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
74
86
|
this._flushInBackground();
|
|
75
87
|
}
|
|
76
88
|
captureLog(options, capturedAt) {
|
|
@@ -135,7 +147,7 @@ class PostHogLogs {
|
|
|
135
147
|
return this._flushPromise;
|
|
136
148
|
}
|
|
137
149
|
async _flushInner() {
|
|
138
|
-
this.
|
|
150
|
+
this._flushTimer.clear();
|
|
139
151
|
let queue = this._instance.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue) ?? [];
|
|
140
152
|
if (0 === queue.length) return;
|
|
141
153
|
const originalQueueLength = queue.length;
|
|
@@ -151,11 +163,13 @@ class PostHogLogs {
|
|
|
151
163
|
if (this._queueGeneration !== generation) return;
|
|
152
164
|
if ('too-large' === outcome.kind && batch.length > 1) {
|
|
153
165
|
this._maxBatchRecordsPerPost = Math.max(1, Math.floor(batch.length / 2));
|
|
154
|
-
this._logger.warn(`
|
|
166
|
+
this._logger.warn(`Logs batch of size ${batch.length} was too large for the ingestion endpoint, reducing batch size to ${this._maxBatchRecordsPerPost}`);
|
|
155
167
|
continue;
|
|
156
168
|
}
|
|
169
|
+
this._retryAfter.record(outcome);
|
|
170
|
+
if (this._flushTimer.pending) this._flushTimer.arm(Math.max(this._flushIntervalMs, this._retryAfter.remainingMs()));
|
|
157
171
|
if ('retry-later' === outcome.kind) throw outcome.error;
|
|
158
|
-
if ('too-large' === outcome.kind) this._logger.warn('Dropping a single log record
|
|
172
|
+
if ('too-large' === outcome.kind) this._logger.warn('Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further.');
|
|
159
173
|
else if ('ok' === outcome.kind && this._maxBatchRecordsPerPost < this._config.maxBatchRecordsPerPost) this._maxBatchRecordsPerPost = Math.min(this._config.maxBatchRecordsPerPost, this._maxBatchRecordsPerPost + 1);
|
|
160
174
|
await this._persistQueueAdvance(batch.length);
|
|
161
175
|
queue = this._instance.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue) ?? [];
|
|
@@ -183,26 +197,22 @@ class PostHogLogs {
|
|
|
183
197
|
}
|
|
184
198
|
queue.push(entry);
|
|
185
199
|
this._instance.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue, queue);
|
|
186
|
-
if (queue.length >= this._maxBufferSize) return void this._flushInBackground();
|
|
200
|
+
if (queue.length >= this._maxBufferSize && !this._retryAfter.isOpen()) return void this._flushInBackground();
|
|
187
201
|
this._armFlushTimer();
|
|
188
202
|
}
|
|
189
|
-
_armFlushTimer(
|
|
190
|
-
if (this._flushTimer) return;
|
|
191
|
-
this._flushTimer
|
|
192
|
-
this._flushTimer = void 0;
|
|
193
|
-
this._flushInBackground();
|
|
194
|
-
}, delayMs);
|
|
203
|
+
_armFlushTimer() {
|
|
204
|
+
if (this._flushTimer.pending) return;
|
|
205
|
+
this._flushTimer.arm(Math.max(this._flushIntervalMs, this._retryAfter.remainingMs()));
|
|
195
206
|
}
|
|
196
207
|
_nextFlushDelay() {
|
|
197
|
-
|
|
198
|
-
return this._flushIntervalMs * 2 ** exponent;
|
|
208
|
+
return Math.max((0, backoff_js_namespaceObject.backoffDelayMs)(this._flushIntervalMs, this._consecutiveFlushFailures, this._flushJitter, backoff_js_namespaceObject.MAX_FLUSH_BACKOFF_MS), this._retryAfter.remainingMs());
|
|
199
209
|
}
|
|
200
210
|
_hasQueuedRecords() {
|
|
201
211
|
const queue = this._instance.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.LogsQueue);
|
|
202
212
|
return !!queue && queue.length > 0;
|
|
203
213
|
}
|
|
204
214
|
async shutdown(timeoutMs) {
|
|
205
|
-
this.
|
|
215
|
+
this._flushTimer.clear();
|
|
206
216
|
const flushPromise = this.flush().catch(()=>{});
|
|
207
217
|
if (void 0 === timeoutMs) return void await flushPromise;
|
|
208
218
|
await (0, index_js_namespaceObject.raceWithTimeout)(flushPromise, timeoutMs);
|
|
@@ -216,19 +226,15 @@ class PostHogLogs {
|
|
|
216
226
|
_flushInBackground() {
|
|
217
227
|
this.flush().then(()=>{
|
|
218
228
|
this._consecutiveFlushFailures = 0;
|
|
229
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
219
230
|
}, (err)=>{
|
|
220
231
|
this._consecutiveFlushFailures++;
|
|
232
|
+
this._flushJitter = (0, backoff_js_namespaceObject.drawJitter)();
|
|
221
233
|
this._logger.error('PostHog logs flush failed:', err);
|
|
222
234
|
}).finally(()=>{
|
|
223
|
-
if (!this._instance.isDisabled && this._hasQueuedRecords()) this.
|
|
235
|
+
if (!this._instance.isDisabled && this._hasQueuedRecords()) this._flushTimer.armNoEarlierThan(this._nextFlushDelay());
|
|
224
236
|
});
|
|
225
237
|
}
|
|
226
|
-
_clearFlushTimer() {
|
|
227
|
-
if (this._flushTimer) {
|
|
228
|
-
clearTimeout(this._flushTimer);
|
|
229
|
-
this._flushTimer = void 0;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
238
|
}
|
|
233
239
|
exports.PostHogLogs = __webpack_exports__.PostHogLogs;
|
|
234
240
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { buildOtlpLogRecord, buildOtlpLogsPayload, buildResourceAttributes } from "./logs-utils.mjs";
|
|
2
2
|
import { PostHogPersistedProperty } from "../types.mjs";
|
|
3
|
-
import { isArray, raceWithTimeout
|
|
4
|
-
|
|
3
|
+
import { isArray, raceWithTimeout } from "../utils/index.mjs";
|
|
4
|
+
import { FlushTimer } from "../utils/flush-timer.mjs";
|
|
5
|
+
import { RetryAfterWindow } from "../utils/retry-after.mjs";
|
|
6
|
+
import { MAX_FLUSH_BACKOFF_MS, NO_JITTER, backoffDelayMs, drawJitter } from "../utils/backoff.mjs";
|
|
5
7
|
class PostHogLogs {
|
|
6
8
|
constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve(), _scopeName){
|
|
7
9
|
this._instance = _instance;
|
|
@@ -11,10 +13,13 @@ class PostHogLogs {
|
|
|
11
13
|
this._onReady = _onReady;
|
|
12
14
|
this._waitForStoragePersist = _waitForStoragePersist;
|
|
13
15
|
this._scopeName = _scopeName;
|
|
16
|
+
this._flushTimer = new FlushTimer(()=>this._flushInBackground());
|
|
14
17
|
this._flushPromise = null;
|
|
15
18
|
this._evictedSinceAdvance = 0;
|
|
16
19
|
this._queueGeneration = 0;
|
|
20
|
+
this._retryAfter = new RetryAfterWindow();
|
|
17
21
|
this._consecutiveFlushFailures = 0;
|
|
22
|
+
this._flushJitter = NO_JITTER;
|
|
18
23
|
this._intervalWindowStart = 0;
|
|
19
24
|
this._intervalLogCount = 0;
|
|
20
25
|
this._droppedWarned = false;
|
|
@@ -30,15 +35,22 @@ class PostHogLogs {
|
|
|
30
35
|
this._instance.setPersistedProperty(PostHogPersistedProperty.LogsQueue, []);
|
|
31
36
|
}
|
|
32
37
|
reset() {
|
|
33
|
-
this.
|
|
38
|
+
this._flushTimer.clear();
|
|
34
39
|
this._intervalWindowStart = 0;
|
|
35
40
|
this._intervalLogCount = 0;
|
|
36
41
|
this._droppedWarned = false;
|
|
37
42
|
this._consecutiveFlushFailures = 0;
|
|
43
|
+
this._flushJitter = NO_JITTER;
|
|
44
|
+
this._retryAfter.reset();
|
|
38
45
|
this._maxBatchRecordsPerPost = this._config.maxBatchRecordsPerPost;
|
|
39
46
|
}
|
|
40
47
|
onReconnect() {
|
|
41
48
|
this._consecutiveFlushFailures = 0;
|
|
49
|
+
this._flushJitter = NO_JITTER;
|
|
50
|
+
if (this._retryAfter.isOpen()) {
|
|
51
|
+
if (this._hasQueuedRecords()) this._armFlushTimer();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
42
54
|
this._flushInBackground();
|
|
43
55
|
}
|
|
44
56
|
captureLog(options, capturedAt) {
|
|
@@ -103,7 +115,7 @@ class PostHogLogs {
|
|
|
103
115
|
return this._flushPromise;
|
|
104
116
|
}
|
|
105
117
|
async _flushInner() {
|
|
106
|
-
this.
|
|
118
|
+
this._flushTimer.clear();
|
|
107
119
|
let queue = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue) ?? [];
|
|
108
120
|
if (0 === queue.length) return;
|
|
109
121
|
const originalQueueLength = queue.length;
|
|
@@ -119,11 +131,13 @@ class PostHogLogs {
|
|
|
119
131
|
if (this._queueGeneration !== generation) return;
|
|
120
132
|
if ('too-large' === outcome.kind && batch.length > 1) {
|
|
121
133
|
this._maxBatchRecordsPerPost = Math.max(1, Math.floor(batch.length / 2));
|
|
122
|
-
this._logger.warn(`
|
|
134
|
+
this._logger.warn(`Logs batch of size ${batch.length} was too large for the ingestion endpoint, reducing batch size to ${this._maxBatchRecordsPerPost}`);
|
|
123
135
|
continue;
|
|
124
136
|
}
|
|
137
|
+
this._retryAfter.record(outcome);
|
|
138
|
+
if (this._flushTimer.pending) this._flushTimer.arm(Math.max(this._flushIntervalMs, this._retryAfter.remainingMs()));
|
|
125
139
|
if ('retry-later' === outcome.kind) throw outcome.error;
|
|
126
|
-
if ('too-large' === outcome.kind) this._logger.warn('Dropping a single log record
|
|
140
|
+
if ('too-large' === outcome.kind) this._logger.warn('Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further.');
|
|
127
141
|
else if ('ok' === outcome.kind && this._maxBatchRecordsPerPost < this._config.maxBatchRecordsPerPost) this._maxBatchRecordsPerPost = Math.min(this._config.maxBatchRecordsPerPost, this._maxBatchRecordsPerPost + 1);
|
|
128
142
|
await this._persistQueueAdvance(batch.length);
|
|
129
143
|
queue = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue) ?? [];
|
|
@@ -151,26 +165,22 @@ class PostHogLogs {
|
|
|
151
165
|
}
|
|
152
166
|
queue.push(entry);
|
|
153
167
|
this._instance.setPersistedProperty(PostHogPersistedProperty.LogsQueue, queue);
|
|
154
|
-
if (queue.length >= this._maxBufferSize) return void this._flushInBackground();
|
|
168
|
+
if (queue.length >= this._maxBufferSize && !this._retryAfter.isOpen()) return void this._flushInBackground();
|
|
155
169
|
this._armFlushTimer();
|
|
156
170
|
}
|
|
157
|
-
_armFlushTimer(
|
|
158
|
-
if (this._flushTimer) return;
|
|
159
|
-
this._flushTimer
|
|
160
|
-
this._flushTimer = void 0;
|
|
161
|
-
this._flushInBackground();
|
|
162
|
-
}, delayMs);
|
|
171
|
+
_armFlushTimer() {
|
|
172
|
+
if (this._flushTimer.pending) return;
|
|
173
|
+
this._flushTimer.arm(Math.max(this._flushIntervalMs, this._retryAfter.remainingMs()));
|
|
163
174
|
}
|
|
164
175
|
_nextFlushDelay() {
|
|
165
|
-
|
|
166
|
-
return this._flushIntervalMs * 2 ** exponent;
|
|
176
|
+
return Math.max(backoffDelayMs(this._flushIntervalMs, this._consecutiveFlushFailures, this._flushJitter, MAX_FLUSH_BACKOFF_MS), this._retryAfter.remainingMs());
|
|
167
177
|
}
|
|
168
178
|
_hasQueuedRecords() {
|
|
169
179
|
const queue = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue);
|
|
170
180
|
return !!queue && queue.length > 0;
|
|
171
181
|
}
|
|
172
182
|
async shutdown(timeoutMs) {
|
|
173
|
-
this.
|
|
183
|
+
this._flushTimer.clear();
|
|
174
184
|
const flushPromise = this.flush().catch(()=>{});
|
|
175
185
|
if (void 0 === timeoutMs) return void await flushPromise;
|
|
176
186
|
await raceWithTimeout(flushPromise, timeoutMs);
|
|
@@ -184,18 +194,14 @@ class PostHogLogs {
|
|
|
184
194
|
_flushInBackground() {
|
|
185
195
|
this.flush().then(()=>{
|
|
186
196
|
this._consecutiveFlushFailures = 0;
|
|
197
|
+
this._flushJitter = NO_JITTER;
|
|
187
198
|
}, (err)=>{
|
|
188
199
|
this._consecutiveFlushFailures++;
|
|
200
|
+
this._flushJitter = drawJitter();
|
|
189
201
|
this._logger.error('PostHog logs flush failed:', err);
|
|
190
202
|
}).finally(()=>{
|
|
191
|
-
if (!this._instance.isDisabled && this._hasQueuedRecords()) this.
|
|
203
|
+
if (!this._instance.isDisabled && this._hasQueuedRecords()) this._flushTimer.armNoEarlierThan(this._nextFlushDelay());
|
|
192
204
|
});
|
|
193
205
|
}
|
|
194
|
-
_clearFlushTimer() {
|
|
195
|
-
if (this._flushTimer) {
|
|
196
|
-
clearTimeout(this._flushTimer);
|
|
197
|
-
this._flushTimer = void 0;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
206
|
}
|
|
201
207
|
export { PostHogLogs };
|
|
@@ -144,7 +144,7 @@ function buildOtlpLogsPayload(logRecords, resourceAttributes, scopeName, scopeVe
|
|
|
144
144
|
resourceLogs: [
|
|
145
145
|
{
|
|
146
146
|
resource: {
|
|
147
|
-
attributes: (0,
|
|
147
|
+
attributes: (0, otlp_resource_js_namespaceObject.toOtlpResourceKeyValueList)(resourceAttributes)
|
|
148
148
|
},
|
|
149
149
|
scopeLogs: [
|
|
150
150
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNullish, isNumber, isUndefined } from "../utils/index.mjs";
|
|
2
2
|
import { UNSERIALIZABLE_VALUE, sanitizeString } from "../utils/json-utils.mjs";
|
|
3
3
|
import { toOtlpKeyValueList } from "../utils/otlp-any-value.mjs";
|
|
4
|
-
import { buildOtlpResourceAttributes } from "../utils/otlp-resource.mjs";
|
|
4
|
+
import { buildOtlpResourceAttributes, toOtlpResourceKeyValueList } from "../utils/otlp-resource.mjs";
|
|
5
5
|
const OTLP_SEVERITY_MAP = {
|
|
6
6
|
trace: {
|
|
7
7
|
text: 'TRACE',
|
|
@@ -108,7 +108,7 @@ function buildOtlpLogsPayload(logRecords, resourceAttributes, scopeName, scopeVe
|
|
|
108
108
|
resourceLogs: [
|
|
109
109
|
{
|
|
110
110
|
resource: {
|
|
111
|
-
attributes:
|
|
111
|
+
attributes: toOtlpResourceKeyValueList(resourceAttributes)
|
|
112
112
|
},
|
|
113
113
|
scopeLogs: [
|
|
114
114
|
{
|
|
@@ -93,8 +93,8 @@ export interface PostHogLogsConfig {
|
|
|
93
93
|
maxBufferSize?: number;
|
|
94
94
|
/**
|
|
95
95
|
* Max records per outbound POST. Keeps each request under the server's
|
|
96
|
-
*
|
|
97
|
-
* same records, then ramps back up by 1 per healthy send. A 413 on a
|
|
96
|
+
* request body cap. On a 413 response, the SDK halves this value, retries
|
|
97
|
+
* the same records, then ramps back up by 1 per healthy send. A 413 on a
|
|
98
98
|
* single-record batch drops the record (it's larger than the server can
|
|
99
99
|
* accept regardless of batch size). Default: 50 (RN) / 100 (browser).
|
|
100
100
|
*/
|
|
@@ -20,11 +20,14 @@ export declare class PostHogMetrics {
|
|
|
20
20
|
private readonly _config;
|
|
21
21
|
private readonly _logger;
|
|
22
22
|
private _series;
|
|
23
|
-
private _flushTimer
|
|
23
|
+
private readonly _flushTimer;
|
|
24
24
|
private _flushPromise;
|
|
25
25
|
private _seriesCapWarned;
|
|
26
26
|
private _typeByName;
|
|
27
27
|
private _typeCollisionWarned;
|
|
28
|
+
private _retryAfter;
|
|
29
|
+
private _consecutiveFlushFailures;
|
|
30
|
+
private _flushJitter;
|
|
28
31
|
private _generation;
|
|
29
32
|
constructor(_instance: MetricsHost, _config: ResolvedPostHogMetricsConfig, _logger: Logger);
|
|
30
33
|
count(name: string, value?: number, options?: CaptureMetricOptions): void;
|
|
@@ -51,7 +54,7 @@ export declare class PostHogMetrics {
|
|
|
51
54
|
private _fold;
|
|
52
55
|
private _runBeforeSend;
|
|
53
56
|
private _armFlushTimer;
|
|
54
|
-
private
|
|
57
|
+
private _nextFlushDelay;
|
|
55
58
|
private _doFlush;
|
|
56
59
|
private _buildPayload;
|
|
57
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAMpB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAMpB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AActC,OAAO,KAAK,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AA2BxE;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;IA0BvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IA3B1B,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAI3B;IAGD,OAAO,CAAC,aAAa,CAA6B;IAElD,OAAO,CAAC,gBAAgB,CAAQ;IAIhC,OAAO,CAAC,WAAW,CAAgC;IACnD,OAAO,CAAC,oBAAoB,CAAoB;IAChD,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,yBAAyB,CAAI;IACrC,OAAO,CAAC,YAAY,CAAY;IAIhC,OAAO,CAAC,WAAW,CAAI;gBAGJ,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,4BAA4B,EACrC,OAAO,EAAE,MAAM;IAGlC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI;IAI5E,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI;IAIxE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI;IAI5E,iFAAiF;IACjF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBtB;;;;;;OAMG;IACH,WAAW,IAAI,kBAAkB,GAAG,IAAI;IAYxC,2FAA2F;IAC3F,KAAK,IAAI,IAAI;IAab,OAAO,CAAC,QAAQ;IAsEhB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,KAAK;IA6Bb,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,eAAe;YAYT,QAAQ;IAyDtB,OAAO,CAAC,aAAa;IASrB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAwDrB,oFAAoF;IACpF,OAAO,CAAC,gBAAgB;CAqCzB;AAED,OAAO,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AACnH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -35,6 +35,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
35
35
|
resolveMetricsConfig: ()=>external_config_js_namespaceObject.resolveMetricsConfig
|
|
36
36
|
});
|
|
37
37
|
const index_js_namespaceObject = require("../utils/index.js");
|
|
38
|
+
const flush_timer_js_namespaceObject = require("../utils/flush-timer.js");
|
|
39
|
+
const retry_after_js_namespaceObject = require("../utils/retry-after.js");
|
|
40
|
+
const backoff_js_namespaceObject = require("../utils/backoff.js");
|
|
38
41
|
const otlp_any_value_js_namespaceObject = require("../utils/otlp-any-value.js");
|
|
39
42
|
const external_metrics_utils_js_namespaceObject = require("./metrics-utils.js");
|
|
40
43
|
const external_config_js_namespaceObject = require("./config.js");
|
|
@@ -45,10 +48,16 @@ class PostHogMetrics {
|
|
|
45
48
|
this._config = _config;
|
|
46
49
|
this._logger = _logger;
|
|
47
50
|
this._series = new Map();
|
|
51
|
+
this._flushTimer = new flush_timer_js_namespaceObject.FlushTimer(()=>this.flush().catch((e)=>{
|
|
52
|
+
this._logger.error('Metrics flush failed:', e);
|
|
53
|
+
}));
|
|
48
54
|
this._flushPromise = null;
|
|
49
55
|
this._seriesCapWarned = false;
|
|
50
56
|
this._typeByName = new Map();
|
|
51
57
|
this._typeCollisionWarned = new Set();
|
|
58
|
+
this._retryAfter = new retry_after_js_namespaceObject.RetryAfterWindow();
|
|
59
|
+
this._consecutiveFlushFailures = 0;
|
|
60
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
52
61
|
this._generation = 0;
|
|
53
62
|
}
|
|
54
63
|
count(name, value = 1, options) {
|
|
@@ -101,7 +110,10 @@ class PostHogMetrics {
|
|
|
101
110
|
}
|
|
102
111
|
reset() {
|
|
103
112
|
this._generation++;
|
|
104
|
-
this.
|
|
113
|
+
this._retryAfter.reset();
|
|
114
|
+
this._consecutiveFlushFailures = 0;
|
|
115
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
116
|
+
this._flushTimer.clear();
|
|
105
117
|
this._series = new Map();
|
|
106
118
|
this._flushPromise = null;
|
|
107
119
|
this._seriesCapWarned = false;
|
|
@@ -203,21 +215,14 @@ class PostHogMetrics {
|
|
|
203
215
|
return result;
|
|
204
216
|
}
|
|
205
217
|
_armFlushTimer() {
|
|
206
|
-
if (this._flushTimer) return;
|
|
207
|
-
this._flushTimer
|
|
208
|
-
this._flushTimer = void 0;
|
|
209
|
-
this.flush().catch((e)=>{
|
|
210
|
-
this._logger.error('Metrics flush failed:', e);
|
|
211
|
-
});
|
|
212
|
-
}, this._config.flushIntervalMs);
|
|
218
|
+
if (this._flushTimer.pending) return;
|
|
219
|
+
this._flushTimer.arm(this._nextFlushDelay());
|
|
213
220
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
clearTimeout(this._flushTimer);
|
|
217
|
-
this._flushTimer = void 0;
|
|
218
|
-
}
|
|
221
|
+
_nextFlushDelay() {
|
|
222
|
+
return Math.max((0, backoff_js_namespaceObject.backoffDelayMs)(this._config.flushIntervalMs, this._consecutiveFlushFailures, this._flushJitter, backoff_js_namespaceObject.MAX_FLUSH_BACKOFF_MS), this._retryAfter.remainingMs());
|
|
219
223
|
}
|
|
220
224
|
async _doFlush() {
|
|
225
|
+
this._flushTimer.clear();
|
|
221
226
|
if (0 === this._series.size) return;
|
|
222
227
|
const window = this._series;
|
|
223
228
|
this._series = new Map();
|
|
@@ -227,12 +232,21 @@ class PostHogMetrics {
|
|
|
227
232
|
const generation = this._generation;
|
|
228
233
|
const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
|
|
229
234
|
if (generation !== this._generation) return;
|
|
235
|
+
this._retryAfter.record(outcome);
|
|
236
|
+
if ('retry-later' === outcome.kind) {
|
|
237
|
+
this._consecutiveFlushFailures++;
|
|
238
|
+
this._flushJitter = (0, backoff_js_namespaceObject.drawJitter)();
|
|
239
|
+
} else {
|
|
240
|
+
this._consecutiveFlushFailures = 0;
|
|
241
|
+
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
242
|
+
}
|
|
243
|
+
if (this._flushTimer.pending) this._flushTimer.arm(this._nextFlushDelay());
|
|
230
244
|
switch(outcome.kind){
|
|
231
245
|
case 'ok':
|
|
232
246
|
return;
|
|
233
247
|
case 'retry-later':
|
|
234
248
|
this._mergeWindowBack(window);
|
|
235
|
-
this.
|
|
249
|
+
this._flushTimer.armNoEarlierThan(this._nextFlushDelay());
|
|
236
250
|
return;
|
|
237
251
|
case 'too-large':
|
|
238
252
|
this._logger.warn('Metrics batch exceeded the server size limit and was dropped');
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { isArray
|
|
1
|
+
import { isArray } from "../utils/index.mjs";
|
|
2
|
+
import { FlushTimer } from "../utils/flush-timer.mjs";
|
|
3
|
+
import { RetryAfterWindow } from "../utils/retry-after.mjs";
|
|
4
|
+
import { MAX_FLUSH_BACKOFF_MS, NO_JITTER, backoffDelayMs, drawJitter } from "../utils/backoff.mjs";
|
|
2
5
|
import { toOtlpKeyValueList } from "../utils/otlp-any-value.mjs";
|
|
3
6
|
import { DEFAULT_HISTOGRAM_BOUNDS, bucketIndexFor, buildMetricsResourceAttributes, buildOtlpMetricsPayload, msToUnixNano, seriesKey } from "./metrics-utils.mjs";
|
|
4
7
|
const OTLP_TEMPORALITY_DELTA = 1;
|
|
@@ -8,10 +11,16 @@ class PostHogMetrics {
|
|
|
8
11
|
this._config = _config;
|
|
9
12
|
this._logger = _logger;
|
|
10
13
|
this._series = new Map();
|
|
14
|
+
this._flushTimer = new FlushTimer(()=>this.flush().catch((e)=>{
|
|
15
|
+
this._logger.error('Metrics flush failed:', e);
|
|
16
|
+
}));
|
|
11
17
|
this._flushPromise = null;
|
|
12
18
|
this._seriesCapWarned = false;
|
|
13
19
|
this._typeByName = new Map();
|
|
14
20
|
this._typeCollisionWarned = new Set();
|
|
21
|
+
this._retryAfter = new RetryAfterWindow();
|
|
22
|
+
this._consecutiveFlushFailures = 0;
|
|
23
|
+
this._flushJitter = NO_JITTER;
|
|
15
24
|
this._generation = 0;
|
|
16
25
|
}
|
|
17
26
|
count(name, value = 1, options) {
|
|
@@ -64,7 +73,10 @@ class PostHogMetrics {
|
|
|
64
73
|
}
|
|
65
74
|
reset() {
|
|
66
75
|
this._generation++;
|
|
67
|
-
this.
|
|
76
|
+
this._retryAfter.reset();
|
|
77
|
+
this._consecutiveFlushFailures = 0;
|
|
78
|
+
this._flushJitter = NO_JITTER;
|
|
79
|
+
this._flushTimer.clear();
|
|
68
80
|
this._series = new Map();
|
|
69
81
|
this._flushPromise = null;
|
|
70
82
|
this._seriesCapWarned = false;
|
|
@@ -166,21 +178,14 @@ class PostHogMetrics {
|
|
|
166
178
|
return result;
|
|
167
179
|
}
|
|
168
180
|
_armFlushTimer() {
|
|
169
|
-
if (this._flushTimer) return;
|
|
170
|
-
this._flushTimer
|
|
171
|
-
this._flushTimer = void 0;
|
|
172
|
-
this.flush().catch((e)=>{
|
|
173
|
-
this._logger.error('Metrics flush failed:', e);
|
|
174
|
-
});
|
|
175
|
-
}, this._config.flushIntervalMs);
|
|
181
|
+
if (this._flushTimer.pending) return;
|
|
182
|
+
this._flushTimer.arm(this._nextFlushDelay());
|
|
176
183
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
clearTimeout(this._flushTimer);
|
|
180
|
-
this._flushTimer = void 0;
|
|
181
|
-
}
|
|
184
|
+
_nextFlushDelay() {
|
|
185
|
+
return Math.max(backoffDelayMs(this._config.flushIntervalMs, this._consecutiveFlushFailures, this._flushJitter, MAX_FLUSH_BACKOFF_MS), this._retryAfter.remainingMs());
|
|
182
186
|
}
|
|
183
187
|
async _doFlush() {
|
|
188
|
+
this._flushTimer.clear();
|
|
184
189
|
if (0 === this._series.size) return;
|
|
185
190
|
const window = this._series;
|
|
186
191
|
this._series = new Map();
|
|
@@ -190,12 +195,21 @@ class PostHogMetrics {
|
|
|
190
195
|
const generation = this._generation;
|
|
191
196
|
const outcome = await this._instance._sendMetricsBatch(this._buildPayload(window));
|
|
192
197
|
if (generation !== this._generation) return;
|
|
198
|
+
this._retryAfter.record(outcome);
|
|
199
|
+
if ('retry-later' === outcome.kind) {
|
|
200
|
+
this._consecutiveFlushFailures++;
|
|
201
|
+
this._flushJitter = drawJitter();
|
|
202
|
+
} else {
|
|
203
|
+
this._consecutiveFlushFailures = 0;
|
|
204
|
+
this._flushJitter = NO_JITTER;
|
|
205
|
+
}
|
|
206
|
+
if (this._flushTimer.pending) this._flushTimer.arm(this._nextFlushDelay());
|
|
193
207
|
switch(outcome.kind){
|
|
194
208
|
case 'ok':
|
|
195
209
|
return;
|
|
196
210
|
case 'retry-later':
|
|
197
211
|
this._mergeWindowBack(window);
|
|
198
|
-
this.
|
|
212
|
+
this._flushTimer.armNoEarlierThan(this._nextFlushDelay());
|
|
199
213
|
return;
|
|
200
214
|
case 'too-large':
|
|
201
215
|
this._logger.warn('Metrics batch exceeded the server size limit and was dropped');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics-utils.d.ts","sourceRoot":"","sources":["../../src/metrics/metrics-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"metrics-utils.d.ts","sourceRoot":"","sources":["../../src/metrics/metrics-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAE1F,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,UAA4E,CAAA;AAEjH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,SAAS,GAC3D,MAAM,CAOR;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAOtE;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,4BAA4B,EACpC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAEtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,UAAU,EAAE,EACrB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACxD,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAcpB"}
|
|
@@ -35,7 +35,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
35
35
|
msToUnixNano: ()=>msToUnixNano,
|
|
36
36
|
seriesKey: ()=>seriesKey
|
|
37
37
|
});
|
|
38
|
-
const otlp_any_value_js_namespaceObject = require("../utils/otlp-any-value.js");
|
|
39
38
|
const otlp_resource_js_namespaceObject = require("../utils/otlp-resource.js");
|
|
40
39
|
const DEFAULT_HISTOGRAM_BOUNDS = [
|
|
41
40
|
0,
|
|
@@ -77,7 +76,7 @@ function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVe
|
|
|
77
76
|
resourceMetrics: [
|
|
78
77
|
{
|
|
79
78
|
resource: {
|
|
80
|
-
attributes: (0,
|
|
79
|
+
attributes: (0, otlp_resource_js_namespaceObject.toOtlpResourceKeyValueList)(resourceAttributes)
|
|
81
80
|
},
|
|
82
81
|
scopeMetrics: [
|
|
83
82
|
{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { buildOtlpResourceAttributes } from "../utils/otlp-resource.mjs";
|
|
1
|
+
import { buildOtlpResourceAttributes, toOtlpResourceKeyValueList } from "../utils/otlp-resource.mjs";
|
|
3
2
|
const DEFAULT_HISTOGRAM_BOUNDS = [
|
|
4
3
|
0,
|
|
5
4
|
5,
|
|
@@ -40,7 +39,7 @@ function buildOtlpMetricsPayload(metrics, resourceAttributes, scopeName, scopeVe
|
|
|
40
39
|
resourceMetrics: [
|
|
41
40
|
{
|
|
42
41
|
resource: {
|
|
43
|
-
attributes:
|
|
42
|
+
attributes: toOtlpResourceKeyValueList(resourceAttributes)
|
|
44
43
|
},
|
|
45
44
|
scopeMetrics: [
|
|
46
45
|
{
|
|
@@ -6,8 +6,15 @@ export type SendMetricsBatchOutcome = {
|
|
|
6
6
|
} | {
|
|
7
7
|
kind: 'retry-later';
|
|
8
8
|
error: unknown;
|
|
9
|
+
retryAfterMs?: number;
|
|
9
10
|
} | {
|
|
10
11
|
kind: 'too-large';
|
|
12
|
+
/**
|
|
13
|
+
* True when the SDK measured the body itself rather than the endpoint
|
|
14
|
+
* refusing it, so the caller can split this drain without lowering the
|
|
15
|
+
* batch size it keeps between them.
|
|
16
|
+
*/
|
|
17
|
+
measuredLocally?: boolean;
|
|
11
18
|
} | {
|
|
12
19
|
kind: 'fatal';
|
|
13
20
|
error: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metrics/types.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAElG,yFAAyF;AACzF,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/metrics/types.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAElG,yFAAyF;AACzF,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GACd;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D;IACE,IAAI,EAAE,WAAW,CAAA;IACjB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,GACD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAErC;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAChF,YAAY,IAAI,MAAM,CAAA;IACtB,iBAAiB,IAAI,MAAM,CAAA;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IAEzD;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IAExB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAA;CACvD;AAID,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACxE,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;CAC1B"}
|