@@ -58,6 +58,43 @@ var e2eTracingTests = []backendTest{
58
58
)
59
59
},
60
60
},
61
+ {
62
+ name : "Tracing/TimersHaveSpans" ,
63
+ f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
64
+ exporter := setupTracing (b )
65
+
66
+ wf := func (ctx workflow.Context ) error {
67
+ workflow .ScheduleTimer (ctx , time .Millisecond * 20 ).Get (ctx )
68
+
69
+ return nil
70
+ }
71
+ register (t , ctx , w , []interface {}{wf }, nil )
72
+
73
+ instance := runWorkflow (t , ctx , c , wf )
74
+ _ , err := client .GetWorkflowResult [any ](ctx , c , instance , time .Second * 5 )
75
+ require .NoError (t , err )
76
+
77
+ spans := exporter .GetSpans ().Snapshots ()
78
+
79
+ workflow1Span := findSpan (spans , func (span trace.ReadOnlySpan ) bool {
80
+ return strings .Contains (span .Name (), "Workflow: 1" )
81
+ })
82
+ require .NotNil (t , workflow1Span )
83
+
84
+ timerSpan := findSpan (spans , func (span trace.ReadOnlySpan ) bool {
85
+ return strings .Contains (span .Name (), "Timer" )
86
+ })
87
+ require .NotNil (t , workflow1Span )
88
+ require .InEpsilon (t , time .Duration (20 * time .Millisecond ),
89
+ timerSpan .EndTime ().Sub (timerSpan .StartTime ())/ time .Millisecond ,
90
+ float64 (5 * time .Millisecond ))
91
+
92
+ require .Equal (t ,
93
+ workflow1Span .SpanContext ().SpanID ().String (),
94
+ timerSpan .Parent ().SpanID ().String (),
95
+ )
96
+ },
97
+ },
61
98
{
62
99
name : "Tracing/SubWorkflowsHaveSpansWithCorrectParent" ,
63
100
f : func (t * testing.T , ctx context.Context , c * client.Client , w * worker.Worker , b TestBackend ) {
@@ -96,13 +133,18 @@ var e2eTracingTests = []backendTest{
96
133
})
97
134
require .NotNil (t , workflow1Span )
98
135
136
+ createSWFSpan := findSpan (spans , func (span trace.ReadOnlySpan ) bool {
137
+ return strings .Contains (span .Name (), "CreateSubworkflowInstance: swf" )
138
+ })
139
+ require .NotNil (t , createSWFSpan )
140
+
99
141
workflow2Span := findSpan (spans , func (span trace.ReadOnlySpan ) bool {
100
142
return strings .Contains (span .Name (), "Workflow: swf" )
101
143
})
102
144
require .NotNil (t , workflow1Span )
103
145
104
146
require .Equal (t ,
105
- workflow1Span .SpanContext ().SpanID ().String (),
147
+ createSWFSpan .SpanContext ().SpanID ().String (),
106
148
workflow2Span .Parent ().SpanID ().String (),
107
149
)
108
150
},
0 commit comments