This CL creates a sendHeartbeat thread that ocassionally sends
heartbeats, consisting of a dataSize of 0, to perfd. perfd will discard
those heartbeats, recheck if the user has canceled the subscription, and
if not, wait for more data from statsd. Sending heartbeats solves two
big problems:
(1) Allows statsd to robustly check if writes to the socket fail because
the read end of the pipe has closed. Previously, if no atoms were pushed
or pulled, statsd never attempted to write to perfd, so statsd could
never detect the end of the subscription. However, now, writes are
regularly made regardless of if statsd receives data. Note that even if
atoms were pushed or pulled, there is no guarantee that they would have
matched the atom matchers sent in perfd's config.
(2) Allows perfd to escape a blocking read call and recheck whether the
user has canceled the subscription. If no data is sent to perfd, perfd
will block in this read call and the AndroidStudio UI will freeze up.
Heartbeats are only sent if statsd has not sent any data to perfd within
the last second, so we do not spam perfd with writes.
+ decomposes the startNewSubscription function
+ prevents startPull from holding the lock while sleeping
Test: atest stastd_test
Test: atest CtsStatsdHostTestCases
Test: manually confirm that AndroidStudio is not freezing
Bug: 153595161
Change-Id: I78f0818e8ed29bdadd02c151444ee7c9555623a4
1. remove old statscompanion counters
2. add outgoing binder call fail counts
3. Add additional pull failure cases
a. No pull uid provider (If a config doesn't register properly)
b. Puller not found - either because it was not registered or because
the client did not specify the correct uids
4. Make metrics own logging pull delays - these were getting overcounted
since both the PullerManager and ValueMetricProducer were logging pull
delays.
5. Move noteEmptyPull to StatsPuller for more uniform logging, instead
of it just being logged in value metric producer.
Test: m statsd
Bug: 154056912
Change-Id: Ia373003905ee44d3b7b37b2bfa1e1d6268250070
- Remove unneeded dependency on atoms.proto
- Remove extractIntoVector function. Assert on actual output directly.
- Use a helper method for creating UidMap mock for all tests.
- Add AttributionChain variants of existing tests in puller_util_tests.
- Add tests in StatsLogProcessor_test to test mapIsolatedUidToHostUid()
in StatsLogProcessor.
Bug: 154285085
Test: bit statsd_test:*
Change-Id: I6d0822be9f0fbca23bd2f441dc63b97110567307
Optionally, accept a std::pair<int, int>* that is populated with the
starting and ending indices of attribution nodes in FieldValues vector.
Bug: 154286011
Test: bit statsd_test:*
Change-Id: I6f19abea7fbb27712b6c2d5a7679aa4f428c191d
Previously, MetricsManagers would unregister themselves as a
PullUidProvider for a given ConfigKey in the destructor. This caused all
pulls to fail after a config update because the new MetricsManager would
register itself before the old MetricsManager was destructed and
unregistered. This resulted in the old MetricsManager removing the new
config since they shared the same config key. The fix is for the
PullerManager to check that the PullUidProviders are equal in the
unregister function before actually erasing it.
Test: bit statsd_test:* (wrote a failing test that now passes).
Test: statsd_localdrive to manually update a config, ensured pulls still
worked.
Bug: 154544328
Change-Id: Id7af3b3b407e24bee74fc34bd1c2b9e0575e9c9e
Also clean up a bit of code on splitting on app upgrades
Piggy-backed off the app upgrade tests, adding parameterized tests to
also test boot complete event.
Refactored some value metric test code to increase code reuse and
assertions.
Fixed a broken value metric test that had assertions commented out.
Refactored NamedLatch into MultiConditionTrigger to avoid creating a
thread before necessary.
Test: atest statsd_test
Test: push a simple test config, reboot, wait, get data. Made sure
the bucket was split
Bug: 144099206
Bug: 154511974
Change-Id: I73858b5db08e8cda762bd8091b30da8738d1fd88
This helps save memory because FieldValues are copied around much more
than LogEvents.
+ removed unused variables from LogEvent
Test: bit statsd_test:*
Bug: 154267590
Change-Id: If444ef79c85a45526fce183b67d9d8a2e74fa10d
Errors are recorded within StatsdStats. The associated CL to change
stats_log.proto within google3 is at cr/306795778.
Test: adb shell dumpsys stats --metadata
Test: bit statsd_test:*
Bug: 144373276
Change-Id: Id80cace9350f77d64a2d401f7fac7b12501e82ee
Use the annotation information in LogEvent/FieldValue instead.
- Initialize nested to true in FieldValue.mAnnotations
- Add filterPrimaryKey function to HashableDimensionKey for populating a
HashableDimensionKey with all FieldValues that have the primary key
annotation set.
- Create StateTrackers without checking if atom is a state atom. (We
can't do this check anymore)
- Remove mAtomId, mStateField, mNested, mPrimaryFields, mDefaultState,
mResetState members from StateTracker. Use the information passed in
LogEvent in onLogEvent instead.
- Update tests to log annotations when logging events.
- Remote kStateAtomsFieldOptions from atoms_info.
- Make MetricProducer::mStateGroupMap const
- Rename handlePartialReset to clearStateForPrimaryKey
- Store "default" states in mStateMap. An entry in mStateMap means the
state is not kStateUnknown. Before, an entry in mStateMap meant the
state is not the "default" state.
- Consolidate all state change logic in updateStateForPrimaryKey()
- remote StateTracker::updateState
- handleReset and clearStateForPrimaryKey call
updateStateForPrimaryKey for resetting and clearing of states
respectively.
- Create a helper method for notifying StateTracker listeners
- Make StateManager::registerListener void
Bug: 151110842
Test: bit statsd_test:*
Change-Id: Ifb8371b213a178fcccaa484086fbdd283dbaec49
This is a sychronizing primitive that is similar to a latch, but a
thread must count down with an identifier. It will be used to make sure
the boot complete, uid map, and all pullers signals are received before
triggering the bucket split.
The latch's countDown operation takes in a string identifier, so that if
the same operation happens twice, it is only counted once.
Bug: 144099206
Test: atest statsd_test
Change-Id: I261a3e50eabbc4998ca30ddf2d67a9a1e788911e
Makes a test mapping for statsd so that unit tests run on presubmit.
Changes to make the tests pass:
1. Require root. This is needed to write to disk, since the tests don't
run as statsd's uid
2. Remove AndroidTest.xml file in favor of the autogenerated one.
3. Remove a check in StatsService.test for getUidFromArgs. The test
checked a failure case where we passed a number bigger than INT32_MAX.
However, on a 32 bit device, strtol will return INT32_MAX when an
overflow happens, since it returns a 32 bit number on a 32 bit device.
4. Refactor a lot of e2e tests to sort dimensions, ensuring that the
dimensions are always in order, instead of relying on implicit ordering
of hashing, which can change.
5. Change a long to an int64 in TestActivationsPersistAcrossSystemServerRestart
Test: statsd_test
Bug: 129613474
Change-Id: I80dfa3bfd50ebe6d2c8c0c3ba201f3ad06b68910
Instead of using the map from atoms_info, we now receive uid information
in the form of StatsEvent annotations. The isUid annotation is exposed
from both LogEvent and FieldValue.
Test: bit statsd_test:*
Test: atest GtsStatsdHostTestCases
Bug: 150414601
Change-Id: Iebbe4ce5668de1ab91485daa1be9197cde6e8309
Abstract test utilities into two new functions: writeAttribution and
parseStatsEventToLogEvent
Bug: 149590301
Test: bit statsd_test:*
&& bit statsd_benchmark:*
Change-Id: I5f77646b6d2d828344b8b6de8777a60d98f96d58
StatsPullerManager should be declared on the heap because wp's can only
point to objects on the heap.
Test: bit statsd_test:*
Test: atest GtsStatsdHostTestCases
Test: atest CtsStatsdHostTestCases
Bug: 153237308
Change-Id: I579375f5bd2db9557f108f39916d69f368865478
- Add AnnotationId enum stats-log-api-gen
- Rename RESET_STATE annotation to TRIGGER_STATE_RESET. Also rename the proto annotation.
Bug: 152412767
Test: stats-log-api-gen-test
Test: m statslog-framework-java-gen
Change-Id: I2c12ea0b9222ef28b8cc11ea36b272e518a96259
After switching to the new socket schema, we can remove certain LogEvent
constructors. AttributionNodeInternal was only used in tests and can be
removed as well.
Bug: 14959031
Test: bit statsd_test:*
Change-Id: Ib5cb6acc50cc4d37a46a076d41face452a0a87d8
StateConditionTracker was previously used as a way to slice by state
through a specific SimplePredicate definition. It is currently being
replaced by StateTracker, and no metrics use StateConditionTracker at
this time.
Bug: 136566566
Test: bit statsd_test:*
Change-Id: I1a14747907c23482a1b7500c6d7f07cd2f1d4aed
- Added #onStateChanged logic to DurationMetricProducer
- Only SUM aggregation type supports state slicing.
OringDurationTrackers now track durations keyed by different state
values.
- Added unit tests for DurationMetricProducer state changes
Test: bit statsd_test:*
Bug: 145838038
Bug: 136566566
Change-Id: I87dcc21bb904ef0fa76ea196d60dadae00f310fa
Merged-In: I735c7deee96639c32cad4b907e59b354dfd98d77