-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rhythm: set ingestion slack for partition consumption (#4611)
* rhythm: set ingestion slack for partition consumption * remove test * Update WalBlock interface to explicitly compute the ingestionSlack * add cycle duration to slack ingestion range calculation * distinguish between ingesters and blockbuilder for dataquality warnings
- Loading branch information
1 parent
649b77f
commit 4ac0715
Showing
26 changed files
with
372 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package blockbuilder | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/go-kit/log" | ||
"github.com/grafana/tempo/pkg/util/test" | ||
"github.com/grafana/tempo/tempodb/backend" | ||
"github.com/grafana/tempo/tempodb/encoding" | ||
"github.com/grafana/tempo/tempodb/wal" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func getPartitionWriter(t *testing.T) *writer { | ||
logger := log.NewNopLogger() | ||
startTime := time.Now() | ||
cycleDuration := 1 * time.Minute | ||
blockCfg := BlockConfig{} | ||
tmpDir := t.TempDir() | ||
w, err := wal.New(&wal.Config{ | ||
Filepath: tmpDir, | ||
Encoding: backend.EncNone, | ||
IngestionSlack: 3 * time.Minute, | ||
Version: encoding.DefaultEncoding().Version(), | ||
}) | ||
require.NoError(t, err) | ||
|
||
return newPartitionSectionWriter(logger, 1, 1, startTime, cycleDuration, blockCfg, &mockOverrides{}, w, encoding.DefaultEncoding()) | ||
} | ||
|
||
func TestPushBytes(t *testing.T) { | ||
pw := getPartitionWriter(t) | ||
|
||
tenant := "test-tenant" | ||
traceID := generateTraceID(t) | ||
now := time.Now() | ||
startTime := uint64(now.UnixNano()) | ||
endTime := uint64(now.Add(time.Second).UnixNano()) | ||
req := test.MakePushBytesRequest(t, 1, traceID, startTime, endTime) | ||
|
||
err := pw.pushBytes(now, tenant, req) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package blockbuilder | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/go-kit/log" | ||
"github.com/grafana/tempo/tempodb/backend" | ||
"github.com/grafana/tempo/tempodb/encoding" | ||
"github.com/grafana/tempo/tempodb/wal" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func getTenantStore(t *testing.T) (*tenantStore, error) { | ||
logger := log.NewNopLogger() | ||
blockCfg := BlockConfig{} | ||
tmpDir := t.TempDir() | ||
w, err := wal.New(&wal.Config{ | ||
Filepath: tmpDir, | ||
Encoding: backend.EncNone, | ||
IngestionSlack: 3 * time.Minute, | ||
Version: encoding.DefaultEncoding().Version(), | ||
}) | ||
require.NoError(t, err) | ||
return newTenantStore("test-tenant", 1, 1, blockCfg, logger, w, encoding.DefaultEncoding(), &mockOverrides{}) | ||
} | ||
|
||
func TestAdjustTimeRangeForSlack(t *testing.T) { | ||
store, err := getTenantStore(t) | ||
require.NoError(t, err) | ||
|
||
startCycleTime := time.Now() | ||
cycleDuration := 1 * time.Minute | ||
|
||
tests := []struct { | ||
name string | ||
start uint32 | ||
end uint32 | ||
expectedStart uint32 | ||
expectedEnd uint32 | ||
}{ | ||
{ | ||
name: "within slack range", | ||
start: uint32(startCycleTime.Add(-2 * time.Minute).Unix()), | ||
end: uint32(startCycleTime.Add(2 * time.Minute).Unix()), | ||
expectedStart: uint32(startCycleTime.Add(-2 * time.Minute).Unix()), | ||
expectedEnd: uint32(startCycleTime.Add(2 * time.Minute).Unix()), | ||
}, | ||
{ | ||
name: "start before slack range", | ||
start: uint32(startCycleTime.Add(-10 * time.Minute).Unix()), | ||
end: uint32(startCycleTime.Add(2 * time.Minute).Unix()), | ||
expectedStart: uint32(startCycleTime.Unix()), | ||
expectedEnd: uint32(startCycleTime.Add(2 * time.Minute).Unix()), | ||
}, | ||
{ | ||
name: "end after slack range", | ||
start: uint32(startCycleTime.Add(-2 * time.Minute).Unix()), | ||
end: uint32(startCycleTime.Add(20 * time.Minute).Unix()), | ||
expectedStart: uint32(startCycleTime.Add(-2 * time.Minute).Unix()), | ||
expectedEnd: uint32(startCycleTime.Unix()), | ||
}, | ||
{ | ||
name: "end before start", | ||
start: uint32(startCycleTime.Add(-2 * time.Minute).Unix()), | ||
end: uint32(startCycleTime.Add(-3 * time.Minute).Unix()), | ||
expectedStart: uint32(startCycleTime.Add(-2 * time.Minute).Unix()), | ||
expectedEnd: uint32(startCycleTime.Unix()), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
start, end := store.adjustTimeRangeForSlack(startCycleTime, cycleDuration, tt.start, tt.end) | ||
assert.Equal(t, tt.expectedStart, start) | ||
assert.Equal(t, tt.expectedEnd, end) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.