Skip to content

feat: variants instrumentation #1272

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

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/registry/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import * as fs from 'node:fs';
import * as path from 'node:path';
import { Logger, SfProject, SfProjectJson } from '@salesforce/core';
import { Logger, SfProject, SfProjectJson, Lifecycle } from '@salesforce/core';
import { deepFreeze } from '../utils/collections';
import { MetadataRegistry } from './types';
import * as registryData from './metadataRegistry.json';
Expand All @@ -16,7 +16,6 @@ export type RegistryLoadInput = {
* will default to the current working directory
* if no project file is found, the standard registry will be returned without modifications
*/
// TODO: this might be a string instead of an object if no other props are needed
projectDir?: string;
};

Expand Down Expand Up @@ -49,6 +48,16 @@ const loadVariants = ({ projectDir }: RegistryLoadInput = {}): MetadataRegistry
(prev, curr) => firstLevelMerge(prev, loadPreset(curr)),
emptyRegistry
);
if (presets.length > 0 || Object.keys(customizations.types).length > 0) {
void Lifecycle.getInstance().emitTelemetry({
library: 'SDR',
eventName: 'RegistryVariants',
presetCount: presets.length,
presets: presets.join(','),
customizationsCount: Object.keys(customizations.types).length,
customizationsTypes: Object.keys(customizations.types).join(','),
});
}
return firstLevelMerge(registryFromPresets, customizations);
};

Expand All @@ -60,13 +69,6 @@ const maybeGetProject = (projectDir?: string): SfProjectJson | undefined => {
}
};

// TODO: this type should maybe live somewhere else and be part of the sfdx-project schema
// but we don't want circular dependency from sfdx-core to SDR
// type CustomRegistry = {
// registryCustomizations: MetadataRegistry;
// registryPresets: string[];
// };

const loadPreset = (preset: string): MetadataRegistry => {
const pathToCheck = path.join(__dirname, 'presets', `${preset}.json`);

Expand Down
13 changes: 5 additions & 8 deletions test/nuts/scale/perfUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ export const recordPerf = async (testName: string, performance: Performance): Pr
fileTarget,
JSON.stringify(
existing.concat(
performance
.getEntriesByType('measure')
// TODO: remove this when we upgrade to node16 and get its types
.map((m: { name: string; duration: number }) => ({
name: `${testName}-${m.name}-${os.platform()}`,
value: Math.trunc(m.duration),
unit: 'ms',
}))
performance.getEntriesByType('measure').map((m) => ({
name: `${testName}-${m.name}-${os.platform()}`,
value: Math.trunc(m.duration),
unit: 'ms',
}))
),
null,
2
Expand Down