workflows
workflows.WithTaskSpanResult
Copy
Ask AI
type Task struct{}
func (t *Task) Execute(ctx context.Context) error {
result, err := workflows.WithTaskSpanResult(ctx, "Expensive Compute", func(ctx context.Context) (int, error) {
return 6 * 7, nil
})
if err != nil {
return fmt.Errorf("failed to compute: %w", err)
}
return nil
}
Copy
Ask AI
workflows.WithTaskSpanResult[Result any](
ctx context.Context,
name string,
f func(ctx context.Context) (Result, error),
) (Result, error)
Wrap a function with a tracing span.
Parameters
The name of the span
The function to wrap
Returns
The result of the function and an error if any.
Copy
Ask AI
type Task struct{}
func (t *Task) Execute(ctx context.Context) error {
result, err := workflows.WithTaskSpanResult(ctx, "Expensive Compute", func(ctx context.Context) (int, error) {
return 6 * 7, nil
})
if err != nil {
return fmt.Errorf("failed to compute: %w", err)
}
return nil
}
Was this page helpful?
Copy
Ask AI
type Task struct{}
func (t *Task) Execute(ctx context.Context) error {
result, err := workflows.WithTaskSpanResult(ctx, "Expensive Compute", func(ctx context.Context) (int, error) {
return 6 * 7, nil
})
if err != nil {
return fmt.Errorf("failed to compute: %w", err)
}
return nil
}
Assistant
Responses are generated using AI and may contain mistakes.