MCPcopy Index your code
hub / github.com/cortexproject/cortex / newCompactor

Function newCompactor

pkg/compactor/compactor.go:514–630  ·  view source on GitHub ↗
(
	compactorCfg Config,
	storageCfg cortex_tsdb.BlocksStorageConfig,
	logger log.Logger,
	registerer prometheus.Registerer,
	bucketClientFactory func(ctx context.Context) (objstore.InstrumentedBucket, error),
	blocksGrouperFactory BlocksGrouperFactory,
	blocksCompactorFactory BlocksCompactorFactory,
	blockDeletableCheckerFactory BlockDeletableCheckerFactory,
	compactionLifecycleCallbackFactory CompactionLifecycleCallbackFactory,
	limits *validation.Overrides,
	ingestionReplicationFactor int,
)

Source from the content-addressed store, hash-verified

512}
513
514func newCompactor(
515 compactorCfg Config,
516 storageCfg cortex_tsdb.BlocksStorageConfig,
517 logger log.Logger,
518 registerer prometheus.Registerer,
519 bucketClientFactory func(ctx context.Context) (objstore.InstrumentedBucket, error),
520 blocksGrouperFactory BlocksGrouperFactory,
521 blocksCompactorFactory BlocksCompactorFactory,
522 blockDeletableCheckerFactory BlockDeletableCheckerFactory,
523 compactionLifecycleCallbackFactory CompactionLifecycleCallbackFactory,
524 limits *validation.Overrides,
525 ingestionReplicationFactor int,
526) (*Compactor, error) {
527 var compactorMetrics *compactorMetrics
528 if compactorCfg.ShardingStrategy == util.ShardingStrategyShuffle {
529 compactorMetrics = newCompactorMetrics(registerer)
530 } else {
531 compactorMetrics = newDefaultCompactorMetrics(registerer)
532 }
533 c := &Compactor{
534 compactorCfg: compactorCfg,
535 storageCfg: storageCfg,
536 parentLogger: logger,
537 logger: log.With(logger, "component", "compactor"),
538 registerer: registerer,
539 bucketClientFactory: bucketClientFactory,
540 blocksGrouperFactory: blocksGrouperFactory,
541 blocksCompactorFactory: blocksCompactorFactory,
542 blockDeletableCheckerFactory: blockDeletableCheckerFactory,
543 compactionLifecycleCallbackFactory: compactionLifecycleCallbackFactory,
544 allowedTenants: users.NewAllowedTenants(compactorCfg.EnabledTenants, compactorCfg.DisabledTenants),
545
546 CompactorStartDurationSeconds: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{
547 Name: "cortex_compactor_start_duration_seconds",
548 Help: "Time in seconds spent by compactor running start function",
549 }),
550 CompactionRunsStarted: promauto.With(registerer).NewCounter(prometheus.CounterOpts{
551 Name: "cortex_compactor_runs_started_total",
552 Help: "Total number of compaction runs started.",
553 }),
554 CompactionRunsInterrupted: promauto.With(registerer).NewCounter(prometheus.CounterOpts{
555 Name: "cortex_compactor_runs_interrupted_total",
556 Help: "Total number of compaction runs interrupted.",
557 }),
558 CompactionRunsCompleted: promauto.With(registerer).NewCounter(prometheus.CounterOpts{
559 Name: "cortex_compactor_runs_completed_total",
560 Help: "Total number of compaction runs successfully completed.",
561 }),
562 CompactionRunsFailed: promauto.With(registerer).NewCounter(prometheus.CounterOpts{
563 Name: "cortex_compactor_runs_failed_total",
564 Help: "Total number of compaction runs failed.",
565 }),
566 CompactionRunsLastSuccess: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{
567 Name: "cortex_compactor_last_successful_run_timestamp_seconds",
568 Help: "Unix timestamp of the last successful compaction run.",
569 }),
570 CompactionRunDiscoveredTenants: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{
571 Name: "cortex_compactor_tenants_discovered",

Callers 3

NewCompactorFunction · 0.85
prepareForPartitioningFunction · 0.85
prepareFunction · 0.85

Calls 7

NewAllowedTenantsFunction · 0.92
NewBasicServiceFunction · 0.92
newCompactorMetricsFunction · 0.85
JoinMethod · 0.80
SetMethod · 0.65
LogMethod · 0.45

Tested by 2

prepareForPartitioningFunction · 0.68
prepareFunction · 0.68