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

Function makeRecordingTracer

packages/hosts/mcp/src/tool-server.test.ts:109–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107
108/** A tracer that records every span + its attributes and end state. */
109const makeRecordingTracer = (): { tracer: Tracer.Tracer; spans: RecordedSpan[] } => {
110 const spans: RecordedSpan[] = [];
111 const tracer: Tracer.Tracer = {
112 span: (options) => {
113 const attributes = new Map<string, unknown>();
114 const recorded: RecordedSpan = { name: options.name, attributes, ended: false };
115 spans.push(recorded);
116 let status: Tracer.SpanStatus = { _tag: "Started", startTime: options.startTime };
117 return {
118 _tag: "Span",
119 name: options.name,
120 spanId: `span-${spans.length}`,
121 traceId: "trace-1",
122 parent: options.parent,
123 annotations: options.annotations,
124 get status() {
125 return status;
126 },
127 attributes,
128 links: options.links,
129 sampled: options.sampled,
130 kind: options.kind,
131 end: (endTime, exit) => {
132 recorded.ended = true;
133 status = { _tag: "Ended", startTime: options.startTime, endTime, exit };
134 },
135 attribute: (key, value) => {
136 attributes.set(key, value);
137 },
138 event: () => undefined,
139 addLinks: () => undefined,
140 };
141 },
142 };
143 return { tracer, spans };
144};
145
146/** withClient, but with a recording tracer installed for the whole server. */
147const withTracedClient = async <E extends Cause.YieldableError>(

Callers 1

withTracedClientFunction · 0.70

Calls 2

pushMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected