mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
fix: regression in internode bytes counting (#18880)
wire up missing metrics since #18461 Bonus: fix trace output inconsistency
This commit is contained in:
parent
1a91edecae
commit
c51f9ef940
@ -757,6 +757,10 @@ func (c *Connection) receive(conn net.Conn, r receiver) error {
|
||||
if op != ws.OpBinary {
|
||||
return fmt.Errorf("unexpected connect response type %v", op)
|
||||
}
|
||||
if c.incomingBytes != nil {
|
||||
c.incomingBytes(int64(len(b)))
|
||||
}
|
||||
|
||||
var m message
|
||||
_, _, err = m.parse(b)
|
||||
if err != nil {
|
||||
@ -938,9 +942,6 @@ func (c *Connection) handleMessages(ctx context.Context, conn net.Conn) {
|
||||
logger.LogIfNot(ctx, fmt.Errorf("ws read: %w", err), net.ErrClosed, io.EOF)
|
||||
return
|
||||
}
|
||||
if c.incomingBytes != nil {
|
||||
c.incomingBytes(int64(len(msg)))
|
||||
}
|
||||
// Parse the received message
|
||||
var m message
|
||||
subID, remain, err := m.parse(msg)
|
||||
|
@ -105,16 +105,18 @@ func NewManager(ctx context.Context, o ManagerOptions) (*Manager, error) {
|
||||
continue
|
||||
}
|
||||
m.targets[host] = newConnection(connectionParams{
|
||||
ctx: ctx,
|
||||
id: m.ID,
|
||||
local: o.Local,
|
||||
remote: host,
|
||||
dial: o.Dialer,
|
||||
handlers: &m.handlers,
|
||||
auth: o.AddAuth,
|
||||
blockConnect: o.BlockConnect,
|
||||
tlsConfig: o.TLSConfig,
|
||||
publisher: o.TraceTo,
|
||||
ctx: ctx,
|
||||
id: m.ID,
|
||||
local: o.Local,
|
||||
remote: host,
|
||||
dial: o.Dialer,
|
||||
handlers: &m.handlers,
|
||||
auth: o.AddAuth,
|
||||
blockConnect: o.BlockConnect,
|
||||
tlsConfig: o.TLSConfig,
|
||||
publisher: o.TraceTo,
|
||||
incomingBytes: o.Incoming,
|
||||
outgoingBytes: o.Outgoing,
|
||||
})
|
||||
}
|
||||
if !found {
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/minio/madmin-go/v3"
|
||||
@ -64,10 +65,20 @@ type tracer struct {
|
||||
Subroute string
|
||||
}
|
||||
|
||||
const (
|
||||
httpScheme = "http://"
|
||||
httpsScheme = "https://"
|
||||
)
|
||||
|
||||
func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID, req []byte) ([]byte, error) {
|
||||
if t == nil || t.Publisher.NumSubscribers(t.TraceType) == 0 {
|
||||
return c.roundtrip(h, req)
|
||||
}
|
||||
|
||||
// Following trimming is needed for consistency between outputs with other internode traces.
|
||||
local := strings.TrimPrefix(strings.TrimPrefix(t.Local, httpsScheme), httpScheme)
|
||||
remote := strings.TrimPrefix(strings.TrimPrefix(t.Remote, httpsScheme), httpScheme)
|
||||
|
||||
start := time.Now()
|
||||
body := bytesOrLength(req)
|
||||
resp, err := c.roundtrip(h, req)
|
||||
@ -90,7 +101,7 @@ func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID,
|
||||
trace := madmin.TraceInfo{
|
||||
TraceType: t.TraceType,
|
||||
FuncName: prefix + "." + h.String(),
|
||||
NodeName: t.Remote,
|
||||
NodeName: remote,
|
||||
Time: start,
|
||||
Duration: end.Sub(start),
|
||||
Path: t.Subroute,
|
||||
@ -100,7 +111,7 @@ func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID,
|
||||
Time: start,
|
||||
Proto: "grid",
|
||||
Method: "REQ",
|
||||
Client: t.Local,
|
||||
Client: local,
|
||||
Headers: nil,
|
||||
Path: t.Subroute,
|
||||
Body: []byte(body),
|
||||
|
Loading…
x
Reference in New Issue
Block a user