flush_v3 #188
@ -44,6 +44,7 @@ type Options struct {
|
|||||||
Meter meter.Meter
|
Meter meter.Meter
|
||||||
Name string
|
Name string
|
||||||
MeterOptions []meter.Option
|
MeterOptions []meter.Option
|
||||||
|
DisableCompress bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func Meter(m meter.Meter) Option {
|
func Meter(m meter.Meter) Option {
|
||||||
@ -58,6 +59,12 @@ func Name(name string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DisableCompress(g bool) Option {
|
||||||
|
return func(o *Options) {
|
||||||
|
o.DisableCompress = g
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func MeterOptions(opts ...meter.Option) Option {
|
func MeterOptions(opts ...meter.Option) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.MeterOptions = append(o.MeterOptions, opts...)
|
o.MeterOptions = append(o.MeterOptions, opts...)
|
||||||
@ -65,7 +72,7 @@ func MeterOptions(opts ...meter.Option) Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{Meter: meter.DefaultMeter}
|
options := Options{Meter: meter.DefaultMeter, DisableCompress: false}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
}
|
}
|
||||||
@ -89,8 +96,9 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.
|
|||||||
|
|
||||||
w := io.Writer(buf)
|
w := io.Writer(buf)
|
||||||
|
|
||||||
if md, ok := metadata.FromOutgoingContext(ctx); gzipAccepted(md) && ok {
|
if md, ok := metadata.FromOutgoingContext(ctx); gzipAccepted(md) && ok && !h.opts.DisableCompress {
|
||||||
md.Set(contentEncodingHeader, "gzip"))
|
omd, _ := metadata.FromOutgoingContext(ctx)
|
||||||
|
omd.Set(contentEncodingHeader, "gzip")
|
||||||
gz := gzipPool.Get().(*gzip.Writer)
|
gz := gzipPool.Get().(*gzip.Writer)
|
||||||
defer gzipPool.Put(gz)
|
defer gzipPool.Put(gz)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user