Skip to content

Commit

Permalink
Just return 200 on insertion requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Negrea committed Nov 17, 2015
1 parent 335d135 commit d191796
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
51 changes: 27 additions & 24 deletions api/diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1605,17 +1605,20 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
---
> public Response addGaugeData(
> List<Gauge> gauges
256,257c209,214
255,258c208,214
< /*Observable<Metric<Double>> metrics = Gauge.toObservable(tenantId, gauges);
< Observable<Void> observable = metricsService.addDataPoints(GAUGE, metrics);
< observable.subscribe(new ResultSetObserver(asyncResponse));
< observable.subscribe(new ResultSetObserver(asyncResponse));*/
< asyncResponse.resume(Response.ok().build());
---
> Observable<Metric<Double>> metrics = Gauge.toObservable(tenantId, gauges);
> try {
> metricsService.addDataPoints(GAUGE, metrics).toBlocking().lastOrDefault(null);
> return Response.ok().build();
> } catch (Exception e) {
> return serverError(e);
> }
262,274c219
263,275c219
< @ApiOperation(value = "Retrieve gauge data.", notes = "When buckets or bucketDuration query parameter is used, " +
< "the time range between start and end will be divided in buckets of equal duration, and metric statistics" +
< " will be computed for each bucket.", response = GaugeDataPoint.class, responseContainer = "List")
Expand All @@ -1631,7 +1634,7 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
< @Suspended AsyncResponse asyncResponse,
---
> public Response findGaugeData(
276,280c221,226
277,281c221,226
< @ApiParam(value = "Defaults to now - 8 hours") @QueryParam("start") Long start,
< @ApiParam(value = "Defaults to now") @QueryParam("end") Long end,
< @ApiParam(value = "Total number of buckets") @QueryParam("buckets") Integer bucketsCount,
Expand All @@ -1644,17 +1647,17 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
> @QueryParam("bucketDuration") Duration bucketDuration,
> @QueryParam("percentiles") Percentiles percentiles
> ) {
283,284c229
284,285c229
< asyncResponse.resume(badRequest(new ApiError(timeRange.getProblem())));
< return;
---
> return badRequest(new ApiError(timeRange.getProblem()));
288,289c233
289,290c233
< asyncResponse.resume(badRequest(new ApiError(bucketConfig.getProblem())));
< return;
---
> return badRequest(new ApiError(bucketConfig.getProblem()));
294,302c238,257
295,303c238,257
< if (buckets == null) {
< metricsService.findDataPoints(metricId, timeRange.getStart(), timeRange.getEnd())
< .map(GaugeDataPoint::new)
Expand Down Expand Up @@ -1685,7 +1688,7 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
> .map(ApiUtils::collectionToResponse)
> .toBlocking()
> .lastOrDefault(null);
304,308c259,260
305,309c259,260
<
< metricsService.findGaugeStats(metricId, timeRange.getStart(), timeRange.getEnd(), buckets,
< percentiles.getPercentiles())
Expand All @@ -1694,7 +1697,7 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
---
> } catch (Exception e) {
> return serverError(e);
314,338c266,274
315,339c266,274
< @ApiOperation(value = "Find stats for multiple metrics.", notes = "Fetches data points from one or more metrics"
< + " that are determined using either a tags filter or a list of metric names. The time range between " +
< "start and end is divided into buckets of equal size (i.e., duration) using either the buckets or " +
Expand Down Expand Up @@ -1730,58 +1733,58 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
> @QueryParam("percentiles") Percentiles percentiles,
> @QueryParam("metrics") List<String> metricNames,
> @DefaultValue("false") @QueryParam("stacked") Boolean stacked) {
342,343c278
343,344c278
< asyncResponse.resume(badRequest(new ApiError(timeRange.getProblem())));
< return;
---
> return badRequest(new ApiError(timeRange.getProblem()));
347,349c282
348,350c282
< asyncResponse.resume(badRequest(new ApiError(
< "Either the buckets or bucketsDuration parameter must be used")));
< return;
---
> return badRequest(new ApiError("Either the buckets or bucketsDuration parameter must be used"));
352,353c285
353,354c285
< asyncResponse.resume(badRequest(new ApiError(bucketConfig.getProblem())));
< return;
---
> return badRequest(new ApiError(bucketConfig.getProblem()));
356,357c288
357,358c288
< asyncResponse.resume(badRequest(new ApiError("Either metrics or tags parameter must be used")));
< return;
---
> return badRequest(new ApiError("Either metrics or tags parameter must be used"));
360,361c291
361,362c291
< asyncResponse.resume(badRequest(new ApiError("Cannot use both the metrics and tags parameters")));
< return;
---
> return badRequest(new ApiError("Cannot use both the metrics and tags parameters"));
369,370c299,302
370,371c299,302
< metricsService.findNumericStats(tenantId, MetricType.GAUGE, tags.getTags(), timeRange.getStart(),
< timeRange.getEnd(), bucketConfig.getBuckets(), percentiles.getPercentiles(), stacked)
---
> return metricsService
> .findNumericStats(tenantId, MetricType.GAUGE, tags.getTags(), timeRange.getStart(),
> timeRange.getEnd(),
> bucketConfig.getBuckets(), percentiles.getPercentiles(), stacked)
372c304,305
373c304,305
< .subscribe(asyncResponse::resume, t -> asyncResponse.resume(ApiUtils.serverError(t)));
---
> .toBlocking()
> .lastOrDefault(null);
374,375c307,309
375,376c307,309
< metricsService.findNumericStats(tenantId, MetricType.GAUGE, metricNames, timeRange.getStart(),
< timeRange.getEnd(), bucketConfig.getBuckets(), percentiles.getPercentiles(), stacked)
---
> return metricsService
> .findNumericStats(tenantId, MetricType.GAUGE, metricNames, timeRange.getStart(),
> timeRange.getEnd(), bucketConfig.getBuckets(), percentiles.getPercentiles(), stacked)
377c311,312
378c311,312
< .subscribe(asyncResponse::resume, t -> asyncResponse.resume(ApiUtils.serverError(t)));
---
> .toBlocking()
> .lastOrDefault(null);
383,391c318
384,392c318
< @ApiOperation(value = "Find condition periods.", notes = "Retrieve periods for which the condition holds true for" +
< " each consecutive data point.", response = List.class)
< @ApiResponses(value = {
Expand All @@ -1793,22 +1796,22 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
< @Suspended final AsyncResponse asyncResponse,
---
> public Response findPeriods(
393,395c320,321
394,396c320,321
< @ApiParam(value = "Defaults to now - 8 hours", required = false) @QueryParam("start") Long start,
< @ApiParam(value = "Defaults to now", required = false) @QueryParam("end") Long end,
< @ApiParam(value = "A threshold against which values are compared", required = true)
---
> @QueryParam("start") final Long start,
> @QueryParam("end") final Long end,
397,398d322
398,399d322
< @ApiParam(value = "A comparison operation to perform between values and the threshold.", required = true,
< allowableValues = "ge, gte, lt, lte, eq, neq")
403,404c327
404,405c327
< asyncResponse.resume(badRequest(new ApiError(timeRange.getProblem())));
< return;
---
> return badRequest(new ApiError(timeRange.getProblem()));
432,437c355,356
433,438c355,356
< asyncResponse.resume(badRequest(
< new ApiError(
< "Invalid value for op parameter. Supported values are lt, "
Expand All @@ -1818,7 +1821,7 @@ diff -r '--exclude-from=api/diff-excludes' api/metrics-api-jaxrs/src/main/java/o
---
> return badRequest(
> new ApiError("Invalid value for op parameter. Supported values are lt, lte, eq, gt, gte."));
439,442c358,365
440,443c358,365
< MetricId<Double> metricId = new MetricId<>(tenantId, GAUGE, id);
< metricsService.getPeriods(metricId, predicate, timeRange.getStart(), timeRange.getEnd())
< .map(ApiUtils::collectionToResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ public void addGaugeData(
@Suspended final AsyncResponse asyncResponse,
@ApiParam(value = "List of metrics", required = true) List<Gauge> gauges
) {
Observable<Metric<Double>> metrics = Gauge.toObservable(tenantId, gauges);
/*Observable<Metric<Double>> metrics = Gauge.toObservable(tenantId, gauges);
Observable<Void> observable = metricsService.addDataPoints(GAUGE, metrics);
observable.subscribe(new ResultSetObserver(asyncResponse));
observable.subscribe(new ResultSetObserver(asyncResponse));*/
asyncResponse.resume(Response.ok().build());
}

@GET
Expand Down

0 comments on commit d191796

Please sign in to comment.