Skip to content
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

Adaptive Load metrics evaluator library #495

Merged
merged 61 commits into from
Sep 10, 2020

Conversation

eric846
Copy link
Contributor

@eric846 eric846 commented Aug 27, 2020

A library that combines the latest Nighthawk Service response, metric and threshold spec configuration, and results from MetricsPlugins to produce metric scores.

Part 5 of splitting PR #483.

eric846 added 30 commits June 1, 2020 17:23
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
…ent.Output turns out not to include the status

Signed-off-by: eric846 <[email protected]>
…plugin names, log thresholds only once per session

Signed-off-by: eric846 <[email protected]>
Signed-off-by: eric846 <[email protected]>
*/
virtual void
ExtractMetricSpecs(const nighthawk::adaptive_load::AdaptiveLoadSessionSpec& spec,
std::vector<const nighthawk::adaptive_load::MetricSpec*>& metric_specs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, could we not just return the map, and retrieve the keys specifically if we need that? I also don't like having two separate data structures that are supposed to be in sync with each other implicitly.

return response;
}

TEST(EvaluateMetric, SetsMetricId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we prefer the ConditionAWillResultinB format for naming these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more detail throughout.

@eric846 eric846 added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Sep 3, 2020
Copy link
Member

@oschaaf oschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great to me, one last question regarding the return type of ExtractMetricSpecs

metric_spec_list_map.second;

std::vector<std::string> errors;
for (const MetricSpec* metric_spec : metric_specs) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this, I'm still wondering; it seems to me that having ExtractMetricSpecs return a vector<std::pair<MetricSpec*, ThresholdSpec*>> could simplify that interface as well as the code here; wouldn't that avoid the map lookups? The map usage would be in implementation detail in ExtractMetricSpecs, and not propagate outside of it. Of course, that might thwart re-use for other purposes perhaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a good idea, it preserves the order and is simpler. I definitely don't need the map. If someone did need a map later, I think they could pass the vector of pairs into a map constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now to return a vector of pairs.

oschaaf
oschaaf previously approved these changes Sep 8, 2020
Copy link
Member

@oschaaf oschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wjuan-AFK
Copy link
Contributor

LGTM

wjuan-AFK
wjuan-AFK previously approved these changes Sep 8, 2020
namespace Nighthawk {

/**
* An interface with utilities for translating between metrics definitions, thresholds, scores,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a usage example here? I have other confusions about the API here, but if you feel like your example will resolve them, feel free to ignore other points.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a better explanation of what this library does. Only one of the methods is expected to be called directly.

* it according to a threshold and scoring function.
*
* @param metric_spec The metric spec identifying the metric by name and plugin name.
* @param metrics_plugin An already activated MetricsPlugin used by the metric_spec.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word activated here is confusing to me. I'm not sure it means: Two questions:

  1. Would someone using this file usually already know what this means, making this less of a concern?
  2. Is the fact that the plugin would already need to be "activated" more or less obvious if you know what it means, making this over-specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped that wording, it should be clearer now.


/**
* Given a MetricSpec, obtains a single metric value from the MetricPlugin and optionally scores
* it according to a threshold and scoring function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be easier to follow if we said according to a ThresholdSpec. Then one would look for the threshold spec in the parameters, and see that it is a threshold with a scoring function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

namespace Nighthawk {

/**
* An interface with utilities for translating between metrics definitions, thresholds, scores,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems to be focused on what it works with, rather than what it actually does? It's possible this will be obvious after the usage is included, but can we try to clarify its purpose if not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be clearer now.


/**
* Analyzes a Nighthawk Service benchmark against configured MetricThresholds. Queries
* outside MetricsPlugins for current metric values, and/or uses "nighthawk.builtin" plugin to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These feel like implementation details to me.

Is nighthawk.builtin a MetricsPlugin? If so, I don't think this sentence ("Queries outside MetricsPlugins") is necessary. The documentation for nighthawk.builtin should rest within that plugin itself, and this would imply we only have one internal MetricsPlugin, which I don't think is a good assumption to make for the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping this discussion of the builtin plugin. Mentioned the nighthawk.builtin in some of the parameter descriptions.

* Analyzes a Nighthawk Service benchmark against configured MetricThresholds. Queries
* outside MetricsPlugins for current metric values, and/or uses "nighthawk.builtin" plugin to
* extract stats and counters from the latest Nighthawk Service output. The Nighthawk benchmark is
* assumed to have finished recently so values from MetricsPlugins will be relevant.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this, I think it might be better phrased as the following. (Please feel free to edit or push back):
Assumes that the values from MetricsPlugins correspond timewise with the nighthawk benchmark.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @param nighthawk_response Proto returned from Nighthawk Service describing the latest single
* benchmark session.
* @param spec Top-level proto defining the adaptive load session.
* @param name_to_custom_metrics_plugin_map Common map from plugin names to MetricsPlugins, loaded
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second clause of this is describing what the caller does, right? I don't think we should be documenting the calling code from this function. (What if it's called by something else in the future, especially since this is an interface, rather than the impl file)

If there are constraints around this, it might be better to describe it from this function's perspective:
"Should not change between calls within one adaptive load session."

But if that's a constraint here, that sounds like an architectural oddity I'd have questions about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, dropped the information about how the caller operates and and added a description of the true constraints.

@dubious90 dubious90 added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Sep 9, 2020
Signed-off-by: eric846 <[email protected]>
@eric846 eric846 dismissed stale reviews from wjuan-AFK and oschaaf via edc82db September 9, 2020 22:55
@eric846 eric846 added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Sep 9, 2020
@dubious90 dubious90 merged commit 5fd7305 into envoyproxy:master Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-review A PR waiting for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants