Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid to send telemetry usage as this method is called every 5s #4692

Merged
merged 1 commit into from Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 23 additions & 31 deletions packages/main/src/plugin/container-registry.ts
Expand Up @@ -1987,37 +1987,29 @@ export class ContainerProviderRegistry {
}

async info(engineId: string): Promise<containerDesktopAPI.ContainerEngineInfo> {
let telemetryOptions = {};
try {
const provider = this.internalProviders.get(engineId);
if (!provider) {
throw new Error('no engine matching this container');
}
if (!provider.api) {
throw new Error('no running provider for the matching container');
}
if (provider.libpodApi) {
const podmanInfo = await provider.libpodApi.podmanInfo();
return {
cpus: podmanInfo.host.cpus,
cpuIdle: podmanInfo.host.cpuUtilization.idlePercent,
memory: podmanInfo.host.memTotal,
memoryUsed: podmanInfo.host.memTotal - podmanInfo.host.memFree,
diskSize: podmanInfo.store.graphRootAllocated,
diskUsed: podmanInfo.store.graphRootUsed,
};
} else {
const dockerInfo = await provider.api.info();
return {
cpus: dockerInfo.NCPU,
memory: dockerInfo.MemTotal,
};
}
} catch (error) {
telemetryOptions = { error: error };
throw error;
} finally {
this.telemetryService.track('info', telemetryOptions);
const provider = this.internalProviders.get(engineId);
if (!provider) {
throw new Error('no engine matching this container');
}
if (!provider.api) {
throw new Error('no running provider for the matching container');
}
if (provider.libpodApi) {
const podmanInfo = await provider.libpodApi.podmanInfo();
return {
cpus: podmanInfo.host.cpus,
cpuIdle: podmanInfo.host.cpuUtilization.idlePercent,
memory: podmanInfo.host.memTotal,
memoryUsed: podmanInfo.host.memTotal - podmanInfo.host.memFree,
diskSize: podmanInfo.store.graphRootAllocated,
diskUsed: podmanInfo.store.graphRootUsed,
};
} else {
const dockerInfo = await provider.api.info();
return {
cpus: dockerInfo.NCPU,
memory: dockerInfo.MemTotal,
};
}
}
}