File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
firebase-perf/src/main/java/com/google/firebase/perf/transport Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,17 @@ private boolean isDeviceAllowedToSendNetworkEvents() {
104
104
return samplingBucketId < validNetworkSamplingBucketIdThreshold ;
105
105
}
106
106
107
+ /** Returns whether device is allowed to send trace events based on trace sampling rate. */
108
+ private boolean isDeviceAllowedToSendFragmentScreenTraces () {
109
+ float validFragmentSamplingBucketIdThreshold = configResolver .getFragmentSamplingRate ();
110
+ return samplingBucketId < validFragmentSamplingBucketIdThreshold ;
111
+ }
112
+
113
+ /** Identifies if the {@link PerfMetric} is a Fragment screen trace */
114
+ private boolean isFragmentScreenTrace (PerfMetric metric ) {
115
+ return metric .hasTraceMetric () && metric .getTraceMetric ().getName ().startsWith (Constants .SCREEN_TRACE_PREFIX ) && metric .getTraceMetric ().containsCustomAttributes (Constants .ACTIVITY_ATTRIBUTE_KEY );
116
+ }
117
+
107
118
/**
108
119
* Check if the {@link PerfMetric} should be rate limited.
109
120
*
@@ -140,6 +151,12 @@ boolean isEventSampled(PerfMetric metric) {
140
151
return false ;
141
152
}
142
153
154
+ if (isFragmentScreenTrace (metric )
155
+ && !(isDeviceAllowedToSendFragmentScreenTraces ()
156
+ || hasVerboseSessions (metric .getTraceMetric ().getPerfSessionsList ()))) {
157
+ return false ;
158
+ }
159
+
143
160
if (metric .hasNetworkRequestMetric ()
144
161
&& !(isDeviceAllowedToSendNetworkEvents ()
145
162
|| hasVerboseSessions (metric .getNetworkRequestMetric ().getPerfSessionsList ()))) {
You can’t perform that action at this time.
0 commit comments