Skip to content

App Engine support #8

Open
Open

Description

@benguild

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.

Activity

  1. dmelikyan commented on Nov 16, 2017

    @dmelikyan
    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!")
    }
    
  2. benguild commented on Nov 16, 2017

    @benguild
    Author

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

  3. dmelikyan commented on Nov 16, 2017

    @dmelikyan
    Member

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

  4. benguild commented on Nov 16, 2017

    @benguild
    Author

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

  5. dmelikyan commented on Nov 16, 2017

    @dmelikyan
    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.

  6. benguild commented on Nov 16, 2017

    @benguild
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions