objiotracing

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: BSD-3-Clause Imports: 5 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 WithBlockKind added in v2.1.0

func WithBlockKind(ctx context.Context, kind blockkind.Kind) context.Context

WithBlockKind 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 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
	BlockKind     blockkind.Kind
	// LSM level plus one (with 0 indicating unknown level).
	LevelPlusOne uint8

	FileNum base.DiskFileNum
	// 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