Documentation ¶
Index ¶
- Constants
- Variables
- func AddJitter(baseDuration time.Duration, jitter float64) time.Duration
- 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 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 WriteTempFile(data []byte, directory, prefix string) (string, error)
- type APMSpanID
- type APMTraceID
- type APMTransactionID
- type Address
- type AddressOrLineno
- type FileID
- func FileIDFromBase64(s string) (FileID, error)
- func FileIDFromBytes(b []byte) (FileID, error)
- func FileIDFromExecutableFile(fileName string) (FileID, error)
- func FileIDFromExecutableReader(reader io.ReadSeeker) (FileID, error)
- func FileIDFromKernelBuildID(buildID string) FileID
- func FileIDFromString(s string) (FileID, error)
- func NewFileID(hi, lo uint64) FileID
- 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 InterpreterType
- type PID
- type Set
- type SourceLineno
- 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) VisitAll(cb func(Symbol))
- type SymbolName
- type SymbolValue
- type Trace
- type TraceAndCounts
- type TraceHash
- type UnixTime32
- type UnixTime64
- type Void
Constants ¶
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 InvalidAPMSpanID = APMSpanID{0, 0, 0, 0, 0, 0, 0, 0}
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 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 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.
Types ¶
type APMTraceID ¶
type APMTraceID [16]byte
type APMTransactionID ¶
type APMTransactionID = APMSpanID
type AddressOrLineno ¶
type AddressOrLineno uint64
AddressOrLineno represents a line number in an interpreted file or an offset into a native file.
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 FileIDFromExecutableFile ¶
FileIDFromExecutableFile opens an executable file and calculates the FileID for it. The caller is responsible pre-validate it as an executable file and that the algorithm described in FileIDFromExecutableReader is suitable.
func FileIDFromExecutableReader ¶
func FileIDFromExecutableReader(reader io.ReadSeeker) (FileID, error)
FileIDFromExecutableReader hashes portions of the contents of the reader in order to generate a system-independent identifier. The file is expected to be an executable file (ELF or PE) where the header and footer has enough data to make the file unique.
*** WARNING *** ANY CHANGE IN BEHAVIOR CAN EASILY BREAK OUR INFRASTRUCTURE, POSSIBLY MAKING THE ENTIRETY OF THE DEBUG INDEX OR FRAME METADATA WORTHLESS (BREAKING BACKWARDS COMPATIBILITY).
func FileIDFromKernelBuildID ¶
FileIDFromKernelBuildID returns the FileID of a kernel image or module, which consists of a hash of its GNU BuildID in hex string form. The hashing step is to ensure that the FileID remains an opaque concept to the end user.
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.
func (FileID) Hash32 ¶
Hash32 returns a 32 bits hash of the input. It's main purpose is to be used as key for caching.
func (FileID) Swapped ¶
Swapped creates a new FileID with swapped high and low part. This function is its own inverse, so it can be used for the opposite operation. This is mostly used to connect Linux kernel module and its debug file build IDs. This provides 2 properties:
- FileIDs must be different between kernel files and their debug files.
- A kernel FileID (debug and non-debug) must only depend on its GNU BuildID (see FileIDFromKernelBuildID), and can always be computed in the Host Agent or during indexing without external information.
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 base64 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 `InterpreterType` ID.
- A partial (non-critical failure), indicated by ORing the `InterpreterType` 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 `InterpreterType` enum.
const ( // 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 // DotnetFrame identifies the Dotnet interpreter frames. DotnetFrame FrameType = support.FrameMarkerDotnet // 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 FrameTypeFromString ¶
func (FrameType) Interpreter ¶
func (ty FrameType) Interpreter() InterpreterType
Interpreter returns the interpreter that produced the frame.
func (FrameType) IsInterpType ¶
func (ty FrameType) IsInterpType(ity InterpreterType) bool
IsInterpType checks whether the frame type belongs to the given interpreter.
type InterpreterType ¶
type InterpreterType int
InterpreterType variables can hold one of the interpreter type values defined below.
const ( // UnknownInterp signifies that the interpreter is unknown. UnknownInterp InterpreterType = support.FrameMarkerUnknown // PHP identifies the PHP interpreter. PHP InterpreterType = support.FrameMarkerPHP // PHPJIT identifies PHP JIT processes. PHPJIT InterpreterType = support.FrameMarkerPHPJIT // Python identifies the Python interpreter. Python InterpreterType = support.FrameMarkerPython // Native identifies native code. Native InterpreterType = support.FrameMarkerNative // Kernel identifies kernel code. Kernel InterpreterType = support.FrameMarkerKernel // HotSpot identifies the Java HotSpot VM. HotSpot InterpreterType = support.FrameMarkerHotSpot // Ruby identifies the Ruby interpreter. Ruby InterpreterType = support.FrameMarkerRuby // Perl identifies the Perl interpreter. Perl InterpreterType = support.FrameMarkerPerl // V8 identifies the V8 interpreter. V8 InterpreterType = support.FrameMarkerV8 // Dotnet identifies the Dotnet interpreter. Dotnet InterpreterType = support.FrameMarkerDotnet )
const ( // APMInt identifies the pseudo-interpreter for the APM integration. APMInt InterpreterType = 0x100 )
Pseudo-interpreters without a corresponding frame type.
func InterpreterTypeFromString ¶
func InterpreterTypeFromString(name string) InterpreterType
func (InterpreterType) Frame ¶
func (i InterpreterType) Frame() FrameType
Frame converts the interpreter type into the corresponding frame type.
func (InterpreterType) String ¶
func (i InterpreterType) String() string
String converts the frame type int to the related string value to be displayed in the UI.
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 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 NewSymbolMap ¶
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.
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 MappingStart []Address MappingEnd []Address MappingFileOffsets []uint64 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 without mapping information.
func (*Trace) AppendFrameFull ¶
func (trace *Trace) AppendFrameFull(ty FrameType, file FileID, addrOrLine AddressOrLineno, mappingStart Address, mappingEnd Address, mappingFileOffset uint64)
AppendFrameFull appends a frame with mapping info to the columnar frame array.
func (*Trace) AppendFrameID ¶
AppendFrameID appends a frame to the columnar frame array without mapping information.
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 byte slice 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 UnixTime64 ¶
type UnixTime64 uint64
UnixTime64 represents nanoseconds or (reduced precision) seconds since epoch.
func (UnixTime64) MarshalJSON ¶
func (t UnixTime64) MarshalJSON() ([]byte, error)
func (UnixTime64) Unix ¶
func (t UnixTime64) Unix() int64
Unix returns the value as seconds since epoch.
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package basehash provides basic types to implement hash identifiers.
|
Package basehash provides basic types to implement hash identifiers. |
Package hash provides the same hash primitives as used by the eBPF.
|
Package hash provides the same hash primitives as used by the eBPF. |
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. |
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. |