Skip to content

Commit

Permalink
feat(metrics): Add a convenience API to track metrics directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed Dec 11, 2023
1 parent 1267668 commit c164983
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sentry-core/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use sentry_types::protocol::latest::{Envelope, EnvelopeItem};

use crate::client::TransportArc;
use crate::Hub;

use crate::units::DurationUnit;
pub use crate::units::MetricUnit;
Expand Down Expand Up @@ -344,6 +345,12 @@ impl MetricBuilder {
pub fn finish(self) -> Metric {
self.metric
}

pub fn send(self) {
if let Some(client) = Hub::current().client() {
client.add_metric(self.finish());
}
}
}

pub struct MetricAggregator {
Expand Down

0 comments on commit c164983

Please sign in to comment.