* Overwrites the placeholder timing with the drain timestamp. For the simple * path the first time segment is also finalized; for the accumulated path only * the top-level aggregate is touched (segments are pre-finalized by the loop).
( output: NormalizedBlockOutput, providerStartTime: number, kind: StreamingTiming['kind'] )
| 175 | * the top-level aggregate is touched (segments are pre-finalized by the loop). |
| 176 | */ |
| 177 | function finalizeTiming( |
| 178 | output: NormalizedBlockOutput, |
| 179 | providerStartTime: number, |
| 180 | kind: StreamingTiming['kind'] |
| 181 | ): void { |
| 182 | const streamEndTime = Date.now() |
| 183 | const providerTiming = output.providerTiming |
| 184 | if (!providerTiming) return |
| 185 | |
| 186 | providerTiming.endTime = new Date(streamEndTime).toISOString() |
| 187 | providerTiming.duration = streamEndTime - providerStartTime |
| 188 | |
| 189 | if (kind === 'simple') { |
| 190 | const segment = providerTiming.timeSegments?.[0] |
| 191 | if (segment) { |
| 192 | segment.endTime = streamEndTime |
| 193 | segment.duration = streamEndTime - providerStartTime |
| 194 | } |
| 195 | } |
| 196 | } |
no outgoing calls
no test coverage detected