> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tilebox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# workflows.WithTaskSpan

```go theme={"system"}
workflows.WithTaskSpan(
    ctx context.Context,
    name string,
    f func(ctx context.Context) error,
) error
```

Wrap a function with a [tracing span](/workflows/observability/tracing).

## Parameters

<ParamField path="name" type="string">
  The name of the span
</ParamField>

<ParamField path="f" type="func(context.Context) error">
  The function to wrap
</ParamField>

## Returns

An error if any.

<RequestExample>
  ```go Go theme={"system"}
  type Task struct{}

  func (t *Task) Execute(ctx context.Context) error {
  	err := workflows.WithTaskSpan(ctx, "Database insert", func(ctx context.Context) error {
  		// Do something
  		return nil
  	})
    if err != nil {
      return fmt.Errorf("failed to insert into database: %w", err)
    }

  	return nil
  }
  ```
</RequestExample>
