fix(hive-metric): multi-thread runtime + counter default
This commit is contained in:
parent
28605e5cdd
commit
61dfceb100
2 changed files with 18 additions and 18 deletions
|
|
@ -33,8 +33,8 @@ struct Cli {
|
|||
/// Numeric value (f64). Floats and integers both accepted.
|
||||
value: f64,
|
||||
|
||||
/// Metric kind: `gauge` (instantaneous, default) or `counter` (cumulative sum).
|
||||
#[arg(long = "type", value_name = "TYPE", default_value = "gauge")]
|
||||
/// Metric kind: `counter` (cumulative sum, default) or `gauge` (instantaneous value).
|
||||
#[arg(long = "type", value_name = "TYPE", default_value = "counter")]
|
||||
metric_type: MetricKind,
|
||||
|
||||
/// Extra label(s) as `key=value` pairs. May be repeated.
|
||||
|
|
@ -46,13 +46,13 @@ struct Cli {
|
|||
|
||||
#[derive(Clone, Debug, clap::ValueEnum)]
|
||||
enum MetricKind {
|
||||
/// Gauge: point-in-time value (default).
|
||||
Gauge,
|
||||
/// Counter: monotonically increasing cumulative sum.
|
||||
/// Counter: monotonically increasing cumulative sum (default).
|
||||
Counter,
|
||||
/// Gauge: point-in-time instantaneous value.
|
||||
Gauge,
|
||||
}
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
|
|
@ -80,12 +80,12 @@ async fn main() -> Result<()> {
|
|||
let meter = provider.meter("hive-metric");
|
||||
|
||||
match cli.metric_type {
|
||||
MetricKind::Gauge => {
|
||||
meter.f64_gauge(cli.name).build().record(cli.value, &labels);
|
||||
}
|
||||
MetricKind::Counter => {
|
||||
meter.f64_counter(cli.name).build().add(cli.value, &labels);
|
||||
}
|
||||
MetricKind::Gauge => {
|
||||
meter.f64_gauge(cli.name).build().record(cli.value, &labels);
|
||||
}
|
||||
}
|
||||
|
||||
// Flush pending metrics and shut down cleanly.
|
||||
|
|
|
|||
Loading…
Reference in a new issue