ds

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PacketTypeLog          = "log"
	PacketTypeAppInfo      = "appinfo"
	PacketTypeGoroutine    = "goroutine"
	PacketTypeAppDone      = "appdone"
	PacketTypeWatch        = "watch"
	PacketTypeRuntimeStats = "runtimestats"
)

Transport packet types

View Source
const (
	// Preserve lower 5 bits for reflect.Kind (0-31)
	KindMask = 0x1F // 00000000_00011111

	// Shift existing flags up by 5 bits
	WatchFlag_Push     = 1 << 5  // 00000000_00100000
	WatchFlag_Counter  = 1 << 6  // 00000000_01000000
	WatchFlag_Atomic   = 1 << 7  // 00000000_10000000
	WatchFlag_Sync     = 1 << 8  // 00000001_00000000
	WatchFlag_Func     = 1 << 9  // 00000010_00000000
	WatchFlag_Hook     = 1 << 10 // 00000100_00000000
	WatchFlag_Settable = 1 << 11 // 00001000_00000000
	WatchFlag_JSON     = 1 << 12 // 00010000_00000000
	WatchFlag_GoFmt    = 1 << 13 // 00100000_00000000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppInfo

type AppInfo struct {
	AppRunId   string         `json:"apprunid"`
	AppName    string         `json:"appname"`
	ModuleName string         `json:"modulename"`
	Executable string         `json:"executable"`
	Args       []string       `json:"args"`
	Env        []string       `json:"env"`
	StartTime  int64          `json:"starttime"`
	Pid        int            `json:"pid"`
	User       string         `json:"user,omitempty"`
	Hostname   string         `json:"hostname,omitempty"`
	BuildInfo  *BuildInfoData `json:"buildinfo,omitempty"`
}

type BuildInfoData

type BuildInfoData struct {
	GoVersion string            `json:"goversion"`
	Path      string            `json:"path"`
	Version   string            `json:"version,omitempty"`
	Settings  map[string]string `json:"settings,omitempty"`
}

BuildInfoData represents a simplified version of runtime/debug.BuildInfo

type ClientType

type ClientType struct {
	Conn       net.Conn
	ClientAddr string
}

ClientType represents our active connection client

type Config

type Config struct {
	// DomainSocketPath is the path to the Unix domain socket. If "" => use default.
	// If "-" => disable domain socket.
	DomainSocketPath string

	// AppName is the name of the application. If not specified, it will be determined
	// from the executable name.
	AppName string

	// ModuleName is the name of the Go module. If not specified, it will be determined
	// from the go.mod file.
	ModuleName string

	// Dev indicates whether the client is in development mode
	Dev bool

	StartAsync bool

	// Collector configurations
	LogProcessorConfig LogProcessorConfig
	WatchConfig        WatchConfig
	GoRoutineConfig    GoRoutineConfig
	RuntimeStatsConfig RuntimeStatsConfig
}

type Controller

type Controller interface {
	Enable()
	Disable(disconnect bool)

	Connect() bool
	Disconnect()

	// Configuration
	GetConfig() Config
	GetAppRunId() string

	// Transport
	SendPacket(pk *PacketType) (bool, error)

	Shutdown()
}

type GoRoutineConfig

type GoRoutineConfig struct {
	// Enabled indicates whether the goroutine collector is enabled
	Enabled bool
}

type GoRoutineStack

type GoRoutineStack struct {
	GoId       int64    `json:"goid"`
	State      string   `json:"state"`
	StackTrace string   `json:"stacktrace"` // does not include the goroutine header (goid + state)
	Name       string   `json:"name,omitempty"`
	Tags       []string `json:"tags,omitempty"`
}

type GoroutineInfo

type GoroutineInfo struct {
	Ts     int64            `json:"ts"`
	Count  int              `json:"count"`
	Stacks []GoRoutineStack `json:"stacks"`
}

type LogLine

type LogLine struct {
	LineNum int64  `json:"linenum"`
	Ts      int64  `json:"ts"`
	Msg     string `json:"msg"`
	Source  string `json:"source,omitempty"`
}

type LogProcessorConfig

type LogProcessorConfig struct {
	// Enabled indicates whether the log processor is enabled
	Enabled    bool
	WrapStdout bool
	WrapStderr bool
	// OutrigPath is the full path to the outrig executable (including the executable name)
	// If empty, the system will look for "outrig" in the PATH
	OutrigPath string
	// AdditionalArgs are additional arguments to pass to the outrig command
	// These are inserted before the "capturelogs" argument
	AdditionalArgs []string
}

type MemoryStatsInfo

type MemoryStatsInfo struct {
	Alloc            uint64 `json:"alloc"`
	TotalAlloc       uint64 `json:"totalalloc"`
	Sys              uint64 `json:"sys"`
	HeapAlloc        uint64 `json:"heapalloc"`
	HeapSys          uint64 `json:"heapsys"`
	HeapIdle         uint64 `json:"heapidle"`
	HeapInuse        uint64 `json:"heapinuse"`
	StackInuse       uint64 `json:"stackinuse"`
	StackSys         uint64 `json:"stacksys"`
	MSpanInuse       uint64 `json:"mspaninuse"`
	MSpanSys         uint64 `json:"mspansys"`
	MCacheInuse      uint64 `json:"mcacheinuse"`
	MCacheSys        uint64 `json:"mcachesys"`
	GCSys            uint64 `json:"gcsys"`
	OtherSys         uint64 `json:"othersys"`
	NextGC           uint64 `json:"nextgc"`
	LastGC           uint64 `json:"lastgc"`
	PauseTotalNs     uint64 `json:"pausetotalns"`
	NumGC            uint32 `json:"numgc"`
	TotalHeapObj     uint64 `json:"totalheapobj"`
	TotalHeapObjFree uint64 `json:"totalheapobjfree"`
}

type PacketType

type PacketType struct {
	Type string `json:"type"`
	Data any    `json:"data"`
}

type RuntimeStatsConfig

type RuntimeStatsConfig struct {
	// Enabled indicates whether the runtime stats collector is enabled
	Enabled bool
}

type RuntimeStatsInfo

type RuntimeStatsInfo struct {
	Ts             int64           `json:"ts"`
	CPUUsage       float64         `json:"cpuusage"`
	GoRoutineCount int             `json:"goroutinecount"`
	GoMaxProcs     int             `json:"gomaxprocs"`
	NumCPU         int             `json:"numcpu"`
	GOOS           string          `json:"goos"`
	GOARCH         string          `json:"goarch"`
	GoVersion      string          `json:"goversion"`
	Pid            int             `json:"pid"`
	Cwd            string          `json:"cwd"`
	MemStats       MemoryStatsInfo `json:"memstats"`
}

type ViewWindow

type ViewWindow struct {
	Start int `json:"start"`
	Size  int `json:"size"`
}

func (ViewWindow) End

func (vw ViewWindow) End() int

type WatchConfig

type WatchConfig struct {
	// Enabled indicates whether the watch collector is enabled
	Enabled bool
}

type WatchInfo

type WatchInfo struct {
	Ts      int64         `json:"ts"`
	Watches []WatchSample `json:"watches"`
}

type WatchSample

type WatchSample struct {
	WatchNum int64    `json:"watchnum,omitempty"`
	Name     string   `json:"name"`
	Tags     []string `json:"tags,omitempty"`
	Ts       int64    `json:"ts"`
	Flags    int      `json:"flags,omitempty"`
	Value    string   `json:"value,omitempty"`
	Type     string   `json:"type"`
	Error    string   `json:"error,omitempty"`
	Addr     []string `json:"addr,omitempty"`
	Cap      int      `json:"cap,omitempty"`
	Len      int      `json:"len,omitempty"`
	WaitTime int64    `json:"waittime,omitempty"`
}

func (*WatchSample) GetKind

func (w *WatchSample) GetKind() uint

GetKind extracts the reflect.Kind from the flags

func (*WatchSample) GetNumericVal

func (w *WatchSample) GetNumericVal() float64

GetNumericVal returns a float64 representation of the value

func (*WatchSample) IsNumeric

func (w *WatchSample) IsNumeric() bool

IsNumeric checks if the value is numeric based on its Kind

func (*WatchSample) SetKind

func (w *WatchSample) SetKind(kind uint)

SetKind sets the reflect.Kind in the flags

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL