mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Added ordered results Signed-off-by: Joe Elliott <[email protected]> * add most_recent query hint Signed-off-by: Joe Elliott <[email protected]> * changelog, docs and lint Signed-off-by: Joe Elliott <[email protected]> * e2e tests - fixed tag search Signed-off-by: Joe Elliott <[email protected]> * lint Signed-off-by: Joe Elliott <[email protected]> * remove clone changes Signed-off-by: Joe Elliott <[email protected]> * review Signed-off-by: Joe Elliott <[email protected]> * make shards configurable Signed-off-by: Joe Elliott <[email protected]> * dont mess with me lint. i will uninstall you Signed-off-by: Joe Elliott <[email protected]> * Make all endpoints search backwards in time Signed-off-by: Joe Elliott <[email protected]> * nice work on this one carles Signed-off-by: Joe Elliott <[email protected]> * consolidate block meta functions Signed-off-by: Joe Elliott <[email protected]> * fix merge :P Signed-off-by: Joe Elliott <[email protected]> * remove tests Signed-off-by: Joe Elliott <[email protected]> * don't bother tracking normal searches Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
46 lines
843 B
Go
46 lines
843 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"unsafe"
|
|
|
|
"github.com/grafana/tempo/tempodb/backend"
|
|
)
|
|
|
|
type DedicatedColumnsToJSON struct {
|
|
columnsToJSON map[uint64]string
|
|
}
|
|
|
|
func NewDedicatedColumnsToJSON() *DedicatedColumnsToJSON {
|
|
return &DedicatedColumnsToJSON{
|
|
columnsToJSON: make(map[uint64]string),
|
|
}
|
|
}
|
|
|
|
func (d *DedicatedColumnsToJSON) JSONForDedicatedColumns(cols backend.DedicatedColumns) (string, error) {
|
|
if len(cols) == 0 {
|
|
return "", nil
|
|
}
|
|
|
|
hash := cols.Hash()
|
|
|
|
if jsonString, ok := d.columnsToJSON[hash]; ok {
|
|
return jsonString, nil
|
|
}
|
|
|
|
proto, err := cols.ToTempopb()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
jsonBytes, err := json.Marshal(proto)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
jsonString := unsafe.String(unsafe.SliceData(jsonBytes), len(jsonBytes))
|
|
d.columnsToJSON[hash] = jsonString
|
|
|
|
return jsonString, nil
|
|
}
|