@@ -18,6 +18,7 @@ import (
18
18
"testing"
19
19
"time"
20
20
21
+ "github.com/goccy/go-json"
21
22
"github.com/k1LoW/concgroup"
22
23
"github.com/k1LoW/stopw"
23
24
"github.com/ryo-yamaoka/otchkiss"
@@ -39,6 +40,7 @@ type operator struct {
39
40
steps []* step
40
41
store store
41
42
desc string
43
+ labels []string
42
44
useMap bool // Use map syntax in `steps:`.
43
45
debug bool
44
46
disableProfile bool
@@ -420,6 +422,7 @@ func New(opts ...Option) (*operator, error) {
420
422
},
421
423
useMap : bk .useMap ,
422
424
desc : bk .desc ,
425
+ labels : bk .labels ,
423
426
debug : bk .debug ,
424
427
disableProfile : bk .disableProfile ,
425
428
interval : bk .interval ,
@@ -441,7 +444,7 @@ func New(opts ...Option) (*operator, error) {
441
444
afterFuncs : bk .afterFuncs ,
442
445
sw : stopw .New (),
443
446
capturers : bk .capturers ,
444
- runResult : newRunResult (bk .desc , bk .path ),
447
+ runResult : newRunResult (bk .desc , bk .labels , bk . path ),
445
448
}
446
449
447
450
if o .debug {
@@ -776,7 +779,7 @@ func (o *operator) Result() *RunResult {
776
779
}
777
780
778
781
func (o * operator ) clearResult () {
779
- o .runResult = newRunResult (o .desc , o .bookPathOrID ())
782
+ o .runResult = newRunResult (o .desc , o .labels , o . bookPathOrID ())
780
783
o .runResult .ID = o .runbookID ()
781
784
for _ , s := range o .steps {
782
785
s .clearResult ()
@@ -1511,20 +1514,23 @@ func setElasped(r *RunResult, result *stopw.Span) error {
1511
1514
1512
1515
// collectStepElaspedByRunbookIDFull collects the elapsed time of each step by runbook ID.
1513
1516
func collectStepElaspedByRunbookIDFull (r * stopw.Span , trs Trails , m map [string ]time.Duration ) map [string ]time.Duration {
1514
- t , ok := r .ID .(Trail )
1517
+ var t Trail
1518
+ s , ok := r .ID .(string )
1515
1519
if ok {
1516
- trs = append (trs , t )
1517
- switch t .Type {
1518
- case TrailTypeRunbook :
1519
- id := trs .runbookID ()
1520
- if ! strings .Contains (id , "?step=" ) {
1521
- // Collect root runbook only
1520
+ if err := json .Unmarshal ([]byte (s ), & t ); err != nil {
1521
+ trs = append (trs , t )
1522
+ switch t .Type {
1523
+ case TrailTypeRunbook :
1524
+ id := trs .runbookID ()
1525
+ if ! strings .Contains (id , "?step=" ) {
1526
+ // Collect root runbook only
1527
+ m [id ] += r .Elapsed
1528
+ }
1529
+ case TrailTypeStep :
1530
+ // Collect steps
1531
+ id := trs .runbookID ()
1522
1532
m [id ] += r .Elapsed
1523
1533
}
1524
- case TrailTypeStep :
1525
- // Collect steps
1526
- id := trs .runbookID ()
1527
- m [id ] += r .Elapsed
1528
1534
}
1529
1535
}
1530
1536
for _ , b := range r .Breakdown {
0 commit comments