@@ -29,27 +29,32 @@ def test_config():
29
29
c .ignored_paths = ["a" , "b" ]
30
30
assert c .ignored_paths == {"a" , "b" }
31
31
32
- # assert use lock
33
32
assert synchronized_mock .call_count == 7
34
33
34
+ c .ignored_user_agents = ["a" , "b" ]
35
+ assert c .ignored_user_agents == ("a" , "b" )
36
+
37
+ # assert use lock
38
+ assert synchronized_mock .call_count == 9
39
+
35
40
c .ignored_tasks = ["a" , "b" ]
36
41
assert c .ignored_tasks == {"a" , "b" }
37
42
38
43
# assert use lock
39
- assert synchronized_mock .call_count == 9
44
+ assert synchronized_mock .call_count == 11
40
45
41
46
data = {"active_sample_rate" : 10 , "wsgi_ignore_path" : (1 , 2 ), "celery_ignore_task" : (3 , 4 )}
42
47
c .update (data )
43
48
44
49
# assert use lock
45
- assert synchronized_mock .call_count == 10
50
+ assert synchronized_mock .call_count == 12
46
51
47
52
assert c .sample_rate == 10
48
53
assert c .ignored_paths == {1 , 2 }
49
54
assert c .ignored_tasks == {3 , 4 }
50
55
51
56
# assert use lock
52
- assert synchronized_mock .call_count == 13
57
+ assert synchronized_mock .call_count == 15
53
58
54
59
55
60
def test_metric ():
@@ -73,26 +78,33 @@ def test_metric():
73
78
m .count_path ("/metric/" )
74
79
assert synchronized_mock .call_count == 1
75
80
76
- m .count_task ( "celery.run " )
81
+ m .count_user_agent ( "kube/1.26 " )
77
82
assert synchronized_mock .call_count == 2
78
83
84
+ m .count_task ("celery.run" )
85
+ assert synchronized_mock .call_count == 3
86
+
79
87
# iteration
80
- assert list (m ) == [(MetricType .WSGI , Counter (["/metric/" ])), (MetricType .CELERY , Counter (["celery.run" ]))]
88
+ assert list (m ) == [
89
+ (MetricType .WSGI , {"path" : Counter (["/metric/" ]), "user_agent" : Counter (["kube/1.26" ])}),
90
+ (MetricType .CELERY , {"task" : Counter (["celery.run" ])}),
91
+ ]
81
92
82
- assert synchronized_mock .call_count == 4
93
+ assert synchronized_mock .call_count == 5
83
94
84
95
assert list (m ) == []
85
96
86
- assert synchronized_mock .call_count == 6
97
+ assert synchronized_mock .call_count == 7
87
98
88
99
m .set_mode (MetricType .WSGI , False )
89
100
m .set_mode (MetricType .CELERY , False )
90
101
91
102
assert list (m ) == []
92
- assert synchronized_mock .call_count == 6
103
+ assert synchronized_mock .call_count == 7
93
104
94
105
m .count_path ("/metric/" )
106
+ m .count_user_agent ("kube/1.26" )
95
107
m .count_task ("celery.run" )
96
108
97
- assert synchronized_mock .call_count == 8
109
+ assert synchronized_mock .call_count == 10
98
110
assert list (m ) == []
0 commit comments