MCPcopy
hub / github.com/grafana/tempo / shouldCutHead

Method shouldCutHead

modules/livestore/instance.go:503–522  ·  view source on GitHub ↗

shouldCutHead checks whether the head block should be cut and returns the reason(s). Caller must hold blocksMtx.

(immediate bool)

Source from the content-addressed store, hash-verified

501// shouldCutHead checks whether the head block should be cut and returns the
502// reason(s). Caller must hold blocksMtx.
503func (i *instance) shouldCutHead(immediate bool) cutReason {
504 hb := i.blocks.Load().headBlock
505 if hb == nil || hb.DataLength() == 0 {
506 return cutReasonNone
507 }
508
509 var reason cutReason
510
511 if immediate {
512 reason |= cutReasonImmediate
513 }
514 if time.Since(i.lastCutTime) >= i.Cfg.MaxBlockDuration {
515 reason |= cutReasonMaxBlockDuration
516 }
517 if hb.DataLength() >= i.Cfg.MaxBlockBytes {
518 reason |= cutReasonMaxBlockBytes
519 }
520
521 return reason
522}
523
524func recordBlockCutMetric(reason cutReason) {
525 if reason&cutReasonImmediate != 0 {

Callers 1

cutBlocksMethod · 0.95

Calls 1

DataLengthMethod · 0.65

Tested by

no test coverage detected