@@ -131,7 +131,7 @@ export default class PrometheusReporter implements Reporter {
131131 name : "test_step_total_error" ,
132132 description : `Total errors in test steps` ,
133133 } ) ;
134- private readonly test_step = new Counter ( {
134+ private test_step = new Counter ( {
135135 name : "test_step" ,
136136 description : `Individual test steps` ,
137137 } ) ;
@@ -168,7 +168,7 @@ export default class PrometheusReporter implements Reporter {
168168 name : "error_count" ,
169169 } ) ;
170170 private test_errors = new Counter ( {
171- name : "test_error " ,
171+ name : "test_errors " ,
172172 } ) ;
173173 private tests_total_attachment = new Counter ( {
174174 name : "tests_attachment_total_count" ,
@@ -398,22 +398,55 @@ export default defineConfig({
398398 }
399399
400400 async onStepEnd ( test : TestCase , result : TestResult , step : TestStep ) {
401- this . test_step . labels ( {
402- path : this . location ( step ) ,
401+ const location = this . location ( step ) ;
402+ const labels : Record < string , string > = {
403403 category : step . category ,
404+ path : location ,
404405 testId : test . id ,
406+ duration : String ( step . duration ) ,
407+ startTime : String ( step . startTime ) ,
408+ titlePath : step . titlePath ( ) . join ( "->" ) ,
409+ stepsCount : String ( step . steps . length ) ,
405410 testTitle : test . title ,
406- stepTitle : step . title ,
407411 stepInnerCount : String ( step . steps . length ) ,
408- startTime : String ( step . startTime ) ,
409- } ) ;
412+ parallelIndex : String ( result . parallelIndex ) ,
413+ retryCount : String ( result . retry ) ,
414+ status : String ( result . status ) ,
415+ } ;
416+ if ( step . error ) {
417+ const errorMessage =
418+ step . error . message ?. replace ( / \r ? \n | \r / g, " " ) ??
419+ // [TODO] trim message?
420+ JSON . stringify ( step . error . message ) ;
421+ labels . errorMessage = errorMessage ;
422+ labels . errorSnippet = String ( step . error . snippet ?? "<unknown snippet>" ) ;
423+ labels . errorStack = String ( step . error . stack ?? "<empty stack>" ) ;
424+ labels . errorValue = String ( step . error . value ?? "<unknown value>" ) ;
425+ labels . errorPath = this . location ( step . error ) ;
426+
427+ this . test_step_total_error . labels ( labels ) . inc ( ) ;
428+ this . test_step_error_count . labels ( labels ) . inc ( ) ;
429+ }
430+
431+ this . test_step_total_duration . inc ( step . duration ) ;
432+ this . test_step_total_count . inc ( ) ;
433+ this . test_step_duration . labels ( labels ) . inc ( step . duration ) ;
434+
435+ this . test_step . labels ( labels ) ;
436+
410437 this . test_step_total_duration
411438 . labels ( {
412439 testId : test . id ,
413440 testTitle : test . title ,
414441 } )
415442 . inc ( step . duration ) ;
416443 this . updateNodejsStats ( ) ;
444+ await this . send (
445+ [ this . test_step_duration , this . test_step_error_count , this . test_step ] . map (
446+ ( m ) => this . mapTimeseries ( m ) ,
447+ ) ,
448+ ) ;
449+ this . test_step . reset ( ) ;
417450 }
418451
419452 async onTestEnd ( test : TestCase , result : TestResult ) {
@@ -472,47 +505,6 @@ export default defineConfig({
472505 const testDuration = this . test_duration . labels ( labels ) . set ( result . duration ) ;
473506 const testRetries = this . test_retry_count . labels ( labels ) . inc ( result . retry ) ;
474507
475- for ( const step of result . steps ) {
476- this . test_step_duration . reset ( ) ;
477- this . test_step_error_count . reset ( ) ;
478-
479- const location = this . location ( step ) ;
480- const labels : Record < string , string > = {
481- category : step . category ,
482- path : location ,
483- testId : test . id ,
484- duration : String ( step . duration ) ,
485- startTime : String ( step . startTime ) ,
486- titlePath : step . titlePath ( ) . join ( "->" ) ,
487- stepsCount : String ( step . steps . length ) ,
488- } ;
489-
490- if ( step . error ) {
491- const errorMessage =
492- step . error . message ?. replace ( / \r ? \n | \r / g, " " ) ??
493- // [TODO] trim message?
494- JSON . stringify ( step . error . message ) ;
495- labels . errorMessage = errorMessage ;
496- labels . errorSnippet = String ( step . error . snippet ?? "<unknown snippet>" ) ;
497- labels . errorStack = String ( step . error . stack ?? "<empty stack>" ) ;
498- labels . errorValue = String ( step . error . value ?? "<unknown value>" ) ;
499- labels . errorPath = this . location ( step . error ) ;
500-
501- this . test_step_total_error . labels ( labels ) . inc ( ) ;
502- this . test_step_error_count . labels ( labels ) . inc ( ) ;
503- }
504-
505- this . test_step_total_duration . inc ( step . duration ) ;
506- this . test_step_total_count . inc ( ) ;
507- this . test_step_duration . labels ( labels ) . inc ( step . duration ) ;
508-
509- await this . send (
510- [ this . test_step_duration , this . test_step_error_count ] . map ( ( m ) =>
511- this . mapTimeseries ( m ) ,
512- ) ,
513- ) ;
514- }
515-
516508 await this . send ( [
517509 this . mapTimeseries ( this . test_step ) ,
518510 this . mapTimeseries ( this . test_step_total_duration ) ,
@@ -526,7 +518,7 @@ export default defineConfig({
526518 this . mapTimeseries ( this . test_step_total_count ) ,
527519 ] ) ;
528520
529- this . test_step . reset ( ) ;
521+ this . test_step = this . test_step . reset ( ) ;
530522 this . test_annotation_count . reset ( ) ;
531523 this . test = this . test . reset ( ) ;
532524 this . test_duration = this . test_duration . reset ( ) ;
0 commit comments