Skip to content

Commit 7b0677c

Browse files
committed
Document new handler parameter to pushgateway function
Provide pydoc for the new handler function to the various pushgateway functions, provide parameter descriptions in the documentatation for the push_to_gateway function to avoid excessive copy-and-paste.
1 parent 8736939 commit 7b0677c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

prometheus_client/exposition.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,30 @@ def push_to_gateway(gateway, job, registry, grouping_key=None, timeout=None, han
123123
Defaults to None
124124
`timeout` is how long push will attempt to connect before giving up.
125125
Defaults to None
126+
`handler` is an optional function which can be provided to perform
127+
requests to the 'gateway'.
128+
Defaults to None, in which case an http or https request
129+
will be carried out by a default handler.
130+
If not None, the argument must be a function which accepts
131+
the following arguments:
132+
url, method, timeout, headers, and content
133+
May be used to implement additional functionality not
134+
supported by the built-in default handler (such as SSL
135+
client certicates, and HTTP authentication mechanisms).
136+
'url' is the URL for the request, the 'gateway' argument
137+
described earlier will form the basis of this URL.
138+
'method' is the HTTP method which should be used when
139+
carrying out the request.
140+
'timeout' requests not successfully completed after this
141+
many seconds should be aborted. If timeout is None, then
142+
the handler should not set a timeout.
143+
'headers' is a list of ("header-name","header-value") tuples
144+
which must be passed to the pushgateway in the form of HTTP
145+
request headers.
146+
The function should raise an exception (e.g. IOError) on
147+
failure.
148+
'content' is the data which should be used to form the HTTP
149+
Message Body.
126150
127151
This overwrites all metrics with the same job and grouping_key.
128152
This uses the PUT HTTP method.'''
@@ -141,6 +165,12 @@ def pushadd_to_gateway(gateway, job, registry, grouping_key=None, timeout=None,
141165
Defaults to None
142166
`timeout` is how long push will attempt to connect before giving up.
143167
Defaults to None
168+
`handler` is an optional function which can be provided to perform
169+
requests to the 'gateway'.
170+
Defaults to None, in which case an http or https request
171+
will be carried out by a default handler.
172+
See the 'prometheus_client.push_to_gateway' documentation
173+
for implementation requirements.
144174
145175
This replaces metrics with the same name, job and grouping_key.
146176
This uses the POST HTTP method.'''
@@ -158,6 +188,12 @@ def delete_from_gateway(gateway, job, grouping_key=None, timeout=None, handler=N
158188
Defaults to None
159189
`timeout` is how long delete will attempt to connect before giving up.
160190
Defaults to None
191+
`handler` is an optional function which can be provided to perform
192+
requests to the 'gateway'.
193+
Defaults to None, in which case an http or https request
194+
will be carried out by a default handler.
195+
See the 'prometheus_client.push_to_gateway' documentation
196+
for implementation requirements.
161197
162198
This deletes metrics with the given job and grouping_key.
163199
This uses the DELETE HTTP method.'''

0 commit comments

Comments
 (0)