Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGLOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [0.1.14] - 2025-10-17
## [0.1.15] - 2025-10-23
### Added
- support set spanID when StartSpan

## [0.1.14] - 2025-10-17
### Modified
- fix span lock

## [0.1.13] - 2025-09-24
Expand Down
8 changes: 7 additions & 1 deletion internal/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Options struct {
type StartSpanOptions struct {
StartTime time.Time
ParentSpanID string
SpanID string
TraceID string
Baggage map[string]string
StartNewTrace bool
Expand Down Expand Up @@ -133,6 +134,11 @@ func (t *Provider) startSpan(ctx context.Context, spanName string, spanType stri
parentID = options.ParentSpanID
}

spanID := options.SpanID
if len(spanID) == 0 {
spanID = util.Gen16CharID()
}

traceID := ""
if options.TraceID != "" {
traceID = options.TraceID
Expand Down Expand Up @@ -160,7 +166,7 @@ func (t *Provider) startSpan(ctx context.Context, spanName string, spanType stri
// 2. create span and init
s := &Span{
SpanContext: SpanContext{
SpanID: util.Gen16CharID(),
SpanID: spanID,
TraceID: traceID,
Baggage: make(map[string]string),
},
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ package internal

// Version returns the version of the loop package.
func Version() string {
return "v0.1.14"
return "v0.1.15"
}
9 changes: 9 additions & 0 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ func WithSpanWorkspaceID(workspaceID string) StartSpanOption {
ops.WorkspaceID = workspaceID
}
}

// WithSpanID Set the spanID of the span.
// Only use when specifying a SpanID! By default, SDK can automatically generate a SpanID
// SpanID must be a combination of 16 digits and letters.
func WithSpanID(spanID string) StartSpanOption {
return func(ops *startSpanOptions) {
ops.SpanID = spanID
}
}
Loading