From ef6bc0704f1ba7c5deb7e8c0a7a7a35737992016 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 1 Dec 2022 14:19:53 +1030 Subject: [PATCH] address related pr comments device retained in registration ID to prevent collision: panic: name 68DD99D548B50928 already used goroutine 157 [running]: github.com/elastic/elastic-agent-libs/monitoring.panicErr(...) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/pkg/mod/github.com/elastic/elastic-agent-libs@v0.2.13/monitoring/registry.go:257 github.com/elastic/elastic-agent-libs/monitoring.(*Registry).Add(0xc000569fc0, {0xc00071ae50, 0x10654fd}, {0x35b8160, 0xc0001f8440}, 0x78) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/pkg/mod/github.com/elastic/elastic-agent-libs@v0.2.13/monitoring/registry.go:155 +0xda github.com/elastic/elastic-agent-libs/monitoring.(*Registry).NewRegistry(0xc000569fc0, {0xc00071ae50, 0x10}, {0x0?, 0x35adc60?, 0x1?}) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/pkg/mod/github.com/elastic/elastic-agent-libs@v0.2.13/monitoring/registry.go:94 +0x158 github.com/elastic/beats/v7/libbeat/monitoring/inputmon.NewInputRegistry({0x3107792, 0x3}, {0xc00071ae50, 0x10}, 0xc00070ff50?) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/src/github.com/elastic/beats/libbeat/monitoring/inputmon/input.go:43 +0x99 github.com/elastic/beats/v7/packetbeat/protos/udp.newInputMetrics({0xc00071ae50?, 0x0?}, {0x0, 0x0}) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/src/github.com/elastic/beats/packetbeat/protos/udp/udp.go:155 +0x7c github.com/elastic/beats/v7/packetbeat/protos/udp.NewUDP({0x35d9388, 0xc000314420}, {0xc00071ae50, 0x10}, {0x0, 0x0}) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/src/github.com/elastic/beats/packetbeat/protos/udp/udp.go:57 +0x9d github.com/elastic/beats/v7/packetbeat/sniffer.DecodersFor.func1(0x0?, {0x0, 0x0}) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/src/github.com/elastic/beats/packetbeat/sniffer/decoders.go:69 +0x22f github.com/elastic/beats/v7/packetbeat/sniffer.(*sniffer).sniffStatic(0xc0002e64b0, {0x35d6f68, 0xc0005695c0}, {0x0, 0x0}) /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/src/github.com/elastic/beats/packetbeat/sniffer/sniffer.go:282 +0x159 github.com/elastic/beats/v7/packetbeat/sniffer.(*Sniffer).Run.func1() /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/src/github.com/elastic/beats/packetbeat/sniffer/sniffer.go:202 +0x1be golang.org/x/sync/errgroup.(*Group).Go.func1() /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/pkg/mod/golang.org/x/sync@v0.0.0-20220819030929-7fc1605a5dde/errgroup/errgroup.go:75 +0x64 created by golang.org/x/sync/errgroup.(*Group).Go /var/lib/jenkins/workspace/PR-33833-10-4f1d82ee-c0da-4414-bc63-8fa79cc6cbf5/pkg/mod/golang.org/x/sync@v0.0.0-20220819030929-7fc1605a5dde/errgroup/errgroup.go:72 +0xa5 --- packetbeat/protos/tcp/tcp.go | 8 ++++---- packetbeat/protos/udp/udp.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packetbeat/protos/tcp/tcp.go b/packetbeat/protos/tcp/tcp.go index a6b9b97a6f1..f960ce340e4 100644 --- a/packetbeat/protos/tcp/tcp.go +++ b/packetbeat/protos/tcp/tcp.go @@ -412,16 +412,16 @@ func newInputMetrics(id, device string) *inputMetrics { out := &inputMetrics{ unregister: unreg, device: monitoring.NewString(reg, "device"), - packets: monitoring.NewUint(reg, "tcp_packets"), - bytes: monitoring.NewUint(reg, "tcp_bytes"), + packets: monitoring.NewUint(reg, "received_events_total"), + bytes: monitoring.NewUint(reg, "received_bytes_total"), overlapped: monitoring.NewUint(reg, "tcp_overlaps"), dropped: monitoring.NewInt(reg, "tcp.dropped_because_of_gaps"), // Name and type retained for compatibility. arrivalPeriod: metrics.NewUniformSample(1024), processingTime: metrics.NewUniformSample(1024), } - _ = adapter.NewGoMetrics(reg, "tcp_arrival_period", adapter.Accept). + _ = adapter.NewGoMetrics(reg, "arrival_period", adapter.Accept). Register("histogram", metrics.NewHistogram(out.arrivalPeriod)) - _ = adapter.NewGoMetrics(reg, "tcp_processing_time", adapter.Accept). + _ = adapter.NewGoMetrics(reg, "processing_time", adapter.Accept). Register("histogram", metrics.NewHistogram(out.processingTime)) out.device.Set(device) diff --git a/packetbeat/protos/udp/udp.go b/packetbeat/protos/udp/udp.go index f51da5f4bc1..0e3998554f9 100644 --- a/packetbeat/protos/udp/udp.go +++ b/packetbeat/protos/udp/udp.go @@ -156,14 +156,14 @@ func newInputMetrics(id, device string) *inputMetrics { out := &inputMetrics{ unregister: unreg, device: monitoring.NewString(reg, "device"), - packets: monitoring.NewUint(reg, "udp_packets"), - bytes: monitoring.NewUint(reg, "udp_bytes"), + packets: monitoring.NewUint(reg, "received_events_total"), + bytes: monitoring.NewUint(reg, "received_bytes_total"), arrivalPeriod: metrics.NewUniformSample(1024), processingTime: metrics.NewUniformSample(1024), } - _ = adapter.NewGoMetrics(reg, "udp_arrival_period", adapter.Accept). + _ = adapter.NewGoMetrics(reg, "arrival_period", adapter.Accept). Register("histogram", metrics.NewHistogram(out.arrivalPeriod)) - _ = adapter.NewGoMetrics(reg, "udp_processing_time", adapter.Accept). + _ = adapter.NewGoMetrics(reg, "processing_time", adapter.Accept). Register("histogram", metrics.NewHistogram(out.processingTime)) out.device.Set(device)