diff --git a/internal/pkg/imports/imports.go b/internal/pkg/imports/imports.go index c308385..7abbc2d 100644 --- a/internal/pkg/imports/imports.go +++ b/internal/pkg/imports/imports.go @@ -15,9 +15,11 @@ import ( _ "github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam" _ "github.com/networkservicemesh/sdk/pkg/tools/debug" _ "github.com/networkservicemesh/sdk/pkg/tools/grpcutils" + _ "github.com/networkservicemesh/sdk/pkg/tools/jaeger" _ "github.com/networkservicemesh/sdk/pkg/tools/log" _ "github.com/networkservicemesh/sdk/pkg/tools/sandbox" _ "github.com/networkservicemesh/sdk/pkg/tools/signalctx" + _ "github.com/networkservicemesh/sdk/pkg/tools/spanhelper" _ "github.com/networkservicemesh/sdk/pkg/tools/spiffejwt" _ "github.com/networkservicemesh/sdk/pkg/tools/spire" _ "github.com/sirupsen/logrus" diff --git a/main.go b/main.go index bb89da5..b9c20dc 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,9 @@ import ( "os" "time" + "github.com/networkservicemesh/sdk/pkg/tools/jaeger" + "github.com/networkservicemesh/sdk/pkg/tools/spanhelper" + nested "github.com/antonfisher/nested-logrus-formatter" "github.com/golang/protobuf/ptypes/timestamp" "github.com/kelseyhightower/envconfig" @@ -73,6 +76,12 @@ func main() { log.Entry(ctx).Infof("%s", err) } + // ******************************************************************************** + // Configure open tracing + // ******************************************************************************** + jaegerCloser := jaeger.InitJaeger("cmd-nse-icmp-responder") + defer func() { _ = jaegerCloser.Close() }() + // enumerating phases log.Entry(ctx).Infof("there are 6 phases which will be executed followed by a success message:") log.Entry(ctx).Infof("the phases include:") @@ -136,9 +145,16 @@ func main() { // ******************************************************************************** log.Entry(ctx).Infof("executing phase 5: create grpc server and register icmp-server") - // TODO add serveroptions for tracing // ******************************************************************************** - server := grpc.NewServer(grpc.Creds(credentials.NewTLS(tlsconfig.MTLSServerConfig(source, source, tlsconfig.AuthorizeAny())))) + options := append( + spanhelper.WithTracing(), + grpc.Creds( + credentials.NewTLS( + tlsconfig.MTLSServerConfig(source, source, tlsconfig.AuthorizeAny()), + ), + ), + ) + server := grpc.NewServer(options...) responderEndpoint.Register(server) srvErrCh := grpcutils.ListenAndServe(ctx, &config.ListenOn, server) exitOnErr(ctx, cancel, srvErrCh) @@ -147,11 +163,20 @@ func main() { // ******************************************************************************** log.Entry(ctx).Infof("executing phase 6: register nse with nsm") // ******************************************************************************** - cc, err := grpc.DialContext(ctx, - grpcutils.URLToTarget(&config.ConnectTo), + clientOptions := append( + spanhelper.WithTracingDial(), grpc.WithBlock(), grpc.WithDefaultCallOptions(grpc.WaitForReady(true)), - grpc.WithTransportCredentials(credentials.NewTLS(tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny())))) + grpc.WithTransportCredentials( + credentials.NewTLS( + tlsconfig.MTLSClientConfig(source, source, tlsconfig.AuthorizeAny()), + ), + ), + ) + cc, err := grpc.DialContext(ctx, + grpcutils.URLToTarget(&config.ConnectTo), + clientOptions..., + ) if err != nil { log.Entry(ctx).Fatalf("error establishing grpc connection to registry server %+v", err) }