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

Integrate pprof #235

Closed
nikunjy opened this Issue Feb 22, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@nikunjy

nikunjy commented Feb 22, 2017

Is there any easy way to integrate pprof with fasthttp ? Instead of using fasthttpadapter and pointing to handler functions provided by pprof

@codesenberg

This comment has been minimized.

Show comment
Hide comment
@codesenberg

codesenberg Feb 22, 2017

What about attaching pprof to a net/http-server binded to a different port?

package main

import (
	"log"
	"net/http"
	_ "net/http/pprof"

	"github.com/valyala/fasthttp"
)

func main() {
	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()
	fasthttp.ListenAndServe("localhost:8080", func(ctx *fasthttp.RequestCtx) {
		ctx.Success("text/plain; charset=utf-8", []byte("Hello, fasthttp and pprof"))
	})
}

codesenberg commented Feb 22, 2017

What about attaching pprof to a net/http-server binded to a different port?

package main

import (
	"log"
	"net/http"
	_ "net/http/pprof"

	"github.com/valyala/fasthttp"
)

func main() {
	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()
	fasthttp.ListenAndServe("localhost:8080", func(ctx *fasthttp.RequestCtx) {
		ctx.Success("text/plain; charset=utf-8", []byte("Hello, fasthttp and pprof"))
	})
}
@nikunjy

This comment has been minimized.

Show comment
Hide comment
@nikunjy

nikunjy Mar 3, 2017

That is not really a great solution, I have been doing that so far.

@valyala

nikunjy commented Mar 3, 2017

That is not really a great solution, I have been doing that so far.

@valyala

@codesenberg

This comment has been minimized.

Show comment
Hide comment
@codesenberg

codesenberg Mar 3, 2017

@nikunjy, what is exactly not so great about it?
Do you have in mind/want to propose anything specific?
Oh, and I have to warn you that @valyala rarely answered to issues in last few months.

codesenberg commented Mar 3, 2017

@nikunjy, what is exactly not so great about it?
Do you have in mind/want to propose anything specific?
Oh, and I have to warn you that @valyala rarely answered to issues in last few months.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 3, 2017

@nikunjy Look how Iris did that months ago, copy the code and change it in order to work with raw fasthttp, it's quite easy:

You're welcome,
kataras

ghost commented Mar 3, 2017

@nikunjy Look how Iris did that months ago, copy the code and change it in order to work with raw fasthttp, it's quite easy:

You're welcome,
kataras

@nikunjy

This comment has been minimized.

Show comment
Hide comment
@nikunjy

nikunjy Mar 3, 2017

Thank you @kataras I was hoping that it would be a first class citizen in this library. Maybe an opportunity for me to do a PR.
@codesenberg the problem with that solution is that in prod environments I don't have to use another port to profile so it is not necessarily a bad solution but would be even great if fasthttp supported it.

nikunjy commented Mar 3, 2017

Thank you @kataras I was hoping that it would be a first class citizen in this library. Maybe an opportunity for me to do a PR.
@codesenberg the problem with that solution is that in prod environments I don't have to use another port to profile so it is not necessarily a bad solution but would be even great if fasthttp supported it.

@codesenberg

This comment has been minimized.

Show comment
Hide comment
@codesenberg

codesenberg Mar 4, 2017

@nikunjy, oh, I see. Then it is indeed and an opportunity for a PR or, maybe, this doesn't have to live in fasthttp itself, since it doesn't use any internals, but in some other library.
I ask you to consider writing a separate library, because in last ~3 months @valyala accepted only 1 PR.

codesenberg commented Mar 4, 2017

@nikunjy, oh, I see. Then it is indeed and an opportunity for a PR or, maybe, this doesn't have to live in fasthttp itself, since it doesn't use any internals, but in some other library.
I ask you to consider writing a separate library, because in last ~3 months @valyala accepted only 1 PR.

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Mar 14, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof
@erikdubbelboer

This comment has been minimized.

Show comment
Hide comment
@erikdubbelboer

erikdubbelboer Mar 14, 2017

Collaborator

I just added a pull request for this.

I'm still hoping one day @valyala will add someone else to help maintain this repository (I don't mind doing it).

Collaborator

erikdubbelboer commented Mar 14, 2017

I just added a pull request for this.

I'm still hoping one day @valyala will add someone else to help maintain this repository (I don't mind doing it).

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Mar 15, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Mar 17, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Apr 6, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof
@nikunjy

This comment has been minimized.

Show comment
Hide comment
@nikunjy

nikunjy Apr 29, 2017

@valyala can you accept this PR ^

nikunjy commented Apr 29, 2017

@valyala can you accept this PR ^

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Jun 5, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Jun 6, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof

erikdubbelboer added a commit to erikdubbelboer/fasthttp that referenced this issue Nov 26, 2017

Add pprofhandler, fix valyala#235
Similar to expvarhandler but for net/http/pprof
@DuckerMan

This comment has been minimized.

Show comment
Hide comment
@DuckerMan

DuckerMan commented Aug 17, 2018

Up!

kirillDanshin added a commit that referenced this issue Aug 17, 2018

@kirillDanshin

This comment has been minimized.

Show comment
Hide comment
@kirillDanshin

kirillDanshin Aug 17, 2018

Collaborator

ha-ha, I implemented this in https://github.com/gramework/gramework/blob/dev/pprof/pprof.go a long time ago but forgot that fasthttp doesn't support this out of the box.

@DuckerMan just merged it :)

Collaborator

kirillDanshin commented Aug 17, 2018

ha-ha, I implemented this in https://github.com/gramework/gramework/blob/dev/pprof/pprof.go a long time ago but forgot that fasthttp doesn't support this out of the box.

@DuckerMan just merged it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment