Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1289a07c authored by lifr's avatar lifr
Browse files

Update the default sampling flag of DNS resolver metrics events

The sample rate of DNS resolver metrics events depends on Experiment
flag and default sampling flag. Currently, the sampling experiment
has been completed. Therefore update the new default sampling flag to
reduce the metrics event size.

1. Current default sampling rate:
   DEFAULT_SUBSAMPLING_MAP[] = "default:1 0:100 7:10
   metrics data size: 170k byte per device
2. Old Experiment:
   DEFAULT_SUBSAMPLING_MAP[] = "default:5 0:300 2:80 7:80"
   metrics data size: 11k byte per device
3. New default sampling rate:
   DEFAULT_SUBSAMPLING_MAP[] = "default:8 0:400 2:110 7:110"
   metrics data size: 7.9k byte per device
4. New Experiment:(including the temporary fix of b/185097438)
   DEFAULT_SUBSAMPLING_MAP[] = "default:8 0:400 2:110 4:110 7:110"
   metrics data size: 7.9k byte per device

Because there is already a solution for b/185097438 in the code.
Therefore, what this commit will do is item3 to reduce the size
of the event.

Bug: 184830442
Test: atest resolv_unit_test
Change-Id: I3c0ab4a4504dfd5f8c789348587de33e01951920
parent 8f58a580
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -903,7 +903,7 @@ namespace {
// if the ReturnCode is not associated with any rate_denom, use default
// Sampling rate varies by return code; events to log are chosen randomly, with a
// probability proportional to the sampling rate.
constexpr const char DEFAULT_SUBSAMPLING_MAP[] = "default:1 0:100 7:10";
constexpr const char DEFAULT_SUBSAMPLING_MAP[] = "default:8 0:400 2:110 7:110";

std::unordered_map<int, uint32_t> resolv_get_dns_event_subsampling_map() {
    using android::base::ParseInt;
+6 −5
Original line number Diff line number Diff line
@@ -935,15 +935,16 @@ class ScopedCacheCreate {
}  // namespace

TEST_F(ResolvCacheTest, DnsEventSubsampling) {
    // Test defaults, default flag is "default:1 0:100 7:10" if no experiment flag is set
    // Test defaults, default flag is "default:8 0:400 2:110 7:110" if no experiment flag is set
    {
        ScopedCacheCreate scopedCacheCreate(TEST_NETID, "");
        EXPECT_EQ(resolv_cache_get_subsampling_denom(TEST_NETID, EAI_NODATA), 10U);
        EXPECT_EQ(resolv_cache_get_subsampling_denom(TEST_NETID, EAI_OK), 100U);
        EXPECT_EQ(resolv_cache_get_subsampling_denom(TEST_NETID, EAI_AGAIN), 110U);
        EXPECT_EQ(resolv_cache_get_subsampling_denom(TEST_NETID, EAI_NODATA), 110U);
        EXPECT_EQ(resolv_cache_get_subsampling_denom(TEST_NETID, EAI_OK), 400U);
        EXPECT_EQ(resolv_cache_get_subsampling_denom(TEST_NETID, EAI_BADFLAGS),
                  1U);  // default
                  8U);  // default
        EXPECT_THAT(resolv_cache_dump_subsampling_map(TEST_NETID),
                    testing::UnorderedElementsAreArray({"default:1", "0:100", "7:10"}));
                    testing::UnorderedElementsAreArray({"default:8", "0:400", "2:110", "7:110"}));
    }
    // Now change the experiment flag to "0:42 default:666"
    {