This folder contains shared utilities for initializing telemetry collection in Chromite code paths, as well as telemetry configuration settings.
The Build team is actively working on instrumenting frequently used code paths in Chromite. Currently supported code paths include:
We intend to expand to the following code paths in 2023:
cros
CLI commandschromite/bin/build_image
If there is an application you want to instrument, you are empowered to do so!
Yes! To opt out, or opt in, you can run:
$ cros telemetry --disable $ cros telemetry --enable
In the script you wish to instrument, you will want to add the following lines of code:
from chromite.third_party.opentelemetry import trace from chromite.utils import telemetry tracer = trace.get_tracer(__name__) def main(argv: Optional[List[str]] = None) -> Optional[int]: commandline.RunInsideChroot() parser, opts = parse_args(argv) telemetry.initialize()
From here, you can trace individual code blocks and method calls as you see fit under service/
, lib/
, or any other relevant chromite code path. Each instrumented file will need a reference to a Tracer
object.
from chromite.third_party.opentelemetry import trace tracer = trace.get_tracer(__name__) @tracer.start_as_current_span("chromite.lib.my_important_method") def my_important_method(): do_cool_thing()
or
from chromite.third_party.opentelemetry import trace tracer = trace.get_tracer(__name__) def my_important_method(): with tracer.start_as_current_span("my_important_method.do_thing") as span: do_cool_thing() span.add_event("cool thing has been done!")
For specific advice about instrumenting code, you can contact chromeos-build-discuss@.
OpenTelemetry documentation is also a worthy read.
If you are a Googler and have a reasonable need to access the telemetry dataset, contact chromeos-build-discuss@ to be added to the relevant MDB group.