-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Instrumentation to Collect Missing HTTP Parameters #567
Changes from all commits
512f39f
0cf699f
9b07a41
1ac1f1e
dbc22de
b98d045
24f6459
36ed01c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import java.sql.DatabaseMetaData; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.Date; | ||
import java.util.LinkedList; | ||
|
||
import com.microsoft.applicationinsights.agent.internal.coresync.AgentNotificationsHandler; | ||
|
@@ -163,6 +164,32 @@ public void httpMethodFinished(String identifier, String method, String correlat | |
telemetryClient.track(telemetry); | ||
} | ||
|
||
@Override | ||
public void httpMethodFinishedWithPath(String identifier, String method, String path, String correlationId, String uri, String target, int result, long delta) { | ||
if (!LocalStringsUtils.isNullOrEmpty(uri) && (uri.startsWith("https://dc.services.visualstudio.com") || uri.startsWith("https://rt.services.visualstudio.com"))) { | ||
return; | ||
} | ||
long deltaInMS = nanoToMilliseconds(delta); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it needed for logging only? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lmolkova great catch. No actually this should be passed while creating Remote Dependency Telemetry object, otherwise numbers would mess up. Will fix this. |
||
String name = method + " " + path; | ||
RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry(name, uri, new Duration(deltaInMS), true); | ||
Date dependencyStartTime = new Date(System.currentTimeMillis() - deltaInMS); | ||
telemetry.setTimestamp(dependencyStartTime); | ||
telemetry.setId(correlationId); | ||
telemetry.setResultCode(Integer.toString(result)); | ||
telemetry.setType("HTTP"); | ||
if (target != null && !target.isEmpty()) { | ||
if (telemetry.getTarget() == null) { | ||
telemetry.setTarget(target); | ||
} else { | ||
telemetry.setTarget(telemetry.getTarget() + " | " + target); | ||
} | ||
} | ||
|
||
InternalLogger.INSTANCE.trace("'%s' sent an HTTP method: '%s', uri: '%s', duration=%s ms", identifier, method, uri, deltaInMS); | ||
telemetryClient.track(telemetry); | ||
|
||
} | ||
|
||
@Override | ||
public void jedisMethodStarted(String name) { | ||
int index = name.lastIndexOf('#'); | ||
|
@@ -211,7 +238,9 @@ public void methodFinished(String name, long thresholdInMS) { | |
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) { | ||
|
@@ -359,10 +388,11 @@ private void report(MethodData methodData, Throwable throwable) { | |
} | ||
|
||
private void sendInstrumentationTelemetry(MethodData methodData, Throwable throwable) { | ||
Duration duration = new Duration(nanoToMilliseconds(methodData.interval)); | ||
RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry(methodData.name, null, duration, throwable == null); | ||
long durationInMilliSeconds = nanoToMilliseconds(methodData.interval); | ||
RemoteDependencyTelemetry telemetry = new RemoteDependencyTelemetry(methodData.name, null, new Duration(durationInMilliSeconds), throwable == null); | ||
telemetry.setType(methodData.type); | ||
|
||
Date dependencyStartDate = new Date(System.currentTimeMillis() - durationInMilliSeconds); | ||
telemetry.setTimestamp(dependencyStartDate); | ||
InternalLogger.INSTANCE.trace("Sending RDD event for '%s'", methodData.name); | ||
|
||
telemetryClient.track(telemetry); | ||
|
@@ -382,6 +412,8 @@ private void sendHTTPTelemetry(MethodData methodData, Throwable throwable) { | |
|
||
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); | ||
|
@@ -418,6 +450,8 @@ private void sendSQLTelemetry(MethodData methodData, Throwable throwable) { | |
duration, | ||
throwable == null); | ||
telemetry.setDependencyKind(DependencyKind.SQL); | ||
Date dependencyStartTime = new Date(System.currentTimeMillis() - durationInMilliSeconds); | ||
telemetry.setTimestamp(dependencyStartTime); | ||
|
||
StringBuilder sb = null; | ||
if (methodData.arguments.length > 3) { | ||
|
@@ -435,7 +469,7 @@ private void sendSQLTelemetry(MethodData methodData, Throwable throwable) { | |
} | ||
|
||
InternalLogger.INSTANCE.trace("Sending Sql RDD event for '%s', command: '%s', duration=%s ms", dependencyName, commandName, durationInMilliSeconds); | ||
|
||
telemetryClient.track(telemetry); | ||
if (throwable != null) { | ||
InternalLogger.INSTANCE.trace("Sending Sql exception"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the motivation to mark it as deprecated, why don't just remove it? Could someone call it externally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmolkova this is a publically exposed method in an interface and that means any one can directly call it, the likelihood of someone doing it with this method is relatively very very low but still in theory this is a breaking change. So better API releasing norms say to first deprecate and then clean :- )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, I thought that the interface is private. deprecation makes perfect sense now