daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "go.opencensus.io/exporter/stackdriver"
  6.     "go.opencensus.io/trace"
  7.     "log"
  8. )
  9.  
  10. func main() {
  11.     // Registering the Stackdriver exporter to log sample requests in Stackdriver Trace
  12.     exporter, err := stackdriver.NewExporter(stackdriver.Options{
  13.         ProjectID: os.Getenv("PROJECT_ID"),
  14.  
  15.         ClientOptions: []option.ClientOption{
  16.             option.WithCredentialsFile(os.Getenv("STACKDRIVER_CREDENTIALS")),
  17.         },
  18.     })
  19.     if err != nil {
  20.         log.Fatalf("error initiating the Stackdriver trace exporter: %s", err)
  21.     }
  22.     trace.RegisterExporter(exporter)
  23.     trace.ApplyConfig(trace.Config{DefaultSampler: trace.ProbabilitySampler(0.01)})
  24.    
  25.     doSomething()
  26. }
  27.  
  28. func doSomething() {
  29.     ctx, span := trace.StartSpan(ctx, "main.doSomething")
  30.     defer span.End()
  31.    
  32.     fmt.Println("Doing something")
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top