Repository: microsoft/ApplicationInsights-node.js
Pull request #1019 (2022-10-07 22:59:24)

[Preview] Allow configuration of instrumentations
Use HTTPInstrumentation to get Standard Metrics now
Removed obsolete configs
Refactor log exporter as the only exporter available in here


Patch:
diff --git a/README.md b/README.md
index 72046f6..d8b6b08 100644
--- a/README.md
+++ b/README.md
@@ -230,13 +230,12 @@ separately from clients created with `new appInsights.TelemetryClient()`.
 | enableAutoCollectExtendedMetrics| Sets the state of performance tracking. If true, extended metrics counters will be collected every minute and sent to Application Insights | true|
 | enableAutoCollectPreAggregatedMetrics | Sets the state of pre aggregated metrics tracking. If true pre aggregated metrics will be collected every minute and sent to Application Insights | true|
 | enableAutoCollectHeartbeat      | Sets the state of request tracking. If true HeartBeat metric data will be collected every 15 minutes and sent to Application Insights | true|
-| enableAutoCollectRequests      | Sets the state of request tracking. If true requests will be sent to Application Insights | true|
-| enableAutoCollectDependencies  | Sets the state of dependency tracking. If true dependencies will be sent to Application Insights | true|
 | enableInternalDebugLogging    | Enables debug and warning logging for AppInsights itself. If true, enables debug logging |true|
 | enableInternalWarningLogging  | Enables debug and warning logging for AppInsights itself. If true, enables warning logging |true|
 | enableSendLiveMetrics         | Enables communication with Application Insights Live Metrics. If true, enables communication with the live metrics service |false|
 | extendedMetrics       | Enable/Disable specific extended Metrics(gc, heap and loop).  |{"gc":false,"heap":false,"loop":false}|
 | aadTokenCredential| Azure Credential instance to be used to authenticate the App. [AAD Identity Credential Classes](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#credential-classes) | |
+| instrumentations| Allow configuration of OpenTelemetry Instrumentations. |  {"http": { enabled: true },"azureSdk": { enabled: false },"mongoDb": { enabled: false },"mySql": { enabled: false },"postgreSql": { enabled: false },"redis": { enabled: false }}|
 
 [Config.ts]: https://github.com/microsoft/ApplicationInsights-node.js/blob/develop/Library/Config.ts
 
diff --git a/src/autoCollection/metrics/collection/httpMetricsInstrumentation.ts b/src/autoCollection/metrics/collection/azureHttpMetricsInstrumentation.ts
similarity index 98%
rename from src/autoCollection/metrics/collection/httpMetricsInstrumentation.ts
rename to src/autoCollection/metrics/collection/azureHttpMetricsInstrumentation.ts
index 30e3e9c..afef411 100644
--- a/src/autoCollection/metrics/collection/httpMetricsInstrumentation.ts
+++ b/src/autoCollection/metrics/collection/azureHttpMetricsInstrumentation.ts
@@ -17,11 +17,11 @@ import { Histogram, MeterProvider, ValueType } from '@opentelemetry/api-metrics'
 import { APPLICATION_INSIGHTS_SDK_VERSION } from "../../../declarations/constants";
 import { HttpMetricsInstrumentationConfig, IHttpStandardMetric, MetricId, MetricName } from '../types';
 import { Logger } from '../../../library/logging';
-import { SpanKind } from '@opentelemetry/api';
+import { SpanKind, TracerProvider } from '@opentelemetry/api';
 import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
 
 
-export class HttpMetricsInstrumentation extends InstrumentationBase<Http> {
+export class AzureHttpMetricsInstrumentation extends InstrumentationBase<Http> {
 
   private _nodeVersion: string;
   public totalRequestCount: number = 0;
@@ -40,6 +40,8 @@ export class HttpMetricsInstrumentation extends InstrumentationBase<Http> {
     this._updateMetricInstruments();
   }
 
+  public setTracerProvider(tracerProvider: TracerProvider) { }
+
   public setMeterProvider(meterProvider: MeterProvider) {
     super.setMeterProvider(meterProvider);
     this._updateMetricInstruments();
diff --git a/src/autoCollection/metrics/collection/dependencyMetrics.ts b/src/autoCollection/metrics/collection/dependencyMetrics.ts
index 970ac4a..ab8b9e1 100644
--- a/src/autoCollection/metrics/collection/dependencyMetrics.ts
+++ b/src/autoCollection/metrics/collection/dependencyMetrics.ts
@@ -1,13 +1,13 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
 import { Meter, ObservableCallback, ObservableGauge, ObservableResult, ValueType } from "@opentelemetry/api-metrics";
-import { HttpMetricsInstrumentation } from "./httpMetricsInstrumentation";
+import { AzureHttpMetricsInstrumentation } from "./azureHttpMetricsInstrumentation";
 import { MetricName } from "../types";
 
 
 export class DependencyMetrics {
     private _meter: Meter;
-    private _httpMetrics: HttpMetricsInstrumentation;
+    private _httpMetrics: AzureHttpMetricsInstrumentation;
     private _dependencyFailureRateGauge: ObservableGauge;
     private _dependencyFailureRateGaugeCallback: ObservableCallback;
     private _dependencyRateGauge: ObservableGauge;
@@ -15,7 +15,7 @@ export class DependencyMetrics {
     private _lastDependencyRate: { count: number; time: number; executionInterval: number; };
     private _lastFailureDependencyRate: { count: number; time: number; executionInterval: number; };
 
-    constructor(meter: Meter, httpMetrics: HttpMetricsInstrumentation) {
+    constructor(meter: Meter, httpMetrics: AzureHttpMetricsInstrumentation) {
         this._meter = meter;
         this._httpMetrics = httpMetrics;
 
diff --git a/src/autoCollection/metrics/collection/requestMetrics.ts b/src/autoCollection/metrics/collection/requestMetrics.ts
index 0d241d4..b142fd1 100644
--- a/src/autoCollection/metrics/collection/requestMetrics.ts
+++ b/src/autoCollection/metrics/collection/requestMetrics.ts
@@ -1,13 +1,13 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
 import { Meter, ObservableCallback, ObservableGauge, ObservableResult, ValueType } from "@opentelemetry/api-metrics";
-import { HttpMetricsInstrumentation } from "./httpMetricsInstrumentation";
+import { AzureHttpMetricsInstrumentation } from "./azureHttpMetricsInstrumentation";
 import { MetricName } from "../types";
 
 
 export class RequestMetrics {
     private _meter: Meter;
-    private _httpMetrics: HttpMetricsInstrumentation;
+    private _httpMetrics: AzureHttpMetricsInstrumentation;
     private _requestRateGauge: ObservableGauge;
     private _requestRateGaugeCallback: ObservableCallback;
     private _requestFailureRateGauge: ObservableGauge;
@@ -15,7 +15,7 @@ export class RequestMetrics {
     private _lastRequestRate: { count: number; time: number; executionInterval: number; };
     private _lastFailureRequestRate: { count: number; time: number; executionInterval: number; };
 
-    constructor(meter: Meter, httpMetrics: HttpMetricsInstrumentation) {
+    constructor(meter: Meter, httpMetrics: AzureHttpMetricsInstrumentation) {
         this._meter = meter;
         this._httpMetrics = httpMetrics;
         this._lastRequestRate = { count: 0, time: 0, executionInterval: 0 };
diff --git a/src/autoCollection/metrics/handlers/liveMetricsHandler.ts b/src/autoCollection/metrics/handlers/liveMetricsHandler.ts
index fd343c1..69e4007 100644
--- a/src/autoCollection/metrics/handlers/liveMetricsHandler.ts
+++ b/src/autoCollection/metrics/handlers/liveMetricsHandler.ts
@@ -6,7 +6,7 @@ import { Config } from "../../../library";
 import { ResourceManager } from "../../../library/handlers";
 import { DependencyMetrics } from "../collection/dependencyMetrics";
 import { ExceptionMetrics } from "../collection/exceptionMetrics";
-import { HttpMetricsInstrumentation } from "../collection/httpMetricsInstrumentation";
+import { AzureHttpMetricsInstrumentation } from "../collection/azureHttpMetricsInstrumentation";
 import { ProcessMetrics } from "../collection/processMetrics";
 import { RequestMetrics } from "../collection/requestMetrics";
 import { HttpMetricsInstrumentationConfig, MetricName, QuickPulseCounter } from "../types";
@@ -20,7 +20,7 @@ export class LiveMetricsHandler {
     private _metricReader: PeriodicExportingMetricReader;
     private _meter: Meter;
     private _exceptionMetrics: ExceptionMetrics;
-    private _httpMetrics: HttpMetricsInstrumentation;
+    private _httpMetrics: AzureHttpMetricsInstrumentation;
     private _processMetrics: ProcessMetrics;
     private _requestMetrics: RequestMetrics;
     private _dependencyMetrics: DependencyMetrics;
@@ -54,7 +54,7 @@ export class LiveMetricsHandler {
         };
         this._processMetrics = new ProcessMetrics(this._meter);
         this._exceptionMetrics = new ExceptionMetrics(this._meter);
-        this._httpMetrics = new HttpMetricsInstrumentation(httpMetricsConfig);
+        this._httpMetrics = new AzureHttpMetricsInstrumentation(httpMetricsConfig);
         this._requestMetrics = new RequestMetrics(this._meter, this._httpMetrics);
         this._dependencyMetrics = new DependencyMetrics(this._meter, this._httpMetrics);
     }
@@ -70,7 +70,7 @@ export class LiveMetricsHandler {
         this._meterProvider.shutdown();
     }
 
-    public getHttpMetricsInstrumentation(): HttpMetricsInstrumentation {
+    public getHttpMetricsInstrumentation(): AzureHttpMetricsInstrumentation {
         return this._httpMetrics;
     }
 
diff --git a/src/autoCollection/metrics/handlers/performanceCounterMetricsHandler.ts b/src/autoCollection/metrics/handlers/performanceCounterMetricsHandler.ts
index 1fdafe5..bc08fcb 100644
--- a/src/autoCollection/metrics/handlers/performanceCounterMetricsHandler.ts
+++ b/src/autoCollection/metrics/handlers/performanceCounterMetricsHandler.ts
@@ -5,7 +5,7 @@ import { AzureExporterConfig, AzureMonitorMetricExporter } from "@azure/monitor-
 import { Meter } from "@opentelemetry/api-metrics";
 import { DropAggregation, MeterProvider, MeterProviderOptions, PeriodicExportingMetricReader, PeriodicExportingMetricReaderOptions, View } from "@opentelemetry/sdk-metrics";
 import { HttpMetricsInstrumentationConfig, MetricName, NativeMetricsCounter, PerformanceCounter } from "../types";
-import { HttpMetricsInstrumentation } from "../collection/httpMetricsInstrumentation";
+import { AzureHttpMetricsInstrumentation } from "../collection/azureHttpMetricsInstrumentation";
 import { ProcessMetrics } from "../collection/processMetrics";
 import { RequestMetrics } from "../collection/requestMetrics";
 import { Config } from "../../../library";
@@ -20,7 +20,7 @@ export class PerformanceCounterMetricsHandler {
     private _azureExporter: AzureMonitorMetricExporter;
     private _metricReader: PeriodicExportingMetricReader;
     private _meter: Meter;
-    private _httpMetrics: HttpMetricsInstrumentation;
+    private _httpMetrics: AzureHttpMetricsInstrumentation;
     private _processMetrics: ProcessMetrics;
     private _requestMetrics: RequestMetrics;
     private _nativeMetrics: NativePerformanceMetrics;
@@ -53,7 +53,7 @@ export class PerformanceCounterMetricsHandler {
                 return false;
             }
         };
-        this._httpMetrics = new HttpMetricsInstrumentation(httpMetricsConfig);
+        this._httpMetrics = new AzureHttpMetricsInstrumentation(httpMetricsConfig);
         this._processMetrics = new ProcessMetrics(this._meter);
         this._requestMetrics = new RequestMetrics(this._meter, this._httpMetrics);
         this._nativeMetrics = new NativePerformanceMetrics(this._meter);
@@ -62,14 +62,14 @@ export class PerformanceCounterMetricsHandler {
     public start() {
         this._processMetrics.enable(true);;
         this._requestMetrics.enable(true);
-        this._nativeMetrics?.enable(true);
+        this._nativeMetrics.enable(true);
     }
 
     public shutdown() {
         this._meterProvider.shutdown();
     }
 
-    public getHttpMetricsInstrumentation(): HttpMetricsInstrumentation {
+    public getHttpMetricsInstrumentation(): AzureHttpMetricsInstrumentation {
         return this._httpMetrics;
     }
 
diff --git a/src/autoCollection/metrics/handlers/standardMetricsHandler.ts b/src/autoCollection/metrics/handlers/standardMetricsHandler.ts
index 0c48dd5..d031364 100644
--- a/src/autoCollection/metrics/handlers/standardMetricsHandler.ts
+++ b/src/autoCollection/metrics/handlers/standardMetricsHandler.ts
@@ -1,13 +1,11 @@
 import { AzureExporterConfig, AzureMonitorMetricExporter } from "@azure/monitor-opentelemetry-exporter";
 import { Meter } from "@opentelemetry/api-metrics";
 import { MeterProvider, MeterProviderOptions, PeriodicExportingMetricReader, PeriodicExportingMetricReaderOptions, View } from "@opentelemetry/sdk-metrics";
-import { RequestOptions } from "https";
 import { Config } from "../../../library";
 import { ResourceManager } from "../../../library/handlers";
 import { ExceptionMetrics } from "../collection/exceptionMetrics";
-import { HttpMetricsInstrumentation } from "../collection/httpMetricsInstrumentation";
 import { TraceMetrics } from "../collection/traceMetrics";
-import { HttpMetricsInstrumentationConfig, MetricName, StandardMetric } from "../types";
+import { MetricName, StandardMetric } from "../types";
 
 
 export class StandardMetricsHandler {
@@ -20,7 +18,6 @@ export class StandardMetricsHandler {
     private _meter: Meter;
     private _exceptionMetrics: ExceptionMetrics;
     private _traceMetrics: TraceMetrics;
-    private _httpMetrics: HttpMetricsInstrumentation;
 
     constructor(config: Config, options?: { collectionInterval: number }) {
         this._config = config;
@@ -41,16 +38,6 @@ export class StandardMetricsHandler {
         this._metricReader = new PeriodicExportingMetricReader(metricReaderOptions);
         this._meterProvider.addMetricReader(this._metricReader);
         this._meter = this._meterProvider.getMeter("ApplicationInsightsStandardMetricsMeter");
-
-        const httpMetricsConfig: HttpMetricsInstrumentationConfig = {
-            ignoreOutgoingRequestHook: (request: RequestOptions) => {
-                if (request.headers && request.headers["user-agent"]) {
-                    return request.headers["user-agent"].toString().indexOf("azsdk-js-monitor-opentelemetry-exporter") > -1;
-                }
-                return false;
-            }
-        };
-        this._httpMetrics = new HttpMetricsInstrumentation(httpMetricsConfig);
         this._exceptionMetrics = new ExceptionMetrics(this._meter);
         this._traceMetrics = new TraceMetrics(this._meter);
     }
@@ -64,8 +51,8 @@ export class StandardMetricsHandler {
         this._meterProvider.shutdown();
     }
 
-    public getHttpMetricsInstrumentation(): HttpMetricsInstrumentation {
-        return this._httpMetrics;
+    public getMeterProvider(): MeterProvider {
+        return this._meterProvider;
     }
 
     public getExceptionMetrics(): ExceptionMetrics {
diff --git a/src/autoCollection/metrics/statsbeat/statsbeat.ts b/src/autoCollection/metrics/statsbeat/statsbeat.ts
index 0072ff9..34b8cf2 100644
--- a/src/autoCollection/metrics/statsbeat/statsbeat.ts
+++ b/src/autoCollection/metrics/statsbeat/statsbeat.ts
@@ -29,7 +29,6 @@ export class Statsbeat {
     private _collectionShortIntervalMs: number = 900000; // 15 minutes
     private _collectionLongIntervalMs: number = 1440000; // 1 day
     private _TAG = "Statsbeat";
-    private _metricHandler: MetricHandler;
     private _networkStatsbeatCollection: Array<NetworkStatsbeat>;
     private _resourceManager: ResourceManager;
     private _handle: NodeJS.Timer | null;
@@ -67,7 +66,6 @@ export class Statsbeat {
         this._statsbeatConfig.enableAutoCollectPerformance = false;
         this._statsbeatConfig.enableAutoCollectPreAggregatedMetrics = false;
         this._statsbeatConfig.enableAutoCollectConsole = false;
-        this._metricHandler = new MetricHandler(this._statsbeatConfig);
     }
 
     public enable(isEnabled: boolean) {
diff --git a/src/autoCollection/metrics/types.ts b/src/autoCollection/metrics/types.ts
index aa99789..53241e7 100644
--- a/src/autoCollection/metrics/types.ts
+++ b/src/autoCollection/metrics/types.ts
@@ -59,8 +59,8 @@ export enum QuickPulseCounter {
 }
 
 export enum StandardMetric {
-  REQUESTS = "requests/duration",
-  DEPENDENCIES = "dependencies/duration",
+  REQUESTS = "http.server.duration",
+  DEPENDENCIES = "http.client.duration",
   EXCEPTIONS = "Exceptions",
   TRACES = "Traces",
 }
diff --git a/src/library/azureVirtualMachine.ts b/src/library/azureVirtualMachine.ts
index 8dce220..1edf32d 100644
--- a/src/library/azureVirtualMachine.ts
+++ b/src/library/azureVirtualMachine.ts
@@ -22,8 +22,6 @@ export class AzureVirtualMachine {
         const metadataRequestUrl = `${AIMS_URI}?${AIMS_API_VERSION}&${AIMS_FORMAT}`;
         const requestOptions = {
             method: "GET",
-            // [AutoCollectHttpDependencies.disableCollectionRequestOption]: true,
-            // TODO: disable tracking of this HTTP call
             headers: {
                 Metadata: "True",
             },
diff --git a/src/library/configuration/config.ts b/src/library/configuration/config.ts
index 6dee671..6db51ae 100644
--- a/src/library/configuration/config.ts
+++ b/src/library/configuration/config.ts
@@ -5,7 +5,7 @@ import { ConnectionStringParser } from "./connectionStringParser";
 import { Logger } from "../logging";
 import * as Constants from "../../declarations/constants";
 import { JsonConfig } from "./jsonConfig";
-import { ExtendedMetricType, IConfig, iInstrumentation, InstrumentationType } from "./interfaces";
+import { ExtendedMetricType, IConfig, InstrumentationsConfig } from "./interfaces";
 
 
 export class Config implements IConfig {
@@ -19,14 +19,12 @@ export class Config implements IConfig {
     public enableAutoCollectExternalLoggers: boolean;
     public enableAutoCollectPreAggregatedMetrics: boolean;
     public enableAutoCollectHeartbeat: boolean;
-    public enableAutoCollectRequests: boolean;
-    public enableAutoCollectDependencies: boolean;
     public enableSendLiveMetrics: boolean;
     public disableStatsbeat: boolean;
     public quickPulseHost: string;
     public setupString: string;
-    public instrumentations: { [type: string]: iInstrumentation };
     public extendedMetrics: { [type: string]: boolean };
+    public instrumentations: InstrumentationsConfig;
 
     private _connectionString: string;
     private _endpointBase: string = Constants.DEFAULT_BREEZE_ENDPOINT;
@@ -72,8 +70,6 @@ export class Config implements IConfig {
         this.disableStatsbeat = this.disableStatsbeat != undefined ? this.disableStatsbeat : false;
         this.enableAutoCollectConsole = this.enableAutoCollectConsole != undefined ? this.enableAutoCollectConsole : false;
         this.enableAutoCollectExternalLoggers = this.enableAutoCollectExternalLoggers != undefined ? this.enableAutoCollectExternalLoggers : true;
-        this.enableAutoCollectDependencies = this.enableAutoCollectDependencies != undefined ? this.enableAutoCollectDependencies : true;
-        this.enableAutoCollectRequests = this.enableAutoCollectRequests != undefined ? this.enableAutoCollectRequests : true;
         this.enableAutoCollectExceptions = this.enableAutoCollectExceptions != undefined ? this.enableAutoCollectExceptions : true;
         this.enableAutoCollectHeartbeat = this.enableAutoCollectHeartbeat != undefined ? this.enableAutoCollectHeartbeat : true;
         this.enableAutoCollectPerformance = this.enableAutoCollectPerformance != undefined ? this.enableAutoCollectPerformance : true;
@@ -81,13 +77,15 @@ export class Config implements IConfig {
         this.enableSendLiveMetrics = this.enableSendLiveMetrics != undefined ? this.enableSendLiveMetrics : false;
         this.samplingPercentage = this.samplingPercentage != undefined ? this.samplingPercentage : 100;
         if (!this.instrumentations) {
-            this.instrumentations = {};
-            this.instrumentations[InstrumentationType.azureSdk] = { enabled: false };
-            this.instrumentations[InstrumentationType.mongoDb] = { enabled: false };
-            this.instrumentations[InstrumentationType.mySql] = { enabled: false };
-            this.instrumentations[InstrumentationType.postgreSql] = { enabled: false };
-            this.instrumentations[InstrumentationType.redis] = { enabled: false };
-            this.instrumentations[InstrumentationType.redis4] = { enabled: false };
+            this.instrumentations = {
+                "http": { enabled: true },
+                "azureSdk": { enabled: false },
+                "mongoDb": { enabled: false },
+                "mySql": { enabled: false },
+                "postgreSql": { enabled: false },
+                "redis": { enabled: false },
+                "redis4": { enabled: false }
+            };
         }
         if (!this.extendedMetrics) {
             this.extendedMetrics = {};
@@ -122,13 +120,11 @@ export class Config implements IConfig {
         this._connectionString = jsonConfig.connectionString;
         this.disableStatsbeat = jsonConfig.disableStatsbeat;
         this.enableAutoCollectConsole = jsonConfig.enableAutoCollectConsole;
-        this.enableAutoCollectDependencies = jsonConfig.enableAutoCollectDependencies;
         this.enableAutoCollectExceptions = jsonConfig.enableAutoCollectExceptions;
         this.enableAutoCollectExternalLoggers = jsonConfig.enableAutoCollectExternalLoggers;
         this.enableAutoCollectHeartbeat = jsonConfig.enableAutoCollectHeartbeat;
         this.enableAutoCollectPerformance = jsonConfig.enableAutoCollectPerformance;
         this.enableAutoCollectPreAggregatedMetrics = jsonConfig.enableAutoCollectPreAggregatedMetrics;
-        this.enableAutoCollectRequests = jsonConfig.enableAutoCollectRequests;
         this.enableSendLiveMetrics = jsonConfig.enableSendLiveMetrics;
         this.endpointUrl = jsonConfig.endpointUrl;
         this.quickPulseHost = jsonConfig.quickPulseHost;
diff --git a/src/library/configuration/interfaces.ts b/src/library/configuration/interfaces.ts
index 8aa9c7a..fb981fd 100644
--- a/src/library/configuration/interfaces.ts
+++ b/src/library/configuration/interfaces.ts
@@ -36,16 +36,6 @@ export interface IBaseConfig {
      * if true HeartBeat metric data will be collected every 15 minutes and sent to Application Insights
      */
     enableAutoCollectHeartbeat: boolean;
-    /**
-     * Sets the state of request tracking (enabled by default)
-     * if true requests will be sent to Application Insights
-     */
-    enableAutoCollectRequests: boolean;
-    /**
-     * Sets the state of dependency tracking (enabled by default)
-     * if true dependencies will be sent to Application Insights
-     */
-    enableAutoCollectDependencies: boolean;
     /**
      * Enables communication with Application Insights Live Metrics.
      * if true, enables communication with the live metrics service
@@ -60,26 +50,22 @@ export interface IBaseConfig {
      */
     quickPulseHost: string;
 
-    instrumentations: { [type: string]: iInstrumentation };
+    instrumentations: InstrumentationsConfig
     /**
     * Specific extended metrics
     */
     extendedMetrics: { [type: string]: boolean };
 }
 
-export interface iInstrumentation {
-    enabled: boolean;
-    configuration?: InstrumentationConfig;
-}
-
-export const enum InstrumentationType {
-    azureSdk = "azureSdk",
-    mongoDb = "mongoDb",
-    mySql = "mySql",
-    postgreSql = "postgreSql",
-    redis = "redis",
-    redis4 = "redis4"
-}
+export interface InstrumentationsConfig {
+    azureSdk?: InstrumentationConfig,
+    http?: InstrumentationConfig,
+    mongoDb?: InstrumentationConfig,
+    mySql?: InstrumentationConfig,
+    postgreSql?: InstrumentationConfig,
+    redis?: InstrumentationConfig,
+    redis4?: InstrumentationConfig
+};
 
 export const enum ExtendedMetricType {
     gc = "gc",
diff --git a/src/library/configuration/jsonConfig.ts b/src/library/configuration/jsonConfig.ts
index fea0d12..504206e 100644
--- a/src/library/configuration/jsonConfig.ts
+++ b/src/library/configuration/jsonConfig.ts
@@ -1,7 +1,8 @@
 import * as fs from "fs";
 import * as path from "path";
 import { Logger } from "../logging";
-import { iInstrumentation, IJsonConfig } from "./interfaces";
+import { IJsonConfig, InstrumentationsConfig } from "./interfaces";
+
 
 const ENV_CONFIGURATION_FILE = "APPLICATIONINSIGHTS_CONFIGURATION_FILE";
 // Azure Connection String
@@ -21,14 +22,13 @@ export class JsonConfig implements IJsonConfig {
     public enableAutoCollectPerformance: boolean;
     public enableAutoCollectPreAggregatedMetrics: boolean;
     public enableAutoCollectHeartbeat: boolean;
-    public enableAutoCollectRequests: boolean;
-    public enableAutoCollectDependencies: boolean;
     public enableSendLiveMetrics: boolean;
     public disableStatsbeat: boolean;
     public quickPulseHost: string;
-    public instrumentations: { [type: string]: iInstrumentation };
+    public instrumentations: InstrumentationsConfig;
     public extendedMetrics: { [type: string]: boolean };
 
+
     static getInstance() {
         if (!JsonConfig._instance) {
             JsonConfig._instance = new JsonConfig();
@@ -72,8 +72,6 @@ export class JsonConfig implements IJsonConfig {
             this.enableAutoCollectPreAggregatedMetrics =
                 jsonConfig.enableAutoCollectPreAggregatedMetrics;
             this.enableAutoCollectHeartbeat = jsonConfig.enableAutoCollectHeartbeat;
-            this.enableAutoCollectRequests = jsonConfig.enableAutoCollectRequests;
-            this.enableAutoCollectDependencies = jsonConfig.enableAutoCollectDependencies;
             this.enableSendLiveMetrics = jsonConfig.enableSendLiveMetrics;
             this.quickPulseHost = jsonConfig.quickPulseHost;
             this.instrumentations = jsonConfig.instrumentations;
diff --git a/src/library/exporters/logExporter.ts b/src/library/exporters/logExporter.ts
index 394ba24..94516cb 100644
--- a/src/library/exporters/logExporter.ts
+++ b/src/library/exporters/logExporter.ts
@@ -1,27 +1,192 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
-import { diag } from "@opentelemetry/api";
+import { context } from "@opentelemetry/api";
+import { ExportResult, ExportResultCode, suppressTracing } from "@opentelemetry/core";
+import { RestError } from "@azure/core-rest-pipeline";
 import { AzureExporterConfig } from "@azure/monitor-opentelemetry-exporter";
-import { BaseExporter } from "./shared";
-import { Config } from "../configuration";
+import { Logger } from "../logging"
+import { Config, ConnectionStringParser } from "../configuration";
+import { isRetriable, IBreezeResponse, IBreezeError } from "./shared/breezeUtils";
+import { TelemetryItem as Envelope } from "../../declarations/generated";
+import { IPersistentStorage, ISender } from "../../declarations/types";
+import { DEFAULT_EXPORTER_CONFIG, IAzureExporterInternalConfig } from "../../declarations/config";
+import { HttpSender } from "./shared/httpSender";
+import { FileSystemPersist } from "./shared/persist";
 
 
-export class LogExporter extends BaseExporter {
+export class LogExporter {
+    protected readonly _sender: ISender;
+    protected readonly _options: IAzureExporterInternalConfig;
+    private readonly _persister: IPersistentStorage;
+    private _numConsecutiveRedirects: number;
+    private _retryTimer: NodeJS.Timer | null;
 
     constructor(config: Config) {
-        let ingestionEndpoint = config.endpointUrl.replace("/v2.1/track", "");
-        let connectionString = `InstrumentationKey=${config.instrumentationKey};IngestionEndpoint=${ingestionEndpoint}`;
+        const ingestionEndpoint = config.endpointUrl.replace("/v2.1/track", "");
+        const connectionString = `InstrumentationKey=${config.instrumentationKey};IngestionEndpoint=${ingestionEndpoint}`;
         let exporterConfig: AzureExporterConfig = {
             connectionString: connectionString,
         };
-        super(exporterConfig);
+
+        this._numConsecutiveRedirects = 0;
+        this._options = {
+            ...DEFAULT_EXPORTER_CONFIG,
+        };
+        this._options.aadTokenCredential = config.aadTokenCredential;
+
+        if (connectionString) {
+            let connectionStringPrser = new ConnectionStringParser();
+            const parsedConnectionString = connectionStringPrser.parse(connectionString);
+            this._options.instrumentationKey =
+                parsedConnectionString.instrumentationkey ?? this._options.instrumentationKey;
+            this._options.endpointUrl =
+                parsedConnectionString.ingestionendpoint?.trim() ?? this._options.endpointUrl;
+        }
+        // Instrumentation key is required
+        if (!this._options.instrumentationKey) {
+            const message =
+                "No instrumentation key or connection string was provided to the Azure Monitor Exporter";
+            Logger.getInstance().error(message);
+            throw new Error(message);
+        }
+
+        this._sender = new HttpSender(this._options);
+        this._persister = new FileSystemPersist({ instrumentationKey: this._options.instrumentationKey });
+        this._retryTimer = null;
+        Logger.getInstance().debug("Exporter was successfully setup");
+
+    }
+
+    public async export(envelopes: Envelope[], resultCallback: (result: ExportResult) => void): Promise<void> {
+        // prevent calls from generating spans
+        context.with(suppressTracing(context.active()), async () => {
+            resultCallback(await this._exportEnvelopes(envelopes));
+        });
+    }
+
+    protected async _exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {
+        Logger.getInstance().info(`Exporting ${envelopes.length} envelope(s)`);
+        try {
+            const { result, statusCode } = await this._sender.send(envelopes);
+            this._numConsecutiveRedirects = 0;
+            if (statusCode === 200) {
+                // Success -- @todo: start retry timer
+                if (!this._retryTimer) {
+                    this._retryTimer = setTimeout(() => {
+                        this._retryTimer = null;
+                        this._sendFirstPersistedFile();
+                    }, this._options.batchSendRetryIntervalMs);
+                    this._retryTimer.unref();
+                }
+                return { code: ExportResultCode.SUCCESS };
+            } else if (statusCode && isRetriable(statusCode)) {
+                // Failed -- persist failed data
+                if (result) {
+                    Logger.getInstance().info(result);
+                    const breezeResponse = JSON.parse(result) as IBreezeResponse;
+                    const filteredEnvelopes: Envelope[] = [];
+                    breezeResponse.errors.forEach((error: IBreezeError) => {
+                        if (error.statusCode && isRetriable(error.statusCode)) {
+                            filteredEnvelopes.push(envelopes[error.index]);
+                        }
+                    });
+                    if (filteredEnvelopes.length > 0) {
+                        // calls resultCallback(ExportResult) based on result of persister.push
+                        return await this._persist(filteredEnvelopes);
+                    }
+                    // Failed -- not retriable
+                    return {
+                        code: ExportResultCode.FAILED,
+                    };
+                } else {
+                    // calls resultCallback(ExportResult) based on result of persister.push
+                    return await this._persist(envelopes);
+                }
+            } else {
+                // Failed -- not retriable
+                return {
+                    code: ExportResultCode.FAILED,
+                };
+            }
+        } catch (error) {
+            const restError = error as RestError;
+            if (
+                restError.statusCode &&
+                (restError.statusCode === 307 || // Temporary redirect
+                    restError.statusCode === 308)
+            ) {
+                // Permanent redirect
+                this._numConsecutiveRedirects++;
+                // To prevent circular redirects
+                if (this._numConsecutiveRedirects < 10) {
+                    if (restError.response && restError.response.headers) {
+                        const location = restError.response.headers.get("location");
+                        if (location) {
+                            // Update sender URL
+                            this._sender.handlePermanentRedirect(location);
+                            // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically
+                            return this._exportEnvelopes(envelopes);
+                        }
+                    }
+                } else {
+                    return { code: ExportResultCode.FAILED, error: new Error("Circular redirect") };
+                }
+            } else if (restError.statusCode && isRetriable(restError.statusCode)) {
+                return await this._persist(envelopes);
+            }
+            if (this._isNetworkError(restError)) {
+                Logger.getInstance().error(
+                    "Retrying due to transient client side error. Error message:",
+                    restError.message
+                );
+                return await this._persist(envelopes);
+            }
+
+            Logger.getInstance().error(
+                "Envelopes could not be exported and are not retriable. Error message:",
+                restError.message
+            );
+            return { code: ExportResultCode.FAILED, error: restError };
+        }
     }
 
     /**
-     * Shutdown AzureMonitorTraceExporter.
+     * Shutdown
      */
-    async shutdown(): Promise<void> {
-        diag.info("Azure Monitor Logs Exporter shutting down");
+    public async shutdown(): Promise<void> {
+        Logger.getInstance().info("Exporter shutting down");
         return this._sender.shutdown();
     }
+
+    private async _persist(envelopes: Envelope[]): Promise<ExportResult> {
+        try {
+            const success = await this._persister.push(envelopes);
+            return success
+                ? { code: ExportResultCode.SUCCESS }
+                : {
+                    code: ExportResultCode.FAILED,
+                    error: new Error("Failed to persist envelope in disk."),
+                };
+        } catch (ex) {
+            return { code: ExportResultCode.FAILED, error: ex };
+        }
+    }
+
+    private async _sendFirstPersistedFile(): Promise<void> {
+        try {
+            const envelopes = (await this._persister.shift()) as Envelope[] | null;
+            if (envelopes) {
+                await this._sender.send(envelopes);
+            }
+        } catch (err) {
+            Logger.getInstance().warn(`Failed to fetch persisted file`, err);
+        }
+    }
+
+    private _isNetworkError(error: RestError): boolean {
+        if (error && error.code && error.code === "REQUEST_SEND_ERROR") {
+            return true;
+        }
+        return false;
+    }
 }
diff --git a/src/library/exporters/shared/baseExporter.ts b/src/library/exporters/shared/baseExporter.ts
deleted file mode 100644
index 121edfd..0000000
--- a/src/library/exporters/shared/baseExporter.ts
+++ /dev/null
@@ -1,190 +0,0 @@
-// Copyright (c) Microsoft Corporation.
-// Licensed under the MIT license.
-
-import { ExportResult, ExportResultCode } from "@opentelemetry/core";
-import { RestError } from "@azure/core-rest-pipeline";
-import { ConnectionStringParser } from "../../configuration";
-import { HttpSender } from "./httpSender";
-import { FileSystemPersist } from "./persist";
-import {
-    DEFAULT_EXPORTER_CONFIG,
-    IAzureExporterConfig,
-    IAzureExporterInternalConfig,
-} from "../../../declarations/config";
-import { IPersistentStorage, ISender } from "../../../declarations/types";
-import { isRetriable, IBreezeResponse, IBreezeError } from "./breezeUtils";
-import { TelemetryItem as Envelope } from "../../../declarations/generated";
-import { Logger } from "../../logging"
-
-export class BaseExporter {
-    protected readonly _sender: ISender;
-    protected readonly _options: IAzureExporterInternalConfig;
-    private readonly _persister: IPersistentStorage;
-    private _numConsecutiveRedirects: number;
-    private _retryTimer: NodeJS.Timer | null;
-
-    /**
-     * Initializes a new instance of the AzureMonitorTraceExporter class.
-     * @param AzureExporterConfig - Exporter configuration.
-     */
-    constructor(options: IAzureExporterConfig = {}) {
-        this._numConsecutiveRedirects = 0;
-        const connectionString = options.connectionString;
-        this._options = {
-            ...DEFAULT_EXPORTER_CONFIG,
-        };
-        this._options.apiVersion = options.apiVersion ?? this._options.apiVersion;
-        this._options.aadTokenCredential = options.aadTokenCredential;
-
-        if (connectionString) {
-            let connectionStringPrser = new ConnectionStringParser();
-            const parsedConnectionString = connectionStringPrser.parse(connectionString);
-            this._options.instrumentationKey =
-                parsedConnectionString.instrumentationkey ?? this._options.instrumentationKey;
-            this._options.endpointUrl =
-                parsedConnectionString.ingestionendpoint?.trim() ?? this._options.endpointUrl;
-        }
-        // Instrumentation key is required
-        if (!this._options.instrumentationKey) {
-            const message =
-                "No instrumentation key or connection string was provided to the Azure Monitor Exporter";
-            Logger.getInstance().error(message);
-            throw new Error(message);
-        }
-
-        this._sender = new HttpSender(this._options);
-        this._persister = new FileSystemPersist({ instrumentationKey: this._options.instrumentationKey });
-        this._retryTimer = null;
-        Logger.getInstance().debug("Exporter was successfully setup");
-    }
-
-    public async export(envelopes: Envelope[], resultCallback: (result: ExportResult) => void): Promise<void> {
-        resultCallback(await this._exportEnvelopes(envelopes));
-    }
-
-    protected async _exportEnvelopes(envelopes: Envelope[]): Promise<ExportResult> {
-        Logger.getInstance().info(`Exporting ${envelopes.length} envelope(s)`);
-        try {
-            const { result, statusCode } = await this._sender.send(envelopes);
-            this._numConsecutiveRedirects = 0;
-            if (statusCode === 200) {
-                // Success -- @todo: start retry timer
-                if (!this._retryTimer) {
-                    this._retryTimer = setTimeout(() => {
-                        this._retryTimer = null;
-                        this._sendFirstPersistedFile();
-                    }, this._options.batchSendRetryIntervalMs);
-                    this._retryTimer.unref();
-                }
-                return { code: ExportResultCode.SUCCESS };
-            } else if (statusCode && isRetriable(statusCode)) {
-                // Failed -- persist failed data
-                if (result) {
-                    Logger.getInstance().info(result);
-                    const breezeResponse = JSON.parse(result) as IBreezeResponse;
-                    const filteredEnvelopes: Envelope[] = [];
-                    breezeResponse.errors.forEach((error: IBreezeError) => {
-                        if (error.statusCode && isRetriable(error.statusCode)) {
-                            filteredEnvelopes.push(envelopes[error.index]);
-                        }
-                    });
-                    if (filteredEnvelopes.length > 0) {
-                        // calls resultCallback(ExportResult) based on result of persister.push
-                        return await this._persist(filteredEnvelopes);
-                    }
-                    // Failed -- not retriable
-                    return {
-                        code: ExportResultCode.FAILED,
-                    };
-                } else {
-                    // calls resultCallback(ExportResult) based on result of persister.push
-                    return await this._persist(envelopes);
-                }
-            } else {
-                // Failed -- not retriable
-                return {
-                    code: ExportResultCode.FAILED,
-                };
-            }
-        } catch (error) {
-            const restError = error as RestError;
-            if (
-                restError.statusCode &&
-                (restError.statusCode === 307 || // Temporary redirect
-                    restError.statusCode === 308)
-            ) {
-                // Permanent redirect
-                this._numConsecutiveRedirects++;
-                // To prevent circular redirects
-                if (this._numConsecutiveRedirects < 10) {
-                    if (restError.response && restError.response.headers) {
-                        const location = restError.response.headers.get("location");
-                        if (location) {
-                            // Update sender URL
-                            this._sender.handlePermanentRedirect(location);
-                            // Send to redirect endpoint as HTTPs library doesn't handle redirect automatically
-                            return this._exportEnvelopes(envelopes);
-                        }
-                    }
-                } else {
-                    return { code: ExportResultCode.FAILED, error: new Error("Circular redirect") };
-                }
-            } else if (restError.statusCode && isRetriable(restError.statusCode)) {
-                return await this._persist(envelopes);
-            }
-            if (this._isNetworkError(restError)) {
-                Logger.getInstance().error(
-                    "Retrying due to transient client side error. Error message:",
-                    restError.message
-                );
-                return await this._persist(envelopes);
-            }
-
-            Logger.getInstance().error(
-                "Envelopes could not be exported and are not retriable. Error message:",
-                restError.message
-            );
-            return { code: ExportResultCode.FAILED, error: restError };
-        }
-    }
-
-    /**
-     * Shutdown
-     */
-    public async shutdown(): Promise<void> {
-        Logger.getInstance().info("Exporter shutting down");
-        return this._sender.shutdown();
-    }
-
-    private async _persist(envelopes: Envelope[]): Promise<ExportResult> {
-        try {
-            const success = await this._persister.push(envelopes);
-            return success
-                ? { code: ExportResultCode.SUCCESS }
-                : {
-                    code: ExportResultCode.FAILED,
-                    error: new Error("Failed to persist envelope in disk."),
-                };
-        } catch (ex) {
-            return { code: ExportResultCode.FAILED, error: ex };
-        }
-    }
-
-    private async _sendFirstPersistedFile(): Promise<void> {
-        try {
-            const envelopes = (await this._persister.shift()) as Envelope[] | null;
-            if (envelopes) {
-                await this._sender.send(envelopes);
-            }
-        } catch (err) {
-            Logger.getInstance().warn(`Failed to fetch persisted file`, err);
-        }
-    }
-
-    private _isNetworkError(error: RestError): boolean {
-        if (error && error.code && error.code === "REQUEST_SEND_ERROR") {
-            return true;
-        }
-        return false;
-    }
-}
diff --git a/src/library/exporters/shared/index.ts b/src/library/exporters/shared/index.ts
index af6cdfc..a90c88c 100644
--- a/src/library/exporters/shared/index.ts
+++ b/src/library/exporters/shared/index.ts
@@ -1,5 +1,4 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
-export { BaseExporter } from "./baseExporter";
 export { HttpSender } from "./httpSender";
 export { parseStack } from "./exceptionUtils";
diff --git a/src/library/handlers/logHandler.ts b/src/library/handlers/logHandler.ts
index e3e289a..ef1a116 100644
--- a/src/library/handlers/logHandler.ts
+++ b/src/library/handlers/logHandler.ts
@@ -55,7 +55,7 @@ export class LogHandler {
     constructor(config: Config, metricHandler?: MetricHandler) {
         this.config = config;
         this._exporter = new LogExporter(config);
-        this._batchProcessor = new BatchProcessor(config, this._exporter);
+        this._batchProcessor = new BatchProcessor(this._exporter);
         this._initializeFlagsFromConfig();
         this._console = new AutoCollectConsole(this);
         this._exceptions = new AutoCollectExceptions(this);
diff --git a/src/library/handlers/metricHandler.ts b/src/library/handlers/metricHandler.ts
index 6887da9..e221113 100644
--- a/src/library/handlers/metricHandler.ts
+++ b/src/library/handlers/metricHandler.ts
@@ -9,7 +9,7 @@ import {
     LiveMetricsHandler,
 } from "../../autoCollection";
 import { HeartBeatHandler } from "../../autoCollection/metrics/handlers/heartBeatHandler";
-import { HttpMetricsInstrumentation } from "../../autoCollection/metrics/collection/httpMetricsInstrumentation";
+import { AzureHttpMetricsInstrumentation } from "../../autoCollection/metrics/collection/azureHttpMetricsInstrumentation";
 import { IMetricExceptionDimensions, IMetricTraceDimensions } from "../../autoCollection/metrics/types";
 
 
@@ -66,10 +66,12 @@ export class MetricHandler {
         return this._standardMetricsHandler;
     }
 
-    public getHttpMetricInstrumentations(): HttpMetricsInstrumentation[] {
-        return [this._liveMetricsHandler?.getHttpMetricsInstrumentation(),
-        this._perfCounterMetricsHandler?.getHttpMetricsInstrumentation(),
-        this._standardMetricsHandler?.getHttpMetricsInstrumentation()];
+    public getPerCounterAzureHttpInstrumentation(): AzureHttpMetricsInstrumentation {
+        return this._perfCounterMetricsHandler?.getHttpMetricsInstrumentation();
+    }
+
+    public getLiveMetricsAzureHttpInstrumentation(): AzureHttpMetricsInstrumentation {
+        return this._liveMetricsHandler?.getHttpMetricsInstrumentation();
     }
 
     public countException(dimensions: IMetricExceptionDimensions): void {
diff --git a/src/library/handlers/sampler.ts b/src/library/handlers/sampler.ts
index 13e5416..33be6f1 100644
--- a/src/library/handlers/sampler.ts
+++ b/src/library/handlers/sampler.ts
@@ -1,6 +1,7 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
-import { Sampler, SamplingDecision, SamplingResult } from '@opentelemetry/api';
+import { Link, Attributes, SpanKind, Context } from '@opentelemetry/api';
+import { Sampler, SamplingDecision, SamplingResult } from '@opentelemetry/sdk-trace-base';
 
 
 export class ApplicationInsightsSampler implements Sampler {
@@ -11,9 +12,8 @@ export class ApplicationInsightsSampler implements Sampler {
         this._samplingPercentage = samplingPercentage;
     }
 
-    public shouldSample(context: unknown, traceId: string): SamplingResult {
+    public shouldSample(context: Context, traceId: string, spanName: string, spanKind: SpanKind, attributes: Attributes, links: Link[]): SamplingResult {
         let isSampledIn = false;
-
         if (this._samplingPercentage == 100) {
             isSampledIn = true;
         }
@@ -28,16 +28,17 @@ export class ApplicationInsightsSampler implements Sampler {
                 isSampledIn = this._getSamplingHashCode(traceId) < this._samplingPercentage;
 
             }
-
         }
-        return isSampledIn ? { decision: SamplingDecision.RECORD_AND_SAMPLED } : { decision: SamplingDecision.NOT_RECORD };
+        // Add sample rate as span attribute
+        attributes = attributes || {};
+        attributes["sampleRate"] = this._samplingPercentage;
+        return isSampledIn ? { decision: SamplingDecision.RECORD_AND_SAMPLED, attributes: attributes } : { decision: SamplingDecision.NOT_RECORD, attributes: attributes };
     }
 
     public toString(): string {
         return 'ApplicationInsightsSampler';
     }
 
-    /** Ported from AI .NET SDK */
     private _getSamplingHashCode(input: string): number {
         var csharpMin = -2147483648;
         var csharpMax = 2147483647;
diff --git a/src/library/handlers/shared/batchProcessor.ts b/src/library/handlers/shared/batchProcessor.ts
index f4c137c..1ea3337 100644
--- a/src/library/handlers/shared/batchProcessor.ts
+++ b/src/library/handlers/shared/batchProcessor.ts
@@ -3,7 +3,7 @@
 import { TelemetryItem as Envelope } from "../../../declarations/generated";
 import { Config } from "../../configuration";
 import { Logger } from "../../logging";
-import { BaseExporter } from "../../exporters/shared";
+import { LogExporter } from "../../exporters";
 import { ExportResult, ExportResultCode } from "@opentelemetry/core";
 
 export class BatchProcessor {
@@ -12,10 +12,10 @@ export class BatchProcessor {
     protected _getBatchSize: () => number;
     protected _getBatchIntervalMs: () => number;
 
-    public _exporter: BaseExporter;
+    public _exporter: LogExporter;
     public _buffer: Envelope[];
 
-    constructor(config: Config, exporter: BaseExporter) {
+    constructor(exporter: LogExporter) {
         this._buffer = [];
         this._lastSend = 0;
         this._exporter = exporter;
diff --git a/src/library/handlers/traceHandler.ts b/src/library/handlers/traceHandler.ts
index 536b0d1..354f9fa 100644
--- a/src/library/handlers/traceHandler.ts
+++ b/src/library/handlers/traceHandler.ts
@@ -1,59 +1,51 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
-import { RequestOptions } from "http";
 import { AzureExporterConfig, AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter";
-import {
-    Instrumentation,
-    InstrumentationOption,
-    registerInstrumentations,
-} from "@opentelemetry/instrumentation";
-import { AzureSdkInstrumentationOptions, createAzureSdkInstrumentation } from "@azure/opentelemetry-instrumentation-azure-sdk";
-import { MongoDBInstrumentation, MongoDBInstrumentationConfig } from "@opentelemetry/instrumentation-mongodb";
-import { MySQLInstrumentation, MySQLInstrumentationConfig } from "@opentelemetry/instrumentation-mysql";
-import { PgInstrumentation, PgInstrumentationConfig } from "@opentelemetry/instrumentation-pg";
-import { RedisInstrumentation, RedisInstrumentationConfig } from "@opentelemetry/instrumentation-redis";
-import { RedisInstrumentation as Redis4Instrumentation, RedisInstrumentationConfig as Redis4InstrumentationConfig } from "@opentelemetry/instrumentation-redis-4";
+import { Instrumentation } from "@opentelemetry/instrumentation";
+import { createAzureSdkInstrumentation } from "@azure/opentelemetry-instrumentation-azure-sdk";
+import { MongoDBInstrumentation } from "@opentelemetry/instrumentation-mongodb";
+import { MySQLInstrumentation } from "@opentelemetry/instrumentation-mysql";
+import { PgInstrumentation } from "@opentelemetry/instrumentation-pg";
+import { RedisInstrumentation } from "@opentelemetry/instrumentation-redis";
+import { RedisInstrumentation as Redis4Instrumentation } from "@opentelemetry/instrumentation-redis-4";
 import { NodeTracerProvider, NodeTracerConfig } from "@opentelemetry/sdk-trace-node";
 import { BatchSpanProcessor, BufferConfig, Tracer } from "@opentelemetry/sdk-trace-base";
 import {
     HttpInstrumentation,
-    HttpInstrumentationConfig,
 } from "@opentelemetry/instrumentation-http";
 
 import { Config } from "../configuration";
 import { ResourceManager } from "./resourceManager";
 import { ApplicationInsightsSampler } from "./sampler";
-import { InstrumentationType } from "../configuration/interfaces";
 import { TracerProvider } from "@opentelemetry/api";
 import { MetricHandler } from "./metricHandler";
 import { AzureSpanProcessor } from "./azureSpanProcessor";
+import { AzureHttpMetricsInstrumentation } from "../../autoCollection/metrics/collection/azureHttpMetricsInstrumentation";
 
 
 export class TraceHandler {
-    public httpInstrumentationConfig: HttpInstrumentationConfig;
-    public azureSdkInstrumentationConfig: AzureSdkInstrumentationOptions;
-    public mongoDbInstrumentationConfig: MongoDBInstrumentationConfig;
-    public mySqlInstrumentationConfig: MySQLInstrumentationConfig;
-    public postgressInstrumentationConfig: PgInstrumentationConfig;
-    public redisInstrumentationConfig: RedisInstrumentationConfig;
-    public redis4InstrumentationConfig: Redis4InstrumentationConfig;
-
     private _exporter: AzureMonitorTraceExporter;
     private _spanProcessor: BatchSpanProcessor;
     private _config: Config;
     private _metricHandler: MetricHandler;
-    private _instrumentations: InstrumentationOption[];
-    private _disableInstrumentations: () => void;
+    private _instrumentations: Instrumentation[];
     private _tracerProvider: NodeTracerProvider;
     private _tracer: Tracer;
+    private _liveMetricsHttpInstrumentation: AzureHttpMetricsInstrumentation;
+    private _perfCountersHttpInstrumentation: AzureHttpMetricsInstrumentation;
+    private _httpInstrumentation: Instrumentation;
+    private _azureSdkInstrumentation: Instrumentation;
+    private _mongoDbInstrumentation: Instrumentation;
+    private _mySqlInstrumentation: Instrumentation;
+    private _postgressInstrumentation: Instrumentation;
+    private _redisInstrumentation: Instrumentation;
+    private _redis4Instrumentation: Instrumentation;
 
     constructor(config: Config, metricHandler?: MetricHandler) {
         this._config = config;
         this._metricHandler = metricHandler;
         this._instrumentations = [];
-
         const aiSampler = new ApplicationInsightsSampler(this._config.samplingPercentage);
-
         let tracerConfig: NodeTracerConfig = {
             sampler: aiSampler,
             resource: ResourceManager.getInstance().getTraceResource(),
@@ -65,7 +57,6 @@ export class TraceHandler {
             aadTokenCredential: config.aadTokenCredential
         };
         this._exporter = new AzureMonitorTraceExporter(exporterConfig);
-
         let bufferConfig: BufferConfig = {
             maxExportBatchSize: 512,
             scheduledDelayMillis: 5000,
@@ -84,17 +75,6 @@ export class TraceHandler {
         this._tracerProvider.register();
         // TODO: Check for conflicts with multiple handlers available
         this._tracer = this._tracerProvider.getTracer("ApplicationInsightsTracer");
-
-        // Default configs
-        this.httpInstrumentationConfig = {
-            ignoreOutgoingRequestHook: this._ignoreOutgoingRequestHook.bind(this),
-            ignoreIncomingRequestHook: this._ignoreIncomingRequestHook.bind(this),
-        };
-        this.mongoDbInstrumentationConfig = {};
-        this.mySqlInstrumentationConfig = {};
-        this.azureSdkInstrumentationConfig = {};
-        this.redisInstrumentationConfig = {};
-        this.redis4InstrumentationConfig = {};
     }
 
     public getTracerProvider(): TracerProvider {
@@ -105,60 +85,64 @@ export class TraceHandler {
         return this._tracer;
     }
 
-
     public start() {
-        // TODO: Remove once HTTP Instrumentation generate Http metrics
-        if ((this._config.enableAutoCollectPreAggregatedMetrics || this._config.enableAutoCollectPerformance) && this._metricHandler) {
-            const instrumentations = this._metricHandler.getHttpMetricInstrumentations();
-            instrumentations.forEach(instrumentation => {
-                if (instrumentation) {
-                    this.addInstrumentation(instrumentation);
+        if (this._metricHandler) {
+            if (!this._liveMetricsHttpInstrumentation) {
+                this._liveMetricsHttpInstrumentation = this._metricHandler.getLiveMetricsAzureHttpInstrumentation();
+                if (this._liveMetricsHttpInstrumentation) { // Null when configured off
+                    this.addInstrumentation(this._liveMetricsHttpInstrumentation);
                 }
-            });
-        }
-        if (this._config.enableAutoCollectRequests || this._config.enableAutoCollectDependencies) {
-            this.addInstrumentation(new HttpInstrumentation(this.httpInstrumentationConfig));
-        }
-        if (this._config.instrumentations) {
-            if (this._config.instrumentations[InstrumentationType.azureSdk] && this._config.instrumentations[InstrumentationType.azureSdk].enabled) {
-                this.addInstrumentation((createAzureSdkInstrumentation(this.azureSdkInstrumentationConfig)) as any);
-            }
-            if (this._config.instrumentations[InstrumentationType.mongoDb] && this._config.instrumentations[InstrumentationType.mongoDb].enabled) {
-                this.addInstrumentation(new MongoDBInstrumentation(this.mongoDbInstrumentationConfig));
-            }
-            if (this._config.instrumentations[InstrumentationType.mySql] && this._config.instrumentations[InstrumentationType.mySql].enabled) {
-                this.addInstrumentation(new MySQLInstrumentation(this.mySqlInstrumentationConfig));
             }
-            if (this._config.instrumentations[InstrumentationType.postgreSql] && this._config.instrumentations[InstrumentationType.postgreSql].enabled) {
-                this.addInstrumentation(new PgInstrumentation(this.postgressInstrumentationConfig));
-            }
-            if (this._config.instrumentations[InstrumentationType.redis] && this._config.instrumentations[InstrumentationType.redis].enabled) {
-                this.addInstrumentation(new RedisInstrumentation(this.redisInstrumentationConfig));
-            }
-            if (this._config.instrumentations[InstrumentationType.redis4] && this._config.instrumentations[InstrumentationType.redis4].enabled) {
-                this.addInstrumentation(new Redis4Instrumentation(this.redis4InstrumentationConfig));
+            if (!this._perfCountersHttpInstrumentation) {
+                this._perfCountersHttpInstrumentation = this._metricHandler.getPerCounterAzureHttpInstrumentation();
+                if (this._perfCountersHttpInstrumentation) { // Null when configured off
+                    this.addInstrumentation(this._perfCountersHttpInstrumentation);
+                }
             }
         }
-        if (this._instrumentations.length > 0) {
-            this.registerInstrumentations();
+        if (!this._httpInstrumentation) {
+            this._httpInstrumentation = new HttpInstrumentation(this._config.instrumentations.http);
+            this._httpInstrumentation.setMeterProvider(this._metricHandler.getStandardMetricsHandler().getMeterProvider());
+            this.addInstrumentation(this._httpInstrumentation);
+        }
+        if (!this._azureSdkInstrumentation) {
+            this._azureSdkInstrumentation = createAzureSdkInstrumentation(this._config.instrumentations.azureSdk) as any;
+            this.addInstrumentation(this._azureSdkInstrumentation);
         }
+        if (!this._mongoDbInstrumentation) {
+            this._mongoDbInstrumentation = new MongoDBInstrumentation(this._config.instrumentations.mongoDb);
+            this.addInstrumentation(this._mongoDbInstrumentation);
+        }
+        if (!this._mySqlInstrumentation) {
+            this._mySqlInstrumentation = new MySQLInstrumentation(this._config.instrumentations.mySql);
+            this.addInstrumentation(this._mySqlInstrumentation);
+        }
+        if (!this._postgressInstrumentation) {
+            this._postgressInstrumentation = new PgInstrumentation(this._config.instrumentations.postgreSql);
+            this.addInstrumentation(this._postgressInstrumentation);
+        }
+        if (!this._redisInstrumentation) {
+            this._redisInstrumentation = new RedisInstrumentation(this._config.instrumentations.redis);
+            this.addInstrumentation(this._redisInstrumentation);
+        }
+        if (!this._redis4Instrumentation) {
+            this._redis4Instrumentation = new Redis4Instrumentation(this._config.instrumentations.redis4);
+            this.addInstrumentation(this._redis4Instrumentation);
+        }
+        this._instrumentations.forEach(instrumentation => {
+            instrumentation.setTracerProvider(this._tracerProvider);
+            instrumentation.enable();
+        });
     }
 
     public addInstrumentation(instrumentation: Instrumentation) {
         this._instrumentations.push(instrumentation);
     }
 
-    public registerInstrumentations() {
-        this._disableInstrumentations = registerInstrumentations({
-            tracerProvider: this._tracerProvider,
-            instrumentations: this._instrumentations,
-        });
-    }
-
     public disableInstrumentations() {
-        if (this._disableInstrumentations) {
-            this._disableInstrumentations();
-        }
+        this._instrumentations.forEach(instrumentation => {
+            instrumentation.disable();
+        });
     }
 
     public async flush(): Promise<void> {
@@ -168,20 +152,4 @@ export class TraceHandler {
     public async shutdown(): Promise<void> {
         await this._tracerProvider.shutdown();
     }
-
-    private _ignoreOutgoingRequestHook(request: RequestOptions): boolean {
-        if (this._config.enableAutoCollectDependencies) {
-            // Check for request made to ingestion endpoint, suppressTracing only avaialble for traces
-            // TODO: Remove check when suppress is available for logs/metrics
-            if (request.headers && request.headers["user-agent"]) {
-                return request.headers["user-agent"].toString().indexOf("azsdk-js-monitor-opentelemetry-exporter") > -1;
-            }
-            return false;
-        }
-        return true;
-    }
-
-    private _ignoreIncomingRequestHook(request: RequestOptions): boolean {
-        return !this._config.enableAutoCollectRequests;
-    }
 }
diff --git a/src/library/util/util.ts b/src/library/util/util.ts
index e4b60f7..ff0dcbf 100644
--- a/src/library/util/util.ts
+++ b/src/library/util/util.ts
@@ -3,14 +3,13 @@ import * as https from "https";
 import * as url from "url";
 import * as constants from "constants";
 
-import { isValidTraceId } from "@opentelemetry/api";
-import { IdGenerator, RandomIdGenerator } from "@opentelemetry/core";
+import { context, isValidTraceId } from "@opentelemetry/api";
+import { suppressTracing } from "@opentelemetry/core";
+import { IdGenerator, RandomIdGenerator } from "@opentelemetry/sdk-trace-base";
 
 import { Logger } from "../logging";
 import { Config } from "../configuration";
-import { Client } from "../client";
-import { RequestHeaders } from "../../declarations/requestResponseHeaders";
-import { HttpRequest } from "../../declarations/functions";
+
 
 export class Util {
     private static _instance: Util;
@@ -276,11 +275,16 @@ export class Util {
                 options.agent = this.tlsRestrictedAgent;
             }
         }
-        if (isHttps) {
-            return https.request(<any>options, requestCallback);
-        } else {
-            return http.request(<any>options, requestCallback);
-        }
+        // prevent calls from generating spans
+        let request: http.ClientRequest = null;
+        context.with(suppressTracing(context.active()), () => {
+            if (isHttps) {
+                request = https.request(<any>options, requestCallback);
+            } else {
+                request = http.request(<any>options, requestCallback);
+            }
+        });
+        return request;
     }
 
     /**
diff --git a/src/shim/applicationinsights.ts b/src/shim/applicationinsights.ts
index 8cc0a57..292d483 100644
--- a/src/shim/applicationinsights.ts
+++ b/src/shim/applicationinsights.ts
@@ -2,7 +2,6 @@ import { IncomingMessage } from "http";
 import { DiagLogLevel, SpanContext } from "@opentelemetry/api";
 
 import { Logger } from "../library/logging";
-import { InstrumentationType } from "../library/configuration/interfaces";
 import { QuickPulseStateManager } from "../library/quickPulse";
 import { ICorrelationContext } from "../declarations/interfaces";
 import { TelemetryClient } from "./telemetryClient";
@@ -12,7 +11,7 @@ import * as azureFunctionsTypes from "../declarations/functions";
 
 // We export these imports so that SDK users may use these classes directly.
 // They're exposed using "export import" so that types are passed along as expected
-export { Contracts, TelemetryClient, azureFunctionsTypes, InstrumentationType };
+export { Contracts, TelemetryClient, azureFunctionsTypes };
 
 /**
  * The default client, initialized when setup was called. To initialize a different client


Test patch:
diff --git a/test/functionalTests/testApp/main.js b/test/functionalTests/testApp/main.js
index 66847ef..30d8fad 100644
--- a/test/functionalTests/testApp/main.js
+++ b/test/functionalTests/testApp/main.js
@@ -6,14 +6,13 @@ if (testconfig.AppInsightsEnabled) {
 
     let config = new Config(`InstrumentationKey=${testconfig.InstrumentationKey};IngestionEndpoint=${testconfig.EndpointBaseAddress}`);
     config.samplingPercentage = parseFloat(testconfig.SampleRate);
+    config.instrumentations["http"].enabled = true;
     config.instrumentations["azureSdk"].enabled = true;
     config.instrumentations["mongoDb"].enabled = true;
     config.instrumentations["mySql"].enabled = true;
     config.instrumentations["postgreSql"].enabled = true;
     config.instrumentations["redis"].enabled = true;
     config.instrumentations["redis4"].enabled = true;
-    config.enableAutoCollectDependencies = true;
-    config.enableAutoCollectRequests = true;
     config.enableAutoCollectExceptions = true;
     config.enableAutoCollectConsole = true;
     config.enableAutoCollectExternalLoggers = true;
diff --git a/test/unitTests/autoCollection/httpMetricsInstrumentation.tests.ts b/test/unitTests/autoCollection/azureHttpMetricsInstrumentation.tests.ts
similarity index 95%
rename from test/unitTests/autoCollection/httpMetricsInstrumentation.tests.ts
rename to test/unitTests/autoCollection/azureHttpMetricsInstrumentation.tests.ts
index e901901..1182b20 100644
--- a/test/unitTests/autoCollection/httpMetricsInstrumentation.tests.ts
+++ b/test/unitTests/autoCollection/azureHttpMetricsInstrumentation.tests.ts
@@ -4,7 +4,7 @@ import * as nock from "nock";
 import { AzureMonitorMetricExporter } from "@azure/monitor-opentelemetry-exporter";
 import { DataPointType, MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
 
-import { HttpMetricsInstrumentation } from "../../../src/autoCollection/metrics/collection/httpMetricsInstrumentation";
+import { AzureHttpMetricsInstrumentation } from "../../../src/autoCollection/metrics/collection/azureHttpMetricsInstrumentation";
 import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
 
 
@@ -23,7 +23,7 @@ const httpMetricsConfig: HttpMetricsInstrumentationConfig = {
         return false;
     }
 };
-const instrumentation = new HttpMetricsInstrumentation(httpMetricsConfig);
+const instrumentation = new AzureHttpMetricsInstrumentation(httpMetricsConfig);
 instrumentation.enable();
 instrumentation.disable();
 
@@ -36,7 +36,7 @@ const metricReader = new PeriodicExportingMetricReader({ exporter: exporter as a
 meterProvider.addMetricReader(metricReader);
 instrumentation.setMeterProvider(meterProvider);
 
-describe("AutoCollection/HttpMetricsInstrumentation", () => {
+describe("AutoCollection/AzureHttpMetricsInstrumentation", () => {
     let sandbox: sinon.SinonSandbox;
     let mockHttpServer: any;
     let mockHttpServerPort = 0;
diff --git a/test/unitTests/autoCollection/performance.tests.ts b/test/unitTests/autoCollection/performance.tests.ts
index c34b41f..fcc7d4d 100644
--- a/test/unitTests/autoCollection/performance.tests.ts
+++ b/test/unitTests/autoCollection/performance.tests.ts
@@ -17,6 +17,7 @@ describe("PerformanceCounterMetricsHandler", () => {
         config.extendedMetrics.loop = true;
         config.extendedMetrics.gc = true;
         autoCollect = new PerformanceCounterMetricsHandler(config, { collectionInterval: 100 });
+        autoCollect["_nativeMetrics"]["_metricsAvailable"] = false;
         sandbox.stub(autoCollect["_metricReader"]["_exporter"], "export");
     })
 
@@ -93,6 +94,7 @@ describe("PerformanceCounterMetricsHandler", () => {
             config.extendedMetrics.loop = false;
             config.extendedMetrics.gc = false;
             let autoCollect = new PerformanceCounterMetricsHandler(config);
+            autoCollect["_nativeMetrics"]["_metricsAvailable"] = false;
             let views = autoCollect["_getViews"]();
             assert.equal(views.length, 18); // All Native metrics ignore views are added
             config.extendedMetrics.heap = true;
diff --git a/test/unitTests/autoCollection/standardMetrics.tests.ts b/test/unitTests/autoCollection/standardMetrics.tests.ts
index 2a15516..3d001a8 100644
--- a/test/unitTests/autoCollection/standardMetrics.tests.ts
+++ b/test/unitTests/autoCollection/standardMetrics.tests.ts
@@ -1,5 +1,4 @@
-import { SpanKind } from "@opentelemetry/api";
-import { InstrumentType } from "@opentelemetry/sdk-metrics";
+import { HttpInstrumentation, HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
 import * as assert from "assert";
 import * as sinon from "sinon";
 
@@ -30,8 +29,6 @@ describe("#StandardMetricsHandler", () => {
     it("should create instruments", () => {
         assert.ok(autoCollect.getExceptionMetrics()["_exceptionsGauge"], "_exceptionsGauge not available");
         assert.ok(autoCollect.getTraceMetrics()["_tracesGauge"], "_tracesGauge not available");
-        assert.ok(autoCollect.getHttpMetricsInstrumentation()["_httpServerDurationHistogram"], "_httpServerDurationHistogram not available");
-        assert.ok(autoCollect.getHttpMetricsInstrumentation()["_httpClientDurationHistogram"], "_httpClientDurationHistogram not available");
     });
 
     it("should observe instruments during collection", async () => {
@@ -43,33 +40,15 @@ describe("#StandardMetricsHandler", () => {
         };
         autoCollect.getExceptionMetrics().countException(dimensions);
         autoCollect.getTraceMetrics().countTrace(dimensions);
-        autoCollect.getHttpMetricsInstrumentation().setMeterProvider(autoCollect["_meterProvider"]);
-        autoCollect.getHttpMetricsInstrumentation()["_httpRequestDone"]({
-            startTime: Date.now() - 100,
-            isProcessed: false,
-            spanKind: SpanKind.CLIENT,
-            attributes: { "HTTP_STATUS_CODE": "200" }
-        });
-        autoCollect.getHttpMetricsInstrumentation()["_httpRequestDone"]({
-            startTime: Date.now() - 100,
-            isProcessed: false,
-            spanKind: SpanKind.SERVER,
-            attributes: { "HTTP_STATUS_CODE": "200" }
-        });
-
         await new Promise(resolve => setTimeout(resolve, 120));
         assert.ok(mockExport.called);
         let resourceMetrics = mockExport.args[0][0];
         const scopeMetrics = resourceMetrics.scopeMetrics;
-        assert.strictEqual(scopeMetrics.length, 2, 'scopeMetrics count');
+        assert.strictEqual(scopeMetrics.length, 1, 'scopeMetrics count');
         let metrics = scopeMetrics[0].metrics;
         assert.strictEqual(metrics.length, 2, 'metrics count');
         assert.equal(metrics[0].descriptor.name, StandardMetric.EXCEPTIONS);
         assert.equal(metrics[1].descriptor.name, StandardMetric.TRACES);
-        metrics = scopeMetrics[1].metrics;
-        assert.strictEqual(metrics.length, 2, 'metrics count');
-        assert.equal(metrics[0].descriptor.name, StandardMetric.REQUESTS);
-        assert.equal(metrics[1].descriptor.name, StandardMetric.DEPENDENCIES);
     });
 
     it("should not collect when disabled", async () => {
@@ -79,4 +58,99 @@ describe("#StandardMetricsHandler", () => {
         await new Promise(resolve => setTimeout(resolve, 120));
         assert.ok(mockExport.notCalled);
     });
+
+    describe("#HTTP incoming/outgoing requests duration", () => {
+        let http: any = null;
+        let mockHttpServer: any;
+        let mockHttpServerPort = 0;
+
+        before(() => {
+            let config = new Config("1aa11111-bbbb-1ccc-8ddd-eeeeffff3333");
+            autoCollect = new StandardMetricsHandler(config, { collectionInterval: 100 });
+
+            let httpConfig: HttpInstrumentationConfig = {
+                enabled: true,
+            };
+            let instrumentation = new HttpInstrumentation(httpConfig);
+            instrumentation.setMeterProvider(autoCollect.getMeterProvider());
+            instrumentation.enable();
+            // Load Http modules, HTTP instrumentation hook will be created in OpenTelemetry
+            http = require("http") as any;
+            createMockServers();
+        });
+
+        after(() => {
+            mockHttpServer.close();
+        });
+
+        function createMockServers() {
+            mockHttpServer = http.createServer((req: any, res: any) => {
+                res.statusCode = 200;
+                res.setHeader('content-type', 'application/json');
+                res.write(
+                    JSON.stringify({
+                        success: true,
+                    })
+                );
+                res.end();
+            });
+            mockHttpServer.listen(0, () => {
+                const addr = mockHttpServer.address();
+                if (addr == null) {
+                    new Error('unexpected addr null');
+                    return;
+                }
+                if (typeof addr === 'string') {
+                    new Error(`unexpected addr ${addr}`);
+                    return;
+                }
+                if (addr.port <= 0) {
+                    new Error('Could not get port');
+                    return;
+                }
+                mockHttpServerPort = addr.port;
+            });
+        }
+
+        async function makeHttpRequest(): Promise<void> {
+            const options = {
+                hostname: 'localhost',
+                port: mockHttpServerPort,
+                path: '/test',
+                method: 'GET',
+            };
+            return new Promise((resolve, reject) => {
+                const req = http.request(options, (res: any) => {
+                    res.on('data', function () {
+                    });
+                    res.on('end', () => {
+                        resolve();
+                    });
+                });
+                req.on('error', (error: Error) => {
+                    reject(error);
+                });
+                req.end();
+            });
+        }
+
+        it("http outgoing/incoming requests", async () => {
+            let mockExport = sandbox.stub(autoCollect["_azureExporter"], "export");
+            autoCollect.start();
+            await makeHttpRequest();
+            await new Promise(resolve => setTimeout(resolve, 120));
+            assert.ok(mockExport.called);
+            let resourceMetrics = mockExport.args[0][0];
+            const scopeMetrics = resourceMetrics.scopeMetrics;
+            assert.strictEqual(scopeMetrics.length, 2, 'scopeMetrics count');
+            let metrics = scopeMetrics[0].metrics;
+            assert.strictEqual(metrics.length, 2, 'metrics count');
+            assert.equal(metrics[0].descriptor.name, StandardMetric.EXCEPTIONS);
+            assert.equal(metrics[1].descriptor.name, StandardMetric.TRACES);
+            metrics = scopeMetrics[1].metrics;
+            assert.strictEqual(metrics.length, 2, 'metrics count');
+            assert.equal(metrics[0].descriptor.name, "http.server.duration");
+            assert.equal(metrics[1].descriptor.name, "http.client.duration");
+        });
+    });
 });
\ No newline at end of file
diff --git a/test/unitTests/library/config.json b/test/unitTests/library/config.json
index 9d691b9..d43eb8f 100644
--- a/test/unitTests/library/config.json
+++ b/test/unitTests/library/config.json
@@ -9,8 +9,6 @@
     "enableAutoCollectExtendedMetrics": false,
     "enableAutoCollectPreAggregatedMetrics": false,
     "enableAutoCollectHeartbeat": false,
-    "enableAutoCollectRequests": false,
-    "enableAutoCollectDependencies": false,
     "disableStatsbeat": false,
     "enableSendLiveMetrics": false,
     "extendedMetrics": {
diff --git a/test/unitTests/library/config.tests.ts b/test/unitTests/library/config.tests.ts
index b9e57f1..c114b9b 100644
--- a/test/unitTests/library/config.tests.ts
+++ b/test/unitTests/library/config.tests.ts
@@ -101,8 +101,6 @@ describe("Library/Config", () => {
                 assert.equal(config.enableAutoCollectPerformance, false, "Wrong enableAutoCollectPerformance");
                 assert.equal(config.enableAutoCollectPreAggregatedMetrics, false, "Wrong enableAutoCollectPreAggregatedMetrics");
                 assert.equal(config.enableAutoCollectHeartbeat, false, "Wrong enableAutoCollectHeartbeat");
-                assert.equal(config.enableAutoCollectRequests, false, "Wrong enableAutoCollectRequests");
-                assert.equal(config.enableAutoCollectDependencies, false, "Wrong enableAutoCollectDependencies");
                 assert.equal(config.disableStatsbeat, false, "Wrong disableStatsbeat");
                 assert.equal(config.enableSendLiveMetrics, false, "Wrong enableSendLiveMetrics");
                 assert.equal(config.extendedMetrics.loop, true, "Wrong loop");
@@ -127,8 +125,6 @@ describe("Library/Config", () => {
                 assert.equal(config.enableAutoCollectPerformance, true, "Wrong enableAutoCollectPerformance");
                 assert.equal(config.enableAutoCollectPreAggregatedMetrics, true, "Wrong enableAutoCollectPreAggregatedMetrics");
                 assert.equal(config.enableAutoCollectHeartbeat, true, "Wrong enableAutoCollectHeartbeat");
-                assert.equal(config.enableAutoCollectRequests, true, "Wrong enableAutoCollectRequests");
-                assert.equal(config.enableAutoCollectDependencies, true, "Wrong enableAutoCollectDependencies");
                 assert.equal(config.disableStatsbeat, false, "Wrong disableStatsbeat");
                 assert.equal(config.enableSendLiveMetrics, false, "Wrong enableSendLiveMetrics");
                 assert.equal(config.extendedMetrics.loop, false, "Wrong loop");
diff --git a/test/unitTests/library/jsonConfig.tests.ts b/test/unitTests/library/jsonConfig.tests.ts
index c1cce41..1cad374 100644
--- a/test/unitTests/library/jsonConfig.tests.ts
+++ b/test/unitTests/library/jsonConfig.tests.ts
@@ -83,8 +83,6 @@ describe("Json Config", () => {
             assert.equal(config.enableAutoCollectPerformance, false, "Wrong enableAutoCollectPerformance");
             assert.equal(config.enableAutoCollectPreAggregatedMetrics, false, "Wrong enableAutoCollectPreAggregatedMetrics");
             assert.equal(config.enableAutoCollectHeartbeat, false, "Wrong enableAutoCollectHeartbeat");
-            assert.equal(config.enableAutoCollectRequests, false, "Wrong enableAutoCollectRequests");
-            assert.equal(config.enableAutoCollectDependencies, false, "Wrong enableAutoCollectDependencies");
             assert.equal(config.disableStatsbeat, false, "Wrong disableStatsbeat");
             assert.equal(config.enableSendLiveMetrics, false, "Wrong enableSendLiveMetrics");
             assert.equal(config.extendedMetrics.loop, true, "Wrong loop");
diff --git a/test/unitTests/library/metricHandler.tests.ts b/test/unitTests/library/metricHandler.tests.ts
index 15dc08a..e4db501 100644
--- a/test/unitTests/library/metricHandler.tests.ts
+++ b/test/unitTests/library/metricHandler.tests.ts
@@ -24,6 +24,7 @@ describe("Library/MetricHandler", () => {
         it("performance enablement during start", () => {
             _config.enableAutoCollectPerformance = true;
             let handler = new MetricHandler(_config);
+            handler["_perfCounterMetricsHandler"]["_nativeMetrics"]["_metricsAvailable"] = false;
             let stub = sinon.stub(handler["_perfCounterMetricsHandler"], "start");
             handler.start();
             assert.ok(stub.calledOnce, "Enable called");
@@ -33,6 +34,7 @@ describe("Library/MetricHandler", () => {
         it("preAggregated metrics enablement during start", () => {
             _config.enableAutoCollectPreAggregatedMetrics = true;
             let handler = new MetricHandler(_config);
+            handler["_perfCounterMetricsHandler"]["_nativeMetrics"]["_metricsAvailable"] = false;
             let stub = sinon.stub(handler["_standardMetricsHandler"], "start");
             handler.start();
             assert.ok(stub.calledOnce, "start called");
@@ -41,6 +43,7 @@ describe("Library/MetricHandler", () => {
         it("heartbeat metrics enablement during start", () => {
             _config.enableAutoCollectHeartbeat = true;
             let handler = new MetricHandler(_config);
+            handler["_perfCounterMetricsHandler"]["_nativeMetrics"]["_metricsAvailable"] = false;
             let stub = sinon.stub(handler["_heartbeatHandler"], "start");
             handler.start();
             assert.ok(stub.calledOnce, "start called");
diff --git a/test/unitTests/library/sampler.tests.ts b/test/unitTests/library/sampler.tests.ts
index e14a2d0..6f48f53 100644
--- a/test/unitTests/library/sampler.tests.ts
+++ b/test/unitTests/library/sampler.tests.ts
@@ -9,7 +9,7 @@ describe("Library/ApplicationInsightsSampler", () => {
     describe("#shouldSample()", () => {
         it("will not send data on 0% sampling", () => {
             let sampler = new ApplicationInsightsSampler(0);
-            let result = sampler.shouldSample(null, null);
+            let result = sampler.shouldSample(null, null, null, null, null, null);
             assert.equal(result.decision, SamplingDecision.NOT_RECORD, "data should not pass");
         });
 
@@ -20,7 +20,7 @@ describe("Library/ApplicationInsightsSampler", () => {
             let sampler = new ApplicationInsightsSampler(33);
 
             for (var i = 0; i < iterations; i++) {
-                var result = sampler.shouldSample(null, null);
+                var result = sampler.shouldSample(null, null, null, null, null, null);
                 if (result.decision === SamplingDecision.RECORD_AND_SAMPLED) accepted++;
             }
 
@@ -34,7 +34,7 @@ describe("Library/ApplicationInsightsSampler", () => {
             let sampler = new ApplicationInsightsSampler(50);
 
             for (var i = 0; i < iterations; i++) {
-                var result = sampler.shouldSample(null, null);
+                var result = sampler.shouldSample(null, null, null, null, null, null);
                 if (result.decision === SamplingDecision.RECORD_AND_SAMPLED) accepted++;
             }
 
@@ -48,7 +48,7 @@ describe("Library/ApplicationInsightsSampler", () => {
             let sampler = new ApplicationInsightsSampler(100);
 
             for (var i = 0; i < iterations; i++) {
-                var result = sampler.shouldSample(null, null);
+                var result = sampler.shouldSample(null, null, null, null, null, null);
                 if (result.decision === SamplingDecision.RECORD_AND_SAMPLED) accepted++;
             }
 
@@ -61,7 +61,7 @@ describe("Library/ApplicationInsightsSampler", () => {
             let sampler = new ApplicationInsightsSampler(33);
 
             for (var i = 0; i < iterations; i++) {
-                var result = sampler.shouldSample(null, "a");
+                var result = sampler.shouldSample(null, "a", null, null, null, null);
                 if (result.decision === SamplingDecision.RECORD_AND_SAMPLED) accepted++;
             }
 
@@ -74,7 +74,7 @@ describe("Library/ApplicationInsightsSampler", () => {
             let sampler = new ApplicationInsightsSampler(33);
 
             for (var i = 0; i < iterations; i++) {
-                var result = sampler.shouldSample(null, "abc");
+                var result = sampler.shouldSample(null, "abc", null, null, null, null);
                 if (result.decision === SamplingDecision.RECORD_AND_SAMPLED) accepted++;
             }
 
diff --git a/test/unitTests/library/traceHandler.tests.ts b/test/unitTests/library/traceHandler.tests.ts
index ea93e02..65925aa 100644
--- a/test/unitTests/library/traceHandler.tests.ts
+++ b/test/unitTests/library/traceHandler.tests.ts
@@ -7,9 +7,10 @@ import { ExportResultCode } from "@opentelemetry/core";
 import { TraceHandler, MetricHandler } from "../../../src/library/handlers/";
 import { Config } from "../../../src/library/configuration";
 import { Instrumentation } from "@opentelemetry/instrumentation";
+import { HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
 
 
-describe("Library/TraceHandlers", () => {
+describe("Library/TraceHandler", () => {
     let http: any = null;
     let https: any = null;
     let sandbox: sinon.SinonSandbox;
@@ -24,7 +25,7 @@ describe("Library/TraceHandlers", () => {
     });
 
     describe("#Instrumentation Enablement", () => {
-        it("HttpMetricsInstrumentation", () => {
+        it("AzureHttpMetricsInstrumentation", () => {
             _config.enableAutoCollectPerformance = true;
             let metricHandler = new MetricHandler(_config);
             let handler = new TraceHandler(_config, metricHandler);
@@ -51,8 +52,10 @@ describe("Library/TraceHandlers", () => {
 
         before(() => {
             process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
-            _config.enableAutoCollectDependencies = true;
-            _config.enableAutoCollectRequests = true;
+            let httpConfig: HttpInstrumentationConfig = {
+                enabled: true,
+            };
+            _config.instrumentations.http = httpConfig;
             metricHandler = new MetricHandler(_config);
             handler = new TraceHandler(_config, metricHandler);
             exportStub = sinon.stub(handler["_exporter"], "export").callsFake((spans: any, resultCallback: any) => {
@@ -64,12 +67,17 @@ describe("Library/TraceHandlers", () => {
                 });
             });
             handler.start();
-            // Load Http modules
+            // Load Http modules, HTTP instrumentation hook will be created in OpenTelemetry
             http = require("http") as any;
             https = require("https") as any;
             createMockServers();
         });
 
+        beforeEach(() => {
+            handler.disableInstrumentations();
+        });
+
+
         afterEach(() => {
             exportStub.resetHistory();
         });
@@ -182,7 +190,7 @@ describe("Library/TraceHandlers", () => {
         }
 
         it("http outgoing/incoming requests", (done) => {
-
+            handler.start();
             makeHttpRequest(false).then(() => {
                 handler.flush().then(() => {
                     assert.ok(exportStub.calledOnce, "Export called");
@@ -231,7 +239,7 @@ describe("Library/TraceHandlers", () => {
         });
 
         it("https outgoing/incoming requests", (done) => {
-
+            handler.start();
             makeHttpRequest(true).then(() => {
                 handler.flush().then(() => {
                     assert.ok(exportStub.calledOnce, "Export called");
@@ -280,6 +288,7 @@ describe("Library/TraceHandlers", () => {
         });
 
         it("Span processing for pre aggregated metrics", (done) => {
+            handler.start();
             metricHandler.getConfig().enableAutoCollectPreAggregatedMetrics = true;
             makeHttpRequest(false).then(() => {
                 handler.flush().then(() => {
@@ -300,8 +309,14 @@ describe("Library/TraceHandlers", () => {
         });
 
         it("should not track dependencies if configured off", (done) => {
-            handler["_config"].enableAutoCollectDependencies = false;
-            handler["_config"].enableAutoCollectRequests = true;
+            let httpConfig: HttpInstrumentationConfig = {
+                enabled: true,
+                ignoreOutgoingRequestHook: () => {
+                    return true;
+                }
+            };
+            handler["_httpInstrumentation"].setConfig(httpConfig);
+            handler.start();
             makeHttpRequest(false).then(() => {
                 handler.flush().then(() => {
                     assert.ok(exportStub.calledOnce, "Export called");
@@ -314,12 +329,18 @@ describe("Library/TraceHandlers", () => {
                 });;
             }).catch((error) => {
                 done(error);
-            });;
+            });
         });
 
         it("should not track requests if configured off", (done) => {
-            handler["_config"].enableAutoCollectDependencies = true;
-            handler["_config"].enableAutoCollectRequests = false;
+            let httpConfig: HttpInstrumentationConfig = {
+                enabled: true,
+                ignoreIncomingRequestHook: () => {
+                    return true;
+                }
+            };
+            handler["_httpInstrumentation"].setConfig(httpConfig);
+            handler.start();
             makeHttpRequest(false).then(() => {
                 handler.flush().then(() => {
                     assert.ok(exportStub.calledOnce, "Export called");
@@ -336,8 +357,6 @@ describe("Library/TraceHandlers", () => {
         });
 
         it("http should not track if instrumentations are disabled", (done) => {
-            handler["_config"].enableAutoCollectDependencies = true;
-            handler["_config"].enableAutoCollectRequests = true;
             handler.disableInstrumentations();
             makeHttpRequest(false).then(() => {
                 makeHttpRequest(true).then(() => {