summaryrefslogtreecommitdiff
path: root/tools/stats_log_api_gen/Collation.cpp
AgeCommit message (Collapse)Author
2020-12-12Migrate to frameworks/proto_logging/statsBaligh Uddin
BUG: 175318992 Test: TH Merged-In: Ia6463c8f6a801cd9db54afa30df0aa3f16b09891 Change-Id: I81324b83802dc2b06081600282bb73491f29473b Exempt-From-Owner-Approval: cleanup CL
2020-11-24Revert^2 "Delete atoms.proto from statsd"Jeffrey Huang
217301c36f7ffd500441cb879a4fa88b770092db Change-Id: I81a8287ed5b055e7b6547794d01e7ac897f0f022
2020-11-24Revert "Delete atoms.proto from statsd"Alex Light
Revert "Add android bp to proto_logging" Revert submission 13070789-atomsproto Reason for revert: Breaks multiple git_master-without-vendor targets ``` out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp error: frameworks/base/tools/stats_log_api_gen/Android.bp:49:1: "stats-log-api-gen-test" depends on undefined module "libstats_proto_host" ninja: build stopped: subcommand failed. ``` Reverted Changes: I184cf8bf8:Add android bp to proto_logging I36ec354d2:Delete atoms.proto from statsd Bug: 167962588 Change-Id: Idce97c5cf020473744eb7f96dcfbdc7677c094da
2020-11-23Delete atoms.proto from statsdJeffrey Huang
Use the atoms.proto in proto_logging as the source of truth. Also migrates statsd log api gen to use the new atoms.proto Bug: 167962588 Test: m -j && m CtsStatsdAtomHostTestCases Change-Id: I36ec354d273dceace5245d7634c68ac63dc5a8cd
2020-07-31Update stats-log-api-gen source based off of google3 presubmit checksSalud Lemus
Bug: 161812407 Test: `m statslog-framework-java-gen` Test: `m statslog-telephony-java-gen` Test: `m stats-log-api-gen-test && out/host/linux-x86/nativetest/stats-log-api-gen-test/stats-log-api-gen-test` Change-Id: Id68982e306fbc379ed8e90b33a38b8a6604e66ad
2020-07-07Added support for pulled atoms for stats-log-api-genSalud Lemus
Currently, stats-log-api-gen allows statsd clients to send events for pushed atoms to statsd using a simple auto-generated function call. Allow support for pulled atoms so that clients no longer have to hand-construct StatsEvent objects by calling StatsEvent write methods directly and also making sure that the appropriate annotations are added. This support is for Java clients only for now. Bug: 160368804 Test: Ran `m statslog-framework-java-gen` and completed successfully Test: Ran `m` and completed successfully Test: Ran `m stats-log-api-gen-test && out/host/linux-x86/nativetest/stats-log-api-gen-test/stats-log-api-gen-test` Test: Ran `atest CtsStatsdHostTestCases:android.cts.statsd.atom` and all passed except for CTS tests related to a SIM card because the testing device does not have a SIM card Change-Id: Ie2cbb298690ce71ff7fe7457b17b9d7bdbb24f6b
2020-06-18Remove libstatsmetadataMuhammad Qureshi
Remove kWhitelistedAtoms usage in MetricsManager and remove: - atoms_info references from statsd - libstatsmetadata usages from statsd - libstatsmetadata library - atoms_info_writer.h/.cpp - references to atoms_info in rest of stats-log-api-gen - allow_from_any_uid annotation Fixes: 147600720 Fixes: 154856835 Fixes: 148993016 Test: m stats-log-api-gen Test: m stats-log-api-gen-test && out/host/linux-x86/nativetest/stats-log-api-gen-test/stats-log-api-gen-test Test: m statsd Change-Id: I2e0579609ff257da934b95cdda397f3ca0ffa1f0
2020-04-17Remove kMaxPushedAtomId from atoms_info.Muhammad Qureshi
Hardcode kMaxPushedAtomId in StatsdStats. Bug: 154164020 Test: bit statsd_test:* Change-Id: Ibca731d9783686a9e3caf0ad580e1d62038d68e2
2020-04-03Make state_option top-level boolean annotationsMuhammad Qureshi
- 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
2020-03-26Group annotations for the same atom idMuhammad Qureshi
Group annotations for the same atom id inside one if-block in generated code. Use shared_ptr to store AtomDecls in multiple data structures. Store a mapping of field numbers to atoms that have annotations at corresponding field numbers in Collation.h Bug: 151744250 Test: stats-log-api-gen-test Test: m stats-log-api-gen Test: m libstatsmetadata Test: m statslog-framework-java-gen Test: m libstatslog Change-Id: I874696cfb5c27141017b4293bec809ab510ceb98
2020-03-24Run clang-format in stats_log_api_genMuhammad Qureshi
Bug: 152253223 Test: m stats-log-api-gen Test: stats-log-api-gen-test Change-Id: Iad76baea8cc9ae7b3978f1133ab94d8e96bbbafe
2020-03-24Add truncate_timestamp annotationMuhammad Qureshi
Mark privacy-sensitive atoms with truncate_timestamp annotation. Factor out annotation collation to a helper method. Add truncate_timestamp annotation support in stats-log-api-gen. Add writeAnnotation* calls in Java and native generated code for atom id annotations. TODO: remove kTruncatingTimestampAtoms from atoms_info. TODO: use truncate_timestamp annotation inside statsd. Bug: 151111680 Test: stats-log-api-gen-test Test: m statslog-framework-java-gen Test: m libstatsmetadata Change-Id: I3db5f4ffbf959bd36c62f890cc88606912798d40
2020-03-20Remove kBytesFieldAtoms from atoms_infoMuhammad Qureshi
Bug: 150415347 Test: m Test: bit statsd_test:* Change-Id: I2e55b445121a39e3bf12164cd9123561e8b5bd4c
2020-03-17Store annotation during collationMuhammad Qureshi
- Only collate atoms in the specified module. - Replace signature_to_modules with signatureInfoMap. This maps each signature to another map keyed by field number and whose values are vector of annotations. Bug: 151102006 Test: stats-log-api-gen-test Change-Id: I25bbe4883c8f7f86a06d04d27cd425367b6d65a0
2020-03-05Support multiple module annotations per atomMuhammad Qureshi
Bug: 150864291 Test: m stats-log-api-gen-test && out/host/linux-x86/nativetest/stats-log-api-gen-test/stats-log-api-gen-test Change-Id: Ibf8869078c6f1eae13e687f0196d6ed91ec35c64
2020-03-05Fail if there are repeated fields in atoms.protoTej Singh
Repeated fields arent allowed outside of attribution node and key value pairs, so we should fail to build if someone attempts to add one. Bug: 149956370 Test: atest stats-log-api-gen-test Change-Id: I0caa6fcf74dabe8e962360ecccfd3a87fcaa4909 Merged-In: I0caa6fcf74dabe8e962360ecccfd3a87fcaa4909
2020-02-03Merge "Allow default state, reset state, and nesting for binary states"Christine Tsai
2020-01-17Add flag to stats-log-api-gen for WorkSource.Muhammad Qureshi
As part of getting rid of StatsLogInternal and moving every atom to be logged from a module, this CL addresses 2 issues: 1. Add WorkSource logging to modules. 2. Gate WorkSource logging via a CLI flag to prevent WorkSource methods from being included in modules that are Mainline modules and can't have @hide calls. Bug: 147541828 Test: m Test: atest android.cts.statsd.atom.UidAtomTests Change-Id: Icce2f6ed7298be5e5ceebfb05d87e6fa7cd6bdbb
2020-01-16Allow default state, reset state, and nesting for binary statestsaichristine
Every state atom can have a customized default state and reset state by annotating atoms.proto. Binary state atoms (such as WakelockStateChanged) can turn on nested counting by annotating atoms.proto as well. Generated atoms_info.h before change: https://paste.googleplex.com/4626190063108096 Generated atoms_info.h after change: https://paste.googleplex.com/5410938863747072 Generated atoms_info.cpp before change: https://paste.googleplex.com/5726061016907776 Generated atoms_info.cpp after change: https://paste.googleplex.com/5540983737417728 Test: bit statsd_test:* Change-Id: I845616f103e013a7927de869b8e8228cfb244090
2020-01-13Allow first uid in attribution chain as primary fieldtsaichristine
Test: bit statsd_test:* Bug: 142108433 Change-Id: I6a2f8e6198765d4205dac95e5f54666496b78808
2020-01-02Rename log_from_module to moduleMuhammad Qureshi
Bug: 145951577 Test: m Test: flashes successfully Test: inspect adb logcat "*:S statsd:*" Change-Id: I4f5fedb63f1d4c743d8dd474f14950c7f36c6999
2019-12-17Move statsd metadata from statslog to atoms_infoMuhammad Qureshi
Clients don't need to know about statsd metadata. Extract out metadata from statslog.h/cpp into atoms_info.h/cpp which is only used by statsd. Generated atoms_info.h: https://paste.googleplex.com/6303016724463616 Generated atoms_info.cpp: https://paste.googleplex.com/5717940978581504 Test: m -j Test: old metadata in statslog matches the metadata in atoms_info Test: Flashes successfully Test: adb logcat "*:S statsd:*" Change-Id: I56ef3cc4ea1fbd2cd0130d4e9576b242efb9f627
2019-04-06Java code for mainline modules to log to statsd.Tej Singh
Adds support for generating app code to allow java mainline modules to call the StatsLog.writeRaw public API. Supports primitives, enums, attribution chains, MODE_BYTES. Does not support key value pairs, worksource methods (because worksource uses hidden apis in the worksource object). Test: manually tested atom logging from DocumentsUI Test: existing autogenerated code is not modified Test: cts will follow Bug: 126134616 Change-Id: Ia321cf2d9952e3875ed0c7a28db1f4113711513f
2019-03-15Mainline logging to statsd: native static libsTej Singh
Creates an annotation to specify if an atom needs to be logged from a specific mainline module. Creates options in stats-log-api-gen so that if the same module name is passed in, cpp/h files will be generated with only those atoms that are specified. These files can be used to create a static library per mainline module to log to statsd. Test: builds Test: atest stats-log-api-gen-test Test: does not affect existing shared libstatslog Test: manually created a static lib for netd and used it to log to statsd. Used testdrive to validate the data was properly flowing. Bug: 126134616 Change-Id: I78064f81fb4971eede8e97dacce5424e3eefd8bb
2019-02-06Add whitelist atom field optionAndrei Onea
Whitelisted atoms can be triggered from any source Test: stats-log-api-gen-test Bug: 119217680 Change-Id: Ia5faed04d696b59ba4ffaab13f5046f943d8a8b7
2018-10-24Allow atoms to log fields in bytes format.Yao Chen
There are an increasing number of requests to log data in complex format to statsd, while the data is not expected to be parsed or aggregated by statsd and only to be uploaded as events. Instead of making an exception for each of these cases in a hard coded way, this CL add a feature to annotate these field in atoms.proto and the stats-log-api-gen tool will produce byte array interfaces for them. Note that log_msg does not have byte array type, and only has string type, when statsd receives the log, these fields are in string type. Only when the atom is written to proto, we will check if this field should be bytes field and write it to protobuf in message format. Change-Id: If53dd95c5826710c76d7fe982bf951a435dfc738 Fix: 118386797 Test: unit test & manual test
2018-10-13Make state atom field annotation name consistent between google3 and android.Yangster-mac
Test: statsd test Fix: b/117681672 Change-Id: I3b0145516c594cc23565df67acc1cfa9f79d306e
2018-09-10allow use of atom definition outside of atoms.proto in pulled atomsChenjie Yu
There will be followup cls to add support of new types that can be nested and repeated. + skip StatsLog.write signature generation for pulled atoms. Bug: 113872139 Test: manual test Change-Id: I69d0ee0b2fe8e286e48eac20ec2c8b280c477bf0
2018-09-07Interface of writing key value pair atom to socket and parsing from statsd.Yangster-mac
Test: statsd unit test BUG: b/114231161 Change-Id: I3543900934b5e8e0677bf1e7cc454d61064a2475
2018-08-19Create log event from key value maps.Yangster-mac
BUG: b/112816333 Test: statsd test. Change-Id: Ib66f06186abfacd77807436379e1e142a5b87c99
2018-03-16Add uid field annotation in atoms.proto and statd memory usage optimization.Yao Chen
[memory] statsd binary size from 664k -> 600k memory usage 1978k -> 1813k (with no configs) + Avoid initialize any static map in statslog.h to avoid many copies of the map in each include. - Do it in cpp so that it is initialized only in places that use them [Uid annotation] + Uid annotation is needed for extracting uid from dimension for UidCpuPuller. + After the change, stand-alone uids don't need to be in field 1 anymore. + Also added exclusive bit annotation in AppDied + Currently only allow one uid field in an Atom. This is to keep things simple until we find an exception. Test: statsd_test Bug: 73958484 Bug: 72129300 Change-Id: I8a916d5c00d5930e24ae7e0825a57dea19c0e744
2018-02-21Add annotation to atoms that represent a state change in atoms.protoYao Chen
+ 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
2018-01-15Stats log interface for single node attribution chain.Yangster-mac
Usually the input parameters for attribution chain is list of int64/string. The new c++interface takes one int64 and one string as input and write as a single node into logd. This will help avoid allocating temp objects in battery stats java code. Test: all statsd unit test passed. Change-Id: Ia0f7f26b71a570bd3628c42726a5afb0a500d073
2018-01-011/ Support nested message and repeated fields in statsd.Yangster-mac
2/ Filter gauge fields by FieldMatcher. 3/ Wire up wakelock attribution chain. 4/ e2e test: wakelock duration metric with aggregated predicate dimensions. 5/ e2e test: count metric with multiple metric condition links for 2 predicates and 1 non-sliced predicate. Test: statsd unit test passed. Change-Id: I89db31cb068184a54e0a892fad710966d3127bc9
2017-12-15Stats log api for attribution chain.Yangster-mac
Test: all unit test passed. Change-Id: I628d409e517f4f95c8da1d0c7fd4d514c1d9196d
2017-10-31Generate constants for enum values.Stefan Lafon
Test: Builds successfully, tests pass and statsd works (it seems). This will allow us to use those constants instead of literals. The generated code only augmentes the java constant file. If needed, the same can be done for the C++ file. Some of the constant names are very long, but this is due to enum value names that are unnecessarily redundant with the enum names, i.e. enum ENUM_NAME { ENUM_NAME_UNKNOWN = 0; ENUM_NAME_VALUE1 = 1; ENUM_NAME_VALUE2 = 2; ... } which can be fixed by avoiding the 'ENUM_NAME_' part in the value names above. So, when possible, we should use shorter value names in stats_events.proto. Change-Id: I1ad19b86e28d0df0f8c15d4c995d101423cff4c2
2017-10-17Revert "Revert "Start auto-generating the stats log API.""Yao Chen
Test: builds successfully This reverts commit 931945399859ab91545ba2c2a914f044092d5e2e. Change-Id: I22bca4a32adf86040b9d72ad5b45999aba28f586
2017-10-16Revert "Start auto-generating the stats log API."Joe Onorato
This reverts commit b81d1a7b9a38dcb4d356ae3435a82fb52ba7d585. Change-Id: I189684d8913ffffca42d9514ac88ea5cc4a44f05
2017-10-15Start auto-generating the stats log API.Joe Onorato
Both native and java bindings. TODOs: - Finish WorkSources. - Clean up the package names for the protos. - Put the protos in a more suitable location. Test: stats-log-api-gen-test Change-Id: Idf4022225e2be05106dbcf7de8e97a3337fc63e2