App Engine support
Hey guys, I was looking into this and noticed that doesn’t seem to be App Engine compatible. On App Engine:
- the
syscalllibrary isn’t available. - 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.
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!")
}
So you're saying that the code above will not work in Standard on a live deployment?
It didn't work for me, the pprof panics. I've also tried pprof CPU profiler directly, without the agent, same error.
You can't CPU profile on App Engine Standard as far as I know. However, you can use heap profiling and some others.
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.
Anything that uses syscall is banned, and probably some others. However the heap one definitely works.