@@ -599,7 +599,31 @@ def run_remote_command_logic(args):
599599 tf_triggering_env ,
600600 ),
601601 )
602- add_standardized_metric (
602+ add_standardized_metric_bybranch (
603+ "benchmark_duration" ,
604+ benchmark_duration_seconds ,
605+ tf_github_branch ,
606+ deployment_type ,
607+ rts ,
608+ start_time_ms ,
609+ test_name ,
610+ tf_github_org ,
611+ tf_github_repo ,
612+ tf_triggering_env ,
613+ )
614+ add_standardized_metric_bybranch (
615+ "dataset_load_duration" ,
616+ dataset_load_duration_seconds ,
617+ tf_github_branch ,
618+ deployment_type ,
619+ rts ,
620+ start_time_ms ,
621+ test_name ,
622+ tf_github_org ,
623+ tf_github_repo ,
624+ tf_triggering_env ,
625+ )
626+ add_standardized_metric_byversion (
603627 "benchmark_duration" ,
604628 benchmark_duration_seconds ,
605629 artifact_version ,
@@ -611,7 +635,7 @@ def run_remote_command_logic(args):
611635 tf_github_repo ,
612636 tf_triggering_env ,
613637 )
614- add_standardized_metric (
638+ add_standardized_metric_byversion (
615639 "dataset_load_duration" ,
616640 dataset_load_duration_seconds ,
617641 artifact_version ,
@@ -679,7 +703,63 @@ def run_remote_command_logic(args):
679703 exit (return_code )
680704
681705
682- def add_standardized_metric (
706+ def add_standardized_metric_bybranch (
707+ metric_name ,
708+ metric_value ,
709+ tf_github_branch ,
710+ deployment_type ,
711+ rts ,
712+ start_time_ms ,
713+ test_name ,
714+ tf_github_org ,
715+ tf_github_repo ,
716+ tf_triggering_env ,
717+ ):
718+ tsname_use_case_duration = get_ts_metric_name (
719+ "by.branch" ,
720+ tf_github_branch ,
721+ tf_github_org ,
722+ tf_github_repo ,
723+ deployment_type ,
724+ test_name ,
725+ tf_triggering_env ,
726+ metric_name ,
727+ )
728+ labels = get_project_ts_tags (
729+ tf_github_org ,
730+ tf_github_repo ,
731+ deployment_type ,
732+ tf_triggering_env ,
733+ )
734+ labels ["branch" ] = tf_github_branch
735+ labels ["test_name" ] = str (test_name )
736+ labels ["metric" ] = str (metric_name )
737+ logging .info (
738+ "Adding metric {}={} to time-serie named {}" .format (
739+ metric_name , metric_value , tsname_use_case_duration
740+ )
741+ )
742+ try :
743+ logging .info (
744+ "Creating timeseries named {} with labels {}" .format (
745+ tsname_use_case_duration , labels
746+ )
747+ )
748+ rts .create (tsname_use_case_duration , labels = labels )
749+ except redis .exceptions .ResponseError :
750+ logging .warning (
751+ "Timeseries named {} already exists" .format (tsname_use_case_duration )
752+ )
753+ pass
754+ rts .add (
755+ tsname_use_case_duration ,
756+ start_time_ms ,
757+ metric_value ,
758+ labels = labels ,
759+ )
760+
761+
762+ def add_standardized_metric_byversion (
683763 metric_name ,
684764 metric_value ,
685765 artifact_version ,
0 commit comments