private void sendHTTPTelemetry(MethodData methodData, Throwable throwable) { if (methodData.arguments != null && methodData.arguments.length == 1) { String url = methodData.arguments[0].toString(); long durationInMilliSeconds = nanoToMilliseconds(methodData.interval); Duration duration = new Duration(durationInMilliSeconds); InternalLogger.INSTANCE.trace("Sending HTTP RDD event, URL: '%s', duration=%s ms", url, durationInMilliSeconds); RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry(url, null, duration, throwable == null); telemetry.setDependencyKind(DependencyKind.Http); Date dependencyStartDate = new Date(System.currentTimeMillis() - durationInMilliSeconds); telemetry.setTimestamp(dependencyStartDate); telemetryClient.trackDependency(telemetry); if (throwable != null) { ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(throwable); telemetryClient.track(exceptionTelemetry); } } }
@Override public void methodFinished(String classAndMethodNames, long deltaInNS, Object[] args, Throwable throwable) { long durationInMS = nanoToMilliseconds(deltaInNS); Duration duration = new Duration(durationInMS); Date dependencyStartTime = new Date(System.currentTimeMillis() - durationInMS); RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry(classAndMethodNames, null, duration, throwable == null); telemetry.setTimestamp(dependencyStartTime); telemetry.setDependencyKind(DependencyKind.Other); if (args != null) { String argsAsString = new ArgsFormatter().format(args); telemetry.getContext().getProperties().put("Args", argsAsString); } InternalLogger.INSTANCE.trace("Sending RDD event for '%s', duration=%s ms", classAndMethodNames, durationInMS); telemetryClient.track(telemetry); if (throwable != null) { ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(throwable); telemetryClient.track(exceptionTelemetry); } }
duration, throwable == null); telemetry.setDependencyKind(DependencyKind.SQL); Date dependencyStartTime = new Date(System.currentTimeMillis() - durationInMilliSeconds); telemetry.setTimestamp(dependencyStartTime);
@Test public void testDependencyKind() { RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry("MockName"); telemetry.setDependencyKind(DependencyKind.Http); assertEquals(DependencyKind.Http, telemetry.getDependencyKind()); }