sourcegraph / appdash

Application tracing system for Go, based on Google's Dapper.

Home Page:https://sourcegraph.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why Annotations type is slice , not map[string][]byte?

1046102779 opened this issue · comments

Annotations's methods include

func (as Annotations) get(key string) []byte {...}

func (as Annotations) schemas() []string {...}

these method' implementation hasn't consider multiple same keys

Those methods are not exported, and they explicitly document the behaviour. I'm unsure why it isn't a map. Maybe @slimsag remembers why?

but the method 'annotationsFromWire' uses pb data to append annotations, if client annotations with SQL, and the server uses the method to append , and it will be occur overide key= "SQL"

It's been multiple years since I've looked at Appdash code. Unfortunately, I don't remember why this was done this way.

My best guess: It may have just been that Annotations only need to be unique for a span, so the change of overlap was small if the SQL key included e.g. the actual SQL query being executed (which IIRC was the case).

i know why.

Annotations type is slice , and its store&get operations is in order, and map is disorder

when we get data from annotations, it keeps original order is pretty good. the same type's data is tobe together. a unit is "_schema:xxx"

        "Client.Request.Headers.Connection":    "close",
        "Client.Request.Headers.Accept":        "application/json",
        "Client.Request.Headers.Authorization": "REDACTED",
        "Client.Request.Proto":                 "HTTP/1.1",
        "Client.Request.RemoteAddr":            "127.0.0.1",
        "Client.Request.Host":                  "example.com",
        "Client.Request.ContentLength":         "0",
        "Client.Request.Method":                "GET",
        "Client.Request.URI":                   "/foo",
        "Client.Response.StatusCode":           "200",
        "Client.Response.ContentLength":        "0",
        "Client.Send":                          "0001-01-01T00:00:00Z",
        "Client.Recv":                          "0001-01-01T00:00:00Z",
         "_schema:HTTPClient":                   "",
       
         ......
        "_schema:msg":  "",
       
        .......
       "_schema:timestamp": "",