symdb

package
v1.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirName      = "symbols"
	IndexFileName       = "index.symdb"
	StacktracesFileName = "stacktraces.symdb"
)
View Source
const (
	FormatV1
)
View Source
const HeaderSize = int(unsafe.Sizeof(Header{}))

Variables

View Source
var (
	ErrInvalidSize    = &FormatError{fmt.Errorf("invalid size")}
	ErrInvalidCRC     = &FormatError{fmt.Errorf("invalid CRC")}
	ErrInvalidMagic   = &FormatError{fmt.Errorf("invalid magic number")}
	ErrUnknownVersion = &FormatError{fmt.Errorf("unknown version")}
)
View Source
var ErrInvalidStacktraceRange = fmt.Errorf("invalid range: stack traces can't be resolved")

Functions

This section is empty.

Types

type ChunkEncoding

type ChunkEncoding byte
const (
	ChunkEncodingGroupVarint ChunkEncoding
)

type Config

type Config struct {
	Dir         string
	Stacktraces StacktracesConfig
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) WithDirectory

func (c *Config) WithDirectory(dir string) *Config

type FormatError

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

func (*FormatError) Error

func (e *FormatError) Error() string
type Header struct {
	Magic    [4]byte
	Version  uint32
	Reserved [8]byte // Reserved for future use.
}

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() ([]byte, error)

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(b []byte) error

type IndexFile

type IndexFile struct {
	Header Header
	TOC    TOC

	// StacktraceChunkHeaders are sorted by
	// partition and chunk index in ascending order.
	StacktraceChunkHeaders StacktraceChunkHeaders

	CRC uint32
}

func OpenIndexFile

func OpenIndexFile(b []byte) (f IndexFile, err error)

func (*IndexFile) WriteTo

func (f *IndexFile) WriteTo(dst io.Writer) (n int64, err error)

type Reader

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

func Open

func (*Reader) Load

func (r *Reader) Load(ctx context.Context) error

Load causes reader to load all contents into memory.

func (*Reader) SymbolsResolver

func (r *Reader) SymbolsResolver(partition uint64) (SymbolsResolver, bool)

type ReaderConfig

type ReaderConfig struct {
	BucketReader objstore.BucketReader

	MaxConcurrentChunks  int
	ChunkFetchBufferSize int
}

type StacktraceAppender

type StacktraceAppender interface {
	// AppendStacktrace appends the stack traces into the mapping,
	// and writes the allocated identifiers into dst:
	// len(dst) must be equal to len(s).
	// The leaf is at locations[0].
	AppendStacktrace(dst []uint32, s []*schemasv1.Stacktrace)
	Release()
}

type StacktraceChunkHeader

type StacktraceChunkHeader struct {
	Offset int64
	Size   int64

	Partition     uint64
	ChunkIndex    uint16
	ChunkEncoding ChunkEncoding

	Stacktraces        uint32 // Number of unique stack traces in the chunk.
	StacktraceNodes    uint32 // Number of nodes in the stacktrace tree.
	StacktraceMaxDepth uint32 // Max stack trace depth in the tree.
	StacktraceMaxNodes uint32 // Max number of nodes at the time of the chunk creation.

	CRC uint32 // Checksum of the chunk data [Offset:Size).
	// contains filtered or unexported fields
}

type StacktraceChunkHeaders

type StacktraceChunkHeaders struct {
	Entries []StacktraceChunkHeader
}

func (*StacktraceChunkHeaders) MarshalBinary

func (h *StacktraceChunkHeaders) MarshalBinary() ([]byte, error)

func (*StacktraceChunkHeaders) Size

func (h *StacktraceChunkHeaders) Size() int64

func (*StacktraceChunkHeaders) UnmarshalBinary

func (h *StacktraceChunkHeaders) UnmarshalBinary(b []byte) error

type StacktraceInserter

type StacktraceInserter interface {
	InsertStacktrace(stacktraceID uint32, locations []int32)
}

StacktraceInserter accepts resolved locations for a given stack trace. The leaf is at locations[0].

Locations slice must not be retained by implementation. It is guaranteed, that for a given stacktrace ID InsertStacktrace is called not more than once.

type StacktraceInserterFn

type StacktraceInserterFn func(stacktraceID uint32, locations []int32)

func (StacktraceInserterFn) InsertStacktrace

func (fn StacktraceInserterFn) InsertStacktrace(stacktraceID uint32, locations []int32)

type StacktraceResolver

type StacktraceResolver interface {
	// ResolveStacktraces resolves locations for each stack trace
	// and inserts it to the StacktraceInserter provided.
	//
	// The stacktraces must be ordered in the ascending order.
	// If a stacktrace can't be resolved, dst receives an empty
	// array of locations.
	//
	// Stacktraces slice might be modified during the call.
	ResolveStacktraces(ctx context.Context, dst StacktraceInserter, stacktraces []uint32) error
	Release()
}

type StacktracesConfig

type StacktracesConfig struct {
	MaxNodesPerChunk uint32
}

type StacktracesRange

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

func SplitStacktraces

func SplitStacktraces(s []uint32, n uint32) []StacktracesRange

SplitStacktraces splits the range of stack trace IDs by limit n into sub-ranges matching to the corresponding chunks and shifts the values accordingly. Note that the input s is modified in place.

stack trace ID 0 is reserved and is not expected at the input. stack trace ID % max_nodes == 0 is not expected as well.

type Stats

type Stats struct {
	StacktracesTotal int
	LocationsTotal   int
	MappingsTotal    int
	FunctionsTotal   int
	StringsTotal     int
	MaxStacktraceID  int
}

type SymDB

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

func NewSymDB

func NewSymDB(c *Config) *SymDB

func (*SymDB) Flush

func (s *SymDB) Flush() error

func (*SymDB) MemorySize

func (s *SymDB) MemorySize() uint64

func (*SymDB) Name

func (s *SymDB) Name() string

func (*SymDB) Size

func (s *SymDB) Size() uint64

func (*SymDB) SymbolsAppender

func (s *SymDB) SymbolsAppender(partition uint64) SymbolsAppender

func (*SymDB) SymbolsResolver

func (s *SymDB) SymbolsResolver(partition uint64) (SymbolsResolver, bool)

type SymbolsAppender

type SymbolsAppender interface {
	StacktraceAppender() StacktraceAppender
}

type SymbolsResolver

type SymbolsResolver interface {
	StacktraceResolver() StacktraceResolver
	WriteStats(*Stats)
}

type TOC

type TOC struct {
	Entries []TOCEntry
}

func (*TOC) MarshalBinary

func (toc *TOC) MarshalBinary() ([]byte, error)

func (*TOC) Size

func (toc *TOC) Size() int

func (*TOC) UnmarshalBinary

func (toc *TOC) UnmarshalBinary(b []byte) error

type TOCEntry

type TOCEntry struct {
	Offset int64
	Size   int64
}

type Writer

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

func NewWriter

func NewWriter(dir string) *Writer

func (*Writer) Flush

func (w *Writer) Flush() (err error)

Jump to

Keyboard shortcuts

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