Stackdriver (Stats and Tracing)

Introduction

Stackdriver Trace is a distributed tracing system that collects latency data from your applications and displays it in the Google Cloud Platform Console.

You can track how requests propagate through your application and receive detailed near real-time performance insights.
Stackdriver Trace automatically analyzes all of your application’s traces to generate in-depth latency reports to surface performance degradations,
and can capture traces from all of your VMs, containers, or Google App Engine projects.

packagemainimport("log""time""contrib.go.opencensus.io/exporter/stackdriver""go.opencensus.io/stats/view")funcmain(){sd,err:=stackdriver.NewExporter(stackdriver.Options{ProjectID:"demo-project-id",// MetricPrefix helps uniquely identify your metrics.
MetricPrefix:"demo-prefix",})iferr!=nil{log.Fatalf("Failed to create the Stackdriver exporter: %v",err)}// It is imperative to invoke flush before your main function exits
defersd.Flush()// Register it as a metrics exporter
view.RegisterExporter(sd)view.SetReportingPeriod(60*time.Second)}

packagemainimport("log""contrib.go.opencensus.io/exporter/stackdriver""go.opencensus.io/trace")funcmain(){sd,err:=stackdriver.NewExporter(stackdriver.Options{ProjectID:"demo-project-id",// MetricPrefix helps uniquely identify your metrics.
MetricPrefix:"demo-prefix",})iferr!=nil{log.Fatalf("Failed to create the Stackdriver exporter: %v",err)}// It is imperative to invoke flush before your main function exits
defersd.Flush()// Register it as a trace exporter
trace.RegisterExporter(sd)}

packagemainimport("log""time""contrib.go.opencensus.io/exporter/stackdriver""go.opencensus.io/stats/view""go.opencensus.io/trace")funcmain(){sd,err:=stackdriver.NewExporter(stackdriver.Options{ProjectID:"demo-project-id",// MetricPrefix helps uniquely identify your metrics.
MetricPrefix:"demo-prefix",})iferr!=nil{log.Fatalf("Failed to create the Stackdriver exporter: %v",err)}// It is imperative to invoke flush before your main function exits
defersd.Flush()// Register it as a metrics exporter
view.RegisterExporter(sd)view.SetReportingPeriod(60*time.Second)// Register it as a trace exporter
trace.RegisterExporter(sd)}