Skip to content

Commit c6bcad5

Browse files
committed
Initial code for go telemetry
1 parent fb4f736 commit c6bcad5

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

src/vs/workbench/contrib/tags/electron-sandbox/workspaceTagsService.ts

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,32 @@ const PyModulesToLookFor = [
244244
'playwright'
245245
];
246246

247+
const GoMetaModulesToLookFor = [
248+
'github.com/Azure/azure-sdk-for-go/sdk/'
249+
];
250+
251+
const GoModulesToLookFor = [
252+
'github.com/Azure/azure-sdk-for-go/sdk/storage/azblob',
253+
'github.com/Azure/azure-sdk-for-go/sdk/storage/azfile',
254+
'github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue',
255+
'github.com/Azure/azure-sdk-for-go/sdk/tracing/azotel',
256+
'github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin',
257+
'github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates',
258+
'github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys',
259+
'github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets',
260+
'github.com/Azure/azure-sdk-for-go/sdk/monitor/azquery',
261+
'github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs',
262+
'github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus',
263+
'github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig',
264+
'github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos',
265+
'github.com/Azure/azure-sdk-for-go/sdk/data/aztables',
266+
'github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry',
267+
'github.com/Azure/azure-sdk-for-go/sdk/cognitiveservices/azopenai',
268+
'github.com/Azure/azure-sdk-for-go/sdk/azidentity',
269+
'github.com/Azure/azure-sdk-for-go/sdk/azcore'
270+
];
271+
272+
247273
export class WorkspaceTagsService implements IWorkspaceTagsService {
248274
declare readonly _serviceBrand: undefined;
249275
private _tags: Tags | undefined;
@@ -566,6 +592,24 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
566592
"workspace.py.azure-security-attestation" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
567593
"workspace.py.azure-data-nspkg" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
568594
"workspace.py.azure-data-tables" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
595+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
596+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/storage/azfile" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
597+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
598+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/tracing/azotel" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
599+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
600+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
601+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
602+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
603+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/monitor/azquery" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
604+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
605+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
606+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
607+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
608+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/data/aztables" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
609+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
610+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/cognitiveservices/azopenai" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
611+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/azidentity" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
612+
"workspace.go.mod.github.com/Azure/azure-sdk-for-go/sdk/azcore" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true }
569613
}
570614
*/
571615
private async resolveWorkspaceTags(): Promise<Tags> {
@@ -624,6 +668,8 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
624668
tags['workspace.py.app'] = nameSet.has('app.py');
625669
tags['workspace.py.pyproject'] = nameSet.has('pyproject.toml');
626670

671+
tags['workspace.go.mod'] = nameSet.has('go.mod');
672+
627673
const mainActivity = nameSet.has('mainactivity.cs') || nameSet.has('mainactivity.fs');
628674
const appDelegate = nameSet.has('appdelegate.cs') || nameSet.has('appdelegate.fs');
629675
const androidManifest = nameSet.has('androidmanifest.xml');
@@ -752,6 +798,29 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
752798
}
753799
});
754800

801+
const goModPromises = getFilePromises('go.mod', this.fileService, this.textFileService, content => {
802+
// TODO: Richard to write the code for parsing the go.mod file
803+
// look for everything in require() and get the string value only discard version
804+
const dependencies: string[] = splitLines(content.value);
805+
for (const dependency of dependencies) {
806+
// Dependencies in requirements.txt can have 3 formats: `foo==3.1, foo>=3.1, foo`
807+
const format1 = dependency.split('==');
808+
const format2 = dependency.split('>=');
809+
const packageName = (format1.length === 2 ? format1[0] : format2[0]).trim();
810+
811+
// copied from line 728 function addPythonTags
812+
if (GoModulesToLookFor.indexOf(packageName) > -1) {
813+
tags['workspace.go.mod' + packageName] = true;
814+
}
815+
// not sure if we should keep this
816+
for (const metaModule of GoMetaModulesToLookFor) {
817+
if (packageName.startsWith(metaModule)) {
818+
tags['workspace.go.mod' + metaModule] = true;
819+
}
820+
}
821+
}
822+
});
823+
755824
const pomPromises = getFilePromises('pom.xml', this.fileService, this.textFileService, content => {
756825
try {
757826
let dependenciesContent;
@@ -792,7 +861,7 @@ export class WorkspaceTagsService implements IWorkspaceTagsService {
792861
});
793862
});
794863

795-
return Promise.all([...packageJsonPromises, ...requirementsTxtPromises, ...pipfilePromises, ...pomPromises, ...gradlePromises, ...androidPromises]).then(() => tags);
864+
return Promise.all([...packageJsonPromises, ...requirementsTxtPromises, ...pipfilePromises, ...pomPromises, ...gradlePromises, ...androidPromises, ...goModPromises]).then(() => tags);
796865
});
797866
}
798867

0 commit comments

Comments
 (0)