Files
chromium_depot_tools/infra_lib/telemetry/__main__.py
Struan Shrimpton d495580f42 Add telemetry initialization and opt out utility
This includes initializing the module which will handle printing the
notice and enabling/disabling telemetry based on config. The __main__
file also allows for the banner to have a consistent entry point for
disabling telemetry so instrumenting programs don't need to worry
about it if they are using the same default config file.

Bug: 326277821
Change-Id: I861d6b9311ed48c2e1effcac22b314b73e2641e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5901465
Reviewed-by: Terrence Reilly <treilly@google.com>
Commit-Queue: Struan Shrimpton <sshrimp@google.com>
2024-10-02 20:38:47 +00:00

42 lines
1.1 KiB
Python
Executable File

#!/bin/env vpython3
# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Utility for opting in or out of metrics collection"""
import argparse
import sys
import pathlib
import config
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--disable',
'-d',
dest='enable',
action='store_false',
default=None,
help='Disable telemetry collection.')
parser.add_argument('--enable',
'-e',
dest='enable',
action='store_true',
default=None,
help='Enable telemetry collection.')
args = parser.parse_args()
if args.enable is not None:
cfg = config.Config(config.DEFAULT_CONFIG_FILE)
cfg.trace_config.update(args.enable, 'USER')
cfg.flush()
else:
print('Error: --enable or --disable flag is required.')
if __name__ == '__main__':
sys.exit(main())