Use hexadecimal ids and lowercase names in zipkin input (#3488)
This commit is contained in:
committed by
Daniel Nelson
parent
9422cca2cc
commit
afe05fcfef
@@ -239,7 +239,7 @@ func TraceIDFromString(s string) (string, error) {
|
||||
return fmt.Sprintf("%x%016x", hi, lo), nil
|
||||
}
|
||||
|
||||
// IDFromString creates a decimal id from a hexadecimal string
|
||||
// IDFromString validates the ID and returns it in hexadecimal format.
|
||||
func IDFromString(s string) (string, error) {
|
||||
if len(s) > 16 {
|
||||
return "", fmt.Errorf("ID cannot be longer than 16 hex characters: %s", s)
|
||||
@@ -248,5 +248,5 @@ func IDFromString(s string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strconv.FormatUint(id, 10), nil
|
||||
return strconv.FormatUint(id, 16), nil
|
||||
}
|
||||
|
||||
@@ -526,14 +526,14 @@ func Test_span_SpanID(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "converts known id correctly",
|
||||
name: "validates known id correctly",
|
||||
ID: "b26412d1ac16767d",
|
||||
want: "12854419928166856317",
|
||||
want: "b26412d1ac16767d",
|
||||
},
|
||||
{
|
||||
name: "converts hex string correctly",
|
||||
name: "validates hex string correctly",
|
||||
ID: "deadbeef",
|
||||
want: "3735928559",
|
||||
want: "deadbeef",
|
||||
},
|
||||
{
|
||||
name: "errors when string isn't hex",
|
||||
@@ -576,9 +576,9 @@ func Test_span_Parent(t *testing.T) {
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "converts hex string correctly",
|
||||
name: "validates hex string correctly",
|
||||
ParentID: "deadbeef",
|
||||
want: "3735928559",
|
||||
want: "deadbeef",
|
||||
},
|
||||
{
|
||||
name: "errors when string isn't hex",
|
||||
@@ -890,9 +890,9 @@ func TestIDFromString(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Convert hex string id",
|
||||
name: "validates hex string id",
|
||||
s: "6b221d5bc9e6496c",
|
||||
want: "7719764991332993388",
|
||||
want: "6b221d5bc9e6496c",
|
||||
},
|
||||
{
|
||||
name: "error : id too long",
|
||||
|
||||
@@ -199,5 +199,5 @@ func (s *span) Duration() time.Duration {
|
||||
}
|
||||
|
||||
func formatID(id int64) string {
|
||||
return strconv.FormatInt(id, 10)
|
||||
return strconv.FormatInt(id, 16)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user