Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sampling on emitting misconfigured partition metrics #6650

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion service/matching/tasklist/task_list_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"context"
"errors"
"fmt"
"math/rand/v2"
"reflect"
"sort"
"sync"
Expand Down Expand Up @@ -63,6 +64,8 @@ const (
returnEmptyTaskTimeBudget = time.Second
noIsolationTimeout = time.Duration(0)
minimumIsolationDuration = time.Millisecond * 50
// sampling rate for emitting misconfigured partition metrics
misconfiguredPartitionEmitRate = 0.05
)

var (
Expand Down Expand Up @@ -643,7 +646,9 @@ func (c *taskListManagerImpl) GetTask(
}

func (c *taskListManagerImpl) getTask(ctx context.Context, maxDispatchPerSecond *float64) (*InternalTask, error) {
c.emitMisconfiguredPartitionMetrics()
if rand.Float32() < misconfiguredPartitionEmitRate {
c.emitMisconfiguredPartitionMetrics()
}
// We need to set a shorter timeout than the original ctx; otherwise, by the time ctx deadline is
// reached, instead of emptyTask, context timeout error is returned to the frontend by the rpc stack,
// which counts against our SLO. By shortening the timeout by a very small amount, the emptyTask can be
Expand Down