Skip to content

Instantly share code, notes, and snippets.

# Install kudu on a fresh Debian/Ubuntu machine
wget http://archive.cloudera.com/beta/kudu/ubuntu/trusty/amd64/kudu/cloudera.list
sudo mv cloudera.list /etc/apt/sources.list.d
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 327574EE02A818DD
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install kudu # Base Kudu files
sudo apt-get install kudu-master # Service scripts for managing kudu-master
sudo apt-get install kudu-tserver # Service scripts for managing kudu-tserver
sudo apt-get install libkuduclient0 # Kudu C++ client shared library
import zipkin "github.com/openzipkin/zipkin-go-opentracing"
func main() {
// ...
// Replace Appdash tracer code with this
collector, err := zipkin.NewKafkaCollector("ZIPKIN_ADDR")
if err != nil {
log.Fatal(err)
return
}
import (
“sourcegraph.com/sourcegraph/appdash”
“sourcegraph.com/sourcegraph/appdash/traceapp”
appdashot "sourcegraph.com/sourcegraph/appdash/opentracing"
)
func main() {
// ...
store := appdash.NewMemoryStore()
func serviceHandler(w http.ResponseWriter, r *http.Request) {
var sp opentracing.Span
opName := r.URL.Path
// Attempt to join a trace by getting trace context from the headers.
wireContext, err := opentracing.GlobalTracer().Extract(
opentracing.TextMap,
opentracing.HTTPHeaderTextMapCarrier(r.Header))
if err != nil {
// If for whatever reason we can't join, go ahead an start a new root span.
sp = opentracing.StartSpan(opName)
func homeHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Request started"))
span := opentracing.StartSpan("/home")
defer span.Finish()
// Since we have to inject our span into the HTTP headers, we create a request
asyncReq, _ := http.NewRequest("GET", "http://localhost:8080/async", nil)
// Inject the span context into the header
err := span.Tracer().Inject(span.Context(),
opentracing.TextMap,
// The ext package provides a set of standardized tags available for use.
import "github.com/opentracing/opentracing-go/ext"
func homeHandler(w http.ResponseWriter, r *http.Request) {
// ...
// We record any errors now.
_, err := http.Get("http://localhost:8080/service")
if err != nil {
ext.Error.Set(span, true) // Tag the span as errored
span.LogEventWithPayload("GET service error", err) // Log the error
func homeHandler(w http.ResponseWriter, r *http.Request) {
span := opentracing.StartSpan("/home") // Start a span using the global, in this case noop, tracer
defer span.Finish()
// ... the rest of the function
}
func main() {
port := 8080
addr := fmt.Sprintf(":%d", port)
mux := http.NewServeMux()
mux.HandleFunc("/", indexHandler)
mux.HandleFunc("/home", homeHandler)
mux.HandleFunc("/async", serviceHandler)
mux.HandleFunc("/service", serviceHandler)
mux.HandleFunc("/db", dbHandler)
fmt.Printf("Go to http://localhost:%d/home to start a request!\n", port)
// Acts as our index page
func indexHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<a href="/home"> Click here to start a request </a>`))
}
func homeHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Request started"))
go func() {
http.Get("http://localhost:8080/async")
}()
http.Get("http://localhost:8080/service")
// Acts as our index page
func indexHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<a href="/home"> Click here to start a request </a>`))
}
func homeHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Request started"))
go func() {
http.Get("http://localhost:8080/async")
}()
http.Get("http://localhost:8080/service")