✨ Capture traces
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package navi
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -13,6 +14,7 @@ var R *RoadApp
|
||||
func ReadInConfig(root string) error {
|
||||
instance := &RoadApp{
|
||||
Regions: make([]*Region, 0),
|
||||
Traces: make([]RoadTrace, 0, viper.GetInt("performance.traces_limit")),
|
||||
}
|
||||
|
||||
if err := filepath.Walk(root, func(fp string, info os.FileInfo, _ error) error {
|
||||
|
25
pkg/navi/metrics.go
Normal file
25
pkg/navi/metrics.go
Normal file
@ -0,0 +1,25 @@
|
||||
package navi
|
||||
|
||||
import "github.com/spf13/viper"
|
||||
|
||||
type RoadTrace struct {
|
||||
Region string `json:"region"`
|
||||
Location string `json:"location"`
|
||||
Destination string `json:"destination"`
|
||||
Uri string `json:"uri"`
|
||||
IpAddress string `json:"ip_address"`
|
||||
UserAgent string `json:"user_agent"`
|
||||
Error RoadTraceError `json:"error"`
|
||||
}
|
||||
|
||||
type RoadTraceError struct {
|
||||
IsNull bool `json:"is_null"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (v *RoadApp) AddTrace(trace RoadTrace) {
|
||||
v.Traces = append(v.Traces, trace)
|
||||
if len(v.Traces) > viper.GetInt("performance.traces_limit") {
|
||||
v.Traces = v.Traces[1:]
|
||||
}
|
||||
}
|
@ -7,7 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type RoadApp struct {
|
||||
Regions []*Region `json:"regions"`
|
||||
Regions []*Region `json:"regions"`
|
||||
Traces []RoadTrace `json:"traces"`
|
||||
}
|
||||
|
||||
func (v *RoadApp) Forward(ctx *fiber.Ctx, dest *Destination) error {
|
||||
|
Reference in New Issue
Block a user