@@ -121,7 +121,7 @@ def write_to_textfile(path, registry):
121
121
os .rename (tmppath , path )
122
122
123
123
124
- def push_to_gateway (gateway , job , registry , grouping_key = None , timeout = None , handler = None ):
124
+ def push_to_gateway (gateway , job , registry , grouping_key = None , timeout = None , handler = None , handler_args = None ):
125
125
'''Push metrics to the given pushgateway.
126
126
127
127
`gateway` the url for your push gateway. Either of the form
@@ -157,13 +157,14 @@ def push_to_gateway(gateway, job, registry, grouping_key=None, timeout=None, han
157
157
failure.
158
158
'content' is the data which should be used to form the HTTP
159
159
Message Body.
160
+ `handler_args` is an optional dict of extra arguments to provide
160
161
161
162
This overwrites all metrics with the same job and grouping_key.
162
163
This uses the PUT HTTP method.'''
163
- _use_gateway ('PUT' , gateway , job , registry , grouping_key , timeout , handler )
164
+ _use_gateway ('PUT' , gateway , job , registry , grouping_key , timeout , handler , handler_args )
164
165
165
166
166
- def pushadd_to_gateway (gateway , job , registry , grouping_key = None , timeout = None , handler = None ):
167
+ def pushadd_to_gateway (gateway , job , registry , grouping_key = None , timeout = None , handler = None , handler_args = None ):
167
168
'''PushAdd metrics to the given pushgateway.
168
169
169
170
`gateway` the url for your push gateway. Either of the form
@@ -184,10 +185,10 @@ def pushadd_to_gateway(gateway, job, registry, grouping_key=None, timeout=None,
184
185
185
186
This replaces metrics with the same name, job and grouping_key.
186
187
This uses the POST HTTP method.'''
187
- _use_gateway ('POST' , gateway , job , registry , grouping_key , timeout , handler )
188
+ _use_gateway ('POST' , gateway , job , registry , grouping_key , timeout , handler , handler_args )
188
189
189
190
190
- def delete_from_gateway (gateway , job , grouping_key = None , timeout = None , handler = None ):
191
+ def delete_from_gateway (gateway , job , grouping_key = None , timeout = None , handler = None , handler_args = None ):
191
192
'''Delete metrics from the given pushgateway.
192
193
193
194
`gateway` the url for your push gateway. Either of the form
@@ -207,10 +208,10 @@ def delete_from_gateway(gateway, job, grouping_key=None, timeout=None, handler=N
207
208
208
209
This deletes metrics with the given job and grouping_key.
209
210
This uses the DELETE HTTP method.'''
210
- _use_gateway ('DELETE' , gateway , job , None , grouping_key , timeout , handler )
211
+ _use_gateway ('DELETE' , gateway , job , None , grouping_key , timeout , handler , handler_args )
211
212
212
213
213
- def _use_gateway (method , gateway , job , registry , grouping_key , timeout , handler ):
214
+ def _use_gateway (method , gateway , job , registry , grouping_key , timeout , handler , handler_args ):
214
215
gateway_url = urlparse (gateway )
215
216
if not gateway_url .scheme :
216
217
gateway = 'http://{0}' .format (gateway )
@@ -228,8 +229,10 @@ def _use_gateway(method, gateway, job, registry, grouping_key, timeout, handler)
228
229
headers = [('Content-Type' , CONTENT_TYPE_LATEST )]
229
230
if handler is None :
230
231
handler = default_handler
232
+ if handler_args is None :
233
+ handler_args = dict ()
231
234
handler (url = url , method = method , timeout = timeout ,
232
- headers = headers , data = data )
235
+ headers = headers , data = data , ** handler_args )
233
236
234
237
def instance_ip_grouping_key ():
235
238
'''Grouping key with instance set to the IP Address of this host.'''
0 commit comments