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

[feat] How to reuse an existing webInterface? #497

Open
p1gd0g opened this issue Nov 4, 2019 · 3 comments
Open

[feat] How to reuse an existing webInterface? #497

p1gd0g opened this issue Nov 4, 2019 · 3 comments
Labels
Priority: p3 Buganizer priority - P3 type: feat Buganizer type - Feature Request

Comments

@p1gd0g
Copy link

p1gd0g commented Nov 4, 2019

What did you do?

In my case, I built a monitor server which was integrated with pprof.

var switcher bool
if err := driver.PProf(&driver.Options{
	Flagset: &internal.GoFlags{
		Profile:   profilePath + profile,
		Http:      "127.0.0.1:" + strconv.Itoa(internal.ListenPort),
		NoBrowser: true,
	},
	HTTPServer: func(args *driver.HTTPServerArgs) error {
		if switcher {
			return nil
		}
		for k, v := range args.Handlers {
			http.Handle("/ui"+k, v)
		}
		switcher = true
		return nil
	},
}); err != nil {
	panic(err)
	return
}

However I haven't found options to reuse existing webInterface, thus the code wouldn't work.

What did you expect to see?

I modified the source code in internal/driver/webui.go:

var webI = new(webInterface)

func makeWebInterface(p *profile.Profile, opt *plugin.Options) *webInterface {
	templates := template.New("templategroup")
	addTemplates(templates)
	report.AddSourceTemplates(templates)

	webI.prof = p
	webI.options = opt
	webI.help = make(map[string]string)
	webI.templates = templates

	return webI
}

It makes sense, but apparently it is not a good idea.

What did you see instead?

I hope this feature could be an option in main function, or anything similarly. Thank you.

@p1gd0g p1gd0g changed the title [feat] How to reuse existing webInterface? [feat] How to reuse an existing webInterface? Nov 4, 2019
@aalexand aalexand self-assigned this Nov 22, 2019
@deckarep
Copy link

This would be fantastic, if we can pull in the web-ui and serve it from an existing monitoring tool or microservice to do self-service profiling.

@aalexand
Copy link
Collaborator

The cockroachdb folks integrate pprof into their service I think - https://github.com/cockroachdb/cockroach/blob/2eebbddbb133eea7102a47fbe7f5d13ec6f8f670/pkg/server/debug/pprofui/server.go#L169.

@p1gd0g Is this what you need or you mean something else by "reuse"?

@p1gd0g
Copy link
Author

p1gd0g commented Dec 2, 2019

@aalexand Not exactly, my "reuse" means we can re-read a profile without restarting pprof.
A temporary modification is like what I write above, set webInterface a global var, which helps me out.
You can close this issue if there is not any good resolution at present.

@aalexand aalexand removed their assignment Sep 28, 2020
@aalexand aalexand added type: feat Buganizer type - Feature Request and removed enhancement labels May 12, 2023
@Louis-Ye Louis-Ye added the Priority: p3 Buganizer priority - P3 label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: p3 Buganizer priority - P3 type: feat Buganizer type - Feature Request
Projects
None yet
Development

No branches or pull requests

5 participants