objiotracing

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Enabled = false

Enabled is used to short circuit tracing-related code in regular builds.

Variables

This section is empty.

Functions

func WithBlockType

func WithBlockType(ctx context.Context, blockType BlockType) context.Context

WithBlockType creates a context that has an associated BlockType (which ends up in traces created under that context).

func WithLevel

func WithLevel(ctx context.Context, level int) context.Context

WithLevel creates a context that has an associated level (which ends up in traces created under that context).

func WithReason

func WithReason(ctx context.Context, reason Reason) context.Context

WithReason creates a context that has an associated Reason (which ends up in traces created under that context).

Types

type BlockType

type BlockType uint8

BlockType indicates the type of data block relevant to an operation.

const (
	UnknownBlock BlockType = iota
	DataBlock
	ValueBlock
	FilterBlock
	MetadataBlock
)

BlockType values.

type Event

type Event struct {
	// Event start time as a Unix time (see time.Time.StartUnixNano()).
	// Note that recorded events are not necessarily ordered by time - this is
	// because separate event "streams" use local buffers (for performance).
	StartUnixNano int64
	Op            OpType
	Reason        Reason
	BlockType     BlockType
	// LSM level plus one (with 0 indicating unknown level).
	LevelPlusOne uint8

	FileNum base.FileNum
	// HandleID is a unique identifier corresponding to an objstorage.ReadHandle;
	// only set for read operations performed through a ReadHandle.
	HandleID uint64
	Offset   int64
	Size     int64
	// contains filtered or unexported fields
}

Event is the on-disk format of a tracing event. It is exported here so that trace processing tools can use it by importing this package.

type OpType

type OpType uint8

OpType indicates the type of operation.

const (
	ReadOp OpType = iota
	WriteOp
	// RecordCacheHitOp happens when a read is satisfied from the block cache. See
	// objstorage.ReadHandle.RecordCacheHit().
	RecordCacheHitOp
	// SetupForCompactionOp is a "meta operation" that configures a read handle
	// for large sequential reads. See objstorage.ReadHandle.SetupForCompaction().
	SetupForCompactionOp
)

OpType values.

type Reason

type Reason uint8

Reason indicates the higher-level context of the operation.

const (
	UnknownReason Reason = iota
	ForFlush
	ForCompaction
	ForIngestion
)

Reason values.

type Tracer

type Tracer struct{}

Tracer manages the writing of object IO traces to files.

func Open

func Open(fs vfs.FS, fsDir string) *Tracer

Open creates a Tracer which generates trace files in the given directory. Each trace file contains a series of Events (as they are in memory).

func (*Tracer) Close

func (*Tracer) Close()

Close the tracer, flushing any remaining events.

func (*Tracer) WrapReadable

func (*Tracer) WrapReadable(
	ctx context.Context, r objstorage.Readable, fileNum base.DiskFileNum,
) objstorage.Readable

WrapReadable wraps an objstorage.Readable with one that generates tracing events.

func (*Tracer) WrapWritable

func (t *Tracer) WrapWritable(
	ctx context.Context, w objstorage.Writable, fileNum base.DiskFileNum,
) objstorage.Writable

WrapWritable wraps an objstorage.Writable with one that generates tracing events.

Jump to

Keyboard shortcuts

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