metrics-rs / metrics

A metrics ecosystem for Rust.
MIT License
1.06k stars 145 forks source link

Metrics not flushed out in v0.23.0 #488

Closed TanyaSrinidhi closed 1 month ago

TanyaSrinidhi commented 1 month ago

Using this code :

    let metrics = metrics_cloudwatch_embedded::Builder::new()
    .cloudwatch_namespace("MyApplication")
    .init()
    .unwrap();

    metrics::counter!("requests", "Method" => "Default").increment(1);

    metrics
        .set_property("RequestId", "ABC123")
        .flush(std::io::stdout())?;

I see that version 0.22.3 works well by creating this JSON :

{"_aws":{"Timestamp":1717117366448,"CloudWatchMetrics":[{"Namespace":"MyApplication","Dimensions":[["Method"]],"Metrics":[{"Name":"requests"}]}]},"Method":"Default","RequestId":"ABC123","requests":1}

I don't see this in version v.23.0

tobz commented 1 month ago

The version of metrics used needs to match the version of metrics that the exporter itself uses. In this case, it looks like metrics-cloudwatch-embedded depends on ^0.22.3, so you would need to match that, which could be done most easily by targeting ^0.22.