OpenTracing for Fission (#1079)
Added Opentracing integration using opencensus libraries for all Fission components.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
@@ -11,6 +12,10 @@ import (
|
||||
"runtime/debug"
|
||||
"syscall"
|
||||
|
||||
"go.opencensus.io/exporter/jaeger"
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.opencensus.io/trace"
|
||||
|
||||
"github.com/fission/fission"
|
||||
"github.com/fission/fission/environments/fetcher"
|
||||
)
|
||||
@@ -19,6 +24,29 @@ func dumpStackTrace() {
|
||||
debug.PrintStack()
|
||||
}
|
||||
|
||||
func registerTraceExporter(collectorEndpoint string) error {
|
||||
if collectorEndpoint == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
serviceName := "Fission-Fetcher"
|
||||
exporter, err := jaeger.NewExporter(jaeger.Options{
|
||||
CollectorEndpoint: collectorEndpoint,
|
||||
Process: jaeger.Process{
|
||||
ServiceName: serviceName,
|
||||
Tags: []jaeger.Tag{
|
||||
jaeger.BoolTag("fission", true),
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
trace.RegisterExporter(exporter)
|
||||
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
|
||||
return nil
|
||||
}
|
||||
|
||||
// Usage: fetcher <shared volume path>
|
||||
func main() {
|
||||
// register signal handler for dumping stack trace.
|
||||
@@ -32,6 +60,7 @@ func main() {
|
||||
}()
|
||||
|
||||
flag.Usage = fetcherUsage
|
||||
collectorEndpoint := flag.String("jaeger-collector-endpoint", "", "")
|
||||
specializeOnStart := flag.Bool("specialize-on-startup", false, "Flag to activate specialize process at pod starup")
|
||||
specializePayload := flag.String("specialize-request", "", "JSON payload for specialize request")
|
||||
secretDir := flag.String("secret-dir", "", "Path to shared secrets directory")
|
||||
@@ -53,6 +82,10 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if err := registerTraceExporter(*collectorEndpoint); err != nil {
|
||||
log.Fatalf("Could not register trace exporter: %v", err)
|
||||
}
|
||||
|
||||
f, err := fetcher.MakeFetcher(dir, *secretDir, *configDir)
|
||||
if err != nil {
|
||||
log.Fatalf("Error making fetcher: %v", err)
|
||||
@@ -70,7 +103,8 @@ func main() {
|
||||
log.Fatalf("Error decoding specialize request: %v", err)
|
||||
}
|
||||
|
||||
err = f.SpecializePod(specializeReq.FetchReq, specializeReq.LoadReq)
|
||||
ctx := context.Background()
|
||||
err = f.SpecializePod(ctx, specializeReq.FetchReq, specializeReq.LoadReq)
|
||||
if err != nil {
|
||||
log.Fatalf("Error specialing function poadt: %v", err)
|
||||
}
|
||||
@@ -96,7 +130,9 @@ func main() {
|
||||
})
|
||||
|
||||
log.Println("Fetcher ready to receive requests")
|
||||
http.ListenAndServe(":8000", mux)
|
||||
http.ListenAndServe(":8000", &ochttp.Handler{
|
||||
Handler: mux,
|
||||
})
|
||||
}
|
||||
|
||||
func fetcherUsage() {
|
||||
|
||||
Reference in New Issue
Block a user