instrumentation

package
v0.1.44 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessStreamName

func AccessStreamName(sessionID string) string

AccessStreamName returns the S2 stream name for an access session.

Types

type AccessEvent

type AccessEvent struct {
	Timestamp        int64  `json:"ts"`
	WorkspaceID      string `json:"workspace_id"`
	SessionID        string `json:"session_id"`
	Path             string `json:"path"`
	Integration      string `json:"integration"`
	QueryPath        string `json:"query_path"`
	ResultID         string `json:"result_id"`
	OriginalBytes    int    `json:"original_bytes"`
	CompressedBytes  int    `json:"compressed_bytes"`
	OriginalTokens   int    `json:"original_tokens"`
	CompressedTokens int    `json:"compressed_tokens"`
	Strategy         string `json:"strategy"` // requested strategy
	Outcome          string `json:"outcome"`  // "compressed", "cache_hit", "passthrough", "timeout", "error", "skipped"
	CompressionMs    int64  `json:"compression_ms"`
	ErrorMsg         string `json:"error_msg,omitempty"` // populated on outcome=error or timeout
}

AccessEvent records a single file access through the filesystem. Every read produces exactly one event regardless of compression outcome.

type AccessRecorder

type AccessRecorder interface {
	// Record enqueues an access event for async delivery.
	Record(ctx context.Context, event AccessEvent) error
	// Flush drains any buffered events. Called on graceful shutdown.
	Flush() error
}

AccessRecorder records file access events. Implementations must be safe for concurrent use and should be non-blocking (buffer internally).

type EventFlusher

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

EventFlusher writes access events to an S2 stream asynchronously. Record() is non-blocking; events are buffered and flushed by a background goroutine.

func NewEventFlusher

func NewEventFlusher(s2 *common.S2Client) *EventFlusher

NewEventFlusher creates and starts an S2-backed access recorder. Call Flush() on shutdown to drain buffered events.

func (*EventFlusher) Flush

func (f *EventFlusher) Flush() error

Flush signals the background goroutine to stop and waits for it to drain remaining events. Safe to call multiple times.

func (*EventFlusher) Record

func (f *EventFlusher) Record(_ context.Context, event AccessEvent) error

Record enqueues an event for async delivery. Non-blocking: if the buffer is full the event is dropped (logged as a warning).

type NoopRecorder

type NoopRecorder struct{}

NoopRecorder discards all events. Used when instrumentation is disabled or in tests.

func NewNoopRecorder

func NewNoopRecorder() *NoopRecorder

func (*NoopRecorder) Flush

func (n *NoopRecorder) Flush() error

func (*NoopRecorder) Record

func (n *NoopRecorder) Record(_ context.Context, _ AccessEvent) error

Jump to

Keyboard shortcuts

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