1
1
from . import collectd
2
+ from . import types
2
3
3
4
4
5
senders = []
5
6
6
7
7
- def sends (name , type_ ):
8
- collectd_type = collectd .Type (
9
- name , ("value" , type_ )
10
- )
11
-
8
+ def sends (collectd_type ):
12
9
def decorate (fn ):
13
10
senders .append ((collectd_type , fn ))
14
11
return fn
@@ -25,39 +22,20 @@ def send(self, connection, collection_target, timestamp, interval, pid):
25
22
for collectd_type , sender in senders :
26
23
message_sender = collectd .MessageSender (
27
24
collectd_type , self .hostname , "sqlalchemy" ,
28
- plugin_instance = str ( pid ) , type_instance = self . stats_name ,
25
+ plugin_instance = self . stats_name , type_instance = str ( pid ) ,
29
26
interval = interval
30
27
)
31
- value = sender (collection_target )
32
- message_sender .send (connection , timestamp , value )
33
-
34
-
35
- @sends ("sqlalchemy_numpools" , collectd .VALUE_GAUGE )
36
- def _numpools (collection_target ):
37
- return collection_target .num_pools
38
-
39
-
40
- @sends ("sqlalchemy_checkedout" , collectd .VALUE_GAUGE )
41
- def _checkedout (collection_target ):
42
- return collection_target .num_checkedout
43
-
44
-
45
- @sends ("sqlalchemy_checkedin" , collectd .VALUE_GAUGE )
46
- def _checkedin (collection_target ):
47
- return collection_target .num_checkedin
48
-
49
-
50
- @sends ("sqlalchemy_detached" , collectd .VALUE_GAUGE )
51
- def _detached (collection_target ):
52
- return collection_target .num_detached
53
-
54
-
55
- @sends ("sqlalchemy_invalidated" , collectd .VALUE_GAUGE )
56
- def _invalidated (collection_target ):
57
- return collection_target .num_invalidated
58
-
59
-
60
- @sends ("sqlalchemy_connections" , collectd .VALUE_GAUGE )
61
- def _connections (collection_target ):
62
- return collection_target .num_connections
63
-
28
+ sender (message_sender , connection , collection_target , timestamp )
29
+
30
+
31
+ @sends (types .pool )
32
+ def _send_pool (message_sender , connection , collection_target , timestamp ):
33
+ message_sender .send (
34
+ connection , timestamp ,
35
+ collection_target .num_pools ,
36
+ collection_target .num_checkedout ,
37
+ collection_target .num_checkedin ,
38
+ collection_target .num_detached ,
39
+ collection_target .num_invalidated ,
40
+ collection_target .num_connections
41
+ )
0 commit comments