Class TelemetryClient

java.lang.Object
com.microsoft.applicationinsights.TelemetryClient

public class TelemetryClient extends Object
  • Constructor Details

    • TelemetryClient

      public TelemetryClient()
  • Method Details

    • getContext

      public TelemetryContext getContext()
    • trackEvent

      public void trackEvent(String name, @Nullable Map<String,String> properties, @Nullable Map<String,Double> metrics)
    • trackEvent

      public void trackEvent(String name)
      Sends a custom event record to Application Insights. Appears in "custom events" in Analytics, Search and Metrics Explorer.
      Parameters:
      name - A name for the event. Max length 150.
    • trackEvent

      public void trackEvent(EventTelemetry telemetry)
      Sends a custom event record to Application Insights. Appears in "custom events" in Analytics, Search and Metrics Explorer.
      Parameters:
      telemetry - An event telemetry item.
    • trackTrace

      public void trackTrace(String message, @Nullable SeverityLevel severityLevel, @Nullable Map<String,String> properties)
      Sends a TraceTelemetry record to Application Insights. Appears in "traces" in Analytics and Search.
      Parameters:
      message - A log message. Max length 10000.
      severityLevel - The severity level.
      properties - Named string values you can use to search and classify trace messages.
    • trackTrace

      public void trackTrace(String message)
      Sends a TraceTelemetry record to Application Insights. Appears in "traces" in Analytics and Search.
      Parameters:
      message - A log message. Max length 10000.
    • trackTrace

      public void trackTrace(String message, SeverityLevel severityLevel)
      Sends a TraceTelemetry record. Appears in "traces" in Analytics and Search.
      Parameters:
      message - A log message. Max length 10000.
      severityLevel - The severity level.
    • trackTrace

      public void trackTrace(TraceTelemetry telemetry)
      Sends a TraceTelemetry record for display in Diagnostic Search.
      Parameters:
      telemetry - The Telemetry instance.
    • trackMetric

      public void trackMetric(String name, double value, @Nullable Integer sampleCount, @Nullable Double min, @Nullable Double max, @Nullable Double stdDev, @Nullable Map<String,String> properties)
      Sends a numeric metric to Application Insights. Appears in customMetrics in Analytics, and under Custom Metrics in Metric Explorer.
      Parameters:
      name - The name of the metric. Max length 150.
      value - The value of the metric. Sum if it represents an aggregation.
      sampleCount - The sample count.
      min - The minimum value of the sample.
      max - The maximum value of the sample.
      stdDev - The standard deviation of the sample.
      properties - Named string values you can use to search and classify trace messages.
      Throws:
      IllegalArgumentException - if name is null or empty
    • trackMetric

      public void trackMetric(String name, double value)
      Sends a numeric metric to Application Insights. Appears in customMetrics in Analytics, and under Custom Metrics in Metric Explorer.
      Parameters:
      name - The name of the metric. Max length 150.
      value - The value of the metric.
      Throws:
      IllegalArgumentException - if name is null or empty.
    • trackMetric

      public void trackMetric(MetricTelemetry telemetry)
      Sends a numeric metric to Application Insights. Appears in customMetrics in Analytics, and under Custom Metrics in Metric Explorer.
      Parameters:
      telemetry - The Telemetry instance.
    • trackException

      public void trackException(Exception exception, @Nullable Map<String,String> properties, @Nullable Map<String,Double> metrics)
      Sends an exception record to Application Insights. Appears in "exceptions" in Analytics and Search.
      Parameters:
      exception - The exception to log information about.
      properties - Named string values you can use to search and classify trace messages.
      metrics - Measurements associated with this exception event. Appear in "custom metrics" in Metrics Explorer.
    • trackException

      public void trackException(Exception exception)
      Sends an exception record to Application Insights. Appears in "exceptions" in Analytics and Search.
      Parameters:
      exception - The exception to log information about.
    • trackException

      public void trackException(ExceptionTelemetry telemetry)
      Sends an ExceptionTelemetry record for display in Diagnostic Search.
      Parameters:
      telemetry - An already constructed exception telemetry record.
    • trackHttpRequest

      public void trackHttpRequest(String name, Date timestamp, long duration, String responseCode, boolean success)
      Sends a request record to Application Insights. Appears in "requests" in Search and Analytics, and contributes to metric charts such as Server Requests, Server Response Time, Failed Requests.
      Parameters:
      name - A user-friendly name for the request or operation.
      timestamp - The time of the request.
      duration - The duration, in milliseconds, of the request processing.
      responseCode - The HTTP response code.
      success - true to record the operation as a successful request, false as a failed request.
    • trackRequest

      public void trackRequest(RequestTelemetry request)
      Sends a request record to Application Insights. Appears in "requests" in Search and Analytics, and contributes to metric charts such as Server Requests, Server Response Time, Failed Requests.
      Parameters:
      request - request
    • trackDependency

      public void trackDependency(String dependencyName, String commandName, Duration duration, boolean success)
    • trackDependency

      public void trackDependency(RemoteDependencyTelemetry telemetry)
      Sends a dependency record to Application Insights. Appears in "dependencies" in Search and Analytics. Set device type == "PC" to have the record contribute to metric charts such as Server Dependency Calls, Dependency Response Time, and Dependency Failures.
      Parameters:
      telemetry - telemetry
    • trackPageView

      public void trackPageView(String name)
      Sends a page view record to Application Insights. Appears in "page views" in Search and Analytics, and contributes to metric charts such as Page View Load Time.
      Parameters:
      name - The name of the page.
    • trackPageView

      public void trackPageView(PageViewTelemetry telemetry)
      Send information about the page viewed in the application.
      Parameters:
      telemetry - The telemetry to send
    • trackAvailability

      public void trackAvailability(AvailabilityTelemetry telemetry)
    • flush

      public void flush()
      Flushes possible pending Telemetries. Not required for a continuously-running server application.
    • track

      public void track(Telemetry telemetry)
      This method is part of the Application Insights infrastructure. Do not call it directly.
      Parameters:
      telemetry - The Telemetry instance.