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

thriftbp: Add Suppressor to ClientPoolConfig #241

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Changes from all commits
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
20 changes: 15 additions & 5 deletions thriftbp/client_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-kit/kit/metrics"

"github.com/reddit/baseplate.go/clientpool"
"github.com/reddit/baseplate.go/errorsbp"
"github.com/reddit/baseplate.go/log"
"github.com/reddit/baseplate.go/metricsbp"
)
Expand Down Expand Up @@ -75,7 +76,7 @@ type ClientPoolConfig struct {
// a negative value.
MaxConnectionAge time.Duration

// ConnectTimeout and SocketTimeout are timeouts used by the underling
// ConnectTimeout and SocketTimeout are timeouts used by the underlying
// thrift.TSocket.
//
// In most cases, you would want ConnectTimeout to be short, because if you
Expand All @@ -85,12 +86,12 @@ type ClientPoolConfig struct {
// latency SLA. If it's shorter than that you are gonna close connections and
// fail requests prematurely.
//
// For both values, <=0 would mean disable timeout.
// For both values, <=0 would mean no timeout.
// In most cases you would want to set timeouts for both.
ConnectTimeout time.Duration
SocketTimeout time.Duration

// Any labels that should be applied to metrics logged by the ClientPool.
// Any tags that should be applied to metrics logged by the ClientPool.
// This includes the optional pool stats.
MetricsTags metricsbp.Tags

Expand Down Expand Up @@ -124,6 +125,14 @@ type ClientPoolConfig struct {
// When PoolGaugeInterval <= 0 and ReportPoolStats is true,
// DefaultPoolGaugeInterval will be used instead.
PoolGaugeInterval time.Duration

// Suppress some of the errors returned by the server before sending them to
// the client span.
//
// See MonitorClientArgs.ErrorSpanSuppressor for more details.
//
// This is optional. If it's not set none of the errors will be suppressed.
ErrorSpanSuppressor errorsbp.Suppressor
}

// Client is a client object that implements both the clientpool.Client and
Expand Down Expand Up @@ -190,8 +199,9 @@ func SingleAddressGenerator(addr string) AddressGenerator {
func NewBaseplateClientPool(cfg ClientPoolConfig, middlewares ...thrift.ClientMiddleware) (ClientPool, error) {
defaults := BaseplateDefaultClientMiddlewares(
DefaultClientMiddlewareArgs{
ServiceSlug: cfg.ServiceSlug,
RetryOptions: cfg.DefaultRetryOptions,
ServiceSlug: cfg.ServiceSlug,
RetryOptions: cfg.DefaultRetryOptions,
ErrorSpanSuppressor: cfg.ErrorSpanSuppressor,
},
)
middlewares = append(middlewares, defaults...)
Expand Down