Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle panic #254

Merged
merged 3 commits into from
Dec 9, 2023
Merged

feat: handle panic #254

merged 3 commits into from
Dec 9, 2023

Conversation

lspgn
Copy link
Member

@lspgn lspgn commented Dec 7, 2023

Adds interceptor for decoder and producer that log potential panic for better debugging.

A line will contain a stacktrace if present

Example log line with JSON:

{
  "blocking": false,
  "count": 1,
  "error": "receiver: test panic",
  "hostname": "",
  "level": "error",
  "message": {
    "Src": "[::ffff:127.0.0.1]:58224",
    "Dst": "[::]:6343",
    "Payload": "b64payload",
    "Received": "2023-12-09T03:57:33.928231Z"
  },
  "msg": "intercepted panic",
  "port": 6343,
  "queue_size": 1000000,
  "scheme": "sflow",
  "stacktrace": "goroutine 49 [running]:\nruntime/debug.Stack()\n\t/usr/local/Cellar/go/1.21.0/libexec/src/runtime/debug/stack.go:24 +0x5e\nmain.main.PanicDecoderWrapper.func5.1()\n\t//goflow2/utils/debug/decoder.go:17 +0x71\npanic({0x1614ba0?, 0x1843c50?})\n\t/usr/local/Cellar/go/1.21.0/libexec/src/runtime/panic.go:914 +0x21f\ngithub.com/netsampler/goflow2/v2/decoders/sflow.DecodeMessage(0x16dc360?, 0xc000073ba0?)\n\t//goflow2/decoders/sflow/sflow.go:421 +0x25\ngithub.com/netsampler/goflow2/v2/decoders/sflow.DecodeMessageVersion(0x0?, 0xc0000a5900)\n\t//goflow2/decoders/sflow/sflow.go:417 +0x10e\ngithub.com/netsampler/goflow2/v2/utils.(*SFlowPipe).DecodeFlow(0xc000280480, {0x15fed80?, 0xc0001d10a0})\n\t//goflow2/utils/pipe.go:113 +0xe5\nmain.main.PanicDecoderWrapper.func5({0x15fed80?, 0xc0001d10a0?})\n\t//goflow2/utils/debug/decoder.go:20 +0x72\nmain.main.PromDecoderWrapper.func6({0x15fed80?, 0xc0001d10a0?})\n\t//goflow2/metrics/decoder.go:53 +0x63c\ngithub.com/netsampler/goflow2/v2/utils.(*UDPReceiver).decoders.func1()\n\t//goflow2/utils/udp.go:215 +0x249\ncreated by github.com/netsampler/goflow2/v2/utils.(*UDPReceiver).decoders in goroutine 1\n\t//goflow2/utils/udp.go:200 +0x32\n",
  "time": "2023-12-08T19:57:33-08:00",
  "workers": 2
}

@lspgn lspgn added the enhancement New feature or request label Dec 7, 2023
@simPod
Copy link
Contributor

simPod commented Dec 8, 2023

I think we should then handle it not only for protobuf since it can panic e.g. with default json output.

@lspgn lspgn changed the title feat: handle panic in producer feat: handle panic Dec 9, 2023
@lspgn lspgn marked this pull request as ready for review December 9, 2023 04:00
@lspgn lspgn merged commit 1a5d58e into main Dec 9, 2023
1 check passed
@lspgn lspgn deleted the feat/panichdl branch December 9, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants