MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / searchSpans

Function searchSpans

e2e/src/surfaces/telemetry.ts:41–59  ·  view source on GitHub ↗
(query: SpanQuery)

Source from the content-addressed store, hash-verified

39
40export const makeTelemetrySurface = (motelUrl: string): TelemetrySurface => {
41 const searchSpans = (query: SpanQuery) =>
42 Effect.gen(function* () {
43 const params = new URLSearchParams({ lookback: "15m", limit: "100" });
44 if (query.operation) params.set("operation", query.operation);
45 if (query.traceId) params.set("traceId", query.traceId);
46 for (const [key, value] of Object.entries(query.attributes ?? {})) {
47 params.set(`attr.${key}`, value);
48 }
49 const response = yield* Effect.promise(() => fetch(`${motelUrl}/api/spans/search?${params}`));
50 if (!response.ok) {
51 return yield* Effect.fail(
52 `motel span search responded ${response.status}: ${yield* Effect.promise(() => response.text())}`,
53 );
54 }
55 const body = (yield* Effect.promise(() => response.json())) as {
56 readonly data?: readonly ExportedSpan[];
57 };
58 return body.data ?? [];
59 });
60
61 return {
62 searchSpans,

Callers 1

makeTelemetrySurfaceFunction · 0.85

Calls 4

setMethod · 0.80
textMethod · 0.65
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected