• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

Révision14c6db6d65faa7cfbcc48044e7400eb13a5d6423 (tree)
l'heure2019-04-03 06:26:01
AuteurYao Chen <yaochen@goog...>
CommiterYao Chen

Message de Log

Report last atom tag of the failed stats log.

Test: manually tested with statsd

Change-Id: I4de61a2eea393e8518cb76147598778293440a81
Merged-In: I4de61a2eea393e8518cb76147598778293440a81
(cherry picked from commit cf776d9b833952991294b2b898ea4a69b4c2731b)

Change Summary

Modification

--- a/libstats/include/stats_event_list.h
+++ b/libstats/include/stats_event_list.h
@@ -24,7 +24,7 @@ extern "C" {
2424 #endif
2525 void reset_log_context(android_log_context ctx);
2626 int write_to_logger(android_log_context context, log_id_t id);
27-void note_log_drop(int error);
27+void note_log_drop(int error, int atom_tag);
2828 void stats_log_close();
2929 int android_log_write_char_array(android_log_context ctx, const char* value, size_t len);
3030 #ifdef __cplusplus
--- a/libstats/stats_event_list.c
+++ b/libstats/stats_event_list.c
@@ -120,8 +120,8 @@ int write_to_logger(android_log_context ctx, log_id_t id) {
120120 return retValue;
121121 }
122122
123-void note_log_drop(int error) {
124- statsdLoggerWrite.noteDrop(error);
123+void note_log_drop(int error, int tag) {
124+ statsdLoggerWrite.noteDrop(error, tag);
125125 }
126126
127127 void stats_log_close() {
--- a/libstats/statsd_writer.c
+++ b/libstats/statsd_writer.c
@@ -47,9 +47,18 @@
4747 #endif
4848 #endif
4949
50+#ifndef htole64
51+#if __BYTE_ORDER == __LITTLE_ENDIAN
52+#define htole64(x) (x)
53+#else
54+#define htole64(x) __bswap_64(x)
55+#endif
56+#endif
57+
5058 static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
5159 static atomic_int dropped = 0;
5260 static atomic_int log_error = 0;
61+static atomic_int atom_tag = 0;
5362
5463 void statsd_writer_init_lock() {
5564 /*
@@ -152,9 +161,10 @@ static int statsdAvailable() {
152161 return 1;
153162 }
154163
155-static void statsdNoteDrop(int error) {
164+static void statsdNoteDrop(int error, int tag) {
156165 atomic_fetch_add_explicit(&dropped, 1, memory_order_relaxed);
157166 atomic_exchange_explicit(&log_error, error, memory_order_relaxed);
167+ atomic_exchange_explicit(&atom_tag, tag, memory_order_relaxed);
158168 }
159169
160170 static int statsdWrite(struct timespec* ts, struct iovec* vec, size_t nr) {
@@ -203,12 +213,17 @@ static int statsdWrite(struct timespec* ts, struct iovec* vec, size_t nr) {
203213 if (sock >= 0) {
204214 int32_t snapshot = atomic_exchange_explicit(&dropped, 0, memory_order_relaxed);
205215 if (snapshot) {
206- android_log_event_int_t buffer;
216+ android_log_event_long_t buffer;
207217 header.id = LOG_ID_STATS;
208218 // store the last log error in the tag field. This tag field is not used by statsd.
209219 buffer.header.tag = htole32(atomic_load(&log_error));
210- buffer.payload.type = EVENT_TYPE_INT;
211- buffer.payload.data = htole32(snapshot);
220+ buffer.payload.type = EVENT_TYPE_LONG;
221+ // format:
222+ // |atom_tag|dropped_count|
223+ int64_t composed_long = atomic_load(&atom_tag);
224+ // Send 2 int32's via an int64.
225+ composed_long = ((composed_long << 32) | ((int64_t)snapshot));
226+ buffer.payload.data = htole64(composed_long);
212227
213228 newVec[headerLength].iov_base = &buffer;
214229 newVec[headerLength].iov_len = sizeof(buffer);
--- a/libstats/statsd_writer.h
+++ b/libstats/statsd_writer.h
@@ -39,7 +39,7 @@ struct android_log_transport_write {
3939 /* write log to transport, returns number of bytes propagated, or -errno */
4040 int (*write)(struct timespec* ts, struct iovec* vec, size_t nr);
4141 /* note one log drop */
42- void (*noteDrop)(int error);
42+ void (*noteDrop)(int error, int tag);
4343 };
4444
4545 #endif // ANDROID_STATS_LOG_STATS_WRITER_H