@deslop/scope 0.1.1132 → 0.1.1134
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/dist/server.js +44 -6
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -7381,6 +7381,42 @@ const dedupe = (self) => {
|
|
|
7381
7381
|
for (const value of input) if (hashBucketsAdd(buckets, value)) out.push(value);
|
|
7382
7382
|
return out;
|
|
7383
7383
|
};
|
|
7384
|
+
/**
|
|
7385
|
+
* Computes the number of elements in an iterable that satisfy a predicate.
|
|
7386
|
+
*
|
|
7387
|
+
* **When to use**
|
|
7388
|
+
*
|
|
7389
|
+
* Use when you need to count how many elements of an iterable satisfy a
|
|
7390
|
+
* predicate.
|
|
7391
|
+
*
|
|
7392
|
+
* **Details**
|
|
7393
|
+
*
|
|
7394
|
+
* The predicate receives both the element and its index. Empty iterables return
|
|
7395
|
+
* `0`.
|
|
7396
|
+
*
|
|
7397
|
+
* **Example** (Counting even numbers)
|
|
7398
|
+
*
|
|
7399
|
+
* ```ts import.meta.vitest
|
|
7400
|
+
* import { Array } from "effect"
|
|
7401
|
+
*
|
|
7402
|
+
* Array.countBy([1, 2, 3, 4, 5], (n) => n % 2 === 0) // => 2
|
|
7403
|
+
* ```
|
|
7404
|
+
*
|
|
7405
|
+
* @see {@link filter} — when you need the matching elements, not just the count
|
|
7406
|
+
*
|
|
7407
|
+
* @stability stable
|
|
7408
|
+
* @category folding
|
|
7409
|
+
* @since 3.16.0
|
|
7410
|
+
*/
|
|
7411
|
+
const countBy = /*#__PURE__*/ dual(2, (self, f) => {
|
|
7412
|
+
let count = 0;
|
|
7413
|
+
const as = fromIterable$5(self);
|
|
7414
|
+
for (let i = 0; i < as.length; i++) {
|
|
7415
|
+
const a = as[i];
|
|
7416
|
+
if (f(a, i)) count++;
|
|
7417
|
+
}
|
|
7418
|
+
return count;
|
|
7419
|
+
});
|
|
7384
7420
|
//#endregion
|
|
7385
7421
|
//#region ../../node_modules/.pnpm/effect@4.0.5/node_modules/effect/dist/Scheduler.js
|
|
7386
7422
|
/**
|
|
@@ -65339,7 +65375,7 @@ const layerNodeHttpServer = layerConfig(createServer, {
|
|
|
65339
65375
|
});
|
|
65340
65376
|
//#endregion
|
|
65341
65377
|
//#region package.json
|
|
65342
|
-
var version = "0.1.
|
|
65378
|
+
var version = "0.1.1134";
|
|
65343
65379
|
//#endregion
|
|
65344
65380
|
//#region src/services/telemetry/schema.ts
|
|
65345
65381
|
var TelemetryError = class extends TaggedError()("TelemetryError", {
|
|
@@ -65555,7 +65591,7 @@ function summary(entries, query) {
|
|
|
65555
65591
|
}
|
|
65556
65592
|
return {
|
|
65557
65593
|
count: entries.length,
|
|
65558
|
-
errors:
|
|
65594
|
+
errors: countBy(entries, (entry) => entry.status === 2),
|
|
65559
65595
|
from: query.from,
|
|
65560
65596
|
maxMs: percentile(1),
|
|
65561
65597
|
p50Ms: percentile(.5),
|
|
@@ -65597,6 +65633,7 @@ function traceView(entries, id) {
|
|
|
65597
65633
|
onSome: (entry) => entry.time
|
|
65598
65634
|
}));
|
|
65599
65635
|
const logs = filter$1(ordered, (entry) => entry.signal === "log");
|
|
65636
|
+
const bySpan = groupBy(logs, (log) => log.spanId);
|
|
65600
65637
|
const nodes = map$5(spans, (span) => {
|
|
65601
65638
|
const ancestors = reverse(unfold({
|
|
65602
65639
|
entry: span.entry,
|
|
@@ -65610,7 +65647,7 @@ function traceView(entries, id) {
|
|
|
65610
65647
|
value: {
|
|
65611
65648
|
...span.entry,
|
|
65612
65649
|
depth: ancestors.length,
|
|
65613
|
-
logs:
|
|
65650
|
+
logs: getOrElse(get$8(bySpan, span.entry.spanId), () => []),
|
|
65614
65651
|
offsetMs: durationMs(start, span.entry.time),
|
|
65615
65652
|
parentSpanId: parentId(span.entry),
|
|
65616
65653
|
runtime: runtime(span.entry.resource)
|
|
@@ -65722,15 +65759,16 @@ var Telemetry = class extends Service$2()("@deslop/scope/services/telemetry/serv
|
|
|
65722
65759
|
}),
|
|
65723
65760
|
traces: fn("Telemetry.traces")(function* (query) {
|
|
65724
65761
|
const active = currentEntries(yield* read());
|
|
65762
|
+
const byTrace = groupBy(active, (entry) => entry.traceId);
|
|
65725
65763
|
const entries = map$5(dedupe(map$5(filter$1(filterEntries(active, query, "all"), (entry) => entry.traceId !== ""), (entry) => entry.traceId)), (id) => {
|
|
65726
|
-
const records =
|
|
65764
|
+
const records = byTrace[id] ?? [];
|
|
65727
65765
|
const view = traceView(records, id);
|
|
65728
65766
|
const root = getOrElse(head(view.spans), () => getOrThrow$1(head(records)));
|
|
65729
65767
|
return {
|
|
65730
65768
|
durationMs: view.durationMs,
|
|
65731
|
-
errors:
|
|
65769
|
+
errors: countBy(records, (entry) => entry.status === 2),
|
|
65732
65770
|
id,
|
|
65733
|
-
logs:
|
|
65771
|
+
logs: countBy(records, (entry) => entry.signal === "log"),
|
|
65734
65772
|
operation: root.name,
|
|
65735
65773
|
service: root.service,
|
|
65736
65774
|
services: view.services,
|