Skip to content

Commit ff41320

Browse files
Add job label to k6 prometheus export
1 parent 0ab3c45 commit ff41320

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/swiss_ai_model_launch/loadtest/cluster.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def build_cluster_loadtest_script(
7272
'RUN_CONFIG_JSON="$(cat /work/run_config.json)"',
7373
"--env",
7474
f"PROMPTS_FILE={shlex.quote(prompts_path)}",
75+
"--env",
76+
f"RUN_LABEL={shlex.quote(run_label)}",
7577
"--summary-export",
7678
"/work/summary.json",
7779
"/work/script.js",

src/swiss_ai_model_launch/loadtest/k6/script.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ const CFG_PROMPT_LABELS =
9292
const BASE_URL = RUN_CFG.server_url ?? DEFAULT_BASE_URL;
9393
const API_KEY = RUN_CFG.api_key ?? "";
9494
const MODEL = RUN_CFG.model ?? "";
95+
// k6 strips non-allowlisted global --tag values from HTTP samples in the
96+
// prometheus exporter, so we re-attach model/run_label per-request below.
97+
const RUN_LABEL = __ENV.RUN_LABEL ?? RUN_CFG.run_label ?? "";
98+
const REQUEST_TAGS = {
99+
...(MODEL ? { model: MODEL } : {}),
100+
...(RUN_LABEL ? { run_label: RUN_LABEL } : {}),
101+
};
95102
const REQUEST_TIMEOUT =
96103
RUN_CFG.request_timeout ??
97104
RUN_CFG.scenario_definition?.request_timeout ??
@@ -388,7 +395,7 @@ function runNonStreaming(prompt) {
388395
const res = http.post(`${BASE_URL}${ENDPOINT}`, payload(prompt), {
389396
headers: HEADERS,
390397
timeout: REQUEST_TIMEOUT,
391-
tags: { [LABEL_TAG]: prompt.label, stream: "false" },
398+
tags: { ...REQUEST_TAGS, [LABEL_TAG]: prompt.label, stream: "false" },
392399
});
393400

394401
activeRequests.add(-1);

0 commit comments

Comments
 (0)