Frontend Logging: Integrate grafana javascript agent (#50801)

Add Grafana Javascript Agent integration to Grafana
This commit is contained in:
Timur Olzhabayev
2022-06-28 03:25:30 -04:00
committed by GitHub
parent 849d4a3c56
commit 7c886fb6f9
29 changed files with 1496 additions and 36 deletions
@@ -0,0 +1,28 @@
package frontendlogging
import (
"fmt"
)
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
}