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