Skip to content

Commit d73066d

Browse files
committed
Log Docker volume setup duration stats
1 parent a9afe82 commit d73066d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/interceptors/docker/docker-data-injection.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export async function ensureDockerInjectionVolumeExists(
104104
if (existingVolume && !isCertOutdated) return; // We're all good!
105105

106106
try {
107+
const startTime = Date.now();
108+
107109
// Clean up any leftover setup components that are hanging around (since they might
108110
// conflict with these next steps):
109111
await cleanupDataInjectionTools(docker);
@@ -138,21 +140,30 @@ export async function ensureDockerInjectionVolumeExists(
138140
}
139141
});
140142

143+
const blankContainerSetupTime = Date.now() - startTime;
144+
let overrideStreamTime: number | undefined;
145+
141146
// Then we use the container to write to the volume, without ever starting it:
142147
const volumeStream = TarStream.pack();
143148
// We write the CA cert, read-only:
144149
volumeStream.entry({ name: 'ca.pem', mode: parseInt('444', 8) }, certContent);
145150
// And all the override filesL
146151
const packOverridesPromise = packOverrideFiles(volumeStream, '/overrides')
147-
.then(() => volumeStream.finalize());
152+
.then(() => {
153+
volumeStream.finalize();
154+
overrideStreamTime = Date.now() - startTime;
155+
});
148156

149157
const writeVolumePromise = blankContainer.putArchive(
150158
volumeStream,
151159
{ path: '/data-volume/' }
152160
);
153161

154162
await Promise.all([packOverridesPromise, writeVolumePromise]);
155-
console.log('Created Docker injection volume');
163+
const volumeCompleteTime = Date.now() - startTime;
164+
console.log(`Created Docker injection volume (took ${
165+
volumeCompleteTime
166+
}ms: ${blankContainerSetupTime}ms for setup & ${overrideStreamTime!}ms to pack)`);
156167

157168
// After success, we cleanup the tools (blank image & containers etc) and all old HTTP
158169
// Toolkit volumes, i.e. all matching volumes _except_ the current one.

0 commit comments

Comments
 (0)