-
Notifications
You must be signed in to change notification settings - Fork 7
Add metric health schema to Entities #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
implements MetricContainer { | ||
|
||
private final Map<Duration, List<MetricInterval>> metricSeriesMap; | ||
|
||
ConvertedMetricContainer( | ||
Map<MetricLookupMapKey, MetricAggregation> metricAggregationMap, | ||
Map<MetricLookupMapKey, BaselineMetricAggregation> metricAggregationMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaselineMetricAggregation implies something totally different from the existing MetricAggregation. Are you sure you want to do a replace/rename instead of an augmentation to the existing users of MetricAggregation with a different object of the type BaselineMetricAggregation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tim-mwangi I didn't understand. Can you please illustrate more ?
...java/org/hypertrace/graphql/utils/metrics/gateway/BaselineConvertedAggregationContainer.java
Outdated
Show resolved
Hide resolved
hypertrace-graphql-metric-schema/src/main/java/org/hypertrace/graphql/metric/schema/Health.java
Outdated
Show resolved
Hide resolved
...metric-schema/src/main/java/org/hypertrace/graphql/metric/schema/BaselineMetricInterval.java
Outdated
Show resolved
Hide resolved
...a/src/main/java/org/hypertrace/graphql/metric/schema/BaselineMetricAggregationContainer.java
Outdated
Show resolved
Hide resolved
...ric-schema/src/main/java/org/hypertrace/graphql/metric/schema/BaselineMetricAggregation.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricContainerMapConverter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricContainerMapConverter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricContainerMapConverter.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricAggregationMapConverter.java
Outdated
Show resolved
Hide resolved
...s/src/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricAggregationConverter.java
Outdated
Show resolved
Hide resolved
@tim-mwangi @aaron-steinfeld thanks for the quick review. This patch is not complete it needs refactoring i should have updated description well, i have just updated just to verify with you guys regarding schema changes. Since generics is not supported in graphql so want to check whether schema changes fine or not. |
Just to clarify, generics can be used (and should be, for enforcing keeping objects in sync) - they just need to be reified in child interfaces so the reflection code can find the appropriate types. |
* updates release workflow and gradle plugin versio * clean up * indentation * executor name * executor name * Update .circleci/config.yml Co-authored-by: Aaron Steinfeld <[email protected]> Co-authored-by: Aaron Steinfeld <[email protected]>
@aaron-steinfeld Please review the implementation and API changes. Some minor things pending will address along with review comments. Not able to find placeholder to calculate Health to metrics, please suggest the right place. |
...ic-schema/src/main/java/org/hypertrace/graphql/metric/schema/BaselinedMetricAggregation.java
Outdated
Show resolved
Hide resolved
...e-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/EntityDaoModule.java
Outdated
Show resolved
Hide resolved
...hema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityRequestBuilder.java
Outdated
Show resolved
Hide resolved
...s/src/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricAggregationConverter.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/hypertrace/graphql/utils/metrics/gateway/BaselineIntervalListContainer.java
Outdated
Show resolved
Hide resolved
private final MetricBaselineAggregationConverter baselineAggregationConverter; | ||
|
||
@Inject | ||
BaselineIntervalListContainer(MetricBaselineAggregationConverter baselineAggregationConverter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like mostly copy paste from the existing interval list converter - how much of the logic could be shared? I expect most of it could go in a base class that is just parameterized with the specific impementation builders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will raise a jira and do this refactoring later.
this.endTime = intervalTimeRange.getEndTime(); | ||
} | ||
|
||
// TODO Fix this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assume this is due to the null below?
...rc/main/java/org/hypertrace/graphql/utils/metrics/gateway/BaselineIntervalListContainer.java
Outdated
Show resolved
Hide resolved
public Single<Map<Duration, List<BaselineMetricInterval>>> convert( | ||
List<MetricSeriesRequest> metricSeriesRequests, | ||
Map<String, BaselineMetricSeries> baselineMetricSeriesMap) { | ||
return Observable.fromIterable(metricSeriesRequests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as intervallist, this looks like copy paste that could be shared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i said earlier will do refactoring in next iteration since it already became big patch.
Lots of comments, many of them nit/style. Can we please first format this code with google style (in 1 standalone commit), then merge in main (again standalone), then fix any compilation issues, since it's not even running in CI and I'm fairly sure it won't compile as is. As to health, my recommendation would be to omit it (from the schema as well as the implementation). We need to be far more iterative with this, and we can easily add health in a later round - the scope of this is already very large and difficult to review. |
My 2p in here. Could we add a GH action checking this by default? That way we avoid unrelated changes in PRs due to formatting. cc @JBAhire
Yes please, this PR is already big. Maybe it is easier to break it up in small PRs? Otherwise reviewing this is almost impossible and it is easy to make mistakes. Please consider either merge smaller PRs against |
Compilation issues are because it depends on gateway-service which is not merged yet. |
Will incorporate this. Thanks @jcchavezs :) |
@jcchavezs We can divide this PR into API and implementation, but API part is small compared to implementation. From next time i will try to push small PR's, if possible |
…rtrace-graphql into master/feature/healthapi
} | ||
} | ||
|
||
static class MetricBaselineAggregationDefaultInstance implements MetricBaselineAggregation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaron-steinfeld Please suggest if this can be improved further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion would be to remove the default one - if Baseline
is null, convert should not be called, since that indicates no baseline object was either requested or returned from the server. The behavior I'd expect for null responses for requested data is described below.
Also to make MetricBaselineAggregationImpl
a simple value class like most of our converted classes, handling the unpacking of it in the converter itself rather than the value class.
Example:
@lombok.Value
@Accessors(fluent = true)
private static class MetricBaselineAggregationImpl implements MetricBaselineAggregation {
Double value;
Double lowerBound;
Double upperBound;
}
In terms of nulls, we want the following behavior:
if I request an aggregation, but there's no data in the time range (this can only happen in the recently added, time agnostic mode):
// Request
sum {
value
}
// No data response
{
sum: {
value: null
}
}
Extending that to baselines, I'd expect:
sum {
value
baseline {
value
lowerBound
upperBound
}
}
// No baseline response
{
sum: {
value: 42
baseline: null // the object, not the contents
}
}
@aaron-steinfeld I have updated all comments. Please review. |
...ty-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityConverter.java
Outdated
Show resolved
Hide resolved
.flatMap(baselineRequest -> baselineProvider.makeRequest(request.resultSetRequest().context(), baselineRequest)) | ||
.flatMap(baselineResponse -> this.entityConverter.convert(request, serverResponse, baselineResponse)))); | ||
.flatMap( | ||
serverRequest -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, it's not a ton of complexity (although triconverter doesn't appear to be defined anywhere in this PR, one of the reasons it doesn't compile), it just saves a level of nesting here. The reason the nesting is required is we're doing one operation at a time but not carrying the previous results with us - so using a result container both saves nesting and removes the need for the new converter interface. It's not required, but I do think it would be nice to remove the nesting one way or another to improve readability. Another way of doing that is just breaking out the calls into different methods rather than doing them inline. For example, creating a new method like makeBaselineAndEntityRequests
...c-schema/src/main/java/org/hypertrace/graphql/metric/request/MetricSeriesRequestBuilder.java
Outdated
Show resolved
Hide resolved
...ce-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/health/BaselineDao.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
static class MetricBaselineAggregationDefaultInstance implements MetricBaselineAggregation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion would be to remove the default one - if Baseline
is null, convert should not be called, since that indicates no baseline object was either requested or returned from the server. The behavior I'd expect for null responses for requested data is described below.
Also to make MetricBaselineAggregationImpl
a simple value class like most of our converted classes, handling the unpacking of it in the converter itself rather than the value class.
Example:
@lombok.Value
@Accessors(fluent = true)
private static class MetricBaselineAggregationImpl implements MetricBaselineAggregation {
Double value;
Double lowerBound;
Double upperBound;
}
In terms of nulls, we want the following behavior:
if I request an aggregation, but there's no data in the time range (this can only happen in the recently added, time agnostic mode):
// Request
sum {
value
}
// No data response
{
sum: {
value: null
}
}
Extending that to baselines, I'd expect:
sum {
value
baseline {
value
lowerBound
upperBound
}
}
// No baseline response
{
sum: {
value: 42
baseline: null // the object, not the contents
}
}
.../src/main/java/org/hypertrace/graphql/utils/metrics/gateway/MetricContainerMapConverter.java
Outdated
Show resolved
Hide resolved
import org.hypertrace.graphql.metric.schema.BaselineMetricInterval; | ||
import org.hypertrace.graphql.metric.schema.BaselinedMetricAggregation; | ||
import org.hypertrace.graphql.metric.schema.MetricBaselineAggregation; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be no gap in imports - please use the google formatter and update your IDE! We should enforce this in CI too, but all of our projects follow the same formatter regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes did that sometime back, even though i formatted entire code using google formatter, it didnt deleted that gap. Anyway i am deleting myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm - did you use the intellij format config or the plugin? I know the format file isn't able to capture the full style, the plugin might have shortcomings too - I use both, but that feels excessive. We'll revisit this with the push to enforce this in CI (and maybe add a gradle task)
...a/src/main/java/org/hypertrace/graphql/metric/schema/BaselineMetricAggregationContainer.java
Outdated
Show resolved
Hide resolved
...metric-schema/src/main/java/org/hypertrace/graphql/metric/schema/BaselineMetricInterval.java
Outdated
Show resolved
Hide resolved
...n/java/org/hypertrace/graphql/utils/metrics/gateway/BaselineMetricIntervalListContainer.java
Outdated
Show resolved
Hide resolved
@aaron-steinfeld I have addressed all your comments, only thing pending is removing nesting inline in GatewayServiceEntityDao which can be done in next iteration. UI team is already blocked on this. Lets push this, but before that we should merge hypertrace/hypertrace-core-graphql#43 |
I have updated core-graphql still it is showing conflicts. |
|
||
@Override | ||
public Double value() { | ||
return metricAggregation.value(); | ||
public MetricBaselineAggregation baseline() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two methods shouldn't be needed with the lombok annotations above
public Double value() { | ||
return null; | ||
} | ||
static final MetricBaselineAggregation EMPTY = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this would end up with null values rather than a null baseline object - we can go with that and revisit
You'll need to rebase this repo off main, then update core-graphql. Once that's done, I think we're good at a good iteration point. |
…master/feature/healthapi
Codecov Report
@@ Coverage Diff @@
## main #50 +/- ##
=========================================
Coverage 80.55% 80.55%
Complexity 2 2
=========================================
Files 2 2
Lines 36 36
=========================================
Hits 29 29
Misses 7 7
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
@aaron-steinfeld All checks have passed. |
Add baseline for metrics for entities
Description
Baseline, lower bound and upper bound values for entity metrics and used gateway service implementation.
Testing
Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.
Checklist:
Documentation
Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.