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

App Engine support #8

Open
benguild opened this issue Nov 14, 2017 · 6 comments
Open

App Engine support #8

benguild opened this issue Nov 14, 2017 · 6 comments

Comments

@benguild
Copy link

Hey guys,
I was looking into this and noticed that doesn’t seem to be App Engine compatible. On App Engine:

  1. the syscall library isn’t available.
  2. the standard HTTP client isn’t available, but requests can create and provide one while active using their context. — See here, for example: https://github.com/stripe/stripe-go#google-appengine

Is it possible that support could be added? There are a lot of Go applications running on App Engine.

@dmelikyan
Copy link
Member

The agent is now compatible with App Engine, starting v2.2.3. However, the ppof panics in App Engine standard environment. We'll try to find out if profiling is possible at all. In App Engine flexible environment the agent works without any problems.

The agent can still be used App Engine standard local development environment. Because of the limitations on background tasks and context dependency of http client, the agent should be used in manual profiling and reporting mode (see readme), here is an example:

package hello

import (
	"fmt"
	"net/http"

	"google.golang.org/appengine"
	"google.golang.org/appengine/urlfetch"

	"github.com/stackimpact/stackimpact-go"
)

var agent *stackimpact.Agent

func init() {
	agent = stackimpact.Start(stackimpact.Options{
		AgentKey: "your agent key",
		AppName: "AppEngineStandardApp",
		DisableAutoProfiling: true,
	})

	http.HandleFunc("/", handler)
}

func handler(w http.ResponseWriter, r *http.Request) {
	span := agent.Profile()
	defer span.Stop()

	ctx := appengine.NewContext(r)
	client := urlfetch.Client(ctx)
	defer agent.ReportWithHTTPClient(client)

	fmt.Fprintln(w, "Hello, world!")
}

@benguild
Copy link
Author

So you're saying that the code above will not work in Standard on a live deployment?

@dmelikyan
Copy link
Member

It didn't work for me, the pprof panics. I've also tried pprof CPU profiler directly, without the agent, same error.

@benguild
Copy link
Author

You can't CPU profile on App Engine Standard as far as I know. However, you can use heap profiling and some others.

@dmelikyan
Copy link
Member

I'll see if any of the profilers works. If yes, then we could add a possibility to disable some profilers and keep only supported ones.

@benguild
Copy link
Author

Anything that uses syscall is banned, and probably some others. However the heap one definitely works.

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

No branches or pull requests

2 participants