sandbox: instrument HTTP handlers with StackDriver

This change adds OpenCensus's HTTP instrumentation to the sandbox. In
development mode, it exposes a prometheus metrics interface on /statusz.
This is the first in a series of CLs to add instrumentation to different
parts of the sandbox to help investigate instability issues. For now,
reporting metrics around our responses per handler to StackDriver will
be helpful.

OpenTelemetry would be preferable, as it is the successor of OpenCensus,
however the StackDriver integration is not quite done.

Updates golang/go#25224
Updates golang/go#38530

Change-Id: I600fd695bb66c8bee16bc0b778d51930f4cdd476
Run-TryBot: Alexander Rakoczy <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Dmitri Shuralyov <>
Reviewed-by: Carlos Amedee <>
6 files changed
tree: da4515968d162649be5f59a0a10cc85203a3283a
  1. .gitignore
  5. Dockerfile
  7. Makefile
  10. app.yaml
  11. cache.go
  12. client.go
  13. cmd/
  14. codereview.cfg
  15. deploy/
  16. edit.go
  17. edit.html
  18. enable-fake-time.patch
  19. examples/
  20. fake_fs.lst
  21. fmt.go
  22. fmt_test.go
  23. go.mod
  24. go.sum
  25. internal/
  26. logger.go
  27. main.go
  28. play.go
  29. play_test.go
  30. sandbox.go
  31. sandbox/
  32. sandbox_test.go
  33. server.go
  34. server_test.go
  35. share.go
  36. static/
  37. store.go
  38. tests.go
  39. txtar.go
  40. txtar_test.go
  41. vet.go


This subrepository holds the source for the Go playground:


# build the image
docker build -t playground .


docker run --name=play --rm -p 8080:8080 golang/playground &
# run some Go code
cat /path/to/code.go | go run client.go | curl -s --upload-file - localhost:8080/compile


Deployment Triggers

Playground releases automatically triggered when new Go repository tags are pushed to GitHub, or when master is pushed on the playground repository.

For details, see deploy/go_trigger.json, deploy/playground_trigger.json, and deploy/deploy.json.

After making changes to trigger configuration, update configuration by running the following Make target:

make update-cloudbuild-trigger

Deploy via Cloud Build

The Cloud Build configuration will always build and deploy with the latest supported release of Go.

gcloud builds submit --config deploy/deploy.json .

Deploy via gcloud app deploy

Building the playground Docker container takes more than the default 10 minute time limit of cloud build, so increase its timeout first (note, app/cloud_build_timeout is a global configuration value):

gcloud config set app/cloud_build_timeout 1200  # 20 mins

Alternatively, to avoid Cloud Build and build locally:

make docker
docker tag golang/playground:latest
docker push
gcloud --project=golang-org app deploy app.yaml


gcloud --project=golang-org app deploy app.yaml


To submit changes to this repository, see