Skip to content

Commit

Permalink
ref: Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed May 4, 2022
1 parent a104202 commit a38e2c8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions relay-common/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn duration_to_millis(duration: Duration) -> f64 {
/// use chrono::Duration;
///
/// let duration = Duration::nanoseconds(2_125_000);
/// let millis = relay_common::signed_duration_to_millis(duration);
/// let millis = relay_common::chrono_to_positive_millis(duration);
/// assert_eq!(millis, 2.125);
/// ```
///
Expand All @@ -54,10 +54,10 @@ pub fn duration_to_millis(duration: Duration) -> f64 {
/// use chrono::Duration;
///
/// let duration = Duration::nanoseconds(-2_125_000);
/// let millis = relay_common::signed_duration_to_millis(duration);
/// let millis = relay_common::chrono_to_positive_millis(duration);
/// assert_eq!(millis, 0.0);
/// ```
pub fn signed_duration_to_millis(duration: chrono::Duration) -> f64 {
pub fn chrono_to_positive_millis(duration: chrono::Duration) -> f64 {
duration_to_millis(duration.to_std().unwrap_or_default())
}

Expand Down
2 changes: 1 addition & 1 deletion relay-sampling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl FieldValueProvider for Event {
},
"event.duration" => match (self.ty.value(), store::validate_timestamps(self)) {
(Some(&EventType::Transaction), Ok((start, end))) => {
match Number::from_f64(relay_common::signed_duration_to_millis(end - start)) {
match Number::from_f64(relay_common::chrono_to_positive_millis(end - start)) {
Some(num) => Value::Number(num),
None => Value::Null,
}
Expand Down
4 changes: 2 additions & 2 deletions relay-server/src/metrics_extraction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn extract_user_satisfaction(
.and_then(|name| config.transaction_thresholds.get(name))
.unwrap_or(&config.project_threshold);
if let Some(value) = match threshold.metric {
SatisfactionMetric::Duration => Some(relay_common::signed_duration_to_millis(
SatisfactionMetric::Duration => Some(relay_common::chrono_to_positive_millis(
end_timestamp - start_timestamp,
)),
SatisfactionMetric::Lcp => store::get_measurement(transaction, "lcp"),
Expand Down Expand Up @@ -386,7 +386,7 @@ fn extract_transaction_metrics_inner(
};

// Duration
let duration_millis = relay_common::signed_duration_to_millis(end_timestamp - start_timestamp);
let duration_millis = relay_common::chrono_to_positive_millis(end_timestamp - start_timestamp);

push_metric(Metric::new_mri(
METRIC_NAMESPACE,
Expand Down

0 comments on commit a38e2c8

Please sign in to comment.