
Add custom spans
Usecontext.tracer inside a task to add spans around meaningful parts of your own code.
trace_id and span_id.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use built-in workflow traces and custom spans to inspect job execution, task duration, and bottlenecks.


context.tracer inside a task to add spans around meaningful parts of your own code.
from tilebox.workflows import ExecutionContext, Task
class ProcessScene(Task):
scene_id: str
def execute(self, context: ExecutionContext) -> None:
with context.tracer.span("download-scene") as span:
span.set_attribute("scene_id", self.scene_id)
# download input data
with context.tracer.span("compute-index"):
# perform expensive computation
pass
package tasks
import (
"context"
"github.com/tilebox/tilebox-go/workflows/v1"
)
type ProcessScene struct{}
func (t *ProcessScene) Execute(ctx context.Context) error {
return workflows.WithSpan(ctx, "compute-index", func(ctx context.Context) error {
// perform expensive computation
return nil
})
}
trace_id and span_id.
class ProcessScene(Task):
scene_id: str
def execute(self, context: ExecutionContext) -> None:
with context.tracer.span("publish-output") as span:
try:
# publish output
pass
except Exception as error:
span.record_exception(error)
raise
package tasks
import (
"context"
"fmt"
"github.com/tilebox/tilebox-go/workflows/v1"
)
type ProcessScene struct{}
func (t *ProcessScene) Execute(ctx context.Context) error {
return workflows.WithSpan(ctx, "publish-output", func(ctx context.Context) error {
if err := publishOutput(); err != nil {
return fmt.Errorf("failed to publish output: %w", err)
}
return nil
})
}
func publishOutput() error {
return nil
}
from tilebox.workflows import Client
client = Client()
job = client.jobs().submit("process-scene", ProcessScene(scene_id="S2A_001"))
spans = client.jobs().query_spans(job)
for span in spans:
print(span.name, span.status_code, span.duration)
df = spans.to_pandas()
package main
import (
"context"
"fmt"
"log/slog"
"time"
"github.com/google/uuid"
"github.com/tilebox/tilebox-go/workflows/v1"
)
func main() {
ctx := context.Background()
client := workflows.NewClient()
jobID := uuid.MustParse("019e07b1-916b-0630-f3ba-f1c33235d174")
for span, err := range client.Jobs.QuerySpans(ctx, jobID) {
if err != nil {
slog.ErrorContext(ctx, "failed to query job spans", slog.Any("error", err))
return
}
fmt.Printf("%s %-40s %s\n",
span.StartTime.Format(time.RFC3339Nano),
span.Name,
span.Duration(),
)
}
}
Was this page helpful?