<PackageReference Include="Microsoft.ApplicationInsights" Version="3.2.0" />

Microsoft.ApplicationInsights.TelemetryClient

public sealed class TelemetryClient
Send events, metrics and other telemetry to the Application Insights service. Learn more
public TelemetryContext Context { get; }

Gets the current context that will be used to augment telemetry you send.

Gets the TelemetryConfiguration object associated with this telemetry client instance. Changes made to the configuration can affect other clients.

Initializes a new instance of the TelemetryClient class. Send telemetry with the specified configuration.

public void Flush()

Flushes the in-memory buffer and any metrics being pre-aggregated.

public Task<bool> FlushAsync(CancellationToken cancellationToken)

Asynchronously Flushes the in-memory buffer and any metrics being pre-aggregated.

public Metric GetMetric(string metricId)

Gets or creates a metric container that you can use to track, aggregate and send metric values. Optionally specify a metric configuration to control how the tracked values are aggregated.

public Metric GetMetric(string metricId, string dimension1Name)

Gets or creates a metric container that you can use to track, aggregate and send metric values. Optionally specify a metric configuration to control how the tracked values are aggregated.

public Metric GetMetric(string metricId, string dimension1Name, string dimension2Name)

Gets or creates a metric container that you can use to track, aggregate and send metric values. Optionally specify a metric configuration to control how the tracked values are aggregated.

public Metric GetMetric(string metricId, string dimension1Name, string dimension2Name, string dimension3Name)

Gets or creates a metric container that you can use to track, aggregate and send metric values. Optionally specify a metric configuration to control how the tracked values are aggregated.

public Metric GetMetric(string metricId, string dimension1Name, string dimension2Name, string dimension3Name, string dimension4Name)

Gets or creates a metric container that you can use to track, aggregate and send metric values. Optionally specify a metric configuration to control how the tracked values are aggregated.

public Metric GetMetric(MetricIdentifier metricIdentifier)

Gets or creates a metric container that you can use to track, aggregate and send metric values. Optionally specify a metric configuration to control how the tracked values are aggregated.

public bool IsEnabled()

Check to determine if the tracking is enabled.

public void Track(ITelemetry telemetry)

This method is an internal part of Application Insights infrastructure. Do not call.

public void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary<string, string> properties = null)

Send information about availability of an application.

Send information about availability of an application. Create a separate AvailabilityTelemetry instance for each call to TrackAvailability.

public void TrackDependency(string dependencyTypeName, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, bool success)

Send information about an external dependency (outgoing call) in the application.

public void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success)

Send information about an external dependency (outgoing call) in the application.

public void TrackDependency(DependencyTelemetry telemetry)

Send information about external dependency call in the application. Create a separate DependencyTelemetry instance for each call to TrackDependency.

public void TrackEvent(string eventName, IDictionary<string, string> properties = null)

Send an EventTelemetry for display in Diagnostic Search and in the Analytics Portal.

public void TrackEvent(EventTelemetry telemetry)

Send an EventTelemetry for display in Diagnostic Search and in the Analytics Portal. Create a separate EventTelemetry instance for each call to TrackEvent.

public void TrackException(Exception exception, IDictionary<string, string> properties = null)

Send an ExceptionTelemetry for display in Diagnostic Search.

public void TrackException(ExceptionTelemetry telemetry)

Send an ExceptionTelemetry for display in Diagnostic Search. Create a separate ExceptionTelemetry instance for each call to TrackException.

public void TrackMetric(string name, double value, IDictionary<string, string> properties = null)

This method is not the preferred method for sending metrics. Metrics should always be pre-aggregated across a time period before being sent. Use one of the GetMetric(..) overloads to get a metric object for accessing SDK pre-aggregation capabilities. If you are implementing your own pre-aggregation logic, then you can use this method. If your application requires sending a separate telemetry item at every occasion without aggregation across time, you likely have a use case for event telemetry; see TrackEvent.

public void TrackMetric(MetricTelemetry telemetry)

This method is not the preferred method for sending metrics. Metrics should always be pre-aggregated across a time period before being sent. Use one of the GetMetric(..) overloads to get a metric object for accessing SDK pre-aggregation capabilities. If you are implementing your own pre-aggregation logic, then you can use this method. If your application requires sending a separate telemetry item at every occasion without aggregation across time, you likely have a use case for event telemetry; see TrackEvent.

public void TrackRequest(string name, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool success)

Send information about a request handled by the application.

public void TrackRequest(RequestTelemetry request)

Send information about a request handled by the application. Create a separate RequestTelemetry instance for each call to TrackRequest.

public void TrackTrace(string message)

Send a trace message for display in Diagnostic Search.

public void TrackTrace(string message, SeverityLevel severityLevel)

Send a trace message for display in Diagnostic Search.

public void TrackTrace(string message, IDictionary<string, string> properties)

Send a trace message for display in Diagnostic Search.

public void TrackTrace(string message, SeverityLevel severityLevel, IDictionary<string, string> properties)

Send a trace message for display in Diagnostic Search.

public void TrackTrace(TraceTelemetry telemetry)

Send a trace message for display in Diagnostic Search. Create a separate TraceTelemetry instance for each call to TrackTrace.