@Deprecated @Override protected void additionalSanitize() { Sanitizer.sanitizeMeasurements(this.getMetrics()); }
/** * 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); }
@Test public void testCtor() { NullPointerException exception = new NullPointerException("mock"); ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(exception); assertSame(exception, exceptionTelemetry.getException()); assertTrue(exceptionTelemetry.getProperties().isEmpty()); assertTrue(exceptionTelemetry.getMetrics().isEmpty()); assertThat(exceptionTelemetry.getExceptions(), hasSize(1)); }
@Override public Telemetry apply(BaseTelemetry bt) { Preconditions.checkNotNull(bt); ExceptionTelemetry t = (ExceptionTelemetry) bt; final Exception.Builder eb = Exception.newBuilder() .setVer(t.getVer()); final SeverityLevel sl = transformSeverityLevel(t.getSeverityLevel()); if (sl != SeverityLevel.UNRECOGNIZED) eb.setSeverityLevel(sl); if (t.getProblemId() != null) eb.setProblemId(t.getProblemId()); if (t.getProperties() != null) eb.putAllProperties(t.getProperties()); if (t.getMetrics() != null) eb.putAllMeasurements(t.getMetrics()); if (t.getExceptions() != null) eb.addAllExceptions(Iterables.transform(t.getExceptions(), EXCEPTION_DETAILS_TRANSFORMER_FUNCTION)); return telemetryBuilderWithStandardFields(t).setException(eb).build(); } });
xt.getContext().setInstrumentationKey(iKey); xt.getProperties().putAll(props); xt.getMetrics().putAll(metrics); testCases.add(new Object[]{ "Exception, with props & metrics",