Sfoglia il codice sorgente

vendor: go.opencensus.io v0.24.0

full diff: https://github.com/census-instrumentation/opencensus-go/compare/v0.23.0...v0.24.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 anni fa
parent
commit
2990defea7

+ 1 - 1
vendor.mod

@@ -180,7 +180,7 @@ require (
 	go.etcd.io/etcd/pkg/v3 v3.5.6 // indirect
 	go.etcd.io/etcd/raft/v3 v3.5.6 // indirect
 	go.etcd.io/etcd/server/v3 v3.5.6 // indirect
-	go.opencensus.io v0.23.0 // indirect
+	go.opencensus.io v0.24.0 // indirect
 	go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.29.0 // indirect
 	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.29.0 // indirect
 	go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.4.1 // indirect

+ 8 - 2
vendor.sum

@@ -1364,8 +1364,10 @@ github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h
 github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
 github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
@@ -1374,7 +1376,10 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
 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/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
 github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
 github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
 github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
@@ -1495,8 +1500,9 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
-go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=
 go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
+go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
+go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0/go.mod h1:E5NNboN0UqSAki0Atn9kVwaN7I+l25gGxDqBueo/74E=
 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.29.0 h1:n9b7AAdbQtQ0k9dm0Dm2/KUcUqtG8i2O15KzNaDze8c=
 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.29.0/go.mod h1:LsankqVDx4W+RhZNA5uWarULII/MBhF5qwCYxTuyXjs=

+ 4 - 4
vendor/go.opencensus.io/Makefile

@@ -91,7 +91,7 @@ embedmd:
 
 .PHONY: install-tools
 install-tools:
-	go get -u golang.org/x/lint/golint
-	go get -u golang.org/x/tools/cmd/cover
-	go get -u golang.org/x/tools/cmd/goimports
-	go get -u github.com/rakyll/embedmd
+	go install golang.org/x/lint/golint@latest
+	go install golang.org/x/tools/cmd/cover@latest
+	go install golang.org/x/tools/cmd/goimports@latest
+	go install github.com/rakyll/embedmd@latest

+ 1 - 1
vendor/go.opencensus.io/opencensus.go

@@ -17,5 +17,5 @@ package opencensus // import "go.opencensus.io"
 
 // Version is the current release version of OpenCensus in use.
 func Version() string {
-	return "0.23.0"
+	return "0.24.0"
 }

+ 9 - 0
vendor/go.opencensus.io/plugin/ocgrpc/client_metrics.go

@@ -28,6 +28,7 @@ var (
 	ClientReceivedMessagesPerRPC = stats.Int64("grpc.io/client/received_messages_per_rpc", "Number of response messages received per RPC (always 1 for non-streaming RPCs).", stats.UnitDimensionless)
 	ClientReceivedBytesPerRPC    = stats.Int64("grpc.io/client/received_bytes_per_rpc", "Total bytes received across all response messages per RPC.", stats.UnitBytes)
 	ClientRoundtripLatency       = stats.Float64("grpc.io/client/roundtrip_latency", "Time between first byte of request sent to last byte of response received, or terminal error.", stats.UnitMilliseconds)
+	ClientStartedRPCs            = stats.Int64("grpc.io/client/started_rpcs", "Number of started client RPCs.", stats.UnitDimensionless)
 	ClientServerLatency          = stats.Float64("grpc.io/client/server_latency", `Propagated from the server and should have the same value as "grpc.io/server/latency".`, stats.UnitMilliseconds)
 )
 
@@ -70,6 +71,14 @@ var (
 		Aggregation: view.Count(),
 	}
 
+	ClientStartedRPCsView = &view.View{
+		Measure:     ClientStartedRPCs,
+		Name:        "grpc.io/client/started_rpcs",
+		Description: "Number of started client RPCs.",
+		TagKeys:     []tag.Key{KeyClientMethod},
+		Aggregation: view.Count(),
+	}
+
 	ClientSentMessagesPerRPCView = &view.View{
 		Measure:     ClientSentMessagesPerRPC,
 		Name:        "grpc.io/client/sent_messages_per_rpc",

+ 9 - 0
vendor/go.opencensus.io/plugin/ocgrpc/server_metrics.go

@@ -27,6 +27,7 @@ var (
 	ServerReceivedBytesPerRPC    = stats.Int64("grpc.io/server/received_bytes_per_rpc", "Total bytes received across all messages per RPC.", stats.UnitBytes)
 	ServerSentMessagesPerRPC     = stats.Int64("grpc.io/server/sent_messages_per_rpc", "Number of messages sent in each RPC. Has value 1 for non-streaming RPCs.", stats.UnitDimensionless)
 	ServerSentBytesPerRPC        = stats.Int64("grpc.io/server/sent_bytes_per_rpc", "Total bytes sent in across all response messages per RPC.", stats.UnitBytes)
+	ServerStartedRPCs            = stats.Int64("grpc.io/server/started_rpcs", "Number of started server RPCs.", stats.UnitDimensionless)
 	ServerLatency                = stats.Float64("grpc.io/server/server_latency", "Time between first byte of request received to last byte of response sent, or terminal error.", stats.UnitMilliseconds)
 )
 
@@ -73,6 +74,14 @@ var (
 		Aggregation: view.Count(),
 	}
 
+	ServerStartedRPCsView = &view.View{
+		Measure:     ServerStartedRPCs,
+		Name:        "grpc.io/server/started_rpcs",
+		Description: "Number of started server RPCs.",
+		TagKeys:     []tag.Key{KeyServerMethod},
+		Aggregation: view.Count(),
+	}
+
 	ServerReceivedMessagesPerRPCView = &view.View{
 		Name:        "grpc.io/server/received_messages_per_rpc",
 		Description: "Distribution of messages received count per RPC, by method.",

+ 22 - 1
vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go

@@ -82,8 +82,10 @@ func methodName(fullname string) string {
 // statsHandleRPC processes the RPC events.
 func statsHandleRPC(ctx context.Context, s stats.RPCStats) {
 	switch st := s.(type) {
-	case *stats.Begin, *stats.OutHeader, *stats.InHeader, *stats.InTrailer, *stats.OutTrailer:
+	case *stats.OutHeader, *stats.InHeader, *stats.InTrailer, *stats.OutTrailer:
 		// do nothing for client
+	case *stats.Begin:
+		handleRPCBegin(ctx, st)
 	case *stats.OutPayload:
 		handleRPCOutPayload(ctx, st)
 	case *stats.InPayload:
@@ -95,6 +97,25 @@ func statsHandleRPC(ctx context.Context, s stats.RPCStats) {
 	}
 }
 
+func handleRPCBegin(ctx context.Context, s *stats.Begin) {
+	d, ok := ctx.Value(rpcDataKey).(*rpcData)
+	if !ok {
+		if grpclog.V(2) {
+			grpclog.Infoln("Failed to retrieve *rpcData from context.")
+		}
+	}
+
+	if s.IsClient() {
+		ocstats.RecordWithOptions(ctx,
+			ocstats.WithTags(tag.Upsert(KeyClientMethod, methodName(d.method))),
+			ocstats.WithMeasurements(ClientStartedRPCs.M(1)))
+	} else {
+		ocstats.RecordWithOptions(ctx,
+			ocstats.WithTags(tag.Upsert(KeyClientMethod, methodName(d.method))),
+			ocstats.WithMeasurements(ServerStartedRPCs.M(1)))
+	}
+}
+
 func handleRPCOutPayload(ctx context.Context, s *stats.OutPayload) {
 	d, ok := ctx.Value(rpcDataKey).(*rpcData)
 	if !ok {

+ 3 - 4
vendor/go.opencensus.io/stats/doc.go

@@ -19,7 +19,7 @@ Package stats contains support for OpenCensus stats recording.
 OpenCensus allows users to create typed measures, record measurements,
 aggregate the collected data, and export the aggregated data.
 
-Measures
+# Measures
 
 A measure represents a type of data point to be tracked and recorded.
 For example, latency, request Mb/s, and response Mb/s are measures
@@ -33,7 +33,7 @@ Libraries can define and export measures. Application authors can then
 create views and collect and break down measures by the tags they are
 interested in.
 
-Recording measurements
+# Recording measurements
 
 Measurement is a data point to be collected for a measure. For example,
 for a latency (ms) measure, 100 is a measurement that represents a 100ms
@@ -49,7 +49,7 @@ Libraries can always record measurements, and applications can later decide
 on which measurements they want to collect by registering views. This allows
 libraries to turn on the instrumentation by default.
 
-Exemplars
+# Exemplars
 
 For a given recorded measurement, the associated exemplar is a diagnostic map
 that gives more information about the measurement.
@@ -64,6 +64,5 @@ then the trace span will be added to the exemplar associated with the measuremen
 
 When exported to a supporting back end, you should be able to easily navigate
 to example traces that fell into each bucket in the Distribution.
-
 */
 package stats // import "go.opencensus.io/stats"

+ 6 - 0
vendor/go.opencensus.io/stats/internal/record.go

@@ -21,5 +21,11 @@ import (
 // DefaultRecorder will be called for each Record call.
 var DefaultRecorder func(tags *tag.Map, measurement interface{}, attachments map[string]interface{})
 
+// MeasurementRecorder will be called for each Record call. This is the same as DefaultRecorder but
+// avoids interface{} conversion.
+// This will be a func(tags *tag.Map, measurement []Measurement, attachments map[string]interface{}) type,
+// but is interface{} here to avoid import loops
+var MeasurementRecorder interface{}
+
 // SubscriptionReporter reports when a view subscribed with a measure.
 var SubscriptionReporter func(measure string)

+ 20 - 1
vendor/go.opencensus.io/stats/record.go

@@ -86,10 +86,29 @@ func createRecordOption(ros ...Options) *recordOptions {
 	return o
 }
 
+type measurementRecorder = func(tags *tag.Map, measurement []Measurement, attachments map[string]interface{})
+
 // Record records one or multiple measurements with the same context at once.
 // If there are any tags in the context, measurements will be tagged with them.
 func Record(ctx context.Context, ms ...Measurement) {
-	RecordWithOptions(ctx, WithMeasurements(ms...))
+	// Record behaves the same as RecordWithOptions, but because we do not have to handle generic functionality
+	// (RecordOptions) we can reduce some allocations to speed up this hot path
+	if len(ms) == 0 {
+		return
+	}
+	recorder := internal.MeasurementRecorder.(measurementRecorder)
+	record := false
+	for _, m := range ms {
+		if m.desc.subscribed() {
+			record = true
+			break
+		}
+	}
+	if !record {
+		return
+	}
+	recorder(tag.FromContext(ctx), ms, nil)
+	return
 }
 
 // RecordWithTags records one or multiple measurements at once.

+ 3 - 3
vendor/go.opencensus.io/stats/view/aggregation.go

@@ -90,9 +90,9 @@ func Sum() *Aggregation {
 //
 // If len(bounds) >= 2 then the boundaries for bucket index i are:
 //
-//     [-infinity, bounds[i]) for i = 0
-//     [bounds[i-1], bounds[i]) for 0 < i < length
-//     [bounds[i-1], +infinity) for i = length
+//	[-infinity, bounds[i]) for i = 0
+//	[bounds[i-1], bounds[i]) for 0 < i < length
+//	[bounds[i-1], +infinity) for i = length
 //
 // If len(bounds) is 0 then there is no histogram associated with the
 // distribution. There will be a single bucket with boundaries

+ 8 - 1
vendor/go.opencensus.io/stats/view/collector.go

@@ -59,8 +59,15 @@ func (c *collector) clearRows() {
 // encodeWithKeys encodes the map by using values
 // only associated with the keys provided.
 func encodeWithKeys(m *tag.Map, keys []tag.Key) []byte {
+	// Compute the buffer length we will need ahead of time to avoid resizing later
+	reqLen := 0
+	for _, k := range keys {
+		s, _ := m.Value(k)
+		// We will store each key + its length
+		reqLen += len(s) + 1
+	}
 	vb := &tagencoding.Values{
-		Buffer: make([]byte, len(keys)),
+		Buffer: make([]byte, reqLen),
 	}
 	for _, k := range keys {
 		v, _ := m.Value(k)

+ 1 - 1
vendor/go.opencensus.io/stats/view/doc.go

@@ -34,7 +34,7 @@
 // Libraries can define views but it is recommended that in most cases registering
 // views be left up to applications.
 //
-// Exporting
+// # Exporting
 //
 // Collected and aggregated data can be exported to a metric collection
 // backend by registering its exporter.

+ 23 - 4
vendor/go.opencensus.io/stats/view/worker.go

@@ -33,6 +33,7 @@ func init() {
 	defaultWorker = NewMeter().(*worker)
 	go defaultWorker.start()
 	internal.DefaultRecorder = record
+	internal.MeasurementRecorder = recordMeasurement
 }
 
 type measureRef struct {
@@ -199,11 +200,21 @@ func record(tags *tag.Map, ms interface{}, attachments map[string]interface{}) {
 	defaultWorker.Record(tags, ms, attachments)
 }
 
+func recordMeasurement(tags *tag.Map, ms []stats.Measurement, attachments map[string]interface{}) {
+	defaultWorker.recordMeasurement(tags, ms, attachments)
+}
+
 // Record records a set of measurements ms associated with the given tags and attachments.
 func (w *worker) Record(tags *tag.Map, ms interface{}, attachments map[string]interface{}) {
+	w.recordMeasurement(tags, ms.([]stats.Measurement), attachments)
+}
+
+// recordMeasurement records a set of measurements ms associated with the given tags and attachments.
+// This is the same as Record but without an interface{} type to avoid allocations
+func (w *worker) recordMeasurement(tags *tag.Map, ms []stats.Measurement, attachments map[string]interface{}) {
 	req := &recordReq{
 		tm:          tags,
-		ms:          ms.([]stats.Measurement),
+		ms:          ms,
 		attachments: attachments,
 		t:           time.Now(),
 	}
@@ -221,6 +232,11 @@ func SetReportingPeriod(d time.Duration) {
 	defaultWorker.SetReportingPeriod(d)
 }
 
+// Stop stops the default worker.
+func Stop() {
+	defaultWorker.Stop()
+}
+
 // SetReportingPeriod sets the interval between reporting aggregated views in
 // the program. If duration is less than or equal to zero, it enables the
 // default behavior.
@@ -281,7 +297,7 @@ func (w *worker) start() {
 		case <-w.quit:
 			w.timer.Stop()
 			close(w.c)
-			w.done <- true
+			close(w.done)
 			return
 		}
 	}
@@ -290,8 +306,11 @@ func (w *worker) start() {
 func (w *worker) Stop() {
 	prodMgr := metricproducer.GlobalManager()
 	prodMgr.DeleteProducer(w)
-
-	w.quit <- true
+	select {
+	case <-w.quit:
+	default:
+		close(w.quit)
+	}
 	<-w.done
 }
 

+ 1 - 0
vendor/go.opencensus.io/tag/profile_19.go

@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+//go:build go1.9
 // +build go1.9
 
 package tag

+ 1 - 0
vendor/go.opencensus.io/tag/profile_not19.go

@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+//go:build !go1.9
 // +build !go1.9
 
 package tag

+ 6 - 7
vendor/go.opencensus.io/trace/doc.go

@@ -18,24 +18,23 @@ Package trace contains support for OpenCensus distributed tracing.
 The following assumes a basic familiarity with OpenCensus concepts.
 See http://opencensus.io
 
-
-Exporting Traces
+# Exporting Traces
 
 To export collected tracing data, register at least one exporter. You can use
 one of the provided exporters or write your own.
 
-    trace.RegisterExporter(exporter)
+	trace.RegisterExporter(exporter)
 
 By default, traces will be sampled relatively rarely. To change the sampling
 frequency for your entire program, call ApplyConfig. Use a ProbabilitySampler
 to sample a subset of traces, or use AlwaysSample to collect a trace on every run:
 
-    trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
+	trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()})
 
 Be careful about using trace.AlwaysSample in a production application with
 significant traffic: a new trace will be started and exported for every request.
 
-Adding Spans to a Trace
+# Adding Spans to a Trace
 
 A trace consists of a tree of spans. In Go, the current span is carried in a
 context.Context.
@@ -44,8 +43,8 @@ It is common to want to capture all the activity of a function call in a span. F
 this to work, the function must take a context.Context as a parameter. Add these two
 lines to the top of the function:
 
-    ctx, span := trace.StartSpan(ctx, "example.com/Run")
-    defer span.End()
+	ctx, span := trace.StartSpan(ctx, "example.com/Run")
+	defer span.End()
 
 StartSpan will create a new top-level span if the context
 doesn't contain another span, otherwise it will create a child span.

+ 1 - 1
vendor/go.opencensus.io/trace/lrumap.go

@@ -44,7 +44,7 @@ func (lm lruMap) len() int {
 }
 
 func (lm lruMap) keys() []interface{} {
-	keys := make([]interface{}, len(lm.cacheKeys))
+	keys := make([]interface{}, 0, len(lm.cacheKeys))
 	for k := range lm.cacheKeys {
 		keys = append(keys, k)
 	}

+ 1 - 0
vendor/go.opencensus.io/trace/trace_go11.go

@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+//go:build go1.11
 // +build go1.11
 
 package trace

+ 1 - 0
vendor/go.opencensus.io/trace/trace_nongo11.go

@@ -12,6 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+//go:build !go1.11
 // +build !go1.11
 
 package trace

+ 1 - 1
vendor/modules.txt

@@ -1020,7 +1020,7 @@ go.etcd.io/etcd/server/v3/etcdserver/api/snap
 go.etcd.io/etcd/server/v3/etcdserver/api/snap/snappb
 go.etcd.io/etcd/server/v3/wal
 go.etcd.io/etcd/server/v3/wal/walpb
-# go.opencensus.io v0.23.0
+# go.opencensus.io v0.24.0
 ## explicit; go 1.13
 go.opencensus.io
 go.opencensus.io/internal