Skip to content

Commit

Permalink
Telemetry for ECS fetch and config read (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyaginidhi authored May 2, 2024
1 parent 82b43c8 commit 34e8239
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/common/ecs-features/ecsFeatureClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ITelemetry } from "../../client/telemetry/ITelemetry";
import { createECSRequestURL } from "./ecsFeatureUtil";
import { ECSFeatureDefinition as ECSFeatureProperties } from "./ecsFeatureProperties";
import { ECSAPIFeatureFlagFilters } from "./ecsFeatureFlagFilters";
import { ECSConfigFailedInit, ECSConfigSuccessfulInit } from "./ecsTelemetryConstants";

export abstract class ECSFeaturesClient {
private static _ecsConfig: Record<string, string | boolean>;
Expand All @@ -26,14 +27,16 @@ export abstract class ECSFeaturesClient {
throw new Error('Request failed');
}
const result = await response.json();
// Update telemetry in other PR
// telemetry.sendTelemetryEvent('ECSConfig', {});

// Initialize ECS config
this._ecsConfig = result[clientName];

// capture telemetry
telemetry.sendTelemetryEvent(ECSConfigSuccessfulInit, { clientName: clientName, configFlagCount: Object.keys(this._ecsConfig).length.toString() });
} catch (error) {
const message = (error as Error)?.message;
// Log error
// telemetry.sendTelemetryEvent('ECSConfigError', {});
telemetry.sendTelemetryErrorEvent(ECSConfigFailedInit, { error: message });
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/common/ecs-features/ecsTelemetryConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

// Telemetry Event Names
export const ECSConfigSuccessfulInit = 'ECSConfigSuccessfulInit';
export const ECSConfigFailedInit = 'ECSConfigFailedInit';

0 comments on commit 34e8239

Please sign in to comment.