Skip to content

Commit

Permalink
add collapse in junit as a table, rename metrics in readout (#50)
Browse files Browse the repository at this point in the history
* add collapse in junit as a table, rename metrics in readout

Signed-off-by: Shashank Reddy Boyapally <[email protected]>

* fixed trivial error

Signed-off-by: Shashank Reddy Boyapally <[email protected]>

* made output shorter and concise

Signed-off-by: Shashank Reddy Boyapally <[email protected]>

* changed format to explicitly state changepoints

Signed-off-by: Shashank Reddy Boyapally <[email protected]>

---------

Signed-off-by: Shashank Reddy Boyapally <[email protected]>
  • Loading branch information
shashank-boyapally authored Jul 17, 2024
1 parent 1eff560 commit f023a1c
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 111 deletions.
14 changes: 7 additions & 7 deletions examples/readout-control-plane-cdv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,25 @@ tests :
controlPlaneArch: amd64

metrics :
- name: CPU_Usage
- name: CPU_Usage_kube-apiserver
metricName.keyword: cpu-kube-apiserver
metric_of_interest: value
agg:
value: kube_apiserver
agg_type: avg
- name: Max_Aggregated_RSS_Usage
- name: Max_Aggregated_RSS_Usage_kube-apiserver
metricName.keyword: max-memory-sum-kube-apiserver
metric_of_interest: value
agg:
value: kube_apiserver
agg_type: avg
- name: CPU_Usage
- name: CPU_Usage_etcd
metricName.keyword: cpu-etcd
metric_of_interest: value
agg:
value: etcd
agg_type: avg
- name: Max_Aggregated_RSS_Usage
- name: Max_Aggregated_RSS_Usage_etcd
metricName.keyword: max-memory-etcd
metric_of_interest: value
agg:
Expand Down Expand Up @@ -227,21 +227,21 @@ tests :
controlPlaneArch: amd64

metrics :
- name: Read_Only_API_request_P99_latency
- name: Read_Only_API_request_P99_latency_namespace
metricName.keyword: avg-ro-apicalls-latency
labels.scope.keyword: namespace
metric_of_interest: value
agg:
value: namespace_scoped
agg_type: avg
- name: Read_Only_API_request_P99_latency
- name: Read_Only_API_request_P99_latency_cluster
metricName.keyword: avg-ro-apicalls-latency
labels.scope.keyword: cluster
metric_of_interest: value
agg:
value: cluster_scoped
agg_type: avg
- name: Read_Only_API_request_P99_latency
- name: Read_Only_API_request_P99_latency_avg
metricName.keyword: avg-mutating-apicalls-latency
metric_of_interest: value
agg:
Expand Down
1 change: 1 addition & 0 deletions orion.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def cli(max_content_width=120): # pylint: disable=unused-argument
)
@click.option("--lookback", help="Get data from last X days and Y hours. Format in XdYh")
@click.option("--convert-tinyurl", is_flag=True, help="Convert buildUrls to tiny url format for better formatting")
@click.option("--collapse", is_flag=True, help="Only outputs changepoints, previous and later runs in the xml format")
def cmd_analysis(**kwargs):
"""
Orion runs on command line mode, and helps in detecting regressions
Expand Down
36 changes: 25 additions & 11 deletions pkg/edivisive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""EDivisive Algorithm from hunter"""
#pylint: disable = line-too-long

# pylint: disable = line-too-long
import json
import pandas as pd
from hunter.report import Report, ReportType
Expand All @@ -8,7 +9,6 @@
from pkg.utils import json_to_junit



class EDivisive(Algorithm):
"""Implementation of the EDivisive algorithm using hunter
Expand Down Expand Up @@ -36,7 +36,10 @@ def output_json(self):
(change_point.stats.mean_2 - change_point.stats.mean_1)
/ change_point.stats.mean_1
) * 100
if percentage_change * self.metrics_config[key]["direction"] > 0 or self.metrics_config[key]["direction"]==0:
if (
percentage_change * self.metrics_config[key]["direction"] > 0
or self.metrics_config[key]["direction"] == 0
):
dataframe_json[index]["metrics"][key][
"percentage_change"
] = percentage_change
Expand All @@ -53,14 +56,19 @@ def output_text(self):

def output_junit(self):
test_name, data_json = self.output_json()
data_json=json.loads(data_json)
data_junit = json_to_junit(test_name=test_name, data_json=data_json, metrics_config=self.metrics_config)
data_json = json.loads(data_json)
data_junit = json_to_junit(
test_name=test_name, data_json=data_json, metrics_config=self.metrics_config, options=self.options
)
return test_name, data_junit

def _analyze(self):
self.dataframe["timestamp"] = pd.to_datetime(self.dataframe["timestamp"])
self.dataframe["timestamp"] = self.dataframe["timestamp"].astype(int) // 10**9
metrics = {column: Metric(value.get("direction",1), 1.0) for column,value in self.metrics_config.items()}
metrics = {
column: Metric(value.get("direction", 1), 1.0)
for column, value in self.metrics_config.items()
}
data = {column: self.dataframe[column] for column in self.metrics_config}
attributes = {
column: self.dataframe[column]
Expand All @@ -79,17 +87,23 @@ def _analyze(self):
# filter by direction
for change_point_group in change_points:
change_point_group.changes = [
change for change in change_point_group.changes
change
for change in change_point_group.changes
if not (
(self.metrics_config[change.metric]["direction"] == 1 and change.stats.mean_1 > change.stats.mean_2) or
(self.metrics_config[change.metric]["direction"] == -1 and change.stats.mean_1 < change.stats.mean_2)
(
self.metrics_config[change.metric]["direction"] == 1
and change.stats.mean_1 > change.stats.mean_2
)
or (
self.metrics_config[change.metric]["direction"] == -1
and change.stats.mean_1 < change.stats.mean_2
)
)
]

for i in range(len(change_points)-1,-1,-1):
for i in range(len(change_points) - 1, -1, -1):
if len(change_points[i].changes) == 0:
del change_points[i]


report = Report(series, change_points)
return report, series
2 changes: 1 addition & 1 deletion pkg/isolationForest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def output_text(self):
def output_junit(self):
test_name, data_json = self.output_json()
data_json=json.loads(data_json)
data_junit = json_to_junit(test_name=test_name, data_json=data_json, metrics_config=self.metrics_config)
data_junit = json_to_junit(test_name=test_name, data_json=data_json, metrics_config=self.metrics_config, options=self.options)
return test_name, data_junit

def analyze(self, dataframe: pd.DataFrame):
Expand Down
Loading

0 comments on commit f023a1c

Please sign in to comment.