From 9073f66656c25c58a0609bedd1648f374a6d160f Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Fri, 18 Jun 2021 15:59:40 +0700 Subject: [PATCH 01/26] Update protobuf to v1.26.0 needed for opentelemetry Signed-off-by: Artem Glazychev --- go.mod | 2 +- go.sum | 14 +- pkg/networkservice/common/heal/server.go | 307 ++++++++++++++++++ pkg/networkservice/common/refresh/client.go | 8 +- .../common/updatepath/server.go | 20 ++ .../common/updatetoken/common.go | 14 +- .../common/updatetoken/server_test.go | 4 +- .../chains/proxydns/server_nse_test.go | 8 +- 8 files changed, 355 insertions(+), 22 deletions(-) create mode 100644 pkg/networkservice/common/heal/server.go diff --git a/go.mod b/go.mod index be012308e..6e091efe9 100644 --- a/go.mod +++ b/go.mod @@ -34,6 +34,6 @@ require ( golang.org/x/tools v0.1.2 // indirect gonum.org/v1/gonum v0.6.2 google.golang.org/grpc v1.35.0 - google.golang.org/protobuf v1.25.0 + google.golang.org/protobuf v1.26.0 gopkg.in/yaml.v2 v2.2.2 ) diff --git a/go.sum b/go.sum index f1a14b9c0..831220162 100644 --- a/go.sum +++ b/go.sum @@ -74,16 +74,22 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +<<<<<<< HEAD github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +======= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +>>>>>>> Update protobuf to v1.26.0 needed for opentelemetry github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -338,8 +344,10 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= diff --git a/pkg/networkservice/common/heal/server.go b/pkg/networkservice/common/heal/server.go new file mode 100644 index 000000000..5284e9293 --- /dev/null +++ b/pkg/networkservice/common/heal/server.go @@ -0,0 +1,307 @@ +// Copyright (c) 2020 Cisco Systems, Inc. +// +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package heal provides a chain element that carries out proper nsm healing from client to endpoint +package heal + +import ( + "context" + "sync" + "time" + + "github.com/golang/protobuf/ptypes/empty" + + "github.com/networkservicemesh/api/pkg/api/networkservice" + + "github.com/networkservicemesh/sdk/pkg/networkservice/common/discover" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" + "github.com/networkservicemesh/sdk/pkg/tools/addressof" + "github.com/networkservicemesh/sdk/pkg/tools/clock" + "github.com/networkservicemesh/sdk/pkg/tools/log" +) + +type ctxWrapper struct { + mut sync.Mutex + request *networkservice.NetworkServiceRequest + requestTimeout time.Duration + ctx context.Context + cancel func() +} + +type healServer struct { + ctx context.Context + onHeal *networkservice.NetworkServiceClient + onRestore OnRestore + restoreTimeout time.Duration + healContextMap ctxWrapperMap +} + +// NewServer - creates a new networkservice.NetworkServiceServer chain element that implements the healing algorithm +func NewServer(ctx context.Context, opts ...Option) networkservice.NetworkServiceServer { + healOpts := &healOptions{ + onRestore: OnRestoreHeal, + restoreTimeout: time.Minute, + } + for _, opt := range opts { + opt(healOpts) + } + + rv := &healServer{ + ctx: ctx, + onHeal: healOpts.onHeal, + onRestore: healOpts.onRestore, + restoreTimeout: healOpts.restoreTimeout, + } + + if rv.onHeal == nil { + rv.onHeal = addressof.NetworkServiceClient(adapters.NewServerToClient(rv)) + } + + return rv +} + +func (f *healServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { + clockTime := clock.FromContext(ctx) + ctx = f.withHandlers(ctx) + + requestTimeout := time.Duration(0) + if deadline, ok := ctx.Deadline(); ok { + requestTimeout = clockTime.Until(deadline) + } + + requestStart := clockTime.Now() + + conn, err := next.Server(ctx).Request(ctx, request) + if err != nil { + return nil, err + } + + // There can possible be a case when we are trying to heal from the local case to the remote case. Maximum captured + // difference between these times was 3x on packet cluster (0.5s local vs 1.5s remote). So taking 5x value would be + // enough to cover such local to remote case and not too much in terms of blocking subsequent Request/Close events + // (7.5s for the worst remote case). + requestDuration := clockTime.Since(requestStart) * 5 + if requestDuration > requestTimeout { + requestTimeout = requestDuration + } + + cw, loaded := f.healContextMap.LoadOrStore(request.GetConnection().GetId(), &ctxWrapper{ + request: request.Clone(), + requestTimeout: requestTimeout, + ctx: f.createHealContext(ctx, nil), + }) + if loaded { + cw.mut.Lock() + defer cw.mut.Unlock() + + if cw.cancel != nil { + cw.cancel() + cw.cancel = nil + } + cw.request = request.Clone() + if requestTimeout > cw.requestTimeout { + cw.requestTimeout = requestTimeout + } + cw.ctx = f.createHealContext(ctx, cw.ctx) + } + + return conn, nil +} + +func (f *healServer) withHandlers(ctx context.Context) context.Context { + ctx = withRequestHealConnectionFunc(ctx, f.handleHealConnectionRequest) + + var restoreConnectionHandler requestHealFuncType + switch f.onRestore { + case OnRestoreRestore: + restoreConnectionHandler = f.handleRestoreConnectionRequest + case OnRestoreHeal: + restoreConnectionHandler = f.handleHealConnectionRequest + case OnRestoreIgnore: + restoreConnectionHandler = func(*networkservice.Connection) {} + } + ctx = withRequestRestoreConnectionFunc(ctx, restoreConnectionHandler) + + return ctx +} + +func (f *healServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { + rv, err := next.Server(ctx).Close(ctx, conn) + + f.stopHeal(conn) + + return rv, err +} + +func (f *healServer) getHealContext( + conn *networkservice.Connection, +) (context.Context, *networkservice.NetworkServiceRequest, time.Duration) { + cw, ok := f.healContextMap.Load(conn.GetId()) + if !ok { + return nil, nil, 0 + } + + cw.mut.Lock() + defer cw.mut.Unlock() + + if cw.cancel != nil { + cw.cancel() + } + ctx, cancel := context.WithCancel(cw.ctx) + cw.cancel = cancel + + return ctx, cw.request.Clone(), cw.requestTimeout +} + +// handleHealConnectionRequest - heals requested connection. Returns immediately, heal is asynchronous. +func (f *healServer) handleHealConnectionRequest(conn *networkservice.Connection) { + ctx, request, requestTimeout := f.getHealContext(conn) + if request == nil { + return + } + + request.SetRequestConnection(conn.Clone()) + + go f.processHeal(ctx, request, requestTimeout) +} + +// handleRestoreConnectionRequest - recreates connection. Returns immediately, heal is asynchronous. +func (f *healServer) handleRestoreConnectionRequest(conn *networkservice.Connection) { + ctx, request, requestTimeout := f.getHealContext(conn) + if request == nil { + return + } + + request.SetRequestConnection(conn.Clone()) + + go f.restoreConnection(ctx, request, requestTimeout) +} + +func (f *healServer) stopHeal(conn *networkservice.Connection) { + cw, loaded := f.healContextMap.LoadAndDelete(conn.GetId()) + if !loaded { + return + } + + cw.mut.Lock() + defer cw.mut.Unlock() + + if cw.cancel != nil { + cw.cancel() + } +} + +func (f *healServer) restoreConnection( + ctx context.Context, + request *networkservice.NetworkServiceRequest, + requestTimeout time.Duration, +) { + clockTime := clock.FromContext(ctx) + + if ctx.Err() != nil { + return + } + + // Make sure we have a valid expireTime to work with + expires := request.GetConnection().GetNextPathSegment().GetExpires() + if !expires.IsValid() { + return + } + expireTime := expires.AsTime() + + deadline := clockTime.Now().Add(f.restoreTimeout) + if deadline.After(expireTime) { + deadline = expireTime + } + restoreCtx, restoreCancel := clockTime.WithDeadline(ctx, deadline) + defer restoreCancel() + + for restoreCtx.Err() == nil { + requestCtx, requestCancel := clockTime.WithTimeout(restoreCtx, requestTimeout) + _, err := (*f.onHeal).Request(requestCtx, request.Clone()) + requestCancel() + + if err == nil { + return + } + } + + f.processHeal(ctx, request, requestTimeout) +} + +func (f *healServer) processHeal( + ctx context.Context, + request *networkservice.NetworkServiceRequest, + requestTimeout time.Duration, +) { + clockTime := clock.FromContext(ctx) + logger := log.FromContext(ctx).WithField("healServer", "processHeal") + + if ctx.Err() != nil { + return + } + + candidates := discover.Candidates(ctx) + conn := request.GetConnection() + if candidates != nil || conn.GetPath().GetIndex() == 0 { + logger.Infof("Starting heal process for %s", conn.GetId()) + + conn.NetworkServiceEndpointName = "" + conn.Path.PathSegments = conn.Path.PathSegments[0 : conn.Path.Index+1] + + for ctx.Err() == nil { + requestCtx, requestCancel := clockTime.WithTimeout(ctx, requestTimeout) + _, err := (*f.onHeal).Request(requestCtx, request.Clone()) + requestCancel() + + if err != nil { + logger.Errorf("Failed to heal connection %s: %v", conn.GetId(), err) + } else { + logger.Infof("Finished heal process for %s", conn.GetId()) + break + } + } + } else { + // Huge timeout is not required to close connection on a current path segment + closeCtx, closeCancel := clockTime.WithTimeout(ctx, time.Second) + defer closeCancel() + + _, err := (*f.onHeal).Close(closeCtx, conn) + if err != nil { + logger.Errorf("Failed to close connection %s: %v", conn.GetId(), err) + } + } +} + +// createHealContext - create context to be used on heal. +// Uses f.ctx as base and inserts Candidates from requestCtx or cachedCtx into it, if there are any. +func (f *healServer) createHealContext(requestCtx, cachedCtx context.Context) context.Context { + ctx := requestCtx + if cachedCtx != nil { + if candidates := discover.Candidates(ctx); candidates == nil || len(candidates.Endpoints) > 0 { + ctx = cachedCtx + } + } + healCtx := f.ctx + if candidates := discover.Candidates(ctx); candidates != nil { + healCtx = discover.WithCandidates(healCtx, candidates.Endpoints, candidates.NetworkService) + } + + return healCtx +} diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 4bd21f0d7..1e1487daa 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -24,7 +24,6 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" "google.golang.org/grpc" @@ -132,9 +131,16 @@ func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, log.FromContext(ctx).Infof("expiration after %s at %s", minTimeout.String(), expireTime.UTC()) } +<<<<<<< HEAD if minTimeout == nil || *minTimeout <= 0 { return 1, nil +======= + nextClient := next.Client(ctx) + if !request.GetConnection().GetCurrentPathSegment().GetExpires().IsValid() { + return +>>>>>>> Update protobuf to v1.26.0 needed for opentelemetry } + expireTime := request.GetConnection().GetCurrentPathSegment().GetExpires().AsTime() // A heuristic to reduce the number of redundant requests in a chain // made of refreshing clients with the same expiration time: let outer diff --git a/pkg/networkservice/common/updatepath/server.go b/pkg/networkservice/common/updatepath/server.go index f398e2b10..30557a223 100644 --- a/pkg/networkservice/common/updatepath/server.go +++ b/pkg/networkservice/common/updatepath/server.go @@ -23,8 +23,12 @@ import ( "context" "github.com/golang/protobuf/ptypes/empty" +<<<<<<< HEAD +======= +>>>>>>> Update protobuf to v1.26.0 needed for opentelemetry "github.com/networkservicemesh/api/pkg/api/networkservice" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" ) @@ -52,6 +56,22 @@ func (i *updatePathServer) Request(ctx context.Context, request *networkservice. return nil, err } +<<<<<<< HEAD +======= + if prev := request.GetConnection().GetPrevPathSegment(); prev != nil { + var tok string + var expireTime time.Time + tok, expireTime, err = token.FromContext(ctx) + + if err != nil { + log.FromContext(ctx).Warnf("an error during getting token from the context: %+v", err) + } else { + prev.Expires = timestamppb.New(expireTime.Local()) + prev.Token = tok + } + } + +>>>>>>> Update protobuf to v1.26.0 needed for opentelemetry conn, err = next.Server(ctx).Request(ctx, request) if err != nil { return nil, err diff --git a/pkg/networkservice/common/updatetoken/common.go b/pkg/networkservice/common/updatetoken/common.go index 4dc6f4414..d7e56af98 100644 --- a/pkg/networkservice/common/updatetoken/common.go +++ b/pkg/networkservice/common/updatetoken/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2020-2021 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -19,9 +19,8 @@ package updatetoken import ( "context" - "github.com/golang/protobuf/ptypes/timestamp" + "google.golang.org/protobuf/types/known/timestamppb" - "github.com/golang/protobuf/ptypes" "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/pkg/errors" "google.golang.org/grpc/credentials" @@ -51,15 +50,8 @@ func updateToken(ctx context.Context, conn *networkservice.Connection, tokenGene return errors.WithStack(err) } - // Convert the expireTime to proto - var expires *timestamp.Timestamp - expires, err = ptypes.TimestampProto(expireTime) - if err != nil { - return errors.WithStack(err) - } - // Update the PathSegment path.GetPathSegments()[path.GetIndex()].Token = tok - path.GetPathSegments()[path.GetIndex()].Expires = expires + path.GetPathSegments()[path.GetIndex()].Expires = timestamppb.New(expireTime) return nil } diff --git a/pkg/networkservice/common/updatetoken/server_test.go b/pkg/networkservice/common/updatetoken/server_test.go index 58b704859..577e8f863 100644 --- a/pkg/networkservice/common/updatetoken/server_test.go +++ b/pkg/networkservice/common/updatetoken/server_test.go @@ -32,10 +32,10 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/updatetoken" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/timestamp" "go.uber.org/goleak" "google.golang.org/grpc/credentials" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/stretchr/testify/assert" @@ -55,7 +55,7 @@ type updateTokenServerSuite struct { func (f *updateTokenServerSuite) SetupSuite() { f.Token, f.Expires, _ = TokenGenerator(nil) - f.ExpiresProto, _ = ptypes.TimestampProto(f.Expires) + f.ExpiresProto = timestamppb.New(f.Expires) } func (f *updateTokenServerSuite) TestNewServer_EmptyPathInRequest() { diff --git a/pkg/registry/chains/proxydns/server_nse_test.go b/pkg/registry/chains/proxydns/server_nse_test.go index 647555b64..4711e9329 100644 --- a/pkg/registry/chains/proxydns/server_nse_test.go +++ b/pkg/registry/chains/proxydns/server_nse_test.go @@ -22,10 +22,10 @@ import ( "testing" "time" - "github.com/golang/protobuf/ptypes" "github.com/stretchr/testify/require" "go.uber.org/goleak" "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/timestamppb" registryapi "github.com/networkservicemesh/api/pkg/api/registry" @@ -68,7 +68,7 @@ func TestInterdomainNetworkServiceEndpointRegistry(t *testing.T) { SetDNSDomainName("domain2"). Build() - expirationTime, _ := ptypes.TimestampProto(time.Now().Add(time.Hour)) + expirationTime := timestamppb.New(time.Now().Add(time.Hour)) reg, err := domain2.Registry.NetworkServiceEndpointRegistryServer().Register( context.Background(), @@ -132,7 +132,7 @@ func TestLocalDomain_NetworkServiceEndpointRegistry(t *testing.T) { SetDNSResolver(dnsServer). Build() - expirationTime, _ := ptypes.TimestampProto(time.Now().Add(time.Hour)) + expirationTime := timestamppb.New(time.Now().Add(time.Hour)) reg, err := domain1.Registry.NetworkServiceEndpointRegistryServer().Register( context.Background(), @@ -208,7 +208,7 @@ func TestInterdomainFloatingNetworkServiceEndpointRegistry(t *testing.T) { SetDNSDomainName("floating.domain"). Build() - expirationTime, _ := ptypes.TimestampProto(time.Now().Add(time.Hour)) + expirationTime := timestamppb.New(time.Now().Add(time.Hour)) reg, err := domain2.Registry.NetworkServiceEndpointRegistryServer().Register( context.Background(), From 2b24e9ce94a5b4b1926eb13a8790809bc8673eee Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Mon, 14 Dec 2020 17:21:21 +0700 Subject: [PATCH 02/26] Add opentelemetry support Signed-off-by: Artem Glazychev --- go.mod | 19 ++- go.sum | 113 ++++++++++++- pkg/networkservice/chains/nsmgr/server.go | 15 ++ pkg/networkservice/common/metrics/server.go | 74 +++++++++ pkg/tools/jaeger/jaeger.go | 28 +--- pkg/tools/log/logger.go | 34 ++++ pkg/tools/log/logruslogger/logruslogger.go | 17 +- pkg/tools/log/spanlogger/span.go | 133 +++++++++++++++ pkg/tools/log/spanlogger/spanlogger.go | 61 ++----- .../opentelemetry/meterhelper/meter_helper.go | 74 +++++++++ pkg/tools/opentelemetry/opentelemetry.go | 155 ++++++++++++++++++ pkg/tools/sandbox/dial_options.go | 4 +- pkg/tools/sandbox/grpc_utils.go | 4 +- .../{opentracing => tracing}/grpcoptions.go | 53 +++++- 14 files changed, 682 insertions(+), 102 deletions(-) create mode 100644 pkg/networkservice/common/metrics/server.go create mode 100644 pkg/tools/log/spanlogger/span.go create mode 100644 pkg/tools/opentelemetry/meterhelper/meter_helper.go create mode 100644 pkg/tools/opentelemetry/opentelemetry.go rename pkg/tools/{opentracing => tracing}/grpcoptions.go (57%) diff --git a/go.mod b/go.mod index 6e091efe9..c2e15df38 100644 --- a/go.mod +++ b/go.mod @@ -21,19 +21,28 @@ require ( github.com/nats-io/stan.go v0.10.0 github.com/networkservicemesh/api v1.0.1-0.20211110183123-3038992da61a github.com/open-policy-agent/opa v0.16.1 - github.com/opentracing/opentracing-go v1.1.0 + github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.7.0 github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85 github.com/stretchr/testify v1.7.0 - github.com/uber/jaeger-client-go v2.21.1+incompatible + github.com/uber/jaeger-client-go v2.25.0+incompatible github.com/uber/jaeger-lib v2.4.0+incompatible // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.22.0 + go.opentelemetry.io/otel v1.0.0-RC2 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.22.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.22.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2 + go.opentelemetry.io/otel/metric v0.22.0 + go.opentelemetry.io/otel/sdk v1.0.0-RC2 + go.opentelemetry.io/otel/sdk/metric v0.22.0 + go.opentelemetry.io/otel/trace v1.0.0-RC2 go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect golang.org/x/tools v0.1.2 // indirect gonum.org/v1/gonum v0.6.2 - google.golang.org/grpc v1.35.0 - google.golang.org/protobuf v1.26.0 - gopkg.in/yaml.v2 v2.2.2 + google.golang.org/grpc v1.39.0 + google.golang.org/protobuf v1.27.1 + gopkg.in/yaml.v2 v2.2.3 ) diff --git a/go.sum b/go.sum index 831220162..524984606 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/HdrHistogram/hdrhistogram-go v1.0.1 h1:GX8GAYDuhlFQnI2fRDHQhTlkHMz8bEn0jTI6LJU0mpw= @@ -9,15 +11,25 @@ github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/RoaringBitmap/roaring v0.9.4 h1:ckvZSX5gwCRaJYBNe7syNawCU5oruY9gQmjXlp4riwo= github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= +<<<<<<< HEAD github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= +======= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +>>>>>>> Add opentelemetry support github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +<<<<<<< HEAD github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +======= +github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= +github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +>>>>>>> Add opentelemetry support github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -26,6 +38,7 @@ github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -41,6 +54,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -74,6 +89,7 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -84,17 +100,25 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= <<<<<<< HEAD +<<<<<<< HEAD github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= ======= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= >>>>>>> Update protobuf to v1.26.0 needed for opentelemetry +======= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +>>>>>>> Add opentelemetry support github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v0.0.0-20181024020800-521ea7b17d02/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -107,8 +131,9 @@ github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iP github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs= github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/raft v1.3.1 h1:zDT8ke8y2aP4wf9zPTB2uSIeavJ3Hx/ceY4jxI2JxuY= @@ -166,8 +191,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/open-policy-agent/opa v0.16.1 h1:BDADmi1Xl08aPcubaYgSEU0lJ/zrWDwmFMRXVPX856c= github.com/open-policy-agent/opa v0.16.1/go.mod h1:P0xUE/GQAAgnvV537GzA0Ikw4+icPELRT327QJPkaKY= -github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/peterh/liner v0.0.0-20170211195444-bf27d3ba8e1d/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= @@ -189,6 +214,7 @@ github.com/prometheus/procfs v0.7.1 h1:TlEtJq5GvGqMykEwWzbZWjjztF86swFhsPix1i0bk github.com/prometheus/procfs v0.7.1/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -198,6 +224,7 @@ github.com/spf13/pflag v0.0.0-20181024212040-082b515c9490/go.mod h1:DYY7MBk1bdzu github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85 h1:+Rnw8UZdRsA7AMJZKApyDtXM6209d+ABW4oMHtOsXoU= github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85/go.mod h1:Z6jOEo3L49OpNaK5JTIOig6K9HJhwH6cb78MF5mothQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -207,8 +234,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/uber/jaeger-client-go v2.21.1+incompatible h1:oozboeZmWz+tyh3VZttJWlF3K73mHgbokieceqKccLo= -github.com/uber/jaeger-client-go v2.21.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-client-go v2.25.0+incompatible h1:IxcNZ7WRY1Y3G4poYlx24szfsn/3LvK9QHCq9oQw8+U= +github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.0+incompatible h1:fY7QsGQWiCt8pajv4r7JEvmATdCVaWxXbjwyYwsNaLQ= github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vVRagRXf67ESqAb72hG2C/ZwI8NtJF2u2V76EsuOHGY= @@ -218,20 +245,67 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= +<<<<<<< HEAD go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= +======= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opentelemetry.io/contrib v0.22.0 h1:0F7gDEjgb1WGn4ODIjaCAg75hmqF+UN0LiVgwxsCodc= +go.opentelemetry.io/contrib v0.22.0/go.mod h1:EH4yDYeNoaTqn/8yCWQmfNB78VHfGX2Jt2bvnvzBlGM= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.22.0 h1:TjqELdtCtlOJQrTnXd2y+RP6wXKZUnnJer0HR0CSo18= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.22.0/go.mod h1:KjqwX4uJNaj479ZjFpADOMJKOM4rBXq4kN7nbeuGKrY= +go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I= +go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg= +go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.22.0 h1:Hsme7LB5XdSNkIV4bUqaziE8BdXD4JvPfRL637vltss= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.22.0/go.mod h1:gIp6+vQxqmh6Vd/mucqnsaFpOuVycQAS/BBXMKzJk0w= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.22.0 h1:jZ569LbkQNe5OJncE2QJfST84uzMo+met1MEZf2pk4I= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.22.0/go.mod h1:4V87CJ5F4+3fSg7ltkWkzpdjtEM6S82KqLWmtX2plF4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2 h1:Z/91DSYkOqnVuECrd+hxCU9lzeo5Fihjp28uq0Izfpw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2/go.mod h1:T+s8GKi1OqMwPuZ+ouDtZW4vWYpJuzIzh2Matq4Jo9k= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2 h1:PaSlrCE+hRbamroLGGgFDmzDamCxp7ID+hBvPmOhcSc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2/go.mod h1:3shayJIFcDqHi9/GT2fAHyMI/bRgc6FO0CAkhaDkhi0= +go.opentelemetry.io/otel/internal/metric v0.22.0 h1:Q9bS02XRykSRIbggaU4hVF9oWOP9PyILu26zJWoKmk0= +go.opentelemetry.io/otel/internal/metric v0.22.0/go.mod h1:7qVuMihW/ktMonEfOvBXuh6tfMvvEyoIDgeJNRloYbQ= +go.opentelemetry.io/otel/metric v0.22.0 h1:/qv10BzznqEifrXBwsTT370OCN1PRgt+mnjzMwxJKrQ= +go.opentelemetry.io/otel/metric v0.22.0/go.mod h1:KcsUkBiYGW003DJ+ugd2aqIRIfjabD9jeOUXqsAtrq0= +go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4= +go.opentelemetry.io/otel/oteltest v1.0.0-RC2 h1:xNKqMhlZYkASSyvF4JwObZFMq0jhFN3c3SP+2rCzVPk= +go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A= +go.opentelemetry.io/otel/sdk v1.0.0-RC1/go.mod h1:kj6yPn7Pgt5ByRuwesbaWcRLA+V7BSDg3Hf8xRvsvf8= +go.opentelemetry.io/otel/sdk v1.0.0-RC2 h1:ROuteeSCBaZNjiT9JcFzZepmInDvLktR28Y6qKo8bCs= +go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw= +go.opentelemetry.io/otel/sdk/export/metric v0.22.0 h1:6huidwh9LZi/+lvFw7EQ+m+pVmlfhOMd9s9PmTXAgeo= +go.opentelemetry.io/otel/sdk/export/metric v0.22.0/go.mod h1:a14rf2CiHSn9xjB6cHuv0HoZGl5C4w2PAgl+Lja1VzU= +go.opentelemetry.io/otel/sdk/metric v0.22.0 h1:ZBagqeLlTgEmvxtaN3GkvmbmG+XWKDwS+amr8EsSMDo= +go.opentelemetry.io/otel/sdk/metric v0.22.0/go.mod h1:LzkI0G0z6KhEagqmzgk3bw/dglE2Tk2OXs455UMcI0s= +go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg= +go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w= +go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4= +go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= +>>>>>>> Add opentelemetry support go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +<<<<<<< HEAD golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +======= +golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +>>>>>>> Add opentelemetry support golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -250,19 +324,27 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +<<<<<<< HEAD golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +======= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +>>>>>>> Add opentelemetry support golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -277,12 +359,18 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +<<<<<<< HEAD golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +======= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +>>>>>>> Add opentelemetry support golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= @@ -321,10 +409,12 @@ gonum.org/v1/gonum v0.6.2/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -334,8 +424,11 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -346,8 +439,9 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= @@ -356,8 +450,9 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/square/go-jose.v2 v2.4.1 h1:H0TmLt7/KmzlrDOpa1F+zr0Tk90PbJYBfsVUmRLrf9Y= gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/pkg/networkservice/chains/nsmgr/server.go b/pkg/networkservice/chains/nsmgr/server.go index 07cf8eb6c..f5cfc0fa7 100644 --- a/pkg/networkservice/chains/nsmgr/server.go +++ b/pkg/networkservice/chains/nsmgr/server.go @@ -40,6 +40,11 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/excludedprefixes" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" +<<<<<<< HEAD +======= + "github.com/networkservicemesh/sdk/pkg/networkservice/common/metrics" + "github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin" +>>>>>>> Add opentelemetry support "github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters" "github.com/networkservicemesh/sdk/pkg/registry" registryclientinfo "github.com/networkservicemesh/sdk/pkg/registry/common/clientinfo" @@ -204,9 +209,19 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options ), excludedprefixes.NewServer(ctx), recvfd.NewServer(), // Receive any files passed +<<<<<<< HEAD connect.NewServer( client.NewClient( ctx, +======= + metrics.NewServer(), + interpose.NewServer(&interposeRegistryServer), + filtermechanisms.NewServer(&urlsRegistryServer), + heal.NewServer(ctx, + heal.WithOnHeal(addressof.NetworkServiceClient(adapters.NewServerToClient(rv)))), + connect.NewServer(ctx, + client.NewClientFactory( +>>>>>>> Add opentelemetry support client.WithName(opts.name), client.WithAdditionalFunctionality( recvfd.NewClient(), diff --git a/pkg/networkservice/common/metrics/server.go b/pkg/networkservice/common/metrics/server.go new file mode 100644 index 000000000..77f9cae6f --- /dev/null +++ b/pkg/networkservice/common/metrics/server.go @@ -0,0 +1,74 @@ +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package metrics provides a chain element that sends metrics to collector +package metrics + +import ( + "context" + + "github.com/golang/protobuf/ptypes/empty" + "github.com/networkservicemesh/api/pkg/api/networkservice" + + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" + "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry/meterhelper" +) + +type metricServer struct { + helpers map[string]meterhelper.MeterHelper +} + +// NewServer returns a new metric server chain element +func NewServer() networkservice.NetworkServiceServer { + return &metricServer{ + helpers: make(map[string]meterhelper.MeterHelper), + } +} + +func (t *metricServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { + conn, err := next.Server(ctx).Request(ctx, request) + if err != nil { + return nil, err + } + + t.writeMetrics(ctx, conn.GetPath()) + return conn, nil +} + +func (t *metricServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { + _, err := next.Server(ctx).Close(ctx, conn) + if err != nil { + return nil, err + } + + t.writeMetrics(ctx, conn.GetPath()) + return &empty.Empty{}, nil +} + +func (t *metricServer) writeMetrics(ctx context.Context, path *networkservice.Path) { + if path != nil { + for _, pathSegment := range path.GetPathSegments() { + if pathSegment.Metrics == nil { + continue + } + _, ok := t.helpers[pathSegment.Id] + if !ok { + t.helpers[pathSegment.Id] = meterhelper.NewMeterHelper(pathSegment.Name, path.GetPathSegments()[0].Id) + } + t.helpers[pathSegment.Id].WriteMetrics(ctx, pathSegment.Metrics) + } + } +} diff --git a/pkg/tools/jaeger/jaeger.go b/pkg/tools/jaeger/jaeger.go index c62e7744e..1e926beef 100644 --- a/pkg/tools/jaeger/jaeger.go +++ b/pkg/tools/jaeger/jaeger.go @@ -24,38 +24,14 @@ import ( "fmt" "io" "os" - "strconv" - - "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/opentracing/opentracing-go" "github.com/uber/jaeger-client-go" "github.com/uber/jaeger-client-go/config" -) -const ( - opentracingEnv = "TRACER_ENABLED" - opentracingDefault = true + "github.com/networkservicemesh/sdk/pkg/tools/log" ) -// IsOpentracingEnabled returns true if opentracing enabled -func IsOpentracingEnabled() bool { - val, err := readEnvBool(opentracingEnv, opentracingDefault) - if err == nil { - return val - } - return opentracingDefault -} - -func readEnvBool(env string, value bool) (bool, error) { - str := os.Getenv(env) - if str == "" { - return value, nil - } - - return strconv.ParseBool(str) -} - type emptyCloser struct { } @@ -66,7 +42,7 @@ func (*emptyCloser) Close() error { // InitJaeger - returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout. func InitJaeger(ctx context.Context, service string) io.Closer { - if !IsOpentracingEnabled() { + if !log.IsOpentracingEnabled() { return &emptyCloser{} } if opentracing.IsGlobalTracerRegistered() { diff --git a/pkg/tools/log/logger.go b/pkg/tools/log/logger.go index e3af88f0f..83033448a 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -19,15 +19,49 @@ package log import ( "context" +<<<<<<< HEAD "sync/atomic" +======= + "os" +>>>>>>> Add opentelemetry support ) type contextKeyType string const ( +<<<<<<< HEAD logKey contextKeyType = "Logger" +======= + logKey contextKeyType = "Logger" + logFieldsKey contextKeyType = "LoggerFields" + + telemetryEnv = "TELEMETRY" + telemetryOT = "opentracing" + telemetryOTel = "opentelemetry" + + // Opentracing enabled by default + telemetryDefault = telemetryOTel +>>>>>>> Add opentelemetry support ) +// IsOpentracingEnabled returns true if opentracing enabled +func IsOpentracingEnabled() bool { + return telemetryOT == getTelemetryEnv() +} + +// IsOpentelemetryEnabled returns true if opentelemetry enabled +func IsOpentelemetryEnabled() bool { + return telemetryOTel == getTelemetryEnv() +} + +func getTelemetryEnv() string { + val := os.Getenv(telemetryEnv) + if val == "" { + return telemetryDefault + } + return val +} + var ( isTracingEnabled int32 = 0 ) diff --git a/pkg/tools/log/logruslogger/logruslogger.go b/pkg/tools/log/logruslogger/logruslogger.go index db5f78b9f..87807e534 100644 --- a/pkg/tools/log/logruslogger/logruslogger.go +++ b/pkg/tools/log/logruslogger/logruslogger.go @@ -26,11 +26,11 @@ import ( "sync" "github.com/google/uuid" - "github.com/opentracing/opentracing-go" "github.com/sirupsen/logrus" "google.golang.org/grpc/metadata" "github.com/networkservicemesh/sdk/pkg/tools/log" + "github.com/networkservicemesh/sdk/pkg/tools/log/spanlogger" ) type loggerKeyType string @@ -93,15 +93,17 @@ func fromContext(ctx context.Context) *traceCtxInfo { type logrusLogger struct { entry *logrus.Entry - span opentracing.Span + span spanlogger.Span info *traceCtxInfo operation string } func (s *logrusLogger) getSpan() string { - spanStr := fmt.Sprintf("%v", s.span) - if len(spanStr) > 0 && spanStr != "{}" && s.span != nil { - return fmt.Sprintf(" span=%v", spanStr) + if s.span != nil { + spanStr := s.span.ToString() + if len(spanStr) > 0 && spanStr != "{}" { + return fmt.Sprintf(" span=%v", spanStr) + } } return "" } @@ -199,9 +201,14 @@ func New(ctx context.Context, fields ...logrus.Fields) log.Logger { // FromSpan - creates a new logruslogger from context, operation and span // and returns context with it, logger, and a function to defer +<<<<<<< HEAD func FromSpan(ctx context.Context, span opentracing.Span, operation string, fields map[string]interface{}) (context.Context, log.Logger, func()) { entry := logrus.WithFields(fields) entry.Logger.SetFormatter(newFormatter()) +======= +func FromSpan(ctx context.Context, span spanlogger.Span, operation string) (context.Context, log.Logger, func()) { + entry := logrus.WithFields(log.Fields(ctx)) +>>>>>>> Add opentelemetry support var info *traceCtxInfo ctx, info = withTraceInfo(ctx) diff --git a/pkg/tools/log/spanlogger/span.go b/pkg/tools/log/spanlogger/span.go new file mode 100644 index 000000000..cefbdd9fc --- /dev/null +++ b/pkg/tools/log/spanlogger/span.go @@ -0,0 +1,133 @@ +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package spanlogger + +import ( + "context" + "fmt" + + "github.com/opentracing/opentracing-go" + opentracinglog "github.com/opentracing/opentracing-go/log" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + opentelemetry "go.opentelemetry.io/otel/trace" + + opentelemetrynsm "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" +) + +// Span - unified interface for opentracing/opentelemetry spans +type Span interface { + Log(level, format string, v ...interface{}) + LogObject(k, v interface{}) + WithField(k, v interface{}) Span + Finish() + + ToString() string +} + +// Opentracing span +type otSpan struct { + span opentracing.Span +} + +func (otsp *otSpan) Log(level, format string, v ...interface{}) { + otsp.span.LogFields( + opentracinglog.String("event", level), + opentracinglog.String("message", fmt.Sprintf(format, v...)), + ) +} + +func (otsp *otSpan) LogObject(k, v interface{}) { + otsp.span.LogFields(opentracinglog.Object(k.(string), v)) +} + +func (otsp *otSpan) WithField(k, v interface{}) Span { + otsp.span = otsp.span.SetTag(k.(string), v) + return otsp +} + +func (otsp *otSpan) ToString() string { + if spanStr := fmt.Sprintf("%v", otsp.span); spanStr != "{}" { + return spanStr + } + return "" +} + +func (otsp *otSpan) Finish() { + otsp.span.Finish() +} + +func newOTSpan(ctx context.Context, operationName string, additionalFields map[string]interface{}) (c context.Context, s Span) { + span, ctx := opentracing.StartSpanFromContext(ctx, operationName) + for k, v := range additionalFields { + span = span.SetTag(k, v) + } + return ctx, &otSpan{span: span} +} + +// Opentelemetry span +type otelSpan struct { + span opentelemetry.Span +} + +func (otelsp *otelSpan) Log(level, format string, v ...interface{}) { + otelsp.span.AddEvent( + "", + opentelemetry.WithAttributes([]attribute.KeyValue{ + attribute.String("event", level), + attribute.String("message", fmt.Sprintf(format, v...)), + }...), + ) +} + +func (otelsp *otelSpan) LogObject(k, v interface{}) { + otelsp.span.AddEvent( + "", + opentelemetry.WithAttributes([]attribute.KeyValue{ + attribute.String(fmt.Sprintf("%v", k), fmt.Sprintf("%v", v)), + }...), + ) +} + +func (otelsp *otelSpan) WithField(k, v interface{}) Span { + otelsp.span.SetAttributes(attribute.Any(k.(string), v)) + return otelsp +} + +func (otelsp *otelSpan) ToString() string { + if spanID := otelsp.span.SpanContext().SpanID(); spanID.IsValid() { + return spanID.String() + } + return "" +} + +func (otelsp *otelSpan) Finish() { + otelsp.span.End() +} + +func newOTELSpan(ctx context.Context, operationName string, additionalFields map[string]interface{}) (c context.Context, s Span) { + var add []attribute.KeyValue + + for k, v := range additionalFields { + add = append(add, attribute.Any(k, v)) + } + + ctx, span := otel.Tracer(opentelemetrynsm.InstrumentationName).Start(ctx, operationName) + span.SetAttributes(add...) + + return ctx, &otelSpan{span: span} +} diff --git a/pkg/tools/log/spanlogger/spanlogger.go b/pkg/tools/log/spanlogger/spanlogger.go index 0cce8064d..fb68f3aa8 100644 --- a/pkg/tools/log/spanlogger/spanlogger.go +++ b/pkg/tools/log/spanlogger/spanlogger.go @@ -21,26 +21,15 @@ import ( "context" "encoding/json" "fmt" - "strings" "sync" - "github.com/opentracing/opentracing-go" - opentracinglog "github.com/opentracing/opentracing-go/log" - - "github.com/networkservicemesh/sdk/pkg/tools/jaeger" "github.com/networkservicemesh/sdk/pkg/tools/log" ) -const ( - maxStringLength int = 1000 - dotCount int = 3 -) - // spanlogger - provides a way to log via opentracing spans type spanLogger struct { - span opentracing.Span - entries map[interface{}]interface{} - lock sync.RWMutex + span Span + lock sync.RWMutex } func (s *spanLogger) Info(v ...interface{}) { @@ -104,11 +93,7 @@ func (s *spanLogger) Object(k, v interface{}) { } else { msg = fmt.Sprint(v) } - - s.span.LogFields(opentracinglog.Object(k.(string), limitString(msg))) - for k, v := range s.entries { - s.span.LogKV(k, v) - } + s.span.LogObject(k, msg) } } } @@ -117,16 +102,13 @@ func (s *spanLogger) WithField(key, value interface{}) log.Logger { s.lock.RLock() defer s.lock.RUnlock() - data := make(map[interface{}]interface{}, len(s.entries)+1) - for k, v := range s.entries { - data[k] = v - } - data[key] = value - newlog := &spanLogger{ - span: s.span, - entries: data, + if s.span != nil { + newlog := &spanLogger{ + span: s.span.WithField(key, value), + } + return newlog } - return newlog + return s } func (s *spanLogger) log(level string, v ...interface{}) { @@ -139,23 +121,21 @@ func (s *spanLogger) logf(level, format string, v ...interface{}) { if s.span != nil { if v != nil { - s.span.LogFields(opentracinglog.String("event", level), opentracinglog.String("message", fmt.Sprintf(format, v...))) - for k, v := range s.entries { - s.span.LogKV(k, v) - } + s.span.Log(level, format, v...) } } } // FromContext - creates a new spanLogger from context and operation -func FromContext(ctx context.Context, operation string) (context.Context, log.Logger, opentracing.Span, func()) { - var span opentracing.Span - if jaeger.IsOpentracingEnabled() { - span, ctx = opentracing.StartSpanFromContext(ctx, operation) +func FromContext(ctx context.Context, operation string) (context.Context, log.Logger, Span, func()) { + var span Span + if log.IsOpentracingEnabled() { + ctx, span = newOTSpan(ctx, operation, log.Fields(ctx)) + } else if log.IsOpentelemetryEnabled() { + ctx, span = newOTELSpan(ctx, operation, log.Fields(ctx)) } newLog := &spanLogger{ - span: span, - entries: make(map[interface{}]interface{}), + span: span, } return ctx, newLog, span, func() { newLog.finish() } } @@ -170,10 +150,3 @@ func (s *spanLogger) finish() { s.span = nil } } - -func limitString(s string) string { - if len(s) > maxStringLength { - return s[maxStringLength-dotCount:] + strings.Repeat(".", dotCount) - } - return s -} diff --git a/pkg/tools/opentelemetry/meterhelper/meter_helper.go b/pkg/tools/opentelemetry/meterhelper/meter_helper.go new file mode 100644 index 000000000..31ac7fdb1 --- /dev/null +++ b/pkg/tools/opentelemetry/meterhelper/meter_helper.go @@ -0,0 +1,74 @@ +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package meterhelper provides a set of utilities to assist in working with opentelemetry metrics +package meterhelper + +import ( + "context" + "strconv" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/global" + + "github.com/networkservicemesh/sdk/pkg/tools/log" + "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" +) + +// MeterHelper - wrap opentelemetry Meter to simplify workflow +type MeterHelper interface { + WriteMetrics(ctx context.Context, metrics map[string]string) +} + +type meterHelper struct { + prefix string + connLabel attribute.KeyValue + meter metric.Meter + recorderMap map[string]metric.Int64ValueRecorder +} + +// NewMeterHelper - constructs a meter helper from segmentName and connectionID. +func NewMeterHelper(segmentName, connectionID string) MeterHelper { + meter := global.Meter(opentelemetry.InstrumentationName) + return &meterHelper{ + prefix: segmentName + "_", + connLabel: attribute.String("connection", connectionID), + meter: meter, + recorderMap: make(map[string]metric.Int64ValueRecorder), + } +} + +func (m *meterHelper) WriteMetrics(ctx context.Context, metrics map[string]string) { + if metrics == nil || !log.IsOpentelemetryEnabled() { + return + } + + for metricName, metricValue := range metrics { + /* Works with integers only */ + recVal, err := strconv.ParseInt(metricValue, 10, 64) + if err != nil { + continue + } + _, ok := m.recorderMap[metricName] + if !ok { + m.recorderMap[metricName] = metric.Must(m.meter).NewInt64ValueRecorder( + m.prefix + metricName, + ) + } + m.recorderMap[metricName].Record(ctx, recVal, m.connLabel) + } +} diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go new file mode 100644 index 000000000..595122889 --- /dev/null +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -0,0 +1,155 @@ +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package opentelemetry provides a set of utilities for assisting with telemetry data +package opentelemetry + +import ( + "context" + "io" + "strings" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/metric/global" + controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" + "go.opentelemetry.io/otel/sdk/metric/selector/simple" + "go.opentelemetry.io/otel/sdk/resource" + sdktrace "go.opentelemetry.io/otel/sdk/trace" + semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + + "github.com/networkservicemesh/sdk/pkg/tools/log" +) + +const ( + // InstrumentationName - denotes the library that provides the instrumentation + InstrumentationName = "NSM" + + // defaults denotes default collector address + defaultAddr = "localhost" + defaultPort = "4317" +) + +type opentelemetry struct { + io.Closer + + ctx context.Context + /* Traces */ + tracerProvider *sdktrace.TracerProvider + /* Metrics */ + metricController *controller.Controller + metricExporter *otlpmetric.Exporter +} + +func (o *opentelemetry) Close() error { + if o.tracerProvider != nil { + if err := o.tracerProvider.Shutdown(o.ctx); err != nil { + log.FromContext(o.ctx).Errorf("failed to shutdown provider: %v", err) + } + } + if o.metricController != nil { + if err := o.metricController.Stop(o.ctx); err != nil { + log.FromContext(o.ctx).Errorf("failed to shutdown controller: %v", err) + } + } + if o.metricExporter != nil { + if err := o.metricExporter.Shutdown(o.ctx); err != nil { + log.FromContext(o.ctx).Errorf("failed to stop exporter: %v", err) + } + } + return nil +} + +// Init - creates opentelemetry tracer and meter providers +func Init(ctx context.Context, collectorAddr, service string) io.Closer { + o := &opentelemetry{ + ctx: ctx, + } + if !log.IsOpentelemetryEnabled() { + return o + } + + // Check the opentlemetry collector address + if collectorAddr == "" { + collectorAddr = defaultAddr + ":" + defaultPort + } else if len(strings.Split(collectorAddr, ":")) == 1 { + collectorAddr += ":" + defaultPort + } + + // Create tracer provider + res, err := resource.New(ctx, + resource.WithAttributes( + // the service name used to display traces in backends + semconv.ServiceNameKey.String(service), + ), + ) + if err != nil { + log.FromContext(ctx).Errorf("%v", err) + return o + } + traceExporter, err := otlptracegrpc.New(ctx, + otlptracegrpc.WithInsecure(), + otlptracegrpc.WithEndpoint(collectorAddr), + ) + if err != nil { + log.FromContext(ctx).Errorf("%v", err) + return o + } + // Register the trace exporter with a TracerProvider, using a batch + // span processor to aggregate spans before export. + bsp := sdktrace.NewBatchSpanProcessor(traceExporter) + tracerProvider := sdktrace.NewTracerProvider( + sdktrace.WithSampler(sdktrace.AlwaysSample()), + sdktrace.WithResource(res), + sdktrace.WithSpanProcessor(bsp), + ) + otel.SetTracerProvider(tracerProvider) + o.tracerProvider = tracerProvider + + // Create meter provider + client := otlpmetricgrpc.NewClient( + otlpmetricgrpc.WithInsecure(), + otlpmetricgrpc.WithEndpoint(collectorAddr), + ) + metricExporter, err := otlpmetric.New(ctx, client) + if err != nil { + log.FromContext(ctx).Errorf("%v", err) + return o + } + o.metricExporter = metricExporter + + metricController := controller.New( + processor.New( + simple.NewWithExactDistribution(), + metricExporter, + ), + controller.WithExporter(metricExporter), + controller.WithCollectPeriod(2*time.Second), + ) + + if err := metricController.Start(ctx); err != nil { + log.FromContext(ctx).Errorf("%v", err) + return o + } + global.SetMeterProvider(metricController.MeterProvider()) + o.metricController = metricController + + return o +} diff --git a/pkg/tools/sandbox/dial_options.go b/pkg/tools/sandbox/dial_options.go index 4ab10cca2..2c49d23fe 100644 --- a/pkg/tools/sandbox/dial_options.go +++ b/pkg/tools/sandbox/dial_options.go @@ -21,8 +21,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "github.com/networkservicemesh/sdk/pkg/tools/opentracing" "github.com/networkservicemesh/sdk/pkg/tools/token" + "github.com/networkservicemesh/sdk/pkg/tools/tracing" ) type dialOpts struct { @@ -62,5 +62,5 @@ func DialOptions(options ...DialOption) []grpc.DialOption { grpcfd.WithChainUnaryInterceptor(), WithInsecureRPCCredentials(), WithInsecureStreamRPCCredentials(), - }, opentracing.WithTracingDial()...) + }, tracing.WithTracingDial()...) } diff --git a/pkg/tools/sandbox/grpc_utils.go b/pkg/tools/sandbox/grpc_utils.go index 7db4d289a..015c4e995 100644 --- a/pkg/tools/sandbox/grpc_utils.go +++ b/pkg/tools/sandbox/grpc_utils.go @@ -28,13 +28,13 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/grpcutils" "github.com/networkservicemesh/sdk/pkg/tools/log" - "github.com/networkservicemesh/sdk/pkg/tools/opentracing" + "github.com/networkservicemesh/sdk/pkg/tools/tracing" ) func serve(ctx context.Context, t *testing.T, u *url.URL, register func(server *grpc.Server)) { server := grpc.NewServer(append([]grpc.ServerOption{ grpc.Creds(grpcfdTransportCredentials(insecure.NewCredentials())), - }, opentracing.WithTracing()...)...) + }, tracing.WithTracing()...)...) register(server) errCh := grpcutils.ListenAndServe(ctx, u, server) diff --git a/pkg/tools/opentracing/grpcoptions.go b/pkg/tools/tracing/grpcoptions.go similarity index 57% rename from pkg/tools/opentracing/grpcoptions.go rename to pkg/tools/tracing/grpcoptions.go index 7eddaa3e1..3cbb08c04 100644 --- a/pkg/tools/opentracing/grpcoptions.go +++ b/pkg/tools/tracing/grpcoptions.go @@ -16,23 +16,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package opentracing provides a set of utilities to assist in working with opentracing -package opentracing +// Package tracing provides a set of utilities to assist in working with opentracing and opentelemetry +package tracing import ( "context" - "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" - "github.com/opentracing/opentracing-go" + "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" + "go.opentelemetry.io/otel" "google.golang.org/grpc" "google.golang.org/protobuf/proto" - "github.com/networkservicemesh/sdk/pkg/tools/jaeger" + "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" + "github.com/opentracing/opentracing-go" + + "github.com/networkservicemesh/sdk/pkg/tools/log" ) -// WithTracing - returns array of grpc.ServerOption that should be passed to grpc.Dial to enable opentracing +// WithTracing - returns array of grpc.ServerOption that should be passed to grpc.Dial to enable opentracing/opentelemetry tracing func WithTracing() []grpc.ServerOption { - if jaeger.IsOpentracingEnabled() { + if log.IsOpentracingEnabled() { interceptor := func( ctx context.Context, req interface{}, @@ -47,15 +50,30 @@ func WithTracing() []grpc.ServerOption { grpc.ChainStreamInterceptor( otgrpc.OpenTracingStreamServerInterceptor(opentracing.GlobalTracer())), } + } else if log.IsOpentelemetryEnabled() { + interceptor := func( + ctx context.Context, + req interface{}, + info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler, + ) (resp interface{}, err error) { + return otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))(ctx, proto.Clone(req.(proto.Message)), info, handler) + } + return []grpc.ServerOption{ + grpc.ChainUnaryInterceptor( + interceptor), + grpc.ChainStreamInterceptor( + otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))), + } } return []grpc.ServerOption{ grpc.EmptyServerOption{}, } } -// WithTracingDial returns array of grpc.DialOption that should be passed to grpc.Dial to enable opentracing +// WithTracingDial returns array of grpc.DialOption that should be passed to grpc.Dial to enable opentracing/opentelemetry tracing func WithTracingDial() []grpc.DialOption { - if jaeger.IsOpentracingEnabled() { + if log.IsOpentracingEnabled() { interceptor := func( ctx context.Context, method string, @@ -72,6 +90,23 @@ func WithTracingDial() []grpc.DialOption { grpc.WithChainStreamInterceptor( otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer())), } + } else if log.IsOpentelemetryEnabled() { + interceptor := func( + ctx context.Context, + method string, + req, reply interface{}, + cc *grpc.ClientConn, + invoker grpc.UnaryInvoker, + opts ...grpc.CallOption, + ) error { + return otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))(ctx, method, proto.Clone(req.(proto.Message)), reply, cc, invoker, opts...) + } + return []grpc.DialOption{ + grpc.WithChainUnaryInterceptor( + interceptor), + grpc.WithChainStreamInterceptor( + otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))), + } } return []grpc.DialOption{ grpc.EmptyDialOption{}, From f8e1fa2bc55d67a7b26f806ad1abb6bc08a6cfc5 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 27 Dec 2021 15:37:21 +0700 Subject: [PATCH 03/26] fixes Signed-off-by: Nikita Skrynnik --- pkg/tools/log/logger.go | 9 +-------- pkg/tools/log/logruslogger/logruslogger.go | 6 +----- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/pkg/tools/log/logger.go b/pkg/tools/log/logger.go index 83033448a..1387dc203 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -19,19 +19,13 @@ package log import ( "context" -<<<<<<< HEAD - "sync/atomic" -======= "os" ->>>>>>> Add opentelemetry support + "sync/atomic" ) type contextKeyType string const ( -<<<<<<< HEAD - logKey contextKeyType = "Logger" -======= logKey contextKeyType = "Logger" logFieldsKey contextKeyType = "LoggerFields" @@ -41,7 +35,6 @@ const ( // Opentracing enabled by default telemetryDefault = telemetryOTel ->>>>>>> Add opentelemetry support ) // IsOpentracingEnabled returns true if opentracing enabled diff --git a/pkg/tools/log/logruslogger/logruslogger.go b/pkg/tools/log/logruslogger/logruslogger.go index 87807e534..2afe267d8 100644 --- a/pkg/tools/log/logruslogger/logruslogger.go +++ b/pkg/tools/log/logruslogger/logruslogger.go @@ -26,6 +26,7 @@ import ( "sync" "github.com/google/uuid" + "github.com/opentracing/opentracing-go" "github.com/sirupsen/logrus" "google.golang.org/grpc/metadata" @@ -201,14 +202,9 @@ func New(ctx context.Context, fields ...logrus.Fields) log.Logger { // FromSpan - creates a new logruslogger from context, operation and span // and returns context with it, logger, and a function to defer -<<<<<<< HEAD func FromSpan(ctx context.Context, span opentracing.Span, operation string, fields map[string]interface{}) (context.Context, log.Logger, func()) { entry := logrus.WithFields(fields) entry.Logger.SetFormatter(newFormatter()) -======= -func FromSpan(ctx context.Context, span spanlogger.Span, operation string) (context.Context, log.Logger, func()) { - entry := logrus.WithFields(log.Fields(ctx)) ->>>>>>> Add opentelemetry support var info *traceCtxInfo ctx, info = withTraceInfo(ctx) From 9bed5e4540c0fe319cd662d5ae5bfebabc81c544 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Fri, 3 Dec 2021 19:07:05 +0700 Subject: [PATCH 04/26] update dependencies Signed-off-by: Nikita Skrynnik --- go.mod | 22 ++++++------ go.sum | 106 ++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 75 insertions(+), 53 deletions(-) diff --git a/go.mod b/go.mod index c2e15df38..970229edd 100644 --- a/go.mod +++ b/go.mod @@ -28,21 +28,23 @@ require ( github.com/stretchr/testify v1.7.0 github.com/uber/jaeger-client-go v2.25.0+incompatible github.com/uber/jaeger-lib v2.4.0+incompatible // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.22.0 - go.opentelemetry.io/otel v1.0.0-RC2 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.22.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.22.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2 - go.opentelemetry.io/otel/metric v0.22.0 - go.opentelemetry.io/otel/sdk v1.0.0-RC2 - go.opentelemetry.io/otel/sdk/metric v0.22.0 - go.opentelemetry.io/otel/trace v1.0.0-RC2 + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 + go.opentelemetry.io/otel v1.2.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.25.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0 + go.opentelemetry.io/otel/metric v0.25.0 + go.opentelemetry.io/otel/sdk v1.2.0 + go.opentelemetry.io/otel/sdk/metric v0.25.0 + go.opentelemetry.io/otel/trace v1.2.0 + go.opentelemetry.io/proto/otlp v0.11.0 // indirect go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect golang.org/x/tools v0.1.2 // indirect gonum.org/v1/gonum v0.6.2 - google.golang.org/grpc v1.39.0 + google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect + google.golang.org/grpc v1.42.0 google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.2.3 ) diff --git a/go.sum b/go.sum index 524984606..a1a869a05 100644 --- a/go.sum +++ b/go.sum @@ -19,26 +19,35 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd >>>>>>> Add opentelemetry support github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.2.0 h1:9Re3G2TWxkE06LdMWMpcY6KV81GLXMGiYpPYUPkFAws= +github.com/benbjohnson/clock v1.2.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= <<<<<<< HEAD github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= ======= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= -github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +<<<<<<< HEAD >>>>>>> Add opentelemetry support +======= +github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +>>>>>>> update dependencies github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -54,8 +63,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -251,42 +260,40 @@ go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= ======= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.opentelemetry.io/contrib v0.22.0 h1:0F7gDEjgb1WGn4ODIjaCAg75hmqF+UN0LiVgwxsCodc= -go.opentelemetry.io/contrib v0.22.0/go.mod h1:EH4yDYeNoaTqn/8yCWQmfNB78VHfGX2Jt2bvnvzBlGM= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.22.0 h1:TjqELdtCtlOJQrTnXd2y+RP6wXKZUnnJer0HR0CSo18= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.22.0/go.mod h1:KjqwX4uJNaj479ZjFpADOMJKOM4rBXq4kN7nbeuGKrY= -go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I= -go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg= -go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.22.0 h1:Hsme7LB5XdSNkIV4bUqaziE8BdXD4JvPfRL637vltss= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.22.0/go.mod h1:gIp6+vQxqmh6Vd/mucqnsaFpOuVycQAS/BBXMKzJk0w= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.22.0 h1:jZ569LbkQNe5OJncE2QJfST84uzMo+met1MEZf2pk4I= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.22.0/go.mod h1:4V87CJ5F4+3fSg7ltkWkzpdjtEM6S82KqLWmtX2plF4= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2 h1:Z/91DSYkOqnVuECrd+hxCU9lzeo5Fihjp28uq0Izfpw= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.0-RC2/go.mod h1:T+s8GKi1OqMwPuZ+ouDtZW4vWYpJuzIzh2Matq4Jo9k= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2 h1:PaSlrCE+hRbamroLGGgFDmzDamCxp7ID+hBvPmOhcSc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.0-RC2/go.mod h1:3shayJIFcDqHi9/GT2fAHyMI/bRgc6FO0CAkhaDkhi0= -go.opentelemetry.io/otel/internal/metric v0.22.0 h1:Q9bS02XRykSRIbggaU4hVF9oWOP9PyILu26zJWoKmk0= -go.opentelemetry.io/otel/internal/metric v0.22.0/go.mod h1:7qVuMihW/ktMonEfOvBXuh6tfMvvEyoIDgeJNRloYbQ= -go.opentelemetry.io/otel/metric v0.22.0 h1:/qv10BzznqEifrXBwsTT370OCN1PRgt+mnjzMwxJKrQ= -go.opentelemetry.io/otel/metric v0.22.0/go.mod h1:KcsUkBiYGW003DJ+ugd2aqIRIfjabD9jeOUXqsAtrq0= -go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4= -go.opentelemetry.io/otel/oteltest v1.0.0-RC2 h1:xNKqMhlZYkASSyvF4JwObZFMq0jhFN3c3SP+2rCzVPk= -go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A= -go.opentelemetry.io/otel/sdk v1.0.0-RC1/go.mod h1:kj6yPn7Pgt5ByRuwesbaWcRLA+V7BSDg3Hf8xRvsvf8= -go.opentelemetry.io/otel/sdk v1.0.0-RC2 h1:ROuteeSCBaZNjiT9JcFzZepmInDvLktR28Y6qKo8bCs= -go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw= -go.opentelemetry.io/otel/sdk/export/metric v0.22.0 h1:6huidwh9LZi/+lvFw7EQ+m+pVmlfhOMd9s9PmTXAgeo= -go.opentelemetry.io/otel/sdk/export/metric v0.22.0/go.mod h1:a14rf2CiHSn9xjB6cHuv0HoZGl5C4w2PAgl+Lja1VzU= -go.opentelemetry.io/otel/sdk/metric v0.22.0 h1:ZBagqeLlTgEmvxtaN3GkvmbmG+XWKDwS+amr8EsSMDo= -go.opentelemetry.io/otel/sdk/metric v0.22.0/go.mod h1:LzkI0G0z6KhEagqmzgk3bw/dglE2Tk2OXs455UMcI0s= -go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg= -go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w= -go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 h1:TON1iU3Y5oIytGQHIejDYLam5uoSMsmA0UV9Yupb5gQ= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0/go.mod h1:T/zQwBldOpoAEpE3HMbLnI8ydESZVz4ggw6Is4FF9LI= +go.opentelemetry.io/otel v1.2.0 h1:YOQDvxO1FayUcT9MIhJhgMyNO1WqoduiyvQHzGN0kUQ= +go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 h1:NbVnc6WbUcR0P0HQvmLU48etdb387P3HkHRPdzAh3OY= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0/go.mod h1:dhfpOVTIVpH053EJNVROYfcvZOflOvaWxhkErMikAqY= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.25.0 h1:hZgezW5v0e9mlJRWxthtzXUe3kgsMnTNBql4Ahs/Sys= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.25.0/go.mod h1:ISyuDvE9MJej8XVqVjeMTcze+RfFDXt3hxKe9CNPVVM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0 h1:xzbcGykysUh776gzD1LUPsNNHKWN0kQWDnJhn1ddUuk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0/go.mod h1:14T5gr+Y6s2AgHPqBMgnGwp04csUjQmYXFWPeiBoq5s= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0 h1:VsgsSCDwOSuO8eMVh63Cd4nACMqgjpmAeJSIvVNneD0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0/go.mod h1:9mLBBnPRf3sf+ASVH2p9xREXVBvwib02FxcKnavtExg= +go.opentelemetry.io/otel/internal/metric v0.25.0 h1:w/7RXe16WdPylaIXDgcYM6t/q0K5lXgSdZOEbIEyliE= +go.opentelemetry.io/otel/internal/metric v0.25.0/go.mod h1:Nhuw26QSX7d6n4duoqAFi5KOQR4AuzyMcl5eXOgwxtc= +go.opentelemetry.io/otel/metric v0.25.0 h1:7cXOnCADUsR3+EOqxPaSKwhEuNu0gz/56dRN1hpIdKw= +go.opentelemetry.io/otel/metric v0.25.0/go.mod h1:E884FSpQfnJOMMUaq+05IWlJ4rjZpk2s/F1Ju+TEEm8= +go.opentelemetry.io/otel/sdk v1.2.0 h1:wKN260u4DesJYhyjxDa7LRFkuhH7ncEVKU37LWcyNIo= +go.opentelemetry.io/otel/sdk v1.2.0/go.mod h1:jNN8QtpvbsKhgaC6V5lHiejMoKD+V8uadoSafgHPx1U= +go.opentelemetry.io/otel/sdk/export/metric v0.25.0 h1:6UjAFmVB5Fza3K5qUJpYWGrk8QMPIqlSnya5FI46VBY= +go.opentelemetry.io/otel/sdk/export/metric v0.25.0/go.mod h1:Ej7NOa+WpN49EIcr1HMUYRvxXXCCnQCg2+ovdt2z8Pk= +go.opentelemetry.io/otel/sdk/metric v0.25.0 h1:J+Ta+4IAA5W9AdWhGQLfciEpavBqqSkBzTDeYvJLFNU= +go.opentelemetry.io/otel/sdk/metric v0.25.0/go.mod h1:G4xzj4LvC6xDDSsVXpvRVclQCbofGGg4ZU2VKKtDRfg= +go.opentelemetry.io/otel/trace v1.2.0 h1:Ys3iqbqZhcf28hHzrm5WAquMkDHNZTUkw7KHbuNjej0= +go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +<<<<<<< HEAD go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4= go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= >>>>>>> Add opentelemetry support +======= +go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU= +go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU= +go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ= +>>>>>>> update dependencies go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= @@ -337,8 +344,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R >>>>>>> Add opentelemetry support golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c h1:WtYZ93XtWSO5KlOMgPZu7hXY9WhMZpprvlm5VwvAl8c= +golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -372,16 +379,27 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +<<<<<<< HEAD golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +======= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +>>>>>>> update dependencies golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +<<<<<<< HEAD golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +======= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +>>>>>>> update dependencies golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -415,8 +433,9 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 h1:DN5b3HU13J4sMd/QjDx34U6afpaexKTDdop+26pdjdk= +google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -426,9 +445,10 @@ google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0 h1:Klz8I9kdtkIN6EpHHUOMLCYhTn/2WAe5a0s1hcBkdTI= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 8715489a34ad0b4e2d4f26b366de25cf10782258 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 20 Dec 2021 15:13:28 +0700 Subject: [PATCH 05/26] fixes due to version update Signed-off-by: Nikita Skrynnik --- pkg/networkservice/chains/nsmgr/single_test.go | 6 ++++++ pkg/tools/log/spanlogger/span.go | 4 ++-- pkg/tools/opentelemetry/meterhelper/meter_helper.go | 6 +++--- pkg/tools/opentelemetry/opentelemetry.go | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index 127cab4f4..dbeedebe6 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -33,6 +33,8 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr" "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" "github.com/networkservicemesh/sdk/pkg/tools/clientinfo" + "github.com/networkservicemesh/sdk/pkg/tools/log" + "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" "github.com/networkservicemesh/sdk/pkg/tools/sandbox" ) @@ -42,6 +44,10 @@ func Test_DNSUsecase(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() + log.EnableTracing(true) + os.Setenv("TELEMETRY", "opentelemetry") + opentelemetry.Init(ctx, "localhost:6831", "NSM") + domain := sandbox.NewBuilder(ctx, t). SetNodesCount(1). SetNSMgrProxySupplier(nil). diff --git a/pkg/tools/log/spanlogger/span.go b/pkg/tools/log/spanlogger/span.go index cefbdd9fc..5062a9c24 100644 --- a/pkg/tools/log/spanlogger/span.go +++ b/pkg/tools/log/spanlogger/span.go @@ -104,7 +104,7 @@ func (otelsp *otelSpan) LogObject(k, v interface{}) { } func (otelsp *otelSpan) WithField(k, v interface{}) Span { - otelsp.span.SetAttributes(attribute.Any(k.(string), v)) + otelsp.span.SetAttributes(attribute.String(k.(string), fmt.Sprint(v))) return otelsp } @@ -123,7 +123,7 @@ func newOTELSpan(ctx context.Context, operationName string, additionalFields map var add []attribute.KeyValue for k, v := range additionalFields { - add = append(add, attribute.Any(k, v)) + add = append(add, attribute.String(k, fmt.Sprint(v))) } ctx, span := otel.Tracer(opentelemetrynsm.InstrumentationName).Start(ctx, operationName) diff --git a/pkg/tools/opentelemetry/meterhelper/meter_helper.go b/pkg/tools/opentelemetry/meterhelper/meter_helper.go index 31ac7fdb1..45ae2da72 100644 --- a/pkg/tools/opentelemetry/meterhelper/meter_helper.go +++ b/pkg/tools/opentelemetry/meterhelper/meter_helper.go @@ -38,7 +38,7 @@ type meterHelper struct { prefix string connLabel attribute.KeyValue meter metric.Meter - recorderMap map[string]metric.Int64ValueRecorder + recorderMap map[string]metric.Int64Histogram } // NewMeterHelper - constructs a meter helper from segmentName and connectionID. @@ -48,7 +48,7 @@ func NewMeterHelper(segmentName, connectionID string) MeterHelper { prefix: segmentName + "_", connLabel: attribute.String("connection", connectionID), meter: meter, - recorderMap: make(map[string]metric.Int64ValueRecorder), + recorderMap: make(map[string]metric.Int64Histogram), } } @@ -65,7 +65,7 @@ func (m *meterHelper) WriteMetrics(ctx context.Context, metrics map[string]strin } _, ok := m.recorderMap[metricName] if !ok { - m.recorderMap[metricName] = metric.Must(m.meter).NewInt64ValueRecorder( + m.recorderMap[metricName] = metric.Must(m.meter).NewInt64Histogram( m.prefix + metricName, ) } diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 595122889..957620961 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -136,7 +136,7 @@ func Init(ctx context.Context, collectorAddr, service string) io.Closer { o.metricExporter = metricExporter metricController := controller.New( - processor.New( + processor.NewFactory( simple.NewWithExactDistribution(), metricExporter, ), @@ -148,7 +148,7 @@ func Init(ctx context.Context, collectorAddr, service string) io.Closer { log.FromContext(ctx).Errorf("%v", err) return o } - global.SetMeterProvider(metricController.MeterProvider()) + global.SetMeterProvider(metricController) o.metricController = metricController return o From ab870cfc1db38eed7d251a3fd3ba401d76c9ff4a Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 20 Dec 2021 17:29:07 +0700 Subject: [PATCH 06/26] add jaeger exporter Signed-off-by: Nikita Skrynnik --- go.mod | 12 +-- go.sum | 41 ++++--- .../chains/nsmgr/single_test.go | 6 +- pkg/tools/jaeger/jaeger.go | 61 ++--------- pkg/tools/opentelemetry/opentelemetry.go | 100 +++++++++--------- 5 files changed, 93 insertions(+), 127 deletions(-) diff --git a/go.mod b/go.mod index 970229edd..dd97907cd 100644 --- a/go.mod +++ b/go.mod @@ -26,17 +26,14 @@ require ( github.com/sirupsen/logrus v1.7.0 github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85 github.com/stretchr/testify v1.7.0 - github.com/uber/jaeger-client-go v2.25.0+incompatible - github.com/uber/jaeger-lib v2.4.0+incompatible // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 - go.opentelemetry.io/otel v1.2.0 + go.opentelemetry.io/otel v1.3.0 + go.opentelemetry.io/otel/exporters/jaeger v1.3.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.25.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0 go.opentelemetry.io/otel/metric v0.25.0 - go.opentelemetry.io/otel/sdk v1.2.0 + go.opentelemetry.io/otel/sdk v1.3.0 go.opentelemetry.io/otel/sdk/metric v0.25.0 - go.opentelemetry.io/otel/trace v1.2.0 + go.opentelemetry.io/otel/trace v1.3.0 go.opentelemetry.io/proto/otlp v0.11.0 // indirect go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 @@ -46,5 +43,6 @@ require ( google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect google.golang.org/grpc v1.42.0 google.golang.org/protobuf v1.27.1 + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.2.3 ) diff --git a/go.sum b/go.sum index a1a869a05..0f6799783 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,6 @@ cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/HdrHistogram/hdrhistogram-go v1.0.1 h1:GX8GAYDuhlFQnI2fRDHQhTlkHMz8bEn0jTI6LJU0mpw= -github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.3 h1:wS8NNaIgtzapuArKIAjsyXtEN/IUjQkbw90xszUdS40= github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -29,11 +27,14 @@ github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> Add opentelemetry support ======= github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= >>>>>>> update dependencies +======= +>>>>>>> add jaeger exporter github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -75,8 +76,18 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +<<<<<<< HEAD github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +======= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= +github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= +github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +>>>>>>> add jaeger exporter github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= @@ -107,6 +118,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +<<<<<<< HEAD github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= <<<<<<< HEAD <<<<<<< HEAD @@ -117,6 +129,8 @@ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= >>>>>>> Update protobuf to v1.26.0 needed for opentelemetry ======= +======= +>>>>>>> add jaeger exporter github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -126,7 +140,6 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3 github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v0.0.0-20181024020800-521ea7b17d02/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= @@ -239,14 +252,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/uber/jaeger-client-go v2.25.0+incompatible h1:IxcNZ7WRY1Y3G4poYlx24szfsn/3LvK9QHCq9oQw8+U= -github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= -github.com/uber/jaeger-lib v2.4.0+incompatible h1:fY7QsGQWiCt8pajv4r7JEvmATdCVaWxXbjwyYwsNaLQ= -github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vVRagRXf67ESqAb72hG2C/ZwI8NtJF2u2V76EsuOHGY= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b/go.mod h1:HptNXiXVDcJjXe9SqMd0v2FsL9f8dz4GnXgltU6q/co= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -262,28 +270,27 @@ go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 h1:TON1iU3Y5oIytGQHIejDYLam5uoSMsmA0UV9Yupb5gQ= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0/go.mod h1:T/zQwBldOpoAEpE3HMbLnI8ydESZVz4ggw6Is4FF9LI= -go.opentelemetry.io/otel v1.2.0 h1:YOQDvxO1FayUcT9MIhJhgMyNO1WqoduiyvQHzGN0kUQ= go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= +go.opentelemetry.io/otel v1.3.0 h1:APxLf0eiBwLl+SOXiJJCVYzA1OOJNyAoV8C5RNRyy7Y= +go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs= +go.opentelemetry.io/otel/exporters/jaeger v1.3.0 h1:HfydzioALdtcB26H5WHc4K47iTETJCdloL7VN579/L0= +go.opentelemetry.io/otel/exporters/jaeger v1.3.0/go.mod h1:KoYHi1BtkUPncGSRtCe/eh1ijsnePhSkxwzz07vU0Fc= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 h1:NbVnc6WbUcR0P0HQvmLU48etdb387P3HkHRPdzAh3OY= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0/go.mod h1:dhfpOVTIVpH053EJNVROYfcvZOflOvaWxhkErMikAqY= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.25.0 h1:hZgezW5v0e9mlJRWxthtzXUe3kgsMnTNBql4Ahs/Sys= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.25.0/go.mod h1:ISyuDvE9MJej8XVqVjeMTcze+RfFDXt3hxKe9CNPVVM= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0 h1:xzbcGykysUh776gzD1LUPsNNHKWN0kQWDnJhn1ddUuk= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0/go.mod h1:14T5gr+Y6s2AgHPqBMgnGwp04csUjQmYXFWPeiBoq5s= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0 h1:VsgsSCDwOSuO8eMVh63Cd4nACMqgjpmAeJSIvVNneD0= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0/go.mod h1:9mLBBnPRf3sf+ASVH2p9xREXVBvwib02FxcKnavtExg= go.opentelemetry.io/otel/internal/metric v0.25.0 h1:w/7RXe16WdPylaIXDgcYM6t/q0K5lXgSdZOEbIEyliE= go.opentelemetry.io/otel/internal/metric v0.25.0/go.mod h1:Nhuw26QSX7d6n4duoqAFi5KOQR4AuzyMcl5eXOgwxtc= go.opentelemetry.io/otel/metric v0.25.0 h1:7cXOnCADUsR3+EOqxPaSKwhEuNu0gz/56dRN1hpIdKw= go.opentelemetry.io/otel/metric v0.25.0/go.mod h1:E884FSpQfnJOMMUaq+05IWlJ4rjZpk2s/F1Ju+TEEm8= -go.opentelemetry.io/otel/sdk v1.2.0 h1:wKN260u4DesJYhyjxDa7LRFkuhH7ncEVKU37LWcyNIo= go.opentelemetry.io/otel/sdk v1.2.0/go.mod h1:jNN8QtpvbsKhgaC6V5lHiejMoKD+V8uadoSafgHPx1U= +go.opentelemetry.io/otel/sdk v1.3.0 h1:3278edCoH89MEJ0Ky8WQXVmDQv3FX4ZJ3Pp+9fJreAI= +go.opentelemetry.io/otel/sdk v1.3.0/go.mod h1:rIo4suHNhQwBIPg9axF8V9CA72Wz2mKF1teNrup8yzs= go.opentelemetry.io/otel/sdk/export/metric v0.25.0 h1:6UjAFmVB5Fza3K5qUJpYWGrk8QMPIqlSnya5FI46VBY= go.opentelemetry.io/otel/sdk/export/metric v0.25.0/go.mod h1:Ej7NOa+WpN49EIcr1HMUYRvxXXCCnQCg2+ovdt2z8Pk= go.opentelemetry.io/otel/sdk/metric v0.25.0 h1:J+Ta+4IAA5W9AdWhGQLfciEpavBqqSkBzTDeYvJLFNU= go.opentelemetry.io/otel/sdk/metric v0.25.0/go.mod h1:G4xzj4LvC6xDDSsVXpvRVclQCbofGGg4ZU2VKKtDRfg= -go.opentelemetry.io/otel/trace v1.2.0 h1:Ys3iqbqZhcf28hHzrm5WAquMkDHNZTUkw7KHbuNjej0= go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= +go.opentelemetry.io/otel/trace v1.3.0 h1:doy8Hzb1RJ+I3yFhtDmwNc7tIyw1tNMOIsyPzp1NOGY= +go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= <<<<<<< HEAD go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4= diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index dbeedebe6..89e3e48df 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -27,12 +27,14 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/networkservicemesh/api/pkg/api/registry" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" "go.uber.org/goleak" "github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr" "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" "github.com/networkservicemesh/sdk/pkg/tools/clientinfo" + "github.com/networkservicemesh/sdk/pkg/tools/jaeger" "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" "github.com/networkservicemesh/sdk/pkg/tools/sandbox" @@ -45,8 +47,10 @@ func Test_DNSUsecase(t *testing.T) { defer cancel() log.EnableTracing(true) + logrus.SetLevel(logrus.TraceLevel) os.Setenv("TELEMETRY", "opentelemetry") - opentelemetry.Init(ctx, "localhost:6831", "NSM") + exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") + opentelemetry.Init(ctx, exporter, "NSM") domain := sandbox.NewBuilder(ctx, t). SetNodesCount(1). diff --git a/pkg/tools/jaeger/jaeger.go b/pkg/tools/jaeger/jaeger.go index 1e926beef..299c9655a 100644 --- a/pkg/tools/jaeger/jaeger.go +++ b/pkg/tools/jaeger/jaeger.go @@ -21,63 +21,24 @@ package jaeger import ( "context" - "fmt" - "io" - "os" - - "github.com/opentracing/opentracing-go" - "github.com/uber/jaeger-client-go" - "github.com/uber/jaeger-client-go/config" "github.com/networkservicemesh/sdk/pkg/tools/log" + "go.opentelemetry.io/otel/exporters/jaeger" + "go.opentelemetry.io/otel/sdk/trace" ) -type emptyCloser struct { -} - -func (*emptyCloser) Close() error { - // Ignore - return nil -} - -// InitJaeger - returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout. -func InitJaeger(ctx context.Context, service string) io.Closer { - if !log.IsOpentracingEnabled() { - return &emptyCloser{} - } - if opentracing.IsGlobalTracerRegistered() { - log.FromContext(ctx).Warnf("global opentracer is already initialized") - } - cfg, err := config.FromEnv() - if err != nil { - panic(fmt.Sprintf("ERROR: cannot create Jaeger configuration: %v\n", err)) +// InitExporter - returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout. +func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { + if !log.IsOpentelemetryEnabled() { + return nil } - if cfg.ServiceName == "" { - var hostname string - hostname, err = os.Hostname() - if err == nil { - cfg.ServiceName = fmt.Sprintf("%s@%s", service, hostname) - } else { - cfg.ServiceName = service - } - } - if cfg.Sampler.Type == "" { - cfg.Sampler.Type = "const" - } - if cfg.Sampler.Param == 0 { - cfg.Sampler.Param = 1 - } - if !cfg.Reporter.LogSpans { - cfg.Reporter.LogSpans = true - } + exporter, err := jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint(exporterURL))) - log.FromContext(ctx).Debugf("Creating logger from config: %v", cfg) - tracer, closer, err := cfg.NewTracer(config.Logger(jaeger.StdLogger)) if err != nil { - log.FromContext(ctx).Errorf("ERROR: cannot init Jaeger: %v\n", err) - return &emptyCloser{} + log.FromContext(ctx).Fatal(err) + return nil } - opentracing.SetGlobalTracer(tracer) - return closer + + return exporter } diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 957620961..6deba35a0 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -20,17 +20,10 @@ package opentelemetry import ( "context" "io" - "strings" - "time" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" - "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" - "go.opentelemetry.io/otel/metric/global" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" - processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" - "go.opentelemetry.io/otel/sdk/metric/selector/simple" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" @@ -78,7 +71,7 @@ func (o *opentelemetry) Close() error { } // Init - creates opentelemetry tracer and meter providers -func Init(ctx context.Context, collectorAddr, service string) io.Closer { +func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) io.Closer { o := &opentelemetry{ ctx: ctx, } @@ -87,13 +80,13 @@ func Init(ctx context.Context, collectorAddr, service string) io.Closer { } // Check the opentlemetry collector address - if collectorAddr == "" { - collectorAddr = defaultAddr + ":" + defaultPort - } else if len(strings.Split(collectorAddr, ":")) == 1 { - collectorAddr += ":" + defaultPort - } + // if collectorAddr == "" { + // collectorAddr = defaultAddr + ":" + defaultPort + // } else if len(strings.Split(collectorAddr, ":")) == 1 { + // collectorAddr += ":" + defaultPort + // } - // Create tracer provider + // Create resourse res, err := resource.New(ctx, resource.WithAttributes( // the service name used to display traces in backends @@ -104,52 +97,55 @@ func Init(ctx context.Context, collectorAddr, service string) io.Closer { log.FromContext(ctx).Errorf("%v", err) return o } - traceExporter, err := otlptracegrpc.New(ctx, - otlptracegrpc.WithInsecure(), - otlptracegrpc.WithEndpoint(collectorAddr), - ) - if err != nil { - log.FromContext(ctx).Errorf("%v", err) - return o - } + // Register the trace exporter with a TracerProvider, using a batch // span processor to aggregate spans before export. - bsp := sdktrace.NewBatchSpanProcessor(traceExporter) + bsp := sdktrace.NewBatchSpanProcessor(exporter) tracerProvider := sdktrace.NewTracerProvider( - sdktrace.WithSampler(sdktrace.AlwaysSample()), - sdktrace.WithResource(res), sdktrace.WithSpanProcessor(bsp), + sdktrace.WithResource(res), ) - otel.SetTracerProvider(tracerProvider) - o.tracerProvider = tracerProvider + go func() { + <-ctx.Done() + if err := tracerProvider.Shutdown(context.Background()); err != nil { + log.FromContext(ctx).Fatal(err) + } - // Create meter provider - client := otlpmetricgrpc.NewClient( - otlpmetricgrpc.WithInsecure(), - otlpmetricgrpc.WithEndpoint(collectorAddr), - ) - metricExporter, err := otlpmetric.New(ctx, client) - if err != nil { - log.FromContext(ctx).Errorf("%v", err) - return o - } - o.metricExporter = metricExporter + bsp.Shutdown(context.Background()) + exporter.Shutdown(context.Background()) + }() - metricController := controller.New( - processor.NewFactory( - simple.NewWithExactDistribution(), - metricExporter, - ), - controller.WithExporter(metricExporter), - controller.WithCollectPeriod(2*time.Second), - ) + otel.SetTracerProvider(tracerProvider) + o.tracerProvider = tracerProvider - if err := metricController.Start(ctx); err != nil { - log.FromContext(ctx).Errorf("%v", err) - return o - } - global.SetMeterProvider(metricController) - o.metricController = metricController + // // Create meter provider + // client := otlpmetricgrpc.NewClient( + // otlpmetricgrpc.WithInsecure(), + // otlpmetricgrpc.WithEndpoint(collectorAddr), + // ) + // metricExporter, err := otlpmetric.New(ctx, client) + // if err != nil { + // log.FromContext(ctx).Errorf("%v", err) + // return o + // } + + // o.metricExporter = metricExporter + + // metricController := controller.New( + // processor.NewFactory( + // simple.NewWithExactDistribution(), + // metricExporter, + // ), + // controller.WithExporter(metricExporter), + // controller.WithCollectPeriod(2*time.Second), + // ) + + // if err := metricController.Start(ctx); err != nil { + // log.FromContext(ctx).Errorf("%v", err) + // return o + // } + // global.SetMeterProvider(metricController) + // o.metricController = metricController return o } From a922d07ee59cb5791c2d6d128248e74d0097cc7b Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 20 Dec 2021 17:37:17 +0700 Subject: [PATCH 07/26] goleaks disappeared somewhere Signed-off-by: Nikita Skrynnik --- pkg/tools/jaeger/jaeger.go | 6 ++++++ pkg/tools/opentelemetry/opentelemetry.go | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/tools/jaeger/jaeger.go b/pkg/tools/jaeger/jaeger.go index 299c9655a..36960640b 100644 --- a/pkg/tools/jaeger/jaeger.go +++ b/pkg/tools/jaeger/jaeger.go @@ -34,6 +34,12 @@ func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { } exporter, err := jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint(exporterURL))) + go func() { + <-ctx.Done() + if err := exporter.Shutdown(context.Background()); err != nil { + log.FromContext(ctx).Fatal(err) + } + }() if err != nil { log.FromContext(ctx).Fatal(err) diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 6deba35a0..7d0bcbcec 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -102,6 +102,7 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i // span processor to aggregate spans before export. bsp := sdktrace.NewBatchSpanProcessor(exporter) tracerProvider := sdktrace.NewTracerProvider( + sdktrace.WithSampler(sdktrace.AlwaysSample()), sdktrace.WithSpanProcessor(bsp), sdktrace.WithResource(res), ) @@ -111,8 +112,9 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i log.FromContext(ctx).Fatal(err) } - bsp.Shutdown(context.Background()) - exporter.Shutdown(context.Background()) + if err := bsp.Shutdown(context.Background()); err != nil { + log.FromContext(ctx).Fatal(err) + } }() otel.SetTracerProvider(tracerProvider) From 5cb9784ceda5f2e2bf1d28a241824f298ec44f3d Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 20 Dec 2021 17:54:42 +0700 Subject: [PATCH 08/26] minor fixes for jaeger Signed-off-by: Nikita Skrynnik --- pkg/tools/jaeger/jaeger.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/tools/jaeger/jaeger.go b/pkg/tools/jaeger/jaeger.go index 36960640b..e89990748 100644 --- a/pkg/tools/jaeger/jaeger.go +++ b/pkg/tools/jaeger/jaeger.go @@ -27,13 +27,18 @@ import ( "go.opentelemetry.io/otel/sdk/trace" ) -// InitExporter - returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout. +// InitExporter - returns an instance of Jaeger Exporter. func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { if !log.IsOpentelemetryEnabled() { return nil } exporter, err := jaeger.New(jaeger.WithCollectorEndpoint(jaeger.WithEndpoint(exporterURL))) + if err != nil { + log.FromContext(ctx).Fatal(err) + return nil + } + go func() { <-ctx.Done() if err := exporter.Shutdown(context.Background()); err != nil { @@ -41,10 +46,5 @@ func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { } }() - if err != nil { - log.FromContext(ctx).Fatal(err) - return nil - } - return exporter } From 5c3d7051eaef25868020c44e43e1576da609d039 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 20 Dec 2021 18:08:22 +0700 Subject: [PATCH 09/26] add zipkin exporter Signed-off-by: Nikita Skrynnik --- go.mod | 11 +- go.sum | 155 +++++++++++++++++- .../chains/nsmgr/single_test.go | 6 +- pkg/tools/zipkin/zipkin.go | 50 ++++++ 4 files changed, 209 insertions(+), 13 deletions(-) create mode 100644 pkg/tools/zipkin/zipkin.go diff --git a/go.mod b/go.mod index dd97907cd..c517664cd 100644 --- a/go.mod +++ b/go.mod @@ -23,13 +23,14 @@ require ( github.com/open-policy-agent/opa v0.16.1 github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 - github.com/sirupsen/logrus v1.7.0 + github.com/sirupsen/logrus v1.8.1 github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 go.opentelemetry.io/otel v1.3.0 go.opentelemetry.io/otel/exporters/jaeger v1.3.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 + go.opentelemetry.io/otel/exporters/zipkin v1.3.0 go.opentelemetry.io/otel/metric v0.25.0 go.opentelemetry.io/otel/sdk v1.3.0 go.opentelemetry.io/otel/sdk/metric v0.25.0 @@ -37,12 +38,16 @@ require ( go.opentelemetry.io/proto/otlp v0.11.0 // indirect go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 +<<<<<<< HEAD golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect +======= + golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c // indirect + golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect +>>>>>>> add zipkin exporter golang.org/x/tools v0.1.2 // indirect gonum.org/v1/gonum v0.6.2 google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect google.golang.org/grpc v1.42.0 google.golang.org/protobuf v1.27.1 - gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect - gopkg.in/yaml.v2 v2.2.3 + gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 0f6799783..6f793ba95 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,13 @@ github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.3 h1:wS8NNaIgtzapuArKIAjsyXtEN/IUjQkbw90xszUdS40= github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +<<<<<<< HEAD github.com/RoaringBitmap/roaring v0.9.4 h1:ckvZSX5gwCRaJYBNe7syNawCU5oruY9gQmjXlp4riwo= github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= +======= +github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= +github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= +>>>>>>> add zipkin exporter github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= <<<<<<< HEAD github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= @@ -49,10 +54,19 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +<<<<<<< HEAD +======= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +>>>>>>> add zipkin exporter github.com/edwarnicke/exechelper v1.0.2 h1:dD49Ui2U0FBFxxhalnKw6vLS0P0TkgnXBRvKL/xmC5w= github.com/edwarnicke/exechelper v1.0.2/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs= github.com/edwarnicke/grpcfd v0.1.1 h1:ej5J1V7iSRa4RF1OIXfaVKsEWCMLIGiNECLgh7juxBA= @@ -70,6 +84,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -87,7 +103,11 @@ github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +<<<<<<< HEAD >>>>>>> add jaeger exporter +======= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +>>>>>>> add zipkin exporter github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= @@ -113,12 +133,14 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= <<<<<<< HEAD +<<<<<<< HEAD github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= <<<<<<< HEAD <<<<<<< HEAD @@ -131,6 +153,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ ======= ======= >>>>>>> add jaeger exporter +======= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +>>>>>>> add zipkin exporter github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -140,6 +165,9 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3 github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v0.0.0-20181024020800-521ea7b17d02/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= +github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= @@ -154,22 +182,41 @@ github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6 github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +<<<<<<< HEAD github.com/hashicorp/raft v1.3.1 h1:zDT8ke8y2aP4wf9zPTB2uSIeavJ3Hx/ceY4jxI2JxuY= github.com/hashicorp/raft v1.3.1/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= +======= +github.com/hashicorp/raft v1.1.1 h1:HJr7UE1x/JrJSc9Oy6aDBHtNHUUBHjcQjTgvUVihoZs= +github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= +github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +>>>>>>> add zipkin exporter github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= +github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= +github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= +github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg= +github.com/jcmturner/gokrb5/v8 v8.4.2/go.mod h1:sb+Xq/fTY5yktf/VxLsE3wlfPqQjp0aWNYyvBVK62bc= +github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +<<<<<<< HEAD github.com/klauspost/compress v1.11.12 h1:famVnQVu7QwryBN4jNseQdUKES71ZAOnB6UQQJPZvqk= github.com/klauspost/compress v1.11.12/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +======= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +>>>>>>> add zipkin exporter github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -204,20 +251,39 @@ github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +<<<<<<< HEAD github.com/nats-io/stan.go v0.10.0 h1:trLFZNWJ3bLpD3dxEv5kFNBPsc+QqygjfDOfqh3hqg4= github.com/nats-io/stan.go v0.10.0/go.mod h1:0jEuBXKauB1HHJswHM/lx05K48TJ1Yxj6VIfM4k+aB4= github.com/networkservicemesh/api v1.0.1-0.20211110183123-3038992da61a h1:gSujYHmGiOpJyzPGZdW2ymMpmDHCMBdbUMXCVzOtrh8= github.com/networkservicemesh/api v1.0.1-0.20211110183123-3038992da61a/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +======= +github.com/nats-io/stan.go v0.6.0 h1:26IJPeykh88d8KVLT4jJCIxCyUBOC5/IQup8oWD/QYY= +github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac= +github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8 h1:kr2/dA/ktBgnChorXBwjn7fdpRKB+eJI2xCPNCGt3ws= +github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +>>>>>>> add zipkin exporter github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/open-policy-agent/opa v0.16.1 h1:BDADmi1Xl08aPcubaYgSEU0lJ/zrWDwmFMRXVPX856c= github.com/open-policy-agent/opa v0.16.1/go.mod h1:P0xUE/GQAAgnvV537GzA0Ikw4+icPELRT327QJPkaKY= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/openzipkin/zipkin-go v0.3.0 h1:XtuXmOLIXLjiU2XduuWREDT0LOKtSgos/g7i7RYyoZQ= +github.com/openzipkin/zipkin-go v0.3.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/peterh/liner v0.0.0-20170211195444-bf27d3ba8e1d/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= +github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.0.0-20181023235946-059132a15dd0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -232,14 +298,24 @@ github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7q github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +<<<<<<< HEAD github.com/prometheus/procfs v0.7.1 h1:TlEtJq5GvGqMykEwWzbZWjjztF86swFhsPix1i0bkgA= github.com/prometheus/procfs v0.7.1/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= +======= +github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/rabbitmq/amqp091-go v1.1.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= +>>>>>>> add zipkin exporter github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cobra v0.0.0-20181021141114-fe5e611709b0/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v0.0.0-20181024212040-082b515c9490/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -252,12 +328,20 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vVRagRXf67ESqAb72hG2C/ZwI8NtJF2u2V76EsuOHGY= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b/go.mod h1:HptNXiXVDcJjXe9SqMd0v2FsL9f8dz4GnXgltU6q/co= +<<<<<<< HEAD github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +======= +>>>>>>> add zipkin exporter github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= @@ -277,6 +361,8 @@ go.opentelemetry.io/otel/exporters/jaeger v1.3.0 h1:HfydzioALdtcB26H5WHc4K47iTET go.opentelemetry.io/otel/exporters/jaeger v1.3.0/go.mod h1:KoYHi1BtkUPncGSRtCe/eh1ijsnePhSkxwzz07vU0Fc= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 h1:NbVnc6WbUcR0P0HQvmLU48etdb387P3HkHRPdzAh3OY= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0/go.mod h1:dhfpOVTIVpH053EJNVROYfcvZOflOvaWxhkErMikAqY= +go.opentelemetry.io/otel/exporters/zipkin v1.3.0 h1:uOD28dZ7yIKITTcUS6MeAGNHYy3uhP7DTkhcJM6onlQ= +go.opentelemetry.io/otel/exporters/zipkin v1.3.0/go.mod h1:LxGGfHIYbvsFnrJtBcazb0yG24xHdDGrT/H6RB9r3+8= go.opentelemetry.io/otel/internal/metric v0.25.0 h1:w/7RXe16WdPylaIXDgcYM6t/q0K5lXgSdZOEbIEyliE= go.opentelemetry.io/otel/internal/metric v0.25.0/go.mod h1:Nhuw26QSX7d6n4duoqAFi5KOQR4AuzyMcl5eXOgwxtc= go.opentelemetry.io/otel/metric v0.25.0 h1:7cXOnCADUsR3+EOqxPaSKwhEuNu0gz/56dRN1hpIdKw= @@ -317,9 +403,15 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y ======= golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +<<<<<<< HEAD golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= >>>>>>> Add opentelemetry support +======= +golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8= +golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +>>>>>>> add zipkin exporter golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -331,7 +423,10 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +<<<<<<< HEAD golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +======= +>>>>>>> add zipkin exporter golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -344,13 +439,22 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= <<<<<<< HEAD +<<<<<<< HEAD golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= ======= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= >>>>>>> Add opentelemetry support +======= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +>>>>>>> add zipkin exporter golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c h1:WtYZ93XtWSO5KlOMgPZu7hXY9WhMZpprvlm5VwvAl8c= golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -362,18 +466,32 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +<<<<<<< HEAD golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +======= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +>>>>>>> add zipkin exporter golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +<<<<<<< HEAD +======= +golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +>>>>>>> add zipkin exporter golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= <<<<<<< HEAD +<<<<<<< HEAD golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= ======= @@ -382,15 +500,27 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w >>>>>>> Add opentelemetry support golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +======= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +>>>>>>> add zipkin exporter golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= <<<<<<< HEAD +<<<<<<< HEAD golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= ======= +======= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +>>>>>>> add zipkin exporter golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= >>>>>>> update dependencies @@ -419,8 +549,12 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +<<<<<<< HEAD golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +======= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +>>>>>>> add zipkin exporter golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -471,17 +605,22 @@ google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+Rur google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/square/go-jose.v2 v2.4.1 h1:H0TmLt7/KmzlrDOpa1F+zr0Tk90PbJYBfsVUmRLrf9Y= gopkg.in/square/go-jose.v2 v2.4.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index 89e3e48df..2ccff627d 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -34,10 +34,10 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr" "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" "github.com/networkservicemesh/sdk/pkg/tools/clientinfo" - "github.com/networkservicemesh/sdk/pkg/tools/jaeger" "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" "github.com/networkservicemesh/sdk/pkg/tools/sandbox" + "github.com/networkservicemesh/sdk/pkg/tools/zipkin" ) func Test_DNSUsecase(t *testing.T) { @@ -49,7 +49,9 @@ func Test_DNSUsecase(t *testing.T) { log.EnableTracing(true) logrus.SetLevel(logrus.TraceLevel) os.Setenv("TELEMETRY", "opentelemetry") - exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") + //exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") + exporter := zipkin.InitExporter(ctx, "http://localhost:9411/api/v2/spans") + opentelemetry.Init(ctx, exporter, "NSM") domain := sandbox.NewBuilder(ctx, t). diff --git a/pkg/tools/zipkin/zipkin.go b/pkg/tools/zipkin/zipkin.go new file mode 100644 index 000000000..2694aabb1 --- /dev/null +++ b/pkg/tools/zipkin/zipkin.go @@ -0,0 +1,50 @@ +// Copyright (c) 2020 Cisco Systems, Inc. +// +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package zipkin provides a set of utilities for assisting with using zipkin +package zipkin + +import ( + "context" + + "github.com/networkservicemesh/sdk/pkg/tools/log" + "go.opentelemetry.io/otel/exporters/zipkin" + "go.opentelemetry.io/otel/sdk/trace" +) + +// InitExporter - returns an instance of Zipkin Exporter. +func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { + if !log.IsOpentelemetryEnabled() { + return nil + } + + exporter, err := zipkin.New(exporterURL) + if err != nil { + log.FromContext(ctx).Fatal(err) + return nil + } + + go func() { + <-ctx.Done() + if err := exporter.Shutdown(context.Background()); err != nil { + log.FromContext(ctx).Fatal(err) + } + }() + + return exporter +} From 6c03a75ac196b3d4c8404cb70973d0e11d1b3e1c Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Tue, 21 Dec 2021 17:35:51 +0700 Subject: [PATCH 10/26] go leaks related to transfer of the spans Signed-off-by: Nikita Skrynnik --- go.mod | 5 ---- go.sum | 8 ++++- .../chains/nsmgr/single_test.go | 10 ++++--- pkg/tools/jaeger/jaeger.go | 7 ----- pkg/tools/opentelemetry/opentelemetry.go | 29 ++++++++++--------- pkg/tools/zipkin/zipkin.go | 7 ----- 6 files changed, 28 insertions(+), 38 deletions(-) diff --git a/go.mod b/go.mod index c517664cd..d5f4993a2 100644 --- a/go.mod +++ b/go.mod @@ -38,12 +38,7 @@ require ( go.opentelemetry.io/proto/otlp v0.11.0 // indirect go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 -<<<<<<< HEAD golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect -======= - golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c // indirect - golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect ->>>>>>> add zipkin exporter golang.org/x/tools v0.1.2 // indirect gonum.org/v1/gonum v0.6.2 google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect diff --git a/go.sum b/go.sum index 6f793ba95..9f1ab2b90 100644 --- a/go.sum +++ b/go.sum @@ -389,8 +389,9 @@ go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg >>>>>>> update dependencies go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= <<<<<<< HEAD @@ -554,9 +555,14 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= ======= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +<<<<<<< HEAD >>>>>>> add zipkin exporter golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +======= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +>>>>>>> go leaks related to transfer of the spans golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index 2ccff627d..f5274458d 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -41,7 +41,10 @@ import ( ) func Test_DNSUsecase(t *testing.T) { - t.Cleanup(func() { goleak.VerifyNone(t) }) + t.Cleanup(func() { + time.Sleep(time.Second * 20) + goleak.VerifyNone(t) + }) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() @@ -49,10 +52,9 @@ func Test_DNSUsecase(t *testing.T) { log.EnableTracing(true) logrus.SetLevel(logrus.TraceLevel) os.Setenv("TELEMETRY", "opentelemetry") - //exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") + // exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") exporter := zipkin.InitExporter(ctx, "http://localhost:9411/api/v2/spans") - - opentelemetry.Init(ctx, exporter, "NSM") + opentelemetry.Init(ctx, exporter, "", "NSM") domain := sandbox.NewBuilder(ctx, t). SetNodesCount(1). diff --git a/pkg/tools/jaeger/jaeger.go b/pkg/tools/jaeger/jaeger.go index e89990748..44ed0a0ad 100644 --- a/pkg/tools/jaeger/jaeger.go +++ b/pkg/tools/jaeger/jaeger.go @@ -39,12 +39,5 @@ func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { return nil } - go func() { - <-ctx.Done() - if err := exporter.Shutdown(context.Background()); err != nil { - log.FromContext(ctx).Fatal(err) - } - }() - return exporter } diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 7d0bcbcec..079f21b58 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -20,6 +20,7 @@ package opentelemetry import ( "context" "io" + "strings" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" @@ -71,7 +72,7 @@ func (o *opentelemetry) Close() error { } // Init - creates opentelemetry tracer and meter providers -func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) io.Closer { +func Init(ctx context.Context, exporter sdktrace.SpanExporter, collectorAddr, service string) io.Closer { o := &opentelemetry{ ctx: ctx, } @@ -80,11 +81,11 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i } // Check the opentlemetry collector address - // if collectorAddr == "" { - // collectorAddr = defaultAddr + ":" + defaultPort - // } else if len(strings.Split(collectorAddr, ":")) == 1 { - // collectorAddr += ":" + defaultPort - // } + if collectorAddr == "" { + collectorAddr = defaultAddr + ":" + defaultPort + } else if len(strings.Split(collectorAddr, ":")) == 1 { + collectorAddr += ":" + defaultPort + } // Create resourse res, err := resource.New(ctx, @@ -98,6 +99,11 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i return o } + //conn, err := grpc.DialContext(ctx, "localhost:30080", grpc.WithInsecure(), grpc.WithBlock()) + + // Set up a trace exporter + //traceExporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithGRPCConn(conn)) + // Register the trace exporter with a TracerProvider, using a batch // span processor to aggregate spans before export. bsp := sdktrace.NewBatchSpanProcessor(exporter) @@ -108,19 +114,14 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i ) go func() { <-ctx.Done() - if err := tracerProvider.Shutdown(context.Background()); err != nil { - log.FromContext(ctx).Fatal(err) - } - - if err := bsp.Shutdown(context.Background()); err != nil { - log.FromContext(ctx).Fatal(err) - } + tracerProvider.ForceFlush(context.Background()) + tracerProvider.Shutdown(context.Background()) }() otel.SetTracerProvider(tracerProvider) o.tracerProvider = tracerProvider - // // Create meter provider + // Create meter provider // client := otlpmetricgrpc.NewClient( // otlpmetricgrpc.WithInsecure(), // otlpmetricgrpc.WithEndpoint(collectorAddr), diff --git a/pkg/tools/zipkin/zipkin.go b/pkg/tools/zipkin/zipkin.go index 2694aabb1..b83246f42 100644 --- a/pkg/tools/zipkin/zipkin.go +++ b/pkg/tools/zipkin/zipkin.go @@ -39,12 +39,5 @@ func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { return nil } - go func() { - <-ctx.Done() - if err := exporter.Shutdown(context.Background()); err != nil { - log.FromContext(ctx).Fatal(err) - } - }() - return exporter } From 5b3bb3ff9e0a745bb230f9cf38a03b107e20d093 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Tue, 21 Dec 2021 20:14:44 +0700 Subject: [PATCH 11/26] add opentelemetry collector support Signed-off-by: Nikita Skrynnik --- go.mod | 3 +- go.sum | 12 +++++ .../chains/nsmgr/single_test.go | 6 +-- pkg/tools/jaeger/{jaeger.go => exporter.go} | 0 pkg/tools/opentelemetry/exporter.go | 48 +++++++++++++++++++ pkg/tools/opentelemetry/opentelemetry.go | 20 +++----- pkg/tools/zipkin/{zipkin.go => exporter.go} | 0 7 files changed, 72 insertions(+), 17 deletions(-) rename pkg/tools/jaeger/{jaeger.go => exporter.go} (100%) create mode 100644 pkg/tools/opentelemetry/exporter.go rename pkg/tools/zipkin/{zipkin.go => exporter.go} (100%) diff --git a/go.mod b/go.mod index d5f4993a2..9fa9a1344 100644 --- a/go.mod +++ b/go.mod @@ -30,12 +30,13 @@ require ( go.opentelemetry.io/otel v1.3.0 go.opentelemetry.io/otel/exporters/jaeger v1.3.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0 go.opentelemetry.io/otel/exporters/zipkin v1.3.0 go.opentelemetry.io/otel/metric v0.25.0 go.opentelemetry.io/otel/sdk v1.3.0 go.opentelemetry.io/otel/sdk/metric v0.25.0 go.opentelemetry.io/otel/trace v1.3.0 - go.opentelemetry.io/proto/otlp v0.11.0 // indirect go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect diff --git a/go.sum b/go.sum index 9f1ab2b90..4a00941ca 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,7 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> Add opentelemetry support ======= github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= @@ -40,6 +41,10 @@ github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq >>>>>>> update dependencies ======= >>>>>>> add jaeger exporter +======= +github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= +github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +>>>>>>> add opentelemetry collector support github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -168,6 +173,7 @@ github.com/gorilla/mux v0.0.0-20181024020800-521ea7b17d02/go.mod h1:1lud6UwP+6or github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= @@ -359,8 +365,14 @@ go.opentelemetry.io/otel v1.3.0 h1:APxLf0eiBwLl+SOXiJJCVYzA1OOJNyAoV8C5RNRyy7Y= go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs= go.opentelemetry.io/otel/exporters/jaeger v1.3.0 h1:HfydzioALdtcB26H5WHc4K47iTETJCdloL7VN579/L0= go.opentelemetry.io/otel/exporters/jaeger v1.3.0/go.mod h1:KoYHi1BtkUPncGSRtCe/eh1ijsnePhSkxwzz07vU0Fc= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0 h1:R/OBkMoGgfy2fLhs2QhkCI1w4HLEQX92GCcJB6SSdNk= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 h1:NbVnc6WbUcR0P0HQvmLU48etdb387P3HkHRPdzAh3OY= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0/go.mod h1:dhfpOVTIVpH053EJNVROYfcvZOflOvaWxhkErMikAqY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 h1:giGm8w67Ja7amYNfYMdme7xSp2pIxThWopw8+QP51Yk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0/go.mod h1:hO1KLR7jcKaDDKDkvI9dP/FIhpmna5lkqPUQdEjFAM8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0 h1:VQbUHoJqytHHSJ1OZodPH9tvZZSVzUHjPHpkO85sT6k= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0/go.mod h1:keUU7UfnwWTWpJ+FWnyqmogPa82nuU5VUANFq49hlMY= go.opentelemetry.io/otel/exporters/zipkin v1.3.0 h1:uOD28dZ7yIKITTcUS6MeAGNHYy3uhP7DTkhcJM6onlQ= go.opentelemetry.io/otel/exporters/zipkin v1.3.0/go.mod h1:LxGGfHIYbvsFnrJtBcazb0yG24xHdDGrT/H6RB9r3+8= go.opentelemetry.io/otel/internal/metric v0.25.0 h1:w/7RXe16WdPylaIXDgcYM6t/q0K5lXgSdZOEbIEyliE= diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index f5274458d..2e0b388f1 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -37,7 +37,6 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/log" "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" "github.com/networkservicemesh/sdk/pkg/tools/sandbox" - "github.com/networkservicemesh/sdk/pkg/tools/zipkin" ) func Test_DNSUsecase(t *testing.T) { @@ -53,8 +52,9 @@ func Test_DNSUsecase(t *testing.T) { logrus.SetLevel(logrus.TraceLevel) os.Setenv("TELEMETRY", "opentelemetry") // exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") - exporter := zipkin.InitExporter(ctx, "http://localhost:9411/api/v2/spans") - opentelemetry.Init(ctx, exporter, "", "NSM") + // exporter := zipkin.InitExporter(ctx, "http://localhost:9411/api/v2/spans") + exporter := opentelemetry.InitExporter(ctx, "0.0.0.0:4317") + opentelemetry.Init(ctx, exporter, "NSM") domain := sandbox.NewBuilder(ctx, t). SetNodesCount(1). diff --git a/pkg/tools/jaeger/jaeger.go b/pkg/tools/jaeger/exporter.go similarity index 100% rename from pkg/tools/jaeger/jaeger.go rename to pkg/tools/jaeger/exporter.go diff --git a/pkg/tools/opentelemetry/exporter.go b/pkg/tools/opentelemetry/exporter.go new file mode 100644 index 000000000..af13b7109 --- /dev/null +++ b/pkg/tools/opentelemetry/exporter.go @@ -0,0 +1,48 @@ +// Copyright (c) 2021 Doc.ai and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package opentelemetry provides a set of utilities for assisting with telemetry data +package opentelemetry + +import ( + "context" + + "github.com/networkservicemesh/sdk/pkg/tools/log" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/sdk/trace" + "google.golang.org/grpc" +) + +// InitExporter - returns an instance of OpenTelemetry Exporter. +func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { + if !log.IsOpentelemetryEnabled() { + return nil + } + + traceClient := otlptracegrpc.NewClient( + otlptracegrpc.WithInsecure(), + otlptracegrpc.WithEndpoint(exporterURL), + otlptracegrpc.WithDialOption(grpc.WithBlock())) + exporter, err := otlptrace.New(ctx, traceClient) + + if err != nil { + log.FromContext(ctx).Fatal(err) + return nil + } + + return exporter +} diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 079f21b58..4c189f83f 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -20,7 +20,6 @@ package opentelemetry import ( "context" "io" - "strings" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" @@ -72,7 +71,7 @@ func (o *opentelemetry) Close() error { } // Init - creates opentelemetry tracer and meter providers -func Init(ctx context.Context, exporter sdktrace.SpanExporter, collectorAddr, service string) io.Closer { +func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) io.Closer { o := &opentelemetry{ ctx: ctx, } @@ -81,11 +80,11 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, collectorAddr, se } // Check the opentlemetry collector address - if collectorAddr == "" { - collectorAddr = defaultAddr + ":" + defaultPort - } else if len(strings.Split(collectorAddr, ":")) == 1 { - collectorAddr += ":" + defaultPort - } + // if collectorAddr == "" { + // collectorAddr = defaultAddr + ":" + defaultPort + // } else if len(strings.Split(collectorAddr, ":")) == 1 { + // collectorAddr += ":" + defaultPort + // } // Create resourse res, err := resource.New(ctx, @@ -99,18 +98,13 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, collectorAddr, se return o } - //conn, err := grpc.DialContext(ctx, "localhost:30080", grpc.WithInsecure(), grpc.WithBlock()) - - // Set up a trace exporter - //traceExporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithGRPCConn(conn)) - // Register the trace exporter with a TracerProvider, using a batch // span processor to aggregate spans before export. bsp := sdktrace.NewBatchSpanProcessor(exporter) tracerProvider := sdktrace.NewTracerProvider( sdktrace.WithSampler(sdktrace.AlwaysSample()), - sdktrace.WithSpanProcessor(bsp), sdktrace.WithResource(res), + sdktrace.WithSpanProcessor(bsp), ) go func() { <-ctx.Done() diff --git a/pkg/tools/zipkin/zipkin.go b/pkg/tools/zipkin/exporter.go similarity index 100% rename from pkg/tools/zipkin/zipkin.go rename to pkg/tools/zipkin/exporter.go From 838b665f030c298d004ec9b6de71a39979534bb7 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Wed, 22 Dec 2021 15:21:50 +0700 Subject: [PATCH 12/26] add metrics support Signed-off-by: Nikita Skrynnik --- go.mod | 8 ++- go.sum | 33 ++++++---- pkg/networkservice/chains/nsmgr/scale_test.go | 5 ++ .../chains/nsmgr/single_test.go | 5 +- pkg/tools/opentelemetry/exporter.go | 24 ++++++- pkg/tools/opentelemetry/opentelemetry.go | 63 ++++++++++--------- 6 files changed, 87 insertions(+), 51 deletions(-) diff --git a/go.mod b/go.mod index 9fa9a1344..c4ec23a47 100644 --- a/go.mod +++ b/go.mod @@ -29,13 +29,15 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 go.opentelemetry.io/otel v1.3.0 go.opentelemetry.io/otel/exporters/jaeger v1.3.0 - go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.26.0 + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.26.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0 go.opentelemetry.io/otel/exporters/zipkin v1.3.0 - go.opentelemetry.io/otel/metric v0.25.0 + go.opentelemetry.io/otel/metric v0.26.0 go.opentelemetry.io/otel/sdk v1.3.0 - go.opentelemetry.io/otel/sdk/metric v0.25.0 + go.opentelemetry.io/otel/sdk/export/metric v0.26.0 + go.opentelemetry.io/otel/sdk/metric v0.26.0 go.opentelemetry.io/otel/trace v1.3.0 go.uber.org/atomic v1.7.0 go.uber.org/goleak v1.1.10 diff --git a/go.sum b/go.sum index 4a00941ca..aa76c0cdc 100644 --- a/go.sum +++ b/go.sum @@ -22,20 +22,23 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd >>>>>>> Add opentelemetry support github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= -github.com/benbjohnson/clock v1.2.0 h1:9Re3G2TWxkE06LdMWMpcY6KV81GLXMGiYpPYUPkFAws= -github.com/benbjohnson/clock v1.2.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= <<<<<<< HEAD github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= ======= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= +<<<<<<< HEAD github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> Add opentelemetry support ======= +======= +>>>>>>> add metrics support github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= >>>>>>> update dependencies @@ -367,35 +370,39 @@ go.opentelemetry.io/otel/exporters/jaeger v1.3.0 h1:HfydzioALdtcB26H5WHc4K47iTET go.opentelemetry.io/otel/exporters/jaeger v1.3.0/go.mod h1:KoYHi1BtkUPncGSRtCe/eh1ijsnePhSkxwzz07vU0Fc= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0 h1:R/OBkMoGgfy2fLhs2QhkCI1w4HLEQX92GCcJB6SSdNk= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0 h1:NbVnc6WbUcR0P0HQvmLU48etdb387P3HkHRPdzAh3OY= -go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.25.0/go.mod h1:dhfpOVTIVpH053EJNVROYfcvZOflOvaWxhkErMikAqY= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.26.0 h1:dIE9swzwOnkGaJ6OF1QQQdBk2EdrJnD9Ilao2G9DeLU= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.26.0/go.mod h1:1E0NE+3ywwedkOEl3d7nFjyI/bqRECMhI3xTGh13pxY= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.26.0 h1:uBujg02iT0vOsjBF85BgcEaMGT6RaViwA9Sz/nh4bxQ= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.26.0/go.mod h1:pK3MWIu31OABQez2HFn3IRglTfIzXZtqRtgqE8fDt9U= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 h1:giGm8w67Ja7amYNfYMdme7xSp2pIxThWopw8+QP51Yk= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0/go.mod h1:hO1KLR7jcKaDDKDkvI9dP/FIhpmna5lkqPUQdEjFAM8= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0 h1:VQbUHoJqytHHSJ1OZodPH9tvZZSVzUHjPHpkO85sT6k= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0/go.mod h1:keUU7UfnwWTWpJ+FWnyqmogPa82nuU5VUANFq49hlMY= go.opentelemetry.io/otel/exporters/zipkin v1.3.0 h1:uOD28dZ7yIKITTcUS6MeAGNHYy3uhP7DTkhcJM6onlQ= go.opentelemetry.io/otel/exporters/zipkin v1.3.0/go.mod h1:LxGGfHIYbvsFnrJtBcazb0yG24xHdDGrT/H6RB9r3+8= -go.opentelemetry.io/otel/internal/metric v0.25.0 h1:w/7RXe16WdPylaIXDgcYM6t/q0K5lXgSdZOEbIEyliE= -go.opentelemetry.io/otel/internal/metric v0.25.0/go.mod h1:Nhuw26QSX7d6n4duoqAFi5KOQR4AuzyMcl5eXOgwxtc= -go.opentelemetry.io/otel/metric v0.25.0 h1:7cXOnCADUsR3+EOqxPaSKwhEuNu0gz/56dRN1hpIdKw= -go.opentelemetry.io/otel/metric v0.25.0/go.mod h1:E884FSpQfnJOMMUaq+05IWlJ4rjZpk2s/F1Ju+TEEm8= -go.opentelemetry.io/otel/sdk v1.2.0/go.mod h1:jNN8QtpvbsKhgaC6V5lHiejMoKD+V8uadoSafgHPx1U= +go.opentelemetry.io/otel/internal/metric v0.26.0 h1:dlrvawyd/A+X8Jp0EBT4wWEe4k5avYaXsXrBr4dbfnY= +go.opentelemetry.io/otel/internal/metric v0.26.0/go.mod h1:CbBP6AxKynRs3QCbhklyLUtpfzbqCLiafV9oY2Zj1Jk= +go.opentelemetry.io/otel/metric v0.26.0 h1:VaPYBTvA13h/FsiWfxa3yZnZEm15BhStD8JZQSA773M= +go.opentelemetry.io/otel/metric v0.26.0/go.mod h1:c6YL0fhRo4YVoNs6GoByzUgBp36hBL523rECoZA5UWg= go.opentelemetry.io/otel/sdk v1.3.0 h1:3278edCoH89MEJ0Ky8WQXVmDQv3FX4ZJ3Pp+9fJreAI= go.opentelemetry.io/otel/sdk v1.3.0/go.mod h1:rIo4suHNhQwBIPg9axF8V9CA72Wz2mKF1teNrup8yzs= -go.opentelemetry.io/otel/sdk/export/metric v0.25.0 h1:6UjAFmVB5Fza3K5qUJpYWGrk8QMPIqlSnya5FI46VBY= -go.opentelemetry.io/otel/sdk/export/metric v0.25.0/go.mod h1:Ej7NOa+WpN49EIcr1HMUYRvxXXCCnQCg2+ovdt2z8Pk= -go.opentelemetry.io/otel/sdk/metric v0.25.0 h1:J+Ta+4IAA5W9AdWhGQLfciEpavBqqSkBzTDeYvJLFNU= -go.opentelemetry.io/otel/sdk/metric v0.25.0/go.mod h1:G4xzj4LvC6xDDSsVXpvRVclQCbofGGg4ZU2VKKtDRfg= +go.opentelemetry.io/otel/sdk/export/metric v0.26.0 h1:eNseg5yyZqaAAY+Att3owR3Bl0Is5rCZywqO1OrGx18= +go.opentelemetry.io/otel/sdk/export/metric v0.26.0/go.mod h1:UpqzSnUOjFeSIVQLPp3pYIXfB/MiMFyXXzYT/bercxQ= +go.opentelemetry.io/otel/sdk/metric v0.26.0 h1:7IKp3gc/ObieCtshBeYYVFp3ZP7xIH1OzODi1Wao90Y= +go.opentelemetry.io/otel/sdk/metric v0.26.0/go.mod h1:2VIeK0kS1YvRLFg3J58ptZTXYpiWlkq2n5RQt6w7He8= go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= go.opentelemetry.io/otel/trace v1.3.0 h1:doy8Hzb1RJ+I3yFhtDmwNc7tIyw1tNMOIsyPzp1NOGY= go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= <<<<<<< HEAD +<<<<<<< HEAD go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4= go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= >>>>>>> Add opentelemetry support ======= go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU= +======= +>>>>>>> add metrics support go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU= go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ= >>>>>>> update dependencies diff --git a/pkg/networkservice/chains/nsmgr/scale_test.go b/pkg/networkservice/chains/nsmgr/scale_test.go index f81e157ec..50aa715a4 100644 --- a/pkg/networkservice/chains/nsmgr/scale_test.go +++ b/pkg/networkservice/chains/nsmgr/scale_test.go @@ -38,9 +38,14 @@ import ( func TestCreateEndpointDuringRequest(t *testing.T) { t.Cleanup(func() { goleak.VerifyNone(t) }) +<<<<<<< HEAD ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) +======= + ctx, cancel := context.WithTimeout(context.Background(), time.Second) +>>>>>>> add metrics support defer cancel() + domain := sandbox.NewBuilder(ctx, t). SetNodesCount(2). SetRegistryProxySupplier(nil). diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index 2e0b388f1..6a9a6c11c 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -53,8 +53,9 @@ func Test_DNSUsecase(t *testing.T) { os.Setenv("TELEMETRY", "opentelemetry") // exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") // exporter := zipkin.InitExporter(ctx, "http://localhost:9411/api/v2/spans") - exporter := opentelemetry.InitExporter(ctx, "0.0.0.0:4317") - opentelemetry.Init(ctx, exporter, "NSM") + spanExporter := opentelemetry.InitSpanExporter(ctx, "0.0.0.0:4317") + metricExporter := opentelemetry.InitMetricExporter(ctx, "0.0.0.0:4317") + opentelemetry.Init(ctx, spanExporter, metricExporter, "NSM") domain := sandbox.NewBuilder(ctx, t). SetNodesCount(1). diff --git a/pkg/tools/opentelemetry/exporter.go b/pkg/tools/opentelemetry/exporter.go index af13b7109..ef678b9a3 100644 --- a/pkg/tools/opentelemetry/exporter.go +++ b/pkg/tools/opentelemetry/exporter.go @@ -21,14 +21,16 @@ import ( "context" "github.com/networkservicemesh/sdk/pkg/tools/log" + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" + "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/sdk/trace" "google.golang.org/grpc" ) -// InitExporter - returns an instance of OpenTelemetry Exporter. -func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { +// InitSpanExporter - returns an instance of OpenTelemetry Exporter. +func InitSpanExporter(ctx context.Context, exporterURL string) trace.SpanExporter { if !log.IsOpentelemetryEnabled() { return nil } @@ -46,3 +48,21 @@ func InitExporter(ctx context.Context, exporterURL string) trace.SpanExporter { return exporter } + +func InitMetricExporter(ctx context.Context, exporterURL string) *otlpmetric.Exporter { + if !log.IsOpentelemetryEnabled() { + return nil + } + + client := otlpmetricgrpc.NewClient( + otlpmetricgrpc.WithInsecure(), + otlpmetricgrpc.WithEndpoint(exporterURL), + ) + exporter, err := otlpmetric.New(ctx, client) + if err != nil { + log.FromContext(ctx).Errorf("%v", err) + return nil + } + + return exporter +} diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 4c189f83f..25fd19c36 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -20,10 +20,14 @@ package opentelemetry import ( "context" "io" + "time" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" + "go.opentelemetry.io/otel/metric/global" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" + processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" + "go.opentelemetry.io/otel/sdk/metric/selector/simple" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" @@ -62,16 +66,16 @@ func (o *opentelemetry) Close() error { log.FromContext(o.ctx).Errorf("failed to shutdown controller: %v", err) } } - if o.metricExporter != nil { - if err := o.metricExporter.Shutdown(o.ctx); err != nil { - log.FromContext(o.ctx).Errorf("failed to stop exporter: %v", err) - } - } + // if o.metricExporter != nil { + // if err := o.metricExporter.Shutdown(o.ctx); err != nil { + // log.FromContext(o.ctx).Errorf("failed to stop exporter: %v", err) + // } + // } return nil } // Init - creates opentelemetry tracer and meter providers -func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) io.Closer { +func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporter *otlpmetric.Exporter, service string) io.Closer { o := &opentelemetry{ ctx: ctx, } @@ -100,7 +104,7 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i // Register the trace exporter with a TracerProvider, using a batch // span processor to aggregate spans before export. - bsp := sdktrace.NewBatchSpanProcessor(exporter) + bsp := sdktrace.NewBatchSpanProcessor(spanExporter) tracerProvider := sdktrace.NewTracerProvider( sdktrace.WithSampler(sdktrace.AlwaysSample()), sdktrace.WithResource(res), @@ -116,33 +120,30 @@ func Init(ctx context.Context, exporter sdktrace.SpanExporter, service string) i o.tracerProvider = tracerProvider // Create meter provider - // client := otlpmetricgrpc.NewClient( - // otlpmetricgrpc.WithInsecure(), - // otlpmetricgrpc.WithEndpoint(collectorAddr), - // ) - // metricExporter, err := otlpmetric.New(ctx, client) - // if err != nil { - // log.FromContext(ctx).Errorf("%v", err) - // return o - // } - // o.metricExporter = metricExporter + o.metricExporter = metricExporter - // metricController := controller.New( - // processor.NewFactory( - // simple.NewWithExactDistribution(), - // metricExporter, - // ), - // controller.WithExporter(metricExporter), - // controller.WithCollectPeriod(2*time.Second), - // ) + metricController := controller.New( + processor.NewFactory( + simple.NewWithHistogramDistribution(), + metricExporter, + ), + controller.WithExporter(metricExporter), + controller.WithCollectPeriod(2*time.Second), + ) - // if err := metricController.Start(ctx); err != nil { - // log.FromContext(ctx).Errorf("%v", err) - // return o - // } - // global.SetMeterProvider(metricController) - // o.metricController = metricController + if err := metricController.Start(ctx); err != nil { + log.FromContext(ctx).Errorf("%v", err) + return o + } + global.SetMeterProvider(metricController) + o.metricController = metricController + + go func() { + <-ctx.Done() + metricController.Stop(context.Background()) + metricExporter.Shutdown(context.Background()) + }() return o } From 4c17d3cd425a44dd1423718dd24ead650c8f6755 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Wed, 22 Dec 2021 16:07:07 +0700 Subject: [PATCH 13/26] add metrics test Signed-off-by: Nikita Skrynnik --- .../chains/nsmgr/single_test.go | 2 +- .../opentelemetry/metrics_chain_element.go | 46 +++++++++++++++++++ pkg/tools/opentelemetry/opentelemetry.go | 14 ++++-- 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 pkg/tools/opentelemetry/metrics_chain_element.go diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index 6a9a6c11c..c077230ce 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -79,7 +79,7 @@ func Test_DNSUsecase(t *testing.T) { DnsServerIps: []string{"8.8.4.4"}, SearchDomains: []string{"my.domain1"}, }, - )) + ), opentelemetry.NewServer()) corefilePath := filepath.Join(t.TempDir(), "corefile") resolveConfigPath := filepath.Join(t.TempDir(), "resolv.conf") diff --git a/pkg/tools/opentelemetry/metrics_chain_element.go b/pkg/tools/opentelemetry/metrics_chain_element.go new file mode 100644 index 000000000..07033b49b --- /dev/null +++ b/pkg/tools/opentelemetry/metrics_chain_element.go @@ -0,0 +1,46 @@ +// Copyright (c) 2020-2021 Cisco Systems, Inc. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package clienturl provides server chain element that sets client URL in context +package opentelemetry + +import ( + "context" + + "github.com/golang/protobuf/ptypes/empty" + + "github.com/networkservicemesh/api/pkg/api/networkservice" + + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" +) + +type metricsServer struct { +} + +// NewServer - returns a new server chain element that sets client URL in context +func NewServer() networkservice.NetworkServiceServer { + return &metricsServer{} +} + +func (c *metricsServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { + //request.Connection.GetCurrentPathSegment().Metrics = make(map[string]string) + //request.Connection.GetCurrentPathSegment().Metrics["my_nsm_metric"] = "10000" + return next.Server(ctx).Request(ctx, request) +} + +func (c *metricsServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { + return next.Server(ctx).Close(ctx, conn) +} diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 25fd19c36..50e000b1b 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -25,6 +25,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" "go.opentelemetry.io/otel/metric/global" + "go.opentelemetry.io/otel/sdk/export/metric" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" @@ -74,8 +75,12 @@ func (o *opentelemetry) Close() error { return nil } +type my_exporter interface { + Shutdown(context context.Context) +} + // Init - creates opentelemetry tracer and meter providers -func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporter *otlpmetric.Exporter, service string) io.Closer { +func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporter metric.Exporter, service string) io.Closer { o := &opentelemetry{ ctx: ctx, } @@ -121,7 +126,7 @@ func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporte // Create meter provider - o.metricExporter = metricExporter + // o.metricExporter = metricExporter metricController := controller.New( processor.NewFactory( @@ -142,7 +147,10 @@ func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporte go func() { <-ctx.Done() metricController.Stop(context.Background()) - metricExporter.Shutdown(context.Background()) + + if exp, ok := metricExporter.(my_exporter); ok { + exp.Shutdown(context.Background()) + } }() return o From ce24e5145c7d82cc084c1da5658ddc061e9648a6 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 27 Dec 2021 12:58:09 +0700 Subject: [PATCH 14/26] add README.md file Signed-off-by: Nikita Skrynnik --- pkg/tools/opentelemetry/README.md | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 pkg/tools/opentelemetry/README.md diff --git a/pkg/tools/opentelemetry/README.md b/pkg/tools/opentelemetry/README.md new file mode 100644 index 000000000..9b959f180 --- /dev/null +++ b/pkg/tools/opentelemetry/README.md @@ -0,0 +1,56 @@ +# OpenTelemetry Collector Example + +This file contains a description of how to launch OpenTelemetry container with Jaeger and Zipkin for spans and Prometheus for metrics using Docker. + + +## Collector +First, you need to clone repository and switch to the folder with docker-compose file: +```shell +git clone git@github.com:open-telemetry/opentelemetry-collector-contrib.git +cd opentelemetry-collector-contrib/examples/demo +``` +Before running docker-compose you need to expose port `4317` for `otel-collector` container inside `docker-compose.yaml` + +Run docker-compose file: +```shell +docker-compose up -d +``` + +The example exposes the following backends: + +- Jaeger at http://0.0.0.0:16686 +- Zipkin at http://0.0.0.0:9411 +- Prometheus at http://0.0.0.0:9090 + +## Using spans and metrics in tests +After running docker-compose you can enable spans and metrics inside any test using the following code: +```Go +log.EnableTracing(true) +os.Setenv("TELEMETRY", "opentelemetry") +spanExporter := opentelemetry.InitSpanExporter(ctx, "0.0.0.0:4317") +metricExporter := opentelemetry.InitMetricExporter(ctx, "0.0.0.0:4317") +opentelemetry.Init(ctx, spanExporter, metricExporter, "NSM") +``` + +Metrics are disabled in tests by default. You can create simple metrics chain element to test them: +```Go +type metricsServer struct { +} + +func NewServer() networkservice.NetworkServiceServer { + return &metricsServer{} +} + +func (c *metricsServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { + request.Connection.GetCurrentPathSegment().Metrics = make(map[string]string) + request.Connection.GetCurrentPathSegment().Metrics["my_nsm_metric"] = "10000" + return next.Server(ctx).Request(ctx, request) +} + +func (c *metricsServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { + return next.Server(ctx).Close(ctx, conn) +} +``` + +## Clean up +To clean up docker containers run `docker-compose down` in `opentelemetry-collector-contrib/examples/demo` folder \ No newline at end of file From 3f09405ae55b2acb79d9329a1d902c2493ea1b1e Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 27 Dec 2021 15:51:48 +0700 Subject: [PATCH 15/26] fixes after cherry-pick Signed-off-by: Nikita Skrynnik --- go.mod | 11 +- go.sum | 188 +---------- pkg/networkservice/chains/nsmgr/scale_test.go | 4 - pkg/networkservice/chains/nsmgr/server.go | 15 +- .../chains/nsmgr/single_test.go | 14 +- pkg/networkservice/common/heal/server.go | 307 ------------------ pkg/networkservice/common/refresh/client.go | 8 +- .../common/updatepath/server.go | 9 +- pkg/tools/log/logruslogger/logruslogger.go | 3 +- pkg/tools/log/spanlogger/spanlogger.go | 4 +- pkg/tools/opentelemetry/README.md | 6 +- .../opentelemetry/metrics_chain_element.go | 46 --- 12 files changed, 28 insertions(+), 587 deletions(-) delete mode 100644 pkg/networkservice/common/heal/server.go delete mode 100644 pkg/tools/opentelemetry/metrics_chain_element.go diff --git a/go.mod b/go.mod index c4ec23a47..c1f80ec02 100644 --- a/go.mod +++ b/go.mod @@ -3,18 +3,17 @@ module github.com/networkservicemesh/sdk go 1.16 require ( - github.com/HdrHistogram/hdrhistogram-go v1.0.1 // indirect github.com/RoaringBitmap/roaring v0.9.4 github.com/antonfisher/nested-logrus-formatter v1.3.1 - github.com/benbjohnson/clock v1.1.0 + github.com/benbjohnson/clock v1.3.0 github.com/edwarnicke/exechelper v1.0.2 github.com/edwarnicke/grpcfd v0.1.1 github.com/edwarnicke/serialize v1.0.7 github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 github.com/golang-jwt/jwt/v4 v4.1.0 - github.com/golang/protobuf v1.4.3 - github.com/google/go-cmp v0.5.4 + github.com/golang/protobuf v1.5.2 + github.com/google/go-cmp v0.5.6 github.com/google/uuid v1.1.2 github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/nats-io/nats-streaming-server v0.22.1 @@ -40,9 +39,7 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.26.0 go.opentelemetry.io/otel/trace v1.3.0 go.uber.org/atomic v1.7.0 - go.uber.org/goleak v1.1.10 - golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect - golang.org/x/tools v0.1.2 // indirect + go.uber.org/goleak v1.1.12 gonum.org/v1/gonum v0.6.2 google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect google.golang.org/grpc v1.42.0 diff --git a/go.sum b/go.sum index aa76c0cdc..c42f31830 100644 --- a/go.sum +++ b/go.sum @@ -6,48 +6,23 @@ github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.3 h1:wS8NNaIgtzapuArKIAjsyXtEN/IUjQkbw90xszUdS40= github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -<<<<<<< HEAD github.com/RoaringBitmap/roaring v0.9.4 h1:ckvZSX5gwCRaJYBNe7syNawCU5oruY9gQmjXlp4riwo= github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h+rzPpv4sbomAA= -======= github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= ->>>>>>> add zipkin exporter github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -<<<<<<< HEAD +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= -======= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= ->>>>>>> Add opentelemetry support github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -<<<<<<< HEAD github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -======= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= -<<<<<<< HEAD -github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -<<<<<<< HEAD -<<<<<<< HEAD -<<<<<<< HEAD ->>>>>>> Add opentelemetry support -======= -======= ->>>>>>> add metrics support github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= ->>>>>>> update dependencies -======= ->>>>>>> add jaeger exporter -======= -github.com/cenkalti/backoff/v4 v4.1.2 h1:6Yo7N8UP2K6LWZnW94DLVSSrbobcWdVzAYOisuDPIFo= -github.com/cenkalti/backoff/v4 v4.1.2/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= ->>>>>>> add opentelemetry collector support github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -67,14 +42,9 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -<<<<<<< HEAD -======= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= ->>>>>>> add zipkin exporter github.com/edwarnicke/exechelper v1.0.2 h1:dD49Ui2U0FBFxxhalnKw6vLS0P0TkgnXBRvKL/xmC5w= github.com/edwarnicke/exechelper v1.0.2/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs= github.com/edwarnicke/grpcfd v0.1.1 h1:ej5J1V7iSRa4RF1OIXfaVKsEWCMLIGiNECLgh7juxBA= @@ -100,22 +70,14 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -<<<<<<< HEAD -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -======= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= github.com/go-logr/logr v1.2.1/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.0 h1:j4LrlVXgrbIWO83mmQUnK0Hi+YnbD+vzrE1z/EphbFE= github.com/go-logr/stdr v1.2.0/go.mod h1:YkVgnZu1ZjjL7xTxrfm/LLZBfkhTqSR1ydtm6jTKKwI= -github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -<<<<<<< HEAD ->>>>>>> add jaeger exporter -======= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= ->>>>>>> add zipkin exporter github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= @@ -147,27 +109,10 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -<<<<<<< HEAD -<<<<<<< HEAD -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -<<<<<<< HEAD -<<<<<<< HEAD -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -======= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= ->>>>>>> Update protobuf to v1.26.0 needed for opentelemetry -======= -======= ->>>>>>> add jaeger exporter -======= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= ->>>>>>> add zipkin exporter github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= ->>>>>>> Add opentelemetry support github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -195,15 +140,9 @@ github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2I github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -<<<<<<< HEAD github.com/hashicorp/raft v1.3.1 h1:zDT8ke8y2aP4wf9zPTB2uSIeavJ3Hx/ceY4jxI2JxuY= github.com/hashicorp/raft v1.3.1/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= -======= -github.com/hashicorp/raft v1.1.1 h1:HJr7UE1x/JrJSc9Oy6aDBHtNHUUBHjcQjTgvUVihoZs= -github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8= -github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= ->>>>>>> add zipkin exporter github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM= @@ -215,12 +154,9 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -<<<<<<< HEAD -github.com/klauspost/compress v1.11.12 h1:famVnQVu7QwryBN4jNseQdUKES71ZAOnB6UQQJPZvqk= github.com/klauspost/compress v1.11.12/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -======= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= ->>>>>>> add zipkin exporter github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -260,21 +196,12 @@ github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -<<<<<<< HEAD github.com/nats-io/stan.go v0.10.0 h1:trLFZNWJ3bLpD3dxEv5kFNBPsc+QqygjfDOfqh3hqg4= github.com/nats-io/stan.go v0.10.0/go.mod h1:0jEuBXKauB1HHJswHM/lx05K48TJ1Yxj6VIfM4k+aB4= github.com/networkservicemesh/api v1.0.1-0.20211110183123-3038992da61a h1:gSujYHmGiOpJyzPGZdW2ymMpmDHCMBdbUMXCVzOtrh8= github.com/networkservicemesh/api v1.0.1-0.20211110183123-3038992da61a/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -======= -github.com/nats-io/stan.go v0.6.0 h1:26IJPeykh88d8KVLT4jJCIxCyUBOC5/IQup8oWD/QYY= -github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac= -github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8 h1:kr2/dA/ktBgnChorXBwjn7fdpRKB+eJI2xCPNCGt3ws= -github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8/go.mod h1:B6meq/SWjWR6bGXZdXPfbOeaBK+T1JayLdtEJQCsXKU= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= ->>>>>>> add zipkin exporter github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -307,15 +234,9 @@ github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39/go.mod h1:daVV7q github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -<<<<<<< HEAD github.com/prometheus/procfs v0.7.1 h1:TlEtJq5GvGqMykEwWzbZWjjztF86swFhsPix1i0bkgA= github.com/prometheus/procfs v0.7.1/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= -======= -github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rabbitmq/amqp091-go v1.1.0/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= ->>>>>>> add zipkin exporter github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -347,20 +268,13 @@ github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+ github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vVRagRXf67ESqAb72hG2C/ZwI8NtJF2u2V76EsuOHGY= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b/go.mod h1:HptNXiXVDcJjXe9SqMd0v2FsL9f8dz4GnXgltU6q/co= -<<<<<<< HEAD github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -======= ->>>>>>> add zipkin exporter github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= -<<<<<<< HEAD go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -======= -go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= -go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 h1:TON1iU3Y5oIytGQHIejDYLam5uoSMsmA0UV9Yupb5gQ= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0/go.mod h1:T/zQwBldOpoAEpE3HMbLnI8ydESZVz4ggw6Is4FF9LI= go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= @@ -394,18 +308,8 @@ go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3 go.opentelemetry.io/otel/trace v1.3.0 h1:doy8Hzb1RJ+I3yFhtDmwNc7tIyw1tNMOIsyPzp1NOGY= go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -<<<<<<< HEAD -<<<<<<< HEAD -go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4= -go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= ->>>>>>> Add opentelemetry support -======= -go.opentelemetry.io/proto/otlp v0.10.0/go.mod h1:zG20xCK0szZ1xdokeSOwEcmlXu+x9kkdRe6N1DhKcfU= -======= ->>>>>>> add metrics support go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU= go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ= ->>>>>>> update dependencies go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= @@ -413,25 +317,14 @@ go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -<<<<<<< HEAD golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -======= -golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -<<<<<<< HEAD -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= ->>>>>>> Add opentelemetry support -======= -golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 h1:kETrAMYZq6WVGPa8IIixL0CaEcIUNi+1WX7grUoi3y8= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= ->>>>>>> add zipkin exporter golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -443,10 +336,7 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -<<<<<<< HEAD golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -======= ->>>>>>> add zipkin exporter golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -458,25 +348,16 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -<<<<<<< HEAD -<<<<<<< HEAD -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -======= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= ->>>>>>> Add opentelemetry support -======= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= ->>>>>>> add zipkin exporter golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20210917221730-978cfadd31cf h1:R150MpwJIv1MpS0N/pc+NhTM8ajzvlmxlY5OYsrevXQ= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c h1:WtYZ93XtWSO5KlOMgPZu7hXY9WhMZpprvlm5VwvAl8c= -golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -486,77 +367,42 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -<<<<<<< HEAD golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -======= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= ->>>>>>> add zipkin exporter +golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -<<<<<<< HEAD -======= -golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= ->>>>>>> add zipkin exporter golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -<<<<<<< HEAD -<<<<<<< HEAD -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -======= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= ->>>>>>> Add opentelemetry support -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -======= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= ->>>>>>> add zipkin exporter +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -<<<<<<< HEAD -<<<<<<< HEAD golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -======= -======= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= ->>>>>>> add zipkin exporter -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= ->>>>>>> update dependencies golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -<<<<<<< HEAD -golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= -golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -======= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= ->>>>>>> update dependencies +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -569,19 +415,11 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -<<<<<<< HEAD golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -======= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -<<<<<<< HEAD ->>>>>>> add zipkin exporter -golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -======= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= ->>>>>>> go leaks related to transfer of the spans golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/networkservice/chains/nsmgr/scale_test.go b/pkg/networkservice/chains/nsmgr/scale_test.go index 50aa715a4..09ae2e084 100644 --- a/pkg/networkservice/chains/nsmgr/scale_test.go +++ b/pkg/networkservice/chains/nsmgr/scale_test.go @@ -38,12 +38,8 @@ import ( func TestCreateEndpointDuringRequest(t *testing.T) { t.Cleanup(func() { goleak.VerifyNone(t) }) -<<<<<<< HEAD ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) -======= - ctx, cancel := context.WithTimeout(context.Background(), time.Second) ->>>>>>> add metrics support defer cancel() domain := sandbox.NewBuilder(ctx, t). diff --git a/pkg/networkservice/chains/nsmgr/server.go b/pkg/networkservice/chains/nsmgr/server.go index f5cfc0fa7..0db8f8b58 100644 --- a/pkg/networkservice/chains/nsmgr/server.go +++ b/pkg/networkservice/chains/nsmgr/server.go @@ -40,11 +40,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/excludedprefixes" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" -<<<<<<< HEAD -======= "github.com/networkservicemesh/sdk/pkg/networkservice/common/metrics" - "github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin" ->>>>>>> Add opentelemetry support "github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters" "github.com/networkservicemesh/sdk/pkg/registry" registryclientinfo "github.com/networkservicemesh/sdk/pkg/registry/common/clientinfo" @@ -209,19 +205,10 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options ), excludedprefixes.NewServer(ctx), recvfd.NewServer(), // Receive any files passed -<<<<<<< HEAD + metrics.NewServer(), connect.NewServer( client.NewClient( ctx, -======= - metrics.NewServer(), - interpose.NewServer(&interposeRegistryServer), - filtermechanisms.NewServer(&urlsRegistryServer), - heal.NewServer(ctx, - heal.WithOnHeal(addressof.NetworkServiceClient(adapters.NewServerToClient(rv)))), - connect.NewServer(ctx, - client.NewClientFactory( ->>>>>>> Add opentelemetry support client.WithName(opts.name), client.WithAdditionalFunctionality( recvfd.NewClient(), diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index c077230ce..7b14c42d5 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -27,15 +27,12 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/networkservicemesh/api/pkg/api/registry" - "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" "go.uber.org/goleak" "github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr" "github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext" "github.com/networkservicemesh/sdk/pkg/tools/clientinfo" - "github.com/networkservicemesh/sdk/pkg/tools/log" - "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" "github.com/networkservicemesh/sdk/pkg/tools/sandbox" ) @@ -48,15 +45,6 @@ func Test_DNSUsecase(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - log.EnableTracing(true) - logrus.SetLevel(logrus.TraceLevel) - os.Setenv("TELEMETRY", "opentelemetry") - // exporter := jaeger.InitExporter(ctx, "http://localhost:14268/api/traces") - // exporter := zipkin.InitExporter(ctx, "http://localhost:9411/api/v2/spans") - spanExporter := opentelemetry.InitSpanExporter(ctx, "0.0.0.0:4317") - metricExporter := opentelemetry.InitMetricExporter(ctx, "0.0.0.0:4317") - opentelemetry.Init(ctx, spanExporter, metricExporter, "NSM") - domain := sandbox.NewBuilder(ctx, t). SetNodesCount(1). SetNSMgrProxySupplier(nil). @@ -79,7 +67,7 @@ func Test_DNSUsecase(t *testing.T) { DnsServerIps: []string{"8.8.4.4"}, SearchDomains: []string{"my.domain1"}, }, - ), opentelemetry.NewServer()) + )) corefilePath := filepath.Join(t.TempDir(), "corefile") resolveConfigPath := filepath.Join(t.TempDir(), "resolv.conf") diff --git a/pkg/networkservice/common/heal/server.go b/pkg/networkservice/common/heal/server.go deleted file mode 100644 index 5284e9293..000000000 --- a/pkg/networkservice/common/heal/server.go +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (c) 2020 Cisco Systems, Inc. -// -// Copyright (c) 2021 Doc.ai and/or its affiliates. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package heal provides a chain element that carries out proper nsm healing from client to endpoint -package heal - -import ( - "context" - "sync" - "time" - - "github.com/golang/protobuf/ptypes/empty" - - "github.com/networkservicemesh/api/pkg/api/networkservice" - - "github.com/networkservicemesh/sdk/pkg/networkservice/common/discover" - "github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters" - "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/networkservicemesh/sdk/pkg/tools/addressof" - "github.com/networkservicemesh/sdk/pkg/tools/clock" - "github.com/networkservicemesh/sdk/pkg/tools/log" -) - -type ctxWrapper struct { - mut sync.Mutex - request *networkservice.NetworkServiceRequest - requestTimeout time.Duration - ctx context.Context - cancel func() -} - -type healServer struct { - ctx context.Context - onHeal *networkservice.NetworkServiceClient - onRestore OnRestore - restoreTimeout time.Duration - healContextMap ctxWrapperMap -} - -// NewServer - creates a new networkservice.NetworkServiceServer chain element that implements the healing algorithm -func NewServer(ctx context.Context, opts ...Option) networkservice.NetworkServiceServer { - healOpts := &healOptions{ - onRestore: OnRestoreHeal, - restoreTimeout: time.Minute, - } - for _, opt := range opts { - opt(healOpts) - } - - rv := &healServer{ - ctx: ctx, - onHeal: healOpts.onHeal, - onRestore: healOpts.onRestore, - restoreTimeout: healOpts.restoreTimeout, - } - - if rv.onHeal == nil { - rv.onHeal = addressof.NetworkServiceClient(adapters.NewServerToClient(rv)) - } - - return rv -} - -func (f *healServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { - clockTime := clock.FromContext(ctx) - ctx = f.withHandlers(ctx) - - requestTimeout := time.Duration(0) - if deadline, ok := ctx.Deadline(); ok { - requestTimeout = clockTime.Until(deadline) - } - - requestStart := clockTime.Now() - - conn, err := next.Server(ctx).Request(ctx, request) - if err != nil { - return nil, err - } - - // There can possible be a case when we are trying to heal from the local case to the remote case. Maximum captured - // difference between these times was 3x on packet cluster (0.5s local vs 1.5s remote). So taking 5x value would be - // enough to cover such local to remote case and not too much in terms of blocking subsequent Request/Close events - // (7.5s for the worst remote case). - requestDuration := clockTime.Since(requestStart) * 5 - if requestDuration > requestTimeout { - requestTimeout = requestDuration - } - - cw, loaded := f.healContextMap.LoadOrStore(request.GetConnection().GetId(), &ctxWrapper{ - request: request.Clone(), - requestTimeout: requestTimeout, - ctx: f.createHealContext(ctx, nil), - }) - if loaded { - cw.mut.Lock() - defer cw.mut.Unlock() - - if cw.cancel != nil { - cw.cancel() - cw.cancel = nil - } - cw.request = request.Clone() - if requestTimeout > cw.requestTimeout { - cw.requestTimeout = requestTimeout - } - cw.ctx = f.createHealContext(ctx, cw.ctx) - } - - return conn, nil -} - -func (f *healServer) withHandlers(ctx context.Context) context.Context { - ctx = withRequestHealConnectionFunc(ctx, f.handleHealConnectionRequest) - - var restoreConnectionHandler requestHealFuncType - switch f.onRestore { - case OnRestoreRestore: - restoreConnectionHandler = f.handleRestoreConnectionRequest - case OnRestoreHeal: - restoreConnectionHandler = f.handleHealConnectionRequest - case OnRestoreIgnore: - restoreConnectionHandler = func(*networkservice.Connection) {} - } - ctx = withRequestRestoreConnectionFunc(ctx, restoreConnectionHandler) - - return ctx -} - -func (f *healServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { - rv, err := next.Server(ctx).Close(ctx, conn) - - f.stopHeal(conn) - - return rv, err -} - -func (f *healServer) getHealContext( - conn *networkservice.Connection, -) (context.Context, *networkservice.NetworkServiceRequest, time.Duration) { - cw, ok := f.healContextMap.Load(conn.GetId()) - if !ok { - return nil, nil, 0 - } - - cw.mut.Lock() - defer cw.mut.Unlock() - - if cw.cancel != nil { - cw.cancel() - } - ctx, cancel := context.WithCancel(cw.ctx) - cw.cancel = cancel - - return ctx, cw.request.Clone(), cw.requestTimeout -} - -// handleHealConnectionRequest - heals requested connection. Returns immediately, heal is asynchronous. -func (f *healServer) handleHealConnectionRequest(conn *networkservice.Connection) { - ctx, request, requestTimeout := f.getHealContext(conn) - if request == nil { - return - } - - request.SetRequestConnection(conn.Clone()) - - go f.processHeal(ctx, request, requestTimeout) -} - -// handleRestoreConnectionRequest - recreates connection. Returns immediately, heal is asynchronous. -func (f *healServer) handleRestoreConnectionRequest(conn *networkservice.Connection) { - ctx, request, requestTimeout := f.getHealContext(conn) - if request == nil { - return - } - - request.SetRequestConnection(conn.Clone()) - - go f.restoreConnection(ctx, request, requestTimeout) -} - -func (f *healServer) stopHeal(conn *networkservice.Connection) { - cw, loaded := f.healContextMap.LoadAndDelete(conn.GetId()) - if !loaded { - return - } - - cw.mut.Lock() - defer cw.mut.Unlock() - - if cw.cancel != nil { - cw.cancel() - } -} - -func (f *healServer) restoreConnection( - ctx context.Context, - request *networkservice.NetworkServiceRequest, - requestTimeout time.Duration, -) { - clockTime := clock.FromContext(ctx) - - if ctx.Err() != nil { - return - } - - // Make sure we have a valid expireTime to work with - expires := request.GetConnection().GetNextPathSegment().GetExpires() - if !expires.IsValid() { - return - } - expireTime := expires.AsTime() - - deadline := clockTime.Now().Add(f.restoreTimeout) - if deadline.After(expireTime) { - deadline = expireTime - } - restoreCtx, restoreCancel := clockTime.WithDeadline(ctx, deadline) - defer restoreCancel() - - for restoreCtx.Err() == nil { - requestCtx, requestCancel := clockTime.WithTimeout(restoreCtx, requestTimeout) - _, err := (*f.onHeal).Request(requestCtx, request.Clone()) - requestCancel() - - if err == nil { - return - } - } - - f.processHeal(ctx, request, requestTimeout) -} - -func (f *healServer) processHeal( - ctx context.Context, - request *networkservice.NetworkServiceRequest, - requestTimeout time.Duration, -) { - clockTime := clock.FromContext(ctx) - logger := log.FromContext(ctx).WithField("healServer", "processHeal") - - if ctx.Err() != nil { - return - } - - candidates := discover.Candidates(ctx) - conn := request.GetConnection() - if candidates != nil || conn.GetPath().GetIndex() == 0 { - logger.Infof("Starting heal process for %s", conn.GetId()) - - conn.NetworkServiceEndpointName = "" - conn.Path.PathSegments = conn.Path.PathSegments[0 : conn.Path.Index+1] - - for ctx.Err() == nil { - requestCtx, requestCancel := clockTime.WithTimeout(ctx, requestTimeout) - _, err := (*f.onHeal).Request(requestCtx, request.Clone()) - requestCancel() - - if err != nil { - logger.Errorf("Failed to heal connection %s: %v", conn.GetId(), err) - } else { - logger.Infof("Finished heal process for %s", conn.GetId()) - break - } - } - } else { - // Huge timeout is not required to close connection on a current path segment - closeCtx, closeCancel := clockTime.WithTimeout(ctx, time.Second) - defer closeCancel() - - _, err := (*f.onHeal).Close(closeCtx, conn) - if err != nil { - logger.Errorf("Failed to close connection %s: %v", conn.GetId(), err) - } - } -} - -// createHealContext - create context to be used on heal. -// Uses f.ctx as base and inserts Candidates from requestCtx or cachedCtx into it, if there are any. -func (f *healServer) createHealContext(requestCtx, cachedCtx context.Context) context.Context { - ctx := requestCtx - if cachedCtx != nil { - if candidates := discover.Candidates(ctx); candidates == nil || len(candidates.Endpoints) > 0 { - ctx = cachedCtx - } - } - healCtx := f.ctx - if candidates := discover.Candidates(ctx); candidates != nil { - healCtx = discover.WithCandidates(healCtx, candidates.Endpoints, candidates.NetworkService) - } - - return healCtx -} diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 1e1487daa..4bd21f0d7 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -24,6 +24,7 @@ import ( "context" "time" + "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" "google.golang.org/grpc" @@ -131,16 +132,9 @@ func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, log.FromContext(ctx).Infof("expiration after %s at %s", minTimeout.String(), expireTime.UTC()) } -<<<<<<< HEAD if minTimeout == nil || *minTimeout <= 0 { return 1, nil -======= - nextClient := next.Client(ctx) - if !request.GetConnection().GetCurrentPathSegment().GetExpires().IsValid() { - return ->>>>>>> Update protobuf to v1.26.0 needed for opentelemetry } - expireTime := request.GetConnection().GetCurrentPathSegment().GetExpires().AsTime() // A heuristic to reduce the number of redundant requests in a chain // made of refreshing clients with the same expiration time: let outer diff --git a/pkg/networkservice/common/updatepath/server.go b/pkg/networkservice/common/updatepath/server.go index 30557a223..57363a727 100644 --- a/pkg/networkservice/common/updatepath/server.go +++ b/pkg/networkservice/common/updatepath/server.go @@ -21,16 +21,16 @@ package updatepath import ( "context" + "time" "github.com/golang/protobuf/ptypes/empty" -<<<<<<< HEAD -======= ->>>>>>> Update protobuf to v1.26.0 needed for opentelemetry "github.com/networkservicemesh/api/pkg/api/networkservice" "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" + "github.com/networkservicemesh/sdk/pkg/tools/log" + "github.com/networkservicemesh/sdk/pkg/tools/token" ) type updatePathServer struct { @@ -56,8 +56,6 @@ func (i *updatePathServer) Request(ctx context.Context, request *networkservice. return nil, err } -<<<<<<< HEAD -======= if prev := request.GetConnection().GetPrevPathSegment(); prev != nil { var tok string var expireTime time.Time @@ -71,7 +69,6 @@ func (i *updatePathServer) Request(ctx context.Context, request *networkservice. } } ->>>>>>> Update protobuf to v1.26.0 needed for opentelemetry conn, err = next.Server(ctx).Request(ctx, request) if err != nil { return nil, err diff --git a/pkg/tools/log/logruslogger/logruslogger.go b/pkg/tools/log/logruslogger/logruslogger.go index 2afe267d8..bfce0d33f 100644 --- a/pkg/tools/log/logruslogger/logruslogger.go +++ b/pkg/tools/log/logruslogger/logruslogger.go @@ -26,7 +26,6 @@ import ( "sync" "github.com/google/uuid" - "github.com/opentracing/opentracing-go" "github.com/sirupsen/logrus" "google.golang.org/grpc/metadata" @@ -202,7 +201,7 @@ func New(ctx context.Context, fields ...logrus.Fields) log.Logger { // FromSpan - creates a new logruslogger from context, operation and span // and returns context with it, logger, and a function to defer -func FromSpan(ctx context.Context, span opentracing.Span, operation string, fields map[string]interface{}) (context.Context, log.Logger, func()) { +func FromSpan(ctx context.Context, span spanlogger.Span, operation string, fields map[string]interface{}) (context.Context, log.Logger, func()) { entry := logrus.WithFields(fields) entry.Logger.SetFormatter(newFormatter()) diff --git a/pkg/tools/log/spanlogger/spanlogger.go b/pkg/tools/log/spanlogger/spanlogger.go index fb68f3aa8..6568c62fd 100644 --- a/pkg/tools/log/spanlogger/spanlogger.go +++ b/pkg/tools/log/spanlogger/spanlogger.go @@ -130,9 +130,9 @@ func (s *spanLogger) logf(level, format string, v ...interface{}) { func FromContext(ctx context.Context, operation string) (context.Context, log.Logger, Span, func()) { var span Span if log.IsOpentracingEnabled() { - ctx, span = newOTSpan(ctx, operation, log.Fields(ctx)) + ctx, span = newOTSpan(ctx, operation, make(map[string]interface{})) } else if log.IsOpentelemetryEnabled() { - ctx, span = newOTELSpan(ctx, operation, log.Fields(ctx)) + ctx, span = newOTELSpan(ctx, operation, make(map[string]interface{})) } newLog := &spanLogger{ span: span, diff --git a/pkg/tools/opentelemetry/README.md b/pkg/tools/opentelemetry/README.md index 9b959f180..5311acad9 100644 --- a/pkg/tools/opentelemetry/README.md +++ b/pkg/tools/opentelemetry/README.md @@ -29,24 +29,22 @@ log.EnableTracing(true) os.Setenv("TELEMETRY", "opentelemetry") spanExporter := opentelemetry.InitSpanExporter(ctx, "0.0.0.0:4317") metricExporter := opentelemetry.InitMetricExporter(ctx, "0.0.0.0:4317") -opentelemetry.Init(ctx, spanExporter, metricExporter, "NSM") +o := opentelemetry.Init(ctx, spanExporter, metricExporter, "NSM") +defer o.Close() ``` Metrics are disabled in tests by default. You can create simple metrics chain element to test them: ```Go type metricsServer struct { } - func NewServer() networkservice.NetworkServiceServer { return &metricsServer{} } - func (c *metricsServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { request.Connection.GetCurrentPathSegment().Metrics = make(map[string]string) request.Connection.GetCurrentPathSegment().Metrics["my_nsm_metric"] = "10000" return next.Server(ctx).Request(ctx, request) } - func (c *metricsServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { return next.Server(ctx).Close(ctx, conn) } diff --git a/pkg/tools/opentelemetry/metrics_chain_element.go b/pkg/tools/opentelemetry/metrics_chain_element.go deleted file mode 100644 index 07033b49b..000000000 --- a/pkg/tools/opentelemetry/metrics_chain_element.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2020-2021 Cisco Systems, Inc. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package clienturl provides server chain element that sets client URL in context -package opentelemetry - -import ( - "context" - - "github.com/golang/protobuf/ptypes/empty" - - "github.com/networkservicemesh/api/pkg/api/networkservice" - - "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" -) - -type metricsServer struct { -} - -// NewServer - returns a new server chain element that sets client URL in context -func NewServer() networkservice.NetworkServiceServer { - return &metricsServer{} -} - -func (c *metricsServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { - //request.Connection.GetCurrentPathSegment().Metrics = make(map[string]string) - //request.Connection.GetCurrentPathSegment().Metrics["my_nsm_metric"] = "10000" - return next.Server(ctx).Request(ctx, request) -} - -func (c *metricsServer) Close(ctx context.Context, conn *networkservice.Connection) (*empty.Empty, error) { - return next.Server(ctx).Close(ctx, conn) -} From 5f8a2c3201accd9174fd81fc799279860e85027e Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 27 Dec 2021 16:48:57 +0700 Subject: [PATCH 16/26] more fixes Signed-off-by: Nikita Skrynnik --- pkg/networkservice/core/trace/context.go | 2 +- pkg/registry/core/trace/context.go | 2 +- pkg/tools/log/logger.go | 3 +- pkg/tools/log/spanlogger/spanlogger.go | 6 ++-- pkg/tools/opentelemetry/exporter.go | 3 +- pkg/tools/opentelemetry/opentelemetry.go | 46 +++++------------------- 6 files changed, 16 insertions(+), 46 deletions(-) diff --git a/pkg/networkservice/core/trace/context.go b/pkg/networkservice/core/trace/context.go index eca12abbe..37dda902b 100644 --- a/pkg/networkservice/core/trace/context.go +++ b/pkg/networkservice/core/trace/context.go @@ -56,7 +56,7 @@ func withLog(parent context.Context, operation, connectionID string) (c context. if grpcTraceState := grpcutils.TraceFromContext(parent); (grpcTraceState == grpcutils.TraceOn) || (grpcTraceState == grpcutils.TraceUndefined && log.IsTracingEnabled()) { - ctx, sLogger, span, sFinish := spanlogger.FromContext(parent, operation) + ctx, sLogger, span, sFinish := spanlogger.FromContext(parent, operation, map[string]interface{}{"type": loggedType, "id": connectionID}) ctx, lLogger, lFinish := logruslogger.FromSpan(ctx, span, operation, map[string]interface{}{"type": loggedType, "id": connectionID}) return withTrace(log.WithLog(ctx, sLogger, lLogger)), func() { sFinish() diff --git a/pkg/registry/core/trace/context.go b/pkg/registry/core/trace/context.go index 0eac12f16..61164b2f8 100644 --- a/pkg/registry/core/trace/context.go +++ b/pkg/registry/core/trace/context.go @@ -42,7 +42,7 @@ func withLog(parent context.Context, operation string) (c context.Context, f fun if grpcTraceState := grpcutils.TraceFromContext(parent); (grpcTraceState == grpcutils.TraceOn) || (grpcTraceState == grpcutils.TraceUndefined && log.IsTracingEnabled()) { - ctx, sLogger, span, sFinish := spanlogger.FromContext(parent, operation) + ctx, sLogger, span, sFinish := spanlogger.FromContext(parent, operation, map[string]interface{}{"type": loggedType}) ctx, lLogger, lFinish := logruslogger.FromSpan(ctx, span, operation, map[string]interface{}{"type": loggedType}) return log.WithLog(ctx, sLogger, lLogger), func() { sFinish() diff --git a/pkg/tools/log/logger.go b/pkg/tools/log/logger.go index 1387dc203..3e58de77d 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -26,8 +26,7 @@ import ( type contextKeyType string const ( - logKey contextKeyType = "Logger" - logFieldsKey contextKeyType = "LoggerFields" + logKey contextKeyType = "Logger" telemetryEnv = "TELEMETRY" telemetryOT = "opentracing" diff --git a/pkg/tools/log/spanlogger/spanlogger.go b/pkg/tools/log/spanlogger/spanlogger.go index 6568c62fd..d4721a7e9 100644 --- a/pkg/tools/log/spanlogger/spanlogger.go +++ b/pkg/tools/log/spanlogger/spanlogger.go @@ -127,12 +127,12 @@ func (s *spanLogger) logf(level, format string, v ...interface{}) { } // FromContext - creates a new spanLogger from context and operation -func FromContext(ctx context.Context, operation string) (context.Context, log.Logger, Span, func()) { +func FromContext(ctx context.Context, operation string, fields map[string]interface{}) (context.Context, log.Logger, Span, func()) { var span Span if log.IsOpentracingEnabled() { - ctx, span = newOTSpan(ctx, operation, make(map[string]interface{})) + ctx, span = newOTSpan(ctx, operation, fields) } else if log.IsOpentelemetryEnabled() { - ctx, span = newOTELSpan(ctx, operation, make(map[string]interface{})) + ctx, span = newOTELSpan(ctx, operation, fields) } newLog := &spanLogger{ span: span, diff --git a/pkg/tools/opentelemetry/exporter.go b/pkg/tools/opentelemetry/exporter.go index ef678b9a3..d1e5d071b 100644 --- a/pkg/tools/opentelemetry/exporter.go +++ b/pkg/tools/opentelemetry/exporter.go @@ -29,7 +29,7 @@ import ( "google.golang.org/grpc" ) -// InitSpanExporter - returns an instance of OpenTelemetry Exporter. +// InitSpanExporter - returns an instance of OpenTelemetry Span Exporter. func InitSpanExporter(ctx context.Context, exporterURL string) trace.SpanExporter { if !log.IsOpentelemetryEnabled() { return nil @@ -49,6 +49,7 @@ func InitSpanExporter(ctx context.Context, exporterURL string) trace.SpanExporte return exporter } +// InitMetricExporter - returns an instance of OpenTelemetry Metric Exporter. func InitMetricExporter(ctx context.Context, exporterURL string) *otlpmetric.Exporter { if !log.IsOpentelemetryEnabled() { return nil diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 50e000b1b..23adfb64b 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -25,7 +25,6 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" "go.opentelemetry.io/otel/metric/global" - "go.opentelemetry.io/otel/sdk/export/metric" controller "go.opentelemetry.io/otel/sdk/metric/controller/basic" processor "go.opentelemetry.io/otel/sdk/metric/processor/basic" "go.opentelemetry.io/otel/sdk/metric/selector/simple" @@ -39,10 +38,6 @@ import ( const ( // InstrumentationName - denotes the library that provides the instrumentation InstrumentationName = "NSM" - - // defaults denotes default collector address - defaultAddr = "localhost" - defaultPort = "4317" ) type opentelemetry struct { @@ -67,20 +62,16 @@ func (o *opentelemetry) Close() error { log.FromContext(o.ctx).Errorf("failed to shutdown controller: %v", err) } } - // if o.metricExporter != nil { - // if err := o.metricExporter.Shutdown(o.ctx); err != nil { - // log.FromContext(o.ctx).Errorf("failed to stop exporter: %v", err) - // } - // } + if o.metricExporter != nil { + if err := o.metricExporter.Shutdown(o.ctx); err != nil { + log.FromContext(o.ctx).Errorf("failed to stop exporter: %v", err) + } + } return nil } -type my_exporter interface { - Shutdown(context context.Context) -} - // Init - creates opentelemetry tracer and meter providers -func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporter metric.Exporter, service string) io.Closer { +func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporter *otlpmetric.Exporter, service string) io.Closer { o := &opentelemetry{ ctx: ctx, } @@ -88,14 +79,7 @@ func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporte return o } - // Check the opentlemetry collector address - // if collectorAddr == "" { - // collectorAddr = defaultAddr + ":" + defaultPort - // } else if len(strings.Split(collectorAddr, ":")) == 1 { - // collectorAddr += ":" + defaultPort - // } - - // Create resourse + // Create resourses res, err := resource.New(ctx, resource.WithAttributes( // the service name used to display traces in backends @@ -115,18 +99,13 @@ func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporte sdktrace.WithResource(res), sdktrace.WithSpanProcessor(bsp), ) - go func() { - <-ctx.Done() - tracerProvider.ForceFlush(context.Background()) - tracerProvider.Shutdown(context.Background()) - }() otel.SetTracerProvider(tracerProvider) o.tracerProvider = tracerProvider // Create meter provider - // o.metricExporter = metricExporter + o.metricExporter = metricExporter metricController := controller.New( processor.NewFactory( @@ -144,14 +123,5 @@ func Init(ctx context.Context, spanExporter sdktrace.SpanExporter, metricExporte global.SetMeterProvider(metricController) o.metricController = metricController - go func() { - <-ctx.Done() - metricController.Stop(context.Background()) - - if exp, ok := metricExporter.(my_exporter); ok { - exp.Shutdown(context.Background()) - } - }() - return o } From d5a5216a451f7ecf81b8abeacfb530e074a1425e Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 27 Dec 2021 17:03:36 +0700 Subject: [PATCH 17/26] run go mod tidy Signed-off-by: Nikita Skrynnik --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index c1f80ec02..ed0a47e9c 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,6 @@ require ( go.opentelemetry.io/otel/exporters/zipkin v1.3.0 go.opentelemetry.io/otel/metric v0.26.0 go.opentelemetry.io/otel/sdk v1.3.0 - go.opentelemetry.io/otel/sdk/export/metric v0.26.0 go.opentelemetry.io/otel/sdk/metric v0.26.0 go.opentelemetry.io/otel/trace v1.3.0 go.uber.org/atomic v1.7.0 From 38000305ded8dcc537ef96b3c01ea0573bc3deaa Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Mon, 27 Dec 2021 18:15:03 +0700 Subject: [PATCH 18/26] lint fixes Signed-off-by: Nikita Skrynnik --- pkg/networkservice/common/refresh/client.go | 20 +++++-------------- .../common/updatetoken/server.go | 16 +++------------ pkg/tools/jaeger/exporter.go | 3 ++- pkg/tools/opentelemetry/exporter.go | 3 ++- pkg/tools/zipkin/exporter.go | 3 ++- 5 files changed, 14 insertions(+), 31 deletions(-) diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 4bd21f0d7..1784386e2 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -24,9 +24,7 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" - "github.com/pkg/errors" "google.golang.org/grpc" "github.com/networkservicemesh/api/pkg/api/networkservice" @@ -59,12 +57,7 @@ func (t *refreshClient) Request(ctx context.Context, request *networkservice.Net } // Compute refreshAfter - refreshAfter, err := after(ctx, conn) - if err != nil { - // If we can't refresh, we should close down chain - _, _ = t.Close(ctx, conn) - return nil, err - } + refreshAfter := after(ctx, conn) // Create a cancel context. cancelCtx, cancel := context.WithCancel(t.chainCtx) @@ -105,16 +98,13 @@ func (t *refreshClient) Close(ctx context.Context, conn *networkservice.Connecti return next.Client(ctx).Close(ctx, conn, opts...) } -func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, error) { +func after(ctx context.Context, conn *networkservice.Connection) time.Duration { clockTime := clock.FromContext(ctx) var minTimeout *time.Duration var expireTime time.Time for _, segment := range conn.GetPath().GetPathSegments() { - expTime, err := ptypes.Timestamp(segment.GetExpires()) - if err != nil { - return 0, errors.WithStack(err) - } + expTime := segment.GetExpires().AsTime() timeout := clockTime.Until(expTime) @@ -133,7 +123,7 @@ func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, } if minTimeout == nil || *minTimeout <= 0 { - return 1, nil + return 1 } // A heuristic to reduce the number of redundant requests in a chain @@ -147,5 +137,5 @@ func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, } duration := time.Duration(float64(*minTimeout) * scale) - return duration, nil + return duration } diff --git a/pkg/networkservice/common/updatetoken/server.go b/pkg/networkservice/common/updatetoken/server.go index 74ea62671..201f42630 100644 --- a/pkg/networkservice/common/updatetoken/server.go +++ b/pkg/networkservice/common/updatetoken/server.go @@ -20,11 +20,9 @@ package updatetoken import ( "context" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/networkservicemesh/api/pkg/api/networkservice" - "github.com/pkg/errors" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" "github.com/networkservicemesh/sdk/pkg/tools/log" @@ -50,11 +48,7 @@ func (u *updateTokenServer) Request(ctx context.Context, request *networkservice if err != nil { log.FromContext(ctx).Warnf("an error during getting token from the context: %+v", err) } else { - var expires *timestamp.Timestamp - expires, err = ptypes.TimestampProto(expireTime.Local()) - if err != nil { - return nil, errors.WithStack(err) - } + expires := timestamppb.New(expireTime.Local()) prev.Expires = expires prev.Token = tok @@ -77,11 +71,7 @@ func (u *updateTokenServer) Close(ctx context.Context, conn *networkservice.Conn if err != nil { log.FromContext(ctx).Warnf("an error during getting token from the context: %+v", err) } else { - var expires *timestamp.Timestamp - expires, err = ptypes.TimestampProto(expireTime.Local()) - if err != nil { - return nil, errors.WithStack(err) - } + expires := timestamppb.New(expireTime.Local()) prev.Expires = expires prev.Token = tok diff --git a/pkg/tools/jaeger/exporter.go b/pkg/tools/jaeger/exporter.go index 44ed0a0ad..9b3a79e9a 100644 --- a/pkg/tools/jaeger/exporter.go +++ b/pkg/tools/jaeger/exporter.go @@ -22,9 +22,10 @@ package jaeger import ( "context" - "github.com/networkservicemesh/sdk/pkg/tools/log" "go.opentelemetry.io/otel/exporters/jaeger" "go.opentelemetry.io/otel/sdk/trace" + + "github.com/networkservicemesh/sdk/pkg/tools/log" ) // InitExporter - returns an instance of Jaeger Exporter. diff --git a/pkg/tools/opentelemetry/exporter.go b/pkg/tools/opentelemetry/exporter.go index d1e5d071b..727d683a8 100644 --- a/pkg/tools/opentelemetry/exporter.go +++ b/pkg/tools/opentelemetry/exporter.go @@ -20,13 +20,14 @@ package opentelemetry import ( "context" - "github.com/networkservicemesh/sdk/pkg/tools/log" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/sdk/trace" "google.golang.org/grpc" + + "github.com/networkservicemesh/sdk/pkg/tools/log" ) // InitSpanExporter - returns an instance of OpenTelemetry Span Exporter. diff --git a/pkg/tools/zipkin/exporter.go b/pkg/tools/zipkin/exporter.go index b83246f42..88344d5f7 100644 --- a/pkg/tools/zipkin/exporter.go +++ b/pkg/tools/zipkin/exporter.go @@ -22,9 +22,10 @@ package zipkin import ( "context" - "github.com/networkservicemesh/sdk/pkg/tools/log" "go.opentelemetry.io/otel/exporters/zipkin" "go.opentelemetry.io/otel/sdk/trace" + + "github.com/networkservicemesh/sdk/pkg/tools/log" ) // InitExporter - returns an instance of Zipkin Exporter. From 52736b8e82579f0a9528503d7c10ef4973bf0197 Mon Sep 17 00:00:00 2001 From: "Nikita.Skrynnik" Date: Thu, 30 Dec 2021 12:29:19 +1100 Subject: [PATCH 19/26] revert test and updatepath files Signed-off-by: Nikita.Skrynnik --- pkg/networkservice/chains/nsmgr/single_test.go | 5 +---- pkg/networkservice/common/updatepath/server.go | 17 ----------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/pkg/networkservice/chains/nsmgr/single_test.go b/pkg/networkservice/chains/nsmgr/single_test.go index 7b14c42d5..127cab4f4 100644 --- a/pkg/networkservice/chains/nsmgr/single_test.go +++ b/pkg/networkservice/chains/nsmgr/single_test.go @@ -37,10 +37,7 @@ import ( ) func Test_DNSUsecase(t *testing.T) { - t.Cleanup(func() { - time.Sleep(time.Second * 20) - goleak.VerifyNone(t) - }) + t.Cleanup(func() { goleak.VerifyNone(t) }) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() diff --git a/pkg/networkservice/common/updatepath/server.go b/pkg/networkservice/common/updatepath/server.go index 57363a727..f398e2b10 100644 --- a/pkg/networkservice/common/updatepath/server.go +++ b/pkg/networkservice/common/updatepath/server.go @@ -21,16 +21,12 @@ package updatepath import ( "context" - "time" "github.com/golang/protobuf/ptypes/empty" "github.com/networkservicemesh/api/pkg/api/networkservice" - "google.golang.org/protobuf/types/known/timestamppb" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/networkservicemesh/sdk/pkg/tools/log" - "github.com/networkservicemesh/sdk/pkg/tools/token" ) type updatePathServer struct { @@ -56,19 +52,6 @@ func (i *updatePathServer) Request(ctx context.Context, request *networkservice. return nil, err } - if prev := request.GetConnection().GetPrevPathSegment(); prev != nil { - var tok string - var expireTime time.Time - tok, expireTime, err = token.FromContext(ctx) - - if err != nil { - log.FromContext(ctx).Warnf("an error during getting token from the context: %+v", err) - } else { - prev.Expires = timestamppb.New(expireTime.Local()) - prev.Token = tok - } - } - conn, err = next.Server(ctx).Request(ctx, request) if err != nil { return nil, err From 563b91ec7dfb91f2281a1a72bde97e4f305e8dd4 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Thu, 30 Dec 2021 13:01:35 +1100 Subject: [PATCH 20/26] revert refresh/client.go file Signed-off-by: Nikita Skrynnik --- pkg/networkservice/common/refresh/client.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 1784386e2..4bd21f0d7 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -24,7 +24,9 @@ import ( "context" "time" + "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" + "github.com/pkg/errors" "google.golang.org/grpc" "github.com/networkservicemesh/api/pkg/api/networkservice" @@ -57,7 +59,12 @@ func (t *refreshClient) Request(ctx context.Context, request *networkservice.Net } // Compute refreshAfter - refreshAfter := after(ctx, conn) + refreshAfter, err := after(ctx, conn) + if err != nil { + // If we can't refresh, we should close down chain + _, _ = t.Close(ctx, conn) + return nil, err + } // Create a cancel context. cancelCtx, cancel := context.WithCancel(t.chainCtx) @@ -98,13 +105,16 @@ func (t *refreshClient) Close(ctx context.Context, conn *networkservice.Connecti return next.Client(ctx).Close(ctx, conn, opts...) } -func after(ctx context.Context, conn *networkservice.Connection) time.Duration { +func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, error) { clockTime := clock.FromContext(ctx) var minTimeout *time.Duration var expireTime time.Time for _, segment := range conn.GetPath().GetPathSegments() { - expTime := segment.GetExpires().AsTime() + expTime, err := ptypes.Timestamp(segment.GetExpires()) + if err != nil { + return 0, errors.WithStack(err) + } timeout := clockTime.Until(expTime) @@ -123,7 +133,7 @@ func after(ctx context.Context, conn *networkservice.Connection) time.Duration { } if minTimeout == nil || *minTimeout <= 0 { - return 1 + return 1, nil } // A heuristic to reduce the number of redundant requests in a chain @@ -137,5 +147,5 @@ func after(ctx context.Context, conn *networkservice.Connection) time.Duration { } duration := time.Duration(float64(*minTimeout) * scale) - return duration + return duration, nil } From 9e58ffabb02d483880cdae546ed0a144156fb9c1 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Thu, 30 Dec 2021 13:31:00 +1100 Subject: [PATCH 21/26] delete meter_helper Signed-off-by: Nikita Skrynnik --- pkg/networkservice/common/metrics/server.go | 30 ++++++-- .../opentelemetry/meterhelper/meter_helper.go | 74 ------------------- 2 files changed, 23 insertions(+), 81 deletions(-) delete mode 100644 pkg/tools/opentelemetry/meterhelper/meter_helper.go diff --git a/pkg/networkservice/common/metrics/server.go b/pkg/networkservice/common/metrics/server.go index 77f9cae6f..45c07667d 100644 --- a/pkg/networkservice/common/metrics/server.go +++ b/pkg/networkservice/common/metrics/server.go @@ -19,22 +19,28 @@ package metrics import ( "context" + "strconv" "github.com/golang/protobuf/ptypes/empty" "github.com/networkservicemesh/api/pkg/api/networkservice" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/global" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry/meterhelper" + "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" ) type metricServer struct { - helpers map[string]meterhelper.MeterHelper + recorderMap map[string]metric.Int64Histogram + meter metric.Meter } // NewServer returns a new metric server chain element func NewServer() networkservice.NetworkServiceServer { return &metricServer{ - helpers: make(map[string]meterhelper.MeterHelper), + recorderMap: make(map[string]metric.Int64Histogram), + meter: global.Meter(opentelemetry.InstrumentationName), } } @@ -64,11 +70,21 @@ func (t *metricServer) writeMetrics(ctx context.Context, path *networkservice.Pa if pathSegment.Metrics == nil { continue } - _, ok := t.helpers[pathSegment.Id] - if !ok { - t.helpers[pathSegment.Id] = meterhelper.NewMeterHelper(pathSegment.Name, path.GetPathSegments()[0].Id) + + for metricName, metricValue := range pathSegment.Metrics { + /* Works with integers only */ + recVal, err := strconv.ParseInt(metricValue, 10, 64) + if err != nil { + continue + } + _, ok := t.recorderMap[metricName] + if !ok { + t.recorderMap[metricName] = metric.Must(t.meter).NewInt64Histogram( + pathSegment.Name + "_" + metricName, + ) + } + t.recorderMap[metricName].Record(ctx, recVal, attribute.String("connection", path.GetPathSegments()[0].Id)) } - t.helpers[pathSegment.Id].WriteMetrics(ctx, pathSegment.Metrics) } } } diff --git a/pkg/tools/opentelemetry/meterhelper/meter_helper.go b/pkg/tools/opentelemetry/meterhelper/meter_helper.go deleted file mode 100644 index 45ae2da72..000000000 --- a/pkg/tools/opentelemetry/meterhelper/meter_helper.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package meterhelper provides a set of utilities to assist in working with opentelemetry metrics -package meterhelper - -import ( - "context" - "strconv" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/global" - - "github.com/networkservicemesh/sdk/pkg/tools/log" - "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" -) - -// MeterHelper - wrap opentelemetry Meter to simplify workflow -type MeterHelper interface { - WriteMetrics(ctx context.Context, metrics map[string]string) -} - -type meterHelper struct { - prefix string - connLabel attribute.KeyValue - meter metric.Meter - recorderMap map[string]metric.Int64Histogram -} - -// NewMeterHelper - constructs a meter helper from segmentName and connectionID. -func NewMeterHelper(segmentName, connectionID string) MeterHelper { - meter := global.Meter(opentelemetry.InstrumentationName) - return &meterHelper{ - prefix: segmentName + "_", - connLabel: attribute.String("connection", connectionID), - meter: meter, - recorderMap: make(map[string]metric.Int64Histogram), - } -} - -func (m *meterHelper) WriteMetrics(ctx context.Context, metrics map[string]string) { - if metrics == nil || !log.IsOpentelemetryEnabled() { - return - } - - for metricName, metricValue := range metrics { - /* Works with integers only */ - recVal, err := strconv.ParseInt(metricValue, 10, 64) - if err != nil { - continue - } - _, ok := m.recorderMap[metricName] - if !ok { - m.recorderMap[metricName] = metric.Must(m.meter).NewInt64Histogram( - m.prefix + metricName, - ) - } - m.recorderMap[metricName].Record(ctx, recVal, m.connLabel) - } -} From 9c989d97a514dd850be43efba519b33b996cbf42 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Thu, 30 Dec 2021 23:20:14 +1100 Subject: [PATCH 22/26] fill empty event names + delete instrumentationname Signed-off-by: Nikita Skrynnik --- pkg/networkservice/common/metrics/server.go | 3 +-- pkg/tools/log/spanlogger/span.go | 13 ++++++------- pkg/tools/opentelemetry/opentelemetry.go | 5 ----- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/networkservice/common/metrics/server.go b/pkg/networkservice/common/metrics/server.go index 45c07667d..b9555ceb4 100644 --- a/pkg/networkservice/common/metrics/server.go +++ b/pkg/networkservice/common/metrics/server.go @@ -28,7 +28,6 @@ import ( "go.opentelemetry.io/otel/metric/global" "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" ) type metricServer struct { @@ -40,7 +39,7 @@ type metricServer struct { func NewServer() networkservice.NetworkServiceServer { return &metricServer{ recorderMap: make(map[string]metric.Int64Histogram), - meter: global.Meter(opentelemetry.InstrumentationName), + meter: global.Meter(""), } } diff --git a/pkg/tools/log/spanlogger/span.go b/pkg/tools/log/spanlogger/span.go index 5062a9c24..acbdbcd54 100644 --- a/pkg/tools/log/spanlogger/span.go +++ b/pkg/tools/log/spanlogger/span.go @@ -25,8 +25,6 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" opentelemetry "go.opentelemetry.io/otel/trace" - - opentelemetrynsm "github.com/networkservicemesh/sdk/pkg/tools/opentelemetry" ) // Span - unified interface for opentracing/opentelemetry spans @@ -81,12 +79,13 @@ func newOTSpan(ctx context.Context, operationName string, additionalFields map[s // Opentelemetry span type otelSpan struct { - span opentelemetry.Span + span opentelemetry.Span + operationName string } func (otelsp *otelSpan) Log(level, format string, v ...interface{}) { otelsp.span.AddEvent( - "", + otelsp.operationName, opentelemetry.WithAttributes([]attribute.KeyValue{ attribute.String("event", level), attribute.String("message", fmt.Sprintf(format, v...)), @@ -96,7 +95,7 @@ func (otelsp *otelSpan) Log(level, format string, v ...interface{}) { func (otelsp *otelSpan) LogObject(k, v interface{}) { otelsp.span.AddEvent( - "", + otelsp.operationName, opentelemetry.WithAttributes([]attribute.KeyValue{ attribute.String(fmt.Sprintf("%v", k), fmt.Sprintf("%v", v)), }...), @@ -126,8 +125,8 @@ func newOTELSpan(ctx context.Context, operationName string, additionalFields map add = append(add, attribute.String(k, fmt.Sprint(v))) } - ctx, span := otel.Tracer(opentelemetrynsm.InstrumentationName).Start(ctx, operationName) + ctx, span := otel.Tracer("").Start(ctx, operationName) span.SetAttributes(add...) - return ctx, &otelSpan{span: span} + return ctx, &otelSpan{span: span, operationName: operationName} } diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index 23adfb64b..a3709cf77 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -35,11 +35,6 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/log" ) -const ( - // InstrumentationName - denotes the library that provides the instrumentation - InstrumentationName = "NSM" -) - type opentelemetry struct { io.Closer From b0fb5328cb6aa13e72d702ba3db9c6ea1babaf36 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Fri, 31 Dec 2021 00:17:52 +1100 Subject: [PATCH 23/26] Revert "revert refresh/client.go file" This reverts commit d5cd9f978cf52e41b9739af885295f2ad78c371f. Signed-off-by: Nikita Skrynnik --- pkg/networkservice/common/refresh/client.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 4bd21f0d7..1784386e2 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -24,9 +24,7 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" - "github.com/pkg/errors" "google.golang.org/grpc" "github.com/networkservicemesh/api/pkg/api/networkservice" @@ -59,12 +57,7 @@ func (t *refreshClient) Request(ctx context.Context, request *networkservice.Net } // Compute refreshAfter - refreshAfter, err := after(ctx, conn) - if err != nil { - // If we can't refresh, we should close down chain - _, _ = t.Close(ctx, conn) - return nil, err - } + refreshAfter := after(ctx, conn) // Create a cancel context. cancelCtx, cancel := context.WithCancel(t.chainCtx) @@ -105,16 +98,13 @@ func (t *refreshClient) Close(ctx context.Context, conn *networkservice.Connecti return next.Client(ctx).Close(ctx, conn, opts...) } -func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, error) { +func after(ctx context.Context, conn *networkservice.Connection) time.Duration { clockTime := clock.FromContext(ctx) var minTimeout *time.Duration var expireTime time.Time for _, segment := range conn.GetPath().GetPathSegments() { - expTime, err := ptypes.Timestamp(segment.GetExpires()) - if err != nil { - return 0, errors.WithStack(err) - } + expTime := segment.GetExpires().AsTime() timeout := clockTime.Until(expTime) @@ -133,7 +123,7 @@ func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, } if minTimeout == nil || *minTimeout <= 0 { - return 1, nil + return 1 } // A heuristic to reduce the number of redundant requests in a chain @@ -147,5 +137,5 @@ func after(ctx context.Context, conn *networkservice.Connection) (time.Duration, } duration := time.Duration(float64(*minTimeout) * scale) - return duration, nil + return duration } From b7c407f6cd018d31bfc8a23c068f80c57b7e5ed3 Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Tue, 11 Jan 2022 20:49:50 +1100 Subject: [PATCH 24/26] remove opentracing Signed-off-by: Nikita Skrynnik --- go.mod | 2 -- go.sum | 4 --- pkg/tools/log/logger.go | 8 ----- pkg/tools/log/spanlogger/span.go | 44 +------------------------ pkg/tools/log/spanlogger/spanlogger.go | 8 ++--- pkg/tools/tracing/grpcoptions.go | 45 +++----------------------- 6 files changed, 9 insertions(+), 102 deletions(-) diff --git a/go.mod b/go.mod index ed0a47e9c..1e4cdf937 100644 --- a/go.mod +++ b/go.mod @@ -15,12 +15,10 @@ require ( github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.6 github.com/google/uuid v1.1.2 - github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 github.com/nats-io/nats-streaming-server v0.22.1 github.com/nats-io/stan.go v0.10.0 github.com/networkservicemesh/api v1.0.1-0.20211110183123-3038992da61a github.com/open-policy-agent/opa v0.16.1 - github.com/opentracing/opentracing-go v1.2.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85 diff --git a/go.sum b/go.sum index c42f31830..ea6df686f 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,6 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU= -github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.16.2 h1:K4ev2ib4LdQETX5cSZBG0DVLk1jwGqSPXBjdah3veNs= @@ -212,8 +210,6 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/open-policy-agent/opa v0.16.1 h1:BDADmi1Xl08aPcubaYgSEU0lJ/zrWDwmFMRXVPX856c= github.com/open-policy-agent/opa v0.16.1/go.mod h1:P0xUE/GQAAgnvV537GzA0Ikw4+icPELRT327QJPkaKY= -github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.3.0 h1:XtuXmOLIXLjiU2XduuWREDT0LOKtSgos/g7i7RYyoZQ= github.com/openzipkin/zipkin-go v0.3.0/go.mod h1:4c3sLeE8xjNqehmF5RpAFLPLJxXscc0R4l6Zg0P1tTQ= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= diff --git a/pkg/tools/log/logger.go b/pkg/tools/log/logger.go index 3e58de77d..5978ae55e 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -29,19 +29,11 @@ const ( logKey contextKeyType = "Logger" telemetryEnv = "TELEMETRY" - telemetryOT = "opentracing" telemetryOTel = "opentelemetry" - // Opentracing enabled by default telemetryDefault = telemetryOTel ) -// IsOpentracingEnabled returns true if opentracing enabled -func IsOpentracingEnabled() bool { - return telemetryOT == getTelemetryEnv() -} - -// IsOpentelemetryEnabled returns true if opentelemetry enabled func IsOpentelemetryEnabled() bool { return telemetryOTel == getTelemetryEnv() } diff --git a/pkg/tools/log/spanlogger/span.go b/pkg/tools/log/spanlogger/span.go index acbdbcd54..1a76c802f 100644 --- a/pkg/tools/log/spanlogger/span.go +++ b/pkg/tools/log/spanlogger/span.go @@ -20,14 +20,12 @@ import ( "context" "fmt" - "github.com/opentracing/opentracing-go" - opentracinglog "github.com/opentracing/opentracing-go/log" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" opentelemetry "go.opentelemetry.io/otel/trace" ) -// Span - unified interface for opentracing/opentelemetry spans +// Span - unified interface for opentelemetry spans type Span interface { Log(level, format string, v ...interface{}) LogObject(k, v interface{}) @@ -37,46 +35,6 @@ type Span interface { ToString() string } -// Opentracing span -type otSpan struct { - span opentracing.Span -} - -func (otsp *otSpan) Log(level, format string, v ...interface{}) { - otsp.span.LogFields( - opentracinglog.String("event", level), - opentracinglog.String("message", fmt.Sprintf(format, v...)), - ) -} - -func (otsp *otSpan) LogObject(k, v interface{}) { - otsp.span.LogFields(opentracinglog.Object(k.(string), v)) -} - -func (otsp *otSpan) WithField(k, v interface{}) Span { - otsp.span = otsp.span.SetTag(k.(string), v) - return otsp -} - -func (otsp *otSpan) ToString() string { - if spanStr := fmt.Sprintf("%v", otsp.span); spanStr != "{}" { - return spanStr - } - return "" -} - -func (otsp *otSpan) Finish() { - otsp.span.Finish() -} - -func newOTSpan(ctx context.Context, operationName string, additionalFields map[string]interface{}) (c context.Context, s Span) { - span, ctx := opentracing.StartSpanFromContext(ctx, operationName) - for k, v := range additionalFields { - span = span.SetTag(k, v) - } - return ctx, &otSpan{span: span} -} - // Opentelemetry span type otelSpan struct { span opentelemetry.Span diff --git a/pkg/tools/log/spanlogger/spanlogger.go b/pkg/tools/log/spanlogger/spanlogger.go index d4721a7e9..6f9196b61 100644 --- a/pkg/tools/log/spanlogger/spanlogger.go +++ b/pkg/tools/log/spanlogger/spanlogger.go @@ -14,7 +14,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package spanlogger provides a set of utilities to assist in working with opentracing spans +// Package spanlogger provides a set of utilities to assist in working with spans package spanlogger import ( @@ -26,7 +26,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/tools/log" ) -// spanlogger - provides a way to log via opentracing spans +// spanlogger - provides a way to log via opentelemetry spans type spanLogger struct { span Span lock sync.RWMutex @@ -129,9 +129,7 @@ func (s *spanLogger) logf(level, format string, v ...interface{}) { // FromContext - creates a new spanLogger from context and operation func FromContext(ctx context.Context, operation string, fields map[string]interface{}) (context.Context, log.Logger, Span, func()) { var span Span - if log.IsOpentracingEnabled() { - ctx, span = newOTSpan(ctx, operation, fields) - } else if log.IsOpentelemetryEnabled() { + if log.IsOpentelemetryEnabled() { ctx, span = newOTELSpan(ctx, operation, fields) } newLog := &spanLogger{ diff --git a/pkg/tools/tracing/grpcoptions.go b/pkg/tools/tracing/grpcoptions.go index 3cbb08c04..4d089eb62 100644 --- a/pkg/tools/tracing/grpcoptions.go +++ b/pkg/tools/tracing/grpcoptions.go @@ -16,7 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package tracing provides a set of utilities to assist in working with opentracing and opentelemetry +// Package tracing provides a set of utilities to assist in working with opentelemetry package tracing import ( @@ -27,30 +27,12 @@ import ( "google.golang.org/grpc" "google.golang.org/protobuf/proto" - "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" - "github.com/opentracing/opentracing-go" - "github.com/networkservicemesh/sdk/pkg/tools/log" ) -// WithTracing - returns array of grpc.ServerOption that should be passed to grpc.Dial to enable opentracing/opentelemetry tracing +// WithTracing - returns array of grpc.ServerOption that should be passed to grpc.Dial to enable opentelemetry tracing func WithTracing() []grpc.ServerOption { - if log.IsOpentracingEnabled() { - interceptor := func( - ctx context.Context, - req interface{}, - info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler, - ) (resp interface{}, err error) { - return otgrpc.OpenTracingServerInterceptor(opentracing.GlobalTracer())(ctx, proto.Clone(req.(proto.Message)), info, handler) - } - return []grpc.ServerOption{ - grpc.ChainUnaryInterceptor( - interceptor), - grpc.ChainStreamInterceptor( - otgrpc.OpenTracingStreamServerInterceptor(opentracing.GlobalTracer())), - } - } else if log.IsOpentelemetryEnabled() { + if log.IsOpentelemetryEnabled() { interceptor := func( ctx context.Context, req interface{}, @@ -71,26 +53,9 @@ func WithTracing() []grpc.ServerOption { } } -// WithTracingDial returns array of grpc.DialOption that should be passed to grpc.Dial to enable opentracing/opentelemetry tracing +// WithTracingDial returns array of grpc.DialOption that should be passed to grpc.Dial to enable opentelemetry tracing func WithTracingDial() []grpc.DialOption { - if log.IsOpentracingEnabled() { - interceptor := func( - ctx context.Context, - method string, - req, reply interface{}, - cc *grpc.ClientConn, - invoker grpc.UnaryInvoker, - opts ...grpc.CallOption, - ) error { - return otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer())(ctx, method, proto.Clone(req.(proto.Message)), reply, cc, invoker, opts...) - } - return []grpc.DialOption{ - grpc.WithChainUnaryInterceptor( - interceptor), - grpc.WithChainStreamInterceptor( - otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer())), - } - } else if log.IsOpentelemetryEnabled() { + if log.IsOpentelemetryEnabled() { interceptor := func( ctx context.Context, method string, From 33209ef954e638abb02318b2c0bc573f5b27e90c Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Wed, 12 Jan 2022 12:04:05 +1100 Subject: [PATCH 25/26] fix linter issue Signed-off-by: Nikita Skrynnik --- pkg/networkservice/chains/nsmgr/scale_test.go | 2 +- pkg/networkservice/chains/nsmgr/server.go | 4 ++-- pkg/networkservice/chains/nsmgr/unix_test.go | 2 +- pkg/networkservice/common/mechanisms/kernel/vlan/server.go | 2 +- pkg/networkservice/common/mechanisms/recvfd/client.go | 4 ++-- pkg/networkservice/common/mechanisms/recvfd/common.go | 2 +- pkg/networkservice/common/mechanisms/recvfd/server.go | 2 +- pkg/networkservice/common/mechanisms/recvfd/server_test.go | 2 +- pkg/networkservice/common/mechanisms/sendfd/client.go | 2 +- pkg/networkservice/common/mechanisms/sendfd/common.go | 2 +- pkg/networkservice/common/mechanisms/sendfd/server.go | 2 +- pkg/networkservice/common/metrics/server.go | 2 +- pkg/networkservice/common/refresh/client.go | 2 +- pkg/networkservice/common/roundrobin/server.go | 4 ++-- pkg/networkservice/common/updatetoken/common.go | 2 +- pkg/networkservice/common/updatetoken/server.go | 2 +- pkg/networkservice/common/updatetoken/server_test.go | 2 +- pkg/networkservice/core/trace/context.go | 4 ++-- pkg/registry/chains/proxydns/server_nse_test.go | 2 +- pkg/registry/common/dnsresolve/common.go | 2 +- pkg/registry/common/recvfd/client.go | 4 ++-- pkg/registry/common/recvfd/server.go | 2 +- pkg/registry/common/recvfd/server_test.go | 2 +- pkg/registry/common/sendfd/client_linux.go | 4 ++-- pkg/registry/common/sendfd/client_linux_test.go | 2 +- pkg/registry/common/sendfd/server_linux.go | 4 ++-- pkg/registry/core/trace/context.go | 4 ++-- pkg/tools/fs/inode.go | 2 +- pkg/tools/grpcfdutils/transceiver.go | 2 +- pkg/tools/jaeger/exporter.go | 4 ++-- pkg/tools/log/logger.go | 3 ++- pkg/tools/log/logruslogger/logruslogger.go | 2 +- pkg/tools/log/spanlogger/span.go | 2 +- pkg/tools/log/spanlogger/spanlogger.go | 2 +- pkg/tools/opa/policy.go | 2 +- pkg/tools/opentelemetry/exporter.go | 2 +- pkg/tools/opentelemetry/opentelemetry.go | 2 +- pkg/tools/prefixpool/prefixpool.go | 4 ++-- pkg/tools/sandbox/dial_options.go | 2 +- pkg/tools/sandbox/grpc_utils.go | 2 +- pkg/tools/sandbox/grpc_utils_notwindows.go | 2 +- pkg/tools/tracing/grpcoptions.go | 4 ++-- pkg/tools/zipkin/exporter.go | 4 ++-- 43 files changed, 56 insertions(+), 55 deletions(-) diff --git a/pkg/networkservice/chains/nsmgr/scale_test.go b/pkg/networkservice/chains/nsmgr/scale_test.go index 09ae2e084..31b633fb6 100644 --- a/pkg/networkservice/chains/nsmgr/scale_test.go +++ b/pkg/networkservice/chains/nsmgr/scale_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/chains/nsmgr/server.go b/pkg/networkservice/chains/nsmgr/server.go index 0db8f8b58..6f63c8458 100644 --- a/pkg/networkservice/chains/nsmgr/server.go +++ b/pkg/networkservice/chains/nsmgr/server.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/chains/nsmgr/unix_test.go b/pkg/networkservice/chains/nsmgr/unix_test.go index ac7c0715a..e3c1c4cc6 100644 --- a/pkg/networkservice/chains/nsmgr/unix_test.go +++ b/pkg/networkservice/chains/nsmgr/unix_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/kernel/vlan/server.go b/pkg/networkservice/common/mechanisms/kernel/vlan/server.go index 702ddd0f6..3ce6d6391 100644 --- a/pkg/networkservice/common/mechanisms/kernel/vlan/server.go +++ b/pkg/networkservice/common/mechanisms/kernel/vlan/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Nordix Foundation. +// Copyright (c) 2021-2022 Nordix Foundation. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/recvfd/client.go b/pkg/networkservice/common/mechanisms/recvfd/client.go index e35e45dfa..494a087a5 100644 --- a/pkg/networkservice/common/mechanisms/recvfd/client.go +++ b/pkg/networkservice/common/mechanisms/recvfd/client.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/recvfd/common.go b/pkg/networkservice/common/mechanisms/recvfd/common.go index 4b176dc8f..bbb3b3713 100644 --- a/pkg/networkservice/common/mechanisms/recvfd/common.go +++ b/pkg/networkservice/common/mechanisms/recvfd/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/recvfd/server.go b/pkg/networkservice/common/mechanisms/recvfd/server.go index c854eefc8..8b6001e9d 100644 --- a/pkg/networkservice/common/mechanisms/recvfd/server.go +++ b/pkg/networkservice/common/mechanisms/recvfd/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/recvfd/server_test.go b/pkg/networkservice/common/mechanisms/recvfd/server_test.go index 69a73ca44..dbd999308 100644 --- a/pkg/networkservice/common/mechanisms/recvfd/server_test.go +++ b/pkg/networkservice/common/mechanisms/recvfd/server_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/sendfd/client.go b/pkg/networkservice/common/mechanisms/sendfd/client.go index 5ccd5ea9b..fd4d76d94 100644 --- a/pkg/networkservice/common/mechanisms/sendfd/client.go +++ b/pkg/networkservice/common/mechanisms/sendfd/client.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/sendfd/common.go b/pkg/networkservice/common/mechanisms/sendfd/common.go index f4a868ce9..cf48b44aa 100644 --- a/pkg/networkservice/common/mechanisms/sendfd/common.go +++ b/pkg/networkservice/common/mechanisms/sendfd/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/mechanisms/sendfd/server.go b/pkg/networkservice/common/mechanisms/sendfd/server.go index 3b5aa235b..f5825f04a 100644 --- a/pkg/networkservice/common/mechanisms/sendfd/server.go +++ b/pkg/networkservice/common/mechanisms/sendfd/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/metrics/server.go b/pkg/networkservice/common/metrics/server.go index b9555ceb4..a74be246a 100644 --- a/pkg/networkservice/common/metrics/server.go +++ b/pkg/networkservice/common/metrics/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 1784386e2..191cc5fe9 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -1,6 +1,6 @@ // Copyright (c) 2020 Cisco Systems, Inc. // -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/roundrobin/server.go b/pkg/networkservice/common/roundrobin/server.go index 818872aa2..856e22763 100644 --- a/pkg/networkservice/common/roundrobin/server.go +++ b/pkg/networkservice/common/roundrobin/server.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/updatetoken/common.go b/pkg/networkservice/common/updatetoken/common.go index d7e56af98..11c84102e 100644 --- a/pkg/networkservice/common/updatetoken/common.go +++ b/pkg/networkservice/common/updatetoken/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/updatetoken/server.go b/pkg/networkservice/common/updatetoken/server.go index 201f42630..85cf92118 100644 --- a/pkg/networkservice/common/updatetoken/server.go +++ b/pkg/networkservice/common/updatetoken/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/common/updatetoken/server_test.go b/pkg/networkservice/common/updatetoken/server_test.go index 577e8f863..88d791e9f 100644 --- a/pkg/networkservice/common/updatetoken/server_test.go +++ b/pkg/networkservice/common/updatetoken/server_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/networkservice/core/trace/context.go b/pkg/networkservice/core/trace/context.go index 37dda902b..1786ccc3e 100644 --- a/pkg/networkservice/core/trace/context.go +++ b/pkg/networkservice/core/trace/context.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/chains/proxydns/server_nse_test.go b/pkg/registry/chains/proxydns/server_nse_test.go index 4711e9329..b86fd4050 100644 --- a/pkg/registry/chains/proxydns/server_nse_test.go +++ b/pkg/registry/chains/proxydns/server_nse_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/dnsresolve/common.go b/pkg/registry/common/dnsresolve/common.go index f361d0afd..5d3f2ef71 100644 --- a/pkg/registry/common/dnsresolve/common.go +++ b/pkg/registry/common/dnsresolve/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/recvfd/client.go b/pkg/registry/common/recvfd/client.go index abc25fe22..8efe55ed0 100644 --- a/pkg/registry/common/recvfd/client.go +++ b/pkg/registry/common/recvfd/client.go @@ -1,6 +1,6 @@ -// Copyright (c) 2021 Cisco and/or its affiliates. +// Copyright (c) 2021-2022 Cisco and/or its affiliates. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/recvfd/server.go b/pkg/registry/common/recvfd/server.go index 9dbac3fd5..8a964408a 100644 --- a/pkg/registry/common/recvfd/server.go +++ b/pkg/registry/common/recvfd/server.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/recvfd/server_test.go b/pkg/registry/common/recvfd/server_test.go index 7adc038e8..d70007991 100644 --- a/pkg/registry/common/recvfd/server_test.go +++ b/pkg/registry/common/recvfd/server_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/sendfd/client_linux.go b/pkg/registry/common/sendfd/client_linux.go index 9bd439a54..532dfe4cd 100644 --- a/pkg/registry/common/sendfd/client_linux.go +++ b/pkg/registry/common/sendfd/client_linux.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/sendfd/client_linux_test.go b/pkg/registry/common/sendfd/client_linux_test.go index 854097719..098b4f54a 100644 --- a/pkg/registry/common/sendfd/client_linux_test.go +++ b/pkg/registry/common/sendfd/client_linux_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/common/sendfd/server_linux.go b/pkg/registry/common/sendfd/server_linux.go index 9da0c833d..c6bfd65f5 100644 --- a/pkg/registry/common/sendfd/server_linux.go +++ b/pkg/registry/common/sendfd/server_linux.go @@ -1,6 +1,6 @@ -// Copyright (c) 2021 Cisco and/or its affiliates. +// Copyright (c) 2021-2022 Cisco and/or its affiliates. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/registry/core/trace/context.go b/pkg/registry/core/trace/context.go index 61164b2f8..c24c63071 100644 --- a/pkg/registry/core/trace/context.go +++ b/pkg/registry/core/trace/context.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/fs/inode.go b/pkg/tools/fs/inode.go index 70902b47b..30fdabaef 100644 --- a/pkg/tools/fs/inode.go +++ b/pkg/tools/fs/inode.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/grpcfdutils/transceiver.go b/pkg/tools/grpcfdutils/transceiver.go index 51c782354..9a926674c 100644 --- a/pkg/tools/grpcfdutils/transceiver.go +++ b/pkg/tools/grpcfdutils/transceiver.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/jaeger/exporter.go b/pkg/tools/jaeger/exporter.go index 9b3a79e9a..cd430872b 100644 --- a/pkg/tools/jaeger/exporter.go +++ b/pkg/tools/jaeger/exporter.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/log/logger.go b/pkg/tools/log/logger.go index 5978ae55e..da7fada44 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -34,6 +34,7 @@ const ( telemetryDefault = telemetryOTel ) +// IsOpentelemetryEnabled returns true if opentelemetry enabled func IsOpentelemetryEnabled() bool { return telemetryOTel == getTelemetryEnv() } diff --git a/pkg/tools/log/logruslogger/logruslogger.go b/pkg/tools/log/logruslogger/logruslogger.go index bfce0d33f..22b6eaac5 100644 --- a/pkg/tools/log/logruslogger/logruslogger.go +++ b/pkg/tools/log/logruslogger/logruslogger.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/log/spanlogger/span.go b/pkg/tools/log/spanlogger/span.go index 1a76c802f..7bdc751c8 100644 --- a/pkg/tools/log/spanlogger/span.go +++ b/pkg/tools/log/spanlogger/span.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/log/spanlogger/spanlogger.go b/pkg/tools/log/spanlogger/spanlogger.go index 6f9196b61..c668f8cb8 100644 --- a/pkg/tools/log/spanlogger/spanlogger.go +++ b/pkg/tools/log/spanlogger/spanlogger.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/opa/policy.go b/pkg/tools/opa/policy.go index df25871e4..7bc4327c2 100644 --- a/pkg/tools/opa/policy.go +++ b/pkg/tools/opa/policy.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/opentelemetry/exporter.go b/pkg/tools/opentelemetry/exporter.go index 727d683a8..30db81cc5 100644 --- a/pkg/tools/opentelemetry/exporter.go +++ b/pkg/tools/opentelemetry/exporter.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/opentelemetry/opentelemetry.go b/pkg/tools/opentelemetry/opentelemetry.go index a3709cf77..025cff0c4 100644 --- a/pkg/tools/opentelemetry/opentelemetry.go +++ b/pkg/tools/opentelemetry/opentelemetry.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/prefixpool/prefixpool.go b/pkg/tools/prefixpool/prefixpool.go index d9d7061af..f6b31580c 100644 --- a/pkg/tools/prefixpool/prefixpool.go +++ b/pkg/tools/prefixpool/prefixpool.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2020-2022 Cisco and/or its affiliates. // -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/sandbox/dial_options.go b/pkg/tools/sandbox/dial_options.go index 2c49d23fe..67de40a39 100644 --- a/pkg/tools/sandbox/dial_options.go +++ b/pkg/tools/sandbox/dial_options.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/sandbox/grpc_utils.go b/pkg/tools/sandbox/grpc_utils.go index 015c4e995..e7304c920 100644 --- a/pkg/tools/sandbox/grpc_utils.go +++ b/pkg/tools/sandbox/grpc_utils.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Doc.ai and/or its affiliates. +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/sandbox/grpc_utils_notwindows.go b/pkg/tools/sandbox/grpc_utils_notwindows.go index 31d8bc6a7..2501d4afd 100644 --- a/pkg/tools/sandbox/grpc_utils_notwindows.go +++ b/pkg/tools/sandbox/grpc_utils_notwindows.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/tracing/grpcoptions.go b/pkg/tools/tracing/grpcoptions.go index 4d089eb62..4986f6401 100644 --- a/pkg/tools/tracing/grpcoptions.go +++ b/pkg/tools/tracing/grpcoptions.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/tools/zipkin/exporter.go b/pkg/tools/zipkin/exporter.go index 88344d5f7..4d7890be6 100644 --- a/pkg/tools/zipkin/exporter.go +++ b/pkg/tools/zipkin/exporter.go @@ -1,6 +1,6 @@ -// Copyright (c) 2020 Cisco Systems, Inc. +// Copyright (c) 2020-2022 Cisco Systems, Inc. // -// Copyright (c) 2021 Doc.ai and/or its affiliates. +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // From c9de6547086312d9920670249ba095042b0af5bc Mon Sep 17 00:00:00 2001 From: Nikita Skrynnik Date: Wed, 12 Jan 2022 22:11:50 +1100 Subject: [PATCH 26/26] change TELEMETRY env value Signed-off-by: Nikita Skrynnik --- pkg/tools/log/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tools/log/logger.go b/pkg/tools/log/logger.go index da7fada44..30bf968be 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -29,7 +29,7 @@ const ( logKey contextKeyType = "Logger" telemetryEnv = "TELEMETRY" - telemetryOTel = "opentelemetry" + telemetryOTel = "enabled" telemetryDefault = telemetryOTel )