api

package
v0.0.0-...-08e63c9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Progress EventType = "progress"
	Result   EventType = "result"
	Notice   EventType = "notice"
	Log      EventType = "log"
	Error    EventType = "error"

	Started ProgressStage = "started"
	Ended   ProgressStage = "ended"
)

Variables

View Source
var GetContainerRuntimeRootPath = map[ContainerRuntime]string{
	Crio:       "/var/lib/containers/storage",
	Containerd: "/run/containerd",
}
View Source
var GetOutputTypesByProfilingTool = map[ProfilingTool][]OutputType{
	AsyncProfiler: {FlameGraph, Jfr, Flat, Traces, Collapsed, Tree, Raw},
	Jcmd:          {Jfr, ThreadDump, HeapDump, HeapHistogram},
	Pyspy:         {FlameGraph, SpeedScope, ThreadDump, Raw},
	Bpf:           {FlameGraph, Raw},
	Perf:          {FlameGraph, Raw},
	Rbspy:         {FlameGraph, SpeedScope, Callgrind, Summary, SummaryByLine},
	NodeDummy:     {HeapSnapshot, HeapDump},
	FakeTool:      {FlameGraph},
}

GetOutputTypesByProfilingTool Gets the list of OutputType related to the ProfilingTool that they will be considered as output types. The first one is considered the default

View Source
var GetProfilingTool = func(l ProgrammingLanguage, o OutputType) ProfilingTool {
	switch l {
	case Java:
		switch o {
		case Jfr, ThreadDump, HeapDump, HeapHistogram:
			return Jcmd
		case FlameGraph, Flat, Traces, Collapsed, Tree, Raw:
			return AsyncProfiler
		}
	case Python:
		return Pyspy
	case Go, Rust:
		return Bpf
	case Clang, ClangPlusPlus:
		return Bpf
	case Ruby:
		return Rbspy
	case Node:
		switch o {
		case FlameGraph, Raw:
			return Bpf
		case HeapSnapshot, HeapDump:
			return NodeDummy
		}
	}

	return GetProfilingToolsByProgrammingLanguage[l][0]
}

GetProfilingTool Gets profiling tool related to the programming language and output event type.

View Source
var GetProfilingToolsByProgrammingLanguage = map[ProgrammingLanguage][]ProfilingTool{
	Java:          {Jcmd, AsyncProfiler},
	Python:        {Pyspy},
	Go:            {Bpf},
	Node:          {Bpf, Perf, NodeDummy},
	Clang:         {Bpf, Perf},
	ClangPlusPlus: {Bpf, Perf},
	Ruby:          {Rbspy},
	Rust:          {Bpf, Perf},
	FakeLang:      {FakeTool},
}

GetProfilingToolsByProgrammingLanguage Gets profiling tool related to the programming language. The first one is considered the default

Functions

func AvailableOutputTypesString

func AvailableOutputTypesString() string

func AvailableProfilingToolsString

func AvailableProfilingToolsString() string

func GetDataStructByType

func GetDataStructByType(t EventType) interface{}

func IsSupportedContainerRuntime

func IsSupportedContainerRuntime(runtime string) bool

func IsSupportedEvent

func IsSupportedEvent(event string) bool

func IsSupportedLanguage

func IsSupportedLanguage(lang string) bool

func IsSupportedLogLevel

func IsSupportedLogLevel(logLevel string) bool

func IsSupportedOutputType

func IsSupportedOutputType(outputType string) bool

func IsSupportedProfilingTool

func IsSupportedProfilingTool(profilingTool string) bool

func IsValidOutputType

func IsValidOutputType(OutputType OutputType, profilingTool ProfilingTool) bool

IsValidOutputType Identifies if given OutputType is valid for the also given ProfilingTool

func IsValidProfilingTool

func IsValidProfilingTool(tool ProfilingTool, language ProgrammingLanguage) bool

IsValidProfilingTool Identifies if given ProfilingTool is valid for the also given ProgrammingLanguage

func ParseEvent

func ParseEvent(eventString string) (interface{}, error)

Types

type ChunkData

type ChunkData struct {
	File            string `json:"file"`
	FileSizeInBytes int64  `json:"file-size-in-bytes"`
	Checksum        string `json:"checksum"`
}

type ContainerRuntime

type ContainerRuntime string
const (
	Crio       ContainerRuntime = "crio"
	Containerd ContainerRuntime = "containerd"

	FakeContainer                                      ContainerRuntime = "fake"
	FakeContainerWithRootFileSystemLocationResultError ContainerRuntime = "fakeWithRootFileSystemLocationResultError"
	FakeContainerWithPIDResultError                    ContainerRuntime = "fakeWithPIDResultError"
	FakeContainerWithCWDResultError                    ContainerRuntime = "fakeWithCWDResultError"
)

func AvailableContainerRuntimes

func AvailableContainerRuntimes() []ContainerRuntime

type ErrorData

type ErrorData struct {
	Reason string `json:"reason"`
}

type Event

type Event struct {
	Type EventType            `json:"type"`
	Data *jsoniter.RawMessage `json:"data"`
}

type EventType

type EventType string

type LogData

type LogData struct {
	Time  time.Time `json:"time"`
	Level string    `json:"level"`
	Msg   string    `json:"msg"`
}

type LogLevel

type LogLevel string
const (
	InfoLevel  LogLevel = "info"
	WarnLevel  LogLevel = "warn"
	DebugLevel LogLevel = "debug"
	TraceLevel LogLevel = "trace"
	ErrorLevel LogLevel = "error"
	PanicLevel LogLevel = "panic"
)

func AvailableLogLevels

func AvailableLogLevels() []LogLevel

type NoticeData

type NoticeData struct {
	Time time.Time `json:"time"`
	Msg  string    `json:"msg"`
}

type OutputType

type OutputType string
const (
	FlameGraph    OutputType = "flamegraph"
	SpeedScope    OutputType = "speedscope"
	Jfr           OutputType = "jfr"
	ThreadDump    OutputType = "threaddump"
	HeapDump      OutputType = "heapdump"
	HeapHistogram OutputType = "heaphistogram"
	Flat          OutputType = "flat"
	Traces        OutputType = "traces"
	Collapsed     OutputType = "collapsed"
	Tree          OutputType = "tree"
	Callgrind     OutputType = "callgrind"
	Raw           OutputType = "raw"
	Pprof         OutputType = "pprof"
	Summary       OutputType = "summary"
	SummaryByLine OutputType = "summary-by-line"
	HeapSnapshot  OutputType = "heapsnapshot"
)

func AvailableOutputTypes

func AvailableOutputTypes() []OutputType

type ProfilingEvent

type ProfilingEvent string
const (
	Cpu         ProfilingEvent = "cpu"
	Alloc       ProfilingEvent = "alloc"
	Lock        ProfilingEvent = "lock"
	CacheMisses ProfilingEvent = "cache-misses"
	Wall        ProfilingEvent = "wall"
	Itimer      ProfilingEvent = "itimer"
)

func AvailableEvents

func AvailableEvents() []ProfilingEvent

type ProfilingTool

type ProfilingTool string
const (
	AsyncProfiler ProfilingTool = "async-profiler"
	Jcmd          ProfilingTool = "jcmd"
	Pyspy         ProfilingTool = "pyspy"
	Bpf           ProfilingTool = "bpf"
	Perf          ProfilingTool = "perf"
	Rbspy         ProfilingTool = "rbspy"
	NodeDummy     ProfilingTool = "node-dummy"
	FakeTool      ProfilingTool = "fake"
)

func AvailableProfilingTools

func AvailableProfilingTools() []ProfilingTool

type ProgrammingLanguage

type ProgrammingLanguage string
const (
	Java          ProgrammingLanguage = "java"
	Go            ProgrammingLanguage = "go"
	Python        ProgrammingLanguage = "python"
	Ruby          ProgrammingLanguage = "ruby"
	Node          ProgrammingLanguage = "node"
	Clang         ProgrammingLanguage = "clang"
	ClangPlusPlus ProgrammingLanguage = "clang++"
	Rust          ProgrammingLanguage = "rust"
	FakeLang      ProgrammingLanguage = "fake"
)

func AvailableLanguages

func AvailableLanguages() []ProgrammingLanguage

type ProgressData

type ProgressData struct {
	Time  time.Time     `json:"time"`
	Stage ProgressStage `json:"stage"`
}

type ProgressStage

type ProgressStage string

type ResultData

type ResultData struct {
	Time            time.Time   `json:"time"`
	ResultType      OutputType  `json:"result-type"`
	File            string      `json:"file,omitempty"`
	FileSizeInBytes int64       `json:"file-size-in-bytes,omitempty"`
	Checksum        string      `json:"checksum,omitempty"`
	CompressorType  string      `json:"compressor-type,omitempty"`
	Chunks          []ChunkData `json:"chunks,omitempty"`
}

Jump to

Keyboard shortcuts

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