parsing

package
v1.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown       Profiler = "unknown"
	DDtrace                = "ddtrace"
	AsyncProfiler          = "async-profiler"
	PySpy
	Pyroscope = "pyroscope"
)
View Source
const (
	LabelExceptionType   = "exception type"
	LabelThreadID        = "thread id"
	LabelThreadNativeID  = "thread native id"
	LabelThreadName      = "thread name"
	LabelSpanID          = "span id"
	LabelLocalRootSpanID = "local root span id"
)
View Source
const UnknownInfo = "<unknown>"

Variables

View Source
var (
	Function = &Aggregator{
		Name:            "Function",
		Mapping:         []string{pprof.FieldFunctionName},
		ShowLanguages:   languages.PythonID | languages.GolangID,
		GetIdentifier:   getFuncIdentifier,
		GetDisplayStr:   getFuncDisplayStr,
		GetMappingFuncs: []GetPropertyFunc{getFuncName},
	}

	PHPFunction = &Aggregator{
		Name:            "Function",
		Mapping:         []string{pprof.FieldFunctionName},
		GetIdentifier:   getFuncIdentifier,
		GetDisplayStr:   getFuncDisplayStr,
		GetMappingFuncs: []GetPropertyFunc{getFuncName},
	}

	Method = &Aggregator{
		Name:            "Method",
		Mapping:         []string{pprof.FieldFunctionName},
		ShowLanguages:   languages.JavaID | languages.DotNetID,
		GetIdentifier:   getMethod,
		GetDisplayStr:   getMethod,
		GetMappingFuncs: []GetPropertyFunc{getMethod},
	}

	Class = &Aggregator{
		Name:            "Class",
		Mapping:         []string{pprof.FieldClass},
		ShowLanguages:   languages.DotNetID,
		GetIdentifier:   getClass,
		GetDisplayStr:   getClass,
		GetMappingFuncs: []GetPropertyFunc{getClass},
	}

	Namespace = &Aggregator{
		Name:            "Namespace",
		Mapping:         []string{pprof.FieldNamespace},
		ShowLanguages:   languages.DotNetID,
		GetIdentifier:   getNamespace,
		GetDisplayStr:   getNamespace,
		GetMappingFuncs: []GetPropertyFunc{getNamespace},
	}

	Assembly = &Aggregator{
		Name:            "Assembly",
		Mapping:         []string{pprof.FieldAssembly},
		ShowLanguages:   languages.DotNetID,
		GetIdentifier:   getAssembly,
		GetDisplayStr:   getAssembly,
		GetMappingFuncs: []GetPropertyFunc{getAssembly},
	}

	PyroNodeFunction = &Aggregator{
		Name:            "Function",
		Mapping:         []string{pprof.FieldFunctionName},
		ShowLanguages:   languages.NodeJSID,
		GetIdentifier:   getFuncIdentifier,
		GetDisplayStr:   getFuncDisplayStr,
		GetMappingFuncs: []GetPropertyFunc{getFuncName},
	}

	FunctionLine = &Aggregator{
		Name:          "Function + Line",
		Mapping:       []string{pprof.FieldFunctionName, pprof.FieldLine},
		ShowLanguages: languages.PythonID | languages.GolangID,
		GetIdentifier: func(lang languages.Lang, smp *profile.Sample, reverse bool) string {
			i := 0
			if reverse {
				i = len(smp.Location) - 1
			}
			if len(smp.Location) > 0 {
				loc := smp.Location[i]
				if len(loc.Line) > 0 {
					return fmt.Sprintf("%s###%d###%d",
						loc.Line[len(loc.Line)-1].Function.Filename, loc.Line[len(loc.Line)-1].Function.ID, loc.Line[len(loc.Line)-1].Line)
				}
			}
			return "<unknown>"
		},
		GetDisplayStr:   GetFuncAndLineDisplay,
		GetMappingFuncs: []GetPropertyFunc{getFuncName, getLine},
	}

	Directory = &Aggregator{
		Name:            "Directory",
		Mapping:         []string{pprof.FieldDirectory},
		ShowLanguages:   languages.PythonID | languages.GolangID,
		GetIdentifier:   getDirectory,
		GetDisplayStr:   getDirectory,
		GetMappingFuncs: []GetPropertyFunc{getDirectory},
	}

	File = &Aggregator{
		Name:            "File",
		Mapping:         []string{pprof.FieldFile},
		ShowLanguages:   languages.PythonID | languages.GolangID,
		GetIdentifier:   getFile,
		GetDisplayStr:   getFile,
		GetMappingFuncs: []GetPropertyFunc{getFile},
	}

	PyroNodeFile = &Aggregator{
		Name:            "File",
		Mapping:         []string{pprof.FieldFile},
		ShowLanguages:   languages.NodeJSID,
		GetIdentifier:   getFile,
		GetDisplayStr:   getFile,
		GetMappingFuncs: []GetPropertyFunc{getFile},
	}

	ThreadID = &Aggregator{
		Name:            "Thread ID",
		Mapping:         []string{pprof.FieldThreadID},
		ShowLanguages:   languages.PythonID | languages.DotNetID,
		GetIdentifier:   getThreadID,
		GetDisplayStr:   getThreadID,
		GetMappingFuncs: []GetPropertyFunc{getThreadID},
	}

	ThreadName = &Aggregator{
		Name:            "Thread Name",
		Mapping:         []string{pprof.FieldThreadName},
		ShowLanguages:   languages.PythonID | languages.DotNetID,
		GetIdentifier:   getThreadName,
		GetDisplayStr:   getThreadName,
		GetMappingFuncs: []GetPropertyFunc{getThreadName},
	}

	Package = &Aggregator{
		Name:            "Package",
		Mapping:         []string{pprof.FieldPackage},
		ShowLanguages:   languages.GolangID,
		GetIdentifier:   getPackageName,
		GetDisplayStr:   getPackageName,
		GetMappingFuncs: []GetPropertyFunc{getPackageName},
	}
)
View Source
var (
	ZIPMagic  = []byte{0x50, 0x4b, 3, 4}
	LZ4Magic  = []byte{4, 34, 77, 24}
	GZIPMagic = []byte{31, 139}
)
View Source
var DDTraceDotnetAggregatorList = []*Aggregator{
	Method,
	Class,
	Namespace,
	Assembly,
	ThreadID,
	ThreadName,
}
View Source
var DDTracePHPAggregatorList = []*Aggregator{
	PHPFunction,
	FunctionLine,
	Class,
	File,
	Directory,
}
View Source
var GoAggregatorList = []*Aggregator{
	Function,
	FunctionLine,
	Directory,
	File,
	Package,
}
View Source
var PyroscopeNodeJSAggregatorList = []*Aggregator{
	PyroNodeFunction,
	PyroNodeFile,
}
View Source
var PythonAggregatorList = []*Aggregator{
	Function,
	FunctionLine,
	Directory,
	File,
	ThreadID,
	ThreadName,
}
View Source
var SpyAggregatorList = []*Aggregator{
	Function,
	FunctionLine,
	Directory,
	File,
	ThreadName,
}

Functions

func GetFuncAndLineDisplay

func GetFuncAndLineDisplay(lang languages.Lang, smp *profile.Sample, reverse bool) string

func GetPrintStrByLine

func GetPrintStrByLine(lang languages.Lang, line profile.Line) string

func GetSpyPrintStr

func GetSpyPrintStr(funcName, fileName string) string

func GetSummary

func GetSummary(param parameter.SummaryParam, filterBySpan bool, spanIDSet *tracing.SpanIDSet) (map[events.Type]*EventSummary, int64, error)

func IsCollapseProfile

func IsCollapseProfile(profiles []*parameter.Profile, workspaceUUID string) (bool, error)

func NewDecompressor

func NewDecompressor(r io.Reader) io.ReadCloser

Types

type Aggregator

type Aggregator struct {
	Name    string
	Mapping []string

	ShowLanguages languages.LangID

	// GetIdentifier 获取维度的唯一标识
	GetIdentifier GetPropertyFunc

	// GetDisplayStr 获取维度的显示字符
	GetDisplayStr GetPropertyFunc

	// GetMappingFuncs, 获取与Mapping字段对应值Func
	GetMappingFuncs []GetPropertyFunc
}

type AggregatorOption

type AggregatorOption struct {
	Title         string             `json:"title"`
	Quantity      *quantity.Quantity `json:"quantity"`
	Value         int64              `json:"value"`
	Unit          *quantity.Unit     `json:"unit"`
	Percent       string             `json:"percent"`
	MappingValues []string           `json:"mappingValues"`
}

func (*AggregatorOption) CalcPercentAndQuantity

func (ao *AggregatorOption) CalcPercentAndQuantity(total int64)

type AggregatorSelect

type AggregatorSelect struct {
	Aggregator *Aggregator
	Mapping    []string
	Options    OptionMap
}

type AggregatorSelectForJSON

type AggregatorSelectForJSON struct {
	Dimension string      `json:"dimension"`
	Mapping   []string    `json:"mapping"`
	Options   OptionSlice `json:"data"`
}

type AggregatorSelectSlice

type AggregatorSelectSlice []*AggregatorSelect

func ParseRawFlameGraph

func ParseRawFlameGraph(filename string) (*pprof.Frame, AggregatorSelectSlice, error)

func (AggregatorSelectSlice) CalcPercentAndQuantity

func (asm AggregatorSelectSlice) CalcPercentAndQuantity(total int64)

func (AggregatorSelectSlice) MarshalJSON

func (asm AggregatorSelectSlice) MarshalJSON() ([]byte, error)

type Collapse

type Collapse struct {
	// contains filtered or unexported fields
}

func NewCollapse

func NewCollapse(workspaceUUID string, profiles []*parameter.Profile,
	filterBySpan bool, spanIDSet *tracing.SpanIDSet) *Collapse

func (*Collapse) ResolveFlameGraph

func (p *Collapse) ResolveFlameGraph(_ events.Type) (*pprof.Frame, AggregatorSelectSlice, error)

func (*Collapse) Summary

func (p *Collapse) Summary() (map[events.Type]*EventSummary, int64, error)

type DDFieldTag

type DDFieldTag string
const (
	AssemblyTag  DDFieldTag = "|lm:"
	NamespaceTag DDFieldTag = "|ns:"
	ClassTag     DDFieldTag = "|ct:"
	MethodTag    DDFieldTag = "|fn:"
)

type DDTrace

type DDTrace struct{}

func (DDTrace) ShowInProfile

func (D DDTrace) ShowInProfile(e events.Type) bool

func (DDTrace) ShowInTrace

func (D DDTrace) ShowInTrace(e events.Type) bool

type Decompressor

type Decompressor struct {
	io.Reader
	// contains filtered or unexported fields
}

func (*Decompressor) Close

func (d *Decompressor) Close() error

type DisplayCtl

type DisplayCtl interface {
	ShowInTrace(e events.Type) bool
	ShowInProfile(e events.Type) bool
}

type EventSummary

type EventSummary = pprof.EventSummary

type Format

type Format string
const (
	FlameGraph Format = "flamegraph" // see https://github.com/brendangregg/FlameGraph
	//Deprecated use Collapsed instead
	RawFlameGraph Format = "rawflamegraph" // flamegraph collapse
	Collapsed     Format = "collapse"      // flamegraph collapse format see https://github.com/brendangregg/FlameGraph/blob/master/stackcollapse.pl
	SpeedScope    Format = "speedscope"    // see https://github.com/jlfwong/speedscope
	JFR           Format = "jfr"           // see https://github.com/openjdk/jmc#core-api-example
	PPROF         Format = "pprof"         // see https://github.com/google/pprof/blob/main/proto/profile.proto
)

type GetPropertyByLine

type GetPropertyByLine func(lang languages.Lang, line profile.Line) string

type GetPropertyFunc

type GetPropertyFunc func(lang languages.Lang, smp *profile.Sample, reverse bool) string

type MetaData

type MetaData struct {
	Format      Format   `json:"format"`
	Profiler    Profiler `json:"profiler"`
	Attachments []string `json:"attachments"`
}

func ReadMetaData

func ReadMetaData(prof *parameter.Profile, workspaceUUID string) (*MetaData, error)

func ReadMetaDataFile

func ReadMetaDataFile(f string) (*MetaData, error)

type OptionMap

type OptionMap map[string]*AggregatorOption

type OptionSlice

type OptionSlice []*AggregatorOption

func (OptionSlice) Len

func (os OptionSlice) Len() int

func (OptionSlice) Less

func (os OptionSlice) Less(i, j int) bool

func (OptionSlice) Swap

func (os OptionSlice) Swap(i, j int)

type PProf

type PProf struct {
	DisplayCtl
	// contains filtered or unexported fields
}

func NewPProfParser

func NewPProfParser(
	from string,
	workspaceUUID string,
	profiles []*parameter.Profile,
	filterBySpan bool,
	span *parameter.Span,
	spanIDSet *tracing.SpanIDSet,
	ctl DisplayCtl,
) *PProf

func (*PProf) ResolveFlameGraph

func (p *PProf) ResolveFlameGraph(eventType events.Type) (*pprof.Frame, AggregatorSelectSlice, error)

ResolveFlameGraph (lang languages.Lang, eType events.Type, pprofSampleType string, filterBySpan bool, span *parameter.Span, spanIDSet *dql.SpanIDSet)

func (*PProf) Summary

func (p *PProf) Summary() (map[events.Type]*EventSummary, int64, error)

type Parser

type Parser interface {
	Summary() (map[events.Type]*EventSummary, int64, error)
	ResolveFlameGraph(eventType events.Type) (*pprof.Frame, AggregatorSelectSlice, error)
}

type Profiler

type Profiler string

type PyroscopeNodejs

type PyroscopeNodejs struct{}

func (*PyroscopeNodejs) ShowInProfile

func (p *PyroscopeNodejs) ShowInProfile(_ events.Type) bool

func (*PyroscopeNodejs) ShowInTrace

func (p *PyroscopeNodejs) ShowInTrace(_ events.Type) bool

type SampleFile

type SampleFile struct {
	Filename   string
	SampleType string
}

func GetFileByEvent

func GetFileByEvent(lang languages.Lang, typ events.Type) (*SampleFile, error)

type SummaryCollection

type SummaryCollection = pprof.SummaryCollection

type SummaryValueType

type SummaryValueType = pprof.SummaryValueType

Jump to

Keyboard shortcuts

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