OSDN Git Service

Add annotation to atoms that represent a state change in atoms.proto
authorYao Chen <yaochen@google.com>
Mon, 19 Feb 2018 22:39:19 +0000 (14:39 -0800)
committerYao Chen <yaochen@google.com>
Thu, 22 Feb 2018 00:46:56 +0000 (16:46 -0800)
commit9c1debe330006b2b4d5c08a55905789c57369609
treeec02b691f65a16d75d5cee817b404012706ea961
parent75c515effa72b2e7af774ee2c513cff7ec1dbd0e
Add annotation to atoms that represent a state change in atoms.proto

+ A state change atom can have one exclusive state field, and any
  number of primary key fields.

  When there is primary key in the atom, it means the state belongs to the primary key.
  For example,
  message UidProcessStateChanged {
    optional int32 uid = 1 [(stateFieldOption).option = PRIMARY];
    optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE];
  }

  When there is no primary key fields in the atom, the state is global.
  For example,
  message ScreenStateChanged {
     optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE];
  }

+ The annotation is consumed by stats_log_api_gen to generate a static map from the state
  atoms to its primary fields, and exclusive fields

+ stats_log.proto is splitted into 2 proto files, because statsd needs proto lite, and c++
  lite proto library cannot properly ignore the field options which requires full proto.

 This CL doesn't change any logic in the statsd yet. A separate CL will use the field option
 information to correctly track the state.

Test: added unit tests in stats_log_api_gen_test. and statsd_test pases.
Change-Id: I9e8a979fe81ba60efd4d854bb7087ce4b2b147ec
39 files changed:
cmds/statsd/Android.bp
cmds/statsd/Android.mk
cmds/statsd/src/HashableDimensionKey.cpp
cmds/statsd/src/atom_field_options.proto [new file with mode: 0644]
cmds/statsd/src/atoms.proto
cmds/statsd/src/guardrail/StatsdStats.h
cmds/statsd/src/logd/LogEvent.cpp
cmds/statsd/src/logd/LogEvent.h
cmds/statsd/src/matchers/matcher_util.h
cmds/statsd/src/packages/UidMap.h
cmds/statsd/src/perfetto/perfetto_config.proto
cmds/statsd/src/stats_log.proto
cmds/statsd/src/stats_log_common.proto [new file with mode: 0644]
cmds/statsd/src/stats_log_util.h
cmds/statsd/src/stats_util.h
cmds/statsd/src/statsd_config.proto
cmds/statsd/src/subscriber/SubscriberReporter.cpp
cmds/statsd/src/subscriber/SubscriberReporter.h
cmds/statsd/tests/FieldValue_test.cpp
cmds/statsd/tests/LogEntryMatcher_test.cpp
cmds/statsd/tests/LogEvent_test.cpp
cmds/statsd/tests/condition/SimpleConditionTracker_test.cpp
cmds/statsd/tests/e2e/Attribution_e2e_test.cpp
cmds/statsd/tests/e2e/DimensionInCondition_e2e_test.cpp
cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
cmds/statsd/tests/statsd_test_util.cpp
cmds/statsd/tests/statsd_test_util.h
cmds/statsd/tools/Android.mk
cmds/statsd/tools/dogfood/Android.mk
cmds/statsd/tools/loadtest/Android.mk
cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java
cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/StatsdStatsRecorder.java
tools/stats_log_api_gen/Android.bp
tools/stats_log_api_gen/Collation.cpp
tools/stats_log_api_gen/Collation.h
tools/stats_log_api_gen/main.cpp
tools/stats_log_api_gen/test.proto
tools/stats_log_api_gen/test_collation.cpp