Skip to content

Commit

Permalink
Replace ParseTraceState with ParseTraceStateString
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed May 20, 2021
1 parent 65cc4c9 commit d5d7bee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions trace/tracestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,10 @@ type TraceState struct { //nolint:golint

var _ json.Marshaler = TraceState{}

// ParseTraceState attempts to decode a TraceState from the passed byte slice.
// It returns an error if the input is invalid according to the W3C
// tracecontext specification.
func ParseTraceState(tracestate []byte) (TraceState, error) {
return ParseTraceStateString(string(tracestate))
}

// ParseTraceStateString attempts to decode a TraceState from the passed
// ParseTraceState attempts to decode a TraceState from the passed
// string. It returns an error if the input is invalid according to the W3C
// tracecontext specification.
func ParseTraceStateString(tracestate string) (TraceState, error) {
func ParseTraceState(tracestate string) (TraceState, error) {
if tracestate == "" {
return TraceState{}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions trace/tracestate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ var maxMembers = func() TraceState {
return TraceState{members: members}
}()

func TestParseTraceStateString(t *testing.T) {
func TestParseTraceState(t *testing.T) {
for _, tc := range testcases {
got, err := ParseTraceState([]byte(tc.in))
got, err := ParseTraceState(tc.in)
assert.Equal(t, tc.tracestate, got)
if tc.err != nil {
assert.ErrorIs(t, err, tc.err, tc.in)
Expand Down

0 comments on commit d5d7bee

Please sign in to comment.