Anomaly alarms, which are used for prediction-base duration metric
anomaly detection, currently use alarm manager for setting alarms. This
can result in excessive binder calls to SCS to set/cancel the alarms if
the duration metric that the alarm is based on gets stopped/started in
quick succession.
To resolve this without losing precision, we can instead rely on the
flow of events into the statsd socket for this prediction. The socket
receives events very frequently, so there should be minimal (if any)
loss of precision, and we can remove the binder call entirely.
One concern is that we used to hold a wakelock when the alarm fired
(since alarm manager would hold a wakelock), and we now lose this
ability.
Test: atest statsd_test
Test: atest AnomalyDetectionTests
Bug: 161326200
Bug: 152642091
Change-Id: If37e5c6ccd8efa4e822c70a0444fa6b5a31bebca
Merged-In: If37e5c6ccd8efa4e822c70a0444fa6b5a31bebca
See https://source.android.com/setup/contribute/respectful-code for reference
BUG=161896447
Test: make (change is only comments + 1 log message)
Change-Id: I8a21ef4ce19c517853388d8f7542f3a0cf8d91d5
Merged-In: I26ef8e079bf13f19bdc3bbc8219f572a43b68090
Right now, if an alarm fires exactly on time (within 1 second), or
exactly on a multiple of its period, statsd will reset the alarm for the
same time, which can result a loop of statsd setting an alarm, the alarm
firing, statsd setting an alarm at the same time, etc.
The fix is that if an alarm fires on time, we should move to the next
period.
Test: atest statsd_test (added to a test, which would fail without the
code change)
Bug: 159098080
Change-Id: I150538cb1d3d5a2b943df2a32d92f8f84bb96626
Merged-In: I150538cb1d3d5a2b943df2a32d92f8f84bb96626
Right now, if an alarm fires exactly on time (within 1 second), or
exactly on a multiple of its period, statsd will reset the alarm for the
same time, which can result a loop of statsd setting an alarm, the alarm
firing, statsd setting an alarm at the same time, etc.
The fix is that if an alarm fires on time, we should move to the next
period.
Test: atest statsd_test (added to a test, which would fail without the
code change)
Bug: 159098080
Change-Id: I150538cb1d3d5a2b943df2a32d92f8f84bb96626
Previously, if the condition was unknown for the entire bucket, the
bucket would be annotated with a NO_DATA rather than being dropped
because CONDITION_UNKNOWN. This updates all the buckets to be dropped
due to CONDITION_UNKNOWN. Note that this will make the condition unknown
problem appear worse, when in reality it is making our bucket drop
reasons more correct and should not have any impact on the true
CONDITION_UNKNOWN.
Also fix an issue where a test was failing due to a previous test
leaving data persisted to disk. This fix is a hack for now, and should
be properly fixed later.
Bug: 158897179
Test: atest statsd_test
Change-Id: Ic703600d37aa1873ec67cb1a279dcf349d48fc9f
Use vector<int> instead of vector<bool>.
vector<bool> is not thread-safe:
https://en.cppreference.com/w/cpp/container#Thread_safety
Fixes: 156690351
Test: atest --iterations=500
statsd_test:MultiConditionTrigger#TestMultipleConditions
Change-Id: I9121747ffbee0864afbff993e7fe417104827952
Right now if we receive an invalid config update, we keep the existing
config in memory. This makes us remove the existing config so that we
don't have any config for the invalid config key.
Test: atest statsd_test
Bug: 158617758
Change-Id: I9daecb1c96e3a63fea3a45b07d1295f3b4ba452a
- The current state key was updated to the new state key after the diff
calculations and base setting. There are a few cases where we exit the
current loop which results in the current state key not getting updated.
- When we reset the base, we should not reset the current state. All
instances where hasCurrentState was set to false have been removed.
- I added a unit test for a value metric that is sliced by state and has
a condition.
Bug: 157661456
Test: m statsd_test && adb sync data && adb shell
data/nativetest/statsd_test/statsd_test32
Change-Id: Ib75bd9d08e6785f9e03b4b5984dbdaf86a7e1749
Because non-zero enums are evaluated to true, it is possible for pulls
to occur on bucket split even if the condition is unknown. Explicitly
check that the condition is true instead.
Bug: 155489707
Test: atest statsd_test
Change-Id: I0bc3de6e885c2200885caf01d07c793b83eca17a
SimplePredicates have a configurable initial value that can be set to
unknown or false. Previously, CombinationPredicates and MetricProducers
were automatically initialized with an unknown condition value instead
of being synced with the conditions of the SimplePredicates that they
rely on.
An initial condition cache is used to store initial conditions of
ConditionTrackers after they are initialized.
CombinationConditionTrackers evaluate their initial condition based on
the initial conditions of their child SimpleConditionTrackers.
MetricProducers also use the initial condition cache to set its
condition during initialization.
Added unit tests in SimpleConditionTracker_test to check that
SimpleConditionTrackers have the correct initial conditions based on
what the InitialValue is set to and the condition is updated properly
after the first few condition change events.
Added unit test in MetricsManager_test to check that all
ConditionTrackers and MetricProducers have the correct initial
conditions.
Test: m statsd_test && adb sync data && adb shell
data/nativetest64/statsd_test/statsd_test64
Bug: b/156762672
Change-Id: I9f6088f8c92fb18eb2ca8632aaa338fb0ed8e679
refactor to simplify the condition nesting in flushCurrentBucketLocked
Bug: 157155330
Test: atest statsd_test
Change-Id: Ieff0e8d8d65e1a4c9fc576e68fd7fa912849f806
This can result in more pull failures, but can prohibit slow pullers
from slowing down statsd.
Test: atest GtsStatsdHostTestCases
Test: atest statsd_test
Test: atest FrameworkStatsdTest
Bug: 154056912
Change-Id: Ie30bd3584d808bb11aaaf0fe2057c9adfb198644
Set the current state key to a HashableDimensionKey with -1
(kStateUnknown) for each sliced state atom. Previously, the current
state key was being set to the DEFAULT_DIMENSION_KEY which is an empty
HashableDimensionKey.
Bug: 155487198
Test: make statsd_test && adb sync data && adb shell
data/nativetest/statsd_test/statsd_test
Change-Id: Icaa187ecae599407695d86eec6104d210aa98714
Previous default for InitialValue was FALSE. Currently, no predicates
configure this field.
Added unit tests to test the initial condition changes in Value and
Count metrics.
- ValueMetricE2eTest.TestInitialConditionChanges
- CountMetricE2eTest.TestInitialConditionChanges
Bug: b/156541904
Test: m statsd_test && adb sync data && adb shell data/nativetest/statsd_test/statsd_test
Change-Id: I242bcb0b60455355e699636aae7e620fabc310ef