Documentation ¶
Index ¶
- Constants
- Variables
- func AddJitter(baseDuration time.Duration, jitter float64) time.Duration
- func AtomicUpdateMaxUint32(store *atomic.Uint32, newValue uint32)
- func CheckCanceled(err1, err2 error) error
- func CheckError(err error, errList ...error) bool
- func ComputeFileCRC32(filePath string) (int32, error)
- func ComputeFileSHA256(filePath string) (string, error)
- func DecToUint64(str string) uint64
- func GetURLWithoutQueryParams(url string) string
- func HashString(s string) uint64
- func HashStrings(strs ...string) []byte
- func HexToUint64(str string) uint64
- func Int64ToTime(t int64) time.Time
- func IsValidString(s string) bool
- func MapKeysToSlice[K comparable, V any](m map[K]V) []K
- func MapSlice[T, V any](in []T, mapf func(T) V) []V
- func MapValuesToSlice[K comparable, V any](m map[K]V) []V
- func NextPowerOfTwo(v uint32) uint32
- func NowAsUInt32() uint32
- func SleepWithJitter(baseDuration time.Duration, jitter float64)
- func SleepWithJitterAndContext(ctx context.Context, duration time.Duration, jitter float64) error
- func SliceAllEqual[T comparable](s []T, value T) bool
- func SliceFrom(data any) []byte
- func SlicesEqual[T comparable](a, b []T) bool
- func TimeToInt64(t time.Time) int64
- func VersionUint(major, minor, patch uint32) uint32
- func WriteTempFile(data []byte, directory, prefix string) (string, error)
- type Address
- type AddressOrLineno
- type CodeIndexingMessage
- type FileID
- type FileType
- type FrameID
- func (f FrameID) AddressOrLine() AddressOrLineno
- func (f *FrameID) AsIP() net.IP
- func (f FrameID) Bytes() []byte
- func (f FrameID) EncodeTo(dst []byte)
- func (FrameID) EncodedLen() int
- func (f FrameID) FileID() FileID
- func (f FrameID) Hash() uint64
- func (f FrameID) Hash32() uint32
- func (f FrameID) String() string
- type FrameMetadata
- type FrameType
- type InterpType
- type InterpVersion
- type KTime
- type OnDiskFileIdentifier
- type PID
- type PackageID
- type PackageType
- type Range
- type Set
- type SourceLineno
- type SourcePackageType
- type Symbol
- type SymbolFinder
- type SymbolMap
- func (symmap *SymbolMap) Add(s Symbol)
- func (symmap *SymbolMap) Finalize()
- func (symmap *SymbolMap) Len() int
- func (symmap *SymbolMap) LookupByAddress(val SymbolValue) (SymbolName, Address, bool)
- func (symmap *SymbolMap) LookupSymbol(symbolName SymbolName) (*Symbol, error)
- func (symmap *SymbolMap) LookupSymbolAddress(symbolName SymbolName) (SymbolValue, error)
- func (symmap *SymbolMap) ScanAllNames(cb func(SymbolName))
- type SymbolName
- type SymbolValue
- type Trace
- type TraceAndCounts
- type TraceHash
- type UnixTime32
- type Void
Constants ¶
const ( PackageTypeDeb = iota PackageTypeRPM PackageTypeCustomSymbols PackageTypeAPK )
const ( SourcePackageTypeDeb = iota SourcePackageTypeRPM )
const ( CodeIndexingPackageTypeDeb = "deb" CodeIndexingPackageTypeRpm = "rpm" CodeIndexingPackageTypeCustom = "custom" CodeIndexingPackageTypeApk = "apk" )
const ( FileTypeNative = iota FileTypePython )
const SymbolNameUnknown = ""
SymbolNameUnknown is the value returned by SymbolMap functions when address has no symbol info.
const SymbolValueInvalid = SymbolValue(0)
SymbolValueInvalid is the value returned by SymbolMap functions when symbol was not found.
Variables ¶
var LocalFSPackageID = PackageID{ basehash.New128(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF), }
LocalFSPackageID is a fake package identifier, indicating that a particular file was not part of a package, but was extracted directly from a local filesystem.
UnknownKernelFileID is used as 128-bit FileID when the host agent isn't able to derive a FileID for a kernel frame.
UnsymbolizedFileID is used as 128-bit FileID when symbolization fails.
Functions ¶
func AtomicUpdateMaxUint32 ¶
AtomicUpdateMaxUint32 updates the value in store using atomic memory primitives. newValue will only be placed in store if newValue is larger than the current value in store. To avoid inconsistency parallel updates to store should be avoided.
func CheckCanceled ¶
CheckCanceled tries to match the first error with context canceled/deadline exceeded and returns it. If no match is found, the second error is returned.
func CheckError ¶
CheckError tries to match err with an error in the passed slice and returns true if a match is found.
func ComputeFileCRC32 ¶
ComputeFileCRC32 computes the CRC32 hash of a file
func ComputeFileSHA256 ¶
func DecToUint64 ¶
DecToUint64 is a convenience function to extract a decimal string to a uint64 and not worry about errors. Essentially a "mustConvertDecToUint64".
func GetURLWithoutQueryParams ¶
GetURLWithoutQueryParams returns an URL with all query parameters removed For example, http://hello.com/abc?a=1&b=2 becomes http://hello.com/abc
func HashStrings ¶
HashStrings turns a list of strings into a 128-bit hash.
func HexToUint64 ¶
HexToUint64 is a convenience function to extract a hex string to a uint64 and not worry about errors. Essentially a "mustConvertHexToUint64".
func Int64ToTime ¶
Int64ToTime converts an int64 to a time.Time. It preserves the "zero-ness" across the conversion, which means 0 is converted to a zero time.Time (instead of the Unix epoch).
func IsValidString ¶
IsValidString checks if string is UTF-8-encoded and only contains expected characters.
func MapKeysToSlice ¶
func MapKeysToSlice[K comparable, V any](m map[K]V) []K
MapKeysToSlice creates a slice from a map's keys.
func MapSlice ¶
func MapSlice[T, V any](in []T, mapf func(T) V) []V
MapSlice returns a new slice by mapping given function over the input slice.
func MapValuesToSlice ¶
func MapValuesToSlice[K comparable, V any](m map[K]V) []V
MapValuesToSlice creates a slice from a map's values.
func NextPowerOfTwo ¶
NextPowerOfTwo returns the next highest power of 2 for a given value v or v, if v is a power of 2.
func NowAsUInt32 ¶
func NowAsUInt32() uint32
NowAsUInt32 is a convenience function to avoid code repetition
func SleepWithJitter ¶
SleepWithJitter sleeps for baseDuration +/- jitter (jitter is [0..1])
func SleepWithJitterAndContext ¶
SleepWithJitterAndContext blocks for duration +/- jitter (jitter is [0..1]) or until ctx is canceled.
func SliceAllEqual ¶
func SliceAllEqual[T comparable](s []T, value T) bool
SliceAllEqual checks whether all items in a slice have a given value.
func SlicesEqual ¶
func SlicesEqual[T comparable](a, b []T) bool
SlicesEqual checks whether two slices are element-wise equal.
func TimeToInt64 ¶
TimeToInt64 converts a time.Time to an int64. It preserves the "zero-ness" across the conversion, which means a zero Time is converted to 0.
func VersionUint ¶
VersionUint returns a single integer composed of major, minor, patch.
Types ¶
type AddressOrLineno ¶
type AddressOrLineno uint64
AddressOrLineno represents a line number in an interpreted file or an offset into a native file. TODO(thomasdullien): check with regards to JSON marshaling/demarshaling.
type CodeIndexingMessage ¶
type FileID ¶
FileID is used for unique identifiers for files
func FileIDFromBase64 ¶
FileIDFromBase64 converts a base64url encoded file ID into its binary representation. We store binary fields as keywords as base64 URL encoded strings. But when retrieving binary fields, ES sends them as base64 STD encoded strings.
func FileIDFromBytes ¶
FileIDFromBytes parses a byte slice into the internal data representation for a file ID.
func FileIDFromString ¶
FileIDFromString parses a hexadecimal notation of a file ID into the internal data representation.
func (FileID) Compare ¶
Compare returns an integer comparing two hashes lexicographically. The result will be 0 if f == other, -1 if f < other, and +1 if f > other.
type FrameID ¶
type FrameID struct {
// contains filtered or unexported fields
}
FrameID represents a frame as an address in an executable file or as a line in a source code file.
func NewFrameID ¶
func NewFrameID(fileID FileID, addressOrLineno AddressOrLineno) FrameID
NewFrameID creates a new FrameID from the fileId and address or line.
func NewFrameIDFromBytes ¶
NewFrameIDFromBytes creates a new FrameID from a byte array of length 24.
func NewFrameIDFromString ¶
NewFrameIDFromString creates a new FrameID from its JSON string representation.
func (FrameID) AddressOrLine ¶
func (f FrameID) AddressOrLine() AddressOrLineno
AddressOrLine returns the addressOrLine part of the frameID.
func (*FrameID) AsIP ¶
AsIP returns the FrameID as a net.IP type to be used for the PC range in profiling-symbols-*.
func (FrameID) EncodeTo ¶
EncodeTo encodes the frame ID into the base64 encoded representation and stores it in the provided destination byte array. The length of the destination must be at least EncodedLen().
func (FrameID) EncodedLen ¶
EncodedLen returns the length of the FrameID's base64 representation.
type FrameMetadata ¶
type FrameMetadata struct { FileID FileID AddressOrLine AddressOrLineno LineNumber SourceLineno FunctionOffset uint32 FunctionName string Filename string }
type FrameType ¶
type FrameType int
FrameType defines the type of frame. This usually corresponds to the interpreter type that emitted it, but can additionally contain meta-information like error frames.
A frame type can represent one of the following things:
- A successfully unwound frame. This is represented simply as the `InterpType` ID.
- A partial (non-critical failure), indicated by ORing the `InterpType` ID with the error bit.
- A fatal failure that caused further unwinding to be aborted. This is indicated using the special value support.FrameMarkerAbort (0xFF). It thus also contains the error bit, but does not fit into the `InterpType` enum.
const ( // UnknownFrame indicates a frame of an unknown interpreter. // If this appears, it's likely a bug somewhere. UnknownFrame FrameType = support.FrameMarkerUnknown // PHPFrame identifies PHP interpreter frames. PHPFrame FrameType = support.FrameMarkerPHP // PHPJITFrame identifies PHP JIT interpreter frames. PHPJITFrame FrameType = support.FrameMarkerPHPJIT // PythonFrame identifies the Python interpreter frames. PythonFrame FrameType = support.FrameMarkerPython // NativeFrame identifies native frames. NativeFrame FrameType = support.FrameMarkerNative // KernelFrame identifies kernel frames. KernelFrame FrameType = support.FrameMarkerKernel // HotSpotFrame identifies Java HotSpot VM frames. HotSpotFrame FrameType = support.FrameMarkerHotSpot // RubyFrame identifies the Ruby interpreter frames. RubyFrame FrameType = support.FrameMarkerRuby // PerlFrame identifies the Perl interpreter frames. PerlFrame FrameType = support.FrameMarkerPerl // V8Frame identifies the V8 interpreter frames. V8Frame FrameType = support.FrameMarkerV8 // AbortFrame identifies frames that report that further unwinding was aborted due to an error. AbortFrame FrameType = support.FrameMarkerAbort )
Convenience shorthands to create various frame types.
Code should not compare against the constants below directly, but instead use the provided methods to query the required information (IsError, Interpreter, ...) to improve forward compatibility and clarify intentions.
func (FrameType) Interpreter ¶
func (ty FrameType) Interpreter() InterpType
Interpreter returns the interpreter that produced the frame.
func (FrameType) IsInterpType ¶
func (ty FrameType) IsInterpType(ity InterpType) bool
IsInterpType checks whether the frame type belongs to the given interpreter.
type InterpType ¶
type InterpType int
InterpType variables can hold one of the interpreter type values defined below.
const ( // UnknownInterp signifies that the interpreter is unknown. UnknownInterp InterpType = support.FrameMarkerUnknown // PHP identifies the PHP interpreter. PHP InterpType = support.FrameMarkerPHP // PHPJIT identifies PHP JIT processes. PHPJIT InterpType = support.FrameMarkerPHPJIT // Python identifies the Python interpreter. Python InterpType = support.FrameMarkerPython // Native identifies native code. Native InterpType = support.FrameMarkerNative // Kernel identifies kernel code. Kernel InterpType = support.FrameMarkerKernel // HotSpot identifies the Java HotSpot VM. HotSpot InterpType = support.FrameMarkerHotSpot // Ruby identifies the Ruby interpreter. Ruby InterpType = support.FrameMarkerRuby // Perl identifies the Perl interpreter. Perl InterpType = support.FrameMarkerPerl // V8 identifies the V8 interpreter. V8 InterpType = support.FrameMarkerV8 )
func (InterpType) Frame ¶
func (i InterpType) Frame() FrameType
Frame converts the interpreter type into the corresponding frame type.
func (InterpType) String ¶
func (i InterpType) String() string
String converts the frame type int to the related string value to be displayed in the UI.
type InterpVersion ¶
type InterpVersion string
InterpVersion represents the version of an interpreter
type KTime ¶
type KTime int64
KTime stores a time value, retrieved from a monotonic clock, in nanoseconds
func GetKTime ¶
func GetKTime() KTime
GetKTime gets the current time in same nanosecond format as bpf_ktime_get_ns() eBPF call This relies runtime.nanotime to use CLOCK_MONOTONIC. If this changes, this needs to be adjusted accordingly. Using this internal is superior in performance, as it is able to use the vDSO to query the time without syscall.
type OnDiskFileIdentifier ¶
type OnDiskFileIdentifier struct { DeviceID uint64 // dev_t as reported by stat. InodeNum uint64 // ino_t should fit into 64 bits }
OnDiskFileIdentifier can be used as unique identifier for a file. It is a structure to identify a particular file on disk by deviceID and inode number.
func GetOnDiskFileIdentifier ¶
func GetOnDiskFileIdentifier(filename string) (OnDiskFileIdentifier, error)
GetOnDiskFileIdentifier builds a unique identifier of a given filename based on the information we can extract from stat.
func (OnDiskFileIdentifier) Hash32 ¶
func (odfi OnDiskFileIdentifier) Hash32() uint32
type PackageID ¶
PackageID is used for unique identifiers for packages
func PackageIDFromBytes ¶
PackageIDFromBytes parses a byte slice into the internal data representation for a PackageID.
func PackageIDFromString ¶
PackageIDFromString returns a PackageID from its string representation.
type PackageType ¶
type PackageType int32
The different types of packages that we process
func (PackageType) String ¶
func (t PackageType) String() string
type Set ¶
type Set[T comparable] map[T]Void
Set is a convenience alias for a map with a `Void` key.
func SliceToSet ¶
func SliceToSet[T comparable](s []T) Set[T]
SliceToSet creates a set from a slice, deduplicating it.
type SourceLineno ¶
type SourceLineno uint64
SourceLineno represents a line number within a source file. It is intended to be used for the source line numbers associated with offsets in native code, or for source line numbers in interpreted code.
type SourcePackageType ¶
type SourcePackageType int32
The different types of source package objects that we process
type Symbol ¶
type Symbol struct { Name SymbolName Address SymbolValue Size int }
Symbol represents the name of a symbol
type SymbolFinder ¶
type SymbolFinder interface { LookupSymbol(symbolName SymbolName) (*Symbol, error) LookupSymbolAddress(symbolName SymbolName) (SymbolValue, error) }
SymbolFinder implements a way to find symbol data
type SymbolMap ¶
type SymbolMap struct {
// contains filtered or unexported fields
}
SymbolMap represents collections of symbols that can be resolved or reverse mapped
func (*SymbolMap) Finalize ¶
func (symmap *SymbolMap) Finalize()
Finalize symbol map by sorting and constructing the nameToSymbol table after all symbols are inserted via Add() calls
func (*SymbolMap) LookupByAddress ¶
func (symmap *SymbolMap) LookupByAddress(val SymbolValue) (SymbolName, Address, bool)
LookupByAddress translates the address to a symbolic information. Return empty string and absolute address if it did not match any symbol.
func (*SymbolMap) LookupSymbol ¶
func (symmap *SymbolMap) LookupSymbol(symbolName SymbolName) (*Symbol, error)
LookupSymbol obtains symbol information. Returns nil and an error if not found.
func (*SymbolMap) LookupSymbolAddress ¶
func (symmap *SymbolMap) LookupSymbolAddress(symbolName SymbolName) (SymbolValue, error)
LookupSymbolAddress returns the address of a symbol. Returns SymbolValueInvalid and error if not found.
func (*SymbolMap) ScanAllNames ¶
func (symmap *SymbolMap) ScanAllNames(cb func(SymbolName))
ScanAllNames calls the provided callback with all the symbol names in the map.
type SymbolValue ¶
type SymbolValue uint64
SymbolValue represents the value associated with a symbol, e.g. either an offset or an absolute address
type Trace ¶
type Trace struct { Files []FileID Linenos []AddressOrLineno FrameTypes []FrameType Hash TraceHash }
Trace represents a stack trace. Each tuple (Files[i], Linenos[i]) represents a stack frame via the file ID and line number at the offset i in the trace. The information for the most recently called function is at offset 0.
func (*Trace) AppendFrame ¶
func (trace *Trace) AppendFrame(ty FrameType, file FileID, addrOrLine AddressOrLineno)
AppendFrame appends a frame to the columnar frame array.
type TraceAndCounts ¶
type TraceHash ¶
TraceHash represents the unique hash of a trace
func NewTraceHash ¶
func TraceHashFromBytes ¶
TraceHashFromBytes parses a byte slice of a trace hash into the internal data representation.
func TraceHashFromString ¶
TraceHashFromString parses a hexadecimal notation of a trace hash into the internal data representation.
func (TraceHash) EncodeTo ¶
EncodeTo encodes the hash into the base64 encoded representation and stores it in the provided destination byte array. The length of the destination must be at least EncodedLen().
func (TraceHash) EncodedLen ¶
EncodedLen returns the length of the hash's base64 representation.
type UnixTime32 ¶
type UnixTime32 uint32
UnixTime32 is another type to represent seconds since epoch. In most cases 32bit time values are good enough until year 2106. Our time series database backend uses this type for TimeStamps as well, so there is no need to use a different type than uint32. Also, Go's semantics on map[time.Time] are particularly nasty footguns, and since the code is mostly dealing with UNIX timestamps, we may as well use uint32s instead. To restore some semblance of type safety, we declare a type alias here.
func (*UnixTime32) MarshalJSON ¶
func (t *UnixTime32) MarshalJSON() ([]byte, error)
type Void ¶
type Void struct{}
Void allows to use maps as sets without memory allocation for the values. From the "Go Programming Language":
The struct type with no fields is called the empty struct, written struct{}. It has size zero and carries no information but may be useful nonetheless. Some Go programmers use it instead of bool as the value type of a map that represents a set, to emphasize that only the keys are significant, but the space saving is marginal and the syntax more cumbersome, so we generally avoid it.
Directories ¶
Path | Synopsis |
---|---|
This package contains a series of helper functions that are useful for ARM disassembly.
|
This package contains a series of helper functions that are useful for ARM disassembly. |
Package basehash provides basic types to implement hash identifiers.
|
Package basehash provides basic types to implement hash identifiers. |
Package freelru is a wrapper around go-freelru.LRU with additional statistics embedded and can be used as a drop in replacement.
|
Package freelru is a wrapper around go-freelru.LRU with additional statistics embedded and can be used as a drop in replacement. |
Package hash provides the same hash primitives as used by the eBPF.
|
Package hash provides the same hash primitives as used by the eBPF. |
lpm package provides helpers for calculating prefix lists from ranges
|
lpm package provides helpers for calculating prefix lists from ranges |
stackdeltatypes
Package stackdeltatypes provides types used to represent stack delta information as constructed by `nativeunwind.GetIntervalStructures` This information is a post-processed form of the stack delta information that is used in all relevant packages.
|
Package stackdeltatypes provides types used to represent stack delta information as constructed by `nativeunwind.GetIntervalStructures` This information is a post-processed form of the stack delta information that is used in all relevant packages. |
nopanicslicereader provides little convenience utilities to read "native" endian values from a slice at given offset.
|
nopanicslicereader provides little convenience utilities to read "native" endian values from a slice at given offset. |
Package periodiccaller allows periodic calls of functions.
|
Package periodiccaller allows periodic calls of functions. |
package pfelf implements functions for processing of ELF files and extracting data from them.
|
package pfelf implements functions for processing of ELF files and extracting data from them. |
remotememory provides access to memory space of a process.
|
remotememory provides access to memory space of a process. |
successfailurecounter provides a wrapper to atomically increment success or failure counters.
|
successfailurecounter provides a wrapper to atomically increment success or failure counters. |
Package vc provides buildtime information.
|
Package vc provides buildtime information. |
Package xsync provides thin wrappers around locking primitives in an effort towards better documenting the relationship between locks and the data they protect.
|
Package xsync provides thin wrappers around locking primitives in an effort towards better documenting the relationship between locks and the data they protect. |