traced_probes: re-flush metatrace data source at DataSourceStop

This allows the metatrace to record the other flushes

Change-Id: I803eef3967e19b158f7c7cc126be450b46ce6aa8
diff --git a/src/traced/probes/probes_producer.cc b/src/traced/probes/probes_producer.cc
index 94e922a..cb1d1a4 100644
--- a/src/traced/probes/probes_producer.cc
+++ b/src/traced/probes/probes_producer.cc
@@ -134,6 +134,7 @@
   {
     DataSourceDescriptor desc;
     desc.set_name(MetatraceDataSource::kDataSourceName);
+    desc.set_will_notify_on_stop(true);
     endpoint_->RegisterDataSource(desc);
   }
 }
@@ -338,6 +339,14 @@
     return;
   }
   ProbesDataSource* data_source = it->second.get();
+
+  // MetatraceDataSource special case: re-flush and ack the stop (to record the
+  // flushes of other data sources).
+  if (data_source->type_id == MetatraceDataSource::kTypeId) {
+    data_source->Flush(FlushRequestID{0}, [] {});
+    endpoint_->NotifyDataSourceStopped(id);
+  }
+
   TracingSessionID session_id = data_source->tracing_session_id;
   auto range = session_data_sources_.equal_range(session_id);
   for (auto kv = range.first; kv != range.second; kv++) {