brass-runtime 1.18.1 → 1.19.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/CHANGELOG.md +65 -0
- package/dist/agent/cli/main.cjs +31 -31
- package/dist/agent/cli/main.js +3 -3
- package/dist/agent/cli/main.mjs +3 -3
- package/dist/agent/index.cjs +4 -4
- package/dist/agent/index.js +3 -3
- package/dist/agent/index.mjs +3 -3
- package/dist/{chunk-22HZQG5F.js → chunk-2R3RVNS2.js} +6 -6
- package/dist/{chunk-YWLLH27R.mjs → chunk-3NKXUX4T.mjs} +2 -2
- package/dist/{chunk-IPSMXUWA.js → chunk-4PKBNG2H.js} +38 -18
- package/dist/{chunk-Z3ZZMQUZ.mjs → chunk-5RVHSBJ6.mjs} +182 -34
- package/dist/{chunk-B5FKOLTB.mjs → chunk-5UBJT4RW.mjs} +4 -4
- package/dist/{chunk-5RZ7YITF.cjs → chunk-6STX4PS3.cjs} +13 -13
- package/dist/{chunk-XPIMJQYS.cjs → chunk-7FZUTJM3.cjs} +400 -252
- package/dist/{chunk-YZ5LQ32F.js → chunk-A6EG5WRL.js} +3 -3
- package/dist/{chunk-TTSPIU3U.js → chunk-APQBU7TM.js} +53 -32
- package/dist/{chunk-BC6Q6BCO.mjs → chunk-AQQQFNYD.mjs} +38 -18
- package/dist/{chunk-OW5VHAOE.js → chunk-B2VXVNIS.js} +1 -1
- package/dist/{chunk-WCBNXPN6.mjs → chunk-BLXBZ6RE.mjs} +1 -1
- package/dist/{chunk-7VQLEN37.js → chunk-C3CWI42G.js} +1 -1
- package/dist/{chunk-WI7GZF3B.cjs → chunk-DV644N7P.cjs} +85 -85
- package/dist/{chunk-RBHNOKH4.mjs → chunk-EKLEDIVJ.mjs} +2 -2
- package/dist/{chunk-S4HXADU4.js → chunk-EXBGIC66.js} +1 -1
- package/dist/{chunk-LSYQ3C2M.js → chunk-FC5N5QHJ.js} +2 -2
- package/dist/{chunk-6MLAZPBL.mjs → chunk-FNWOH2T2.js} +18 -6
- package/dist/{chunk-WGE2FEZE.cjs → chunk-FYWWU3Z7.cjs} +2 -2
- package/dist/{chunk-2OW6IFY2.cjs → chunk-GOEO763K.cjs} +21 -21
- package/dist/{chunk-UAKAF32U.js → chunk-GXOIUBKE.js} +2 -2
- package/dist/{chunk-7DU7IQHK.js → chunk-H4ZRUQZL.js} +4 -4
- package/dist/{chunk-JWIEMBE6.mjs → chunk-HW2CLRJ3.mjs} +6 -6
- package/dist/{chunk-YGR2IN4R.js → chunk-JWFOWPMB.js} +163 -155
- package/dist/{chunk-6V2AWT4R.mjs → chunk-KAPZHDO4.mjs} +1 -1
- package/dist/{chunk-EEN5OTCR.mjs → chunk-KDXNWGPB.mjs} +1 -1
- package/dist/{chunk-UUMKZJRJ.cjs → chunk-KPOL2YEO.cjs} +18 -6
- package/dist/{chunk-J6DUHITE.cjs → chunk-MA74OYCI.cjs} +6 -6
- package/dist/{chunk-H626ZTDZ.mjs → chunk-MUMBUXU6.mjs} +53 -32
- package/dist/{chunk-5LC7V2OZ.cjs → chunk-NQW3YUFN.cjs} +18 -18
- package/dist/{chunk-EICAJDNX.cjs → chunk-OO7BGCC3.cjs} +54 -34
- package/dist/{chunk-7GBJYOX7.mjs → chunk-OX6MF7SZ.mjs} +163 -155
- package/dist/{chunk-WVSZOPGQ.cjs → chunk-QBVS3UYN.cjs} +245 -237
- package/dist/{chunk-WUDHOZIH.js → chunk-RZGB3DXR.js} +182 -34
- package/dist/{chunk-COOW7BJX.mjs → chunk-URVS2OE2.mjs} +3 -3
- package/dist/{chunk-HCJ4S3YB.js → chunk-UZQ3BB6W.mjs} +18 -6
- package/dist/{chunk-KNTJ7FQB.cjs → chunk-YQWZ7FZX.cjs} +5 -5
- package/dist/{chunk-ELIECDYN.cjs → chunk-Z2YIDHRI.cjs} +5 -5
- package/dist/{chunk-2JHJ4YHS.cjs → chunk-ZDZNV6NA.cjs} +59 -38
- package/dist/core/index.cjs +8 -8
- package/dist/core/index.js +7 -7
- package/dist/core/index.mjs +7 -7
- package/dist/http/index.cjs +54 -54
- package/dist/http/index.js +7 -7
- package/dist/http/index.mjs +7 -7
- package/dist/http/testing.cjs +9 -9
- package/dist/http/testing.js +5 -5
- package/dist/http/testing.mjs +5 -5
- package/dist/index.cjs +86 -86
- package/dist/index.js +8 -8
- package/dist/index.mjs +8 -8
- package/dist/observability/index.cjs +10 -10
- package/dist/observability/index.js +9 -9
- package/dist/observability/index.mjs +9 -9
- package/dist/perf/cli.cjs +26 -26
- package/dist/perf/cli.js +11 -11
- package/dist/perf/cli.mjs +11 -11
- package/dist/perf/index.cjs +13 -13
- package/dist/perf/index.js +11 -11
- package/dist/perf/index.mjs +11 -11
- package/dist/schema/index.cjs +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkZ2YIDHRIcjs = require('./chunk-Z2YIDHRI.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -13,30 +13,26 @@ var _chunkELIECDYNcjs = require('./chunk-ELIECDYN.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkDV644N7Pcjs = require('./chunk-DV644N7P.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var _chunk7FZUTJM3cjs = require('./chunk-7FZUTJM3.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkL6VB5N7Qcjs = require('./chunk-L6VB5N7Q.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
|
|
30
|
+
var _chunk6STX4PS3cjs = require('./chunk-6STX4PS3.cjs');
|
|
36
31
|
|
|
37
32
|
|
|
38
33
|
|
|
39
34
|
|
|
35
|
+
var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
|
|
40
36
|
|
|
41
37
|
|
|
42
38
|
|
|
@@ -120,7 +116,7 @@ var HTTP_OBSERVABILITY_CONTRACT = Object.freeze({
|
|
|
120
116
|
});
|
|
121
117
|
function withHttpObservability(options) {
|
|
122
118
|
if (!isObservabilityInstance(options)) {
|
|
123
|
-
|
|
119
|
+
_chunkDV644N7Pcjs.validateHttpObservabilityOptions.call(void 0, _nullishCoalesce(options, () => ( {})));
|
|
124
120
|
}
|
|
125
121
|
const resolved = resolveHttpObservabilityOptions(options);
|
|
126
122
|
const metricCache = makeHttpMetricCache();
|
|
@@ -134,45 +130,149 @@ function withHttpObservability(options) {
|
|
|
134
130
|
return withLeanHttpSampledSpanObservability(next, resolved, metricCache);
|
|
135
131
|
}
|
|
136
132
|
return (req) => {
|
|
137
|
-
const run = _chunkMVGUEJ5Zcjs.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
133
|
+
const run = _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
134
|
+
const startedAt = resolved.clock();
|
|
135
|
+
const baseLabels = getCachedBaseLabels(req, resolved, metricCache);
|
|
136
|
+
const inFlight = resolved.metrics ? getCachedMetric(
|
|
137
|
+
metricCache,
|
|
138
|
+
metricCache.inFlightGauges,
|
|
139
|
+
metricCacheKey("brass_http_client_in_flight", baseLabels),
|
|
140
|
+
() => resolved.metrics.gauge("brass_http_client_in_flight", baseLabels)
|
|
141
|
+
) : void 0;
|
|
142
|
+
_optionalChain([inFlight, 'optionalAccess', _ => _.increment, 'call', _2 => _2()]);
|
|
143
|
+
let finished = false;
|
|
144
|
+
let cancelInner;
|
|
145
|
+
const completeFinish = (outcome, status, extra) => {
|
|
146
|
+
const durationMs = Math.max(0, resolved.clock() - startedAt);
|
|
147
|
+
const labels = requestFinishLabelsFromBase(baseLabels, outcome, status);
|
|
148
|
+
if (!finished) {
|
|
149
|
+
finished = true;
|
|
150
|
+
if (inFlight && inFlight.value() > 0) inFlight.decrement();
|
|
151
|
+
if (resolved.metrics) {
|
|
152
|
+
getCachedMetric(
|
|
153
|
+
metricCache,
|
|
154
|
+
metricCache.requestCounters,
|
|
155
|
+
metricCacheKey("brass_http_client_requests_total", labels),
|
|
156
|
+
() => resolved.metrics.counter("brass_http_client_requests_total", labels)
|
|
157
|
+
).increment();
|
|
158
|
+
getCachedMetric(
|
|
159
|
+
metricCache,
|
|
160
|
+
metricCache.durationHistograms,
|
|
161
|
+
metricCacheKey("brass_http_client_duration_ms", labels),
|
|
162
|
+
() => resolved.metrics.histogram(
|
|
163
|
+
"brass_http_client_duration_ms",
|
|
164
|
+
[..._nullishCoalesce(resolved.durationBuckets, () => ( DEFAULT_DURATION_BUCKETS))],
|
|
165
|
+
labels
|
|
166
|
+
)
|
|
167
|
+
).observe(
|
|
168
|
+
durationMs,
|
|
169
|
+
resolved.spans === false ? void 0 : currentTraceExemplar(durationMs, startedAt + durationMs)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
durationMs,
|
|
175
|
+
outcome,
|
|
176
|
+
labels,
|
|
177
|
+
spanAttributes: resolved.spans === false ? EMPTY_SPAN_ATTRIBUTES : {
|
|
178
|
+
"http.duration_ms": durationMs,
|
|
179
|
+
"http.outcome": outcome,
|
|
180
|
+
...status ? { "http.status_code": Number(status) } : {},
|
|
181
|
+
...status ? { "http.response.status_code": Number(status) } : {},
|
|
182
|
+
...extra
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
|
|
187
|
+
_optionalChain([fiber, 'optionalAccess', _3 => _3.addFinalizer, 'optionalCall', _4 => _4(() => {
|
|
188
|
+
completeFinish("abort", void 0, { "http.cancelled": true });
|
|
189
|
+
})]);
|
|
190
|
+
const reqLogLevel = resolved.logs === false ? false : _nullishCoalesce(resolved.logs.requestLevel, () => ( false));
|
|
191
|
+
if (reqLogLevel) {
|
|
192
|
+
const logEff = _chunkDV644N7Pcjs.logEffect.call(void 0, reqLogLevel, "http.client.request", requestLogFields(req, resolved));
|
|
193
|
+
_chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, logEff, env, () => void 0);
|
|
194
|
+
}
|
|
195
|
+
const wireReq = resolved.injectTraceHeaders ? injectCurrentTraceContext(req) : req;
|
|
196
|
+
const onSuccess = (res) => {
|
|
197
|
+
const finish = completeFinish(httpStatusOutcome(res.status), String(res.status), {});
|
|
198
|
+
const adaptiveAttrs = observeAdaptiveLimiter(wireReq, next, resolved);
|
|
199
|
+
if (shouldEmitHttpSpanEvents(resolved)) {
|
|
200
|
+
const ev = _chunkDV644N7Pcjs.spanEvent.call(void 0, "http.client.response", {
|
|
201
|
+
...finish.spanAttributes,
|
|
202
|
+
...adaptiveAttrs
|
|
203
|
+
});
|
|
204
|
+
_chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, ev, env, () => void 0);
|
|
205
|
+
}
|
|
206
|
+
const respLevel = resolved.logs === false ? false : (_nullishCoalesce(resolved.logs.responseLevel, () => ( false))) || (finish.outcome === "error" ? _nullishCoalesce(resolved.logs.errorLevel, () => ( "warn")) : false);
|
|
207
|
+
if (respLevel) {
|
|
208
|
+
const logEff = _chunkDV644N7Pcjs.logEffect.call(void 0, respLevel, "http.client.response", {
|
|
209
|
+
...requestLogFields(req, resolved),
|
|
210
|
+
status: res.status,
|
|
211
|
+
statusText: res.statusText,
|
|
212
|
+
outcome: finish.outcome,
|
|
213
|
+
durationMs: finish.durationMs
|
|
214
|
+
});
|
|
215
|
+
_chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, logEff, env, () => void 0);
|
|
216
|
+
}
|
|
217
|
+
cb({ _tag: "Success", value: res });
|
|
218
|
+
};
|
|
219
|
+
const onError = (error) => {
|
|
220
|
+
const status = _chunk7FZUTJM3cjs.httpErrorStatus.call(void 0, error);
|
|
221
|
+
const finish = completeFinish(
|
|
222
|
+
httpErrorOutcome(error),
|
|
223
|
+
status !== void 0 ? String(status) : void 0,
|
|
224
|
+
{
|
|
225
|
+
"error.type": error._tag,
|
|
226
|
+
"http.retryable": _chunk7FZUTJM3cjs.isRetryableHttpError.call(void 0, error)
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
const adaptiveAttrs = observeAdaptiveLimiter(wireReq, next, resolved);
|
|
230
|
+
if (shouldEmitHttpSpanEvents(resolved)) {
|
|
231
|
+
const ev = _chunkDV644N7Pcjs.spanEvent.call(void 0, "http.client.error", {
|
|
232
|
+
...finish.spanAttributes,
|
|
233
|
+
...adaptiveAttrs,
|
|
234
|
+
"error.type": error._tag
|
|
235
|
+
});
|
|
236
|
+
_chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, ev, env, () => void 0);
|
|
237
|
+
}
|
|
238
|
+
const errLevel = resolved.logs === false ? false : _nullishCoalesce(resolved.logs.errorLevel, () => ( "error"));
|
|
239
|
+
if (errLevel) {
|
|
240
|
+
const statusText = httpErrorStatusText(error);
|
|
241
|
+
const logEff = _chunkDV644N7Pcjs.logEffect.call(void 0, errLevel, "http.client.error", {
|
|
242
|
+
...requestLogFields(req, resolved),
|
|
243
|
+
outcome: finish.outcome,
|
|
244
|
+
durationMs: finish.durationMs,
|
|
245
|
+
...status !== void 0 ? { status } : {},
|
|
246
|
+
...statusText ? { statusText } : {},
|
|
247
|
+
retryable: _chunk7FZUTJM3cjs.isRetryableHttpError.call(void 0, error),
|
|
248
|
+
errorTag: error._tag,
|
|
249
|
+
message: httpErrorMessage(error)
|
|
250
|
+
});
|
|
251
|
+
_chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, logEff, env, () => void 0);
|
|
252
|
+
}
|
|
253
|
+
cb({ _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail(error) });
|
|
254
|
+
};
|
|
255
|
+
try {
|
|
256
|
+
cancelInner = _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, next(wireReq), env, (exit) => {
|
|
257
|
+
cancelInner = void 0;
|
|
258
|
+
if (exit._tag === "Success") onSuccess(exit.value);
|
|
259
|
+
else {
|
|
260
|
+
const failure = _chunkMVGUEJ5Zcjs.Cause.firstFailure(exit.cause);
|
|
261
|
+
if (failure._tag === "Some") onError(failure.value);
|
|
262
|
+
else cb(exit);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
} catch (error) {
|
|
266
|
+
cb({ _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.die(error) });
|
|
267
|
+
}
|
|
268
|
+
return () => {
|
|
269
|
+
const cancel = cancelInner;
|
|
270
|
+
cancelInner = void 0;
|
|
271
|
+
_optionalChain([cancel, 'optionalCall', _5 => _5()]);
|
|
272
|
+
};
|
|
273
|
+
});
|
|
174
274
|
if (resolved.spans === false) return run;
|
|
175
|
-
return
|
|
275
|
+
return _chunkDV644N7Pcjs.withSpan.call(void 0, spanName(req, resolved.spans), run, spanStartAttributes(req, resolved));
|
|
176
276
|
};
|
|
177
277
|
};
|
|
178
278
|
}
|
|
@@ -191,7 +291,7 @@ function canUseLeanHttpSampledSpanPath(options, adaptiveLimiter) {
|
|
|
191
291
|
function withLeanHttpSampledSpanObservability(next, options, metricCache) {
|
|
192
292
|
return (req) => _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
193
293
|
const startedAt = options.clock();
|
|
194
|
-
const baseLabels =
|
|
294
|
+
const baseLabels = getCachedBaseLabels(req, options, metricCache);
|
|
195
295
|
const handles = beginLeanHttpMetricsObservation(baseLabels, options, metricCache);
|
|
196
296
|
const span = startLeanHttpSpan(req, options);
|
|
197
297
|
let finished = false;
|
|
@@ -212,7 +312,7 @@ function withLeanHttpSampledSpanObservability(next, options, metricCache) {
|
|
|
212
312
|
finishLeanHttpSpan(span, "success");
|
|
213
313
|
} else {
|
|
214
314
|
const error = httpErrorFromCause(exit.cause);
|
|
215
|
-
const status =
|
|
315
|
+
const status = _chunk7FZUTJM3cjs.httpErrorStatus.call(void 0, error);
|
|
216
316
|
recordHttpMetricsFinish(
|
|
217
317
|
handles,
|
|
218
318
|
httpErrorOutcome(error),
|
|
@@ -249,14 +349,14 @@ function withLeanHttpSampledSpanObservability(next, options, metricCache) {
|
|
|
249
349
|
}
|
|
250
350
|
const cancel = cancelInner;
|
|
251
351
|
cancelInner = void 0;
|
|
252
|
-
_optionalChain([cancel, 'optionalCall',
|
|
352
|
+
_optionalChain([cancel, 'optionalCall', _6 => _6()]);
|
|
253
353
|
};
|
|
254
354
|
});
|
|
255
355
|
}
|
|
256
356
|
function withLeanHttpMetricsObservability(next, options, metricCache) {
|
|
257
357
|
return (req) => _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
258
358
|
const startedAt = options.clock();
|
|
259
|
-
const baseLabels =
|
|
359
|
+
const baseLabels = getCachedBaseLabels(req, options, metricCache);
|
|
260
360
|
const handles = beginLeanHttpMetricsObservation(baseLabels, options, metricCache);
|
|
261
361
|
let finished = false;
|
|
262
362
|
let cancelInner;
|
|
@@ -275,7 +375,7 @@ function withLeanHttpMetricsObservability(next, options, metricCache) {
|
|
|
275
375
|
);
|
|
276
376
|
} else {
|
|
277
377
|
const error = httpErrorFromCause(exit.cause);
|
|
278
|
-
const status =
|
|
378
|
+
const status = _chunk7FZUTJM3cjs.httpErrorStatus.call(void 0, error);
|
|
279
379
|
recordHttpMetricsFinish(
|
|
280
380
|
handles,
|
|
281
381
|
httpErrorOutcome(error),
|
|
@@ -310,7 +410,7 @@ function withLeanHttpMetricsObservability(next, options, metricCache) {
|
|
|
310
410
|
}
|
|
311
411
|
const cancel = cancelInner;
|
|
312
412
|
cancelInner = void 0;
|
|
313
|
-
_optionalChain([cancel, 'optionalCall',
|
|
413
|
+
_optionalChain([cancel, 'optionalCall', _7 => _7()]);
|
|
314
414
|
};
|
|
315
415
|
});
|
|
316
416
|
}
|
|
@@ -318,7 +418,7 @@ function beginLeanHttpMetricsObservation(baseLabels, options, metricCache) {
|
|
|
318
418
|
const cacheKey = metricCacheKey("brass_http_client", baseLabels);
|
|
319
419
|
const existing = metricCache.disabled ? void 0 : metricCache.leanEntries.get(cacheKey);
|
|
320
420
|
if (existing) {
|
|
321
|
-
_optionalChain([existing, 'access',
|
|
421
|
+
_optionalChain([existing, 'access', _8 => _8.inFlight, 'optionalAccess', _9 => _9.increment, 'call', _10 => _10()]);
|
|
322
422
|
return existing;
|
|
323
423
|
}
|
|
324
424
|
const inFlight = options.metrics ? getCachedMetric(
|
|
@@ -327,7 +427,7 @@ function beginLeanHttpMetricsObservation(baseLabels, options, metricCache) {
|
|
|
327
427
|
metricCacheKey("brass_http_client_in_flight", baseLabels),
|
|
328
428
|
() => options.metrics.gauge("brass_http_client_in_flight", baseLabels)
|
|
329
429
|
) : void 0;
|
|
330
|
-
_optionalChain([inFlight, 'optionalAccess',
|
|
430
|
+
_optionalChain([inFlight, 'optionalAccess', _11 => _11.increment, 'call', _12 => _12()]);
|
|
331
431
|
const created = {
|
|
332
432
|
baseLabels,
|
|
333
433
|
inFlight,
|
|
@@ -340,7 +440,7 @@ function beginLeanHttpMetricsObservation(baseLabels, options, metricCache) {
|
|
|
340
440
|
}
|
|
341
441
|
function recordHttpMetricsFinish(handles, outcome, status, startedAt, options, metricCache) {
|
|
342
442
|
const durationMs = Math.max(0, options.clock() - startedAt);
|
|
343
|
-
_optionalChain([handles, 'access',
|
|
443
|
+
_optionalChain([handles, 'access', _13 => _13.inFlight, 'optionalAccess', _14 => _14.decrement, 'call', _15 => _15()]);
|
|
344
444
|
if (!options.metrics) return;
|
|
345
445
|
const finishKey = `${outcome}|${_nullishCoalesce(status, () => ( "none"))}`;
|
|
346
446
|
let finishMetrics = metricCache.disabled ? void 0 : handles.finishMetrics.get(finishKey);
|
|
@@ -365,20 +465,20 @@ function startLeanHttpSpan(req, options) {
|
|
|
365
465
|
if (configuredSampleRate <= 0) return void 0;
|
|
366
466
|
if (configuredSampleRate < 1 && Math.random() >= configuredSampleRate) return void 0;
|
|
367
467
|
}
|
|
368
|
-
const fiber =
|
|
369
|
-
const runtime = _optionalChain([fiber, 'optionalAccess',
|
|
370
|
-
const sink = _nullishCoalesce(options.spanSink, () => ( _optionalChain([runtime, 'optionalAccess',
|
|
371
|
-
if (!_optionalChain([fiber, 'optionalAccess',
|
|
468
|
+
const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
|
|
469
|
+
const runtime = _optionalChain([fiber, 'optionalAccess', _16 => _16.runtime]);
|
|
470
|
+
const sink = _nullishCoalesce(options.spanSink, () => ( _optionalChain([runtime, 'optionalAccess', _17 => _17.hooks])));
|
|
471
|
+
if (!_optionalChain([fiber, 'optionalAccess', _18 => _18.fiberContext]) || !runtime || !sink) return void 0;
|
|
372
472
|
const previousTrace = _nullishCoalesce(fiber.fiberContext.trace, () => ( null));
|
|
373
|
-
const brass = _optionalChain([runtime, 'access',
|
|
374
|
-
if (_optionalChain([previousTrace, 'optionalAccess',
|
|
473
|
+
const brass = _optionalChain([runtime, 'access', _19 => _19.env, 'optionalAccess', _20 => _20.brass]);
|
|
474
|
+
if (_optionalChain([previousTrace, 'optionalAccess', _21 => _21.sampled]) === false && _optionalChain([brass, 'optionalAccess', _22 => _22.respectRemoteSampled]) !== false) return void 0;
|
|
375
475
|
const name = spanName(req, options.spans);
|
|
376
476
|
const tracer = resolveRuntimeTracer(runtime);
|
|
377
|
-
let traceId = _optionalChain([previousTrace, 'optionalAccess',
|
|
378
|
-
let sampled = _optionalChain([previousTrace, 'optionalAccess',
|
|
477
|
+
let traceId = _optionalChain([previousTrace, 'optionalAccess', _23 => _23.traceId]);
|
|
478
|
+
let sampled = _optionalChain([previousTrace, 'optionalAccess', _24 => _24.sampled]);
|
|
379
479
|
let attributes;
|
|
380
480
|
if (!previousTrace && configuredSampleRate === void 0) {
|
|
381
|
-
const ratio = traceSamplerRatio(_optionalChain([brass, 'optionalAccess',
|
|
481
|
+
const ratio = traceSamplerRatio(_optionalChain([brass, 'optionalAccess', _25 => _25.sampler]));
|
|
382
482
|
if (ratio !== void 0) {
|
|
383
483
|
if (ratio <= 0) return void 0;
|
|
384
484
|
if (ratio < 1 && Math.random() >= ratio) return void 0;
|
|
@@ -392,10 +492,10 @@ function startLeanHttpSpan(req, options) {
|
|
|
392
492
|
attributes = spanStartAttributes(req, options);
|
|
393
493
|
if (sampled === void 0) {
|
|
394
494
|
traceId = _nullishCoalesce(traceId, () => ( tracer.newTraceId()));
|
|
395
|
-
sampled =
|
|
495
|
+
sampled = _chunkDV644N7Pcjs.shouldSampleWith.call(void 0, _optionalChain([brass, 'optionalAccess', _26 => _26.sampler]), {
|
|
396
496
|
traceId,
|
|
397
497
|
spanName: name,
|
|
398
|
-
parentSampled: _optionalChain([previousTrace, 'optionalAccess',
|
|
498
|
+
parentSampled: _optionalChain([previousTrace, 'optionalAccess', _27 => _27.sampled]),
|
|
399
499
|
attributes
|
|
400
500
|
});
|
|
401
501
|
}
|
|
@@ -403,10 +503,10 @@ function startLeanHttpSpan(req, options) {
|
|
|
403
503
|
const trace = {
|
|
404
504
|
traceId: _nullishCoalesce(traceId, () => ( tracer.newTraceId())),
|
|
405
505
|
spanId: tracer.newSpanId(),
|
|
406
|
-
parentSpanId: _optionalChain([previousTrace, 'optionalAccess',
|
|
506
|
+
parentSpanId: _optionalChain([previousTrace, 'optionalAccess', _28 => _28.spanId]),
|
|
407
507
|
sampled: true,
|
|
408
|
-
traceState: _optionalChain([previousTrace, 'optionalAccess',
|
|
409
|
-
..._optionalChain([previousTrace, 'optionalAccess',
|
|
508
|
+
traceState: _optionalChain([previousTrace, 'optionalAccess', _29 => _29.traceState]),
|
|
509
|
+
..._optionalChain([previousTrace, 'optionalAccess', _30 => _30.baggage]) ? { baggage: previousTrace.baggage } : {}
|
|
410
510
|
};
|
|
411
511
|
const state = {
|
|
412
512
|
fiber,
|
|
@@ -417,9 +517,9 @@ function startLeanHttpSpan(req, options) {
|
|
|
417
517
|
ended: false
|
|
418
518
|
};
|
|
419
519
|
fiber.fiberContext = { ...fiber.fiberContext, trace };
|
|
420
|
-
_optionalChain([fiber, 'access',
|
|
421
|
-
const status = _optionalChain([exit, 'optionalAccess',
|
|
422
|
-
finishLeanHttpSpan(state, status, _optionalChain([exit, 'optionalAccess',
|
|
520
|
+
_optionalChain([fiber, 'access', _31 => _31.addFinalizer, 'optionalCall', _32 => _32((exit) => {
|
|
521
|
+
const status = _optionalChain([exit, 'optionalAccess', _33 => _33._tag]) === "Success" ? "success" : _optionalChain([exit, 'optionalAccess', _34 => _34.cause]) && _chunkMVGUEJ5Zcjs.Cause.containsInterrupt(exit.cause) ? "interrupted" : "failure";
|
|
522
|
+
finishLeanHttpSpan(state, status, _optionalChain([exit, 'optionalAccess', _35 => _35._tag]) === "Failure" ? exit.cause : void 0);
|
|
423
523
|
})]);
|
|
424
524
|
sink.emit(
|
|
425
525
|
{ type: "span.start", name, attributes, links: [] },
|
|
@@ -434,14 +534,14 @@ function finishLeanHttpSpan(state, status, error) {
|
|
|
434
534
|
{ type: "span.end", name: state.name, status, error },
|
|
435
535
|
leanSpanContext(state.fiber, state.trace)
|
|
436
536
|
);
|
|
437
|
-
if (_optionalChain([state, 'access',
|
|
537
|
+
if (_optionalChain([state, 'access', _36 => _36.fiber, 'optionalAccess', _37 => _37.fiberContext])) {
|
|
438
538
|
state.fiber.fiberContext = { ...state.fiber.fiberContext, trace: state.previousTrace };
|
|
439
539
|
}
|
|
440
540
|
}
|
|
441
541
|
function leanSpanContext(fiber, trace) {
|
|
442
542
|
return {
|
|
443
|
-
fiberId: _optionalChain([fiber, 'optionalAccess',
|
|
444
|
-
scopeId: _optionalChain([fiber, 'optionalAccess',
|
|
543
|
+
fiberId: _optionalChain([fiber, 'optionalAccess', _38 => _38.id]),
|
|
544
|
+
scopeId: _optionalChain([fiber, 'optionalAccess', _39 => _39.scopeId]),
|
|
445
545
|
traceId: trace.traceId,
|
|
446
546
|
spanId: trace.spanId,
|
|
447
547
|
parentSpanId: trace.parentSpanId,
|
|
@@ -451,8 +551,8 @@ function leanSpanContext(fiber, trace) {
|
|
|
451
551
|
};
|
|
452
552
|
}
|
|
453
553
|
function resolveRuntimeTracer(runtime) {
|
|
454
|
-
const tracer = _optionalChain([runtime, 'optionalAccess',
|
|
455
|
-
if (_optionalChain([tracer, 'optionalAccess',
|
|
554
|
+
const tracer = _optionalChain([runtime, 'optionalAccess', _40 => _40.env, 'optionalAccess', _41 => _41.brass, 'optionalAccess', _42 => _42.tracer]);
|
|
555
|
+
if (_optionalChain([tracer, 'optionalAccess', _43 => _43.newTraceId]) && _optionalChain([tracer, 'optionalAccess', _44 => _44.newSpanId])) return tracer;
|
|
456
556
|
return {
|
|
457
557
|
newTraceId: () => randomRuntimeId("trace"),
|
|
458
558
|
newSpanId: () => randomRuntimeId("span")
|
|
@@ -465,7 +565,7 @@ function traceSamplerRatio(sampler) {
|
|
|
465
565
|
}
|
|
466
566
|
function randomRuntimeId(prefix) {
|
|
467
567
|
const cryptoLike = globalThis.crypto;
|
|
468
|
-
if (typeof _optionalChain([cryptoLike, 'optionalAccess',
|
|
568
|
+
if (typeof _optionalChain([cryptoLike, 'optionalAccess', _45 => _45.randomUUID]) === "function") return cryptoLike.randomUUID();
|
|
469
569
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
470
570
|
}
|
|
471
571
|
function httpErrorFromCause(cause) {
|
|
@@ -486,9 +586,23 @@ function makeHttpMetricCache() {
|
|
|
486
586
|
leanEntries: /* @__PURE__ */ new Map(),
|
|
487
587
|
inFlightGauges: /* @__PURE__ */ new Map(),
|
|
488
588
|
requestCounters: /* @__PURE__ */ new Map(),
|
|
489
|
-
durationHistograms: /* @__PURE__ */ new Map()
|
|
589
|
+
durationHistograms: /* @__PURE__ */ new Map(),
|
|
590
|
+
baseLabelsCache: /* @__PURE__ */ new Map()
|
|
490
591
|
};
|
|
491
592
|
}
|
|
593
|
+
function getCachedBaseLabels(req, options, cache) {
|
|
594
|
+
if (cache.disabled) return requestBaseLabels(req, options);
|
|
595
|
+
const route = requestRoute(req, options);
|
|
596
|
+
const host = options.includeHostLabel ? requestHost(req) : void 0;
|
|
597
|
+
const policy = _chunk7FZUTJM3cjs.getHttpRequestPolicy.call(void 0, req);
|
|
598
|
+
const preset = typeof policy === "string" ? policy : _optionalChain([policy, 'optionalAccess', _46 => _46.preset]);
|
|
599
|
+
const key = `${req.method}|${_nullishCoalesce(host, () => ( ""))}|${_nullishCoalesce(route, () => ( ""))}|${_nullishCoalesce(preset, () => ( ""))}`;
|
|
600
|
+
const existing = cache.baseLabelsCache.get(key);
|
|
601
|
+
if (existing) return existing;
|
|
602
|
+
const fresh = requestBaseLabels(req, options);
|
|
603
|
+
cache.baseLabelsCache.set(key, fresh);
|
|
604
|
+
return fresh;
|
|
605
|
+
}
|
|
492
606
|
function attachMetricCache(metrics, cache) {
|
|
493
607
|
if (!metrics) return;
|
|
494
608
|
const existing = metricResetRegistry.get(metrics);
|
|
@@ -536,127 +650,21 @@ function metricCacheKey(name, labels) {
|
|
|
536
650
|
}
|
|
537
651
|
return key;
|
|
538
652
|
}
|
|
539
|
-
function beginHttpObservation(req, options, metricCache) {
|
|
540
|
-
return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
|
|
541
|
-
const startedAt = options.clock();
|
|
542
|
-
let finished = false;
|
|
543
|
-
const baseLabels = requestBaseLabels(req, options);
|
|
544
|
-
const inFlight = options.metrics ? getCachedMetric(
|
|
545
|
-
metricCache,
|
|
546
|
-
metricCache.inFlightGauges,
|
|
547
|
-
metricCacheKey("brass_http_client_in_flight", baseLabels),
|
|
548
|
-
() => options.metrics.gauge("brass_http_client_in_flight", baseLabels)
|
|
549
|
-
) : void 0;
|
|
550
|
-
_optionalChain([inFlight, 'optionalAccess', _41 => _41.increment, 'call', _42 => _42()]);
|
|
551
|
-
const finish = (outcome, status, extra = {}) => {
|
|
552
|
-
const durationMs = Math.max(0, options.clock() - startedAt);
|
|
553
|
-
const labels = requestFinishLabelsFromBase(baseLabels, outcome, status);
|
|
554
|
-
if (!finished) {
|
|
555
|
-
finished = true;
|
|
556
|
-
if (inFlight && inFlight.value() > 0) inFlight.decrement();
|
|
557
|
-
if (options.metrics) {
|
|
558
|
-
getCachedMetric(
|
|
559
|
-
metricCache,
|
|
560
|
-
metricCache.requestCounters,
|
|
561
|
-
metricCacheKey("brass_http_client_requests_total", labels),
|
|
562
|
-
() => options.metrics.counter("brass_http_client_requests_total", labels)
|
|
563
|
-
).increment();
|
|
564
|
-
getCachedMetric(
|
|
565
|
-
metricCache,
|
|
566
|
-
metricCache.durationHistograms,
|
|
567
|
-
metricCacheKey("brass_http_client_duration_ms", labels),
|
|
568
|
-
() => options.metrics.histogram(
|
|
569
|
-
"brass_http_client_duration_ms",
|
|
570
|
-
[..._nullishCoalesce(options.durationBuckets, () => ( DEFAULT_DURATION_BUCKETS))],
|
|
571
|
-
labels
|
|
572
|
-
)
|
|
573
|
-
).observe(
|
|
574
|
-
durationMs,
|
|
575
|
-
options.spans === false ? void 0 : currentTraceExemplar(durationMs, startedAt + durationMs)
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
return {
|
|
580
|
-
durationMs,
|
|
581
|
-
outcome,
|
|
582
|
-
labels,
|
|
583
|
-
spanAttributes: options.spans === false ? EMPTY_SPAN_ATTRIBUTES : {
|
|
584
|
-
"http.duration_ms": durationMs,
|
|
585
|
-
"http.outcome": outcome,
|
|
586
|
-
...status ? { "http.status_code": Number(status) } : {},
|
|
587
|
-
...status ? { "http.response.status_code": Number(status) } : {},
|
|
588
|
-
...extra
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
};
|
|
592
|
-
const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
|
|
593
|
-
_optionalChain([fiber, 'optionalAccess', _43 => _43.addFinalizer, 'optionalCall', _44 => _44(() => {
|
|
594
|
-
finish("abort", void 0, { "http.cancelled": true });
|
|
595
|
-
})]);
|
|
596
|
-
return {
|
|
597
|
-
finishWithResponse: (res) => finish(httpStatusOutcome(res.status), String(res.status)),
|
|
598
|
-
finishWithError: (error) => {
|
|
599
|
-
const status = _chunkXPIMJQYScjs.httpErrorStatus.call(void 0, error);
|
|
600
|
-
return finish(httpErrorOutcome(error), status !== void 0 ? String(status) : void 0, {
|
|
601
|
-
"error.type": error._tag,
|
|
602
|
-
"http.retryable": _chunkXPIMJQYScjs.isRetryableHttpError.call(void 0, error)
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
function prepareHttpRequest(req, options) {
|
|
609
|
-
if (!options.injectTraceHeaders) return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, req);
|
|
610
|
-
return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => injectCurrentTraceContext(req));
|
|
611
|
-
}
|
|
612
|
-
function logHttpRequest(req, options) {
|
|
613
|
-
const level = options.logs === false ? false : _nullishCoalesce(options.logs.requestLevel, () => ( false));
|
|
614
|
-
if (!level) return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
|
|
615
|
-
return _chunkWI7GZF3Bcjs.logEffect.call(void 0, level, "http.client.request", requestLogFields(req, options));
|
|
616
|
-
}
|
|
617
|
-
function logHttpResponse(req, res, finish, options) {
|
|
618
|
-
const configured = options.logs === false ? false : _nullishCoalesce(options.logs.responseLevel, () => ( false));
|
|
619
|
-
const level = configured || (finish.outcome === "error" ? options.logs !== false ? _nullishCoalesce(options.logs.errorLevel, () => ( "warn")) : false : false);
|
|
620
|
-
if (!level) return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
|
|
621
|
-
return _chunkWI7GZF3Bcjs.logEffect.call(void 0, level, "http.client.response", {
|
|
622
|
-
...requestLogFields(req, options),
|
|
623
|
-
status: res.status,
|
|
624
|
-
statusText: res.statusText,
|
|
625
|
-
outcome: finish.outcome,
|
|
626
|
-
durationMs: finish.durationMs
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
function logHttpError(req, error, finish, options) {
|
|
630
|
-
const level = options.logs === false ? false : _nullishCoalesce(options.logs.errorLevel, () => ( "error"));
|
|
631
|
-
if (!level) return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
|
|
632
|
-
const status = _chunkXPIMJQYScjs.httpErrorStatus.call(void 0, error);
|
|
633
|
-
const statusText = httpErrorStatusText(error);
|
|
634
|
-
return _chunkWI7GZF3Bcjs.logEffect.call(void 0, level, "http.client.error", {
|
|
635
|
-
...requestLogFields(req, options),
|
|
636
|
-
outcome: finish.outcome,
|
|
637
|
-
durationMs: finish.durationMs,
|
|
638
|
-
...status !== void 0 ? { status } : {},
|
|
639
|
-
...statusText ? { statusText } : {},
|
|
640
|
-
retryable: _chunkXPIMJQYScjs.isRetryableHttpError.call(void 0, error),
|
|
641
|
-
errorTag: error._tag,
|
|
642
|
-
message: httpErrorMessage(error)
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
653
|
function resolveHttpObservabilityOptions(options) {
|
|
646
654
|
const maybeObservability = isObservabilityInstance(options) ? options : void 0;
|
|
647
655
|
const raw = maybeObservability ? { metrics: maybeObservability.metrics } : options;
|
|
648
656
|
return {
|
|
649
|
-
metrics: _optionalChain([raw, 'optionalAccess',
|
|
650
|
-
logs: _nullishCoalesce(_optionalChain([raw, 'optionalAccess',
|
|
651
|
-
spans: _nullishCoalesce(_optionalChain([raw, 'optionalAccess',
|
|
652
|
-
spanSink: _optionalChain([raw, 'optionalAccess',
|
|
653
|
-
adaptiveLimiter: resolveAdaptiveLimiterObservabilityOptions(_optionalChain([raw, 'optionalAccess',
|
|
654
|
-
policy: resolveHttpPolicyObservabilityOptions(_optionalChain([raw, 'optionalAccess',
|
|
655
|
-
injectTraceHeaders: _nullishCoalesce(_optionalChain([raw, 'optionalAccess',
|
|
656
|
-
includeHostLabel: _nullishCoalesce(_optionalChain([raw, 'optionalAccess',
|
|
657
|
-
route: _optionalChain([raw, 'optionalAccess',
|
|
658
|
-
clock: _nullishCoalesce(_optionalChain([raw, 'optionalAccess',
|
|
659
|
-
durationBuckets: _optionalChain([raw, 'optionalAccess',
|
|
657
|
+
metrics: _optionalChain([raw, 'optionalAccess', _47 => _47.metrics]) === false ? void 0 : _optionalChain([raw, 'optionalAccess', _48 => _48.metrics]),
|
|
658
|
+
logs: _nullishCoalesce(_optionalChain([raw, 'optionalAccess', _49 => _49.logs]), () => ( {})),
|
|
659
|
+
spans: _nullishCoalesce(_optionalChain([raw, 'optionalAccess', _50 => _50.spans]), () => ( {})),
|
|
660
|
+
spanSink: _optionalChain([raw, 'optionalAccess', _51 => _51.spanSink]) === false ? void 0 : _optionalChain([raw, 'optionalAccess', _52 => _52.spanSink]),
|
|
661
|
+
adaptiveLimiter: resolveAdaptiveLimiterObservabilityOptions(_optionalChain([raw, 'optionalAccess', _53 => _53.adaptiveLimiter])),
|
|
662
|
+
policy: resolveHttpPolicyObservabilityOptions(_optionalChain([raw, 'optionalAccess', _54 => _54.policy])),
|
|
663
|
+
injectTraceHeaders: _nullishCoalesce(_optionalChain([raw, 'optionalAccess', _55 => _55.injectTraceHeaders]), () => ( true)),
|
|
664
|
+
includeHostLabel: _nullishCoalesce(_optionalChain([raw, 'optionalAccess', _56 => _56.includeHostLabel]), () => ( true)),
|
|
665
|
+
route: _optionalChain([raw, 'optionalAccess', _57 => _57.route]),
|
|
666
|
+
clock: _nullishCoalesce(_optionalChain([raw, 'optionalAccess', _58 => _58.clock]), () => ( Date.now)),
|
|
667
|
+
durationBuckets: _optionalChain([raw, 'optionalAccess', _59 => _59.durationBuckets])
|
|
660
668
|
};
|
|
661
669
|
}
|
|
662
670
|
function isObservabilityInstance(options) {
|
|
@@ -719,11 +727,11 @@ function adaptiveLimiterLabels(req, stats, options) {
|
|
|
719
727
|
});
|
|
720
728
|
}
|
|
721
729
|
function inferAdaptiveLimiterKey(req, stats) {
|
|
722
|
-
const policy =
|
|
730
|
+
const policy = _chunk7FZUTJM3cjs.getHttpRequestPolicy.call(void 0, req);
|
|
723
731
|
if (policy.poolKey) return policy.poolKey;
|
|
724
732
|
const host = requestHost(req);
|
|
725
733
|
if (host) return host;
|
|
726
|
-
return _optionalChain([stats, 'access',
|
|
734
|
+
return _optionalChain([stats, 'access', _60 => _60.keys, 'optionalAccess', _61 => _61.length]) === 1 ? stats.keys[0] : void 0;
|
|
727
735
|
}
|
|
728
736
|
function setGauge(metrics, name, value, labels) {
|
|
729
737
|
if (!metrics || value === void 0 || !Number.isFinite(value)) return;
|
|
@@ -801,7 +809,7 @@ function requestLogFields(req, options) {
|
|
|
801
809
|
}
|
|
802
810
|
function requestPolicyLogFields(req, options) {
|
|
803
811
|
if (!options.policy.enabled) return void 0;
|
|
804
|
-
const policy =
|
|
812
|
+
const policy = _chunk7FZUTJM3cjs.getHttpRequestPolicy.call(void 0, req);
|
|
805
813
|
const fields = {
|
|
806
814
|
...policy.preset ? { preset: policy.preset } : {},
|
|
807
815
|
...policy.lane ? { lane: policy.lane } : {},
|
|
@@ -814,7 +822,7 @@ function requestPolicyLogFields(req, options) {
|
|
|
814
822
|
}
|
|
815
823
|
function requestPolicySpanAttributes(req, options) {
|
|
816
824
|
if (!options.policy.enabled) return {};
|
|
817
|
-
const policy =
|
|
825
|
+
const policy = _chunk7FZUTJM3cjs.getHttpRequestPolicy.call(void 0, req);
|
|
818
826
|
return {
|
|
819
827
|
...compactSpanAttributes({
|
|
820
828
|
"http.request.policy.lane": policy.lane,
|
|
@@ -828,7 +836,7 @@ function requestPolicySpanAttributes(req, options) {
|
|
|
828
836
|
}
|
|
829
837
|
function requestPolicyMetricLabels(req, options) {
|
|
830
838
|
if (!options.policy.enabled || options.policy.labelKeys.length === 0) return {};
|
|
831
|
-
const policy =
|
|
839
|
+
const policy = _chunk7FZUTJM3cjs.getHttpRequestPolicy.call(void 0, req);
|
|
832
840
|
const values = {
|
|
833
841
|
preset: policy.preset,
|
|
834
842
|
lane: policy.lane,
|
|
@@ -904,17 +912,17 @@ function httpErrorStatusText(error) {
|
|
|
904
912
|
return error._tag === "FetchError" ? error.statusText : void 0;
|
|
905
913
|
}
|
|
906
914
|
function injectCurrentTraceContext(req) {
|
|
907
|
-
const fiber =
|
|
908
|
-
const trace = _optionalChain([fiber, 'optionalAccess',
|
|
909
|
-
if (!_optionalChain([trace, 'optionalAccess',
|
|
915
|
+
const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
|
|
916
|
+
const trace = _optionalChain([fiber, 'optionalAccess', _62 => _62.fiberContext, 'optionalAccess', _63 => _63.trace]);
|
|
917
|
+
if (!_optionalChain([trace, 'optionalAccess', _64 => _64.traceId]) || !_optionalChain([trace, 'optionalAccess', _65 => _65.spanId])) return req;
|
|
910
918
|
return {
|
|
911
919
|
...req,
|
|
912
|
-
headers:
|
|
920
|
+
headers: _chunkDV644N7Pcjs.injectTraceContext.call(void 0, req.headers, trace)
|
|
913
921
|
};
|
|
914
922
|
}
|
|
915
923
|
function currentTraceExemplar(value, timestamp) {
|
|
916
|
-
const fiber =
|
|
917
|
-
return
|
|
924
|
+
const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
|
|
925
|
+
return _chunkDV644N7Pcjs.exemplarFromTraceContext.call(void 0, _optionalChain([fiber, 'optionalAccess', _66 => _66.fiberContext, 'optionalAccess', _67 => _67.trace]), value, timestamp);
|
|
918
926
|
}
|
|
919
927
|
function requestHost(req) {
|
|
920
928
|
if (!isAbsoluteUrl(req.url)) return void 0;
|
|
@@ -982,38 +990,38 @@ function compactLabels(labels) {
|
|
|
982
990
|
|
|
983
991
|
// src/observability/adapters.ts
|
|
984
992
|
function makeFetchRequestObservabilityContext(observability, request, input = {}) {
|
|
985
|
-
return
|
|
993
|
+
return _chunkDV644N7Pcjs.makeRequestObservabilityContext.call(void 0, observability, {
|
|
986
994
|
headers: request.headers,
|
|
987
995
|
method: request.method,
|
|
988
|
-
target:
|
|
989
|
-
route: _nullishCoalesce(input.route, () => (
|
|
996
|
+
target: _chunkDV644N7Pcjs.sanitizeHttpTarget.call(void 0, request.url),
|
|
997
|
+
route: _nullishCoalesce(input.route, () => ( _chunkDV644N7Pcjs.normalizeHttpRoute.call(void 0, urlPathname(request.url)))),
|
|
990
998
|
...input
|
|
991
999
|
});
|
|
992
1000
|
}
|
|
993
1001
|
function makeNodeRequestObservabilityContext(observability, request, input = {}) {
|
|
994
|
-
return
|
|
1002
|
+
return _chunkDV644N7Pcjs.makeRequestObservabilityContext.call(void 0, observability, {
|
|
995
1003
|
headers: request.headers,
|
|
996
1004
|
method: request.method,
|
|
997
|
-
target:
|
|
998
|
-
route: _nullishCoalesce(input.route, () => (
|
|
1005
|
+
target: _chunkDV644N7Pcjs.sanitizeHttpTarget.call(void 0, request.url),
|
|
1006
|
+
route: _nullishCoalesce(input.route, () => ( _chunkDV644N7Pcjs.normalizeHttpRoute.call(void 0, request.url))),
|
|
999
1007
|
...input
|
|
1000
1008
|
});
|
|
1001
1009
|
}
|
|
1002
1010
|
function makeExpressRequestObservabilityContext(observability, request, input = {}) {
|
|
1003
|
-
return
|
|
1011
|
+
return _chunkDV644N7Pcjs.makeRequestObservabilityContext.call(void 0, observability, {
|
|
1004
1012
|
headers: request.headers,
|
|
1005
1013
|
method: request.method,
|
|
1006
|
-
target:
|
|
1007
|
-
route: _nullishCoalesce(_nullishCoalesce(input.route, () => ( _optionalChain([request, 'access',
|
|
1014
|
+
target: _chunkDV644N7Pcjs.sanitizeHttpTarget.call(void 0, _nullishCoalesce(request.originalUrl, () => ( request.url))),
|
|
1015
|
+
route: _nullishCoalesce(_nullishCoalesce(input.route, () => ( _optionalChain([request, 'access', _68 => _68.route, 'optionalAccess', _69 => _69.path]))), () => ( _chunkDV644N7Pcjs.normalizeHttpRoute.call(void 0, _nullishCoalesce(request.path, () => ( request.url))))),
|
|
1008
1016
|
...input
|
|
1009
1017
|
});
|
|
1010
1018
|
}
|
|
1011
1019
|
function makeFastifyRequestObservabilityContext(observability, request, input = {}) {
|
|
1012
|
-
return
|
|
1020
|
+
return _chunkDV644N7Pcjs.makeRequestObservabilityContext.call(void 0, observability, {
|
|
1013
1021
|
headers: request.headers,
|
|
1014
1022
|
method: request.method,
|
|
1015
|
-
target:
|
|
1016
|
-
route: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(input.route, () => ( _optionalChain([request, 'access',
|
|
1023
|
+
target: _chunkDV644N7Pcjs.sanitizeHttpTarget.call(void 0, request.url),
|
|
1024
|
+
route: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(input.route, () => ( _optionalChain([request, 'access', _70 => _70.routeOptions, 'optionalAccess', _71 => _71.url]))), () => ( request.routerPath)), () => ( _chunkDV644N7Pcjs.normalizeHttpRoute.call(void 0, request.url))),
|
|
1017
1025
|
...input
|
|
1018
1026
|
});
|
|
1019
1027
|
}
|
|
@@ -1034,7 +1042,7 @@ function urlPathname(url) {
|
|
|
1034
1042
|
|
|
1035
1043
|
// src/observability/config.ts
|
|
1036
1044
|
function makeNoopObservability() {
|
|
1037
|
-
return
|
|
1045
|
+
return _chunkDV644N7Pcjs.makeObservability.call(void 0, {
|
|
1038
1046
|
metrics: false,
|
|
1039
1047
|
logs: false,
|
|
1040
1048
|
traces: false,
|
|
@@ -1043,12 +1051,12 @@ function makeNoopObservability() {
|
|
|
1043
1051
|
}
|
|
1044
1052
|
function makeObservabilityPreset(preset, overrides = {}) {
|
|
1045
1053
|
if (preset === "disabled") return makeNoopObservability();
|
|
1046
|
-
return
|
|
1054
|
+
return _chunkDV644N7Pcjs.makeObservability.call(void 0, mergeObservabilityOptions(observabilityOptionsForPreset(preset), overrides));
|
|
1047
1055
|
}
|
|
1048
1056
|
function makeObservabilityFromEnv(env = readProcessEnv(), overrides = {}) {
|
|
1049
1057
|
const preset = env.BRASS_OBSERVABILITY === "disabled" ? "disabled" : parsePreset(_nullishCoalesce(env.BRASS_OBSERVABILITY_PRESET, () => ( env.NODE_ENV)));
|
|
1050
1058
|
if (preset === "disabled") return makeNoopObservability();
|
|
1051
|
-
return
|
|
1059
|
+
return _chunkDV644N7Pcjs.makeObservability.call(void 0, mergeObservabilityOptions(observabilityOptionsFromEnv(env, preset), overrides));
|
|
1052
1060
|
}
|
|
1053
1061
|
function observabilityOptionsForPreset(preset) {
|
|
1054
1062
|
switch (preset) {
|
|
@@ -1132,10 +1140,10 @@ function mergeObservabilityOptions(base, overrides) {
|
|
|
1132
1140
|
otlp: {
|
|
1133
1141
|
..._nullishCoalesce(base.otlp, () => ( {})),
|
|
1134
1142
|
..._nullishCoalesce(overrides.otlp, () => ( {})),
|
|
1135
|
-
retry: _nullishCoalesce(_optionalChain([overrides, 'access',
|
|
1143
|
+
retry: _nullishCoalesce(_optionalChain([overrides, 'access', _72 => _72.otlp, 'optionalAccess', _73 => _73.retry]), () => ( _optionalChain([base, 'access', _74 => _74.otlp, 'optionalAccess', _75 => _75.retry]))),
|
|
1136
1144
|
pipeline: {
|
|
1137
|
-
..._nullishCoalesce(_optionalChain([base, 'access',
|
|
1138
|
-
..._nullishCoalesce(_optionalChain([overrides, 'access',
|
|
1145
|
+
..._nullishCoalesce(_optionalChain([base, 'access', _76 => _76.otlp, 'optionalAccess', _77 => _77.pipeline]), () => ( {})),
|
|
1146
|
+
..._nullishCoalesce(_optionalChain([overrides, 'access', _78 => _78.otlp, 'optionalAccess', _79 => _79.pipeline]), () => ( {}))
|
|
1139
1147
|
}
|
|
1140
1148
|
}
|
|
1141
1149
|
};
|
|
@@ -1179,27 +1187,27 @@ function readProcessEnv() {
|
|
|
1179
1187
|
}
|
|
1180
1188
|
|
|
1181
1189
|
// src/observability/layer.ts
|
|
1182
|
-
var ObservabilityService =
|
|
1190
|
+
var ObservabilityService = _chunk6STX4PS3cjs.makeServiceTag.call(void 0, "Observability");
|
|
1183
1191
|
function makeObservabilityLayer(config = {}, options = {}) {
|
|
1184
1192
|
const tag = _nullishCoalesce(options.tag, () => ( ObservabilityService));
|
|
1185
|
-
return
|
|
1193
|
+
return _chunk6STX4PS3cjs.layerEffect.call(void 0,
|
|
1186
1194
|
tag,
|
|
1187
|
-
(context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () =>
|
|
1195
|
+
(context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => _chunkDV644N7Pcjs.makeObservability.call(void 0, resolveObservabilityLayerConfig(config, context))),
|
|
1188
1196
|
shutdownObservability
|
|
1189
1197
|
);
|
|
1190
1198
|
}
|
|
1191
1199
|
function makeObservedRuntimeLayer(options = {}) {
|
|
1192
1200
|
const {
|
|
1193
1201
|
observabilityTag = ObservabilityService,
|
|
1194
|
-
runtimeTag =
|
|
1202
|
+
runtimeTag = _chunkZ2YIDHRIcjs.RuntimeService,
|
|
1195
1203
|
env = {},
|
|
1196
1204
|
...runtimeOptions
|
|
1197
1205
|
} = options;
|
|
1198
|
-
return
|
|
1206
|
+
return _chunk6STX4PS3cjs.layerEffect.call(void 0,
|
|
1199
1207
|
runtimeTag,
|
|
1200
1208
|
(context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
|
|
1201
1209
|
const observability = context.unsafeGet(observabilityTag);
|
|
1202
|
-
return new (0,
|
|
1210
|
+
return new (0, _chunkZDZNV6NAcjs.Runtime)({
|
|
1203
1211
|
...runtimeOptions,
|
|
1204
1212
|
env: mergeRuntimeEnv(resolveObservedRuntimeLayerEnv(env, context, observability), observability.env),
|
|
1205
1213
|
hooks: observability.hooks
|
|
@@ -1209,8 +1217,8 @@ function makeObservedRuntimeLayer(options = {}) {
|
|
|
1209
1217
|
}
|
|
1210
1218
|
function makeObservedHttpClientLayer(config = {}, options = {}) {
|
|
1211
1219
|
const observabilityTag = _nullishCoalesce(options.observabilityTag, () => ( ObservabilityService));
|
|
1212
|
-
const httpTag = _nullishCoalesce(options.httpTag, () => (
|
|
1213
|
-
return
|
|
1220
|
+
const httpTag = _nullishCoalesce(options.httpTag, () => ( _chunk7FZUTJM3cjs.HttpClientService));
|
|
1221
|
+
return _chunk6STX4PS3cjs.layerEffect.call(void 0,
|
|
1214
1222
|
httpTag,
|
|
1215
1223
|
(context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
|
|
1216
1224
|
const observability = context.unsafeGet(observabilityTag);
|
|
@@ -1220,7 +1228,7 @@ function makeObservedHttpClientLayer(config = {}, options = {}) {
|
|
|
1220
1228
|
context,
|
|
1221
1229
|
observability
|
|
1222
1230
|
);
|
|
1223
|
-
return
|
|
1231
|
+
return _chunk7FZUTJM3cjs.makeDefaultHttpClient.call(void 0, {
|
|
1224
1232
|
...httpConfig,
|
|
1225
1233
|
middleware: [
|
|
1226
1234
|
..._nullishCoalesce(httpConfig.middleware, () => ( [])),
|
|
@@ -1250,7 +1258,7 @@ function mergeRuntimeEnv(env, observabilityEnv) {
|
|
|
1250
1258
|
return Object.assign({}, env, observabilityEnv);
|
|
1251
1259
|
}
|
|
1252
1260
|
function shutdownObservability(observability) {
|
|
1253
|
-
return
|
|
1261
|
+
return _chunkZDZNV6NAcjs.fromPromiseAbortable.call(void 0,
|
|
1254
1262
|
() => observability.shutdown().then(() => void 0),
|
|
1255
1263
|
() => void 0,
|
|
1256
1264
|
{ label: "observability.shutdown" }
|