diff --git a/changelog.txt b/changelog.txt index fefaf616de..e5f8a8029a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,17 +1,6 @@ vNext ---------- - -Version 22.0.3 ----------- -- [PATCH] Fix DualScreenActivity theme color constant (#2737) - -Version 22.0.1 ----------- -- [PATCH] Handling https scheme for device enrollment link (#2732) -- [PATCH] Remove System Gesture Inset (#2730) - -Version 22.0.0 ----------- +- [MINOR] Move ests telemetry behind feature flag (#2742) - [MINOR] Update Broker ATS flow for Resource Account (#2704) - [PATCH] Handle BadTokenException gracefully in CBA dialogs (#2731) - [MINOR] Enable ShouldPreserveWebViewFlowOnSslError in Common (#2741) @@ -19,6 +8,10 @@ Version 22.0.0 - [PATCH] Fix DualScreenActivity theme color constant (#2737) - [MINOR] [SDL Assessment task] Secure webview settings (#2715) +Version 22.0.3 +---------- +- [PATCH] Fix DualScreenActivity theme color constant (#2737) + Version 22.0.1 ---------- - [PATCH] Handling https scheme for device enrollment link (#2732) diff --git a/common4j/src/main/com/microsoft/identity/common/java/eststelemetry/EstsTelemetry.java b/common4j/src/main/com/microsoft/identity/common/java/eststelemetry/EstsTelemetry.java index 77032bb64a..b421d24920 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/eststelemetry/EstsTelemetry.java +++ b/common4j/src/main/com/microsoft/identity/common/java/eststelemetry/EstsTelemetry.java @@ -26,10 +26,14 @@ import com.microsoft.identity.common.java.commands.ICommandResult; import com.microsoft.identity.common.java.exception.BaseException; import com.microsoft.identity.common.java.exception.ServiceException; +import com.microsoft.identity.common.java.flighting.CommonFlight; +import com.microsoft.identity.common.java.flighting.CommonFlightsManager; import com.microsoft.identity.common.java.interfaces.INameValueStorage; import com.microsoft.identity.common.java.interfaces.IPlatformComponents; import com.microsoft.identity.common.java.logging.DiagnosticContext; import com.microsoft.identity.common.java.logging.Logger; +import com.microsoft.identity.common.java.opentelemetry.AttributeName; +import com.microsoft.identity.common.java.opentelemetry.SpanExtension; import com.microsoft.identity.common.java.result.ILocalAuthenticationResult; import com.microsoft.identity.common.java.util.StringUtil; import com.microsoft.identity.common.java.util.ported.InMemoryStorage; @@ -64,6 +68,82 @@ public class EstsTelemetry { private final INameValueStorage mTelemetryMap; private final INameValueStorage> mSentFailedRequests; + /** + * A no-op implementation of EstsTelemetry that silently ignores all operations. + * Used when telemetry is disabled via feature flag. + */ + private static class NoopEstsTelemetry extends EstsTelemetry { + NoopEstsTelemetry() { + super(new InMemoryStorage(), new InMemoryStorage>()); + } + + @Override + public synchronized void setUp(@NonNull LastRequestTelemetryCache lastRequestTelemetryCache) { + // No-op + } + + @Override + public synchronized void setUp(@NonNull IPlatformComponents platformComponents) { + // No-op + } + + @Override + public void initTelemetryForCommand(@NonNull final ICommand command) { + // No-op + } + + @Override + public void emit(@Nullable Map telemetry) { + // No-op + } + + @Override + public void emit(@Nullable String key, String value) { + // No-op + } + + @Override + public void emit(@Nullable String key, int value) { + // No-op + } + + @Override + public void emit(@Nullable String key, long value) { + // No-op + } + + @Override + public void emit(@Nullable String key, boolean value) { + // No-op + } + + @Override + public void emitApiId(@Nullable String apiId) { + // No-op + } + + @Override + public void emitForceRefresh(boolean forceRefresh) { + // No-op + } + + @Override + public synchronized void flush(@NonNull ICommand command, @NonNull ICommandResult commandResult) { + // No-op + } + + @NonNull + @Override + public Map getTelemetryHeaders() { + return Collections.emptyMap(); + } + + @Override + public synchronized void clear() { + // No-op + } + } + /** * A supplemental cache that can used to store telemetry that is captured outside of the * DiagnosticContext. We have lots of code that is executed outside of a DiagnosticContext i.e. @@ -89,12 +169,26 @@ public class EstsTelemetry { /** * Get an instance of {@link EstsTelemetry}. This method will return an existing * instance of EstsTelemetry or create and return a new instance if the existing instance is null. + * If telemetry is disabled via the SKIP_ESTS_TELEMETRY feature flag, a NoopEstsTelemetry instance + * will be returned that safely ignores all telemetry operations. * * @return EstsTelemetry object instance */ public static synchronized EstsTelemetry getInstance() { if (sEstsTelemetryInstance == null) { - sEstsTelemetryInstance = new EstsTelemetry(); + // Check feature flag to decide whether to return NoopEstsTelemetry or real EstsTelemetry + final boolean shouldSkipEstsTelemetry = + CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.SKIP_ESTS_TELEMETRY); + + if (shouldSkipEstsTelemetry) { + Logger.verbose(TAG, "SKIP_ESTS_TELEMETRY feature flag enabled, using NoopEstsTelemetry"); + SpanExtension.current().setAttribute(AttributeName.skipped_ests_telemetry.name(), true); + sEstsTelemetryInstance = new NoopEstsTelemetry(); + } else { + Logger.verbose(TAG, "SKIP_ESTS_TELEMETRY feature flag disabled, using standard EstsTelemetry"); + SpanExtension.current().setAttribute(AttributeName.skipped_ests_telemetry.name(), false); + sEstsTelemetryInstance = new EstsTelemetry(); + } } return sEstsTelemetryInstance; diff --git a/common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java b/common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java index 0ed770bc72..762c610eb1 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java +++ b/common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java @@ -155,7 +155,12 @@ public enum CommonFlight implements IFlightConfig { /** * Flight to enable WebView security settings to prevent unauthorized access. */ - ENABLE_WEBVIEW_SECURITY_SETTINGS("EnableWebViewSecuritySettings", false); + ENABLE_WEBVIEW_SECURITY_SETTINGS("EnableWebViewSecuritySettings", false), + + /** + * Flight to skip ests telemetry. + */ + SKIP_ESTS_TELEMETRY("SkipEstsTelemetry", false); private String key; private Object defaultValue; diff --git a/common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java b/common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java index 13b60d3cc2..145c47efad 100644 --- a/common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java +++ b/common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java @@ -432,6 +432,12 @@ public enum AttributeName { /** * Records the time (in milliseconds) spent on flight check for webcp. */ - web_cp_flight_get_time + web_cp_flight_get_time, + + /** + * Indicates if ests telemetry was skipped. + */ + skipped_ests_telemetry + }