change set md
This commit is contained in:
parent
364077e72d
commit
4ec60dbb5b
@ -44,6 +44,7 @@ type Options struct {
|
||||
Meter meter.Meter
|
||||
Name string
|
||||
MeterOptions []meter.Option
|
||||
DisableCompress bool
|
||||
}
|
||||
|
||||
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 {
|
||||
return func(o *Options) {
|
||||
o.MeterOptions = append(o.MeterOptions, opts...)
|
||||
@ -65,7 +72,7 @@ func MeterOptions(opts ...meter.Option) Option {
|
||||
}
|
||||
|
||||
func NewOptions(opts ...Option) Options {
|
||||
options := Options{Meter: meter.DefaultMeter}
|
||||
options := Options{Meter: meter.DefaultMeter, DisableCompress: false}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
@ -89,8 +96,9 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.
|
||||
|
||||
w := io.Writer(buf)
|
||||
|
||||
if md, ok := metadata.FromOutgoingContext(ctx); gzipAccepted(md) && ok {
|
||||
md.Set(contentEncodingHeader, "gzip"))
|
||||
if md, ok := metadata.FromOutgoingContext(ctx); gzipAccepted(md) && ok && !h.opts.DisableCompress {
|
||||
omd, _ := metadata.FromOutgoingContext(ctx)
|
||||
omd.Set(contentEncodingHeader, "gzip")
|
||||
gz := gzipPool.Get().(*gzip.Writer)
|
||||
defer gzipPool.Put(gz)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user