Skip to content

include gorouter_time metrics report #471

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

Closed
wants to merge 1 commit into from

Conversation

kart2bc
Copy link
Contributor

@kart2bc kart2bc commented Apr 1, 2025

Summary

Backward Compatibility

Breaking Change? No

Copy link

linux-foundation-easycla bot commented Apr 1, 2025

CLA Not Signed

Copy link
Member

@ameowlia ameowlia left a comment

Choose a reason for hiding this comment

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

I think there are at least two options forward:

  1. Move the call to CaptureGorouter to the accesslog handler. And move the calculation to gorouter time to access log handler.
  2. OR set "FinishedAt" in the reporter handler, calculate gorouter_time in the reporter handler, send a metric for gorouter_time in the reporter handler, set gorouter_time on the reqInfo in the reporter handler, and then use that calculated value for gorouter time in the access log handler.

Also needed

  • tests
  • this needs to be behind the config flag for per request metrics

@kart2bc
Copy link
Contributor Author

kart2bc commented Apr 7, 2025

I think there are at least two options forward:

  1. Move the call to CaptureGorouter to the accesslog handler. And move the calculation to gorouter time to access log handler.
  2. OR set "FinishedAt" in the reporter handler, calculate gorouter_time in the reporter handler, send a metric for gorouter_time in the reporter handler, set gorouter_time on the reqInfo in the reporter handler, and then use that calculated value for gorouter time in the access log handler.

Also needed

  • tests
  • this needs to be behind the config flag for per request metrics

I prefer the option #2.
Plan to move the calculation to an utility. However, the accesslogger been called before reporthandler.
Is my understanding correct?

nvm. Figured out the stack been called in reverse order while processing the response. So finished at will be called once all the request been processed.

@kart2bc kart2bc force-pushed the gorouter-time-metric branch 5 times, most recently from 96ee98a to f048622 Compare April 7, 2025 21:34
@ameowlia
Copy link
Member

ameowlia commented Apr 8, 2025

I think you might also need to add a promethius metric implementation: https://github.com/cloudfoundry/gorouter/blob/main/metrics_prometheus/metrics.go

@kart2bc kart2bc force-pushed the gorouter-time-metric branch 2 times, most recently from 29d2635 to 209f8fa Compare April 8, 2025 17:35
@kart2bc kart2bc force-pushed the gorouter-time-metric branch from 209f8fa to 37c8da3 Compare April 8, 2025 17:36
@kart2bc kart2bc marked this pull request as ready for review April 8, 2025 17:52
@kart2bc kart2bc requested a review from a team as a code owner April 8, 2025 17:52
@kart2bc
Copy link
Contributor Author

kart2bc commented Apr 8, 2025

  • Test results *
{"status":"success","data":{"resultType":"vector","result":[{"metric":{"__v1_type":"ValueMetric","deployment":"cf-217600a306e78084eaf0","index":"e33e6db0-2af5-4b4a-adf7-8b18bb1ff447","ip":"10.10.0.12","job":"router","origin":"gorouter","product":"Small Footprint Tanzu Platform for Cloud Foundry","source_id":"gorouter","system_domain":"sys.tas.z547a4313.shepherd.lease"},"value":[1744150830.000,"0.26723100000000666"]}]}}```

return -1
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused how the access log record tests still pass with no updates. After removing gorouterTime(), and having it log the pre-calculated GorouterTime value, the GorouterTime would be 0, unless the test was modified to set GorouterTime on the fake access log record used in the tests.

... right? 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Figured this issue after running the whole suite. Addressed them here #473.

@@ -107,7 +107,6 @@ var _ = Describe("AccessLog", func() {
Expect(alr.Request.URL).To(Equal(req.URL))
Expect(alr.Request.RemoteAddr).To(Equal(req.RemoteAddr))
Expect(alr.ExtraHeadersToLog).To(Equal(extraHeadersToLog))
Expect(alr.FinishedAt).ToNot(BeZero())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace this with a check to make sure we get a nonzero value on GorouterTime in the access log record?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed it here. #473

@kart2bc
Copy link
Contributor Author

kart2bc commented Apr 11, 2025

Closing this PR due to CLA issue. Opened a new one. #473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants