Skip to content

Conversation

0xaravindh
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking
/kind bug

/kind cleanup

/kind documentation
/kind feature
/kind hotfix
/kind release

What this PR does / Why we need it:

  • Added tests for Prometheus exporter registration and metrics endpoint exposure
  • Verified all expected metrics are served via /metrics endpoint
  • Included Stackdriver-only setup test to ensure no panics

Which issue(s) this PR fixes:

Closes #3925

Special notes for your reviewer:

… metrics setup

- Added tests for Prometheus exporter registration and metrics endpoint exposure
- Verified all expected metrics are served via /metrics endpoint
- Included Stackdriver-only setup test to ensure no panics
@0xaravindh 0xaravindh self-assigned this May 22, 2025
@github-actions github-actions bot added the kind/cleanup Refactoring code, fixing up documentation, etc label May 22, 2025
@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 9386d087-612a-404f-8994-fcf316d51dda

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4185/head:pr_4185 && git checkout pr_4185
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.50.0-dev-67da16b

@github-actions github-actions bot added the size/M label Jun 2, 2025
@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 23068501-53f6-4639-b3c6-97f7f58947be

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4185/head:pr_4185 && git checkout pr_4185
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.50.0-dev-d097ea8

Copy link
Collaborator

@igooch igooch left a comment

Choose a reason for hiding this comment

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

Looks like this test isn't including the agones_gameserver_allocations_duration_seconds or agones_gameserver_allocations_retry_total. @vicentefb could you confirm which metrics are expected at the allocator endpoint?

Try adding some debug statements (or just use your debugger) to see what metrics the test is testing for:

	metricsSet := collectMetricNames(resp)
	fmt.Println("GOT", metricsSet)
	expectedMetrics := getMetricNames()
	fmt.Println("EXPECTED", expectedMetrics)
	// Force test to fail so that the above fmt.Println actually prints.
	assert.True(t, false)


}

func TestSetupMetrics_StackdriverOnly_NoPanic(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stackdriver has been deprecated in favor of Google Cloud Monitoring.

As part of a separate issue we should investigate if these configs are still working as intended, or if they need to be updated.

@vicentefb
Copy link
Collaborator

Looks like this test isn't including the agones_gameserver_allocations_duration_seconds or agones_gameserver_allocations_retry_total. @vicentefb could you confirm which metrics are expected at the allocator endpoint?

Try adding some debug statements (or just use your debugger) to see what metrics the test is testing for:

	metricsSet := collectMetricNames(resp)
	fmt.Println("GOT", metricsSet)
	expectedMetrics := getMetricNames()
	fmt.Println("EXPECTED", expectedMetrics)
	// Force test to fail so that the above fmt.Println actually prints.
	assert.True(t, false)

Yeah, those two metrics are also expected at the allocator endpoint as well as metrics listed here: https://agones.dev/site/docs/guides/metrics/

@@ -117,3 +135,131 @@ func TestSetResponse(t *testing.T) {
})
}
}

func TestAllocationMetrics(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@igooch @vicentefb I’ve added a separate test case for these metrics: agones_gameserver_allocations_duration_seconds, agones_gameserver_allocations_retry_total, and agones_gameserver_creation_duration. This should fix the issue with missing metrics in the tests. PR is now ready for review.

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 39b31441-5c49-41f8-9952-7da7117eefa8

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4185/head:pr_4185 && git checkout pr_4185
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.50.0-dev-cbf1045

@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 1034ca0f-312c-4550-8da4-0c52d51d32c0

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@0xaravindh
Copy link
Member Author

/gcbrun

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: bce52699-46ed-4e2f-825c-d93dc931153f

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4185/head:pr_4185 && git checkout pr_4185
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.50.0-dev-2acecd1

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 135458f3-06d2-482b-b080-45996e261032

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4185/head:pr_4185 && git checkout pr_4185
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.51.0-dev-837d684

Copy link
Collaborator

@vicentefb vicentefb left a comment

Choose a reason for hiding this comment

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

lgtm

@0xaravindh 0xaravindh merged commit 86e8fa8 into googleforgames:main Jun 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Refactoring code, fixing up documentation, etc size/L size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit test to check if metrics endpoint is scraping metrics
4 participants