diff --git a/go.mod b/go.mod index 096ba8565..8ae1ec62d 100644 --- a/go.mod +++ b/go.mod @@ -11,21 +11,31 @@ require ( github.com/edwarnicke/serialize v1.0.7 github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 - github.com/golang/protobuf v1.4.3 - github.com/google/go-cmp v0.5.2 + 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/hashicorp/go-uuid v1.0.1 // indirect github.com/nats-io/nats-streaming-server v0.17.0 github.com/nats-io/stan.go v0.6.0 github.com/networkservicemesh/api v1.0.1-0.20210811070028-10403c0f20c8 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/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect @@ -33,7 +43,7 @@ require ( golang.org/x/sys v0.0.0-20210603125802-9665404d3644 // 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.25.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 99a5fa48a..a202c7b49 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= @@ -7,12 +9,15 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/OneOfOne/xxhash v1.2.3 h1:wS8NNaIgtzapuArKIAjsyXtEN/IUjQkbw90xszUdS40= github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= 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= 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= 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= @@ -21,6 +26,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= @@ -38,6 +44,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/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -68,20 +76,26 @@ 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 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +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= 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= @@ -92,8 +106,9 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= 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.1.1 h1:HJr7UE1x/JrJSc9Oy6aDBHtNHUUBHjcQjTgvUVihoZs= @@ -139,8 +154,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= @@ -162,6 +177,7 @@ github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLk github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= 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= @@ -171,6 +187,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= @@ -180,8 +197,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= @@ -191,6 +208,41 @@ github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= 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= 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= @@ -199,6 +251,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 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= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -217,17 +270,22 @@ 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= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 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-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -240,9 +298,11 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/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-20201119102817-f84b799fce68/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-20210603125802-9665404d3644 h1:CA1DEQ4NdKphKeL70tvsWNdT5oFh1lOjihRcEDROi0I= golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -276,10 +336,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= @@ -289,8 +351,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= @@ -299,8 +364,11 @@ 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/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= @@ -309,8 +377,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 b85d47004..dd83840db 100644 --- a/pkg/networkservice/chains/nsmgr/server.go +++ b/pkg/networkservice/chains/nsmgr/server.go @@ -43,6 +43,7 @@ import ( "github.com/networkservicemesh/sdk/pkg/networkservice/common/interpose" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/recvfd" "github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms/sendfd" + "github.com/networkservicemesh/sdk/pkg/networkservice/common/metrics" "github.com/networkservicemesh/sdk/pkg/networkservice/common/roundrobin" "github.com/networkservicemesh/sdk/pkg/networkservice/core/adapters" "github.com/networkservicemesh/sdk/pkg/registry" @@ -191,6 +192,7 @@ func NewServer(ctx context.Context, tokenGenerator token.GeneratorFunc, options roundrobin.NewServer(), excludedprefixes.NewServer(ctx), recvfd.NewServer(), // Receive any files passed + metrics.NewServer(), interpose.NewServer(&interposeRegistryServer), filtermechanisms.NewServer(&urlsRegistryServer), heal.NewServer(ctx, diff --git a/pkg/networkservice/common/heal/server.go b/pkg/networkservice/common/heal/server.go index 0bd7bbc58..5284e9293 100644 --- a/pkg/networkservice/common/heal/server.go +++ b/pkg/networkservice/common/heal/server.go @@ -24,7 +24,6 @@ import ( "sync" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" "github.com/networkservicemesh/api/pkg/api/networkservice" @@ -221,10 +220,10 @@ func (f *healServer) restoreConnection( // Make sure we have a valid expireTime to work with expires := request.GetConnection().GetNextPathSegment().GetExpires() - expireTime, err := ptypes.Timestamp(expires) - if err != nil { + if !expires.IsValid() { return } + expireTime := expires.AsTime() deadline := clockTime.Now().Add(f.restoreTimeout) if deadline.After(expireTime) { 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/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index 78ba07d09..eaab8807e 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" @@ -86,10 +85,10 @@ func (t *refreshClient) startTimer(ctx context.Context, connectionID string, req clockTime := clock.FromContext(ctx) nextClient := next.Client(ctx) - expireTime, err := ptypes.Timestamp(request.GetConnection().GetCurrentPathSegment().GetExpires()) - if err != nil { + if !request.GetConnection().GetCurrentPathSegment().GetExpires().IsValid() { return } + 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 1dd4a2e13..4ebfc2934 100644 --- a/pkg/networkservice/common/updatepath/server.go +++ b/pkg/networkservice/common/updatepath/server.go @@ -23,12 +23,9 @@ import ( "context" "time" - "github.com/golang/protobuf/ptypes" "github.com/golang/protobuf/ptypes/empty" - "github.com/golang/protobuf/ptypes/timestamp" - "github.com/pkg/errors" - "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" @@ -66,13 +63,7 @@ func (i *updatePathServer) 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) - } - - prev.Expires = expires + prev.Expires = timestamppb.New(expireTime.Local()) prev.Token = tok } } 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(), 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 54a6291f7..982002369 100644 --- a/pkg/tools/log/logger.go +++ b/pkg/tools/log/logger.go @@ -19,6 +19,7 @@ package log import ( "context" + "os" ) type contextKeyType string @@ -26,8 +27,33 @@ type contextKeyType string const ( logKey contextKeyType = "Logger" logFieldsKey contextKeyType = "LoggerFields" + + 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() +} + +func getTelemetryEnv() string { + val := os.Getenv(telemetryEnv) + if val == "" { + return telemetryDefault + } + return val +} + var ( isTracingEnabled = false ) diff --git a/pkg/tools/log/logruslogger/logruslogger.go b/pkg/tools/log/logruslogger/logruslogger.go index 3f7608734..1dc1c986c 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 "" } @@ -194,7 +196,7 @@ func New(ctx context.Context) 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) (context.Context, log.Logger, func()) { +func FromSpan(ctx context.Context, span spanlogger.Span, operation string) (context.Context, log.Logger, func()) { entry := logrus.WithFields(log.Fields(ctx)) var info *traceCtxInfo 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 4e37db367..f45443755 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 { @@ -64,5 +64,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 a090afd35..1fc6d5357 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{},