You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📝 Add docstrings to codex/extend-.perf-budget.yml-with-navigation-thresholds (#285)
Docstrings generation was requested by @shayancoin.
* #126 (comment)
The following files were modified:
* `tools/perf/check-canary-metrics.py`
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Substitutes the `$BUILD` placeholder in a query template with the provided build identifier.
103
+
104
+
Parameters:
105
+
template (str): Prometheus query template containing the `$BUILD` placeholder.
106
+
build (str): Build identifier to substitute into the template.
107
+
108
+
Returns:
109
+
rendered (str): The query string with `$BUILD` replaced by `build`.
110
+
"""
80
111
returntemplate.replace('$BUILD', build)
81
112
82
113
@@ -104,6 +135,20 @@ def evaluate_metric(
104
135
unit: str,
105
136
description: str,
106
137
) ->MetricResult:
138
+
"""
139
+
Evaluate a single canary metric against an absolute threshold and an optional regression allowance.
140
+
141
+
Parameters:
142
+
name (str): Human-readable metric identifier used in messages and the resulting MetricResult.name.
143
+
template (str): Prometheus query template; the placeholder `$BUILD` will be replaced with the build SHA.
144
+
threshold (float): Absolute budget value the current metric must be less than or equal to.
145
+
regression_pct (float): Allowed relative increase over the previous build (e.g., 0.1 for 10%); ignored when previous baseline is near zero or unavailable.
146
+
unit (str): Unit string appended to numeric values in human-readable messages (e.g., "ms", or empty).
147
+
description (str): Short textual description stored on the MetricResult.description for reporting.
148
+
149
+
Returns:
150
+
MetricResult: Populated result containing current and optional previous values, threshold and regression parameters, a pass/fail flag, and a human-readable message explaining the outcome.
Check Tempo for traces slower than the configured threshold for the canary service.
211
+
212
+
If TEMPO_URL is unset the function prints a skip message and returns None. Otherwise it queries Tempo for any trace with duration at or above TEMPO_SLOW_TRACE_THRESHOLD_MS within TEMPO_LOOKBACK_SECONDS for TEMPO_SERVICE and produces a MetricResult summarizing whether slow traces were found.
213
+
214
+
Returns:
215
+
MetricResult: a result named 'tempo_slow_traces' where `passed` is `False` if a slow trace was found and `current_value` is the slow-threshold in milliseconds (or `0.0` if none was found).
216
+
None: if TEMPO_URL is not configured.
217
+
"""
164
218
ifnotTEMPO_URL:
165
219
print('TEMPO_URL not provided; skipping trace regression checks.')
Write a JUnit-format XML report summarizing the provided MetricResult entries and save it to the configured artifacts location.
296
+
297
+
Each MetricResult becomes a <testcase>; passing results include a <system-out> block with metric details, failing results include a <failure> element and the same details. The file is written to RESULT_DIR/JUNIT_FILENAME and a message with the written path is printed.
298
+
299
+
Parameters:
300
+
results_list (list[MetricResult]): List of metric results to include in the JUnit report.
0 commit comments