func (l *WAL) Statistics(tags map[string]string) []models.Statistic {
	return []models.Statistic{{
		Name: "tsm1_wal",
		Tags: tags,
		Values: map[string]interface{}{
			statWALOldBytes:     atomic.LoadInt64(&l.stats.OldBytes),
			statWALCurrentBytes: atomic.LoadInt64(&l.stats.CurrentBytes),
			statWriteOk:         atomic.LoadInt64(&l.stats.WriteOK),
			statWriteErr:        atomic.LoadInt64(&l.stats.WriteErr),
		},
	}}
}
Statistics returns statistics for periodic monitoring.
package tsm1
import (
	"bufio"
	"bytes"
	"encoding/binary"
	"fmt"
	"io"
	"math"
	"os"
	"path/filepath"
	"runtime"
	"sort"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"
	"github.com/golang/snappy"
	"github.com/influxdata/influxdb/models"
	"github.com/influxdata/influxdb/pkg/limiter"
	"github.com/influxdata/influxdb/pkg/pool"
	"go.uber.org/zap"
)
const (
	DefaultSegmentSize = 10 * 1024 * 1024
	WALFileExtension = "wal"
	WALFilePrefix = "_"
	walEncodeBufSize = 4 * 1024 * 1024
	float64EntryType  = 1
	integerEntryType  = 2
	booleanEntryType  = 3
	stringEntryType   = 4
	unsignedEntryType = 5
)
type WalEntryType byte
const (
	WriteWALEntryType WalEntryType = 0x01
	DeleteWALEntryType WalEntryType = 0x02
	DeleteRangeWALEntryType WalEntryType = 0x03
)
var (
	ErrWALClosed = fmt.Errorf("WAL closed")
	ErrWALCorrupt = fmt.Errorf("corrupted WAL entry")
	defaultWaitingWALWrites = runtime.GOMAXPROCS(0) * 2
	bytesPool = pool.NewLimitedBytes(256, walEncodeBufSize*2)
)
const (
	statWALOldBytes     = "oldSegmentsDiskBytes"
	statWALCurrentBytes = "currentSegmentDiskBytes"
	statWriteOk         = "writeOk"
	statWriteErr        = "writeErr"
)
type WAL struct {
	syncCount   uint64
	syncWaiters chan chan error
	mu            sync.RWMutex
	lastWriteTime time.Time
	path string
	currentSegmentID     int
	currentSegmentWriter *WALSegmentWriter
	once    sync.Once
	closing chan struct{}
	syncDelay time.Duration
	logger       *zap.Logger  
	traceLogger  *zap.Logger  
	traceLogging bool
	SegmentSize int
	stats   *WALStatistics
	limiter limiter.Fixed
}
func NewWAL(path string) *WAL {
	logger := zap.NewNop()
	return &WAL{
		path: path,
		SegmentSize: DefaultSegmentSize,
		closing:     make(chan struct{}),
		syncWaiters: make(chan chan error, 1024),
		stats:       &WALStatistics{},
		limiter:     limiter.NewFixed(defaultWaitingWALWrites),
		logger:      logger,
		traceLogger: logger,
	}
}
func (l *WAL) enableTraceLogging(enabled bool) {
	l.traceLogging = enabled
	if enabled {
		l.traceLogger = l.logger
	}
}
func (l *WAL) WithLogger(log *zap.Logger) {
	l.logger = log.With(zap.String("service", "wal"))
	if l.traceLogging {
		l.traceLogger = l.logger
	}
}
type WALStatistics struct {
	OldBytes     int64
	CurrentBytes int64
	WriteOK      int64
	WriteErr     int64
}