Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry client does not flush metrics unless bound to a hub #637

Open
untitaker opened this issue Jan 28, 2024 · 2 comments
Open

Sentry client does not flush metrics unless bound to a hub #637

untitaker opened this issue Jan 28, 2024 · 2 comments

Comments

@untitaker
Copy link
Member

untitaker commented Jan 28, 2024

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

@mitsuhiko
Copy link
Member

Point of reference here: the other SDKs force the flusher to flush when the client flushes explicitly.

@syphar
Copy link

syphar commented Mar 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants