Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cde3c46
fix OOM error handling
fadidurah Jan 10, 2025
4f24891
changes
fadidurah Jan 10, 2025
443fcc2
t push originMerge branch 'dev' of https://github.com/AzureAD/microso…
fadidurah Jan 29, 2025
3bf1b13
comments
fadidurah Jan 29, 2025
0e7b05b
On getBrowserSafeList return empty list if null
p3dr0rv Jan 29, 2025
09e7137
Merge branch 'dev' into pedroro/empty-list-browser-safe-list
p3dr0rv Jan 29, 2025
c756cac
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah Jan 30, 2025
584a2aa
Merge branch 'pedroro/empty-list-browser-safe-list' of https://github…
fadidurah Jan 30, 2025
03e1946
changes for common
fadidurah Jan 30, 2025
bcf7347
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah Jan 30, 2025
6f85009
adapter
fadidurah Jan 30, 2025
26d9247
switch to killProcess
fadidurah Jan 30, 2025
880625d
platform specific
fadidurah Jan 31, 2025
21d79f7
dev
fadidurah Feb 21, 2025
acf5a66
attributeName
fadidurah Feb 21, 2025
8ccd046
suppress spotbugs
fadidurah Feb 21, 2025
9906e9e
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
fadidurah Feb 25, 2025
f92b7b1
revert
fadidurah Feb 26, 2025
a85a25d
take out changes
fadidurah Feb 26, 2025
8761d65
comment
fadidurah Feb 26, 2025
1783748
track telemetry
fadidurah Feb 26, 2025
0294fc7
Merge branch 'dev' into fadi/oom-handle
fadidurah Feb 28, 2025
9009b65
comments
fadidurah Feb 28, 2025
b20b8ad
try-catch
fadidurah Feb 28, 2025
af1fe6f
throwable
fadidurah Feb 28, 2025
2ccf080
comment
fadidurah Feb 28, 2025
7f675af
Merge branch 'dev' into fadi/oom-handle
fadidurah Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ vNext
----------
- [MINOR] Launch browser when a switch_browser redirect URL is present (#2553)
- [MINOR] Add Broker Webapps operations api. (#2579)
- [PATCH] Add Telemetry for OOM Errors (#2567)

Version 20.0.0
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import com.microsoft.identity.common.java.exception.UserCancelException;
import com.microsoft.identity.common.java.logging.Logger;
import com.microsoft.identity.common.java.net.HttpResponse;
import com.microsoft.identity.common.java.opentelemetry.AttributeName;
import com.microsoft.identity.common.java.opentelemetry.SpanExtension;
import com.microsoft.identity.common.java.providers.microsoft.MicrosoftAuthorizationErrorResponse;
import com.microsoft.identity.common.java.providers.oauth2.AuthorizationErrorResponse;
import com.microsoft.identity.common.java.providers.oauth2.AuthorizationResult;
Expand All @@ -66,6 +68,7 @@

import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.opentelemetry.api.trace.Span;
import lombok.NonNull;

public class ExceptionAdapter {
Expand Down Expand Up @@ -436,6 +439,26 @@ public static ClientException clientExceptionFromException(@NonNull final Throwa


if (e instanceof OutOfMemoryError) {
Logger.warn(TAG,
"Received an out of memory error, attempting to attach stacktrace...");

// Record exception stacktrace in span
// Put this in a try-catch in case this telemetry emit attempt causes another OOM
try {
final Span currentSpan = SpanExtension.current();

// Attach the stack trace, to debug in telemetry later
currentSpan.setAttribute(
AttributeName.out_of_memory_exception_stacktrace.name(),
StringUtil.getStacktraceAsStringFromElementArray(e.getStackTrace())
);

Logger.warn(TAG,
"Received an out of memory error, stacktrace attached to span with id: " + currentSpan.getSpanContext().getSpanId());
} catch (Throwable throwable) {
Logger.warn(TAG, "Failed to emit telemetry for out of memory exception.");
}

return new ClientException(
ClientException.OUT_OF_MEMORY,
e.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,10 @@ public enum AttributeName {
/**
* Indicates the exception in generating a keypair.
*/
keypair_gen_exception
keypair_gen_exception,

/**
* Records the stacktrace for an out-of-memory exception.
*/
out_of_memory_exception_stacktrace
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,21 @@ public static void overwriteWithNull(final char[] chars) {
chars[i] = '\0';
}
}

/**
* Converts an array of stack trace elements (one method invocation) into one concatenated string object.
*
* @param elements list of stacktrace elements
* @return concatenated string list
*/
@NonNull
public static String getStacktraceAsStringFromElementArray(@NonNull final StackTraceElement[] elements) {
final StringBuilder builder = new StringBuilder();
builder.append(elements[0]);
for (int i = 1; i < elements.length; i++) {
builder.append("\n");
builder.append(elements[i]);
}
return builder.toString();
}
}