AWS X-Ray (Tracing)
Introduction
AWS X-Ray is a distributed trace collection and analysis system from Amazon Web Services.
Its support is available by means of the X-Ray package https://godoc.org/github.com/census-instrumentation/opencensus-go-exporter-aws
Requirements
You’ll need to have an AWS Developer account, if you haven’t yet, please visit In case you haven’t yet enabled AWS X-Ray, please visit https://console.aws.amazon.com/xray/home
Creating the exporter
This is possible by importing
import xray "contrib.go.opencensus.io/exporter/aws"
// Then create the actual exporter
xe, err := xray.NewExporter(xray.WithVersion("latest"))
if err != nil {
log.Fatalf("Failed to create the AWS X-Ray exporter: %v", err)
}
Then finally register it as a trace exporter, to collectively give
package main
import (
"log"
xray "contrib.go.opencensus.io/exporter/aws"
"go.opencensus.io/trace"
)
func main() {
xe, err := xray.NewExporter(xray.WithVersion("latest"))
if err != nil {
log.Fatalf("Failed to create the AWS X-Ray exporter: %v", err)
}
// It is imperative that your exporter invokes Flush before your program exits!
defer xe.Flush()
trace.RegisterExporter(xe)
}
Viewing your traces
Please visit https://console.aws.amazon.com/xray/home