Skip to content

Commit 27d84c1

Browse files
committed
Add expvars integration for stream packet size metrics in czar protocol
1 parent e40b03e commit 27d84c1

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

protocol/czar/engine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/libraries/daze"
13+
"github.com/libraries/daze/lib/expvpp"
1314
"github.com/libraries/daze/lib/rate"
1415
"github.com/libraries/daze/protocol/ashe"
1516
)
@@ -55,6 +56,13 @@ var Conf = struct {
5556
StreamPool: 256,
5657
}
5758

59+
// Expv is a simple wrapper around the expvars package.
60+
var Expv = struct {
61+
StreamWriteSize *expvpp.Average
62+
}{
63+
StreamWriteSize: expvpp.NewAverage("Protocol.Czar.Stream.WriteSize", 64),
64+
}
65+
5866
// Server implemented the czar protocol.
5967
type Server struct {
6068
Cipher []byte

protocol/czar/mux.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func (s *Stream) Read(p []byte) (int, error) {
9090

9191
// Write implements io.Writer.
9292
func (s *Stream) Write(p []byte) (int, error) {
93+
Expv.StreamWriteSize.Append(float64(len(p)))
9394
var (
9495
buf []byte
9596
l = 0
@@ -248,10 +249,6 @@ func (m *Mux) Recv() {
248249
m.ach <- stm
249250
case 0x01:
250251
bsz = binary.BigEndian.Uint16(buf[2:4])
251-
if int(bsz) > Conf.PacketSize-4 {
252-
m.con.Close()
253-
break
254-
}
255252
msg = make([]byte, bsz)
256253
_, err = io.ReadFull(m.con, msg)
257254
if err != nil {

0 commit comments

Comments
 (0)