Last active
July 14, 2016 18:22
-
-
Save bg451/270af7e792ed6c2f5b76f680957d16ac to your computer and use it in GitHub Desktop.
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
import ( | |
“sourcegraph.com/sourcegraph/appdash” | |
“sourcegraph.com/sourcegraph/appdash/traceapp” | |
appdashot "sourcegraph.com/sourcegraph/appdash/opentracing" | |
) | |
func main() { | |
// ... | |
store := appdash.NewMemoryStore() | |
// Listen on any available TCP port locally. | |
l, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0}) | |
if err != nil { | |
log.Fatal(err) | |
} | |
collectorPort := l.Addr().(*net.TCPAddr).Port | |
collectorAdd := fmt.Sprintf(":%d", collectorPort) | |
// Start an Appdash collection server that will listen for spans and | |
// annotations and add them to the local collector (stored in-memory). | |
cs := appdash.NewServer(l, appdash.NewLocalCollector(store)) | |
go cs.Start() | |
// Print the URL at which the web UI will be running. | |
appdashPort := 8700 | |
appdashURLStr := fmt.Sprintf("http://localhost:%d", appdashPort) | |
appdashURL, err := url.Parse(appdashURLStr) | |
if err != nil { | |
log.Fatalf("Error parsing %s: %s", appdashURLStr, err) | |
} | |
fmt.Printf("To see your traces, go to %s/traces\n", appdashURL) | |
// Start the web UI in a separate goroutine. | |
tapp, err := traceapp.New(nil, appdashURL) | |
if err != nil { | |
log.Fatal(err) | |
} | |
tapp.Store = store | |
tapp.Queryer = store | |
go func() { | |
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", appdashPort), tapp)) | |
}() | |
tracer := appdashot.NewTracer(appdash.NewRemoteCollector(collectorPort)) | |
opentracing.InitGlobalTracer(tracer) | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment