Class TelemetryClient
- java.lang.Object
-
- com.microsoft.applicationinsights.TelemetryClient
-
public class TelemetryClient extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description TelemetryClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
Flushes possible pending Telemetries.TelemetryContext
getContext()
void
track(Telemetry telemetry)
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(java.lang.String dependencyName, java.lang.String commandName, Duration duration, boolean success)
void
trackEvent(EventTelemetry telemetry)
Sends a custom event record to Application Insights.void
trackEvent(java.lang.String name)
Sends a custom event record to Application Insights.void
trackEvent(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> properties, java.util.Map<java.lang.String,java.lang.Double> metrics)
void
trackException(ExceptionTelemetry telemetry)
Sends an ExceptionTelemetry record for display in Diagnostic Search.void
trackException(java.lang.Exception exception)
Sends an exception record to Application Insights.void
trackException(java.lang.Exception exception, java.util.Map<java.lang.String,java.lang.String> properties, java.util.Map<java.lang.String,java.lang.Double> metrics)
Sends an exception record to Application Insights.void
trackHttpRequest(java.lang.String name, java.util.Date timestamp, long duration, java.lang.String responseCode, boolean success)
Sends a request record to Application Insights.void
trackMetric(MetricTelemetry telemetry)
Sends a numeric metric to Application Insights.void
trackMetric(java.lang.String name, double value)
Sends a numeric metric to Application Insights.void
trackMetric(java.lang.String name, double value, java.lang.Integer sampleCount, java.lang.Double min, java.lang.Double max, java.lang.Double stdDev, java.util.Map<java.lang.String,java.lang.String> properties)
Sends a numeric metric to Application Insights.void
trackPageView(PageViewTelemetry telemetry)
Send information about the page viewed in the application.void
trackPageView(java.lang.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(java.lang.String message)
Sends a TraceTelemetry record to Application Insights.void
trackTrace(java.lang.String message, SeverityLevel severityLevel)
Sends a TraceTelemetry record.void
trackTrace(java.lang.String message, SeverityLevel severityLevel, java.util.Map<java.lang.String,java.lang.String> properties)
Sends a TraceTelemetry record to Application Insights.
-
-
-
Method Detail
-
getContext
public TelemetryContext getContext()
-
trackEvent
public void trackEvent(java.lang.String name, @Nullable java.util.Map<java.lang.String,java.lang.String> properties, @Nullable java.util.Map<java.lang.String,java.lang.Double> metrics)
-
trackEvent
public void trackEvent(java.lang.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(java.lang.String message, @Nullable SeverityLevel severityLevel, @Nullable java.util.Map<java.lang.String,java.lang.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(java.lang.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(java.lang.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
- TheTelemetry
instance.
-
trackMetric
public void trackMetric(java.lang.String name, double value, @Nullable java.lang.Integer sampleCount, @Nullable java.lang.Double min, @Nullable java.lang.Double max, @Nullable java.lang.Double stdDev, @Nullable java.util.Map<java.lang.String,java.lang.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:
java.lang.IllegalArgumentException
- if name is null or empty
-
trackMetric
public void trackMetric(java.lang.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:
java.lang.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
- TheTelemetry
instance.
-
trackException
public void trackException(java.lang.Exception exception, @Nullable java.util.Map<java.lang.String,java.lang.String> properties, @Nullable java.util.Map<java.lang.String,java.lang.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(java.lang.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(java.lang.String name, java.util.Date timestamp, long duration, java.lang.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(java.lang.String dependencyName, java.lang.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(java.lang.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.
-
-