Skip to content

Full POC for metrics system #1844

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

Closed
wants to merge 1 commit into from
Closed

Conversation

dagnir
Copy link
Contributor

@dagnir dagnir commented May 15, 2020

POC of the metrics system for V2 incorporating the feedback from @bmaizels and @millems. Includes the metrics SPI, default implementations of these classes, and wiring up the metrics into an API call (for XML protocols).

/**
* An immutable collection of metrics.
*/
public interface MetricCollection extends Iterable<MetricRecord<?>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

SdkIterable?

* A specific SDK metric
* @param <T>
*/
public final class SdkMetric<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any way we can reuse some of the logic from AttributeMap.Key for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, these are modeled after AttributeMap.Key, so it should be possible

* @param <T>
*/
public final class SdkMetric<T> {
private static final Set<SdkMetric<?>> SDK_METRICS = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1

Comment on lines +87 to +94
@Override
public void close() {
if (closed) return;

children.forEach(MetricCollector::close);

this.closed = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't really do anything, except prevent publish from getting called, right? Do we really need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, mostly premature optimization. I wanted to prevent cases where the whole tree is traversed unnecessarily.

Comment on lines +21 to +25
public DefaultMetricCollection(String name, Map<SdkMetric<?>, List<MetricRecord<?>>> metrics, Collection<MetricCollection> children) {
this.name = name;
this.metrics = metrics;
this.children = children != null ? Collections.unmodifiableCollection(children) : Collections.emptyList();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be clear in the Javadoc that we're not doing copies of these inputs, since in other places we do that.

Comment on lines +57 to +60
@Override
public Collection<MetricCollection> children() {
return children;
}
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 do a List, so that it's ordered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I think that could be valuable

Comment on lines +45 to +52
/**
* This is an umbrella category (provided for convenience) that records metrics belonging to every category
* defined in this enum. Clients who wish to collect lot of SDK metrics data should use this.
* <p>
* Note: Enabling this option is verbose and can be expensive based on the platform the metrics are uploaded to.
* Please make sure you need all this data before using this category.
*/
ALL("all")
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like we have to treat "all" magically. Can't we just do MetricCategory.values() to get all of them?

@dagnir dagnir closed this May 20, 2020
aws-sdk-java-automation pushed a commit that referenced this pull request Nov 18, 2021
ignoring kinesis test that fails during release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants