/** * 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. * @param name A user-friendly name for the request or operation. * @param timestamp The time of the request. * @param duration The duration, in milliseconds, of the request processing. * @param responseCode The HTTP response code. * @param success true to record the operation as a successful request, false as a failed request. */ public void trackHttpRequest(String name, Date timestamp, long duration, String responseCode, boolean success) { if (isDisabled()) { return; } track(new RequestTelemetry(name, timestamp, duration, responseCode, success)); }
/** * 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. * @param telemetry telemetry */ public void trackDependency(RemoteDependencyTelemetry telemetry) { if (isDisabled()) { return; } if (telemetry == null) { telemetry = new RemoteDependencyTelemetry(""); } track(telemetry); }
/** * 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. @param name The name of the page. */ public void trackPageView(String name) { // Avoid creation of data if not needed if (isDisabled()) { return; } if (name == null) { name = ""; } Telemetry telemetry = new PageViewTelemetry(name); track(telemetry); }
/** * Sends a TraceTelemetry record to Application Insights. Appears in "traces" in Analytics and Search. * @param message A log message. Max length 10000. * @param severityLevel The severity level. * @param properties Named string values you can use to search and classify trace messages. */ public void trackTrace(String message, SeverityLevel severityLevel, Map<String, String> properties) { if (isDisabled()) { return; } if (Strings.isNullOrEmpty(message)) { message = ""; } TraceTelemetry et = new TraceTelemetry(message, severityLevel); MapUtil.copy(properties, et.getContext().getProperties()); this.track(et); }
/** * Sends an exception record to Application Insights. Appears in "exceptions" in Analytics and Search. * @param exception The exception to log information about. * @param properties Named string values you can use to search and classify trace messages. * @param metrics Measurements associated with this exception event. Appear in "custom metrics" in Metrics Explorer. */ public void trackException(Exception exception, Map<String, String> properties, Map<String, Double> metrics) { if (isDisabled()) { return; } ExceptionTelemetry et = new ExceptionTelemetry(exception); MapUtil.copy(properties, et.getContext().getProperties()); MapUtil.copy(metrics, et.getMetrics()); this.track(et); }
/** * Sends a custom event record to Application Insights. Appears in custom events in Analytics, Search and Metrics Explorer. * @param name A name for the event. Max length 150. * @param properties Named string values you can use to search and filter events. * @param metrics Numeric measurements associated with this event. Appear under Custom Metrics in Metrics Explorer. */ public void trackEvent(String name, Map<String, String> properties, Map<String, Double> metrics) { if (isDisabled()) { return; } if (Strings.isNullOrEmpty(name)) { name = ""; } EventTelemetry et = new EventTelemetry(name); MapUtil.copy(properties, et.getContext().getProperties()); MapUtil.copy(metrics, et.getMetrics()); this.track(et); }
if (isDisabled()) { return;
/** * Sends a numeric metric to Application Insights. Appears in customMetrics in Analytics, and under Custom Metrics in Metric Explorer. * * @param name The name of the metric. Max length 150. * @param value The value of the metric. Sum if it represents an aggregation. * @param sampleCount The sample count. * @param min The minimum value of the sample. * @param max The maximum value of the sample. * @param stdDev The standard deviation of the sample. * @param properties Named string values you can use to search and classify trace messages. * @throws IllegalArgumentException if name is null or empty */ public void trackMetric(String name, double value, Integer sampleCount, Double min, Double max, Double stdDev, Map<String, String> properties) { if (isDisabled()) { return; } MetricTelemetry mt = new MetricTelemetry(name, value); mt.setCount(sampleCount); mt.setMin(min); mt.setMax(max); mt.setStandardDeviation(stdDev); MapUtil.copy(properties, mt.getProperties()); this.track(mt); }