From 36619f9a21ccaeb524823922b2d775857602f7cb Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 29 Nov 2024 10:07:47 +0100 Subject: [PATCH] BREAKING CHANGE: netcore: scope non-common fields 1. `domain` => `dnsLookupDomain` 2. `addrs` => `dnsResolvedAddrs` 3. `count` => `ioBufferSize` or `ioBufferCount` This set of changes is part of an overall effort to ensure it's relatively trivial to serialize to a flat data format. To this end, figure out which fields are really common and which fields, instead, are specific, and add prefixes to the specific ones to make it very clear what they are about. Also, avoid overload, and split into two fields when we're using the same field with two distinct semantics dependent on the message type. This should also increase the data format orthogonality. See also https://github.com/rbmk-project/dnscore/pull/13 --- go.mod | 4 ++-- go.sum | 8 ++++---- netcore/conn.go | 8 ++++---- netcore/resolver.go | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index eee37da..8ec395e 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.23.3 require ( github.com/miekg/dns v1.1.62 - github.com/rbmk-project/common v0.3.0 - github.com/rbmk-project/dnscore v0.5.0 + github.com/rbmk-project/common v0.4.0 + github.com/rbmk-project/dnscore v0.6.0 github.com/rogpeppe/go-internal v1.13.1 golang.org/x/sys v0.27.0 ) diff --git a/go.sum b/go.sum index d0c0f7e..2c17ccb 100644 --- a/go.sum +++ b/go.sum @@ -4,10 +4,10 @@ github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rbmk-project/common v0.3.0 h1:g9iX/lg5kvzmgxgr4xbkcCjA2jfazM1zAyLKzLD/3iU= -github.com/rbmk-project/common v0.3.0/go.mod h1:uzrFIJl8SEOpgS2pSeBFLUgqc4D1lIcGk/EYuxkFO0U= -github.com/rbmk-project/dnscore v0.5.0 h1:GaWr4SUJFJzjAgkZ9kJdS0I0BWHPnObD/lZaZzPfB9c= -github.com/rbmk-project/dnscore v0.5.0/go.mod h1:ENuxqOG44rTIByt412eghWPRvTg/G5RkE6Truv+tapQ= +github.com/rbmk-project/common v0.4.0 h1:gw7f/YdPxcUZ81cO9IMzEPDhsc6tOUte1m0OFi6euFg= +github.com/rbmk-project/common v0.4.0/go.mod h1:uzrFIJl8SEOpgS2pSeBFLUgqc4D1lIcGk/EYuxkFO0U= +github.com/rbmk-project/dnscore v0.6.0 h1:23rRsLBwTkQqJQMVPf4kimzGSZsw29EY7u3ffHbWkKg= +github.com/rbmk-project/dnscore v0.6.0/go.mod h1:Ct9RhR8HTI6tnq6/HSbzB/F8bk3k7E/6hmEctxSecUQ= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= diff --git a/netcore/conn.go b/netcore/conn.go index 1b84c9a..3a74a36 100644 --- a/netcore/conn.go +++ b/netcore/conn.go @@ -117,7 +117,7 @@ func (c *connWrapper) Read(buf []byte) (int, error) { c.netx.Logger.InfoContext( c.ctx, "readStart", - slog.Int("count", len(buf)), + slog.Int("ioBufferSize", len(buf)), slog.String("localAddr", c.laddr), slog.String("protocol", c.protocol), slog.String("remoteAddr", c.raddr), @@ -131,7 +131,7 @@ func (c *connWrapper) Read(buf []byte) (int, error) { c.netx.Logger.InfoContext( c.ctx, "readDone", - slog.Int("count", count), + slog.Int("ioBytesCount", count), slog.Any("err", err), slog.String("localAddr", c.laddr), slog.String("protocol", c.protocol), @@ -169,7 +169,7 @@ func (c *connWrapper) Write(data []byte) (n int, err error) { c.netx.Logger.InfoContext( c.ctx, "writeStart", - slog.Int("count", len(data)), + slog.Int("ioBufferSize", len(data)), slog.String("localAddr", c.laddr), slog.String("protocol", c.protocol), slog.String("remoteAddr", c.raddr), @@ -183,7 +183,7 @@ func (c *connWrapper) Write(data []byte) (n int, err error) { c.netx.Logger.InfoContext( c.ctx, "writeDone", - slog.Int("count", count), + slog.Int("ioBytesCount", count), slog.Any("err", err), slog.String("localAddr", c.laddr), slog.String("protocol", c.protocol), diff --git a/netcore/resolver.go b/netcore/resolver.go index 888fb0d..d1ab5f2 100644 --- a/netcore/resolver.go +++ b/netcore/resolver.go @@ -80,7 +80,7 @@ func (nx *Network) emitLookupHostStart(ctx context.Context, domain string) time. nx.Logger.InfoContext( ctx, "lookupHostStart", - slog.String("domain", domain), + slog.String("dnsLookupDomain", domain), slog.Time("t", t0), ) } @@ -94,8 +94,8 @@ func (nx *Network) emitLookupHostDone(ctx context.Context, nx.Logger.InfoContext( ctx, "lookupHostDone", - slog.String("domain", domain), - slog.Any("addrs", addrs), + slog.String("dnsLookupDomain", domain), + slog.Any("dnsResolvedAddrs", addrs), slog.Any("err", err), slog.Time("t0", t0), slog.Time("t", nx.timeNow()),