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

feat(metrics): Add units in built-in measurements [INGEST-1056] #1229

Merged
merged 5 commits into from
Apr 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(metrics): Add units in built-in measurements
  • Loading branch information
iker-barriocanal committed Apr 14, 2022
commit a96cba50bcfdf5c22491e8f23e2fc51724ea961b
32 changes: 31 additions & 1 deletion relay-server/src/metrics_extraction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,36 @@ fn extract_user_satisfaction(
None
}

/// Returns the unit of the provided metric. Defaults to None.
#[cfg(feature = "processing")]
fn get_metric_measurement_unit(metric: &String) -> MetricUnit {
match metric.as_str() {
// Web
"fcp" => MetricUnit::Duration(DurationUnit::MilliSecond),
"lcp" => MetricUnit::Duration(DurationUnit::MilliSecond),
"fid" => MetricUnit::Duration(DurationUnit::MilliSecond),
"fp" => MetricUnit::Duration(DurationUnit::MilliSecond),
"ttfb" => MetricUnit::Duration(DurationUnit::MilliSecond),
"ttfb.requesttime" => MetricUnit::Duration(DurationUnit::MilliSecond),
"cls" => MetricUnit::None,

// Mobile
"app_start_cold" => MetricUnit::Duration(DurationUnit::MilliSecond),
"app_start_warm" => MetricUnit::Duration(DurationUnit::MilliSecond),
"frames_total" => MetricUnit::None,
"frames_slow" => MetricUnit::None,
"frames_frozen" => MetricUnit::None,

// React-Native
"stall_count" => MetricUnit::None,
"stall_total_time" => MetricUnit::Duration(DurationUnit::MilliSecond),
"stall_longest_time" => MetricUnit::Duration(DurationUnit::MilliSecond),

// Default
_ => MetricUnit::None,
}
}

#[cfg(feature = "processing")]
pub fn extract_transaction_metrics(
config: &TransactionMetricsConfig,
Expand Down Expand Up @@ -251,7 +281,7 @@ fn extract_transaction_metrics_inner(
push_metric(Metric::new_mri(
METRIC_NAMESPACE,
format_args!("measurements.{}", measurement_name),
MetricUnit::None,
get_metric_measurement_unit(&measurement_name),
MetricValue::Distribution(measurement),
unix_timestamp,
tags,
Expand Down