Переглянути джерело

Support sign in tagfocus (#438)

Support sign in tagfocus
Matt Fowles Kulukundis 6 роки тому
джерело
коміт
b4f47329b9
2 змінених файлів з 16 додано та 1 видалено
  1. 1
    1
      internal/driver/driver_focus.go
  2. 15
    0
      internal/driver/driver_test.go

+ 1
- 1
internal/driver/driver_focus.go Переглянути файл

@@ -25,7 +25,7 @@ import (
25 25
 	"github.com/google/pprof/profile"
26 26
 )
27 27
 
28
-var tagFilterRangeRx = regexp.MustCompile("([[:digit:]]+)([[:alpha:]]+)")
28
+var tagFilterRangeRx = regexp.MustCompile("([+-]?[[:digit:]]+)([[:alpha:]]+)")
29 29
 
30 30
 // applyFocus filters samples based on the focus/ignore options
31 31
 func applyFocus(prof *profile.Profile, numLabelUnits map[string]string, v variables, ui plugin.UI) error {

+ 15
- 0
internal/driver/driver_test.go Переглянути файл

@@ -96,6 +96,7 @@ func TestParse(t *testing.T) {
96 96
 		{"peek=line.*01", "cpu"},
97 97
 		{"weblist=line[13],addresses,flat", "cpu"},
98 98
 		{"tags,tagfocus=400kb:", "heap_request"},
99
+		{"tags,tagfocus=+400kb:", "heap_request"},
99 100
 		{"dot", "longNameFuncs"},
100 101
 		{"text", "longNameFuncs"},
101 102
 	}
@@ -1440,6 +1441,20 @@ func TestNumericTagFilter(t *testing.T) {
1440 1441
 			map[string]string{"key1": "bytes"},
1441 1442
 			false,
1442 1443
 		},
1444
+		{
1445
+			"Match negative key and range of values, value matches",
1446
+			"bytes=-512b:-128b",
1447
+			map[string][]int64{"bytes": {-256}},
1448
+			map[string]string{"bytes": "bytes"},
1449
+			true,
1450
+		},
1451
+		{
1452
+			"Match negative key and range of values, value outside range",
1453
+			"bytes=-512b:-128b",
1454
+			map[string][]int64{"bytes": {-2048}},
1455
+			map[string]string{"bytes": "bytes"},
1456
+			false,
1457
+		},
1443 1458
 	}
1444 1459
 	for _, test := range tagFilterTests {
1445 1460
 		t.Run(test.desc, func(*testing.T) {