@@ -102,11 +102,22 @@ func (c *client) CreateWorkflowInstance(ctx context.Context, options WorkflowIns
102
102
}
103
103
104
104
func (c * client ) CancelWorkflowInstance (ctx context.Context , instance * workflow.Instance ) error {
105
+ ctx , span := c .backend .Tracer ().Start (ctx , "CancelWorkflowInstance" , trace .WithAttributes (
106
+ attribute .String (log .InstanceIDKey , instance .InstanceID ),
107
+ ))
108
+ defer span .End ()
109
+
105
110
cancellationEvent := history .NewWorkflowCancellationEvent (time .Now ())
106
111
return c .backend .CancelWorkflowInstance (ctx , instance , cancellationEvent )
107
112
}
108
113
109
114
func (c * client ) SignalWorkflow (ctx context.Context , instanceID string , name string , arg interface {}) error {
115
+ ctx , span := c .backend .Tracer ().Start (ctx , "SignalWorkflow" , trace .WithAttributes (
116
+ attribute .String (log .InstanceIDKey , instanceID ),
117
+ attribute .String (log .SignalNameKey , name ),
118
+ ))
119
+ defer span .End ()
120
+
110
121
input , err := c .backend .Converter ().To (arg )
111
122
if err != nil {
112
123
return fmt .Errorf ("converting arguments: %w" , err )
@@ -136,6 +147,11 @@ func (c *client) WaitForWorkflowInstance(ctx context.Context, instance *workflow
136
147
timeout = time .Second * 20
137
148
}
138
149
150
+ ctx , span := c .backend .Tracer ().Start (ctx , "WaitForWorkflowInstance" , trace .WithAttributes (
151
+ attribute .String (log .InstanceIDKey , instance .InstanceID ),
152
+ ))
153
+ defer span .End ()
154
+
139
155
b := backoff.ExponentialBackOff {
140
156
InitialInterval : time .Millisecond * 1 ,
141
157
MaxInterval : time .Second * 1 ,
@@ -167,13 +183,18 @@ func (c *client) WaitForWorkflowInstance(ctx context.Context, instance *workflow
167
183
// GetWorkflowResult gets the workflow result for the given workflow result. It first waits for the workflow to finish or until
168
184
// the given timeout has expired.
169
185
func GetWorkflowResult [T any ](ctx context.Context , c Client , instance * workflow.Instance , timeout time.Duration ) (T , error ) {
186
+ ic := c .(* client )
187
+ b := ic .backend
188
+
189
+ ctx , span := b .Tracer ().Start (ctx , "GetWorkflowResult" , trace .WithAttributes (
190
+ attribute .String (log .InstanceIDKey , instance .InstanceID ),
191
+ ))
192
+ defer span .End ()
193
+
170
194
if err := c .WaitForWorkflowInstance (ctx , instance , timeout ); err != nil {
171
195
return * new (T ), fmt .Errorf ("workflow did not finish in time: %w" , err )
172
196
}
173
197
174
- ic := c .(* client )
175
- b := ic .backend
176
-
177
198
h , err := b .GetWorkflowInstanceHistory (ctx , instance , nil )
178
199
if err != nil {
179
200
return * new (T ), fmt .Errorf ("getting workflow history: %w" , err )
@@ -208,5 +229,10 @@ func GetWorkflowResult[T any](ctx context.Context, c Client, instance *workflow.
208
229
}
209
230
210
231
func (c * client ) RemoveWorkflowInstance (ctx context.Context , instance * core.WorkflowInstance ) error {
232
+ ctx , span := c .backend .Tracer ().Start (ctx , "RemoveWorkflowInstance" , trace .WithAttributes (
233
+ attribute .String (log .InstanceIDKey , instance .InstanceID ),
234
+ ))
235
+ defer span .End ()
236
+
211
237
return c .backend .RemoveWorkflowInstance (ctx , instance )
212
238
}
0 commit comments