From 696f49ddae2edbb7da3f4cd0e444b57ae8e2437b Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Fri, 1 Mar 2024 15:18:33 +0000 Subject: [PATCH] tetra: Add support to display throttle events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding support to display throttle events in getevents like: 💥 exit ubuntu-22 /usr/bin/sleep 0.1s 0 🚀 process ubuntu-22 /usr/bin/sleep 0.1s 🧬 throttle START session-130.scope-10741 🧬 throttle STOP session-130.scope-10741 🚀 process ubuntu-22 /usr/bin/git diff 🚀 process ubuntu-22 /usr/bin/pager Signed-off-by: Jiri Olsa --- pkg/encoder/encoder.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/encoder/encoder.go b/pkg/encoder/encoder.go index a2663d69646..6d000debbc7 100644 --- a/pkg/encoder/encoder.go +++ b/pkg/encoder/encoder.go @@ -250,6 +250,17 @@ func (p *CompactEncoder) EventToString(response *tetragon.GetEventsResponse) (st status = p.Colorer.Red.Sprint(exit.Status) } return CapTrailorPrinter(fmt.Sprintf("%s %s %s %s", event, processInfo, args, status), caps), nil + case *tetragon.GetEventsResponse_ProcessThrottle: + throttle := response.GetProcessThrottle() + event := p.Colorer.Red.Sprintf("🧬 %-7s", "throttle") + var typ string + switch throttle.Type { + case tetragon.ThrottleType_THROTTLE_START: + typ = p.Colorer.Red.Sprint("START") + case tetragon.ThrottleType_THROTTLE_STOP: + typ = p.Colorer.Green.Sprint("STOP ") + } + return fmt.Sprintf("%s %s %s", event, typ, throttle.Cgroup), nil case *tetragon.GetEventsResponse_ProcessLoader: loader := response.GetProcessLoader() if loader.Process == nil {