From 1d1ce1f6cc27c321bc4912e8c9bd0fe6767643e4 Mon Sep 17 00:00:00 2001 From: Pawel Zak Date: Mon, 14 Oct 2024 15:21:16 +0200 Subject: [PATCH] addressing comments --- plugins/inputs/ceph/ceph.go | 26 +++++++++---------- .../cisco_telemetry_mdt.go | 4 --- .../cisco_telemetry_mdt_test.go | 10 +++---- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/plugins/inputs/ceph/ceph.go b/plugins/inputs/ceph/ceph.go index 528768dc23bfb..6bb521345cbbf 100644 --- a/plugins/inputs/ceph/ceph.go +++ b/plugins/inputs/ceph/ceph.go @@ -18,6 +18,19 @@ import ( //go:embed sample.conf var sampleConfig string +const ( + measurement = "ceph" + typeMon = "monitor" + typeOsd = "osd" + typeMds = "mds" + typeRgw = "rgw" + osdPrefix = "ceph-osd" + monPrefix = "ceph-mon" + mdsPrefix = "ceph-mds" + rgwPrefix = "ceph-client" + sockSuffix = "asok" +) + type Ceph struct { CephBinary string `toml:"ceph_binary"` OsdPrefix string `toml:"osd_prefix"` @@ -35,19 +48,6 @@ type Ceph struct { schemaMaps map[socket]perfSchemaMap } -const ( - measurement = "ceph" - typeMon = "monitor" - typeOsd = "osd" - typeMds = "mds" - typeRgw = "rgw" - osdPrefix = "ceph-osd" - monPrefix = "ceph-mon" - mdsPrefix = "ceph-mds" - rgwPrefix = "ceph-client" - sockSuffix = "asok" -) - func (*Ceph) SampleConfig() string { return sampleConfig } diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go index a87762b5004c1..b364c6e914f64 100644 --- a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt.go @@ -798,10 +798,6 @@ func (c *CiscoTelemetryMDT) parseContentField( delete(tags, prefix) } -func (c *CiscoTelemetryMDT) address() net.Addr { - return c.listener.Addr() -} - func init() { inputs.Add("cisco_telemetry_mdt", func() telegraf.Input { return &CiscoTelemetryMDT{ diff --git a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go index 5a172f2e8f420..458f490d8952c 100644 --- a/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go +++ b/plugins/inputs/cisco_telemetry_mdt/cisco_telemetry_mdt_test.go @@ -979,7 +979,7 @@ func TestTCPDialoutOverflow(t *testing.T) { MsgLen uint32 }{MsgLen: uint32(1000000000)} - addr := c.address() + addr := c.listener.Addr() conn, err := net.Dial(addr.Network(), addr.String()) require.NoError(t, err) require.NoError(t, binary.Write(conn, binary.BigEndian, hdr)) @@ -1104,7 +1104,7 @@ func TestTCPDialoutMultiple(t *testing.T) { MsgLen uint32 }{} - addr := c.address() + addr := c.listener.Addr() conn, err := net.Dial(addr.Network(), addr.String()) require.NoError(t, err) @@ -1186,7 +1186,7 @@ func TestGRPCDialoutError(t *testing.T) { err := c.Start(acc) require.NoError(t, err) - addr := c.address() + addr := c.listener.Addr() conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) client := mdtdialout.NewGRPCMdtDialoutClient(conn) @@ -1220,7 +1220,7 @@ func TestGRPCDialoutMultiple(t *testing.T) { require.NoError(t, err) tel := mockTelemetryMessage() - addr := c.address() + addr := c.listener.Addr() conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) require.True(t, conn.WaitForStateChange(context.Background(), connectivity.Connecting)) @@ -1306,7 +1306,7 @@ func TestGRPCDialoutKeepalive(t *testing.T) { err := c.Start(acc) require.NoError(t, err) - addr := c.address() + addr := c.listener.Addr() conn, err := grpc.NewClient(addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) client := mdtdialout.NewGRPCMdtDialoutClient(conn)