Skip to content

Commit c790f92

Browse files
authored
Feat response api trace (#25)
* modify model spec, add response_id * fix baggage escape
1 parent 198c597 commit c790f92

5 files changed

Lines changed: 14 additions & 12 deletions

File tree

CHANGLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.1.16] - 2025-11-10
2+
### Fixed
3+
- fix baggage escape problem
4+
15
## [0.1.15] - 2025-10-23
26
### Added
37
- support set spanID when StartSpan

internal/trace/span.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,10 @@ func (s *Span) SetBaggage(ctx context.Context, baggageItems map[string]string) {
742742
return
743743
}
744744

745-
s.setBaggage(ctx, baggageItems, true)
745+
s.setBaggage(ctx, baggageItems)
746746
}
747747

748-
func (s *Span) setBaggage(ctx context.Context, baggageItems map[string]string, escape bool) {
748+
func (s *Span) setBaggage(ctx context.Context, baggageItems map[string]string) {
749749
if s == nil {
750750
return
751751
}
@@ -760,10 +760,6 @@ func (s *Span) setBaggage(ctx context.Context, baggageItems map[string]string, e
760760
s.SetTags(ctx, map[string]interface{}{key: value})
761761
newKey := key
762762
newValue := value
763-
if escape {
764-
newKey = url.QueryEscape(key)
765-
newValue = url.QueryEscape(value)
766-
}
767763
s.SetBaggageItem(newKey, newValue)
768764
}
769765
}
@@ -928,7 +924,7 @@ func (s *Span) toHeaderBaggage() (string, error) {
928924
tempV := v
929925
// empty key or value is invalid
930926
if tempK != "" && tempV != "" {
931-
m[tempK] = tempV
927+
m[url.QueryEscape(tempK)] = url.QueryEscape(tempV)
932928
}
933929
}
934930
return util.MapToStringString(m), nil

internal/trace/trace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (t *Provider) startSpan(ctx context.Context, spanName string, spanType stri
190190
}
191191

192192
// 3. set Baggage from parent span
193-
s.setBaggage(ctx, options.Baggage, false)
193+
s.setBaggage(ctx, options.Baggage)
194194

195195
return s
196196
}

internal/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ package internal
55

66
// Version returns the version of the loop package.
77
func Version() string {
8-
return "v0.1.15"
8+
return "v0.1.16"
99
}

spec/tracespec/model.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import "encoding/json"
77

88
// ModelInput is the input for model span, for tag key: input
99
type ModelInput struct {
10-
Messages []*ModelMessage `json:"messages,omitempty"`
11-
Tools []*ModelTool `json:"tools,omitempty"`
12-
ModelToolChoice *ModelToolChoice `json:"tool_choice,omitempty"`
10+
Messages []*ModelMessage `json:"messages,omitempty"`
11+
Tools []*ModelTool `json:"tools,omitempty"`
12+
ModelToolChoice *ModelToolChoice `json:"tool_choice,omitempty"`
13+
PreviousResponseID string `json:"previous_response_id,omitempty"`
1314
}
1415

1516
// ModelOutput is the output for model span, for tag key: output
1617
type ModelOutput struct {
18+
ID string `json:"id,omitempty"`
1719
Choices []*ModelChoice `json:"choices"`
1820
}
1921

0 commit comments

Comments
 (0)