metricsfs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 15 Imported by: 1

README

metricsfs

Go Reference Go Report Card CI License

Filesystem operation metrics for Prometheus and OpenTelemetry

Overview

metricsfs is an AbsFS wrapper that provides comprehensive observability and monitoring for filesystem operations. It collects detailed metrics about filesystem usage, performance, and errors, exposing them through industry-standard observability platforms like Prometheus and OpenTelemetry.

By wrapping any absfs.FileSystem implementation, metricsfs automatically instruments all filesystem operations, enabling:

  • Performance monitoring: Track latencies, throughput, and bottlenecks
  • Usage analytics: Understand I/O patterns and resource utilization
  • Error tracking: Identify and diagnose filesystem errors
  • Capacity planning: Monitor bandwidth and operation rates
  • SLA compliance: Measure and alert on performance targets

Metrics to Collect

Operation Metrics
  • Operation Counts (Counter)

    • fs_operations_total{operation, status} - Total filesystem operations by type and status
    • fs_file_opens_total{mode} - File opens by mode (read/write/append)
    • fs_file_creates_total - File creation count
    • fs_dir_operations_total{operation} - Directory operations (mkdir, readdir, remove)
  • Operation Latencies (Histogram)

    • fs_operation_duration_seconds{operation} - Operation duration distribution
    • fs_read_duration_seconds - Read operation latency
    • fs_write_duration_seconds - Write operation latency
    • fs_stat_duration_seconds - Stat operation latency
    • fs_open_duration_seconds - Open operation latency
Data Transfer Metrics
  • Bandwidth (Counter + Histogram)

    • fs_bytes_read_total - Total bytes read
    • fs_bytes_written_total - Total bytes written
    • fs_read_size_bytes{operation} - Distribution of read sizes
    • fs_write_size_bytes{operation} - Distribution of write sizes
  • Throughput (Gauge)

    • fs_read_throughput_bytes_per_second - Current read throughput
    • fs_write_throughput_bytes_per_second - Current write throughput
Error Metrics
  • Error Counts (Counter)
    • fs_errors_total{operation, error_type} - Errors by operation and type
    • fs_permission_errors_total{operation} - Permission denied errors
    • fs_not_found_errors_total{operation} - File/directory not found errors
    • fs_timeout_errors_total{operation} - Timeout errors
File Descriptor Metrics
  • File Handle Usage (Gauge)
    • fs_open_files - Currently open files
    • fs_open_files_max - Maximum concurrent open files observed
Path-Level Metrics (Optional, with cardinality limits)
  • Hot Paths (Counter)
    • fs_path_access_total{path, operation} - Access counts for specific paths (top N only)

Architecture

Wrapper Pattern
Application
    |
    v
MetricsFS (instrumentation layer)
    |
    v
Underlying FileSystem (any absfs.FileSystem)
Components
  1. MetricsFS: Main wrapper implementing absfs.FileSystem
  2. MetricsFile: Instrumented file handle implementing absfs.File
  3. Collector: Metrics collection and aggregation
  4. Exporter: Prometheus/OpenTelemetry integration
  5. Config: Configurable metrics collection options

Implementation Phases

Phase 1: Core Infrastructure
  • Basic wrapper structure implementing absfs.FileSystem
  • Operation counting for all filesystem operations
  • Error tracking and categorization
  • In-memory metrics storage
  • Basic Prometheus exporter
Phase 2: Performance Metrics
  • Operation latency histograms
  • Bandwidth counters
  • File descriptor tracking
  • Throughput gauges
  • Configurable histogram buckets
Phase 3: Advanced Features
  • OpenTelemetry integration
  • Trace correlation (span context)
  • Path-based metrics with cardinality protection
  • Custom metric labels
  • Sampling and aggregation strategies
Phase 4: Optimization and Tooling
  • Low-overhead metric collection
  • Lock-free counters where possible
  • Metrics dashboard templates (Grafana)
  • Alerting rule examples
  • Performance overhead benchmarks
  • Production best practices documentation

API Design

Basic Usage
package main

import (
    "github.com/absfs/absfs"
    "github.com/absfs/metricsfs"
    "github.com/absfs/osfs"
    "github.com/prometheus/client_golang/prometheus"
    "github.com/prometheus/client_golang/prometheus/promhttp"
    "net/http"
)

func main() {
    // Create base filesystem
    base := osfs.NewFS()

    // Wrap with metrics
    fs := metricsfs.New(base)

    // Register with Prometheus
    prometheus.MustRegister(fs.Collector())

    // Expose metrics endpoint
    http.Handle("/metrics", promhttp.Handler())
    go http.ListenAndServe(":9090", nil)

    // Use filesystem normally - metrics collected automatically
    f, _ := fs.OpenFile("/data/file.txt", os.O_RDWR, 0644)
    defer f.Close()

    data := make([]byte, 1024)
    f.Read(data)  // Automatically tracked
}
Configuration Options
// Create metrics filesystem with custom configuration
fs := metricsfs.New(base, metricsfs.Config{
    // Namespace for Prometheus metrics
    Namespace: "myapp",

    // Subsystem name
    Subsystem: "storage",

    // Enable/disable specific metric groups
    EnableLatencyMetrics: true,
    EnableBandwidthMetrics: true,
    EnablePathMetrics: false,  // High cardinality - disabled by default

    // Histogram buckets for latency (seconds)
    LatencyBuckets: []float64{0.001, 0.01, 0.1, 1.0, 10.0},

    // Histogram buckets for data size (bytes)
    SizeBuckets: prometheus.ExponentialBuckets(1024, 2, 10),

    // Maximum unique paths to track (cardinality limit)
    MaxTrackedPaths: 100,

    // Sample rate for path metrics (0.0 to 1.0)
    PathSampleRate: 0.01,
})
OpenTelemetry Integration
import (
    "github.com/absfs/metricsfs"
    "go.opentelemetry.io/otel"
    "go.opentelemetry.io/otel/metric"
)

func main() {
    // Get OpenTelemetry meter provider
    provider := otel.GetMeterProvider()

    // Create metrics filesystem with OpenTelemetry
    fs := metricsfs.NewWithOTel(base, metricsfs.OTelConfig{
        MeterProvider: provider,
        MeterName: "github.com/myapp/storage",

        // Enable trace correlation
        EnableTracing: true,
    })

    // Metrics automatically exported through OTLP
    // Operations correlated with distributed traces
}
Custom Labels
// Add custom labels to all metrics
fs := metricsfs.New(base, metricsfs.Config{
    ConstLabels: prometheus.Labels{
        "environment": "production",
        "datacenter": "us-west-2",
        "service": "storage-api",
    },
})
Metric Callbacks
// Hook into metrics collection for custom logic
fs := metricsfs.New(base, metricsfs.Config{
    OnOperation: func(op metricsfs.Operation) {
        if op.Duration > time.Second {
            log.Printf("Slow operation: %s took %v", op.Name, op.Duration)
        }
    },
    OnError: func(op string, err error) {
        errorTracker.Record(op, err)
    },
})

Usage Examples

Example 1: HTTP File Server Monitoring
func NewMonitoredFileServer(dir string) http.Handler {
    base := osfs.NewFS()
    fs := metricsfs.New(base, metricsfs.Config{
        Namespace: "fileserver",
        EnableLatencyMetrics: true,
        EnableBandwidthMetrics: true,
    })

    // Register metrics
    prometheus.MustRegister(fs.Collector())

    // Create file server using instrumented filesystem
    return http.FileServer(absfs.HTTPFileSystem(fs, dir))
}
Example 2: S3 Backend Monitoring
// Monitor S3 filesystem performance
s3base := s3fs.New(s3Config)
s3monitored := metricsfs.New(s3base, metricsfs.Config{
    Namespace: "app",
    Subsystem: "s3",
    ConstLabels: prometheus.Labels{
        "bucket": bucketName,
    },
})

// Track S3 operation latencies and bandwidth
Example 3: Cache Hit Rate Tracking
// Layer metrics on cache filesystem
cache := cachefs.New(backend, cacheDir)
monitored := metricsfs.New(cache, metricsfs.Config{
    Namespace: "cache",
    EnablePathMetrics: true,
    MaxTrackedPaths: 1000,
})

// Query cache hit rates from metrics:
// rate(fs_operations_total{operation="read",status="success"}[5m])
Example 4: Multi-Tenant Monitoring
// Create separate metrics per tenant
func NewTenantFS(tenantID string, base absfs.FileSystem) absfs.FileSystem {
    return metricsfs.New(base, metricsfs.Config{
        Namespace: "app",
        Subsystem: "tenant",
        ConstLabels: prometheus.Labels{
            "tenant_id": tenantID,
        },
    })
}

Dashboard Examples

Grafana Dashboard - Filesystem Overview
Panel 1: Operation Rate
Query: rate(fs_operations_total[5m])
Visualization: Graph (by operation type)

Panel 2: Error Rate
Query: rate(fs_errors_total[5m])
Visualization: Graph (by error type)

Panel 3: P95 Latency
Query: histogram_quantile(0.95, rate(fs_operation_duration_seconds_bucket[5m]))
Visualization: Graph (by operation)

Panel 4: Throughput
Query: rate(fs_bytes_read_total[5m]) + rate(fs_bytes_written_total[5m])
Visualization: Graph (stacked by read/write)

Panel 5: Open Files
Query: fs_open_files
Visualization: Gauge (current vs max)

Panel 6: Success Rate
Query: sum(rate(fs_operations_total{status="success"}[5m])) / sum(rate(fs_operations_total[5m]))
Visualization: Stat (percentage)
Sample Queries
# Slow operations (>100ms) rate
sum(rate(fs_operation_duration_seconds_bucket{le="0.1"}[5m]))
  / sum(rate(fs_operation_duration_seconds_count[5m]))

# Error rate by operation
sum by (operation) (rate(fs_errors_total[5m]))

# Read/Write ratio
sum(rate(fs_bytes_read_total[5m])) / sum(rate(fs_bytes_written_total[5m]))

# Average operation size
rate(fs_bytes_written_total[5m]) / rate(fs_operations_total{operation="write"}[5m])

# File descriptor leak detection
deriv(fs_open_files[10m]) > 0
Alerting Rules
groups:
  - name: filesystem_alerts
    rules:
      - alert: HighFilesystemErrorRate
        expr: rate(fs_errors_total[5m]) > 0.01
        for: 5m
        annotations:
          summary: "High filesystem error rate detected"

      - alert: FilesystemHighLatency
        expr: histogram_quantile(0.95, rate(fs_operation_duration_seconds_bucket[5m])) > 1.0
        for: 5m
        annotations:
          summary: "Filesystem operations are slow"

      - alert: OpenFileDescriptorLeak
        expr: deriv(fs_open_files[10m]) > 0.1
        for: 10m
        annotations:
          summary: "Possible file descriptor leak"

Performance Overhead Analysis

Overhead Targets
  • Metric collection: <5% CPU overhead
  • Memory: <10MB for typical workload (1M ops/hour)
  • Latency: <100us per operation instrumentation
Optimization Strategies
  1. Lock-Free Counters

    • Use atomic operations for increment-only metrics
    • Minimize contention on hot paths
  2. Lazy Aggregation

    • Collect raw events in lock-free buffers
    • Aggregate periodically in background
  3. Sampling

    • Sample path-level metrics to limit cardinality
    • Configurable sample rates per metric type
  4. Histogram Pre-allocation

    • Pre-allocate histogram buckets
    • Reuse duration measurement buffers
  5. Optional Metrics

    • Allow disabling expensive metric groups
    • Fine-grained control over what's collected
Benchmarking
// Benchmark overhead of metrics collection
func BenchmarkMetricsOverhead(b *testing.B) {
    base := memfs.New()
    instrumented := metricsfs.New(base)

    b.Run("baseline", func(b *testing.B) {
        for i := 0; i < b.N; i++ {
            base.Stat("/test")
        }
    })

    b.Run("instrumented", func(b *testing.B) {
        for i := 0; i < b.N; i++ {
            instrumented.Stat("/test")
        }
    })
}

Expected results:

BenchmarkMetricsOverhead/baseline-8          10000000    120 ns/op
BenchmarkMetricsOverhead/instrumented-8       9500000    126 ns/op
Overhead: ~5%

Integration Testing

func TestMetricsCollection(t *testing.T) {
    base := memfs.New()
    fs := metricsfs.New(base)

    // Perform operations
    f, _ := fs.Create("/test.txt")
    f.Write([]byte("hello"))
    f.Close()

    // Verify metrics collected
    metrics := fs.Collector().Collect()

    assert.Contains(t, metrics, "fs_operations_total")
    assert.Equal(t, 1, metrics["fs_file_creates_total"])
    assert.Greater(t, metrics["fs_bytes_written_total"], 0)
}

Production Best Practices

  1. Cardinality Management

    • Disable path-level metrics in high-traffic environments
    • Use sampling for high-cardinality dimensions
    • Set aggressive limits on unique label values
  2. Resource Limits

    • Configure histogram bucket counts appropriately
    • Monitor memory usage of metrics collector
    • Set max tracked paths based on available memory
  3. Performance Monitoring

    • Benchmark metrics overhead in your environment
    • Monitor the monitoring (meta-metrics on collection time)
    • Use profiling to identify hot paths
  4. Alerting

    • Alert on error rates, not absolute error counts
    • Set SLO-based alerts (P95 latency, success rate)
    • Include runbooks in alert annotations
  5. Dashboard Design

    • Start with high-level overview dashboard
    • Drill-down dashboards for specific subsystems
    • Use consistent time ranges and aggregations
  • absfs - Core filesystem abstraction
  • cachefs - Filesystem caching layer
  • lockfs - Filesystem locking and synchronization
  • retryfs - Automatic retry for transient failures

License

MIT License - see LICENSE file for details

Documentation

Index

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

func NewCollector(config Config) *Collector

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) Chdir

func (m *MetricsFS) Chdir(dir string) error

Chdir changes the current working directory.

func (*MetricsFS) Chmod

func (m *MetricsFS) Chmod(name string, mode os.FileMode) error

Chmod changes file permissions.

func (*MetricsFS) Chown

func (m *MetricsFS) Chown(name string, uid, gid int) error

Chown changes file ownership.

func (*MetricsFS) Chtimes

func (m *MetricsFS) Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes changes file access and modification times.

func (*MetricsFS) Collector

func (m *MetricsFS) Collector() *Collector

Collector returns the Prometheus collector for this filesystem. Register this with prometheus.MustRegister() to expose metrics.

func (*MetricsFS) Create

func (m *MetricsFS) Create(name string) (absfs.File, error)

Create creates a new file.

func (*MetricsFS) Getwd

func (m *MetricsFS) Getwd() (string, error)

Getwd returns the current working directory.

func (*MetricsFS) Lstat

func (m *MetricsFS) Lstat(name string) (os.FileInfo, error)

Lstat returns file information without following symlinks. This method is only available if the underlying filesystem implements SymlinkFileSystem.

func (*MetricsFS) Mkdir

func (m *MetricsFS) Mkdir(name string, perm os.FileMode) error

Mkdir creates a directory.

func (*MetricsFS) MkdirAll

func (m *MetricsFS) MkdirAll(name string, perm os.FileMode) error

MkdirAll creates a directory and all necessary parent directories.

func (*MetricsFS) Open

func (m *MetricsFS) Open(name string) (absfs.File, error)

Open opens a file for reading.

func (*MetricsFS) OpenFile

func (m *MetricsFS) OpenFile(name string, flag int, perm os.FileMode) (absfs.File, error)

OpenFile opens a file with the specified flags and mode.

func (*MetricsFS) ReadDir

func (m *MetricsFS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the named directory and returns a list of directory entries.

func (*MetricsFS) ReadFile

func (m *MetricsFS) ReadFile(name string) ([]byte, error)

ReadFile reads the named file and returns its contents.

func (m *MetricsFS) Readlink(name string) (string, error)

Readlink reads the target of a symbolic link. This method is only available if the underlying filesystem implements SymlinkFileSystem.

func (*MetricsFS) Remove

func (m *MetricsFS) Remove(name string) error

Remove removes a file or directory.

func (*MetricsFS) RemoveAll

func (m *MetricsFS) RemoveAll(name string) error

RemoveAll removes a path and all children.

func (*MetricsFS) Rename

func (m *MetricsFS) Rename(oldpath, newpath string) error

Rename renames a file or directory.

func (*MetricsFS) Stat

func (m *MetricsFS) Stat(name string) (os.FileInfo, error)

Stat returns file information.

func (*MetricsFS) Sub

func (m *MetricsFS) Sub(dir string) (fs.FS, error)

Sub returns a Filer corresponding to the subtree rooted at dir.

func (m *MetricsFS) Symlink(oldname, newname string) error

Symlink creates a symbolic link. This method is only available if the underlying filesystem implements SymlinkFileSystem.

func (*MetricsFS) TempDir

func (m *MetricsFS) TempDir() string

TempDir returns the path to the temporary directory.

func (*MetricsFS) Truncate

func (m *MetricsFS) Truncate(name string, size int64) error

Truncate truncates the named file to the specified size.

type MetricsFile

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

MetricsFile wraps an absfs.File and collects metrics on file operations.

func (*MetricsFile) Close

func (f *MetricsFile) Close() error

Close closes the file.

func (*MetricsFile) Name

func (f *MetricsFile) Name() string

Name returns the name of the file.

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

func (m *OTelMetricsFS) ChmodWithContext(ctx context.Context, name string, mode os.FileMode) error

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

func (m *OTelMetricsFS) ChownWithContext(ctx context.Context, name string, uid, gid int) error

ChownWithContext changes file ownership with context and tracing.

func (*OTelMetricsFS) Chtimes

func (m *OTelMetricsFS) Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes changes file access and modification times.

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

func (m *OTelMetricsFS) CreateWithContext(ctx context.Context, name string) (absfs.File, error)

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

func (m *OTelMetricsFS) LstatWithContext(ctx context.Context, name string) (os.FileInfo, error)

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

func (m *OTelMetricsFS) MkdirWithContext(ctx context.Context, name string, perm os.FileMode) error

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) OpenFile

func (m *OTelMetricsFS) OpenFile(name string, flag int, perm os.FileMode) (absfs.File, error)

OpenFile opens a file with the specified flags and mode.

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

func (m *OTelMetricsFS) OpenWithContext(ctx context.Context, name string) (absfs.File, error)

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

func (m *OTelMetricsFS) ReadDirWithContext(ctx context.Context, name string) ([]fs.DirEntry, error)

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

func (m *OTelMetricsFS) ReadFileWithContext(ctx context.Context, name string) ([]byte, error)

ReadFileWithContext reads the named file with context and tracing.

func (m *OTelMetricsFS) Readlink(name string) (string, error)

Readlink reads the target of a symbolic link.

func (*OTelMetricsFS) ReadlinkWithContext

func (m *OTelMetricsFS) ReadlinkWithContext(ctx context.Context, name string) (string, error)

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

func (m *OTelMetricsFS) StatWithContext(ctx context.Context, name string) (os.FileInfo, error)

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

func (m *OTelMetricsFS) SubWithContext(ctx context.Context, dir string) (fs.FS, error)

SubWithContext returns a Filer corresponding to the subtree with context and tracing.

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

func (m *OTelMetricsFS) TruncateWithContext(ctx context.Context, name string, size int64) error

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.

Jump to

Keyboard shortcuts

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