Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
feat: Added a chart to display global Health Check average\nThis closes
Browse files Browse the repository at this point in the history
  • Loading branch information
aelamrani committed Dec 10, 2017
1 parent 79a0239 commit 5819605
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 5 deletions.
Expand Up @@ -23,18 +23,18 @@ public class Data {

private final long timestamp;

private final long count;
private final Number value;

public Data(long timestamp, long count) {
public Data(long timestamp, Number value) {
this.timestamp = timestamp;
this.count = count;
this.value = value;
}

public long timestamp() {
return timestamp;
}

public long count() {
return count;
public Number value() {
return value;
}
}
Expand Up @@ -15,6 +15,8 @@
*/
package io.gravitee.repository.healthcheck.query;

import io.gravitee.repository.analytics.query.TimeRangeFilter;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
Expand All @@ -23,6 +25,8 @@ public abstract class AbstractQuery<T extends Response> implements Query<T> {

private RootFilter rootFilter;

private TimeRangeFilter timeRangeFilter;

private QueryFilter queryFilter;

public RootFilter root() {
Expand All @@ -33,6 +37,14 @@ void root(RootFilter rootFilter) {
this.rootFilter = rootFilter;
}

public TimeRangeFilter timeRange() {
return timeRangeFilter;
}

void timeRange(TimeRangeFilter timeRangeFilter) {
this.timeRangeFilter = timeRangeFilter;
}

public QueryFilter query() {
return queryFilter;
}
Expand Down
Expand Up @@ -15,6 +15,10 @@
*/
package io.gravitee.repository.healthcheck.query;

import io.gravitee.repository.analytics.query.DateRange;
import io.gravitee.repository.analytics.query.Interval;
import io.gravitee.repository.analytics.query.TimeRangeFilter;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
Expand All @@ -40,9 +44,22 @@ public QB query(String query) {
return (QB) this;
}

public QB timeRange(DateRange dateRange, Interval interval) {
this.query.timeRange(new TimeRangeFilter(dateRange, interval));
return (QB) this;
}

public QB api(String api) {
this.query.root(new RootFilter("api", api));

return (QB) this;
}

public QB root(String field, String id) {
if (field != null && id != null) {
this.query.root(new RootFilter(field, id));
}

return (QB) this;
}
}
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.healthcheck.query;

import io.gravitee.repository.analytics.query.Aggregation;
import io.gravitee.repository.healthcheck.query.response.histogram.DateHistogramResponse;

import java.util.ArrayList;
import java.util.List;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class DateHistogramQuery extends AbstractQuery<DateHistogramResponse> {

private List<Aggregation> aggregations = new ArrayList<>();

@Override
public Class<DateHistogramResponse> responseType() {
return DateHistogramResponse.class;
}

public List<Aggregation> aggregations() {
return aggregations;
}
}
@@ -0,0 +1,55 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.healthcheck.query;

import io.gravitee.repository.analytics.query.Aggregation;
import io.gravitee.repository.analytics.query.AggregationType;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class DateHistogramQueryBuilder extends AbstractQueryBuilder<DateHistogramQueryBuilder, DateHistogramQuery> {

protected DateHistogramQueryBuilder(DateHistogramQuery query) {
super(query);
}

static DateHistogramQueryBuilder query() {
return new DateHistogramQueryBuilder(new DateHistogramQuery());
}

public DateHistogramQueryBuilder aggregation(Aggregation aggregation) {
query.aggregations().add(aggregation);
return this;
}

public DateHistogramQueryBuilder aggregation(AggregationType type, String field) {
query.aggregations().add(new Aggregation() {
@Override
public AggregationType type() {
return type;
}

@Override
public String field() {
return field;
}
});

return this;
}
}
Expand Up @@ -36,4 +36,8 @@ public static AverageResponseTimeQueryBuilder responseTime() {
public static LogsQueryBuilder logs() {
return LogsQueryBuilder.query();
}

public static DateHistogramQueryBuilder dateHistogram() {
return DateHistogramQueryBuilder.query();
}
}
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.healthcheck.query.response.histogram;

import io.gravitee.repository.healthcheck.query.Response;
import io.gravitee.repository.analytics.query.response.histogram.Bucket;

import java.util.ArrayList;
import java.util.List;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class DateHistogramResponse implements Response {

private final List<Long> timestamps = new ArrayList<>();
private final List<Bucket> values = new ArrayList<>();

public List<Bucket> values() {
return values;
}

public List<Long> timestamps() {
return timestamps;
}
}

0 comments on commit 5819605

Please sign in to comment.