}
break;
case Subscription::SubscriberInformationCase::kPerfettoDetails:
- if (!CollectPerfettoTraceAndUploadToDropbox(subscription.perfetto_details())) {
- ALOGW("Failed to generate prefetto traces.");
+ if (!CollectPerfettoTraceAndUploadToDropbox(subscription.perfetto_details(),
+ rule_id, configKey)) {
+ ALOGW("Failed to generate perfetto traces.");
}
break;
case Subscription::SubscriberInformationCase::kBroadcastSubscriberDetails:
*/
#define DEBUG false // STOPSHIP if true
+#include "config/ConfigKey.h"
#include "Log.h"
#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" // Alert
#include <android-base/unique_fd.h>
#include <errno.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
namespace os {
namespace statsd {
-bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config) {
+bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config,
+ int64_t alert_id,
+ const ConfigKey& configKey) {
VLOG("Starting trace collection through perfetto");
if (!config.has_trace_config()) {
return false;
}
+ char alertId[20];
+ char configId[20];
+ char configUid[20];
+ snprintf(alertId, sizeof(alertId), "%" PRId64, alert_id);
+ snprintf(configId, sizeof(configId), "%" PRId64, configKey.GetId());
+ snprintf(configUid, sizeof(configUid), "%d", configKey.GetUid());
+
android::base::unique_fd readPipe;
android::base::unique_fd writePipe;
if (!android::base::Pipe(&readPipe, &writePipe)) {
}
execl("/system/bin/perfetto", "perfetto", "--background", "--config", "-", "--dropbox",
- kDropboxTag, nullptr);
+ kDropboxTag, "--alert-id", alertId, "--config-id", configId, "--config-uid",
+ configUid, nullptr);
// execl() doesn't return in case of success, if we get here something
// failed.
namespace os {
namespace statsd {
+class ConfigKey;
class PerfettoDetails; // Declared in statsd_config.pb.h
// Starts the collection of a Perfetto trace with the given |config|.
// The trace is uploaded to Dropbox by the perfetto cmdline util once done.
// This method returns immediately after passing the config and does NOT wait
// for the full duration of the trace.
-bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config);
+bool CollectPerfettoTraceAndUploadToDropbox(const PerfettoDetails& config,
+ int64_t alert_id,
+ const ConfigKey& configKey);
} // namespace statsd
} // namespace os