Commit graph

155 commits

Author SHA1 Message Date
Jeffrey Huang
6d99e68e74 Merge "Tag libstatspull and libstatssocket tests as MTS" into rvc-dev 2020-04-23 23:55:31 +00:00
Jeffrey Huang
2f51ad7b86 Tag libstatspull and libstatssocket tests as MTS
create both 32 and 64 bit variants
fixes libstatssocket_test for 32 bit devices

Bug: 154652564
Test: make mts, adb push, adb shell all 4 tests
Change-Id: Ia6b51686c06e786b38cb3713315977533f1bb819
2020-04-22 17:13:24 -07:00
Jiyong Park
a6bcd4817c Set apex_available property
The marked library(ies) were available to the APEXes via the
hand-written whitelist in build/soong/apex/apex.go. Trying to remove the
whitelist by adding apex_available property to the Android.bp of the
libraries.

Exempt-From-Owner-Approval: cherry-pick from AOSP

Bug: 150999716
Test: m
Merged-In: I8fd2a3c9b69454c6018c72f5198898bc90dc4d0d
(cherry picked from commit 937b4bf173)
Change-Id: I8fd2a3c9b69454c6018c72f5198898bc90dc4d0d
2020-04-20 16:35:05 +09:00
Tej Singh
5d8f770b1c Link libc++ statically
Test: bit statsd_test:*
Test: bit libstatssocket_test:*
Test: bit libstatspull_test:*
Bug: 153349659
Change-Id: Ief3d0e062ed3e5cabf5b8b6198510caf3f64eefd
2020-04-06 19:52:03 -07:00
Tej Singh
0d7fb3d260 libstatspull documentation for puller guardrails
Test: atest LibStatsPullTests
Bug: 152543610
Change-Id: Ia5caad7c9307c02fef7d3dfe70998601e7ffeb55
2020-03-30 18:15:05 -07:00
Ruchir Rastogi
e39a7cf021 Merge "Support ERROR_ATOM_ID_INVALID_POSITION" into rvc-dev 2020-03-24 18:47:16 +00:00
Ruchir Rastogi
8056dd129a Support ERROR_ATOM_ID_INVALID_POSITION
Originally, the native implementation would discard everything clients
wrote to the buffer before the setAtomId call. Thus, the atom id was
always placed in the "correct position." However, for consistency with
the Java implementation, we now allow write calls before setAtomId to
occur and log an error in that case.

Test: bit libstatssocket_test:*
Bug: 152119205
Change-Id: Ib109c7a939a5ae92c1d5fc70aa647ac7390fadad
2020-03-24 07:57:51 -07:00
Hsin-Yi Chen
e3bdbfa46c Disable ABI check for libstatspull
The ABI dump for libstatspull can't be built due to the link error.

Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py
Bug: 151102177
Bug: 151694054
Change-Id: Id324890235679b9593995b6e12a60ef055b4c825
2020-03-23 03:45:07 +00:00
Tej Singh
47e5ae49c2 Minor followups from api feedback
Bug: 150788562
Test: m
Change-Id: I3473e49bc3f3682300b036ddeb032c3776d8d830
2020-03-20 12:16:28 -07:00
Tej Singh
c06f147566 Native API feedback for puller API
1. Rename registerPullAtomCallback to setPullAtomCallback
2. Rename unregisterPullAtomCallback to clearPullAtomCallback
3. Change Ns to Millis for consistency with java
4. Swap metadata and callback params in setPullAtomCallback to match
java
5. Added getters for PullAtomMetadata
6. Added libstatspull_test to test PullAtomMetadata
7. Changed the types on setAdditiveFields from int to int32_t

Test: make
Test: atest LibStatsPullTests
Test: bit libstatspull_test:*
Bug: 1507885621
Bug: 151875223
Change-Id: I5cb07bfe71b1002180403828d5e8e6a5b88ce6fe
2020-03-20 11:10:56 -07:00
TreeHugger Robot
5a495becd0 Merge "Enforce permission in native puller API." into rvc-dev 2020-03-19 21:12:52 +00:00
Tej Singh
8196687d39 Enforce permission in native puller API.
Test: m
Test: No security exceptions on boot
Bug: 148955001
Change-Id: If196a82bf5a54ee15557825e16f70b5f64f45412
2020-03-17 11:26:00 -07:00
Ruchir Rastogi
e712eed24c Support atom-level annotations within AStatsEvent
Refactors implementation details to allow for atom-level annotations.
This CL does not change the API surface. addBoolAnnotation and
addInt32Annotation work for both atom-level and proto field annotations.

Test: bit libstatssocket_test:*
Bug: 151158794
Change-Id: I2c340b201aeb3bcddd5cfde171b7c4df1d8d69a4
2020-03-12 15:21:26 -07:00
Jiyong Park
c2a354be68 Merge "don't include liblog to APEXes" into rvc-dev 2020-03-12 04:10:15 +00:00
Jiyong Park
01aa81cec5 don't include liblog to APEXes
liblog is a platform library that provides stable C API. There is no
need to include the library, especialy by statically linking to it, in
any APEX. It not only wastes the storage/ram, but also is incorrect
because the socket interface to logd which is implemented in liblog is
not guaranteed to be stable.

Fixing this issue by converting static_libs: ["liblog"] into
shared_libs: ["liblog"], in which case the dependency to the library
is satisfied via the stub variant of the library.

As a result, we could restrict the availablity of the library to
the platform and the runtime APEX.

Exempt-From-Owner-Approval: already approved when this was in internal
master (ag/10572699)

Bug: http://b/151051671
Bug: http://b/150827719
Test: m
Merged-In: I5aab863cb12b8767b6979255c247000a59355b0e
(cherry picked from commit 95b6f45b0e)
Change-Id: I5aab863cb12b8767b6979255c247000a59355b0e
2020-03-11 18:30:06 +09:00
Ruchir Rastogi
7a287d0751 Use dlsym to load libstatssocket API
Also fixes a bug in the tests where the platform version was being
checked by querying version.release instead of version.codename
(currently, version.release == 10, while version.codename == R).

Test: bit libstatspush_compat_test:* (on Q and R)
Test: libsstatssocket.so is not placed in resolv apex (on R)

1|bonito:/ $ ls apex/com.android.resolv/lib64
libclang_rt.ubsan_standalone-aarch64-android.so
libcrypto.so
libnetd_resolv.so
libssl.so

Test: NETWORK_DNS_EVENT_REPORTED atom is logged to statsd (on R)
    - adb shell cmd stats print-stats (atom 116 count > 0)

Bug: 148743333
Change-Id: Ib3eaa32835905bcf6e3b003054bf0f3c4e7ec0a4
Merged-In: Ib3eaa32835905bcf6e3b003054bf0f3c4e7ec0a4
(cherry picked from commit 9848eb4f1c)
2020-03-09 15:16:11 -07:00
Luke Huang
7452e46ae0 Use libbase to get the elapsed time instead of libutils
To minimize the external library dependencies

Bug: 149721367
Test: atest
Change-Id: I7b79223ad58c2af94d01a35ad39be6cdd1de7f47
Merged-In: I7b79223ad58c2af94d01a35ad39be6cdd1de7f47
(cherry picked from commit cab9854fa9)
2020-03-06 22:09:44 +00:00
Tej Singh
d78f4dab02 Make libstatssocket a shared_lib
Make libstatssocket unable to be linked as a static lib on the platform.

Test: bit libstatssocket_test:*
Test: bit statsd_test:*
Test: atest LibStatsPullTests
Bug: 149340100

Change-Id: I5889dd718536f5f2c693b4c2e7331c9cc2eb2ac9
2020-02-27 11:37:33 -08:00
Muhammad Qureshi
3a40ee5402 //apex_available:platform should be first in list
Test: m
Change-Id: I6ede6f008bc149f587ae2fc024d5869463b2c64d
2020-02-18 17:05:19 -08:00
Ruchir Rastogi
d430c85c52 Merge "Delete stats_event_list from libstatssocket" 2020-02-15 01:34:34 +00:00
TreeHugger Robot
ea37af2c62 Merge "AStatsEvent_overwriteTimestamp" 2020-02-14 23:11:48 +00:00
Ruchir Rastogi
e1cff24259 Delete stats_event_list from libstatssocket
This change is done in internal master because the flag has not been
switched in AOSP, so stats_event_list is still being used there.

Test: m -j
Bug: 145573568
Change-Id: Ica525d0fd731b8d3e9d273ce2220a3d3179d93d9
2020-02-14 13:34:10 -08:00
Howard Ro
f8e70a5bf8 Merge "Expose AStatsSocket_close() from the statsd apex" 2020-02-14 19:43:21 +00:00
Ruchir Rastogi
e41a6c621c AStatsEvent_overwriteTimestamp
Create a function to overwrite timestamp for LogEvent tests. This
function is not exposed outside of the APEX.

Test: bit libstatssocket_test:*
Change-Id: Id0eac485af60e952cc700f7d1231b1b971400982
2020-02-14 10:56:49 -08:00
Muhammad Qureshi
2ebc2e3d8f Expose AStatsSocket_close() from the statsd apex
As part of statsd becoming a Mainline module in R, we need to formalize
the statsd APIs called from outside the statsd apex.

Bug: 145923416
Test: m
Change-Id: I296a018cc93d95bda77d95f8161acbbe983a5d51
2020-02-13 16:16:48 -08:00
Jeffrey Huang
b0a85dc46d Add apex_available to libs
Bug: 145922701
Test: m -j
Change-Id: If5cbe5651e47878520bdc5b943b17a4f72a2a2f3
2020-02-12 18:30:26 -08:00
Ruchir Rastogi
223dadb830 Migrate libstatspull to libbinder_ndk
Since libstatspull will be placed within the APEX, we need to move to
libbinder_ndk.

Test: m -j libstatspull
Test: atest LibStatsPullTests
Bug: 145213327
Change-Id: I86dd6e759efa5eb20bffc76492d5fa72cf279872
2020-02-10 16:07:18 -08:00
Jeffrey Huang
8095e4eef1 Update libstatspull lib
statsd_aidl was updated, so this is the matching change.

Test: m -j
Bug: 148682447
Change-Id: Iec0459cec9f649eb23c6d04b205075fff9b6e911
2020-02-07 12:17:40 -08:00
Muhammad Qureshi
b173a95ae8 Fix native stats_event logging
pass the byte array pointer; not the reference to the pointer.

Also turn on new socket protocol.

Bug: 148909969
Bug: 143979391
Test: m
Test: fastboot flashall
Test: atest android.cts.statsd.atom.UidAtomTests#testLmkKillOccurred
Test: atest LibStatsPullTests
Test: atest GtsStatsdHostTestCases
Change-Id: If7abae5cadb036555540d1b9b5e7f2cabe99beb8
2020-02-05 17:10:46 -08:00
Howard Ro
f49c38beb5 Merge "Expose libstatspull as a stable C API" 2020-02-05 18:28:12 +00:00
Tej Singh
0fca736e6c Add libstatssocket_test to TEST_MAPPING
Test: treehugger
Change-Id: Iddff5df4c498bf7c93e57b1ae214f813920243e1
2020-02-04 16:08:21 -08:00
Tej Singh
a8fd39d83f Expose libstatspull as a stable C API
Libstatspull will ship as a part of the statsd apex in R.

Also update libstatssocket to have version 30 to align with api level,
as per native api council feedback.

Change both libraries to use NDK style naming conventions (AStatsEvent,
AStatsManager), and remove unneeded APIs in libstatssocket.

Remove KeyValuePairs from libstatssocket. KeyValuePairs will not be
supported in native code.

Bug: 147499386
Test: make libstatspull
Test: make libstatssocket
Test: atest libstatssocket_test
Change-Id: Ie79771461215a057529aaac91db95e4334c3960e
2020-02-04 14:07:35 -08:00
Muhammad Qureshi
a37a2bc415 export libstatssocket_headers
Add export_header_lib_headers: ["libstatssocket_headers"]
to libstatspush_compat

Test: m
Change-Id: I70d7a214a5233c6a730b24c9c21b8bd654a78b04
2020-01-30 16:44:53 -08:00
Tej Singh
518d77d208 Register pullers in separate thread
This cl modifies getStatsService to use the blocking getService, but
also makes the binder call in a separate thread to not block the client
thread. This is needed because it is possible for pullers to be
registered before statsd starts, and calling checkService before statsd
is up will fail. We also would never receive the binderDied to register
it, because we would never have a binder object to linkToDeath on.

Bug: 147682855
Test: atest LibStatsPullTests
Change-Id: I68c04bc24c7fe066eca88cab4f6a76885581c1ee
2020-01-15 21:15:26 +00:00
Tej Singh
dab324f6e0 Unregistration of native pullers
Changes the API to return an int instead of a bool.
Creates API to unregister pullers.

Test: atest LibStatsPullTests
Bug: 144373250
Change-Id: I6d395237082337a22f37190343a1fc59703d39bf
2020-01-14 14:37:58 -08:00
TreeHugger Robot
d37759086f Merge "Remove extra indirection in native puller API" 2020-01-10 08:29:37 +00:00
Tej Singh
7e1b190832 Remove extra indirection in native puller API
The indirection is unneeded since we already take a function pointer.

Test: builds
Change-Id: Ice426d7dcb090aaf87a377ede233a4eb18f5eb30
2020-01-09 11:53:53 -08:00
Ruchir Rastogi
21c1f9c314 stats_event.h/c tests
Add unit tests for the native API to log atoms to statsd.

Test: bit libstatssocket_test:*
Bug: 145231901
Change-Id: If427c17319787200260cbe3b71075ca556c9a82b
2020-01-08 14:30:01 -08:00
Automerger Merge Worker
a8cdcadbd2 Merge "Fix bug in stats_event_benchmark" am: 3bf8858105 am: ae9375f13e am: 759c6ff425
Change-Id: I9446a60a7aa33d913d92b13f60690f5b7f903790
2020-01-07 01:13:13 +00:00
Treehugger Robot
3bf8858105 Merge "Fix bug in stats_event_benchmark" 2020-01-07 00:43:49 +00:00
Ruchir Rastogi
d177461a72 Fix bug in stats_event_benchmark
Now, the number of elements in each simulated stats_event is correctly
sampled from a uniform distribution.

Rerunning the benchmarking tests indicates that truncating the buffer
increases the number of cycles require to log an event by only 1.6%.

Test: m libstatssocket_benchmark
Test: bit libstatssocket_benchmark:*
Change-Id: I8d5c1734861038beec8eeb7ce1f84a24bde25a75
2020-01-06 23:10:51 +00:00
Automerger Merge Worker
5310401fe0 Merge "Expose libstatssocket as a stable C API" am: 2ff1eac71a am: 1662e44207 am: dada41d2cc
Change-Id: I33cd016ccbe2ce29b775b7a630c46bc00917114f
2020-01-06 21:41:15 +00:00
Ruchir Rastogi
2ff1eac71a Merge "Expose libstatssocket as a stable C API" 2020-01-06 20:57:55 +00:00
Ruchir Rastogi
5dbcae5020 Expose libstatssocket as a stable C API
We create a .map.txt file that lists all the stable entry points into
libstatssocket. This should allow other APEXes to link to libstatssocket
without having to copy the library within the APEX.

Test: m -j libstatssocket
Bug: 146377784
Change-Id: I9f77a0c380b6884d9ca60807a8974380420cfe0a
2019-12-27 15:04:54 -08:00
Automerger Merge Worker
a318188b70 Merge "Fix error checking in append_string" am: e2e2b2d3d3 am: 33e2002540 am: b2140e1246
Change-Id: I07dabf70064881875b5c6fd7522e9334dac3d8d9
2019-12-20 02:31:11 +00:00
Treehugger Robot
e2e2b2d3d3 Merge "Fix error checking in append_string" 2019-12-20 00:38:25 +00:00
Ruchir Rastogi
3bbc240263 Fix error checking in append_string
Test: m -j
Change-Id: Ifa806d5037acb17f83cbf45712e9795d6f56152f
2019-12-19 14:57:10 -08:00
Ruchir Rastogi
20516da9bc Merge libstatspush_compat and libstatssocket_q
This cleanup makes it clear that there are only two acceptable ways of
logging to the socket: either through libstatspush_compat or
libstatssocket (which will soon be renamed to libstatspush).

Test: m -j
Change-Id: I467b08bc300c2ef394b22422c6acf55a978a380a
Merged-In: I6a49b4995b56df462e1be901ea5e54acfe2e8bac
2019-12-18 17:48:28 -08:00
Ruchir Rastogi
79dd3eaa87 Improve stats_event memory usage
We now truncate the buffer to the appropriate length when clients call
stats_event_build().

Benchmarking tests indicate that truncating the buffer to the
appropriate length increases the cost clients pay to write to the socket
by 2%. This is negligible enough that I decided to truncate the buffer
for both pushed and pulled atoms in order to simplify the API.

Test: m libstatssocket
Test: bit libstatssocket_benchmark:*
Bug: 144126231
Change-Id: I35dec748ff87c0821d0d06779a406997e6e64966
Merged-In: Ife976bb383ecff8de5064730692a95e2a3a82c9d
2019-12-18 17:44:26 -08:00
Ruchir Rastogi
926fa88c35 StatsEventCompat
StatsEventCompat is a wrapper library that toggles between the old
logging scheme and the new logging scheme. It was designed particularly
for the DNS Resolver module and should not be used by others.

We will merge libstatspush_compat and libstatssocket_q in a future CL.

Test: m libstatspush_compat
Test: bit libstatspush_compat_test:* (passes on Q and R)
Bug: 145534143

Change-Id: Ib355031f3573101ea90bd8694861fbfc33b0c788
Merged-In: Idf35ccb6669798166475f08b2fbab40534b5db19
2019-12-18 17:21:27 -08:00
Muhammad Qureshi
a33f81bff5 Remove libstats/Android.bp
subdirs is not needed

Test: m -j
Change-Id: Idc034571eadae9c3135324af45fb4cd404ba8dd2
Merged-In: Ia7675fdf2e9a3a19bc52396ccbcc551556958803
2019-12-18 15:26:02 -08:00
Muhammad Qureshi
6d5a2fc44d Make stats_event write function parameters const
Bug: 143968790
Test: bit statsd_test:*
Change-Id: I413accb10cf3de4c5c49eb06a472168b1171039b
Merged-In: I2660cad5400a0e819c60b9caa706bb66ca2eef4f
2019-12-18 15:20:59 -08:00
Muhammad Qureshi
962cc23b9f Create stats_buffer_writer
Move iovec* construction and noteLogLoss from stats_event_list to
stats_buffer_writer.h.
Expose write_buffer_to_statsd that takes in a byte array and writes
it to the statsd socket. Currently exposed for StatsLog.write JNI call.

This change also allows getting rid of stats_event_list once all clients
have migrated to stats_event

Bug: 145619049
Test: m -j libstatssocket
Change-Id: I73f914985421fc1a4f094982c826bf364604b788
Merged-In: I0048e392c2f5039eb70dacf4e91a43d3f32e8749
2019-12-18 15:15:43 -08:00
Muhammad Qureshi
a3dcefc079 Create libstatssocket_q
Break up libstatssocket into libstatssocket_q and libstatssocket.
libstatssocket_q is for Q Mainline modules.

Bug: 145569088
Test: m -j
Test: bit statsd_test:*
Test: adb shell cmd stats print-logs && adb logcat "*:S statsd:*"
Change-Id: I2978dd544f4cb17714f3d14d5977cf6b46277ef9
Merged-In: I9d113b37640345ebad6aa269ab710db0d2179671
2019-12-18 15:11:53 -08:00
Ruchir Rastogi
a38d5a6fd6 Simplified stats_event.c; exposed getter methods
Simplifications/changes:
(1) We remove the bufPos field and track the end of the buffer using
    only the size field.
(2) We rename put_<type>() functions to append_<type>() to signify that the
    value will be placed at the end of the buffer. We also move the
    increment of event->size to within the append_<type>() functions;
    this improves readability of the write_<type>() functions.
(3) We immediately write the timestamp and atom id to the buffer in
    order to simplify stats_event_build().
(4) We never check for null pointers; checking for null pointers
    delays errors and obfuscates the root problem.
(5) We change the the annotationId and numPairs parameters to be
    uint8_t's. This helps signify to clients that these values must fit
    in 1 byte.
(6) Clients no longer have to pass in the length of strings. Instead, we
    expect them to pass in null-terminated strings, and we will
    calculate the length outselves using strnlen.

Test: m -j libstatssocket
Change-Id: I6d192768876a23d7016173bcdaf59f8b7e92b182
Merged-In: I0173f8bc76ef25118379dce5d2481f5f7a9b7519
2019-12-18 13:17:36 -08:00
Ruchir Rastogi
3822e61d7b General cleanup; add support for key-value pairs
Encoding of key-value pairs follows strategy described in
go/statsd-socket-doc.

Fixed bug where timestamp and atom id were not contributing to the
number of fields in the buffer.

Note: Similar to ag/9603344, which was abandoned because of git rebasing
issues.

Test: m -j libstatssocket compiles
Bug: 143079361
Change-Id: I15abdf13ad8debf83ae1f6c372676db4fe390289
Merged-In: I8d23ddf2dbfee518ad970894ac09ba3ad5b5b4ad
2019-12-18 13:11:28 -08:00
Ruchir Rastogi
a3bc1af1b8 Move type ids to stats_event.h
This allows the parsing code within statsd to access the type ids.
Also, we move stats_event.h to the include directory for consistency.

Test: m -j libstatssocket
Change-Id: I7030416872677f3a523c2baf7bf6bcb4ca0ae6a4
Merged-In: I1db7fc9e9d0efd2225612353a8fc49bb13220ff0
2019-12-18 11:58:42 -08:00
Ruchir Rastogi
f4d23fc353 Set default timestamp to elapsedRealtimeNanos
Test: m -j libstatssocket compiles
Change-Id: I52b0cb8e1e916413db3dc0fe1b9a7e922833bdf7
Merged-In: I62f4c6bb14c3914124a6af25ff46fb0a980204e7
2019-12-18 11:53:38 -08:00
Ruchir Rastogi
bb0da94f8d First draft of native StatsEvent API
Test: m -j libstatssocket compiles
Change-Id: I874968d4f77a5990764100123794b923847e5eb5
Merged-In: I0da9740d29749d79d14be39e5949b98c58df704d
2019-12-18 11:33:22 -08:00
Ruchir Rastogi
ffa2b31708 Merge "Merge libstatspush_compat and libstatssocket_q" 2019-12-17 19:33:58 +00:00
Ruchir Rastogi
7070b7ac74 Merge libstatspush_compat and libstatssocket_q
This cleanup makes it clear that there are only two acceptable ways of
logging to the socket: either through libstatspush_compat or
libstatssocket (which will soon be renamed to libstatspush).

Test: m -j
Change-Id: I6a49b4995b56df462e1be901ea5e54acfe2e8bac
2019-12-16 15:24:36 -08:00
Stan Iliev
5dc56738bf Change register_stats_pull_atom_callback cookie parameter to non-const
Test: Ran GRAPHICS_STATS puller
Bug: 146052586
Bug: 142665516
Change-Id: I98b4cbb99e35eda50fa9dc3069b3f0ddf16f5ff9
2019-12-16 12:14:08 -05:00
Ruchir Rastogi
f104eb94be Improve stats_event memory usage
We now truncate the buffer to the appropriate length when clients call
stats_event_build().

Benchmarking tests indicate that truncating the buffer to the
appropriate length increases the cost clients pay to write to the socket
by 2%. This is negligible enough that I decided to truncate the buffer
for both pushed and pulled atoms in order to simplify the API.

Test: m libstatssocket
Test: bit libstatssocket_benchmark:*
Bug: 144126231
Change-Id: Ife976bb383ecff8de5064730692a95e2a3a82c9d
2019-12-13 23:38:19 +00:00
TreeHugger Robot
c9b826c66b Merge "StatsEventCompat" 2019-12-13 21:57:34 +00:00
Ruchir Rastogi
8822a0208f StatsEventCompat
StatsEventCompat is a wrapper library that toggles between the old
logging scheme and the new logging scheme. It was designed particularly
for the DNS Resolver module and should not be used by others.

We will merge libstatspush_compat and libstatssocket_q in a future CL.

Test: m libstatspush_compat
Test: bit libstatspush_compat_test:* (passes on Q and R)
Bug: 145534143

Change-Id: Idf35ccb6669798166475f08b2fbab40534b5db19
2019-12-13 12:03:03 -08:00
Jeffrey Huang
666510a0d4 Rename IStatsManager to IStatsd
Bug: 146075178
Test: CTS/GTS tests
Change-Id: I08f1b5c6f67c9e510dfaa7b50737c2720e177ad9
2019-12-12 11:32:41 -08:00
Ruchir Rastogi
9ecc986bb7 Use StatEventParcel in libstatspull
Test: m -j128 libstatspull
Change-Id: Ice031f38cdde8a505a887359f6c0cb3312046929
2019-12-06 13:57:42 -08:00
TreeHugger Robot
389fea8a3e Merge "Native puller API: libstatspulled" 2019-12-06 18:30:36 +00:00
TreeHugger Robot
3edba676bd Merge "Remove libstats/Android.bp" 2019-12-05 10:25:27 +00:00
Muhammad Qureshi
c1ecb983c4 Remove libstats/Android.bp
subdirs is not needed

Test: m -j
Change-Id: Ia7675fdf2e9a3a19bc52396ccbcc551556958803
2019-12-04 16:49:46 -08:00
Tej Singh
c03d009697 Native puller API: libstatspulled
Create a new library for the native puller callback API. The library has
2 main interfaces: register_stats_pull_atom_callback, which is used to
register a callback, and stats_pull_atom_callback_t, which is the
callback for the puller. It also exposes pulled_stats_event_list, which
is a struct wrapper around a vector of stats_event.

Test: make libstatspull
Bug: 142969725

Change-Id: I14fe4dc523d6f81fdeaa3fe6fad3e95aeecfe92e
2019-12-04 15:56:21 -08:00
Muhammad Qureshi
c8ef71b425 Make stats_event write function parameters const
Bug: 143968790
Test: bit statsd_test:*
Change-Id: I2660cad5400a0e819c60b9caa706bb66ca2eef4f
2019-12-04 12:01:26 -08:00
Muhammad Qureshi
f9b24aef5f Create stats_buffer_writer
Move iovec* construction and noteLogLoss from stats_event_list to
stats_buffer_writer.h.
Expose write_buffer_to_statsd that takes in a byte array and writes
it to the statsd socket. Currently exposed for StatsLog.write JNI call.

This change also allows getting rid of stats_event_list once all clients
have migrated to stats_event

Bug: 145619049
Test: m -j libstatssocket
Change-Id: I0048e392c2f5039eb70dacf4e91a43d3f32e8749
2019-12-03 15:02:48 -08:00
Muhammad Qureshi
876f64cb2f Create libstatssocket_q
Break up libstatssocket into libstatssocket_q and libstatssocket.
libstatssocket_q is for Q Mainline modules.

Bug: 145569088
Test: m -j
Test: bit statsd_test:*
Test: adb shell cmd stats print-logs && adb logcat "*:S statsd:*"
Change-Id: I9d113b37640345ebad6aa269ab710db0d2179671
2019-12-03 14:58:31 -08:00
Ruchir Rastogi
0ca5f8d0f1 Simplified stats_event.c; exposed getter methods
Simplifications/changes:
(1) We remove the bufPos field and track the end of the buffer using
    only the size field.
(2) We rename put_<type>() functions to append_<type>() to signify that the
    value will be placed at the end of the buffer. We also move the
    increment of event->size to within the append_<type>() functions;
    this improves readability of the write_<type>() functions.
(3) We immediately write the timestamp and atom id to the buffer in
    order to simplify stats_event_build().
(4) We never check for null pointers; checking for null pointers
    delays errors and obfuscates the root problem.
(5) We change the the annotationId and numPairs parameters to be
    uint8_t's. This helps signify to clients that these values must fit
    in 1 byte.
(6) Clients no longer have to pass in the length of strings. Instead, we
    expect them to pass in null-terminated strings, and we will
    calculate the length outselves using strnlen.

Test: m -j libstatssocket

Change-Id: I0173f8bc76ef25118379dce5d2481f5f7a9b7519
2019-11-25 12:23:27 -08:00
Ruchir Rastogi
6a406d6d4e General cleanup; add support for key-value pairs
Encoding of key-value pairs follows strategy described in
go/statsd-socket-doc.

Fixed bug where timestamp and atom id were not contributing to the
number of fields in the buffer.

Note: Similar to ag/9603344, which was abandoned because of git rebasing
issues.

Test: m -j libstatssocket compiles
Bug: 143079361
Change-Id: I8d23ddf2dbfee518ad970894ac09ba3ad5b5b4ad
2019-11-04 16:17:13 -08:00
Ruchir Rastogi
85f73573d6 Move type ids to stats_event.h
This allows the parsing code within statsd to access the type ids.
Also, we move stats_event.h to the include directory for consistency.

Test: m -j libstatssocket

Change-Id: I1db7fc9e9d0efd2225612353a8fc49bb13220ff0
2019-11-04 16:05:10 -08:00
Ruchir Rastogi
65567ee266 Merge "Set default timestamp to elapsedRealtimeNanos" 2019-11-02 00:02:58 +00:00
Ruchir Rastogi
0469b006ce Merge "Update OWNERS for libstatssocket" am: 7933195a36 am: cdfea6d783
am: 876b72c431

Change-Id: Ie9d34d69c670c66e1828131743cf784af730aabd
2019-11-01 15:45:24 -07:00
Ruchir Rastogi
6c7cbc430e Set default timestamp to elapsedRealtimeNanos
Test: m -j libstatssocket compiles

Change-Id: I62f4c6bb14c3914124a6af25ff46fb0a980204e7
2019-11-01 15:34:02 -07:00
Ruchir Rastogi
2aa3d903da Update OWNERS for libstatssocket
Test: m -j libstatssocket compiles
Change-Id: I57bce83a88de51a7671b452afb5e251e9a61ffb3
2019-11-01 13:25:31 -07:00
Ruchir Rastogi
6baeca576a First draft of native StatsEvent API
Test: m -j libstatssocket compiles
Change-Id: I0da9740d29749d79d14be39e5949b98c58df704d
2019-10-21 11:51:14 -07:00
Elliott Hughes
b55731d883 libstats: remove copy of cruft removed from liblog.
Test: treehugger
Change-Id: Id336758cd435393f2013d8e643d3784ee1820b1e
2019-10-02 12:03:23 -07:00
Elliott Hughes
022aafebb1 Merge "libstats: remove _USING_LIBCXX."
am: 5b3672a8a2

Change-Id: Ia3576ee301cd9df679f8559f2c0b233204fdf4a4
2019-08-06 12:39:52 -07:00
Elliott Hughes
a1f2005121 libstats: remove _USING_LIBCXX.
Bug: http://b/137876753
Test: treehugger
Change-Id: I1a1162a931c2cbbe3883eb9925993d48ce7bb8cf
2019-08-05 08:15:17 -07:00
yaochen
b7080aab9d Merge "Report last atom tag of the failed stats log." 2019-04-02 23:18:14 +00:00
Tej Singh
a7c1ff6906 stats_event_list changes for statsd mainline api
Cherry pick to aosp.
stats_event_list changes for creating a generic api for statsd mainline
logging.

Test: builds
Test: existing logs continue to flow
Change-Id: I4163edc80ffcca61db7ab2a1e14ae8c14aab2347
Merged-In: I4163edc80ffcca61db7ab2a1e14ae8c14aab2347
(cherry picked from commit 4c2f079dad)
2019-04-02 15:01:57 -07:00
Yao Chen
14c6db6d65 Report last atom tag of the failed stats log.
Test: manually tested with statsd

Change-Id: I4de61a2eea393e8518cb76147598778293440a81
Merged-In: I4de61a2eea393e8518cb76147598778293440a81
(cherry picked from commit cf776d9b83)
2019-04-02 14:26:01 -07:00
Yao Chen
0a75f928d1 Increase the SO_SNDBUF for statsd socket.
In addition to the dgram queue size, the sender buffer size also matters.
Set it to a higher value (default is 224KB).

Test: manual
Change-Id: Ib610c1fa1eaf3c5e36f51854a2b0720f387dc1b8
2019-04-02 13:55:28 -07:00
Yao Chen
cf776d9b83 Report last atom tag of the failed stats log.
Test: manually tested with statsd
Change-Id: I4de61a2eea393e8518cb76147598778293440a81
2019-03-26 19:47:16 -07:00
Tej Singh
4c2f079dad stats_event_list changes for statsd mainline api
stats_event_list changes for creating a generic api for statsd mainline
logging.

Test: builds
Test: existing logs continue to flow
Change-Id: I4163edc80ffcca61db7ab2a1e14ae8c14aab2347
2019-03-22 15:34:18 -07:00
Tom Cherry
e181bf5116 Merge "Remove liblog/uio.c and <log/uio.h>" 2019-01-17 17:19:52 +00:00
Tom Cherry
c2ea6e7c39 Remove __android_log_event_list and the reader aspect of android_log_event_list
One user of each, dubious API, remove it while we work on a new one.

Test: build
Change-Id: If422246226addaf873dc2af32553fad3a5182089
2019-01-16 15:35:20 -08:00
Tom Cherry
6f6ef39b48 Remove liblog/uio.c and <log/uio.h>
readv() isn't used by anyone, writev() has one easily replaced user.
uio.h can be left as a private header for windows compatibility with
struct iovec.

Test: build
Change-Id: I33d4c6bdee6fd818271f78ae06abdd2aa09430f2
2019-01-16 14:26:36 -08:00
Yao Chen
1d35761c67 Log the last error code of StatsLog failures
Test: builds and manual test
Bug: 80538532

Change-Id: I7f9d0e22b7ad4295dd787f6cb409bfb3342a7b27
Merged-In: I7f9d0e22b7ad4295dd787f6cb409bfb3342a7b27
(cherry picked from commit cb3527794c)
2018-12-07 11:02:08 -08:00
Yao Chen
6bd71aef37 Add a function to pass byte array to the log context.
The existing APIs will truncate the byte array in case of '\0' in between.

Test: test_drive with atom 103
Change-Id: I104d35b330c6b52e2fdce1f5d4305dca08228f1b
2018-12-06 13:03:12 -08:00
Howard Ro
d173009c74 Make native metrics logger write to statsd socket
Previous submission of this change, aosp/790068, caused a failure in
sdk_mac for CLOCK_REALTIME and <endian.h> not being available.

Bug: 110537511
Test: compiles without failures and verified the correct metric
Change-Id: Iba1dc920ad82e88a4bcdd2feaee9a06202a440c2
2018-10-24 15:19:14 -07:00
Howard Ro
44874e5b0e Revert "Make native metrics logger write to statsd socket"
This reverts commit 34bc567a93.

Reason for revert: build failure

Change-Id: I67e0270051a82db7f524ed219316f02f2766d6e1
2018-10-19 01:41:07 +00:00
Howard Ro
34bc567a93 Make native metrics logger write to statsd socket
Bug: 110537511
Test: compiles without failures and verified the correct metric
Change-Id: Ie8019a20a2112ed6cbbc0999d68592efb8f0f538
2018-10-18 10:39:40 -07:00
Yao Chen
763e3aee42 Reset statsd writer to init state after close
Bug: 117796113
Test: locally tested and verified stats logs can write to statsd again.
Change-Id: I33b006199d23f851ff1a6e49445fb16d74223062
2018-10-15 16:12:48 -07:00