diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 16:04:43 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 16:04:43 +0200 |
| commit | cc4edee087143d656fc74067297f3f540b61362e (patch) | |
| tree | 7bd4b8bf841037b2fb19779d52cff6219c4fa070 /internal/collapse | |
| parent | a2d253f1e92578ccea95f962bbd1a1aebf190de1 (diff) | |
refactor: share collapse field validation lists (task 387)
Diffstat (limited to 'internal/collapse')
| -rw-r--r-- | internal/collapse/fields.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/collapse/fields.go b/internal/collapse/fields.go new file mode 100644 index 0000000..b87fe11 --- /dev/null +++ b/internal/collapse/fields.go @@ -0,0 +1,39 @@ +package collapse + +import "slices" + +var validFields = []string{ + "path", + "comm", + "tracepoint", + "pid", + "tid", + "flags", +} + +var validCountFields = []string{ + "count", + "duration", + "durationToPrev", + "bytes", +} + +// ValidFields returns a copy of supported collapse fields. +func ValidFields() []string { + return slices.Clone(validFields) +} + +// ValidCountFields returns a copy of supported collapse count fields. +func ValidCountFields() []string { + return slices.Clone(validCountFields) +} + +// IsValidField reports whether a collapse field is supported. +func IsValidField(field string) bool { + return slices.Contains(validFields, field) +} + +// IsValidCountField reports whether a collapse count field is supported. +func IsValidCountField(field string) bool { + return slices.Contains(validCountFields, field) +} |
