@@ -29,27 +29,32 @@ def test_config():
2929 c .ignored_paths = ["a" , "b" ]
3030 assert c .ignored_paths == {"a" , "b" }
3131
32- # assert use lock
3332 assert synchronized_mock .call_count == 7
3433
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+
3540 c .ignored_tasks = ["a" , "b" ]
3641 assert c .ignored_tasks == {"a" , "b" }
3742
3843 # assert use lock
39- assert synchronized_mock .call_count == 9
44+ assert synchronized_mock .call_count == 11
4045
4146 data = {"active_sample_rate" : 10 , "wsgi_ignore_path" : (1 , 2 ), "celery_ignore_task" : (3 , 4 )}
4247 c .update (data )
4348
4449 # assert use lock
45- assert synchronized_mock .call_count == 10
50+ assert synchronized_mock .call_count == 12
4651
4752 assert c .sample_rate == 10
4853 assert c .ignored_paths == {1 , 2 }
4954 assert c .ignored_tasks == {3 , 4 }
5055
5156 # assert use lock
52- assert synchronized_mock .call_count == 13
57+ assert synchronized_mock .call_count == 15
5358
5459
5560def test_metric ():
@@ -73,26 +78,33 @@ def test_metric():
7378 m .count_path ("/metric/" )
7479 assert synchronized_mock .call_count == 1
7580
76- m .count_task ( "celery.run " )
81+ m .count_user_agent ( "kube/1.26 " )
7782 assert synchronized_mock .call_count == 2
7883
84+ m .count_task ("celery.run" )
85+ assert synchronized_mock .call_count == 3
86+
7987 # 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+ ]
8192
82- assert synchronized_mock .call_count == 4
93+ assert synchronized_mock .call_count == 5
8394
8495 assert list (m ) == []
8596
86- assert synchronized_mock .call_count == 6
97+ assert synchronized_mock .call_count == 7
8798
8899 m .set_mode (MetricType .WSGI , False )
89100 m .set_mode (MetricType .CELERY , False )
90101
91102 assert list (m ) == []
92- assert synchronized_mock .call_count == 6
103+ assert synchronized_mock .call_count == 7
93104
94105 m .count_path ("/metric/" )
106+ m .count_user_agent ("kube/1.26" )
95107 m .count_task ("celery.run" )
96108
97- assert synchronized_mock .call_count == 8
109+ assert synchronized_mock .call_count == 10
98110 assert list (m ) == []
0 commit comments