export class SourceTracer {
    constructor() {
        this.requests = [];
    }
    /** Reset the request tracer */
    reset() {
        this.requests = [];
    }
    /** Override the fetchByte function to trace all requests for this source  */
    trace(source) {
        const originFetch = source.fetchBytes;
        source.fetchBytes = async (offset, length) => {
            const request = { source: source.uri, offset, length };
            this.requests.push(request);
            const startTime = Date.now();
            const ret = await originFetch.apply(source, [offset, length]);
            request.duration = Date.now() - startTime;
            return ret;
        };
    }
}
export const St = new SourceTracer();
//# sourceMappingURL=source.tracer.js.map