Skip to content

Commit 1962c0c

Browse files
author
Rachel Prince
committed
Merge remote-tracking branch 'origin/master' into fad-update-java-doc-comments
2 parents 415bfd1 + 2db9b55 commit 1962c0c

File tree

9 files changed

+220
-197
lines changed

9 files changed

+220
-197
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ currently includes the following Firebase libraries, and some of their
55
dependencies:
66

77
* `firebase-abt`
8+
* `firebase-appdistribution`
89
* `firebase-common`
910
* `firebase-common-ktx`
1011
* `firebase-crashlytics`
@@ -22,6 +23,8 @@ dependencies:
2223
* `firebase-inappmessaging-ktx`
2324
* `firebase-inappmessaging-display`
2425
* `firebase-inappmessaging-display-ktx`
26+
* `firebase-messaging`
27+
* `firebase-messaging-directboot`
2528
* `firebase-perf`
2629
* `firebase-perf-ktx`
2730
* `firebase-remote-config`

firebase-appdistribution-stub/api.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ package com.google.firebase.appdistribution {
3636
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status DOWNLOAD_FAILURE;
3737
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status INSTALLATION_CANCELED;
3838
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status INSTALLATION_FAILURE;
39-
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status INSTALLATION_FAILURE_SIGNATURE_MISMATCH;
4039
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status NETWORK_FAILURE;
41-
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status RELEASE_URL_EXPIRED;
4240
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status UNKNOWN;
4341
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status UPDATE_NOT_AVAILABLE;
4442
}

firebase-appdistribution-stub/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistributionException.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,8 @@ public enum Status {
4545
/** Update not available for the current tester and app */
4646
UPDATE_NOT_AVAILABLE,
4747

48-
/** Installation failed due to signature mismatch */
49-
INSTALLATION_FAILURE_SIGNATURE_MISMATCH,
50-
5148
/** App is in production */
5249
APP_RUNNING_IN_PRODUCTION,
53-
54-
/** Download URL for release expired */
55-
RELEASE_URL_EXPIRED,
5650
}
5751

5852
@NonNull private final Status status;

firebase-appdistribution/api.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ package com.google.firebase.appdistribution {
3737
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status HOST_ACTIVITY_INTERRUPTED;
3838
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status INSTALLATION_CANCELED;
3939
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status INSTALLATION_FAILURE;
40-
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status INSTALLATION_FAILURE_SIGNATURE_MISMATCH;
4140
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status NETWORK_FAILURE;
42-
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status RELEASE_URL_EXPIRED;
4341
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status UNKNOWN;
4442
enum_constant public static final com.google.firebase.appdistribution.FirebaseAppDistributionException.Status UPDATE_NOT_AVAILABLE;
4543
}

firebase-messaging-directboot/firebase-messaging-directboot.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ plugins {
1818

1919
firebaseLibrary {
2020
testLab.enabled = false
21+
releaseWith project(':firebase-messaging')
2122
}
2223

2324
android {

firebase-perf/src/main/java/com/google/firebase/perf/transport/RateLimiter.java

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929
import com.google.firebase.perf.util.Rate;
3030
import com.google.firebase.perf.util.Timer;
3131
import com.google.firebase.perf.util.Utils;
32-
import com.google.firebase.perf.v1.NetworkRequestMetric;
3332
import com.google.firebase.perf.v1.PerfMetric;
3433
import com.google.firebase.perf.v1.PerfSession;
3534
import com.google.firebase.perf.v1.SessionVerbosity;
36-
import com.google.firebase.perf.v1.TraceMetric;
3735
import java.util.List;
3836
import java.util.Random;
3937

@@ -107,46 +105,47 @@ private boolean isDeviceAllowedToSendNetworkEvents() {
107105
}
108106

109107
/**
110-
* Check if we should log the {@link PerfMetric} to transport.
111-
*
112-
* <p>Cases in which we don't log a {@link PerfMetric} to transport:
113-
*
114-
* <ul>
115-
* <li>It is a {@link TraceMetric}, the {@link PerfSession} is not verbose and trace metrics are
116-
* sampled.
117-
* <li>It is a {@link NetworkRequestMetric}, the {@link PerfSession} is not verbose and network
118-
* requests are sampled.
119-
* <li>The number of metrics being sent exceeds what the rate limiter allows.
120-
* </ul>
108+
* Check if the {@link PerfMetric} should be rate limited.
121109
*
122110
* @param metric {@link PerfMetric} object.
123-
* @return true if allowed, false if not allowed.
111+
* @return true if event is rated limited, false if event is not rate limited.
124112
*/
125-
boolean check(PerfMetric metric) {
126-
if (metric.hasTraceMetric()
127-
&& !isDeviceAllowedToSendTraces()
128-
&& !hasVerboseSessions(metric.getTraceMetric().getPerfSessionsList())) {
113+
boolean isEventRateLimited(PerfMetric metric) {
114+
if (!isRateLimitApplicable(metric)) {
115+
// Apply rate limiting on this metric.
129116
return false;
130117
}
131118

132-
if (metric.hasNetworkRequestMetric()
133-
&& !isDeviceAllowedToSendNetworkEvents()
134-
&& !hasVerboseSessions(metric.getNetworkRequestMetric().getPerfSessionsList())) {
135-
return false;
119+
if (metric.hasNetworkRequestMetric()) {
120+
return !networkLimiter.check(metric);
121+
} else if (metric.hasTraceMetric()) {
122+
return !traceLimiter.check(metric);
123+
} else {
124+
// Should not reach here
125+
return true;
136126
}
127+
}
137128

138-
if (!isRateLimited(metric)) {
139-
// Do not apply rate limiting on this metric.
140-
return true;
129+
/**
130+
* Check if the {@link PerfMetric} should be sampled. A {@link PerfMetric} is considered sampled
131+
* if the device isn't allowed to send the event type and it is not part of a verbose session.
132+
*
133+
* @param metric {@link PerfMetric} object.
134+
* @return true if allowed, false if not allowed.
135+
*/
136+
boolean isEventSampled(PerfMetric metric) {
137+
if (metric.hasTraceMetric()
138+
&& !(isDeviceAllowedToSendTraces()
139+
|| hasVerboseSessions(metric.getTraceMetric().getPerfSessionsList()))) {
140+
return false;
141141
}
142142

143-
if (metric.hasNetworkRequestMetric()) {
144-
return networkLimiter.check(metric);
145-
} else if (metric.hasTraceMetric()) {
146-
return traceLimiter.check(metric);
147-
} else {
143+
if (metric.hasNetworkRequestMetric()
144+
&& !(isDeviceAllowedToSendNetworkEvents()
145+
|| hasVerboseSessions(metric.getNetworkRequestMetric().getPerfSessionsList()))) {
148146
return false;
149147
}
148+
return true;
150149
}
151150

152151
/**
@@ -174,7 +173,7 @@ private boolean hasVerboseSessions(List<PerfSession> perfSessions) {
174173
* @param metric {@link PerfMetric} object.
175174
* @return true if applying rate limiting. false if not.
176175
*/
177-
boolean isRateLimited(@NonNull PerfMetric metric) {
176+
boolean isRateLimitApplicable(@NonNull PerfMetric metric) {
178177
if (metric.hasTraceMetric()
179178
&& (metric
180179
.getTraceMetric()

firebase-perf/src/main/java/com/google/firebase/perf/transport/TransportManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ private boolean isAllowedToCache(PerfMetricOrBuilder perfMetricOrBuilder) {
407407
}
408408

409409
logger.debug(
410-
"%s is not allowed to cache. Cache exhausted the limit (availableTracesForCaching: %d, availableNetworkRequestsForCaching: %d, availableGaugesForCaching: %d).",
410+
"%s is not allowed to cache. Cache exhausted the limit (availableTracesForCaching: %d,"
411+
+ " availableNetworkRequestsForCaching: %d, availableGaugesForCaching: %d).",
411412
getLogcatMsg(perfMetricOrBuilder),
412413
availableTracesForCaching,
413414
availableNetworkRequestsForCaching,
@@ -441,16 +442,15 @@ private boolean isAllowedToDispatch(PerfMetric perfMetric) {
441442
return false;
442443
}
443444

444-
if (!rateLimiter.check(perfMetric)) {
445+
if (!rateLimiter.isEventSampled(perfMetric)) {
445446
incrementDropCount(perfMetric);
447+
logger.info("Event dropped due to device sampling - %s", getLogcatMsg(perfMetric));
448+
return false;
449+
}
446450

447-
if (perfMetric.hasTraceMetric()) {
448-
logger.info("Rate Limited - %s", getLogcatMsg(perfMetric.getTraceMetric()));
449-
450-
} else if (perfMetric.hasNetworkRequestMetric()) {
451-
logger.info("Rate Limited - %s", getLogcatMsg(perfMetric.getNetworkRequestMetric()));
452-
}
453-
451+
if (rateLimiter.isEventRateLimited(perfMetric)) {
452+
incrementDropCount(perfMetric);
453+
logger.info("Rate limited (per device) - %s", getLogcatMsg(perfMetric));
454454
return false;
455455
}
456456

0 commit comments

Comments
 (0)