tree: e3fe73460c3c97d047cc6e6040bd556dcd62e3a6 [path history] [tgz]
  1. codelab/
  2. cpp/
  3. rust/
  4. rust-ergonomic/
  5. BUILD.gn
  6. OWNERS
  7. README.md
examples/diagnostics/inspect/README.md

Inspect examples

This directory contains examples components using the Inspect libraries. For more details on Inspect, see component inspection

Building

If these components are not present in your build, they can be added by appending --with //examples to your fx set command:

$ fx set core.x64 --with //examples --with //examples:tests
$ fx build

If you do not already have one running, start a package server so the example components can be resolved from your device:

$ fx serve

Running

To run one of the example components defined here, provide the full component URL to run, then bind to the client component:

  • C++

    $ ffx component run 'fuchsia-pkg://fuchsia.com/inspect-example-cpp#meta/echo_realm.cm'
    $ ffx component start '/core/ffx-laboratory:echo_realm/echo_client'
    
  • Rust

    $ ffx component run 'fuchsia-pkg://fuchsia.com/inspect-example-rust#meta/echo_realm.cm'
    $ ffx component start '/core/ffx-laboratory:echo_realm/echo_client'
    

This starts the echo_client component, which sends a request message to the echo_server for each argument. Each request is tracked by echo_server using Inspect.

Use ffx inspect show to review the metrics collected by echo_server:

$ ffx inspect show 'core/ffx-laboratory\:echo_realm/echo_server'
core/ffx-laboratory\:echo_realm/echo_server:
  metadata:
    filename = fuchsia.inspect.Tree
    component_url = #meta/echo_server.cm
    timestamp = 2601204210478
  payload:
    root:
      bytes_processed = 14
      request_count = 1
      fuchsia.inspect.Health:
        start_timestamp_nanos = 2169252928627
        status = OK

You can run ffx component start multiple times to watch the server metrics increment with each request.

Testing

To run one of the test components defined here, provide the package name to fx test:

  • C++

    $ fx test inspect-example-cpp-tests
    
  • Rust

    $ fx test inspect-example-rust-tests
    

Additional Inspect examples

  • Inspect codelab: Interactive codelab demonstrating additional Inspect concepts.
  • Inspect Dart: A simple module that demonstrates Inspect usage from within Flutter/Dart.
  • Ergonomic Inspect: Demonstration of the fuchsia_derive_inspect Rust crate.