Skip to content

Commit bd93a65

Browse files
committed
Fixed path bug on prometheusExporter.py
1 parent b350699 commit bd93a65

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

reports/src/prometheusExporter.py

+29-22
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
from prometheus_client import start_http_server, Gauge
22
import pandas as pd
33
import time
4+
import argparse
45
import os
5-
from concurrent.futures import ThreadPoolExecutor
66

77

8-
output_path = '../output/'
8+
execution_time_gauge = Gauge(
9+
's3_specs_time_metrics',
10+
'Tests time metrics',
11+
['execution_name', 'execution_type', 'time_metric']
12+
)
13+
14+
# Gauge setup
15+
execution_status_gauge = Gauge(
16+
's3_specs_status_data',
17+
'Test statuses',
18+
['name', 'category']
19+
)
20+
21+
22+
parser = argparse.ArgumentParser()
23+
parser.add_argument('--parquet_path',
24+
required=True,
25+
help='Path of folder containing the execution_time and test parquet artifacts')
26+
27+
parser = parser.parse_args() # Parse the arguments
928

1029
def execution_metrics_exporter():
11-
file_path = output_path + 'execution_time.parquet'
30+
file_path = 'execution_time.parquet'
31+
file_path = os.path.join(parser.parquet_path, file_path)
1232
df = pd.read_parquet(file_path)
1333

1434
# Drop unnecessary columns and take the first 5 rows
@@ -19,30 +39,24 @@ def execution_metrics_exporter():
1939
cleaned_time_metric_df,
2040
id_vars=['execution_name', 'execution_type'],
2141
value_vars=['avg_time', 'min_time', 'total_time'],
22-
var_name='type_time',
42+
var_name='time_metric',
2343
value_name='time_values'
2444
).reset_index(drop=True).drop_duplicates()
2545

26-
# Gauge setup
27-
execution_time_gauge = Gauge(
28-
's3_specs_time_metrics',
29-
'Tests time metrics',
30-
['execution_name', 'execution_type', 'type_time']
31-
)
32-
3346
# Set gauge values
3447
for record in melted_df.to_dict('records'):
3548
execution_time_gauge.labels(
36-
Execution_name=record['execution_name'],
37-
Execution_type=record['execution_type'],
38-
type_time=record['type_time']
49+
execution_name=record['execution_name'],
50+
execution_type=record['execution_type'],
51+
time_metric=record['time_metric']
3952
).set(record['time_values'])
4053

4154
print('Time metrics exported...')
4255

4356
def test_metrics_exporter():
4457
# Test data gauge
45-
file_path = output_path + 'tests.parquet'
58+
file_path = 'tests.parquet'
59+
file_path = os.path.join(parser.parquet_path, file_path)
4660
df = pd.read_parquet(file_path)
4761

4862
status_to_numeric = {
@@ -55,13 +69,6 @@ def test_metrics_exporter():
5569
cleaned_status_df['status'] = cleaned_status_df['status'].map(status_to_numeric).drop_duplicates()
5670
dicts_time_metric_df = cleaned_status_df.to_dict(orient='records')
5771

58-
# Gauge setup
59-
execution_status_gauge = Gauge(
60-
's3_specs_status_data',
61-
'Test statuses',
62-
['name', 'category']
63-
)
64-
6572
# Set gauge values
6673
for record in dicts_time_metric_df:
6774
execution_status_gauge.labels(

0 commit comments

Comments
 (0)