Skip to content

Commit

Permalink
Change ACS metric name
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Cheng committed Feb 26, 2025
1 parent 41e95e2 commit d7eaf01
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ecs-agent/acs/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (s *session) startSessionOnce(ctx context.Context) error {
s.disconnectJitter)

// Metric created for determining whether ACS connection is successful or not
s.metricsFactory.New(metrics.ACSSessionCallName).Done(err)
s.metricsFactory.New(metrics.ACSSessionFailureCallName).Done(err)
if err != nil {
logger.Error("Failed to connect to ACS", logger.Fields{
"containerInstanceARN": s.containerInstanceARN,
Expand Down
22 changes: 11 additions & 11 deletions ecs-agent/acs/session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestSessionReconnectsOnConnectErrors(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestSessionReconnectsWithoutBackoffOnEOFError(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestSessionReconnectsWithBackoffOnNonEOFError(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -485,7 +485,7 @@ func TestSessionCallsInactiveInstanceCB(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -552,7 +552,7 @@ func TestSessionReconnectDelayForInactiveInstanceError(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -624,7 +624,7 @@ func TestSessionReconnectsOnServeErrors(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -685,7 +685,7 @@ func TestSessionStopsWhenContextIsCanceled(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).AnyTimes()
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).AnyTimes()

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -742,7 +742,7 @@ func TestSessionStopsWhenContextIsErrorDueToTimeout(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any())
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry)

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -795,7 +795,7 @@ func TestSessionReconnectsOnDiscoverPollEndpointError(t *testing.T) {

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any())
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry)

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectDuration").Return(mockACSConnectDurationEndpointEntry).AnyTimes()
Expand Down Expand Up @@ -868,7 +868,7 @@ func TestConnectionIsClosedOnIdle(t *testing.T) {
mockMetricsFactory := mock_metrics.NewMockEntryFactory(ctrl)

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any())

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
Expand Down Expand Up @@ -1127,7 +1127,7 @@ func TestSessionCorrectlySetsSendCredentials(t *testing.T) {
mockMetricsFactory := mock_metrics.NewMockEntryFactory(ctrl)

mockACSConnectEndpointEntry := mock_metrics.NewMockEntry(ctrl)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnect").Return(mockACSConnectEndpointEntry).Times(10)
mockMetricsFactory.EXPECT().New("ACSSession.ACSConnectFailure").Return(mockACSConnectEndpointEntry).Times(10)
mockACSConnectEndpointEntry.EXPECT().Done(gomock.Any()).Times(10)

mockACSConnectDurationEndpointEntry := mock_metrics.NewMockEntry(ctrl)
Expand Down
2 changes: 1 addition & 1 deletion ecs-agent/metrics/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (

// ACS Session Metrics
acsSessionNamespace = "ACSSession"
ACSSessionCallName = acsSessionNamespace + ".ACSConnect"
ACSSessionFailureCallName = acsSessionNamespace + ".ACSConnectFailure"
ACSSessionCallDurationName = acsSessionNamespace + ".ACSConnectDuration"

// ECS Client Metrics
Expand Down

0 comments on commit d7eaf01

Please sign in to comment.