MCPcopy
hub / github.com/prometheus/prometheus / NewBlockWriter

Function NewBlockWriter

tsdb/blockwriter.go:52–62  ·  view source on GitHub ↗

NewBlockWriter creates a new block writer. The returned writer accumulates all the series in the Head block until `Flush` is called. Note that the writer will not check if the target directory exists or contains anything at all. It is the caller's responsibility to ensure that the resulting blocks

(logger *slog.Logger, dir string, blockSize int64)

Source from the content-addressed store, hash-verified

50// ensure that the resulting blocks do not overlap etc.
51// Writer ensures the block flush is atomic (via rename).
52func NewBlockWriter(logger *slog.Logger, dir string, blockSize int64) (*BlockWriter, error) {
53 w := &BlockWriter{
54 logger: logger,
55 destinationDir: dir,
56 blockSize: blockSize,
57 }
58 if err := w.initHead(); err != nil {
59 return nil, err
60 }
61 return w, nil
62}
63
64// initHead creates and initialises a new TSDB head.
65func (w *BlockWriter) initHead() error {

Callers 5

createBlocksFunction · 0.92
importRuleMethod · 0.92
TestBlockWriterFunction · 0.85
CreateBlockFunction · 0.85

Calls 1

initHeadMethod · 0.95

Tested by 2

TestBlockWriterFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…