Commit graph

31 commits

Author SHA1 Message Date
Ruchir Rastogi
3bbc240263 Fix error checking in append_string
Test: m -j
Change-Id: Ifa806d5037acb17f83cbf45712e9795d6f56152f
2019-12-19 14:57:10 -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
2aa3d903da Update OWNERS for libstatssocket
Test: m -j libstatssocket compiles
Change-Id: I57bce83a88de51a7671b452afb5e251e9a61ffb3
2019-11-01 13:25:31 -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
Yao Chen
602d292cb1 Add an API to release stats logger resources.
Test: tested with ag/5112579
Change-Id: I271b7574beab1baa9886d31bc1cf25c40c2fae23
Merged-In: I271b7574beab1baa9886d31bc1cf25c40c2fae23
(cherry picked from commit 5b63e2704a)
2018-10-03 10:43:21 -07:00
Yao Chen
6301054b38 Add a function to allow statslog failure.
+ Record all types of failures which lead to log loss
+ Only record eventual failure after the retries to get a accurate log loss count.

Bug: 80538532
Test: manually tested

Change-Id: I23a55e62e140bf22ae5aa9e6c40539d51149cd66
Merged-In: I23a55e62e140bf22ae5aa9e6c40539d51149cd66
(cherry picked from commit ad3a40bf76)
2018-10-03 10:42:34 -07:00
Yao Chen
4d1deed139 Remove a redundant check in statsd socket code.
The original liblog code has this additional check because there may be multiple writers registered,
there is a for-loop and the retVal is set to be the FIRST error. Statsd doesn't need it because it
 only has one writer.

Test: locally tested.
Change-Id: I03f0015d0c29eba19eb2b5ea145380cb98fb2509
2018-05-22 16:06:21 -07:00
Yao Chen
bc586d15d3 Add OWNERS file for libstats/
Test: N/A
Change-Id: Ic16b0e1330ff46bfea9524eacf109c4ded430c67
2018-05-21 10:12:49 -07:00
Yao Chen
b3be9eaff5 Move libstatssocket from frameworks/base to system/core/
So that lmkd can build on PDK.

Bug: 79349329
Test: builds locally
Merged-In: I981e6ef9f9769b873640e5f169a9495ccea2f25c
Change-Id: I981e6ef9f9769b873640e5f169a9495ccea2f25c
(cherry picked from commit b13a102c0a)
2018-05-21 10:06:25 -07:00