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

[feature] Instrument the API server(s) with pprof #160

Merged

Conversation

els0r
Copy link
Owner

@els0r els0r commented Aug 3, 2023

Provides facilities to hook up a net/http/pprof server on /debug/pprof.

The majority of this commit will unify the server base across all binaries, which serve an API, in this case goProbe and global-query. This is primarily to deduplicate code for functionalit that is desired in both APIs.

To this end, and analogous to the client.DefaultClient a server.DefaultServer is introduced to cover observability middlewares as well as setting up the gin.Engine

Closes #142

Provides facilities to hook up a net/http/pprof server on /debug/pprof.

The majority of this commit will unify the server base across all binaries,
which serve an API, in this case `goProbe` and `global-query`. This is primarily
to deduplicate code for functionalit that is desired in both APIs.

To this end, and analogous to the client.DefaultClient a server.DefaultServer
is introduced to cover observability middlewares as well as setting up the gin.Engin
@els0r els0r linked an issue Aug 3, 2023 that may be closed by this pull request
9 tasks
@els0r els0r requested a review from fako1024 August 3, 2023 19:25
@els0r
Copy link
Owner Author

els0r commented Aug 3, 2023

@fako1024 : I wanted to do this first before providing the profiles for #138 . There's only one caveat: the profiles are empty if I pull them with wget http://host:port/debug/pprof/profile?seconds=300. However, if I hook into the server directly, using go tool pprof http://host:port/debug/pprof/profile, I do get profiling results.

Have you encountered this before? Am I missing something obvious?

@fako1024
Copy link
Collaborator

fako1024 commented Aug 4, 2023

@fako1024 : I wanted to do this first before providing the profiles for #138 . There's only one caveat: the profiles are empty if I pull them with wget http://host:port/debug/pprof/profile?seconds=300. However, if I hook into the server directly, using go tool pprof http://host:port/debug/pprof/profile, I do get profiling results.

Have you encountered this before? Am I missing something obvious?

I do recall something like that. Maybe it has something to do with the way wget does the request. Can you try this (which seems to be the commonly referenced way of doing it):

curl -s http://host:port/debug/pprof/profile?seconds=60 > ./cpu.prof

Copy link
Collaborator

@fako1024 fako1024 left a comment

Choose a reason for hiding this comment

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

Aside from some minor mimimi, LGTM!

cmd/goProbe/goProbe.go Show resolved Hide resolved
pkg/api/server/server.go Show resolved Hide resolved
pkg/api/server/server.go Outdated Show resolved Hide resolved
cmd/goProbe/goProbe.go Show resolved Hide resolved
@els0r
Copy link
Owner Author

els0r commented Aug 4, 2023

I do recall something like that. Maybe it has something to do with the way wget does the request. Can you try this (which seems to be the commonly referenced way of doing it):

curl -s http://host:port/debug/pprof/profile?seconds=60 > ./cpu.prof

Yup. That was it. Thanks! In that case, I'll wrap up this PR with the feedback and then deploy it on the sensors to collect profiles. This is getting better by the minute :)

@els0r els0r marked this pull request as ready for review August 4, 2023 13:02
@els0r els0r merged commit d1e8346 into develop Aug 4, 2023
6 checks passed
@els0r els0r deleted the 142-full-instrumentation-of-goprobegoqueryglobal-query branch August 4, 2023 13:41
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.

Full instrumentation of goProbe/goQuery/global-query
2 participants