The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/api/frontendlogging/grafana_javascript_agent.go

30 lines
880 B

package frontendlogging
import (
"fmt"
)
type CtxVector []interface{}
type FrontendGrafanaJavascriptAgentEvent struct {
Exceptions []Exception `json:"exceptions,omitempty"`
Logs []Log `json:"logs,omitempty"`
Measurements []Measurement `json:"measurements,omitempty"`
Meta Meta `json:"meta,omitempty"`
Traces *Traces `json:"traces,omitempty"`
}
// KeyValToInterfaceMap converts KeyVal to map[string]interface
func KeyValToInterfaceMap(kv *KeyVal) map[string]interface{} {
retv := make(map[string]interface{})
for el := kv.Oldest(); el != nil; el = el.Next() {
retv[fmt.Sprint(el.Key)] = el.Value
}
return retv
}
func (event *FrontendGrafanaJavascriptAgentEvent) AddMetaToContext(ctx CtxVector) []interface{} {
for k, v := range KeyValToInterfaceMap(event.Meta.KeyVal()) {
ctx = append(ctx, k, v)
}
return ctx
}