Skip to content

Commit 674d7b6

Browse files
committed
flight added for webcp timeout
1 parent b186398 commit 674d7b6

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

common/src/main/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClient.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -650,25 +650,24 @@ protected boolean isWebCpInWebviewFeatureEnabled(@NonNull final String originalU
650650
return false;
651651
}
652652

653-
if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_WEB_CP_IN_WEBVIEW)) {
654-
// Directly enabled via flight rollout.
655-
Logger.info(methodTag, "WebCP in WebView feature is enabled.");
656-
mIsWebCpInWebViewFeatureEnabled = true;
657-
return true;
658-
}
659-
660-
// Else, check if the home tenant is in the list of tenants that have this feature enabled.
661653
final String homeTenantId = !StringUtil.isNullOrEmpty(mUtid)? mUtid : getHomeTenantIdFromUrl(originalUrl);
662654
if (StringUtil.isNullOrEmpty(homeTenantId)) {
663655
Logger.info(methodTag, "Home tenantId is empty");
664656
return false;
665657
}
666658

667-
final String tenantIdList = CommonFlightsManager.INSTANCE.getFlightsProvider().getStringValue(CommonFlight.TENANT_LIST_TO_ENABLE_WEB_CP_IN_WEBVIEW);
668-
final boolean isFlightEnabledForCurrentTenant = !StringUtil.isNullOrEmpty(tenantIdList) && tenantIdList.contains(homeTenantId);
669-
Logger.info(methodTag, "TenantId list is empty? " + StringUtil.isNullOrEmpty(tenantIdList) + ", Is current tenantId in list? " + isFlightEnabledForCurrentTenant);
670-
mIsWebCpInWebViewFeatureEnabled = isFlightEnabledForCurrentTenant;
671-
return isFlightEnabledForCurrentTenant;
659+
final long webCpGetFlightStartTime = System.currentTimeMillis();
660+
final int waitForFlightsTimeOut = CommonFlightsManager.INSTANCE.getFlightsProvider().getIntValue(CommonFlight.WEB_CP_WAIT_TIMEOUT_FOR_FLIGHTS);
661+
final boolean isWebCpFlightEnabled = CommonFlightsManager.INSTANCE.getFlightsProviderForTenant(homeTenantId, waitForFlightsTimeOut).isFlightEnabled(CommonFlight.ENABLE_WEB_CP_IN_WEBVIEW);
662+
SpanExtension.current().setAttribute(AttributeName.web_cp_flight_get_time.name(), (System.currentTimeMillis() - webCpGetFlightStartTime));
663+
if (isWebCpFlightEnabled) {
664+
// Directly enabled via flight rollout.
665+
Logger.info(methodTag, "WebCP in WebView feature is enabled. "+ waitForFlightsTimeOut);
666+
mIsWebCpInWebViewFeatureEnabled = true;
667+
return true;
668+
}
669+
670+
return false;
672671
} catch (final Throwable throwable) {
673672
// Catching any unexpected exceptions to avoid breaking the flow. We will anyway remove this block once the feature is fully rolled out.
674673
Logger.error(methodTag, "Failed to check if WebCP in WebView feature is enabled.", throwable);

common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ public enum CommonFlight implements IFlightConfig {
145145
* Flight to enable the WebView flow to not cancel and preserve WebView flow on SSL errors.
146146
* The web resource running into SSL will itself not be loaded.
147147
*/
148-
SHOULD_PRESERVE_WEBVIEW_FLOW_ON_SSL_ERROR("ShouldPreserveWebViewFlowOnSslError", false);
148+
SHOULD_PRESERVE_WEBVIEW_FLOW_ON_SSL_ERROR("ShouldPreserveWebViewFlowOnSslError", false),
149+
150+
/**
151+
* Flight to control the timeout to wait for tenant based flight in WebCP.
152+
*/
153+
WEB_CP_WAIT_TIMEOUT_FOR_FLIGHTS("WebCpWaitTimeoutForFlights", 3000);
149154

150155
private String key;
151156
private Object defaultValue;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,5 +427,11 @@ public enum AttributeName {
427427
/**
428428
* Record whether or not the request stored a number match entry.
429429
*/
430-
stored_number_match_entry
430+
stored_number_match_entry,
431+
432+
/**
433+
* Records the time (in milliseconds) spent on flight check for webcp.
434+
*/
435+
web_cp_flight_get_time
436+
431437
}

0 commit comments

Comments
 (0)