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
|
import {
|
|
2
2
|
RuntimeService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3NKXUX4T.mjs";
|
|
4
4
|
import {
|
|
5
5
|
exemplarFromTraceContext,
|
|
6
6
|
injectTraceContext,
|
|
@@ -13,33 +13,29 @@ import {
|
|
|
13
13
|
spanEvent,
|
|
14
14
|
validateHttpObservabilityOptions,
|
|
15
15
|
withSpan
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-URVS2OE2.mjs";
|
|
17
17
|
import {
|
|
18
18
|
HttpClientService,
|
|
19
19
|
getHttpRequestPolicy,
|
|
20
20
|
httpErrorStatus,
|
|
21
21
|
isRetryableHttpError,
|
|
22
22
|
makeDefaultHttpClient
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5RVHSBJ6.mjs";
|
|
24
24
|
import {
|
|
25
25
|
registerHttpEffect
|
|
26
26
|
} from "./chunk-MOO4L7F4.mjs";
|
|
27
27
|
import {
|
|
28
28
|
layerEffect,
|
|
29
29
|
makeServiceTag
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-KDXNWGPB.mjs";
|
|
31
31
|
import {
|
|
32
32
|
Runtime,
|
|
33
33
|
fromPromiseAbortable,
|
|
34
34
|
getCurrentFiber
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-MUMBUXU6.mjs";
|
|
36
36
|
import {
|
|
37
37
|
Cause,
|
|
38
38
|
asyncEffect,
|
|
39
|
-
asyncFail,
|
|
40
|
-
asyncFlatMap,
|
|
41
|
-
asyncFold,
|
|
42
|
-
asyncSucceed,
|
|
43
39
|
asyncSync
|
|
44
40
|
} from "./chunk-36I3M4UC.mjs";
|
|
45
41
|
|
|
@@ -134,43 +130,147 @@ function withHttpObservability(options) {
|
|
|
134
130
|
return withLeanHttpSampledSpanObservability(next, resolved, metricCache);
|
|
135
131
|
}
|
|
136
132
|
return (req) => {
|
|
137
|
-
const run =
|
|
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 = asyncEffect((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
|
+
inFlight?.increment();
|
|
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
|
+
[...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 = getCurrentFiber();
|
|
187
|
+
fiber?.addFinalizer?.(() => {
|
|
188
|
+
completeFinish("abort", void 0, { "http.cancelled": true });
|
|
189
|
+
});
|
|
190
|
+
const reqLogLevel = resolved.logs === false ? false : resolved.logs.requestLevel ?? false;
|
|
191
|
+
if (reqLogLevel) {
|
|
192
|
+
const logEff = logEffect(reqLogLevel, "http.client.request", requestLogFields(req, resolved));
|
|
193
|
+
registerHttpEffect(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 = spanEvent("http.client.response", {
|
|
201
|
+
...finish.spanAttributes,
|
|
202
|
+
...adaptiveAttrs
|
|
203
|
+
});
|
|
204
|
+
registerHttpEffect(ev, env, () => void 0);
|
|
205
|
+
}
|
|
206
|
+
const respLevel = resolved.logs === false ? false : (resolved.logs.responseLevel ?? false) || (finish.outcome === "error" ? resolved.logs.errorLevel ?? "warn" : false);
|
|
207
|
+
if (respLevel) {
|
|
208
|
+
const logEff = logEffect(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
|
+
registerHttpEffect(logEff, env, () => void 0);
|
|
216
|
+
}
|
|
217
|
+
cb({ _tag: "Success", value: res });
|
|
218
|
+
};
|
|
219
|
+
const onError = (error) => {
|
|
220
|
+
const status = httpErrorStatus(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": isRetryableHttpError(error)
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
const adaptiveAttrs = observeAdaptiveLimiter(wireReq, next, resolved);
|
|
230
|
+
if (shouldEmitHttpSpanEvents(resolved)) {
|
|
231
|
+
const ev = spanEvent("http.client.error", {
|
|
232
|
+
...finish.spanAttributes,
|
|
233
|
+
...adaptiveAttrs,
|
|
234
|
+
"error.type": error._tag
|
|
235
|
+
});
|
|
236
|
+
registerHttpEffect(ev, env, () => void 0);
|
|
237
|
+
}
|
|
238
|
+
const errLevel = resolved.logs === false ? false : resolved.logs.errorLevel ?? "error";
|
|
239
|
+
if (errLevel) {
|
|
240
|
+
const statusText = httpErrorStatusText(error);
|
|
241
|
+
const logEff = logEffect(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: isRetryableHttpError(error),
|
|
248
|
+
errorTag: error._tag,
|
|
249
|
+
message: httpErrorMessage(error)
|
|
250
|
+
});
|
|
251
|
+
registerHttpEffect(logEff, env, () => void 0);
|
|
252
|
+
}
|
|
253
|
+
cb({ _tag: "Failure", cause: Cause.fail(error) });
|
|
254
|
+
};
|
|
255
|
+
try {
|
|
256
|
+
cancelInner = registerHttpEffect(next(wireReq), env, (exit) => {
|
|
257
|
+
cancelInner = void 0;
|
|
258
|
+
if (exit._tag === "Success") onSuccess(exit.value);
|
|
259
|
+
else {
|
|
260
|
+
const failure = 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: Cause.die(error) });
|
|
267
|
+
}
|
|
268
|
+
return () => {
|
|
269
|
+
const cancel = cancelInner;
|
|
270
|
+
cancelInner = void 0;
|
|
271
|
+
cancel?.();
|
|
272
|
+
};
|
|
273
|
+
});
|
|
174
274
|
if (resolved.spans === false) return run;
|
|
175
275
|
return withSpan(spanName(req, resolved.spans), run, spanStartAttributes(req, resolved));
|
|
176
276
|
};
|
|
@@ -191,7 +291,7 @@ function canUseLeanHttpSampledSpanPath(options, adaptiveLimiter) {
|
|
|
191
291
|
function withLeanHttpSampledSpanObservability(next, options, metricCache) {
|
|
192
292
|
return (req) => asyncEffect((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;
|
|
@@ -256,7 +356,7 @@ function withLeanHttpSampledSpanObservability(next, options, metricCache) {
|
|
|
256
356
|
function withLeanHttpMetricsObservability(next, options, metricCache) {
|
|
257
357
|
return (req) => asyncEffect((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;
|
|
@@ -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 = getHttpRequestPolicy(req);
|
|
598
|
+
const preset = typeof policy === "string" ? policy : policy?.preset;
|
|
599
|
+
const key = `${req.method}|${host ?? ""}|${route ?? ""}|${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,112 +650,6 @@ function metricCacheKey(name, labels) {
|
|
|
536
650
|
}
|
|
537
651
|
return key;
|
|
538
652
|
}
|
|
539
|
-
function beginHttpObservation(req, options, metricCache) {
|
|
540
|
-
return asyncSync(() => {
|
|
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
|
-
inFlight?.increment();
|
|
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
|
-
[...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 = getCurrentFiber();
|
|
593
|
-
fiber?.addFinalizer?.(() => {
|
|
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 = httpErrorStatus(error);
|
|
600
|
-
return finish(httpErrorOutcome(error), status !== void 0 ? String(status) : void 0, {
|
|
601
|
-
"error.type": error._tag,
|
|
602
|
-
"http.retryable": isRetryableHttpError(error)
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
function prepareHttpRequest(req, options) {
|
|
609
|
-
if (!options.injectTraceHeaders) return asyncSucceed(req);
|
|
610
|
-
return asyncSync(() => injectCurrentTraceContext(req));
|
|
611
|
-
}
|
|
612
|
-
function logHttpRequest(req, options) {
|
|
613
|
-
const level = options.logs === false ? false : options.logs.requestLevel ?? false;
|
|
614
|
-
if (!level) return asyncSucceed(void 0);
|
|
615
|
-
return logEffect(level, "http.client.request", requestLogFields(req, options));
|
|
616
|
-
}
|
|
617
|
-
function logHttpResponse(req, res, finish, options) {
|
|
618
|
-
const configured = options.logs === false ? false : options.logs.responseLevel ?? false;
|
|
619
|
-
const level = configured || (finish.outcome === "error" ? options.logs !== false ? options.logs.errorLevel ?? "warn" : false : false);
|
|
620
|
-
if (!level) return asyncSucceed(void 0);
|
|
621
|
-
return logEffect(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 : options.logs.errorLevel ?? "error";
|
|
631
|
-
if (!level) return asyncSucceed(void 0);
|
|
632
|
-
const status = httpErrorStatus(error);
|
|
633
|
-
const statusText = httpErrorStatusText(error);
|
|
634
|
-
return logEffect(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: isRetryableHttpError(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;
|