summaryrefslogtreecommitdiff
path: root/tools/stats_log_api_gen/main.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-08-03Update stats-log-api-gen 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: If4a130e4728c4ffd632c76b6999e9a3da9b21f0c Change-Id: Icddf5ef21155ede50319fc2bf7c8a361eeb09539
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-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-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-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-06Merge "Remove libstatslog from libstatsmetadata" into rvc-devMuhammad Qureshi
2020-03-05Remove libstatslog from libstatsmetadataMuhammad Qureshi
Instead of relying on the constants in libstatslog, hardcode them in atoms_info to get rid of the dependency on libstatslog New generated atoms_info.cpp: https://paste.googleplex.com/5779947622760448 Bug: 150417465 Test: m libstatsmetadata Change-Id: I954c963f1883f889053b63d308c648548de71e56
2020-03-05Delete unused code in stats-log-api-genMuhammad Qureshi
Bug: 145100015 Test: m Change-Id: Idbbe35fbce0d751a5973128406596678e1ead5d3
2020-01-29Generate compile-time Q-compatible StatsLogMuhammad Qureshi
Bug: 148388745 Test: m NetworkStack Test: m NetworkStackNext Change-Id: Ic37bb67ce625d0a583c424d4775e9f0fa132c418
2020-01-23Add 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 Merged-In: Icce2f6ed7298be5e5ceebfb05d87e6fa7cd6bdbb
2020-01-08Add --supportQ flag to java StatsLog codegenMuhammad Qureshi
Add support to generate Q schema code generation only for modules that ship to Q. Bug: 145606209 Test: m Test: flashes successfully Test: adb logcat "*:S statsd:*" Change-Id: I978ac321415f1e8d76e4ec73445894965845aaea Merged-In: I978ac321415f1e8d76e4ec73445894965845aaea
2020-01-08Support new socket schema in native codegenMuhammad Qureshi
New code generation implementation is flag guarded by STATS_SCHEMA_LEGACY Support for Q schema can be added by passing --supportQ flag in stats_log_api_gen. (Only needed for statslog_resolv.cpp) Q schema is supported through StatsEventCompat. Generated R schema statslog.h: https://paste.googleplex.com/4986214782337024 Generated R schema statslog.cpp: https://paste.googleplex.com/4856851575341056 Generated R schema statslog_resolv.h: https://paste.googleplex.com/6062978921136128 Generated R schema statslog_resolv.cpp: https://paste.googleplex.com/4752329251225600 Generated Q schema statslog.h: https://paste.googleplex.com/4766729873915904 Generated Q schema statslog.cpp: https://paste.googleplex.com/5018563779756032 Generated Q schema statslog_resolv.h: https://paste.googleplex.com/5338897498243072 Generated Q schema statslog_resolv.cpp: https://paste.googleplex.com/5191011011657728 Test: m -j Test: flashes successfully Test: adb logcat inspection Change-Id: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab Merged-In: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab
2020-01-08Move 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 Merged-In: I56ef3cc4ea1fbd2cd0130d4e9576b242efb9f627
2020-01-08Use StatsEvent in Java autogenerated codeMuhammad Qureshi
The change is guarded by STATS_SCHEMA_LEGACY flag in the autogenerator Android.bp. The flag can only be removed once rest of statsd switches over to the new socket schema. The new autogeneration uses StatsEvent for both Mainline module clients and the default platform client. For Mainline modules, the autogenerated code uses a runtime dessert version check to use new socket schema on R+ platforms and the legacy schema on the older platforms. The legacy schema is encapsulated in a separate autogenerated inner class called QLogger. generated DocumentsStatsLog.java: https://paste.googleplex.com/4665805503463424 generated StatsLogInternal.java: https://paste.googleplex.com/5955095055302656 generated android_util_StatsLogInternal.cpp: https://paste.googleplex.com/6737331711115264 Bug: 142811546 Test: m -j && m -j DocumentsUIGoogle Test: Flashes successfully and events are logged to statsd Change-Id: I4c804eaf4d5ae78001146c89ebe46dfb0a453853 Merged-In: I4c804eaf4d5ae78001146c89ebe46dfb0a453853
2019-06-05Blacklist truncated atoms instead of whitelistnigTej Singh
We used a whitelist to determine which atoms should have their timestamps truncated to the nearest 5 minutes. This changes the logic to a blacklist so that we can get fine grained timestamps from vendor and mainline atoms. Also reserves a range for atoms that need to be truncated in the future. Bug: 134574701 Test: inspected generated statslog.cpp file to make sure it had the correct blacklist Test: testdrive on ScreenStateChanged to ensure timestamps are preserved when they should be Test: testdrive on CallStateChanged to ensure timestamps are truncated when they should be. Change-Id: Id3468542c830cdf41395a94c77f7df0b46cd11b7
2019-04-09stats_log_api_gen: Minor printf format fixGreg Kaiser
We use "%zu" for a size_t argumet. Test: TreeHugger Bug: 126134616 Change-Id: I02916829dfb71a63f78eda0d45129b4dc0732a82 Merged-In: I02916829dfb71a63f78eda0d45129b4dc0732a82 (cherry picked from commit f87e93835a9cbebec2a46124f0f0b7e967de0d52)
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-26Report the last atom tag, uid in the case of log loss.Yao Chen
Test: manually tested and existing statsd_test Change-Id: I8cea9e09c4c069ec234fc0d989d550886605449b
2019-03-23Merge "Mainline logging to statsd: native static libs"TreeHugger Robot
2019-03-20Public StatsLog API for generic mainline logging.Tej Singh
Sets up a public api for logging atoms to statsd. The API excepts a buffer which is already encoded in the proper format for the socket, as well as the number of bytes of the buffer to write. It performs a JNI call to perform the socket write. Autogenerated app code will be built for each mainline module that needs to use this API to log. Test: builds Test: existing logs flow properly Bug: 126134616 Change-Id: I8a9a91e638d730e3ff69cb9345692e49e0db3c96
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-09Merge "Generate constants for enum values in cpp header"Muhammad Qureshi
2019-02-06Generate constants for enum values in cpp headerMuhammad Qureshi
This is the C++ counterpart of the enum generation for Java done in ag/I1ad19b86e28d0df0f8c15d4c995d101423cff4c2 Bug: 120990429 Test: builds successfully, logged one of atoms with an enum in C++ code and verified statsd logcat Change-Id: I2c1452c0590aecdef0dbede6d88014c748e6509e
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
2019-01-10Add a struct wrapper for bytes fields in stats_log cpp APIs.Yao Chen
To avoid conflict between statslog.write() function signatures for Atom1 { Foo foo = 1 [logMode=bytes]; } and Atom2 { string bar = 1; int64 arg2 = 2; } Bug: 122571213 Test: manually tested with new atoms. Change-Id: Ied0f0bd81cef8d0964f571e921f47022301157d9
2019-01-09Merge "118395019: Hide constants and methods in StatsLogInternal" am: ↵Adrian Roos
0a5f26376f am: d6393758a7 am: 9e9899720c Change-Id: I7814e47f241fc433c5baa5d45b630088e5b8876b
2019-01-08118395019: Hide constants and methods in StatsLogInternalTor Norbye
This CL updates the code generator which creates the hidden StatsLogInternal class to explicitly hide the generated constants and write methods as well. The intent of this class was for everything to be hidden, but it turns out that public methods and fields in hidden classes which are extended by a public class also ends up in the SDK, even though they don't appear in the signature file. StringBuilder#setLength(int) is an example of this. Bug: 118395019 Test: make sdk Change-Id: I97e510e8155ee50ade653f6abeb5479c7ca9029d
2018-12-20Merge "Statsd: Enable host_supported for libstatslog" am: 0d7970f4e9 am: ↵Jack He
46efaea281 am: b60a7cdc07 Change-Id: I59c5e4c8e27d31ba38af827162e0adb50fc183b1
2018-12-20Statsd: Enable host_supported for libstatslogJack He
* libutils must be used as a static library when compiled on host * Host does not have Android system properties and hence we cannot use <cutils/properties.h>. In fact, properties.cpp is not even compiled on host for libcutils. Therefore, this CL adds a check for __ANDROID__ macro before including <sys/propoerties.h> and before calling properties_get_bool() * On host, statsd logging will be disabled since host does not use statsd for anything Fixes: 121294178 Test: test drive statsd Change-Id: I838ff02468c650c5f7d85e68fa5008b98f08ce8c
2018-12-15Add byte size of the bytes fields to statslog c++ APIs.Yao Chen
The proto binary data can contain '\0's and in the native layer, the current liblog api would convert that into string and thus the data is truncated. This CL adds a "size_t bytes_field_len" after the bytes fields so that we can correctly pass the data from JAVA to native. Java StatsLog.write() APIs remain the same Bug: 120635548 Test: test_drive with atom 103 Change-Id: I34f1c4ddd6a4ec5f3604b0c67a47a5399e3c6ddd Merged-In: I34f1c4ddd6a4ec5f3604b0c67a47a5399e3c6ddd (cherry picked from commit 1fe9f594984b47144b958f0ac423eeffc56b62ea)
2018-12-15Skip writing message field in an atom if it's emptyYao Chen
Test: unit test added Bug: 120635548 Change-Id: I825b1ce526944a20fe65705508ad180ece37492c Merged-In: I825b1ce526944a20fe65705508ad180ece37492c (cherry picked from commit 8e6f9983009eadf32d05ad65e38906d3985bc9ba)
2018-12-15Allow 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 Merged-In: If53dd95c5826710c76d7fe982bf951a435dfc738 Fix: 118386797 Bug: 120635548 Test: unit test & manual test (cherry picked from commit bbdd67d19f4912fbec00220b22e44c68eff5ab3f)
2018-12-06Add byte size of the bytes fields to statslog c++ APIs.Yao Chen
The proto binary data can contain '\0's and in the native layer, the current liblog api would convert that into string and thus the data is truncated. This CL adds a "size_t bytes_field_len" after the bytes fields so that we can correctly pass the data from JAVA to native. Java StatsLog.write() APIs remain the same Test: test_drive with atom 103 Change-Id: I34f1c4ddd6a4ec5f3604b0c67a47a5399e3c6ddd
2018-11-29Skip writing message field in an atom if it's emptyYao Chen
Test: unit test added Change-Id: I825b1ce526944a20fe65705508ad180ece37492c
2018-11-09Pass the last error code when statslog.write failsYao Chen
The error code will give us some clue on what caused the loss (e.g., EBUSY, or ENOENT) Test: manual Bug: 80538532 Change-Id: I446c6e2255bdae063dfb8803ad0b702ead87c645
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-09-27Support int32_t (Java Integer) in KeyValuePair atomHoward Ro
Bug: 116826451 Test: statsd_test + manual verification through logcat Change-Id: I0157c22033907fea46e26ee4262c723fa8c0b518
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-22Add more accurate logging for stats log loss.Yao Chen
+ Only record eventual failure after the retries to get a accurate log loss count. + Record all types of failures which lead to log loss + Change the timestamp from elapsedRealtime to wallclock time for easier debugging server side + Also log the count too. Bug: 80538532 Test: manually tested Change-Id: I4fcccae3fa39c9e280a842e27c6432bb0a090b85
2018-06-07Merge "Disable statsd and make StatsLog no-op if ro.statsd.enable=false" ↵Yao Chen
into pi-dev am: 38b92986df Change-Id: Ia90bed14900a2c944165aefe00661d3979c08aed
2018-06-06Disable statsd and make StatsLog no-op if ro.statsd.enable=falseYao Chen
Bug: 79324611 Test: manually tested on marlin_svelte Change-Id: Ic7fbf86d7c295cb6b2f20e7f9a957d1ed74c42c0
2018-06-05Wean statsd off batterystats: workchain (cp)Bookatz
Modified cherry pick from master: (cherry picked from commit d888df2ba99e117b50a5553e18426ad370294a20) covering ag/4210168 and ag/4230692. The tool that generates StatsLogInternal.java now includes the following type of code, to accomodate WorkSources automatically. public static void write(int code, WorkSource ws, int arg2) { for (int i = 0; i < ws.size(); ++i) { write_non_chained(code, ws.get(i), ws.getName(i), arg2); } ArrayList<WorkSource.WorkChain> workChains = ws.getWorkChains(); if (workChains != null) { for (WorkSource.WorkChain wc : workChains) { write(code, wc.getUids(), wc.getTags(), arg2); } } } This will reduce a lot of code repitition for the StatsLog.write calls in BatteryStats. Consequently, doing so will make it easier to remove these StatsLog.write calls out of BatteryStats. Bug: 80308558 Bug: 80314737 Test: manual verification Test: com.android.internal.os.BatteryStatsTests Change-Id: Ied537a6195121f16ef49b6bccf58c8c31964909c Merged-In: Ibd28297345f4ab926dec01a89de0f1bfff9f8871
2018-04-20Allow StatsLog to directly write to statsd's socket.Yao Chen
+ Reuse the log_event_list from liblog. StatsLog's binary format remains unchanged + Copied socket write code from liblog, including the retry logic. + Added build flags to control the StatsLog channel (logd, statsd, or both for debugging) Bug: 78239479 Test: locally tested and saw logs being written to statsd Change-Id: I7b1f0069ead00bbf3c29e4bd5b7f363a7ce26abe
2018-04-10Logd retry throttling.Yangster-mac
Test: statsd test BUG: b/77852322 Change-Id: I3b4c46aaa592e21bfed13330c2ca72fac8e8320a