in agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/quickpulse/QuickPulseDataCollector.java [279:314]
private void addException(TelemetryExceptionData exceptionData, int itemCount) {
Counters counters = this.counters.get();
if (counters == null) {
return;
}
counters.exceptions.addAndGet(itemCount);
QuickPulseExceptionDocument quickPulseExceptionDocument = new QuickPulseExceptionDocument();
quickPulseExceptionDocument.setDocumentType("Exception");
quickPulseExceptionDocument.setType("ExceptionTelemetryDocument");
quickPulseExceptionDocument.setOperationId(exceptionData.getProblemId());
quickPulseExceptionDocument.setVersion("1.0");
List<TelemetryExceptionDetails> exceptionList = exceptionData.getExceptions();
StringBuilder exceptions = new StringBuilder();
if (exceptionList != null && exceptionList.size() > 0) {
List<StackFrame> parsedStack = exceptionList.get(0).getParsedStack();
String stack = exceptionList.get(0).getStack();
if (parsedStack != null && parsedStack.size() > 0) {
for (StackFrame stackFrame : parsedStack) {
if (stackFrame != null && stackFrame.getAssembly() != null) {
exceptions.append(stackFrame.getAssembly()).append("\n");
}
}
} else if (stack != null && stack.length() > 0) {
exceptions.append(stack);
}
quickPulseExceptionDocument.setException(exceptions.toString());
quickPulseExceptionDocument.setExceptionMessage(exceptionList.get(0).getMessage());
quickPulseExceptionDocument.setExceptionType(exceptionList.get(0).getTypeName());
}
synchronized (counters.documentList) {
if (counters.documentList.size() < Counters.MAX_DOCUMENTS_SIZE) {
counters.documentList.add(quickPulseExceptionDocument);
}
}
}