Shape the future of software operations and make your voice heard by taking the 2021 State of DevOps survey.

Go Compute Engine

Shows how to initialize with Go on Compute Engine.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


For more information, see the Profiler Go API reference documentation.

// snippets is an example of starting
package main

import (

func main() {
	cfg := profiler.Config{
		Service:        "myservice",
		ServiceVersion: "1.0.0",
		// ProjectID must be set if not running on GCP.
		// ProjectID: "my-project",

		// For OpenCensus users:
		// To see Profiler agent spans in APM backend,
		// set EnableOCTelemetry to true
		// EnableOCTelemetry: true,

	// Profiler initialization, best done as early as possible.
	if err := profiler.Start(cfg); err != nil {
		// TODO: Handle error.

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser