rakyll / gom

A visual interface to work with runtime profiling data for Go
Apache License 2.0
1.29k stars 42 forks source link

Gorilla mux router usage fix #15

Closed matejb closed 8 years ago

matejb commented 8 years ago

Hi, when I tried gom on my application that is using Gorilla Mux router it wasn't working out of the box. I had to extract pprofstats handler so it can be manually registered to router.

Please review my pull request.

matejb commented 8 years ago

Hi,

adding helper function was fun :)

I was not fully aware yesterday that this issue not only affects GorillaMux but any custom router instance because pprof registers it's http routes to http.DefaultServeMux in init func.

Now I added support for any custom router as long it has same signature for Handle and HandleFunc methods. Which of course GorillaMux does not so adapter was needed.

I put everything in gom/http package because users of gom would have to import more than one package if there are using custom router instance.

I'm not pleased with signature of http.AttachProfiler function, second parameter controls registration of pprof http routes. We can't easy change this later because it could break others people apps. If you have any suggestions pls tell.

matejb commented 8 years ago

I changed signature of http.AttachProfiler method, batter to have small code duplication (registration of /debug/pprofstats in init and AttachProfiler) than wird signature of http.AttachProfiler. Also moved GorillaMux adapter to separate sub package.

rakyll commented 8 years ago

Given it a second thought, I decided to follow the following strategy:

matejb commented 8 years ago

That sounds good.

rakyll commented 8 years ago

Partially addressed the issue via b1f21705888d63b397896a18097f14f500eae30f, need to document usage.

rakyll commented 8 years ago

Closed via b1f2170 and d8c1291ecccb7eea089a27db3c60206810e88e0d.