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

Function makeRecordingTracer

apps/cloud/src/mcp/telemetry.test.ts:15–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13};
14
15const makeRecordingTracer = (): {
16 tracer: Tracer.Tracer;
17 attributesOf: (name: string) => ReadonlyMap<string, unknown> | undefined;
18} => {
19 const spans: RecordedSpan[] = [];
20 const tracer: Tracer.Tracer = {
21 span: (options) => {
22 const attributes = new Map<string, unknown>();
23 spans.push({ name: options.name, attributes });
24 let status: Tracer.SpanStatus = { _tag: "Started", startTime: options.startTime };
25 return {
26 _tag: "Span",
27 name: options.name,
28 spanId: `span-${spans.length}`,
29 traceId: "trace-1",
30 parent: options.parent,
31 annotations: options.annotations,
32 get status() {
33 return status;
34 },
35 attributes,
36 links: options.links,
37 sampled: options.sampled,
38 kind: options.kind,
39 end: (endTime, exit) => {
40 status = { _tag: "Ended", startTime: options.startTime, endTime, exit };
41 },
42 attribute: (key, value) => {
43 attributes.set(key, value);
44 },
45 event: () => undefined,
46 addLinks: () => undefined,
47 };
48 },
49 };
50 return { tracer, attributesOf: (name) => spans.find((span) => span.name === name)?.attributes };
51};
52
53const expectDefined: <T>(value: T) => asserts value is NonNullable<T> = (value) => {
54 expect(value).toBeDefined();

Callers 1

telemetry.test.tsFile · 0.70

Calls 2

pushMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected