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

enhancement: user agent 2.1 #3001

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yenfryherrerafeliz
Copy link
Contributor

This change provides:

  • A builder class for appending metrics
  • Default initialization of a metrics builder within command instantiation
  • Wraps user agent logic into a single middleware class
  • Adds middlewares into the different features from where metrics can be gather, to acomplish this purpose.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This change provides:
- A builder class for appending metrics
- Default initialization of a metrics builder within command instantiation
- Wraps user agent logic into a single middleware class
- Adds middlewares into the different features from where metrics can be gather, to acomplish this purpose.
Copy link
Member

@stobrien89 stobrien89 left a comment

Choose a reason for hiding this comment

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

Just an initial pass- had a few comments

@@ -280,6 +280,11 @@ public function __construct(array $args)
if (isset($args['with_resolved'])) {
$args['with_resolved']($config);
}
MetricsBuilder::appendMetricsCaptureMiddleware(
Copy link
Member

Choose a reason for hiding this comment

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

question: do we need to add this (or other static/guaranteed metrics) to our middleware stack?

@@ -490,6 +497,11 @@ private function addSignatureMiddleware(array $args)
$region = $signingRegionSet
?? $commandSigningRegionSet
?? $region;

MetricsBuilder::appendMetricsCaptureMiddleware(
Copy link
Member

Choose a reason for hiding this comment

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

question: This function is invoked during the sign step. How is the signature version being passed to the metrics builder by appending middleware to the build step, which has already completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Metrics here will not be collected. I will do a refactor for this type of cases.

@@ -394,4 +402,23 @@ private function resolveAccountId(): ?string

return $identity->getAccountId();
}

private function hookAccountIdMetric($accountId, &$command)
Copy link
Member

Choose a reason for hiding this comment

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

question: can we make a generic method on the MetricsBuilder class that will handle this and other things like it i.e. accountidendpointmetric?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can take a look and see if it fits better there.

src/MetricsBuilder.php Show resolved Hide resolved
}

/**
* Appends a metric into the internal metrics holder.
Copy link
Member

Choose a reason for hiding this comment

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

nit: can this and other longer docblocks be shortened?

src/MetricsBuilder.php Show resolved Hide resolved
src/UserAgentMiddleware.php Show resolved Hide resolved
*/
private function buildUserAgentValue(): array
{
static $fnList = [
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: consider moving to a static property if it could possibly be used by anything else

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.

2 participants