Sentry client does not flush metrics unless bound to a hub
Closed this issue · 3 comments
I would like to use the Rust SDK from within vector to send metrics, without instrumenting the rest of the app.
This example does not send anything:
use sentry::{metrics::Metric, ClientOptions};
use std::time::Duration;
# does not send any metric
fn main() {
let client = sentry::Client::from_config("...");
let metric = Metric::incr("hello-with-global", 2.0).finish();
client.add_metric(metric);
client.flush(Some(Duration::from_secs(1)));
}
I can verify using mitmproxy that there's no HTTP request leaving the process.
the only version that works is one where MetricBuilder::send
and sentry::init
are used:
# sends a metric
fn main() {
let _guard = sentry::init("...");
Metric::incr("hello", 2.0).send();
}
SDK version 0.32.1
Point of reference here: the other SDKs force the flusher to flush when the client flushes explicitly.
is there a workaround for this issue?
I'm not 100% certain I'm hitting it, but I want to send metrics without having to use the global hub
( we have a small service that converts logs to sentry errors & messages )
that wasn't the issue, I can use Client::add_metric
directly, and data is transferred. I didn't test explicit flushing
As we decided to discontinue Metrics (in that form), I will close this issue.