From 34e8239c82cb2d11a810138053f33573e23a0daf Mon Sep 17 00:00:00 2001 From: tyaginidhi Date: Thu, 2 May 2024 12:55:49 +0530 Subject: [PATCH] Telemetry for ECS fetch and config read (#925) --- src/common/ecs-features/ecsFeatureClient.ts | 9 ++++++--- src/common/ecs-features/ecsTelemetryConstants.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/common/ecs-features/ecsTelemetryConstants.ts diff --git a/src/common/ecs-features/ecsFeatureClient.ts b/src/common/ecs-features/ecsFeatureClient.ts index 589aedd4..2d8852e2 100644 --- a/src/common/ecs-features/ecsFeatureClient.ts +++ b/src/common/ecs-features/ecsFeatureClient.ts @@ -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; @@ -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 }); } } diff --git a/src/common/ecs-features/ecsTelemetryConstants.ts b/src/common/ecs-features/ecsTelemetryConstants.ts new file mode 100644 index 00000000..dbbe721a --- /dev/null +++ b/src/common/ecs-features/ecsTelemetryConstants.ts @@ -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';