8000 Document new handler parameter to pushgateway function · pythonAI/client_python@568f6ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 568f6ca

Browse files
tim-seossrossigee
authored andcommitted
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 c3de82b commit 568f6ca

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
@@ -130,6 +130,30 @@ def push_to_gateway(gateway, job, registry, grouping_key=None, timeout=None, han
130130
Defaults to None
131131
`timeout` is how long push will attempt to connect before giving up.
132132
Defaults to None
133+
`handler` is an optional function which can be provided to perform
134+
requests to the 'gateway'.
135+
Defaults to None, in which case an http or https request
136+
will be carried out by a default handler.
137+
If not None, the argument must be a function which accepts
138+
the following arguments:
139+
url, method, timeout, headers, and content
140+
May be used to implement additional functionality not
141+
supported by the built-in default handler (such as SSL
142+
client certicates, and HTTP authentication mechanisms).
143+
'url' is the URL for the request, the 'gateway' argument
144+
described earlier will form the basis of this URL.
145+
'method' is the HTTP method which should be used when
146+
carrying out the request.
147+
'timeout' requests not successfully completed after this
148+
many seconds should be aborted. If timeout is None, then
149+
the handler should not set a timeout.
150+
'headers' is a list of ("header-name","header-value") tuples
151+
which must be passed to the pushgateway in the form of HTTP
152+
request headers.
153+
The function should raise an exception (e.g. IOError) on
154+
failure.
155+
'content' is the data which should be used to form the HTTP
156+
Message Body.
133157
134158
This overwrites all metrics with the same job and grouping_key.
135159
This uses the PUT HTTP method.'''
@@ -148,6 +172,12 @@ def pushadd_to_gateway(gateway, job, registry, grouping_key=None, timeout=None,
148172
Defaults to None
149173
`timeout` is how long push will attempt to connect before giving up.
150174
Defaults to None
175+
`handler` is an optional function which can be provided to perform
176+
requests to the 'gateway'.
177+
Defaults to None, in which case an http or https request
178+
will be carried out by a default handler.
179+
See the 'prometheus_client.push_to_gateway' documentation
180+
for implementation requirements.
151181
152182
This replaces metrics with the same name, job and grouping_key.
153183
This uses the POST HTTP method.'''
@@ -165,6 +195,12 @@ def delete_from_gateway(gateway, job, grouping_key=None, timeout=None, handler=N
165195
Defaults to None
166196
`timeout` is how long delete will attempt to connect before giving up.
167197
Defaults to None
198+
`handler` is an optional function which can be provided to perform
199+
requests to the 'gateway'.
200+
Defaults to None, in which case an http or https request
201+
will be carried out by a default handler.
202+
See the 'prometheus_client.push_to_gateway' documentation
203+
for implementation requirements.
168204
169205
This deletes metrics with the given job and grouping_key.
170206
This uses the DELETE HTTP method.'''

0 commit comments

Comments
 (0)
0