add flush

This commit is contained in:
Gorbunov Kirill Andreevich
2024-03-18 16:14:34 +03:00
parent 7c669c636d
commit c6976246cc
3 changed files with 7 additions and 21 deletions

View File

@@ -91,6 +91,7 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.
if md, ok := metadata.FromIncomingContext(ctx); gzipAccepted(md) && ok {
md.Set(contentEncodingHeader, "gzip")
ctx = metadata.NewIncomingContext(ctx, md)
gz := gzipPool.Get().(*gzip.Writer)
defer gzipPool.Put(gz)
@@ -98,6 +99,7 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.
defer gz.Close()
w = gz
gz.Flush()
}
if err := h.opts.Meter.Write(w, h.opts.MeterOptions...); err != nil {