Skip to content

Commit

Permalink
Merge pull request #17 from tigrulya-exe/adapt-to-use-opentracing
Browse files Browse the repository at this point in the history
Adapt cmd-nse-icmp-responder to use opentracing
  • Loading branch information
denis-tingaikin authored Nov 12, 2020
2 parents dd43685 + ceb96c1 commit 03123b4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions internal/pkg/imports/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 30 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:")
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down

0 comments on commit 03123b4

Please sign in to comment.