Releases: reddit/baseplate.go
Releases · reddit/baseplate.go
v0.6.1
Non-breaking changes:
- Thrift updates to fix bug and improve connectivity check.
log.ErrorWithSentry
now also report the extra key-value information to sentry.- We also auto report the hostname to sentry now.
- There's now exported
breakerbp.FailureRatioBreaker.Execute
function to be used in non-thrift scenarios. - Added
errorsbp.Batch.AddPrefix
, deprecatebatchcloser.CloseError
.
v0.6.0
Breaking Changes
Improvements
- The (mostly internally used)
log.Wrapper
API now takesctx
arg. This makeslog.Wrapper
implementations no longer cast-able intothrift.Logger
, butToThriftLogger
andlog.WrapToThriftLogger
are added to help convert them intothrift.Logger
. This also happens automatically inthriftbp.NewBaseplateServer
so for most services you don't have to do anything.
Non-breaking Changes
Improvements
- Add
metricsbp.LogWrapper
, which is alog.Wrapper
implementation that also adds a counter when called. It can be used to keep tracking of errors, for example:
ecImpl := edgecontext.Init(edgecontext.Config{
Store: bp.secrets,
Logger: metricsbp.LogWrapper(metricsbp.LogWrapperArgs{
Counter: "edge-context.jwt-failures",
Wrapper: log.ErrorWithSentryWrapper(),
}),
})
v0.5.2
Non-breaking Changes
Bug fixes:
- Fix a bug that
log.ErrorWithSentryWrapper
does not contain stack trace info on Sentry.
Improvements
- Add support for
BaseplateServiceV2
in newbaseplate.thrift
.
v0.5.1
Non-breaking Changes
Bug fixes:
- Fix a potential infinite recursion in unknown experiment error
- Fix a bug that the retry filters could decide to retry on context deadline exceeded errors when you constructed the filters in the wrong order
Improvements:
- You can now add breaker to default thrift client middlewares
- Add a function to publish redisbp connection pool stats
v0.5.0
Breaking changes:
- Some of the metrics were marked as deprecated in previous releases.
They are removed in this version:*.fail
counters coming from span hooks.- Thrift client pool gauges that's not
RuntimeGauge
.
- Starting from this version, Baseplate.go requires service code to use
Thrift compiler minimal version ofbcae3bb
(recommended version
4db7a0a
), until Thrift 0.14.0 is released. Go code compiled from
Thrift compiler 0.13.0 will be incompatible with new Baseplate.go
libraries.- This change brings us the ability to have a short
SocketTimeout
for
Thrift client pools, as long as all the client calls use a context
object with deadline attached. - Thrift compiler
4db7a0a
built for 64-bit Linux and Mac are provided
here for you convenient. If you use homebrew, you can also get it by
runningbrew install --HEAD thrift
.
- This change brings us the ability to have a short
v0.4.2
v0.4.0 + v0.4.1
v0.4.1
Non-breaking changes
metricsbp
- Add Statsd.RuntimeGauge, this is the gauges we used in RunSysStats. Make it a public API so other
code can take advantage of it, too. If you are usingmetricsbp.M.Gauge
, it might make sense to move to usingmetricsbp.M.RuntimeGauge(...)
but note that it will addrutime.
to the prefix and add instance+pid tags. - The Thrift client pool reported gauges are runtime gauges now, the old gauge will be removed in a future version so users should start to update their dashboards/alerts now.
thriftbp
- Add support for suppressing errors on Thrift clients. (#241)
diff --git a/client.go b/client.go
index 53d6183..348ee0f 100644
--- a/client.go
+++ b/client.go
@@ -1,10 +1,12 @@
package auth
import (
+ "errors"
"time"
"github.com/reddit/baseplate.go/errorsbp"
"github.com/reddit/baseplate.go/thriftbp"
+ "github.com/reddit/my-service/thrift/my_service"
)
const (
@@ -107,5 +109,10 @@ func (cfg Config) Compile() thriftbp.ClientPoolConfig {
SocketTimeout: cfg.SocketTimeout,
ReportPoolStats: cfg.PoolStats.Report,
PoolGaugeInterval: cfg.PoolStats.GaugeInterval,
+ ErrorSpanSuppressor: func(err error) bool {
+ var myErr *my_service.MyError
+ return errors.As(err, &myErr)
+ },
}
}
v0.4.0
This is a big release with bug fixes, enhancements, and several breaking changes.
Bug fixes
httpbp
httpbp.InjectEdgeRequestContext
middleware was not base64 decoding the edge context header before parsing it, resulting in parsing failures. This has been fixed and should not require any changes to service code. (#236)
Breaking changes
thriftbp
- The signatures of
NewBaseplateServer
,NewServer
, andBaseplateDefaultProcessorMiddlewares
have changed.NewBaseplateServer
andNewServer
both useServerConfig
as an arg now, and some of the new configuration options are added into ServerConfig struct. Specifically,ErrorSpanSuppressor
has been added to allow you to suppress IDL defined errors from being reported as errors when stopping the server span. (#239)
diff --git a/main.go b/main.go
index dca49ac..37a9b9c 100644
--- a/main.go
+++ b/main.go
@@ -2,6 +2,7 @@ package main
import (
"context"
+ "errors"
"flag"
"github.com/go-redis/redis/v7"
@@ -37,7 +38,13 @@ func main() {
redis.NewClusterClient(cfg.Redis.Options()),
),
})
- server, err := thriftbp.NewBaseplateServer(bp, processor)
+ server, err := thriftbp.NewBaseplateServer(bp, thriftbp.ServerConfig{
+ Processor: processor,
+ ErrorSpanSuppressor: func(err error) bool {
+ var myErr *my_service.MyError
+ return errors.As(err, &myErr)
+ },
+ })
if err != nil {
log.Fatal(err)
}
diff --git a/server/service_test.go b/server/service_test.go
index a4789f0..664503f 100644
--- a/server/service_test.go
+++ b/server/service_test.go
@@ -44,7 +44,10 @@ func TestMain(m *testing.M) {
),
})
- srv, err = thrifttest.NewBaseplateServer(secrets, processor, thrifttest.ServerConfig{})
+ srv, err = thrifttest.NewBaseplateServer(thrifttest.ServerConfig{
+ Processor: processor,
+ SecretStore: secrets,
+ })
if err != nil {
panic(err)
}
- When creating client pool we now have separated
ConnectTimeout
andSocketTimeout
onClientPoolConfig
. (#232)
diff --git a/foo.go b/foo.go
index dc894be..53d6183 100644
--- a/foo.go
+++ b/foo.go
@@ -96,6 +103,7 @@ func (cfg Config) Compile() thriftbp.ClientPoolConfig {
Addr: "9090",
InitialConnections: 1,
MaxConnections: 100,
+ ConnectTimeout: 25*time.Millisecond,
SocketTimeout: 500*time.Millisecond,
ReportPoolStats: true,
httpbp
- When creating the
Endpoint
map for an HTTP server, you are now required to provide the list of allowed HTTP methods for each endpoint. (#227 , #229)
diff --git a/server/service.go b/server/service.go
index bb13e1f..7eb50a7 100644
--- a/server/service.go
+++ b/server/service.go
@@ -54,18 +54,22 @@ func (s MyService) Endpoints() map[httpbp.Pattern]httpbp.Endpoint {
return map[httpbp.Pattern]httpbp.Endpoint{
"/health": {
Name: "is_healthy",
+ Methods: []string{http.MethodGet},
Handle: s.IsHealthy,
},
"/foo": {
Name: "foo",
+ Methods: []string{http.MethodPost},
Handle: s.Foo,
},
"/foo/bar": {
Name: "foo-bar",
+ Methods: []string{http.MethodPost},
Handle: s.FooBar,
},
"/fizz": {
Name: "fizz",
+ Methods: []string{http.MethodGet},
Handle: s.Fizz,
},
}
metricsbp
- Renamed all the terminology of “labels” into “tags”, this includes all of the types and functions to align with the terminology used in baseplate.py as well as the terminology used by Spans. (#224)
diff --git a/foo.go b/foo.go
index 1970b06..88875d3 100644
--- a/foo.go
+++ b/foo.go
@@ -22,13 +22,13 @@ func MonitorTraffic(name string, next httpbp.HandlerFunc) httpbp.HandlerFunc {
- tags := metricsbp.Labels{"foo": foo}
+ tags := metricsbp.Tags{"foo": foo}
if bar := r.Header.Get("bar"); bar != "" {
tags["bar"] = strings.ToLower(bar)
}
- metricsbp.M.Counter("traffic").With(tags.AsStatsdLabels()...).Add(1)
+ metricsbp.M.Counter("traffic").With(tags.AsStatsdTags()...).Add(1)
return next(ctx, w, r)
}
}
- The sys stats (reported via RunSysStats function) no longer takes customizable tags as the arg. The tags associated with those gauges are now fixed to comply with Baseplate spec. The metrics will also be prefixed with “runtime.”, and “runtime.active_requests” is added. (#224 , #238)
- This is not a breaking change in code but you will have to adjust any dashboards/alerts that report these metrics.
batcherror -> errorsbp
- The package
batcherror
no longer exists.batcherror.BatchError
is now renamed intoerrorsbp.Batch
. (#239)
diff --git a/foo.go b/foo.go
index c2705a4..dc894be 100644
--- a/foo.go
+++ b/foo.go
@@ -3,7 +3,7 @@ package foo
import (
- "github.com/reddit/baseplate.go/batcherror"
+ "github.com/reddit/baseplate.go/errorsbp"
)
@@ -46,9 +46,9 @@ func DefaultConfig() Config {
func (cfg Config) Validate() error {
- var err batcherror.BatchError
+ var err errorsbp.Batch
if cfg.Addr == "" {
err.Add(ErrorInvalidConfigValue{
Name: "Addr",
Non-breaking changes
errorsbp
- Added a new type,
errorsbp.Suppressor
, in order to support some of the changes mentioned inthriftbp
package. (#239)
metricsbp
- For the counters that come automatically with Spans, the “fail” counter is called “failure” now to comply with Baseplate spec. (#224)
- Currently we report both for an easier transition, but the “fail” counter will be removed in a future version.