How to use the applicationinsights.Configuration function in applicationinsights

To help you get started, we’ve selected a few applicationinsights examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teamdigitale / io-functions / lib / utils / application_insights.ts View on Github external
export function wrapCustomTelemetryClient(
  isTracingDisabled: boolean,
  client: ApplicationInsights.TelemetryClient
): (
  params: ITelemetryParams,
  commonProperties?: Record
) => ApplicationInsights.TelemetryClient {
  if (isTracingDisabled) {
    // this won't disable manual calls to trackEvent / trackDependency
    ApplicationInsights.Configuration.setAutoCollectConsole(false)
      .setAutoCollectDependencies(false)
      .setAutoCollectPerformance(false)
      .setAutoCollectRequests(false)
      .setInternalLogging(false)
      // see https://stackoverflow.com/questions/49438235/application-insights-metric-in-aws-lambda/49441135#49441135
      .setUseDiskRetryCaching(false);
  }
  return (params, commonProperties) => {
    client.addTelemetryProcessor(env => {
      // tslint:disable-next-line:no-object-mutation
      env.tags = {
        ...env.tags,
        [client.context.keys.operationId]: params.operationId,
        [client.context.keys.operationParentId]: params.operationParentId,
        [client.context.keys.userAccountId]: params.serviceId
      };