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

Fix prometheus port (#1078) and add unit test for opentelemetry (#1088) #1093

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

tiationg-kho
Copy link
Contributor

Fix prometheus port (#1078) and add unit test for opentelemetry (#1088)

**Issue #, if available:
#1078
#1088

Description of changes:

  • When enablePrometheusServer config is false, we will not open the port
  • Add unit test for pkg/observability/opentelemetry.go file

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

@tiationg-kho tiationg-kho requested a review from a team as a code owner November 28, 2024 01:02
Lu-David
Lu-David previously approved these changes Dec 5, 2024
Copy link
Contributor

@Lu-David Lu-David left a comment

Choose a reason for hiding this comment

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

Overall lgtm! Just some small comments

conn, err = net.DialTimeout("tcp", fmt.Sprintf("localhost:%d", mockClosedPort), time.Second)
if err == nil {
conn.Close()
t.Errorf("server should not listening on port %d: %v", mockClosedPort, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

metrics.NodeActionsInc(mockAction, mockNodeName2, mockEventID2, nil)
metrics.NodeActionsInc(mockAction, mockNodeName3, mockEventID3, errors.New("mockError"))

rr := mockMetricsRequest()
Copy link
Contributor

Choose a reason for hiding this comment

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

What does rr mean? Could we rename to something more specific?

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume request response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by renaming to responseRecorder.


metrics := getMetrics(t)

errorEventLables := []attribute.KeyValue{labelEventErrorWhereKey.String(mockErrorEvent)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: errorEventLabels. Same for other areas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

h.Equals(t, http.StatusOK, status)
}

func getMetricsMap(body string) map[string]string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment here indicating an example of what the body might look like? Is there only a specific format it accepts? Just so it's easier to understand what this does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by adding doc comment for example response body.

@tiationg-kho tiationg-kho merged commit 1a0643c into aws:main Dec 5, 2024
8 of 16 checks passed
@tiationg-kho tiationg-kho deleted the prometheus-server-port branch December 10, 2024 23:56
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