Documentation
¶
Overview ¶
Package gospantimeline implements timeline.Timeline with gospan spans and an in-memory projection. No collector, database, or process-global tracer is used.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(_ context.Context, id, operation string, attributes ...timeline.Attribute) (timeline.Timeline, error)
New begins an operation with a non-empty, immutable caller-supplied ID. It does not bind the returned Timeline to context. The construction context does not own the operation lifetime; the completion owner must call Finish.
Example ¶
package main
import (
"context"
"fmt"
"time"
"github.com/compforge/go-stdx/timeline"
gospantimeline "github.com/compforge/go-stdx/timeline/gospan"
)
func main() {
ctx := context.Background()
tl, err := gospantimeline.New(ctx, "start-42", "sandbox.start",
timeline.Attribute{Key: "sandbox_id", Value: "sandbox-1"})
if err != nil {
panic(err)
}
prepareCtx, prepare := timeline.BeginWithContext(ctx, tl, "prepare", timeline.WithStageActor(timeline.Actor{Name: "test"}))
_, workspace := timeline.BeginWithContext(prepareCtx, tl, "resolve_workspace", timeline.WithParent(prepare.ID()), timeline.WithStageActor(timeline.Actor{Name: "test"}))
workspace.End(nil)
prepare.End(nil)
// The completion owner uses its own collection budget. A timed-out HTTP
// request may instead call Snapshot while background work continues.
collectCtx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
result, err := tl.Finish(collectCtx, nil)
if err != nil {
panic(err)
}
fmt.Println(tl.ID() == result.ID)
fmt.Println(result.Operation, result.Status, (result.Collection.LocalFlushed && result.Collection.StoreRead))
fmt.Println(result.Stages[1].ParentID == result.Stages[0].ID)
}
Output: true sandbox.start succeeded true true
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.