-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Laushinka/add metrics for server 9824 #9863
Conversation
f4e9f40
to
e7cf60e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Are the 'how to test' instructions correct though?
I did:
go run main.go
(inpublic-api-server
)curl localhost:9500/metrics
which works as expected. I don't think the server takes subcommands like api workspaces get
.
start := time.Now() | ||
defer func() { | ||
ReportConnectionDuration(time.Since(start)) | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of defer
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just taught by @easyCZ 🤗
Oops wrote the wrong thing! Thanks for the catch. |
Thanks for helping review, @andrew-farries 🤗 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, left a couple of comments mostly to make the metric private. As a challenge, can you write a test for this? By injecting the registry, you should be able to check that it got incremented after you invoked Get
2cfc71f
to
c594365
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice job on the tests!
) | ||
if err != nil { | ||
return fmt.Errorf("failed to initialize public api server: %w", err) | ||
} | ||
|
||
if registerErr := register(srv, cfg); registerErr != nil { | ||
if registerErr := register(srv, cfg, registry); registerErr != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this part being quite not ergonomic, I've raised #9879 which allows us to do srv.MetricsRegistry()
to get access to the registry. It just reduces the need to pass the registry along in a side-channel. We can update later if this PR lands first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
/hold /werft run 👍 started the job as gitpod-build-laushinka-add-metrics-for-server-9824.16 This PR block merge pool |
Oops didn't check the job. Thank you, @mustard-mh 🤗 |
c594365
to
aede52a
Compare
3b2cebb
to
a6ef3df
Compare
Description
Sets up metric for how long a connection takes.
Related Issue(s)
Fixes #9824
How to test
/components/public-api-server
rungo run main.go
curl localhost:9500/metrics
Release Notes
Documentation