Created
November 26, 2018 12:34
-
-
Save Deleplace/f19963807758eed0e613938f7e2c49c8 to your computer and use it in GitHub Desktop.
Trace for AppEngine Standard with Go 1.9 (can't deploy as of 2018-11-26)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2018 Google Inc. All rights reserved. | |
// Use of this source code is governed by the Apache 2.0 | |
// license that can be found in the LICENSE file. | |
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"contrib.go.opencensus.io/exporter/stackdriver" | |
"go.opencensus.io/trace" | |
"google.golang.org/appengine" | |
) | |
func main() { | |
sd, err := stackdriver.NewExporter(stackdriver.Options{ | |
ProjectID: "spans-go19", | |
// MetricPrefix helps uniquely identify your metrics. | |
MetricPrefix: "demo-prefix", | |
}) | |
if err != nil { | |
log.Fatalf("Failed to create the Stackdriver exporter: %v", err) | |
} | |
// It is imperative to invoke flush before your main function exits | |
defer sd.Flush() | |
// Register it as a trace exporter | |
trace.RegisterExporter(sd) | |
http.HandleFunc("/", handle) | |
appengine.Main() | |
} | |
func handle(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintln(w, "Hello, VDE") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment