Skip to content

Commit

Permalink
Added hidden native histogram flag for receive tsdb
Browse files Browse the repository at this point in the history
  • Loading branch information
rabenhorst committed Jan 12, 2023
1 parent 6ec0d2d commit 57c9771
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ func registerReceive(app *extkingpin.App) {
EnableExemplarStorage: true,
HeadChunksWriteQueueSize: int(conf.tsdbWriteQueueSize),
EnableMemorySnapshotOnShutdown: conf.tsdbMemorySnapshotOnShutdown,
//TODO (rabenhorst): Do we want to make this configurable?
EnableNativeHistograms: true,
EnableNativeHistograms: conf.tsdbEnableNativeHistograms,
}

// Are we running in IngestorOnly, RouterOnly or RouterIngestor mode?
Expand Down Expand Up @@ -785,6 +784,7 @@ type receiveConfig struct {
tsdbMaxExemplars int64
tsdbWriteQueueSize int64
tsdbMemorySnapshotOnShutdown bool
tsdbEnableNativeHistograms bool

walCompression bool
noLockFile bool
Expand Down Expand Up @@ -897,6 +897,10 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
"[EXPERIMENTAL] Enables feature to snapshot in-memory chunks on shutdown for faster restarts.").
Default("false").Hidden().BoolVar(&rc.tsdbMemorySnapshotOnShutdown)

cmd.Flag("tsdb.enable-native-histograms",
"[EXPERIMENTAL] Enables the ingestion of native histograms.").
Default("false").Hidden().BoolVar(&rc.tsdbEnableNativeHistograms)

cmd.Flag("hash-func", "Specify which hash function to use when calculating the hashes of produced files. If no function has been specified, it does not happen. This permits avoiding downloading some files twice albeit at some performance cost. Possible values are: \"\", \"SHA256\".").
Default("").EnumVar(&rc.hashFunc, "SHA256", "")

Expand Down
10 changes: 10 additions & 0 deletions test/e2e/e2ethanos/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ type ReceiveBuilder struct {
relabelConfigs []*relabel.Config
replication int
image string
nativeHistograms bool
}

func NewReceiveBuilder(e e2e.Environment, name string) *ReceiveBuilder {
Expand Down Expand Up @@ -511,6 +512,11 @@ func (r *ReceiveBuilder) WithValidationEnabled(limit int, metaMonitoring string,
return r
}

func (r *ReceiveBuilder) WithNativeHistograms() *ReceiveBuilder {
r.nativeHistograms = true
return r
}

// Init creates a Thanos Receive instance.
// If ingestion is enabled it will be configured for ingesting samples.
// If routing is configured (i.e. hashring configuration is provided) it routes samples to other receivers.
Expand Down Expand Up @@ -589,6 +595,10 @@ func (r *ReceiveBuilder) Init() *e2emon.InstrumentedRunnable {
args["--receive.relabel-config"] = string(relabelConfigBytes)
}

if r.nativeHistograms {
args["--tsdb.enable-native-histograms"] = ""
}

return e2emon.AsInstrumented(r.f.Init(wrapWithDefaults(e2e.StartOptions{
Image: r.image,
Command: e2e.NewCommand("receive", e2e.BuildArgs(args)...),
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/native_histograms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func TestWriteNativeHistograms(t *testing.T) {
testutil.Ok(t, err)
t.Cleanup(e2ethanos.CleanScenario(t, e))

ingestor0 := e2ethanos.NewReceiveBuilder(e, "ingestor0").WithIngestionEnabled().Init()
ingestor1 := e2ethanos.NewReceiveBuilder(e, "ingestor1").WithIngestionEnabled().Init()
ingestor0 := e2ethanos.NewReceiveBuilder(e, "ingestor0").WithIngestionEnabled().WithNativeHistograms().Init()
ingestor1 := e2ethanos.NewReceiveBuilder(e, "ingestor1").WithIngestionEnabled().WithNativeHistograms().Init()

h := receive.HashringConfig{
Endpoints: []string{
Expand Down

0 comments on commit 57c9771

Please sign in to comment.