mirror of
https://github.com/minio/minio.git
synced 2025-04-23 03:45:49 -04: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 {
|
if op != ws.OpBinary {
|
||||||
return fmt.Errorf("unexpected connect response type %v", op)
|
return fmt.Errorf("unexpected connect response type %v", op)
|
||||||
}
|
}
|
||||||
|
if c.incomingBytes != nil {
|
||||||
|
c.incomingBytes(int64(len(b)))
|
||||||
|
}
|
||||||
|
|
||||||
var m message
|
var m message
|
||||||
_, _, err = m.parse(b)
|
_, _, err = m.parse(b)
|
||||||
if err != nil {
|
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)
|
logger.LogIfNot(ctx, fmt.Errorf("ws read: %w", err), net.ErrClosed, io.EOF)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.incomingBytes != nil {
|
|
||||||
c.incomingBytes(int64(len(msg)))
|
|
||||||
}
|
|
||||||
// Parse the received message
|
// Parse the received message
|
||||||
var m message
|
var m message
|
||||||
subID, remain, err := m.parse(msg)
|
subID, remain, err := m.parse(msg)
|
||||||
|
@ -105,16 +105,18 @@ func NewManager(ctx context.Context, o ManagerOptions) (*Manager, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.targets[host] = newConnection(connectionParams{
|
m.targets[host] = newConnection(connectionParams{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
id: m.ID,
|
id: m.ID,
|
||||||
local: o.Local,
|
local: o.Local,
|
||||||
remote: host,
|
remote: host,
|
||||||
dial: o.Dialer,
|
dial: o.Dialer,
|
||||||
handlers: &m.handlers,
|
handlers: &m.handlers,
|
||||||
auth: o.AddAuth,
|
auth: o.AddAuth,
|
||||||
blockConnect: o.BlockConnect,
|
blockConnect: o.BlockConnect,
|
||||||
tlsConfig: o.TLSConfig,
|
tlsConfig: o.TLSConfig,
|
||||||
publisher: o.TraceTo,
|
publisher: o.TraceTo,
|
||||||
|
incomingBytes: o.Incoming,
|
||||||
|
outgoingBytes: o.Outgoing,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/madmin-go/v3"
|
"github.com/minio/madmin-go/v3"
|
||||||
@ -64,10 +65,20 @@ type tracer struct {
|
|||||||
Subroute string
|
Subroute string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
httpScheme = "http://"
|
||||||
|
httpsScheme = "https://"
|
||||||
|
)
|
||||||
|
|
||||||
func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID, req []byte) ([]byte, error) {
|
func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID, req []byte) ([]byte, error) {
|
||||||
if t == nil || t.Publisher.NumSubscribers(t.TraceType) == 0 {
|
if t == nil || t.Publisher.NumSubscribers(t.TraceType) == 0 {
|
||||||
return c.roundtrip(h, req)
|
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()
|
start := time.Now()
|
||||||
body := bytesOrLength(req)
|
body := bytesOrLength(req)
|
||||||
resp, err := c.roundtrip(h, 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{
|
trace := madmin.TraceInfo{
|
||||||
TraceType: t.TraceType,
|
TraceType: t.TraceType,
|
||||||
FuncName: prefix + "." + h.String(),
|
FuncName: prefix + "." + h.String(),
|
||||||
NodeName: t.Remote,
|
NodeName: remote,
|
||||||
Time: start,
|
Time: start,
|
||||||
Duration: end.Sub(start),
|
Duration: end.Sub(start),
|
||||||
Path: t.Subroute,
|
Path: t.Subroute,
|
||||||
@ -100,7 +111,7 @@ func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID,
|
|||||||
Time: start,
|
Time: start,
|
||||||
Proto: "grid",
|
Proto: "grid",
|
||||||
Method: "REQ",
|
Method: "REQ",
|
||||||
Client: t.Local,
|
Client: local,
|
||||||
Headers: nil,
|
Headers: nil,
|
||||||
Path: t.Subroute,
|
Path: t.Subroute,
|
||||||
Body: []byte(body),
|
Body: []byte(body),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user