Skip to content

Commit ec4105c

Browse files
authored
Add an ISMV3 compatible HTTP source. (#165)
1 parent fda35ea commit ec4105c

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/main/java/com/arpnetworking/http/Routes.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.arpnetworking.metrics.Units;
4343
import com.arpnetworking.metrics.common.sources.ClientHttpSourceV1;
4444
import com.arpnetworking.metrics.common.sources.ClientHttpSourceV2;
45+
import com.arpnetworking.metrics.common.sources.ClientHttpSourceV3;
4546
import com.arpnetworking.metrics.common.sources.CollectdHttpSourceV1;
4647
import com.arpnetworking.metrics.common.sources.PrometheusHttpSource;
4748
import com.arpnetworking.metrics.incubator.PeriodicMetrics;
@@ -217,6 +218,8 @@ private CompletionStage<HttpResponse> process(final HttpRequest request) {
217218
} else if (Objects.equals(HttpMethods.POST, request.method())) {
218219
if (Objects.equals(path, COLLECTD_V1_SOURCE_PREFIX)) {
219220
return dispatchHttpRequest(request, ACTOR_COLLECTD_V1);
221+
} else if (Objects.equals(path, APP_V3_SOURCE_PREFIX)) {
222+
return dispatchHttpRequest(request, ACTOR_APP_V3);
220223
} else if (Objects.equals(path, APP_V2_SOURCE_PREFIX)) {
221224
return dispatchHttpRequest(request, ACTOR_APP_V2);
222225
} else if (Objects.equals(path, APP_V1_SOURCE_PREFIX)) {
@@ -350,10 +353,12 @@ private String createMetricName(final HttpRequest request, final String actionPa
350353
private static final String COLLECTD_V1_SOURCE_PREFIX = "/metrics/v1/collectd";
351354
private static final String APP_V1_SOURCE_PREFIX = "/metrics/v1/application";
352355
private static final String APP_V2_SOURCE_PREFIX = "/metrics/v2/application";
356+
private static final String APP_V3_SOURCE_PREFIX = "/metrics/v3/application";
353357
private static final String PROMETHEUS_SOURCE_PREFIX = "/metrics/prometheus";
354358
private static final String ACTOR_COLLECTD_V1 = "/user/" + CollectdHttpSourceV1.ACTOR_NAME;
355359
private static final String ACTOR_APP_V1 = "/user/" + ClientHttpSourceV1.ACTOR_NAME;
356360
private static final String ACTOR_APP_V2 = "/user/" + ClientHttpSourceV2.ACTOR_NAME;
361+
private static final String ACTOR_APP_V3 = "/user/" + ClientHttpSourceV3.ACTOR_NAME;
357362
private static final String ACTOR_PROMETHEUS = "/user/" + PrometheusHttpSource.ACTOR_NAME;
358363
private static final String REST_SERVICE_METRIC_ROOT = "rest_service/";
359364
private static final String BODY_SIZE_METRIC = "body_size";
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2019 Dropbox
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.arpnetworking.metrics.common.sources;
17+
18+
import com.arpnetworking.metrics.mad.parsers.ProtobufV3ToRecordParser;
19+
20+
/**
21+
* Processes HTTP requests from the metrics client, extracts data and emits metrics.
22+
*
23+
* @author Ville Koskela (ville dot koskela at inscopemetrics dot io)
24+
*/
25+
public final class ClientHttpSourceV3 extends HttpSource {
26+
27+
/**
28+
* Protected constructor.
29+
*
30+
* @param builder Instance of {@link Builder}.
31+
*/
32+
private ClientHttpSourceV3(final Builder builder) {
33+
super(builder);
34+
}
35+
36+
/**
37+
* Name of the actor created to receive the HTTP Posts.
38+
*/
39+
public static final String ACTOR_NAME = "appv3";
40+
41+
/**
42+
* ClientHttpSourceV3 {@link BaseSource.Builder} implementation.
43+
*
44+
* @author Ville Koskela (ville dot koskela at inscopemetrics dot io)
45+
*/
46+
public static final class Builder extends HttpSource.Builder<Builder, ClientHttpSourceV3> {
47+
/**
48+
* Public constructor.
49+
*/
50+
public Builder() {
51+
super(ClientHttpSourceV3::new);
52+
setActorName(ACTOR_NAME);
53+
setParser(new ProtobufV3ToRecordParser());
54+
}
55+
56+
@Override
57+
protected Builder self() {
58+
return this;
59+
}
60+
}
61+
62+
}

0 commit comments

Comments
 (0)