Skip to content

Adding a method to enable pprof endpoints on Echo#1696

Closed
pafuent wants to merge 1 commit into
labstack:masterfrom
pafuent:enable_profiling
Closed

Adding a method to enable pprof endpoints on Echo#1696
pafuent wants to merge 1 commit into
labstack:masterfrom
pafuent:enable_profiling

Conversation

@pafuent
Copy link
Copy Markdown
Contributor

@pafuent pafuent commented Nov 24, 2020

In order to avoid making the pprof endpoints public in the same address than Echo is listening, a new goroutine is launched with a stdlib http.Server that binds to localhost.

In order to avoid making the pprof endpoints public in the same address
than Echo is listening, a new goroutine is launched whith a stdlib
http.Server that binds to localhost.
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 24, 2020

Codecov Report

Merging #1696 (a50f8a3) into master (17a5fca) will decrease coverage by 0.21%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1696      +/-   ##
==========================================
- Coverage   84.72%   84.50%   -0.22%     
==========================================
  Files          29       29              
  Lines        1938     1943       +5     
==========================================
  Hits         1642     1642              
- Misses        188      193       +5     
  Partials      108      108              
Impacted Files Coverage Δ
echo.go 83.21% <0.00%> (-1.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17a5fca...a50f8a3. Read the comment docs.

@pafuent
Copy link
Copy Markdown
Contributor Author

pafuent commented Nov 24, 2020

I'm not sure if it makes sense for this PR to not fail codecov.
For sure I can add a UT just for the sake of coverage, and even do an small assert on /debug/pprof/cmdline route, but I guess doesn't make sense. Any thoughts?

@aldas
Copy link
Copy Markdown
Contributor

aldas commented Nov 24, 2020

Would it be more reasonable to add this as a recipe to echo cookbook. To demonstrate how to add this feature (its only 4 lines).

_ "net/http/pprof" has sideeffect of automatically register routes. It could be that library user in addition to echo also also uses DefaultServeMux for some their specific stuff and is not aware that now these routes are now exposed.

Sidenote: some people even argue that underscore imports is best to add into application main.go to have those magic parts clearly visible at the top of application.

@aldas
Copy link
Copy Markdown
Contributor

aldas commented Nov 24, 2020

p.s. these small change failures can be ignored with adding codecov.yml to repo and setting threshold value. example

@pafuent
Copy link
Copy Markdown
Contributor Author

pafuent commented Nov 26, 2020

I guess I overestimated my desire of "Use Echo and forget everything else" (patent pending 😉)
I thought that the chance of use the DefaultServeMux in the context of Echo is very low, but you are right, if there is a chance it's better to have this as a Cookbook.

@pafuent pafuent self-assigned this Nov 26, 2020
@lammel
Copy link
Copy Markdown
Contributor

lammel commented Dec 9, 2020

This has been addressed earlier in #1591 (with PR #1592) and resulted in PR labstack/echo-contrib#42 which adds a pprof middleware without bloating the core.

@pafuent So I think we should close this in favor of a dedicated middleware and add a cookbook entry instead.

@pafuent pafuent closed this Dec 10, 2020
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.

3 participants