Skip to content

Commit f09c46b

Browse files
authored
Remove deprecated pushgateway methods. (#617)
These were deprecated back in 2015, and take an explicit instance label which is not good practice for using the pushgateway. Signed-off-by: Brian Brazil <[email protected]>
1 parent b6c6e63 commit f09c46b

File tree

2 files changed

+0
-147
lines changed

2 files changed

+0
-147
lines changed

simpleclient_pushgateway/src/main/java/io/prometheus/client/exporter/PushGateway.java

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ public void setConnectionFactory(HttpConnectionFactory connectionFactory) {
9494
* Creates a URL instance from a String representation of a URL without throwing a checked exception.
9595
* Required because you can't wrap a call to another constructor in a try statement.
9696
*
97-
* TODO: Remove this along with other deprecated methods before version 1.0 is released.
98-
*
9997
* @param urlString the String representation of the URL.
10098
* @return The URL instance.
10199
*/
@@ -216,66 +214,6 @@ public void delete(String job, Map<String, String> groupingKey) throws IOExcepti
216214
doRequest(null, job, groupingKey, "DELETE");
217215
}
218216

219-
220-
/**
221-
* Pushes all metrics in a registry, replacing all those with the same job and instance.
222-
* <p>
223-
* This uses the PUT HTTP method.
224-
* @deprecated use {@link #push(CollectorRegistry, String, Map)}
225-
*/
226-
@Deprecated
227-
public void push(CollectorRegistry registry, String job, String instance) throws IOException {
228-
push(registry, job, Collections.singletonMap("instance", instance));
229-
}
230-
231-
/**
232-
* Pushes all metrics in a Collector, replacing all those with the same job and instance.
233-
* <p>
234-
* This is useful for pushing a single Gauge.
235-
* <p>
236-
* This uses the PUT HTTP method.
237-
* @deprecated use {@link #push(Collector, String, Map)}
238-
*/
239-
@Deprecated
240-
public void push(Collector collector, String job, String instance) throws IOException {
241-
push(collector, job, Collections.singletonMap("instance", instance));
242-
}
243-
244-
/**
245-
* Pushes all metrics in a registry, replacing only previously pushed metrics of the same name.
246-
* <p>
247-
* This uses the POST HTTP method.
248-
* @deprecated use {@link #pushAdd(CollectorRegistry, String, Map)}
249-
*/
250-
@Deprecated
251-
public void pushAdd(CollectorRegistry registry, String job, String instance) throws IOException {
252-
pushAdd(registry, job, Collections.singletonMap("instance", instance));
253-
}
254-
255-
/**
256-
* Pushes all metrics in a Collector, replacing only previously pushed metrics of the same name.
257-
* <p>
258-
* This is useful for pushing a single Gauge.
259-
* <p>
260-
* This uses the POST HTTP method.
261-
* @deprecated use {@link #pushAdd(Collector, String, Map)}
262-
*/
263-
@Deprecated
264-
public void pushAdd(Collector collector, String job, String instance) throws IOException {
265-
pushAdd(collector, job, Collections.singletonMap("instance", instance));
266-
}
267-
268-
/**
269-
* Deletes metrics from the Pushgateway.
270-
* <p>
271-
* This uses the DELETE HTTP method.
272-
* @deprecated use {@link #delete(String, Map)}
273-
*/
274-
@Deprecated
275-
public void delete(String job, String instance) throws IOException {
276-
delete(job, Collections.singletonMap("instance", instance));
277-
}
278-
279217
void doRequest(CollectorRegistry registry, String job, Map<String, String> groupingKey, String method) throws IOException {
280218
String url = gatewayBaseURL;
281219
if (job.contains("/")) {

simpleclient_pushgateway/src/test/java/io/prometheus/client/exporter/PushGatewayTest.java

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -214,91 +214,6 @@ public void testDeleteWithGroupingKey() throws IOException {
214214
pg.delete("j", groupingKey);
215215
}
216216

217-
@Test
218-
public void testOldPushWithoutInstance() throws IOException {
219-
mockServerClient.when(
220-
request()
221-
.withMethod("PUT")
222-
.withPath("/metrics/job/j/instance@base64/=")
223-
).respond(response().withStatusCode(202));
224-
pg.push(registry, "j", "");
225-
}
226-
227-
@Test
228-
public void testOldPushWithInstance() throws IOException {
229-
mockServerClient.when(
230-
request()
231-
.withMethod("PUT")
232-
.withPath("/metrics/job/j/instance/i")
233-
).respond(response().withStatusCode(202));
234-
pg.push(registry, "j", "i");
235-
}
236-
237-
@Test
238-
public void testOldNon202ResponseThrows() throws IOException {
239-
mockServerClient.when(
240-
request()
241-
.withMethod("PUT")
242-
.withPath("/metrics/job/j/instance/i")
243-
).respond(response().withStatusCode(500));
244-
thrown.expect(IOException.class);
245-
thrown.expectMessage(
246-
"Response code from http://localhost:"
247-
+ mockServerRule.getHttpPort()
248-
+ "/metrics/job/j/instance/i was 500");
249-
pg.push(registry,"j", "i");
250-
}
251-
252-
@Test
253-
public void testOldPushWithSlashes() throws IOException {
254-
mockServerClient.when(
255-
request()
256-
.withMethod("PUT")
257-
.withPath("/metrics/job@base64/YS9i/instance@base64/Yy9k")
258-
).respond(response().withStatusCode(202));
259-
pg.push(registry, "a/b", "c/d");
260-
}
261-
262-
@Test
263-
public void testOldPushCollector() throws IOException {
264-
mockServerClient.when(
265-
request()
266-
.withMethod("PUT")
267-
.withPath("/metrics/job/j/instance/i")
268-
).respond(response().withStatusCode(202));
269-
pg.push(gauge, "j", "i");
270-
}
271-
272-
@Test
273-
public void testOldPushAdd() throws IOException {
274-
mockServerClient.when(
275-
request()
276-
.withMethod("POST")
277-
.withPath("/metrics/job/j/instance/i")
278-
).respond(response().withStatusCode(202));
279-
pg.pushAdd(registry, "j", "i");
280-
}
281-
282-
@Test
283-
public void testOldPushAddCollector() throws IOException {
284-
mockServerClient.when(
285-
request()
286-
.withMethod("POST")
287-
.withPath("/metrics/job/j/instance/i")
288-
).respond(response().withStatusCode(202));
289-
pg.pushAdd(gauge, "j", "i");
290-
}
291-
292-
@Test
293-
public void testOldDelete() throws IOException {
294-
mockServerClient.when(
295-
request()
296-
.withMethod("DELETE")
297-
.withPath("/metrics/job/j/instance/i")
298-
).respond(response().withStatusCode(202));
299-
pg.delete("j", "i");
300-
}
301-
302217
@Test
303218
public void testInstanceIPGroupingKey() throws IOException {
304219
groupingKey = PushGateway.instanceIPGroupingKey();

0 commit comments

Comments
 (0)