blob: 9e58dba434664089da6d598671df7da6af8ae83f [file] [log] [blame]
Will Bradley88b1ffc2019-08-19 15:09:39 -06001# -*- coding: utf-8 -*-
2# Copyright 2019 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""The build API Metrics Emit entry point."""
7
8from __future__ import print_function
9
10from chromite.lib import commandline
11from chromite.utils import metrics
12
13
14def main(argv):
15 """Emit a metric event."""
16 parser = commandline.ArgumentParser(description=__doc__)
17 parser.add_argument('op', choices=metrics.VALID_OPS,
18 help='Which metric event operator to emit.')
19 parser.add_argument('name',
20 help='The name of the metric event as you would like it '
21 'to appear downstream in data stores.')
22 parser.add_argument('key', nargs='?',
23 help='A unique key for this invocation to ensure that '
24 'start and stop timers can be matched.')
25 opts = parser.parse_args(argv)
26
27 timestamp = metrics.current_milli_time()
28 key = opts.key or opts.name
29 metrics.append_metrics_log(timestamp, opts.name, opts.op, key=key)