Documentation
¶
Index ¶
- type Collector
- type Config
- type MetricsFS
- func (m *MetricsFS) Chdir(dir string) error
- func (m *MetricsFS) Chmod(name string, mode os.FileMode) error
- func (m *MetricsFS) Chown(name string, uid, gid int) error
- func (m *MetricsFS) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (m *MetricsFS) Collector() *Collector
- func (m *MetricsFS) Create(name string) (absfs.File, error)
- func (m *MetricsFS) Getwd() (string, error)
- func (m *MetricsFS) Lstat(name string) (os.FileInfo, error)
- func (m *MetricsFS) Mkdir(name string, perm os.FileMode) error
- func (m *MetricsFS) MkdirAll(name string, perm os.FileMode) error
- func (m *MetricsFS) Open(name string) (absfs.File, error)
- func (m *MetricsFS) OpenFile(name string, flag int, perm os.FileMode) (absfs.File, error)
- func (m *MetricsFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *MetricsFS) ReadFile(name string) ([]byte, error)
- func (m *MetricsFS) Readlink(name string) (string, error)
- func (m *MetricsFS) Remove(name string) error
- func (m *MetricsFS) RemoveAll(name string) error
- func (m *MetricsFS) Rename(oldpath, newpath string) error
- func (m *MetricsFS) Stat(name string) (os.FileInfo, error)
- func (m *MetricsFS) Sub(dir string) (fs.FS, error)
- func (m *MetricsFS) Symlink(oldname, newname string) error
- func (m *MetricsFS) TempDir() string
- func (m *MetricsFS) Truncate(name string, size int64) error
- type MetricsFile
- func (f *MetricsFile) Close() error
- func (f *MetricsFile) Name() string
- func (f *MetricsFile) Read(p []byte) (n int, err error)
- func (f *MetricsFile) ReadAt(p []byte, off int64) (n int, err error)
- func (f *MetricsFile) ReadDir(n int) ([]fs.DirEntry, error)
- func (f *MetricsFile) Readdir(n int) ([]os.FileInfo, error)
- func (f *MetricsFile) Readdirnames(n int) ([]string, error)
- func (f *MetricsFile) Seek(offset int64, whence int) (int64, error)
- func (f *MetricsFile) Stat() (os.FileInfo, error)
- func (f *MetricsFile) Sync() error
- func (f *MetricsFile) Truncate(size int64) error
- func (f *MetricsFile) Write(p []byte) (n int, err error)
- func (f *MetricsFile) WriteAt(p []byte, off int64) (n int, err error)
- func (f *MetricsFile) WriteString(s string) (n int, err error)
- type OTelCollector
- type OTelConfig
- type OTelMetricsFS
- func (m *OTelMetricsFS) Chdir(dir string) error
- func (m *OTelMetricsFS) ChdirWithContext(ctx context.Context, dir string) error
- func (m *OTelMetricsFS) Chmod(name string, mode os.FileMode) error
- func (m *OTelMetricsFS) ChmodWithContext(ctx context.Context, name string, mode os.FileMode) error
- func (m *OTelMetricsFS) Chown(name string, uid, gid int) error
- func (m *OTelMetricsFS) ChownWithContext(ctx context.Context, name string, uid, gid int) error
- func (m *OTelMetricsFS) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (m *OTelMetricsFS) ChtimesWithContext(ctx context.Context, name string, atime time.Time, mtime time.Time) error
- func (m *OTelMetricsFS) Collector() *OTelCollector
- func (m *OTelMetricsFS) Create(name string) (absfs.File, error)
- func (m *OTelMetricsFS) CreateWithContext(ctx context.Context, name string) (absfs.File, error)
- func (m *OTelMetricsFS) Getwd() (string, error)
- func (m *OTelMetricsFS) GetwdWithContext(ctx context.Context) (string, error)
- func (m *OTelMetricsFS) Lstat(name string) (os.FileInfo, error)
- func (m *OTelMetricsFS) LstatWithContext(ctx context.Context, name string) (os.FileInfo, error)
- func (m *OTelMetricsFS) Mkdir(name string, perm os.FileMode) error
- func (m *OTelMetricsFS) MkdirAll(name string, perm os.FileMode) error
- func (m *OTelMetricsFS) MkdirAllWithContext(ctx context.Context, name string, perm os.FileMode) error
- func (m *OTelMetricsFS) MkdirWithContext(ctx context.Context, name string, perm os.FileMode) error
- func (m *OTelMetricsFS) Open(name string) (absfs.File, error)
- func (m *OTelMetricsFS) OpenFile(name string, flag int, perm os.FileMode) (absfs.File, error)
- func (m *OTelMetricsFS) OpenFileWithContext(ctx context.Context, name string, flag int, perm os.FileMode) (absfs.File, error)
- func (m *OTelMetricsFS) OpenWithContext(ctx context.Context, name string) (absfs.File, error)
- func (m *OTelMetricsFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *OTelMetricsFS) ReadDirWithContext(ctx context.Context, name string) ([]fs.DirEntry, error)
- func (m *OTelMetricsFS) ReadFile(name string) ([]byte, error)
- func (m *OTelMetricsFS) ReadFileWithContext(ctx context.Context, name string) ([]byte, error)
- func (m *OTelMetricsFS) Readlink(name string) (string, error)
- func (m *OTelMetricsFS) ReadlinkWithContext(ctx context.Context, name string) (string, error)
- func (m *OTelMetricsFS) Remove(name string) error
- func (m *OTelMetricsFS) RemoveAll(name string) error
- func (m *OTelMetricsFS) RemoveAllWithContext(ctx context.Context, name string) error
- func (m *OTelMetricsFS) RemoveWithContext(ctx context.Context, name string) error
- func (m *OTelMetricsFS) Rename(oldpath, newpath string) error
- func (m *OTelMetricsFS) RenameWithContext(ctx context.Context, oldpath, newpath string) error
- func (m *OTelMetricsFS) Stat(name string) (os.FileInfo, error)
- func (m *OTelMetricsFS) StatWithContext(ctx context.Context, name string) (os.FileInfo, error)
- func (m *OTelMetricsFS) Sub(dir string) (fs.FS, error)
- func (m *OTelMetricsFS) SubWithContext(ctx context.Context, dir string) (fs.FS, error)
- func (m *OTelMetricsFS) Symlink(oldname, newname string) error
- func (m *OTelMetricsFS) SymlinkWithContext(ctx context.Context, oldname, newname string) error
- func (m *OTelMetricsFS) TempDir() string
- func (m *OTelMetricsFS) Truncate(name string, size int64) error
- func (m *OTelMetricsFS) TruncateWithContext(ctx context.Context, name string, size int64) error
- type Operation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector collects and exposes filesystem metrics.
func NewCollector ¶
NewCollector creates a new metrics collector with the given configuration.
func (*Collector) Collect ¶
func (c *Collector) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Collector) Describe ¶
func (c *Collector) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
type Config ¶
type Config struct {
// Namespace for Prometheus metrics (default: "fs")
Namespace string
// Subsystem name for Prometheus metrics (default: "")
Subsystem string
// ConstLabels are labels that will be applied to all metrics
ConstLabels prometheus.Labels
// EnableLatencyMetrics controls whether operation latency histograms are collected
EnableLatencyMetrics bool
// EnableBandwidthMetrics controls whether bandwidth counters are collected
EnableBandwidthMetrics bool
// EnablePathMetrics controls whether path-level metrics are collected
// WARNING: This can lead to high cardinality - disabled by default
EnablePathMetrics bool
// LatencyBuckets defines histogram buckets for operation latency (in seconds)
// Default: [0.001, 0.01, 0.1, 1.0, 10.0]
LatencyBuckets []float64
// SizeBuckets defines histogram buckets for data transfer sizes (in bytes)
// Default: prometheus.ExponentialBuckets(1024, 2, 10)
SizeBuckets []float64
// MaxTrackedPaths is the maximum number of unique paths to track
// Only used when EnablePathMetrics is true (default: 100)
MaxTrackedPaths int
// PathSampleRate controls sampling rate for path metrics (0.0 to 1.0)
// Only used when EnablePathMetrics is true (default: 0.01)
PathSampleRate float64
// OnOperation is called after each filesystem operation
OnOperation func(op Operation)
// OnError is called when an operation encounters an error
OnError func(operation string, err error)
}
Config holds configuration options for the metrics filesystem.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with default values.
type MetricsFS ¶
type MetricsFS struct {
// contains filtered or unexported fields
}
MetricsFS wraps an absfs.FileSystem and collects metrics on all operations.
func New ¶
func New(fs absfs.FileSystem) *MetricsFS
New creates a new MetricsFS that wraps the given filesystem. It uses default configuration. For custom configuration, use NewWithConfig.
func NewWithConfig ¶
func NewWithConfig(fs absfs.FileSystem, config Config) *MetricsFS
NewWithConfig creates a new MetricsFS with custom configuration.
func (*MetricsFS) Collector ¶
Collector returns the Prometheus collector for this filesystem. Register this with prometheus.MustRegister() to expose metrics.
func (*MetricsFS) Lstat ¶
Lstat returns file information without following symlinks. This method is only available if the underlying filesystem implements SymlinkFileSystem.
func (*MetricsFS) ReadDir ¶
ReadDir reads the named directory and returns a list of directory entries.
func (*MetricsFS) Readlink ¶
Readlink reads the target of a symbolic link. This method is only available if the underlying filesystem implements SymlinkFileSystem.
func (*MetricsFS) Symlink ¶
Symlink creates a symbolic link. This method is only available if the underlying filesystem implements SymlinkFileSystem.
type MetricsFile ¶
type MetricsFile struct {
// contains filtered or unexported fields
}
MetricsFile wraps an absfs.File and collects metrics on file operations.
func (*MetricsFile) Read ¶
func (f *MetricsFile) Read(p []byte) (n int, err error)
Read reads data from the file.
func (*MetricsFile) ReadAt ¶
func (f *MetricsFile) ReadAt(p []byte, off int64) (n int, err error)
ReadAt reads data from the file at a specific offset.
func (*MetricsFile) ReadDir ¶
func (f *MetricsFile) ReadDir(n int) ([]fs.DirEntry, error)
ReadDir reads the contents of the directory and returns a slice of up to n DirEntry values.
func (*MetricsFile) Readdir ¶
func (f *MetricsFile) Readdir(n int) ([]os.FileInfo, error)
Readdir reads directory entries.
func (*MetricsFile) Readdirnames ¶
func (f *MetricsFile) Readdirnames(n int) ([]string, error)
Readdirnames reads directory entry names.
func (*MetricsFile) Seek ¶
func (f *MetricsFile) Seek(offset int64, whence int) (int64, error)
Seek sets the file offset for the next read or write.
func (*MetricsFile) Stat ¶
func (f *MetricsFile) Stat() (os.FileInfo, error)
Stat returns file information.
func (*MetricsFile) Sync ¶
func (f *MetricsFile) Sync() error
Sync commits the current contents of the file to stable storage.
func (*MetricsFile) Truncate ¶
func (f *MetricsFile) Truncate(size int64) error
Truncate changes the size of the file.
func (*MetricsFile) Write ¶
func (f *MetricsFile) Write(p []byte) (n int, err error)
Write writes data to the file.
func (*MetricsFile) WriteAt ¶
func (f *MetricsFile) WriteAt(p []byte, off int64) (n int, err error)
WriteAt writes data to the file at a specific offset.
func (*MetricsFile) WriteString ¶
func (f *MetricsFile) WriteString(s string) (n int, err error)
WriteString writes a string to the file.
type OTelCollector ¶
type OTelCollector struct {
// contains filtered or unexported fields
}
OTelCollector collects filesystem metrics using OpenTelemetry.
func NewOTelCollector ¶
func NewOTelCollector(config OTelConfig) (*OTelCollector, error)
NewOTelCollector creates a new OpenTelemetry metrics collector.
type OTelConfig ¶
type OTelConfig struct {
// MeterProvider for creating metrics instruments
MeterProvider metric.MeterProvider
// TracerProvider for creating traces
TracerProvider trace.TracerProvider
// MeterName is the name of the meter (default: "github.com/absfs/metricsfs")
MeterName string
// TracerName is the name of the tracer (default: "github.com/absfs/metricsfs")
TracerName string
// EnableTracing enables distributed tracing for filesystem operations
EnableTracing bool
// ConstAttributes are attributes that will be applied to all metrics and spans
ConstAttributes []attribute.KeyValue
}
OTelConfig holds configuration for OpenTelemetry integration.
type OTelMetricsFS ¶
type OTelMetricsFS struct {
// contains filtered or unexported fields
}
OTelMetricsFS wraps an absfs.FileSystem with OpenTelemetry instrumentation.
func NewWithOTel ¶
func NewWithOTel(fs absfs.FileSystem, config OTelConfig) (*OTelMetricsFS, error)
NewWithOTel creates a new filesystem wrapper with OpenTelemetry instrumentation.
func (*OTelMetricsFS) Chdir ¶
func (m *OTelMetricsFS) Chdir(dir string) error
Chdir changes the current working directory.
func (*OTelMetricsFS) ChdirWithContext ¶
func (m *OTelMetricsFS) ChdirWithContext(ctx context.Context, dir string) error
ChdirWithContext changes the current working directory with context and tracing.
func (*OTelMetricsFS) Chmod ¶
func (m *OTelMetricsFS) Chmod(name string, mode os.FileMode) error
Chmod changes file permissions.
func (*OTelMetricsFS) ChmodWithContext ¶
ChmodWithContext changes file permissions with context and tracing.
func (*OTelMetricsFS) Chown ¶
func (m *OTelMetricsFS) Chown(name string, uid, gid int) error
Chown changes file ownership.
func (*OTelMetricsFS) ChownWithContext ¶
ChownWithContext changes file ownership with context and tracing.
func (*OTelMetricsFS) ChtimesWithContext ¶
func (m *OTelMetricsFS) ChtimesWithContext(ctx context.Context, name string, atime time.Time, mtime time.Time) error
ChtimesWithContext changes file times with context and tracing.
func (*OTelMetricsFS) Collector ¶
func (m *OTelMetricsFS) Collector() *OTelCollector
Collector returns the OpenTelemetry collector.
func (*OTelMetricsFS) Create ¶
func (m *OTelMetricsFS) Create(name string) (absfs.File, error)
Create creates a new file.
func (*OTelMetricsFS) CreateWithContext ¶
CreateWithContext creates a new file with context and tracing.
func (*OTelMetricsFS) Getwd ¶
func (m *OTelMetricsFS) Getwd() (string, error)
Getwd returns the current working directory.
func (*OTelMetricsFS) GetwdWithContext ¶
func (m *OTelMetricsFS) GetwdWithContext(ctx context.Context) (string, error)
GetwdWithContext returns the current working directory with context and tracing.
func (*OTelMetricsFS) Lstat ¶
func (m *OTelMetricsFS) Lstat(name string) (os.FileInfo, error)
Lstat returns file information without following symlinks.
func (*OTelMetricsFS) LstatWithContext ¶
LstatWithContext returns file information without following symlinks with context and tracing.
func (*OTelMetricsFS) Mkdir ¶
func (m *OTelMetricsFS) Mkdir(name string, perm os.FileMode) error
Mkdir creates a directory.
func (*OTelMetricsFS) MkdirAll ¶
func (m *OTelMetricsFS) MkdirAll(name string, perm os.FileMode) error
MkdirAll creates a directory and all necessary parent directories.
func (*OTelMetricsFS) MkdirAllWithContext ¶
func (m *OTelMetricsFS) MkdirAllWithContext(ctx context.Context, name string, perm os.FileMode) error
MkdirAllWithContext creates a directory and parents with context and tracing.
func (*OTelMetricsFS) MkdirWithContext ¶
MkdirWithContext creates a directory with context and tracing.
func (*OTelMetricsFS) Open ¶
func (m *OTelMetricsFS) Open(name string) (absfs.File, error)
Open opens a file for reading with tracing support.
func (*OTelMetricsFS) OpenFileWithContext ¶
func (m *OTelMetricsFS) OpenFileWithContext(ctx context.Context, name string, flag int, perm os.FileMode) (absfs.File, error)
OpenFileWithContext opens a file with context and tracing.
func (*OTelMetricsFS) OpenWithContext ¶
OpenWithContext opens a file for reading with context and tracing.
func (*OTelMetricsFS) ReadDir ¶
func (m *OTelMetricsFS) ReadDir(name string) ([]fs.DirEntry, error)
ReadDir reads the named directory and returns a list of directory entries.
func (*OTelMetricsFS) ReadDirWithContext ¶
ReadDirWithContext reads the named directory with context and tracing.
func (*OTelMetricsFS) ReadFile ¶
func (m *OTelMetricsFS) ReadFile(name string) ([]byte, error)
ReadFile reads the named file and returns its contents.
func (*OTelMetricsFS) ReadFileWithContext ¶
ReadFileWithContext reads the named file with context and tracing.
func (*OTelMetricsFS) Readlink ¶
func (m *OTelMetricsFS) Readlink(name string) (string, error)
Readlink reads the target of a symbolic link.
func (*OTelMetricsFS) ReadlinkWithContext ¶
ReadlinkWithContext reads the target of a symbolic link with context and tracing.
func (*OTelMetricsFS) Remove ¶
func (m *OTelMetricsFS) Remove(name string) error
Remove removes a file or directory.
func (*OTelMetricsFS) RemoveAll ¶
func (m *OTelMetricsFS) RemoveAll(name string) error
RemoveAll removes a path and all children.
func (*OTelMetricsFS) RemoveAllWithContext ¶
func (m *OTelMetricsFS) RemoveAllWithContext(ctx context.Context, name string) error
RemoveAllWithContext removes a path and all children with context and tracing.
func (*OTelMetricsFS) RemoveWithContext ¶
func (m *OTelMetricsFS) RemoveWithContext(ctx context.Context, name string) error
RemoveWithContext removes a file or directory with context and tracing.
func (*OTelMetricsFS) Rename ¶
func (m *OTelMetricsFS) Rename(oldpath, newpath string) error
Rename renames a file or directory.
func (*OTelMetricsFS) RenameWithContext ¶
func (m *OTelMetricsFS) RenameWithContext(ctx context.Context, oldpath, newpath string) error
RenameWithContext renames a file or directory with context and tracing.
func (*OTelMetricsFS) Stat ¶
func (m *OTelMetricsFS) Stat(name string) (os.FileInfo, error)
Stat returns file information with tracing.
func (*OTelMetricsFS) StatWithContext ¶
StatWithContext returns file information with context and tracing.
func (*OTelMetricsFS) Sub ¶
func (m *OTelMetricsFS) Sub(dir string) (fs.FS, error)
Sub returns a Filer corresponding to the subtree rooted at dir.
func (*OTelMetricsFS) SubWithContext ¶
SubWithContext returns a Filer corresponding to the subtree with context and tracing.
func (*OTelMetricsFS) Symlink ¶
func (m *OTelMetricsFS) Symlink(oldname, newname string) error
Symlink creates a symbolic link.
func (*OTelMetricsFS) SymlinkWithContext ¶
func (m *OTelMetricsFS) SymlinkWithContext(ctx context.Context, oldname, newname string) error
SymlinkWithContext creates a symbolic link with context and tracing.
func (*OTelMetricsFS) TempDir ¶
func (m *OTelMetricsFS) TempDir() string
TempDir returns the path to the temporary directory.
func (*OTelMetricsFS) Truncate ¶
func (m *OTelMetricsFS) Truncate(name string, size int64) error
Truncate truncates the named file to the specified size.
func (*OTelMetricsFS) TruncateWithContext ¶
TruncateWithContext truncates the named file with context and tracing.
type Operation ¶
type Operation struct {
// Name of the operation (e.g., "read", "write", "stat")
Name string
// Duration of the operation
Duration time.Duration
// BytesTransferred is the number of bytes read or written
BytesTransferred int64
// Path is the file path involved in the operation
Path string
// Error that occurred during the operation, if any
Error error
}
Operation represents a completed filesystem operation with metrics.