Fix telemetry recording bug

When someone disables and then re-enables the global telemetry setting,
the telemetry recorder needs to be recreated in order to allow it to
respond to events again.

Also, write the telemetry log item in the same telemetry processor as
is used to remove unused fields. This ensures there is no race condition
on the order of telemetry processors being run. We always log after
fields are removed.
This commit is contained in:
Andrew Eisenberg
2021-01-27 12:55:14 -08:00
parent 091d36b1a0
commit 7387ef6d2c

View File

@@ -67,7 +67,10 @@ export class TelemetryListener extends ConfigListener {
* @param e the configuration change event
*/
async handleDidChangeConfiguration(e: ConfigurationChangeEvent): Promise<void> {
if (e.affectsConfiguration('codeQL.telemetry.enableTelemetry')) {
if (
e.affectsConfiguration('codeQL.telemetry.enableTelemetry') ||
e.affectsConfiguration('telemetry.enableTelemetry')
) {
await this.initialize();
}
@@ -115,11 +118,6 @@ export class TelemetryListener extends ConfigListener {
baseDataPropertiesToRemove.forEach(prop => delete baseDataProperties[prop]);
}
return true;
});
// add a telemetry processor to log if requested
client.addTelemetryProcessor((envelope) => {
if (LOG_TELEMETRY.getValue<boolean>()) {
logger.log(`Telemetry: ${JSON.stringify(envelope)}`);
}