Skip to content

Commit

Permalink
Remove deprecated pushgateway methods. (#617)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
brian-brazil authored Jan 22, 2021
1 parent b6c6e63 commit f09c46b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ public void setConnectionFactory(HttpConnectionFactory connectionFactory) {
* Creates a URL instance from a String representation of a URL without throwing a checked exception.
* Required because you can't wrap a call to another constructor in a try statement.
*
* TODO: Remove this along with other deprecated methods before version 1.0 is released.
*
* @param urlString the String representation of the URL.
* @return The URL instance.
*/
Expand Down Expand Up @@ -216,66 +214,6 @@ public void delete(String job, Map<String, String> groupingKey) throws IOExcepti
doRequest(null, job, groupingKey, "DELETE");
}


/**
* Pushes all metrics in a registry, replacing all those with the same job and instance.
* <p>
* This uses the PUT HTTP method.
* @deprecated use {@link #push(CollectorRegistry, String, Map)}
*/
@Deprecated
public void push(CollectorRegistry registry, String job, String instance) throws IOException {
push(registry, job, Collections.singletonMap("instance", instance));
}

/**
* Pushes all metrics in a Collector, replacing all those with the same job and instance.
* <p>
* This is useful for pushing a single Gauge.
* <p>
* This uses the PUT HTTP method.
* @deprecated use {@link #push(Collector, String, Map)}
*/
@Deprecated
public void push(Collector collector, String job, String instance) throws IOException {
push(collector, job, Collections.singletonMap("instance", instance));
}

/**
* Pushes all metrics in a registry, replacing only previously pushed metrics of the same name.
* <p>
* This uses the POST HTTP method.
* @deprecated use {@link #pushAdd(CollectorRegistry, String, Map)}
*/
@Deprecated
public void pushAdd(CollectorRegistry registry, String job, String instance) throws IOException {
pushAdd(registry, job, Collections.singletonMap("instance", instance));
}

/**
* Pushes all metrics in a Collector, replacing only previously pushed metrics of the same name.
* <p>
* This is useful for pushing a single Gauge.
* <p>
* This uses the POST HTTP method.
* @deprecated use {@link #pushAdd(Collector, String, Map)}
*/
@Deprecated
public void pushAdd(Collector collector, String job, String instance) throws IOException {
pushAdd(collector, job, Collections.singletonMap("instance", instance));
}

/**
* Deletes metrics from the Pushgateway.
* <p>
* This uses the DELETE HTTP method.
* @deprecated use {@link #delete(String, Map)}
*/
@Deprecated
public void delete(String job, String instance) throws IOException {
delete(job, Collections.singletonMap("instance", instance));
}

void doRequest(CollectorRegistry registry, String job, Map<String, String> groupingKey, String method) throws IOException {
String url = gatewayBaseURL;
if (job.contains("/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,91 +214,6 @@ public void testDeleteWithGroupingKey() throws IOException {
pg.delete("j", groupingKey);
}

@Test
public void testOldPushWithoutInstance() throws IOException {
mockServerClient.when(
request()
.withMethod("PUT")
.withPath("/metrics/job/j/instance@base64/=")
).respond(response().withStatusCode(202));
pg.push(registry, "j", "");
}

@Test
public void testOldPushWithInstance() throws IOException {
mockServerClient.when(
request()
.withMethod("PUT")
.withPath("/metrics/job/j/instance/i")
).respond(response().withStatusCode(202));
pg.push(registry, "j", "i");
}

@Test
public void testOldNon202ResponseThrows() throws IOException {
mockServerClient.when(
request()
.withMethod("PUT")
.withPath("/metrics/job/j/instance/i")
).respond(response().withStatusCode(500));
thrown.expect(IOException.class);
thrown.expectMessage(
"Response code from http://localhost:"
+ mockServerRule.getHttpPort()
+ "/metrics/job/j/instance/i was 500");
pg.push(registry,"j", "i");
}

@Test
public void testOldPushWithSlashes() throws IOException {
mockServerClient.when(
request()
.withMethod("PUT")
.withPath("/metrics/job@base64/YS9i/instance@base64/Yy9k")
).respond(response().withStatusCode(202));
pg.push(registry, "a/b", "c/d");
}

@Test
public void testOldPushCollector() throws IOException {
mockServerClient.when(
request()
.withMethod("PUT")
.withPath("/metrics/job/j/instance/i")
).respond(response().withStatusCode(202));
pg.push(gauge, "j", "i");
}

@Test
public void testOldPushAdd() throws IOException {
mockServerClient.when(
request()
.withMethod("POST")
.withPath("/metrics/job/j/instance/i")
).respond(response().withStatusCode(202));
pg.pushAdd(registry, "j", "i");
}

@Test
public void testOldPushAddCollector() throws IOException {
mockServerClient.when(
request()
.withMethod("POST")
.withPath("/metrics/job/j/instance/i")
).respond(response().withStatusCode(202));
pg.pushAdd(gauge, "j", "i");
}

@Test
public void testOldDelete() throws IOException {
mockServerClient.when(
request()
.withMethod("DELETE")
.withPath("/metrics/job/j/instance/i")
).respond(response().withStatusCode(202));
pg.delete("j", "i");
}

@Test
public void testInstanceIPGroupingKey() throws IOException {
groupingKey = PushGateway.instanceIPGroupingKey();
Expand Down

0 comments on commit f09c46b

Please sign in to comment.