MCPcopy Index your code
hub / github.com/rabbitstack/fibratus / Summary

Method Summary

pkg/callstack/callstack.go:263–302  ·  view source on GitHub ↗

Summary returns a sequence of non-repeated module names.

()

Source from the content-addressed store, hash-verified

261
262// Summary returns a sequence of non-repeated module names.
263func (s Callstack) Summary() string {
264 var b strings.Builder
265 var prev string
266 var removeSep bool
267
268 for i := range s {
269 frame := s[len(s)-i-1]
270 if frame.Addr.InSystemRange() {
271 continue
272 }
273
274 var n string
275 if frame.IsUnbacked() {
276 n = unbacked
277 } else {
278 n = filepath.Base(frame.Module)
279 }
280
281 if n == prev {
282 if i == len(s)-1 {
283 // last module equals to the previous
284 // which renders redundant separator
285 removeSep = true
286 }
287 continue
288 }
289
290 b.WriteString(n)
291 if i != len(s)-1 {
292 b.WriteRune('|')
293 }
294 prev = n
295 }
296
297 if removeSep {
298 return strings.TrimSuffix(b.String(), "|")
299 }
300
301 return b.String()
302}
303
304func (s Callstack) String() string {
305 var b strings.Builder

Callers 1

TestCallstackFunction · 0.95

Calls 3

InSystemRangeMethod · 0.80
IsUnbackedMethod · 0.80
StringMethod · 0.65

Tested by 1

TestCallstackFunction · 0.76