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

Add latency metrics for DiscoverPollEndpoint and ACS #4454

Closed
wants to merge 7 commits into from

Conversation

chacheng21
Copy link

Summary

Adding new metrics and variables in acs session

Implementation details

Added new metrics and variables in acs session for StartSessionOnce

Testing

Tested by running all unit tests in acs

New tests cover the changes:
No new tests, but modified existing tests to account for new metrics (ie mocked the calls to create metrics)

Description for the changelog

Enhancement - add metrics to monitor latency in acs session

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?
No

Does this PR include the addition of new environment variables in the README?
No

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@chacheng21 chacheng21 requested a review from a team as a code owner December 12, 2024 23:12
@@ -776,6 +782,7 @@ func (client *ecsClient) discoverPollEndpoint(containerInstanceArn string,
}
return nil, err
}
client.metricsFactory.New(metrics.DiscoverPollEndpointDurationName).WithGauge(time.Since(discoverPollEndpointStartTime)).Done(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Besides this gauge metric, can we emit one more counter metric to monitor if the discoverPollEndpoint call is successful or not?

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good, think this will be a good addition to get more insights into DiscoverPollEndpoint()

// WithMetricsFactory is an ECSClientOption that configures
// ecsClient.metricsFactory with the value passed as a parameter.
// This is especially useful for emitting metrics in the ECS Client
func WithMetricsFactory(metricsFactory metrics.EntryFactory) ECSClientOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -262,8 +271,13 @@ func (s *session) startSessionOnce(ctx context.Context) error {
})
return err
}
acsConnectionMetric.Done(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

withGauge?

Copy link
Contributor

Choose a reason for hiding this comment

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

And besides the duration metric, can we also have a counter metric for this?

Copy link
Author

Choose a reason for hiding this comment

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

withGauge()is used to add any value to a given metric - useful when we want to add info to a metric outside of what's already provided (ie startTime, metric name, etc.)

Copy link
Author

Choose a reason for hiding this comment

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

what's the purpose for the counter metric?

@@ -46,6 +46,11 @@ const (
ACSDisconnectTimeoutMetricName = agentAvailabilityNamespace + ".ACSDisconnectTimeout"
TCSDisconnectTimeoutMetricName = agentAvailabilityNamespace + ".TCSDisconnectTimeout"

// ACS Session Metrics
acsStartSessionNamespace = "ACSStartSession"
DiscoverPollEndpointDurationName = acsStartSessionNamespace + ".DiscoverPollEndpointDuration"
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 use a different namespace/prefix for this DiscoverPollEndpointDurationName? because discoverPollEndpoint is not for ACS only.

Copy link
Author

Choose a reason for hiding this comment

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

oh right yes good point ill go ahead and change that


// WithMetricsFactory is an ECSClientOption that configures
// ecsClient.metricsFactory with the value passed as a parameter.
// This is especially useful for emitting metrics in the ECS Client

Choose a reason for hiding this comment

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

nit. Comments end with period.


mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSStartSession.ACSConnectEndpointDuration").Return(mockACSConnectEndpointEntry).AnyTimes()

Choose a reason for hiding this comment

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

nit. Import the metric instead of hard-coding it.

isaac-400
isaac-400 previously approved these changes Dec 16, 2024
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.

4 participants