Skip to content

Enable global custom attributes on Network Requests #3399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firebase-perf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Refer [GMaven](https://maven.google.com/web/index.html?q=firebase-perf#com.googl
> **Note:** Refer go/firebase-android-release for `MXX` info.

## Unreleased
* {{feature}} Enable global custom attributes on Network Requests
* {{fixed}} Update log statement to differentiate event drop because of rate limiting and sampling.

## Released

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ private PerfMetric setApplicationInfoAndBuild(
ApplicationInfo.Builder appInfoBuilder =
applicationInfoBuilder.setApplicationProcessState(appState);

if (perfMetricBuilder.hasTraceMetric()) {
if (perfMetricBuilder.hasTraceMetric() || perfMetricBuilder.hasNetworkRequestMetric()) {
appInfoBuilder =
appInfoBuilder
.clone() // Needed so that we don't add global custom attributes everywhere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ public void logTraceMetric_globalCustomAttributesAreAdded() {
}

@Test
public void logNetworkMetric_globalCustomAttributesAreNotAdded() {
public void logNetworkMetric_globalCustomAttributesAreAdded() {
FirebasePerformance.getInstance().putAttribute("test_key1", "test_value1");
FirebasePerformance.getInstance().putAttribute("test_key2", "test_value2");
NetworkRequestMetric validNetworkRequest = createValidNetworkRequestMetric();
Expand All @@ -1131,7 +1131,12 @@ public void logNetworkMetric_globalCustomAttributesAreNotAdded() {
assertThat(loggedPerfMetric.getNetworkRequestMetric()).isEqualTo(validNetworkRequest);
validateApplicationInfo(
loggedPerfMetric, ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN);
assertThat(loggedPerfMetric.getApplicationInfo().getCustomAttributesCount()).isEqualTo(0);

Map<String, String> globalCustomAttributes =
loggedPerfMetric.getApplicationInfo().getCustomAttributesMap();
assertThat(globalCustomAttributes).hasSize(2);
assertThat(globalCustomAttributes).containsEntry("test_key1", "test_value1");
assertThat(globalCustomAttributes).containsEntry("test_key2", "test_value2");
}

@Test
Expand Down