diff --git a/.env.example b/.env.example index f258852..6a69049 100644 --- a/.env.example +++ b/.env.example @@ -46,7 +46,7 @@ ENDPOINT_L1_SUCCESS="/success/l1" L1_TOKEN_EXPIRATION=60 L1_TOKEN_HEADER_NAME=x-token L2_TOKEN_EXPIRATION=3600 -APPINSIGHTS_INSTRUMENTATIONKEY=foo +APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=foo;IngestionEndpoint=http://localhost;LiveEndpoint=http://localhost REQUIRED_ATTRIBUTES_SERVICE_NAME=Service Name ENABLE_FULL_OPERATOR_METADATA=true diff --git a/e2e/scenarios/basic/env.scenario b/e2e/scenarios/basic/env.scenario index 76c29a3..8455037 100644 --- a/e2e/scenarios/basic/env.scenario +++ b/e2e/scenarios/basic/env.scenario @@ -96,7 +96,7 @@ ENDPOINT_L1_SUCCESS="/success/l1" L1_TOKEN_EXPIRATION=60 L1_TOKEN_HEADER_NAME=x-token L2_TOKEN_EXPIRATION=3600 -APPINSIGHTS_INSTRUMENTATIONKEY=foo +APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=foo;IngestionEndpoint=http://localhost;LiveEndpoint=http://localhost REQUIRED_ATTRIBUTES_SERVICE_NAME=Service Name ENABLE_FULL_OPERATOR_METADATA=true diff --git a/e2e/scenarios/with-aws-s3/env.scenario b/e2e/scenarios/with-aws-s3/env.scenario index 07405d7..ff1e1ec 100644 --- a/e2e/scenarios/with-aws-s3/env.scenario +++ b/e2e/scenarios/with-aws-s3/env.scenario @@ -96,7 +96,7 @@ ENDPOINT_L1_SUCCESS="/success/l1" L1_TOKEN_EXPIRATION=60 L1_TOKEN_HEADER_NAME=x-token L2_TOKEN_EXPIRATION=3600 -APPINSIGHTS_INSTRUMENTATIONKEY=foo +APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=foo;IngestionEndpoint=http://localhost;LiveEndpoint=http://localhost REQUIRED_ATTRIBUTES_SERVICE_NAME=Service Name ENABLE_FULL_OPERATOR_METADATA=true diff --git a/e2e/scenarios/with-redis-cluster/env.scenario b/e2e/scenarios/with-redis-cluster/env.scenario index f74b828..6ce064d 100644 --- a/e2e/scenarios/with-redis-cluster/env.scenario +++ b/e2e/scenarios/with-redis-cluster/env.scenario @@ -96,7 +96,7 @@ ENDPOINT_L1_SUCCESS="/success/l1" L1_TOKEN_EXPIRATION=60 L1_TOKEN_HEADER_NAME=x-token L2_TOKEN_EXPIRATION=3600 -APPINSIGHTS_INSTRUMENTATIONKEY=foo +APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=foo;IngestionEndpoint=http://localhost;LiveEndpoint=http://localhost REQUIRED_ATTRIBUTES_SERVICE_NAME=Service Name ENABLE_FULL_OPERATOR_METADATA=true diff --git a/src/server.ts b/src/server.ts index ce9aca2..2af29d9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -7,9 +7,12 @@ import { getConfigOrThrow } from "./utils/config"; import { logger } from "./utils/logger"; const config = getConfigOrThrow(); -const appInsights = initAppInsights(config.APPINSIGHTS_INSTRUMENTATIONKEY, { - disableAppInsights: config.APPINSIGHTS_DISABLED -}); +const appInsights = initAppInsights( + config.APPLICATIONINSIGHTS_CONNECTION_STRING, + { + disableAppInsights: config.APPINSIGHTS_DISABLED + } +); // eslint-disable-next-line functional/immutable-data appInsights.context.tags[appInsights.context.keys.cloudRole] = diff --git a/src/utils/appinsights.ts b/src/utils/appinsights.ts index 76b89d1..191ee84 100644 --- a/src/utils/appinsights.ts +++ b/src/utils/appinsights.ts @@ -13,9 +13,9 @@ import * as appInsights from "applicationinsights"; * - Realtime API metrics */ export const initAppInsights = ( - instrumentationKey: string, + connectionString: string, config: ApplicationInsightsConfig = {} ): appInsights.TelemetryClient => { - startAppInsights(instrumentationKey, config); + startAppInsights(connectionString, config); return appInsights.defaultClient; }; diff --git a/src/utils/config.ts b/src/utils/config.ts index b5a8629..7f0dc9e 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -391,7 +391,7 @@ export type IConfigUtility = t.TypeOf; export const IConfigUtility = t.intersection([ t.interface({ APPINSIGHTS_DISABLED: t.boolean, - APPINSIGHTS_INSTRUMENTATIONKEY: NonEmptyString, + APPLICATIONINSIGHTS_CONNECTION_STRING: NonEmptyString, SERVER_PORT: NonNegativeInteger, isProduction: t.boolean }),