Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Optional arguments:
branch/ref time-series are created (default: None)
--local-dir LOCAL_DIR
local dir to use as storage (default: ./)
--local_file PERF_DAEMON_LOGNAME local_file to write the logs to (default: None)
--logfile PERF_DAEMON_LOGNAME logfile to write the logs to (default: None)
--github_actor [GITHUB_ACTOR]
--github_repo GITHUB_REPO
--github_org GITHUB_ORG
Expand Down
15 changes: 13 additions & 2 deletions redisbench_admin/run/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ def extract_results_table(
return results_matrix


def collect_redis_metrics(redis_conns, sections=["memory", "cpu"]):
def collect_redis_metrics(redis_conns, sections=["memory", "cpu", "commandstats"]):
start_time = dt.datetime.utcnow()
start_time_ms = int((start_time - dt.datetime(1970, 1, 1)).total_seconds() * 1000)
res = []
overall = {}
for conn in redis_conns:
multi_shard = False
if len(redis_conns) > 1:
multi_shard = True
for conn_n, conn in enumerate(redis_conns):
conn_res = {}
for section in sections:
info = conn.info(section)
Expand All @@ -101,6 +104,14 @@ def collect_redis_metrics(redis_conns, sections=["memory", "cpu"]):
if k not in overall[section]:
overall[section][k] = 0
overall[section][k] += v
if type(v) is dict:
for inner_k, inner_v in v.items():
if type(inner_v) is float or type(inner_v) is int:
final_str_k = "{}_{}".format(k, inner_k)
if multi_shard:
final_str_k += "_shard_{}".format(conn_n + 1)
if final_str_k not in overall[section]:
overall[section][final_str_k] = inner_v

res.append(conn_res)

Expand Down
28 changes: 27 additions & 1 deletion redisbench_admin/run_remote/run_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ def run_remote_command_logic(args, project_name, project_version):
end_time_ms,
_,
overall_end_time_metrics,
) = collect_redis_metrics(redis_conns)
) = collect_redis_metrics(
redis_conns, ["cpu", "memory"]
)
export_redis_metrics(
artifact_version,
end_time_ms,
Expand All @@ -549,6 +551,27 @@ def run_remote_command_logic(args, project_name, project_version):
tf_github_repo,
tf_triggering_env,
)
(
end_time_ms,
_,
overall_commandstats_metrics,
) = collect_redis_metrics(
redis_conns, ["commandstats"]
)
export_redis_metrics(
artifact_version,
end_time_ms,
overall_commandstats_metrics,
rts,
setup_name,
setup_type,
test_name,
tf_github_branch,
tf_github_org,
tf_github_repo,
tf_triggering_env,
{"metric-type": "commandstats"},
)

if setup_details["env"] is None:
if args.keep_env_and_topo is False:
Expand Down Expand Up @@ -767,6 +790,7 @@ def export_redis_metrics(
tf_github_org,
tf_github_repo,
tf_triggering_env,
metadata_dict=None,
):
datapoint_errors = 0
datapoint_inserts = 0
Expand Down Expand Up @@ -818,6 +842,8 @@ def export_redis_metrics(
)
variant_labels_dict["test_name"] = test_name
variant_labels_dict["metric"] = metric_name
if metadata_dict is not None:
variant_labels_dict.update(metadata_dict)

timeseries_dict[tsname_metric] = {
"labels": get_project_ts_tags(
Expand Down
10 changes: 8 additions & 2 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ def test_collect_redis_metrics():
rts.redis.ping()
time_ms, metrics_arr, overall_metrics = collect_redis_metrics([rts.redis])
assert len(metrics_arr) == 1
assert len(metrics_arr[0].keys()) == 2
assert len(metrics_arr[0].keys()) == 3
assert "cpu" in metrics_arr[0].keys()
assert "memory" in metrics_arr[0].keys()
assert "commandstats" in metrics_arr[0].keys()
assert "allocator_active" in metrics_arr[0]["memory"]
assert "cmdstat_ping" in metrics_arr[0]["commandstats"]
allocator_active = metrics_arr[0]["memory"]["allocator_active"]
allocator_active_kv = overall_metrics["memory_allocator_active"]
assert allocator_active == allocator_active_kv

_, _, overall_metrics = collect_redis_metrics([rts.redis, rts.redis])
_, metrics_arr, overall_metrics = collect_redis_metrics([rts.redis, rts.redis])
allocator_active_kv = overall_metrics["memory_allocator_active"]
assert (2 * allocator_active) == allocator_active_kv
assert "cmdstat_ping" in metrics_arr[0]["commandstats"]
assert "cmdstat_ping" in metrics_arr[1]["commandstats"]
assert "commandstats_cmdstat_ping_calls_shard_1" in overall_metrics
assert "commandstats_cmdstat_ping_calls_shard_2" in overall_metrics
14 changes: 14 additions & 0 deletions tests/test_profilers_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# BSD 3-Clause License
#
# Copyright (c) 2022., Redis Labs Modules
# All rights reserved.
#
from redisbench_admin.profilers.profilers_schema import get_profilers_rts_key_prefix


def test_get_profilers_rts_key_prefix():
triggering_env = "ci"
tf_github_org = "redislabs"
tf_github_repo = "redisbench-admin"
res = get_profilers_rts_key_prefix(triggering_env, tf_github_org, tf_github_repo)
assert res == "ci.benchmarks.redis.com/ci/redislabs/redisbench-admin:profiles"
11 changes: 11 additions & 0 deletions tests/test_run_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ def test_export_redis_metrics():
tf_github_org,
tf_github_repo,
tf_triggering_env,
{"metric-type": "test-tag"},
)
assert (
rts.info(
"ci.benchmarks.redislabs/env/org/repo/test1/by.version/6.2.3/benchmark_end/commandstats_cmdstat_ping_calls"
).labels["metric-type"]
== "test-tag"
)
assert (
"ci.benchmarks.redislabs/env/org/repo/test1/by.version/6.2.3/benchmark_end/commandstats_cmdstat_ping_calls"
in rts.queryindex(["metric-type=test-tag"])
)
assert datapoint_errors == 0
assert datapoint_inserts == (1 * len(list(overall_end_time_metrics.keys())))
Expand Down