Help us shape the future of Go! Take the 2026 Go Developer Survey

metastore

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStacktraceNotFound = errors.New("stacktrace not found")
	ErrLocationNotFound   = errors.New("location not found")
	ErrMappingNotFound    = errors.New("mapping not found")
	ErrFunctionNotFound   = errors.New("function not found")
)

Functions

func GetLocationsByIDs

func GetLocationsByIDs(ctx context.Context, s ProfileMetaStore, ids ...[]byte) (
	map[string]*Location,
	error,
)

func MakeFunctionKey

func MakeFunctionKey(f *pb.Function) []byte

func MakeLocationKey

func MakeLocationKey(l *Location) []byte

func MakeMappingKey

func MakeMappingKey(m *pb.Mapping) []byte

func UnsymbolizableMapping

func UnsymbolizableMapping(m *pb.Mapping) bool

UnsymbolizableMapping returns true if a mapping points to a binary for which locations can't be symbolized in principle, at least now. Examples are "[vdso]", [vsyscall]" and some others, see the code.

Types

type BadgerLogger

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

func (*BadgerLogger) Debugf

func (l *BadgerLogger) Debugf(f string, v ...interface{})

func (*BadgerLogger) Errorf

func (l *BadgerLogger) Errorf(f string, v ...interface{})

func (*BadgerLogger) Infof

func (l *BadgerLogger) Infof(f string, v ...interface{})

func (*BadgerLogger) Warningf

func (l *BadgerLogger) Warningf(f string, v ...interface{})

type BadgerMetastore

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

BadgerMetastore is an implementation of the metastore using the badger KV store.

func NewBadgerMetastore

func NewBadgerMetastore(
	logger log.Logger,
	reg prometheus.Registerer,
	tracer trace.Tracer,
	uuidGenerator UUIDGenerator,
) *BadgerMetastore

NewBadgerMetastore returns a new BadgerMetastore with using in-memory badger instance.

func (*BadgerMetastore) Close

func (m *BadgerMetastore) Close() error

Close closes the badger store.

func (*BadgerMetastore) CreateFunction

func (m *BadgerMetastore) CreateFunction(ctx context.Context, f *pb.Function) ([]byte, error)

CreateFunction creates a new function in the database.

func (*BadgerMetastore) CreateLocation

func (m *BadgerMetastore) CreateLocation(ctx context.Context, l *Location) ([]byte, error)

func (*BadgerMetastore) CreateLocationLines

func (m *BadgerMetastore) CreateLocationLines(ctx context.Context, locID []byte, lines []LocationLine) error

CreateLocationLines writes a set of lines related to a location to the database.

func (*BadgerMetastore) CreateMapping

func (m *BadgerMetastore) CreateMapping(ctx context.Context, mapping *pb.Mapping) ([]byte, error)

CreateMapping creates a new mapping in the database.

func (*BadgerMetastore) CreateStacktrace

func (m *BadgerMetastore) CreateStacktrace(ctx context.Context, key []byte, sample *pb.Sample) (uuid.UUID, error)

func (*BadgerMetastore) GetFunctionByKey

func (m *BadgerMetastore) GetFunctionByKey(ctx context.Context, key *pb.Function) (*pb.Function, error)

GetFunctionByKey returns the function for the given key.

func (*BadgerMetastore) GetFunctions

func (m *BadgerMetastore) GetFunctions(ctx context.Context) ([]*pb.Function, error)

GetFunctions returns all functions in the database.

func (*BadgerMetastore) GetFunctionsByIDs

func (m *BadgerMetastore) GetFunctionsByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Function, error)

GetFunctionByID returns the function for the given ID.

func (*BadgerMetastore) GetLinesByLocationIDs

func (m *BadgerMetastore) GetLinesByLocationIDs(ctx context.Context, ids ...[]byte) (
	map[string][]*pb.Line,
	[][]byte,
	error,
)

GetLinesByLocationIDs returns the lines for the given location IDs.

func (*BadgerMetastore) GetLocationByKey

func (m *BadgerMetastore) GetLocationByKey(ctx context.Context, key *Location) (*pb.Location, error)

func (*BadgerMetastore) GetLocations

func (m *BadgerMetastore) GetLocations(ctx context.Context) ([]*pb.Location, [][]byte, error)

func (*BadgerMetastore) GetLocationsByIDs

func (m *BadgerMetastore) GetLocationsByIDs(ctx context.Context, ids ...[]byte) (
	map[string]*pb.Location,
	[][]byte,
	error,
)

func (*BadgerMetastore) GetMappingByKey

func (m *BadgerMetastore) GetMappingByKey(ctx context.Context, key *pb.Mapping) (*pb.Mapping, error)

GetMappingByKey returns the mapping for the given key.

func (*BadgerMetastore) GetMappingsByIDs

func (m *BadgerMetastore) GetMappingsByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Mapping, error)

GetMappingsByIDs returns the mappings for the given IDs.

func (*BadgerMetastore) GetStacktraceByIDs

func (m *BadgerMetastore) GetStacktraceByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Sample, error)

func (*BadgerMetastore) GetStacktraceByKey

func (m *BadgerMetastore) GetStacktraceByKey(ctx context.Context, key []byte) (uuid.UUID, error)

func (*BadgerMetastore) GetSymbolizableLocations

func (m *BadgerMetastore) GetSymbolizableLocations(ctx context.Context) ([]*pb.Location, [][]byte, error)

func (*BadgerMetastore) Ping

func (m *BadgerMetastore) Ping() error

Ping returns an error if the metastore is not available.

func (*BadgerMetastore) Symbolize

func (m *BadgerMetastore) Symbolize(ctx context.Context, l *Location) error

type FunctionKey

type FunctionKey struct {
	StartLine                  int64
	Name, SystemName, Filename string
}

func MakeSQLFunctionKey

func MakeSQLFunctionKey(f *pb.Function) FunctionKey

type FunctionStore

type FunctionStore interface {
	GetFunctionByKey(ctx context.Context, key *pb.Function) (*pb.Function, error)
	CreateFunction(ctx context.Context, f *pb.Function) ([]byte, error)
	GetFunctionsByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Function, error)
	GetFunctions(ctx context.Context) ([]*pb.Function, error)
}

type LinearUUIDGenerator

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

Some tests need UUID generation to be predictable, so this generator just returns monotonically increasing UUIDs as if the UUID was a 16 byte integer. WARNING: THIS IS ONLY MEANT FOR TESTING.

func (*LinearUUIDGenerator) New

func (g *LinearUUIDGenerator) New() uuid.UUID

New returns the next UUID according to the current count.

type Location

type Location struct {
	ID       uuid.UUID
	Address  uint64
	Mapping  *pb.Mapping
	Lines    []LocationLine
	IsFolded bool
}

func GetLocationByKey

func GetLocationByKey(ctx context.Context, s ProfileMetaStore, key *Location) (*Location, error)

func GetLocations

func GetLocations(ctx context.Context, s ProfileMetaStore) ([]*Location, error)

Only used in tests so not as important to be efficient.

func GetSymbolizableLocations

func GetSymbolizableLocations(ctx context.Context, s ProfileMetaStore) (
	[]*Location,
	error,
)

type LocationKey

type LocationKey struct {
	Address   uint64
	MappingID uuid.UUID
	Lines     string
	IsFolded  bool
}

func MakeSQLLocationKey

func MakeSQLLocationKey(l *Location) LocationKey

type LocationLine

type LocationLine struct {
	Line     int64
	Function *pb.Function
}

type LocationLineStore

type LocationLineStore interface {
	CreateLocationLines(ctx context.Context, locID []byte, lines []LocationLine) error
	GetLinesByLocationIDs(ctx context.Context, id ...[]byte) (map[string][]*pb.Line, [][]byte, error)
}

type LocationStore

type LocationStore interface {
	GetLocations(ctx context.Context) ([]*pb.Location, [][]byte, error)
	GetLocationByKey(ctx context.Context, key *Location) (*pb.Location, error)
	GetLocationsByIDs(ctx context.Context, id ...[]byte) (map[string]*pb.Location, [][]byte, error)
	CreateLocation(ctx context.Context, l *Location) ([]byte, error)
	Symbolize(ctx context.Context, location *Location) error
	GetSymbolizableLocations(ctx context.Context) ([]*pb.Location, [][]byte, error)
}

type MappingKey

type MappingKey struct {
	Size, Offset  uint64
	BuildIDOrFile string
}

func MakeSQLMappingKey

func MakeSQLMappingKey(m *pb.Mapping) MappingKey

type MappingStore

type MappingStore interface {
	GetMappingByKey(ctx context.Context, key *pb.Mapping) (*pb.Mapping, error)
	CreateMapping(ctx context.Context, m *pb.Mapping) ([]byte, error)
	GetMappingsByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Mapping, error)
}

type ProfileMetaStore

type ProfileMetaStore interface {
	StacktraceStore
	LocationStore
	LocationLineStore
	FunctionStore
	MappingStore
	Close() error
	Ping() error
}

type RandomUUIDGenerator

type RandomUUIDGenerator struct{}

RandomUUIDGenerator returns a new random UUID.

func (*RandomUUIDGenerator) New

func (g *RandomUUIDGenerator) New() uuid.UUID

New returns a new UUID.

type RemoteMetaStore

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

func NewRemoteMetaStore added in v0.9.0

func NewRemoteMetaStore(reg prometheus.Registerer, db *sql.DB) (*RemoteMetaStore, error)

NewRemoteMetaStore creates a sql metastore with given remote database connection.

func (RemoteMetaStore) Close

func (s RemoteMetaStore) Close() error

func (RemoteMetaStore) CreateFunction

func (s RemoteMetaStore) CreateFunction(ctx context.Context, fn *pb.Function) ([]byte, error)

func (RemoteMetaStore) CreateLocation

func (s RemoteMetaStore) CreateLocation(ctx context.Context, l *Location) ([]byte, error)

func (RemoteMetaStore) CreateLocationLines

func (s RemoteMetaStore) CreateLocationLines(ctx context.Context, locID []byte, lines []LocationLine) error

func (RemoteMetaStore) CreateMapping

func (s RemoteMetaStore) CreateMapping(ctx context.Context, m *pb.Mapping) ([]byte, error)

func (RemoteMetaStore) CreateStacktrace

func (r RemoteMetaStore) CreateStacktrace(ctx context.Context, key []byte, sample *pb.Sample) (uuid.UUID, error)

func (RemoteMetaStore) GetFunctionByKey

func (s RemoteMetaStore) GetFunctionByKey(ctx context.Context, fkey *pb.Function) (*pb.Function, error)

func (RemoteMetaStore) GetFunctions

func (s RemoteMetaStore) GetFunctions(ctx context.Context) ([]*pb.Function, error)

func (RemoteMetaStore) GetFunctionsByIDs

func (s RemoteMetaStore) GetFunctionsByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Function, error)

func (RemoteMetaStore) GetLinesByLocationIDs

func (s RemoteMetaStore) GetLinesByLocationIDs(ctx context.Context, ids ...[]byte) (map[string][]*pb.Line, [][]byte, error)

func (RemoteMetaStore) GetLocationByKey

func (s RemoteMetaStore) GetLocationByKey(ctx context.Context, lkey *Location) (*pb.Location, error)

func (RemoteMetaStore) GetLocations

func (s RemoteMetaStore) GetLocations(ctx context.Context) ([]*pb.Location, [][]byte, error)

func (RemoteMetaStore) GetLocationsByIDs

func (s RemoteMetaStore) GetLocationsByIDs(ctx context.Context, ids ...[]byte) (
	map[string]*pb.Location,
	[][]byte,
	error,
)

func (RemoteMetaStore) GetMappingByKey

func (s RemoteMetaStore) GetMappingByKey(ctx context.Context, mkey *pb.Mapping) (*pb.Mapping, error)

func (RemoteMetaStore) GetMappingsByIDs

func (s RemoteMetaStore) GetMappingsByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Mapping, error)

func (RemoteMetaStore) GetStacktraceByIDs

func (r RemoteMetaStore) GetStacktraceByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Sample, error)

func (RemoteMetaStore) GetStacktraceByKey

func (r RemoteMetaStore) GetStacktraceByKey(ctx context.Context, key []byte) (uuid.UUID, error)

func (RemoteMetaStore) GetSymbolizableLocations

func (s RemoteMetaStore) GetSymbolizableLocations(ctx context.Context) ([]*pb.Location, [][]byte, error)

func (RemoteMetaStore) Ping

func (s RemoteMetaStore) Ping() error

func (RemoteMetaStore) Symbolize

func (s RemoteMetaStore) Symbolize(ctx context.Context, l *Location) error

type StacktraceStore

type StacktraceStore interface {
	GetStacktraceByKey(ctx context.Context, key []byte) (uuid.UUID, error)
	GetStacktraceByIDs(ctx context.Context, ids ...[]byte) (map[string]*pb.Sample, error)
	CreateStacktrace(ctx context.Context, key []byte, sample *pb.Sample) (uuid.UUID, error)
}

type UUIDGenerator

type UUIDGenerator interface {
	New() uuid.UUID
}

UUIDGenerator returns new UUIDs.

func NewLinearUUIDGenerator

func NewLinearUUIDGenerator() UUIDGenerator

NewLinearUUIDGenerator returns a new LinearUUIDGenerator.

func NewRandomUUIDGenerator

func NewRandomUUIDGenerator() UUIDGenerator

NewRandomUUIDGenerator returns a new random UUID generator.

Jump to

Keyboard shortcuts

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