Class TelemetryClient
java.lang.Object
com.microsoft.applicationinsights.TelemetryClient
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Flushes possible pending Telemetries.void
This method is part of the Application Insights infrastructure.void
trackAvailability
(AvailabilityTelemetry telemetry) void
trackDependency
(RemoteDependencyTelemetry telemetry) Sends a dependency record to Application Insights.void
trackDependency
(String dependencyName, String commandName, Duration duration, boolean success) void
trackEvent
(EventTelemetry telemetry) Sends a custom event record to Application Insights.void
trackEvent
(String name) Sends a custom event record to Application Insights.void
void
trackException
(ExceptionTelemetry telemetry) Sends an ExceptionTelemetry record for display in Diagnostic Search.void
trackException
(Exception exception) Sends an exception record to Application Insights.void
Sends an exception record to Application Insights.void
trackHttpRequest
(String name, Date timestamp, long duration, String responseCode, boolean success) Sends a request record to Application Insights.void
trackMetric
(MetricTelemetry telemetry) Sends a numeric metric to Application Insights.void
trackMetric
(String name, double value) Sends a numeric metric to Application Insights.void
trackMetric
(String name, double value, Integer sampleCount, Double min, Double max, Double stdDev, Map<String, String> properties) Sends a numeric metric to Application Insights.void
trackPageView
(PageViewTelemetry telemetry) Send information about the page viewed in the application.void
trackPageView
(String name) Sends a page view record to Application Insights.void
trackRequest
(RequestTelemetry request) Sends a request record to Application Insights.void
trackTrace
(TraceTelemetry telemetry) Sends a TraceTelemetry record for display in Diagnostic Search.void
trackTrace
(String message) Sends a TraceTelemetry record to Application Insights.void
trackTrace
(String message, SeverityLevel severityLevel) Sends a TraceTelemetry record.void
trackTrace
(String message, SeverityLevel severityLevel, Map<String, String> properties) Sends a TraceTelemetry record to Application Insights.
-
Constructor Details
-
TelemetryClient
public TelemetryClient()
-
-
Method Details
-
getContext
-
trackEvent
-
trackEvent
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
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
Sends a TraceTelemetry record to Application Insights. Appears in "traces" in Analytics and Search.- Parameters:
message
- A log message. Max length 10000.
-
trackTrace
Sends a TraceTelemetry record. Appears in "traces" in Analytics and Search.- Parameters:
message
- A log message. Max length 10000.severityLevel
- The severity level.
-
trackTrace
Sends a TraceTelemetry record for display in Diagnostic Search.- Parameters:
telemetry
- TheTelemetry
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
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
Sends a numeric metric to Application Insights. Appears in customMetrics in Analytics, and under Custom Metrics in Metric Explorer.- Parameters:
telemetry
- TheTelemetry
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
Sends an exception record to Application Insights. Appears in "exceptions" in Analytics and Search.- Parameters:
exception
- The exception to log information about.
-
trackException
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
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
-
trackDependency
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
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
Send information about the page viewed in the application.- Parameters:
telemetry
- The telemetry to send
-
trackAvailability
-
flush
public void flush()Flushes possible pending Telemetries. Not required for a continuously-running server application. -
track
This method is part of the Application Insights infrastructure. Do not call it directly.- Parameters:
telemetry
- TheTelemetry
instance.
-