Skip to content

Commit ff4ce28

Browse files
committed
Add telemetry data
1 parent a4ff3cb commit ff4ce28

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

common4j/src/main/com/microsoft/identity/common/java/cache/SharedPreferencesAccountCredentialCacheWithMemoryCache.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.microsoft.identity.common.java.logging.Logger;
3434
import com.microsoft.identity.common.java.opentelemetry.AttributeName;
3535
import com.microsoft.identity.common.java.opentelemetry.OTelUtility;
36+
import com.microsoft.identity.common.java.opentelemetry.OtelContextExtension;
3637
import com.microsoft.identity.common.java.util.StringUtil;
3738
import com.microsoft.identity.common.java.util.ported.Predicate;
3839

@@ -76,10 +77,11 @@ public SharedPreferencesAccountCredentialCacheWithMemoryCache(
7677
super(sharedPreferencesFileManager);
7778
Logger.verbose(TAG, "Init: " + TAG);
7879
mCacheValueDelegate = accountCacheValueDelegate;
79-
new Thread(() -> load()).start();
80+
new Thread(OtelContextExtension.wrap(() -> load())).start();
8081
}
8182

8283
private void load() {
84+
final long loadStartTime = System.currentTimeMillis();
8385
final String methodTag = TAG + ":load";
8486

8587
synchronized (mCacheLock) {
@@ -93,6 +95,8 @@ private void load() {
9395
} finally {
9496
mLoaded = true;
9597
mCacheLock.notifyAll();
98+
OTelUtility.recordElapsedTime(AttributeName.out_of_memory_exception_stacktrace.name(),
99+
loadStartTime);
96100
}
97101
}
98102
}

common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ public static FinalizableResultFuture<CommandResult> submitSilentReturningFuture
346346
AttributeName.num_concurrent_silent_requests.name(),
347347
sExecutingCommandMap.size()
348348
);
349+
int queueSize = ((ThreadPoolExecutor)sSilentExecutor).getQueue().size();
350+
SpanExtension.current().setAttribute(
351+
AttributeName.silent_requests_queue_size.name(),
352+
queueSize
353+
);
349354

350355
commandExecutor.execute(OtelContextExtension.wrap(new Runnable() {
351356
@Override

common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,17 @@ public enum AttributeName {
146146
http_status_code,
147147

148148
/**
149-
* The size of the silent command executor queue when starting to process an ATS request.
149+
* The number of unique cacheable silent requests currently being tracked in the executing command map.
150+
* This represents deduplicated commands that are either executing or waiting in the thread pool queue.
150151
*/
151152
num_concurrent_silent_requests,
152153

154+
/**
155+
* The number of tasks waiting in the silent request thread pool queue to be executed.
156+
* This does not include tasks currently being executed by worker threads.
157+
*/
158+
silent_requests_queue_size,
159+
153160
/**
154161
* The time (in milliseconds) spent in executing the save method in OAuth2TokenCache.
155162
*/

0 commit comments

Comments
 (0)