@@ -414,36 +414,37 @@ def fetch_remote_setup_from_config(
414414def push_data_to_redistimeseries (rts : client , branch_time_series_dict : dict ):
415415 datapoint_errors = 0
416416 datapoint_inserts = 0
417- for timeseries_name , time_series in branch_time_series_dict .items ():
418- try :
419- logging .info (
420- "Creating timeseries named {} with labels {}" .format (
421- timeseries_name , time_series ["labels" ]
422- )
423- )
424- rts .create (timeseries_name , labels = time_series ["labels" ])
425- except redis .exceptions .ResponseError :
426- logging .warning (
427- "Timeseries named {} already exists" .format (timeseries_name )
428- )
429- pass
430- for timestamp , value in time_series ["data" ].items ():
417+ if rts is not None :
418+ for timeseries_name , time_series in branch_time_series_dict .items ():
431419 try :
432- rts .add (
433- timeseries_name ,
434- timestamp ,
435- value ,
436- duplicate_policy = "last" ,
420+ logging .info (
421+ "Creating timeseries named {} with labels {}" .format (
422+ timeseries_name , time_series ["labels" ]
423+ )
437424 )
438- datapoint_inserts += 1
425+ rts . create ( timeseries_name , labels = time_series [ "labels" ])
439426 except redis .exceptions .ResponseError :
440427 logging .warning (
441- "Error while inserting datapoint ({} : {}) in timeseries named {}. " .format (
442- timestamp , value , timeseries_name
443- )
428+ "Timeseries named {} already exists" .format (timeseries_name )
444429 )
445- datapoint_errors += 1
446430 pass
431+ for timestamp , value in time_series ["data" ].items ():
432+ try :
433+ rts .add (
434+ timeseries_name ,
435+ timestamp ,
436+ value ,
437+ duplicate_policy = "last" ,
438+ )
439+ datapoint_inserts += 1
440+ except redis .exceptions .ResponseError :
441+ logging .warning (
442+ "Error while inserting datapoint ({} : {}) in timeseries named {}. " .format (
443+ timestamp , value , timeseries_name
444+ )
445+ )
446+ datapoint_errors += 1
447+ pass
447448 return datapoint_errors , datapoint_inserts
448449
449450
@@ -470,34 +471,40 @@ def extract_perversion_timeseries_from_results(
470471 for jsonpath in metrics :
471472 jsonpath_expr = parse (jsonpath )
472473 metric_name = jsonpath [2 :]
473- metric_value = float (jsonpath_expr .find (results_dict )[0 ].value )
474- # prepare tags
475- # branch tags
476- version_tags = get_project_ts_tags (
477- tf_github_org , tf_github_repo , deployment_type , tf_triggering_env
478- )
479- version_tags ["version" ] = project_version
480- version_tags ["test_name" ] = str (test_name )
481- version_tags ["metric" ] = str (metric_name )
482-
483- ts_name = (
484- "ci.benchmarks.redislabs/by.version/"
485- "{triggering_env}/{github_org}/{github_repo}/"
486- "{test_name}/{deployment_type}/{version}/{metric}" .format (
487- version = project_version ,
488- github_org = tf_github_org ,
489- github_repo = tf_github_repo ,
490- deployment_type = deployment_type ,
491- test_name = test_name ,
492- triggering_env = tf_triggering_env ,
493- metric = metric_name ,
474+ find_res = jsonpath_expr .find (results_dict )
475+ if find_res is not None and len (find_res ) > 0 :
476+ metric_value = float (find_res [0 ].value )
477+ # prepare tags
478+ # branch tags
479+ version_tags = get_project_ts_tags (
480+ tf_github_org , tf_github_repo , deployment_type , tf_triggering_env
481+ )
482+ version_tags ["version" ] = project_version
483+ version_tags ["test_name" ] = str (test_name )
484+ version_tags ["metric" ] = str (metric_name )
485+
486+ ts_name = (
487+ "ci.benchmarks.redislabs/by.version/"
488+ "{triggering_env}/{github_org}/{github_repo}/"
489+ "{test_name}/{deployment_type}/{version}/{metric}" .format (
490+ version = project_version ,
491+ github_org = tf_github_org ,
492+ github_repo = tf_github_repo ,
493+ deployment_type = deployment_type ,
494+ test_name = test_name ,
495+ triggering_env = tf_triggering_env ,
496+ metric = metric_name ,
497+ )
494498 )
495- )
496499
497- branch_time_series_dict [ts_name ] = {
498- "labels" : version_tags .copy (),
499- "data" : {datapoints_timestamp : metric_value },
500- }
500+ branch_time_series_dict [ts_name ] = {
501+ "labels" : version_tags .copy (),
502+ "data" : {datapoints_timestamp : metric_value },
503+ }
504+ else :
505+ logging .warning (
506+ "Unable to find metric path {} in {}" .format (jsonpath , results_dict )
507+ )
501508 return True , branch_time_series_dict
502509
503510
@@ -532,34 +539,38 @@ def extract_perbranch_timeseries_from_results(
532539 for jsonpath in metrics :
533540 jsonpath_expr = parse (jsonpath )
534541 metric_name = jsonpath [2 :]
535- metric_value = float ( jsonpath_expr .find (results_dict )[ 0 ]. value )
536- # prepare tags
537- # branch tags
542+ find_res = jsonpath_expr .find (results_dict )
543+ if find_res is not None and len ( find_res ) > 0 :
544+ metric_value = float ( find_res [ 0 ]. value )
538545
539- branch_tags = get_project_ts_tags (
540- tf_github_org , tf_github_repo , deployment_type , tf_triggering_env
541- )
542- branch_tags ["branch" ] = str (tf_github_branch )
543- branch_tags ["test_name" ] = str (test_name )
544- branch_tags ["metric" ] = str (metric_name )
545- ts_name = (
546- "ci.benchmarks.redislabs/by.branch/"
547- "{triggering_env}/{github_org}/{github_repo}/"
548- "{test_name}/{deployment_type}/{branch}/{metric}" .format (
549- branch = str (tf_github_branch ),
550- github_org = tf_github_org ,
551- github_repo = tf_github_repo ,
552- deployment_type = deployment_type ,
553- test_name = test_name ,
554- triggering_env = tf_triggering_env ,
555- metric = metric_name ,
546+ branch_tags = get_project_ts_tags (
547+ tf_github_org , tf_github_repo , deployment_type , tf_triggering_env
548+ )
549+ branch_tags ["branch" ] = str (tf_github_branch )
550+ branch_tags ["test_name" ] = str (test_name )
551+ branch_tags ["metric" ] = str (metric_name )
552+ ts_name = (
553+ "ci.benchmarks.redislabs/by.branch/"
554+ "{triggering_env}/{github_org}/{github_repo}/"
555+ "{test_name}/{deployment_type}/{branch}/{metric}" .format (
556+ branch = str (tf_github_branch ),
557+ github_org = tf_github_org ,
558+ github_repo = tf_github_repo ,
559+ deployment_type = deployment_type ,
560+ test_name = test_name ,
561+ triggering_env = tf_triggering_env ,
562+ metric = metric_name ,
563+ )
556564 )
557- )
558565
559- branch_time_series_dict [ts_name ] = {
560- "labels" : branch_tags .copy (),
561- "data" : {datapoints_timestamp : metric_value },
562- }
566+ branch_time_series_dict [ts_name ] = {
567+ "labels" : branch_tags .copy (),
568+ "data" : {datapoints_timestamp : metric_value },
569+ }
570+ else :
571+ logging .warning (
572+ "Unable to find metric path {} in {}" .format (jsonpath , results_dict )
573+ )
563574 return True , branch_time_series_dict
564575
565576
0 commit comments