Skip to content

Commit 6a61c8d

Browse files
committed
add a counter to getCurrentAccount() to track lack of SDM
1 parent 6ed9f94 commit 6a61c8d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

common/src/main/java/com/microsoft/identity/common/internal/controllers/BrokerMsalController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
import com.microsoft.identity.common.java.exception.ServiceException;
102102
import com.microsoft.identity.common.java.exception.UnsupportedBrokerException;
103103
import com.microsoft.identity.common.java.interfaces.IPlatformComponents;
104+
import com.microsoft.identity.common.java.opentelemetry.OTelUtility;
104105
import com.microsoft.identity.common.java.providers.microsoft.MicrosoftRefreshToken;
105106
import com.microsoft.identity.common.java.providers.microsoft.azureactivedirectory.ClientInfo;
106107
import com.microsoft.identity.common.java.providers.microsoft.microsoftsts.MicrosoftStsAccount;
@@ -123,6 +124,7 @@
123124
import java.util.concurrent.ExecutionException;
124125
import java.util.concurrent.TimeUnit;
125126

127+
import io.opentelemetry.api.metrics.LongCounter;
126128
import lombok.EqualsAndHashCode;
127129

128130
/**
@@ -151,6 +153,12 @@ public class BrokerMsalController extends BaseController {
151153

152154
private String mMaxMsalBrokerProtocolVersion;
153155

156+
// telemetry count metric for tracking getCurrentAccount() SDM failures
157+
private static final LongCounter sGetCurrentAccountFailedNoSDMCount = OTelUtility.createLongCounter(
158+
"get_current_account_failed_no_sdm_count",
159+
"Number of failed getCurrentAccount calls due to no SDM"
160+
);
161+
154162
public BrokerMsalController(@NonNull final Context applicationContext,
155163
@NonNull final IPlatformComponents components,
156164
@NonNull final String activeBrokerPackageName) {
@@ -947,6 +955,7 @@ List<ICacheRecord> getCurrentAccount(final @NonNull CommandParameters parameters
947955

948956
if (!parameters.isSharedDevice()) {
949957
Logger.verbose(TAG + methodName, "Not a shared device, invoke getAccounts() instead of getCurrentAccount()");
958+
sGetCurrentAccountFailedNoSDMCount.add(1); // TODO: Any useful attributes? How is this omitted?
950959
return getAccounts(parameters);
951960
}
952961

0 commit comments

Comments
 (0)