11from . import collectd
2+ from . import types
23
34
45senders = []
56
67
7- def sends (name , type_ ):
8- collectd_type = collectd .Type (
9- name , ("value" , type_ )
10- )
11-
8+ def sends (collectd_type ):
129 def decorate (fn ):
1310 senders .append ((collectd_type , fn ))
1411 return fn
@@ -25,39 +22,20 @@ def send(self, connection, collection_target, timestamp, interval, pid):
2522 for collectd_type , sender in senders :
2623 message_sender = collectd .MessageSender (
2724 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 ) ,
2926 interval = interval
3027 )
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