tracing: Add interceptor support

This patch introduces the concept of interceptors to the tracing SDK.
Interceptors make it possible to divert tracing data (i.e., serialized
trace packets) generated by a data source into a custom sink instead
of the central tracing service. Potential use cases include:

  * Logging trace events to the console in real time.

  * Exporting trace events to Android ATrace.

  * Exporting trace events to Windows ETW.

Intercepting works by creating special heap-backed trace writers for
each data source that is being intercepted. The serialized data is
passed in real time to the interceptor at the end of each trace point.

Interceptors are enabled through a new field in the trace config:

data_sources: {
    config {
        name: "track_event"
        interceptor_config: {
            name: "console"
        }
    }
}

Design doc: https://docs.google.com/document/d/1zIBGz7LvaucSb9B7UUWF24gDi6i3XFTGiuTi5Nf1czo

Bug: 170628040
Change-Id: I776f9bb5e99a37155619ea20c56df339131db813
24 files changed
tree: 07646d944472d498536b07a18dc8e4f7f74fb03b
  1. .github/
  2. bazel/
  3. build_overrides/
  4. buildtools/
  5. debian/
  6. docs/
  7. examples/
  8. gn/
  9. include/
  10. infra/
  11. protos/
  12. src/
  13. test/
  14. tools/
  15. ui/
  16. .clang-format
  17. .clang-tidy
  18. .gitignore
  19. .gn
  20. .style.yapf
  21. Android.bp
  22. Android.bp.extras
  23. BUILD
  24. BUILD.extras
  25. BUILD.gn
  26. CHANGELOG
  27. codereview.settings
  28. heapprofd.rc
  29. LICENSE
  30. METADATA
  31. MODULE_LICENSE_APACHE2
  32. OWNERS
  33. perfetto.rc
  34. PRESUBMIT.py
  35. README.chromium
  36. README.md
  37. TEST_MAPPING
  38. traced_perf.rc
  39. WORKSPACE
README.md

Perfetto - System profiling, app tracing and trace analysis

Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.

See https://perfetto.dev/docs or the /docs/ directory for documentation.