From 8a0a05b5bf950f7427f58e7df505bc008c9bfb39 Mon Sep 17 00:00:00 2001 From: "renovate-sh-app[bot]" <219655108+renovate-sh-app[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 19:46:20 +0000 Subject: [PATCH] fix(deps): update module go.opentelemetry.io/collector/pdata to v1.49.0 | datasource | package | from | to | | ---------- | ----------------------------------- | ------- | ------- | | go | go.opentelemetry.io/collector/pdata | v1.47.0 | v1.49.0 | Signed-off-by: renovate-sh-app[bot] <219655108+renovate-sh-app[bot]@users.noreply.github.com> --- go.mod | 8 +- go.sum | 20 +- .../github.com/hashicorp/go-version/LICENSE | 2 +- .../github.com/hashicorp/go-version/README.md | 5 +- .../hashicorp/go-version/constraint.go | 73 ++-- .../hashicorp/go-version/version.go | 64 +-- .../go-version/version_collection.go | 2 +- .../internal/generated_proto_anyvalue.go | 18 +- .../internal/generated_proto_arrayvalue.go | 2 - .../internal/generated_proto_entityref.go | 7 +- .../internal/generated_proto_exemplar.go | 16 +- .../generated_proto_exponentialhistogram.go | 6 +- ...ted_proto_exponentialhistogramdatapoint.go | 340 +++++----------- ...to_exponentialhistogramdatapointbuckets.go | 10 +- ...enerated_proto_exportlogspartialsuccess.go | 9 +- ...enerated_proto_exportlogsservicerequest.go | 2 - ...nerated_proto_exportlogsserviceresponse.go | 2 - ...rated_proto_exportmetricspartialsuccess.go | 9 +- ...rated_proto_exportmetricsservicerequest.go | 2 - ...ated_proto_exportmetricsserviceresponse.go | 2 - ...ated_proto_exportprofilespartialsuccess.go | 9 +- ...ated_proto_exportprofilesservicerequest.go | 2 - ...ted_proto_exportprofilesserviceresponse.go | 2 - ...nerated_proto_exporttracepartialsuccess.go | 9 +- ...nerated_proto_exporttraceservicerequest.go | 2 - ...erated_proto_exporttraceserviceresponse.go | 2 - .../internal/generated_proto_function.go | 23 +- .../pdata/internal/generated_proto_gauge.go | 2 - .../internal/generated_proto_histogram.go | 6 +- .../generated_proto_histogramdatapoint.go | 321 +++++---------- .../generated_proto_instrumentationscope.go | 9 +- .../pdata/internal/generated_proto_ipaddr.go | 5 +- .../internal/generated_proto_keyvalue.go | 5 +- .../generated_proto_keyvalueandunit.go | 13 +- .../internal/generated_proto_keyvaluelist.go | 2 - .../pdata/internal/generated_proto_line.go | 17 +- .../pdata/internal/generated_proto_link.go | 2 - .../internal/generated_proto_location.go | 18 +- .../internal/generated_proto_logrecord.go | 39 +- .../internal/generated_proto_logsdata.go | 2 - .../internal/generated_proto_logsrequest.go | 5 +- .../pdata/internal/generated_proto_mapping.go | 28 +- .../pdata/internal/generated_proto_metric.go | 12 +- .../internal/generated_proto_metricsdata.go | 2 - .../generated_proto_metricsrequest.go | 5 +- .../generated_proto_numberdatapoint.go | 27 +- .../pdata/internal/generated_proto_profile.go | 44 +-- .../internal/generated_proto_profilesdata.go | 2 - .../generated_proto_profilesdictionary.go | 5 +- .../generated_proto_profilesrequest.go | 5 +- .../generated_proto_requestcontext.go | 9 +- .../internal/generated_proto_resource.go | 11 +- .../internal/generated_proto_resourcelogs.go | 5 +- .../generated_proto_resourcemetrics.go | 5 +- .../generated_proto_resourceprofiles.go | 4 +- .../internal/generated_proto_resourcespans.go | 5 +- .../pdata/internal/generated_proto_sample.go | 23 +- .../internal/generated_proto_scopelogs.go | 6 +- .../internal/generated_proto_scopemetrics.go | 6 +- .../internal/generated_proto_scopeprofiles.go | 6 +- .../internal/generated_proto_scopespans.go | 6 +- .../pdata/internal/generated_proto_span.go | 68 ++-- .../internal/generated_proto_spancontext.go | 17 +- .../internal/generated_proto_spanevent.go | 14 +- .../internal/generated_proto_spanlink.go | 18 +- .../pdata/internal/generated_proto_stack.go | 2 + .../pdata/internal/generated_proto_status.go | 7 +- .../pdata/internal/generated_proto_sum.go | 12 +- .../pdata/internal/generated_proto_summary.go | 2 - .../generated_proto_summarydatapoint.go | 30 +- ...d_proto_summarydatapointvalueatquantile.go | 11 +- .../pdata/internal/generated_proto_tcpaddr.go | 11 +- .../internal/generated_proto_tracesdata.go | 2 - .../internal/generated_proto_tracesrequest.go | 5 +- .../pdata/internal/generated_proto_udpaddr.go | 11 +- .../internal/generated_proto_unixaddr.go | 3 +- .../internal/generated_proto_valuetype.go | 11 +- .../pdata/pmetric/generated_exemplar.go | 4 +- ...generated_exponentialhistogramdatapoint.go | 24 +- .../pmetric/generated_histogramdatapoint.go | 24 +- .../pdata/pmetric/generated_metric.go | 20 +- .../pmetric/generated_numberdatapoint.go | 4 +- .../grpc_lb_v1/load_balancer_grpc.pb.go | 2 +- .../balancer/weightedroundrobin/balancer.go | 39 +- .../balancer/weightedroundrobin/scheduler.go | 4 +- vendor/google.golang.org/grpc/clientconn.go | 144 ++++++- .../proto/grpc_gcp/handshaker_grpc.pb.go | 2 +- .../grpc/experimental/stats/metricregistry.go | 39 ++ .../grpc/experimental/stats/metrics.go | 7 + .../health/grpc_health_v1/health_grpc.pb.go | 2 +- .../balancer/gracefulswitch/gracefulswitch.go | 12 + .../grpc/internal/envconfig/envconfig.go | 5 + .../grpc/internal/experimental.go | 4 + .../grpc/internal/idle/idle.go | 77 ++-- .../grpc/internal/internal.go | 4 + .../proto/grpc_lookup_v1/rls_grpc.pb.go | 2 +- .../grpc/internal/transport/http2_client.go | 13 +- .../grpc/internal/transport/http_util.go | 6 - .../grpc/internal/transport/transport.go | 11 +- .../xds/balancer/cdsbalancer/cdsbalancer.go | 4 +- .../balancer/cdsbalancer/cluster_watcher.go | 5 +- .../xds/balancer/clusterimpl/clusterimpl.go | 3 +- .../xds/balancer/clusterimpl/picker.go | 22 ++ .../clusterresolver/resource_resolver_eds.go | 4 +- .../grpc/internal/xds/bootstrap/bootstrap.go | 13 + .../xds/clients/internal/buffer/unbounded.go | 1 + .../xds/clients/xdsclient/ads_stream.go | 216 ++++------ .../xds/clients/xdsclient/authority.go | 2 +- .../internal/xds/clients/xdsclient/channel.go | 2 +- .../clients/xdsclient/clientimpl_watchers.go | 19 +- .../xds/clients/xdsclient/resource_watcher.go | 3 + .../xds/clients/xdsclient/xdsconfig.go | 34 +- .../internal/xds/matcher/string_matcher.go | 119 ++++-- .../internal/xds/resolver/serviceconfig.go | 84 ++-- .../internal/xds/resolver/watch_service.go | 92 ----- .../internal/xds/resolver/xds_resolver.go | 370 +++++------------- .../internal/xds/server/listener_wrapper.go | 3 +- .../grpc/internal/xds/server/rds_handler.go | 6 +- .../grpc/internal/xds/xds.go | 16 + .../grpc/internal/xds/xdsclient/client.go | 8 +- .../grpc/internal/xds/xdsclient/clientimpl.go | 54 ++- .../xds/xdsclient/clientimpl_watchers.go | 36 -- .../internal/xds/xdsclient/resource_types.go | 6 +- .../xdsresource/cluster_resource_type.go | 110 +++--- .../xdsresource/endpoints_resource_type.go | 103 ++--- .../xds/xdsclient/xdsresource/filter_chain.go | 2 +- .../xdsresource/listener_resource_type.go | 8 +- .../xdsclient/xdsresource/resource_type.go | 146 +------ .../xdsresource/route_config_resource_type.go | 104 ++--- .../xds/xdsclient/xdsresource/type_eds.go | 1 + .../xds/xdsclient/xdsresource/type_rds.go | 3 + .../xdsclient/xdsresource/unmarshal_eds.go | 1 + .../xdsclient/xdsresource/unmarshal_lds.go | 13 +- .../xdsclient/xdsresource/unmarshal_rds.go | 22 +- .../xds/xdsclient/xdsresource/xdsconfig.go | 114 ++++++ .../internal/xds/xdsdepmgr/watch_service.go | 83 ++++ .../xds/xdsdepmgr/xds_dependency_manager.go | 279 +++++++++++++ .../google.golang.org/grpc/mem/buffer_pool.go | 13 +- .../grpc/resolver_wrapper.go | 1 + vendor/google.golang.org/grpc/rpc_util.go | 93 ++++- vendor/google.golang.org/grpc/stream.go | 68 ++-- vendor/google.golang.org/grpc/version.go | 2 +- vendor/modules.txt | 9 +- 143 files changed, 2135 insertions(+), 2145 deletions(-) delete mode 100644 vendor/google.golang.org/grpc/internal/xds/resolver/watch_service.go delete mode 100644 vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl_watchers.go create mode 100644 vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/xdsconfig.go create mode 100644 vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/watch_service.go create mode 100644 vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/xds_dependency_manager.go diff --git a/go.mod b/go.mod index 45655ff93e8..6c8dd145e74 100644 --- a/go.mod +++ b/go.mod @@ -105,7 +105,7 @@ require ( golang.org/x/sys v0.40.0 golang.org/x/time v0.14.0 google.golang.org/api v0.257.0 - google.golang.org/grpc v1.77.0 + google.golang.org/grpc v1.78.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/klog/v2 v2.130.1 @@ -157,7 +157,7 @@ require ( github.com/twmb/franz-go/pkg/kmsg v1.12.0 github.com/twmb/franz-go/plugin/kotel v1.6.0 github.com/twmb/franz-go/plugin/kprom v1.2.1 - go.opentelemetry.io/collector/pdata v1.47.0 + go.opentelemetry.io/collector/pdata v1.49.0 go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 go.opentelemetry.io/otel/sdk v1.38.0 go4.org/netipx v0.0.0-20230125063823-8449b0a6169f @@ -236,7 +236,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect github.com/hashicorp/go-metrics v0.5.4 // indirect github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect - github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/go-version v1.8.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/jaegertracing/jaeger-idl v0.5.0 // indirect github.com/kamstrup/intmap v0.5.2 // indirect @@ -296,7 +296,7 @@ require ( go.opentelemetry.io/collector/confmap v1.45.0 // indirect go.opentelemetry.io/collector/confmap/xconfmap v0.139.0 // indirect go.opentelemetry.io/collector/consumer v1.45.0 // indirect - go.opentelemetry.io/collector/featuregate v1.47.0 // indirect + go.opentelemetry.io/collector/featuregate v1.49.0 // indirect go.opentelemetry.io/collector/pipeline v1.45.0 // indirect go.opentelemetry.io/collector/processor v1.45.0 // indirect go.opentelemetry.io/contrib/bridges/prometheus v0.63.0 // indirect diff --git a/go.sum b/go.sum index e5875de1a71..2264b9adcf7 100644 --- a/go.sum +++ b/go.sum @@ -704,8 +704,8 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= -github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4= +github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= @@ -1205,12 +1205,12 @@ go.opentelemetry.io/collector/consumer/consumertest v0.139.0 h1:06mu43mMO7l49ASJ go.opentelemetry.io/collector/consumer/consumertest v0.139.0/go.mod h1:gaeCpRQGbCFYTeLzi+Z2cTDt40GiIa3hgIEgLEmiC78= go.opentelemetry.io/collector/consumer/xconsumer v0.139.0 h1:FhzDv+idglnrfjqPvnUw3YAEOkXSNv/FuNsuMiXQwcY= go.opentelemetry.io/collector/consumer/xconsumer v0.139.0/go.mod h1:yWrg/6FE/A4Q7eo/Mg++CzkBoSILHdeMnTlxV3serI0= -go.opentelemetry.io/collector/featuregate v1.47.0 h1:LuJnDngViDzPKds5QOGxVYNL1QCCVWN/m61lHTV8Pf4= -go.opentelemetry.io/collector/featuregate v1.47.0/go.mod h1:d0tiRzVYrytB6LkcYgz2ESFTv7OktRPQe0QEQcPt1L4= -go.opentelemetry.io/collector/internal/testutil v0.141.0 h1:/rUGApojPtUPMN3rFfApNgEjAt03rCGt2qxNxGGs/4A= -go.opentelemetry.io/collector/internal/testutil v0.141.0/go.mod h1:YAD9EAkwh/l5asZNbEBEUCqEjoL1OKMjAMoPjPqH76c= -go.opentelemetry.io/collector/pdata v1.47.0 h1:4Mk0mo2RlKCUPomV8ISm+Yx/STFtuSn88yjiCePHkGA= -go.opentelemetry.io/collector/pdata v1.47.0/go.mod h1:yMdjdWZBNA8wLFCQXOCLb0RfcpZOxp7exH+bN7udWO0= +go.opentelemetry.io/collector/featuregate v1.49.0 h1:4UfnqTvSvm6GkeD/w39LYLPmnZDfk4f+grkWuyl0NPU= +go.opentelemetry.io/collector/featuregate v1.49.0/go.mod h1:/1bclXgP91pISaEeNulRxzzmzMTm4I5Xih2SnI4HRSo= +go.opentelemetry.io/collector/internal/testutil v0.143.0 h1:rp3vIsOhXg/H3YXuStdggGTLuU+Udf1BdDIF/I7+Tyk= +go.opentelemetry.io/collector/internal/testutil v0.143.0/go.mod h1:YAD9EAkwh/l5asZNbEBEUCqEjoL1OKMjAMoPjPqH76c= +go.opentelemetry.io/collector/pdata v1.49.0 h1:h6V3rdLNxweI3K8B5SZzjMiVdsPPBB1TPAWwZkCtGZE= +go.opentelemetry.io/collector/pdata v1.49.0/go.mod h1:gidKN58CUnhd4DSM61UzPKWjXmG0vyoIn7dd+URZW9A= go.opentelemetry.io/collector/pdata/pprofile v0.140.0 h1:b9TZ6UnyzsT/ERQw2VKGi/NYLtKSmjG7cgQuc9wZt5s= go.opentelemetry.io/collector/pdata/pprofile v0.140.0/go.mod h1:/2s/YBWGbu+r8MuKu5zas08iSqe+3P6xnbRpfE2DWAA= go.opentelemetry.io/collector/pdata/testdata v0.139.0 h1:n7O5bmLLhc3T6PePV4447fFcI/6QWcMhBsLtfCaD0do= @@ -1642,8 +1642,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= -google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= +google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc= +google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U= 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= diff --git a/vendor/github.com/hashicorp/go-version/LICENSE b/vendor/github.com/hashicorp/go-version/LICENSE index 1409d6ab92f..bb1e9a486af 100644 --- a/vendor/github.com/hashicorp/go-version/LICENSE +++ b/vendor/github.com/hashicorp/go-version/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 HashiCorp, Inc. +Copyright IBM Corp. 2014, 2025 Mozilla Public License, version 2.0 diff --git a/vendor/github.com/hashicorp/go-version/README.md b/vendor/github.com/hashicorp/go-version/README.md index 4b7806cd964..83a8249f72c 100644 --- a/vendor/github.com/hashicorp/go-version/README.md +++ b/vendor/github.com/hashicorp/go-version/README.md @@ -1,6 +1,7 @@ # Versioning Library for Go + ![Build Status](https://github.com/hashicorp/go-version/actions/workflows/go-tests.yml/badge.svg) -[![GoDoc](https://godoc.org/github.com/hashicorp/go-version?status.svg)](https://godoc.org/github.com/hashicorp/go-version) +[![Go Reference](https://pkg.go.dev/badge/github.com/hashicorp/go-version.svg)](https://pkg.go.dev/github.com/hashicorp/go-version) go-version is a library for parsing versions and version constraints, and verifying versions against a set of constraints. go-version @@ -12,7 +13,7 @@ Versions used with go-version must follow [SemVer](http://semver.org/). ## Installation and Usage Package documentation can be found on -[GoDoc](http://godoc.org/github.com/hashicorp/go-version). +[Go Reference](https://pkg.go.dev/github.com/hashicorp/go-version). Installation can be done with a normal `go get`: diff --git a/vendor/github.com/hashicorp/go-version/constraint.go b/vendor/github.com/hashicorp/go-version/constraint.go index 29bdc4d2b5d..3964da070d6 100644 --- a/vendor/github.com/hashicorp/go-version/constraint.go +++ b/vendor/github.com/hashicorp/go-version/constraint.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package version @@ -8,8 +8,26 @@ import ( "regexp" "sort" "strings" + "sync" ) +var ( + constraintRegexp *regexp.Regexp + constraintRegexpOnce sync.Once +) + +func getConstraintRegexp() *regexp.Regexp { + constraintRegexpOnce.Do(func() { + // This heavy lifting only happens the first time this function is called + constraintRegexp = regexp.MustCompile(fmt.Sprintf( + `^\s*(%s)\s*(%s)\s*$`, + `<=|>=|!=|~>|<|>|=|`, + VersionRegexpRaw, + )) + }) + return constraintRegexp +} + // Constraint represents a single constraint for a version, such as // ">= 1.0". type Constraint struct { @@ -29,38 +47,11 @@ type Constraints []*Constraint type constraintFunc func(v, c *Version) bool -var constraintOperators map[string]constraintOperation - type constraintOperation struct { op operator f constraintFunc } -var constraintRegexp *regexp.Regexp - -func init() { - constraintOperators = map[string]constraintOperation{ - "": {op: equal, f: constraintEqual}, - "=": {op: equal, f: constraintEqual}, - "!=": {op: notEqual, f: constraintNotEqual}, - ">": {op: greaterThan, f: constraintGreaterThan}, - "<": {op: lessThan, f: constraintLessThan}, - ">=": {op: greaterThanEqual, f: constraintGreaterThanEqual}, - "<=": {op: lessThanEqual, f: constraintLessThanEqual}, - "~>": {op: pessimistic, f: constraintPessimistic}, - } - - ops := make([]string, 0, len(constraintOperators)) - for k := range constraintOperators { - ops = append(ops, regexp.QuoteMeta(k)) - } - - constraintRegexp = regexp.MustCompile(fmt.Sprintf( - `^\s*(%s)\s*(%s)\s*$`, - strings.Join(ops, "|"), - VersionRegexpRaw)) -} - // NewConstraint will parse one or more constraints from the given // constraint string. The string must be a comma-separated list of // constraints. @@ -107,7 +98,7 @@ func (cs Constraints) Check(v *Version) bool { // to '>0.2' it is *NOT* treated as equal. // // Missing operator is treated as equal to '=', whitespaces -// are ignored and constraints are sorted before comaparison. +// are ignored and constraints are sorted before comparison. func (cs Constraints) Equals(c Constraints) bool { if len(cs) != len(c) { return false @@ -176,9 +167,9 @@ func (c *Constraint) String() string { } func parseSingle(v string) (*Constraint, error) { - matches := constraintRegexp.FindStringSubmatch(v) + matches := getConstraintRegexp().FindStringSubmatch(v) if matches == nil { - return nil, fmt.Errorf("Malformed constraint: %s", v) + return nil, fmt.Errorf("malformed constraint: %s", v) } check, err := NewVersion(matches[2]) @@ -186,7 +177,25 @@ func parseSingle(v string) (*Constraint, error) { return nil, err } - cop := constraintOperators[matches[1]] + var cop constraintOperation + switch matches[1] { + case "=": + cop = constraintOperation{op: equal, f: constraintEqual} + case "!=": + cop = constraintOperation{op: notEqual, f: constraintNotEqual} + case ">": + cop = constraintOperation{op: greaterThan, f: constraintGreaterThan} + case "<": + cop = constraintOperation{op: lessThan, f: constraintLessThan} + case ">=": + cop = constraintOperation{op: greaterThanEqual, f: constraintGreaterThanEqual} + case "<=": + cop = constraintOperation{op: lessThanEqual, f: constraintLessThanEqual} + case "~>": + cop = constraintOperation{op: pessimistic, f: constraintPessimistic} + default: + cop = constraintOperation{op: equal, f: constraintEqual} + } return &Constraint{ f: cop.f, diff --git a/vendor/github.com/hashicorp/go-version/version.go b/vendor/github.com/hashicorp/go-version/version.go index 7c683c2813a..17b29732ee1 100644 --- a/vendor/github.com/hashicorp/go-version/version.go +++ b/vendor/github.com/hashicorp/go-version/version.go @@ -1,23 +1,39 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package version import ( - "bytes" "database/sql/driver" "fmt" "regexp" "strconv" "strings" + "sync" ) // The compiled regular expression used to test the validity of a version. var ( - versionRegexp *regexp.Regexp - semverRegexp *regexp.Regexp + versionRegexp *regexp.Regexp + versionRegexpOnce sync.Once + semverRegexp *regexp.Regexp + semverRegexpOnce sync.Once ) +func getVersionRegexp() *regexp.Regexp { + versionRegexpOnce.Do(func() { + versionRegexp = regexp.MustCompile("^" + VersionRegexpRaw + "$") + }) + return versionRegexp +} + +func getSemverRegexp() *regexp.Regexp { + semverRegexpOnce.Do(func() { + semverRegexp = regexp.MustCompile("^" + SemverRegexpRaw + "$") + }) + return semverRegexp +} + // The raw regular expression string used for testing the validity // of a version. const ( @@ -42,28 +58,23 @@ type Version struct { original string } -func init() { - versionRegexp = regexp.MustCompile("^" + VersionRegexpRaw + "$") - semverRegexp = regexp.MustCompile("^" + SemverRegexpRaw + "$") -} - // NewVersion parses the given version and returns a new // Version. func NewVersion(v string) (*Version, error) { - return newVersion(v, versionRegexp) + return newVersion(v, getVersionRegexp()) } // NewSemver parses the given version and returns a new // Version that adheres strictly to SemVer specs // https://semver.org/ func NewSemver(v string) (*Version, error) { - return newVersion(v, semverRegexp) + return newVersion(v, getSemverRegexp()) } func newVersion(v string, pattern *regexp.Regexp) (*Version, error) { matches := pattern.FindStringSubmatch(v) if matches == nil { - return nil, fmt.Errorf("Malformed version: %s", v) + return nil, fmt.Errorf("malformed version: %s", v) } segmentsStr := strings.Split(matches[1], ".") segments := make([]int64, len(segmentsStr)) @@ -71,7 +82,7 @@ func newVersion(v string, pattern *regexp.Regexp) (*Version, error) { val, err := strconv.ParseInt(str, 10, 64) if err != nil { return nil, fmt.Errorf( - "Error parsing version: %s", err) + "error parsing version: %s", err) } segments[i] = val @@ -174,7 +185,7 @@ func (v *Version) Compare(other *Version) int { } else if lhs < rhs { return -1 } - // Otherwis, rhs was > lhs, they're not equal + // Otherwise, rhs was > lhs, they're not equal return 1 } @@ -382,22 +393,29 @@ func (v *Version) Segments64() []int64 { // missing parts (1.0 => 1.0.0) will be made into a canonicalized form // as shown in the parenthesized examples. func (v *Version) String() string { - var buf bytes.Buffer - fmtParts := make([]string, len(v.segments)) + return string(v.bytes()) +} + +func (v *Version) bytes() []byte { + var buf []byte for i, s := range v.segments { - // We can ignore err here since we've pre-parsed the values in segments - str := strconv.FormatInt(s, 10) - fmtParts[i] = str + if i > 0 { + buf = append(buf, '.') + } + buf = strconv.AppendInt(buf, s, 10) } - fmt.Fprintf(&buf, strings.Join(fmtParts, ".")) + if v.pre != "" { - fmt.Fprintf(&buf, "-%s", v.pre) + buf = append(buf, '-') + buf = append(buf, v.pre...) } + if v.metadata != "" { - fmt.Fprintf(&buf, "+%s", v.metadata) + buf = append(buf, '+') + buf = append(buf, v.metadata...) } - return buf.String() + return buf } // Original returns the original parsed version as-is, including any diff --git a/vendor/github.com/hashicorp/go-version/version_collection.go b/vendor/github.com/hashicorp/go-version/version_collection.go index 83547fe13d6..11bc8b1c56c 100644 --- a/vendor/github.com/hashicorp/go-version/version_collection.go +++ b/vendor/github.com/hashicorp/go-version/version_collection.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright IBM Corp. 2014, 2025 // SPDX-License-Identifier: MPL-2.0 package version diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go index ddc86601cd8..103c4c5b443 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_anyvalue.go @@ -170,7 +170,6 @@ func DeleteAnyValue(orig *AnyValue, nullable bool) { orig.Reset() return } - switch ov := orig.Value.(type) { case *AnyValue_StringValue: if UseProtoPooling.IsEnabled() { @@ -205,9 +204,7 @@ func DeleteAnyValue(orig *AnyValue, nullable bool) { ov.BytesValue = nil ProtoPoolAnyValue_BytesValue.Put(ov) } - } - orig.Reset() if nullable { protoPoolAnyValue.Put(orig) @@ -237,6 +234,7 @@ func CopyAnyValue(dest, src *AnyValue) *AnyValue { } ov.StringValue = t.StringValue dest.Value = ov + case *AnyValue_BoolValue: var ov *AnyValue_BoolValue if !UseProtoPooling.IsEnabled() { @@ -246,6 +244,7 @@ func CopyAnyValue(dest, src *AnyValue) *AnyValue { } ov.BoolValue = t.BoolValue dest.Value = ov + case *AnyValue_IntValue: var ov *AnyValue_IntValue if !UseProtoPooling.IsEnabled() { @@ -255,6 +254,7 @@ func CopyAnyValue(dest, src *AnyValue) *AnyValue { } ov.IntValue = t.IntValue dest.Value = ov + case *AnyValue_DoubleValue: var ov *AnyValue_DoubleValue if !UseProtoPooling.IsEnabled() { @@ -264,6 +264,7 @@ func CopyAnyValue(dest, src *AnyValue) *AnyValue { } ov.DoubleValue = t.DoubleValue dest.Value = ov + case *AnyValue_ArrayValue: var ov *AnyValue_ArrayValue if !UseProtoPooling.IsEnabled() { @@ -295,6 +296,7 @@ func CopyAnyValue(dest, src *AnyValue) *AnyValue { } ov.BytesValue = t.BytesValue dest.Value = ov + default: dest.Value = nil } @@ -404,7 +406,6 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { ov.StringValue = iter.ReadString() orig.Value = ov } - case "boolValue", "bool_value": { var ov *AnyValue_BoolValue @@ -416,7 +417,6 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { ov.BoolValue = iter.ReadBool() orig.Value = ov } - case "intValue", "int_value": { var ov *AnyValue_IntValue @@ -428,7 +428,6 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { ov.IntValue = iter.ReadInt64() orig.Value = ov } - case "doubleValue", "double_value": { var ov *AnyValue_DoubleValue @@ -440,7 +439,6 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { ov.DoubleValue = iter.ReadFloat64() orig.Value = ov } - case "arrayValue", "array_value": { var ov *AnyValue_ArrayValue @@ -453,7 +451,6 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { ov.ArrayValue.UnmarshalJSON(iter) orig.Value = ov } - case "kvlistValue", "kvlist_value": { var ov *AnyValue_KvlistValue @@ -466,7 +463,6 @@ func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { ov.KvlistValue.UnmarshalJSON(iter) orig.Value = ov } - case "bytesValue", "bytes_value": { var ov *AnyValue_BytesValue @@ -497,10 +493,13 @@ func (orig *AnyValue) SizeProto() int { l = len(orig.StringValue) n += 1 + proto.Sov(uint64(l)) + l case *AnyValue_BoolValue: + n += 2 case *AnyValue_IntValue: + n += 1 + proto.Sov(uint64(orig.IntValue)) case *AnyValue_DoubleValue: + n += 9 case *AnyValue_ArrayValue: if orig.ArrayValue != nil { @@ -736,6 +735,7 @@ func (orig *AnyValue) UnmarshalProto(buf []byte) error { copy(ov.BytesValue, buf[startPos:pos]) } orig.Value = ov + default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) if err != nil { diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go index a4367eac263..f973831cf8e 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_arrayvalue.go @@ -43,11 +43,9 @@ func DeleteArrayValue(orig *ArrayValue, nullable bool) { orig.Reset() return } - for i := range orig.Values { DeleteAnyValue(&orig.Values[i], false) } - orig.Reset() if nullable { protoPoolArrayValue.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go index 47c562e6813..d326cfe46e5 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_entityref.go @@ -66,10 +66,9 @@ func CopyEntityRef(dest, src *EntityRef) *EntityRef { dest = NewEntityRef() } dest.SchemaUrl = src.SchemaUrl - dest.Type = src.Type - dest.IdKeys = append(dest.IdKeys[:0], src.IdKeys...) + dest.DescriptionKeys = append(dest.DescriptionKeys[:0], src.DescriptionKeys...) return dest @@ -148,6 +147,7 @@ func (orig *EntityRef) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + if len(orig.DescriptionKeys) > 0 { dest.WriteObjectField("descriptionKeys") dest.WriteArrayStart() @@ -158,6 +158,7 @@ func (orig *EntityRef) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -189,10 +190,12 @@ func (orig *EntityRef) SizeProto() int { var n int var l int _ = l + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.Type) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go index 29223128d0d..5516bfd201d 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exemplar.go @@ -50,9 +50,9 @@ func (m *Exemplar) GetAsInt() int64 { // Exemplars also hold information about the environment when the measurement was recorded, // for example the span and trace ID of the active span when the exemplar was recorded. type Exemplar struct { + Value any FilteredAttributes []KeyValue TimeUnixNano uint64 - Value any TraceId TraceID SpanId SpanID } @@ -93,10 +93,10 @@ func DeleteExemplar(orig *Exemplar, nullable bool) { orig.Reset() return } - for i := range orig.FilteredAttributes { DeleteKeyValue(&orig.FilteredAttributes[i], false) } + switch ov := orig.Value.(type) { case *Exemplar_AsDouble: if UseProtoPooling.IsEnabled() { @@ -108,11 +108,9 @@ func DeleteExemplar(orig *Exemplar, nullable bool) { ov.AsInt = int64(0) ProtoPoolExemplar_AsInt.Put(ov) } - } DeleteTraceID(&orig.TraceId, false) DeleteSpanID(&orig.SpanId, false) - orig.Reset() if nullable { protoPoolExemplar.Put(orig) @@ -135,7 +133,6 @@ func CopyExemplar(dest, src *Exemplar) *Exemplar { dest.FilteredAttributes = CopyKeyValueSlice(dest.FilteredAttributes, src.FilteredAttributes) dest.TimeUnixNano = src.TimeUnixNano - switch t := src.Value.(type) { case *Exemplar_AsDouble: var ov *Exemplar_AsDouble @@ -146,6 +143,7 @@ func CopyExemplar(dest, src *Exemplar) *Exemplar { } ov.AsDouble = t.AsDouble dest.Value = ov + case *Exemplar_AsInt: var ov *Exemplar_AsInt if !UseProtoPooling.IsEnabled() { @@ -155,6 +153,7 @@ func CopyExemplar(dest, src *Exemplar) *Exemplar { } ov.AsInt = t.AsInt dest.Value = ov + default: dest.Value = nil } @@ -277,7 +276,6 @@ func (orig *Exemplar) UnmarshalJSON(iter *json.Iterator) { ov.AsDouble = iter.ReadFloat64() orig.Value = ov } - case "asInt", "as_int": { var ov *Exemplar_AsInt @@ -310,7 +308,7 @@ func (orig *Exemplar) SizeProto() int { l = orig.FilteredAttributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } switch orig := orig.Value.(type) { @@ -318,8 +316,10 @@ func (orig *Exemplar) SizeProto() int { _ = orig break case *Exemplar_AsDouble: + n += 9 case *Exemplar_AsInt: + n += 9 } l = orig.TraceId.SizeProto() @@ -340,7 +340,7 @@ func (orig *Exemplar) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x3a } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go index 926816346a9..5d5e07793d2 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogram.go @@ -45,7 +45,6 @@ func DeleteExponentialHistogram(orig *ExponentialHistogram, nullable bool) { orig.Reset() return } - for i := range orig.DataPoints { DeleteExponentialHistogramDataPoint(orig.DataPoints[i], true) } @@ -175,7 +174,7 @@ func (orig *ExponentialHistogram) SizeProto() int { l = orig.DataPoints[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.AggregationTemporality != 0 { + if orig.AggregationTemporality != AggregationTemporality(0) { n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) } return n @@ -192,7 +191,7 @@ func (orig *ExponentialHistogram) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.AggregationTemporality != 0 { + if orig.AggregationTemporality != AggregationTemporality(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) pos-- buf[pos] = 0x10 @@ -240,7 +239,6 @@ func (orig *ExponentialHistogram) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.AggregationTemporality = AggregationTemporality(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go index d16c0120ebd..e0407b073e0 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapoint.go @@ -16,79 +16,26 @@ import ( "go.opentelemetry.io/collector/pdata/internal/proto" ) -func (m *ExponentialHistogramDataPoint) GetSum_() any { - if m != nil { - return m.Sum_ - } - return nil -} - -type ExponentialHistogramDataPoint_Sum struct { - Sum float64 -} - -func (m *ExponentialHistogramDataPoint) GetSum() float64 { - if v, ok := m.GetSum_().(*ExponentialHistogramDataPoint_Sum); ok { - return v.Sum - } - return float64(0) -} - -func (m *ExponentialHistogramDataPoint) GetMin_() any { - if m != nil { - return m.Min_ - } - return nil -} - -type ExponentialHistogramDataPoint_Min struct { - Min float64 -} - -func (m *ExponentialHistogramDataPoint) GetMin() float64 { - if v, ok := m.GetMin_().(*ExponentialHistogramDataPoint_Min); ok { - return v.Min - } - return float64(0) -} - -func (m *ExponentialHistogramDataPoint) GetMax_() any { - if m != nil { - return m.Max_ - } - return nil -} - -type ExponentialHistogramDataPoint_Max struct { - Max float64 -} - -func (m *ExponentialHistogramDataPoint) GetMax() float64 { - if v, ok := m.GetMax_().(*ExponentialHistogramDataPoint_Max); ok { - return v.Max - } - return float64(0) -} - // ExponentialHistogramDataPoint is a single data point in a timeseries that describes the // time-varying values of a ExponentialHistogram of double values. A ExponentialHistogram contains // summary statistics for a population of values, it may optionally contain the // distribution of those values across a set of buckets. type ExponentialHistogramDataPoint struct { + Positive ExponentialHistogramDataPointBuckets + Negative ExponentialHistogramDataPointBuckets Attributes []KeyValue + Exemplars []Exemplar StartTimeUnixNano uint64 TimeUnixNano uint64 Count uint64 - Sum_ any - Scale int32 + Sum float64 ZeroCount uint64 - Positive ExponentialHistogramDataPointBuckets - Negative ExponentialHistogramDataPointBuckets - Flags uint32 - Exemplars []Exemplar - Min_ any - Max_ any + Min float64 + Max float64 ZeroThreshold float64 + metadata [1]uint64 + Scale int32 + Flags uint32 } var ( @@ -97,23 +44,6 @@ var ( return &ExponentialHistogramDataPoint{} }, } - ProtoPoolExponentialHistogramDataPoint_Sum = sync.Pool{ - New: func() any { - return &ExponentialHistogramDataPoint_Sum{} - }, - } - - ProtoPoolExponentialHistogramDataPoint_Min = sync.Pool{ - New: func() any { - return &ExponentialHistogramDataPoint_Min{} - }, - } - - ProtoPoolExponentialHistogramDataPoint_Max = sync.Pool{ - New: func() any { - return &ExponentialHistogramDataPoint_Max{} - }, - } ) func NewExponentialHistogramDataPoint() *ExponentialHistogramDataPoint { @@ -132,39 +62,16 @@ func DeleteExponentialHistogramDataPoint(orig *ExponentialHistogramDataPoint, nu orig.Reset() return } - for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } - switch ov := orig.Sum_.(type) { - case *ExponentialHistogramDataPoint_Sum: - if UseProtoPooling.IsEnabled() { - ov.Sum = float64(0) - ProtoPoolExponentialHistogramDataPoint_Sum.Put(ov) - } - } DeleteExponentialHistogramDataPointBuckets(&orig.Positive, false) DeleteExponentialHistogramDataPointBuckets(&orig.Negative, false) + for i := range orig.Exemplars { DeleteExemplar(&orig.Exemplars[i], false) } - switch ov := orig.Min_.(type) { - case *ExponentialHistogramDataPoint_Min: - if UseProtoPooling.IsEnabled() { - ov.Min = float64(0) - ProtoPoolExponentialHistogramDataPoint_Min.Put(ov) - } - - } - switch ov := orig.Max_.(type) { - case *ExponentialHistogramDataPoint_Max: - if UseProtoPooling.IsEnabled() { - ov.Max = float64(0) - ProtoPoolExponentialHistogramDataPoint_Max.Put(ov) - } - - } orig.Reset() if nullable { @@ -188,63 +95,33 @@ func CopyExponentialHistogramDataPoint(dest, src *ExponentialHistogramDataPoint) dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.StartTimeUnixNano = src.StartTimeUnixNano - dest.TimeUnixNano = src.TimeUnixNano - dest.Count = src.Count - - switch t := src.Sum_.(type) { - case *ExponentialHistogramDataPoint_Sum: - var ov *ExponentialHistogramDataPoint_Sum - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Sum{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*ExponentialHistogramDataPoint_Sum) - } - ov.Sum = t.Sum - dest.Sum_ = ov - default: - dest.Sum_ = nil + if src.HasSum() { + dest.SetSum(src.Sum) + } else { + dest.RemoveSum() } dest.Scale = src.Scale - dest.ZeroCount = src.ZeroCount - CopyExponentialHistogramDataPointBuckets(&dest.Positive, &src.Positive) CopyExponentialHistogramDataPointBuckets(&dest.Negative, &src.Negative) dest.Flags = src.Flags - dest.Exemplars = CopyExemplarSlice(dest.Exemplars, src.Exemplars) - switch t := src.Min_.(type) { - case *ExponentialHistogramDataPoint_Min: - var ov *ExponentialHistogramDataPoint_Min - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Min{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*ExponentialHistogramDataPoint_Min) - } - ov.Min = t.Min - dest.Min_ = ov - default: - dest.Min_ = nil - } - - switch t := src.Max_.(type) { - case *ExponentialHistogramDataPoint_Max: - var ov *ExponentialHistogramDataPoint_Max - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Max{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*ExponentialHistogramDataPoint_Max) - } - ov.Max = t.Max - dest.Max_ = ov - default: - dest.Max_ = nil + if src.HasMin() { + dest.SetMin(src.Min) + } else { + dest.RemoveMin() + } + + if src.HasMax() { + dest.SetMax(src.Max) + } else { + dest.RemoveMax() } dest.ZeroThreshold = src.ZeroThreshold @@ -329,7 +206,7 @@ func (orig *ExponentialHistogramDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectField("count") dest.WriteUint64(orig.Count) } - if orig, ok := orig.Sum_.(*ExponentialHistogramDataPoint_Sum); ok { + if orig.HasSum() { dest.WriteObjectField("sum") dest.WriteFloat64(orig.Sum) } @@ -359,11 +236,11 @@ func (orig *ExponentialHistogramDataPoint) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } - if orig, ok := orig.Min_.(*ExponentialHistogramDataPoint_Min); ok { + if orig.HasMin() { dest.WriteObjectField("min") dest.WriteFloat64(orig.Min) } - if orig, ok := orig.Max_.(*ExponentialHistogramDataPoint_Max); ok { + if orig.HasMax() { dest.WriteObjectField("max") dest.WriteFloat64(orig.Max) } @@ -391,16 +268,7 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalJSON(iter *json.Iterator) { case "count": orig.Count = iter.ReadUint64() case "sum": - { - var ov *ExponentialHistogramDataPoint_Sum - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Sum{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*ExponentialHistogramDataPoint_Sum) - } - ov.Sum = iter.ReadFloat64() - orig.Sum_ = ov - } + orig.SetSum(iter.ReadFloat64()) case "scale": orig.Scale = iter.ReadInt32() @@ -421,28 +289,10 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalJSON(iter *json.Iterator) { } case "min": - { - var ov *ExponentialHistogramDataPoint_Min - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Min{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*ExponentialHistogramDataPoint_Min) - } - ov.Min = iter.ReadFloat64() - orig.Min_ = ov - } + orig.SetMin(iter.ReadFloat64()) case "max": - { - var ov *ExponentialHistogramDataPoint_Max - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Max{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*ExponentialHistogramDataPoint_Max) - } - ov.Max = iter.ReadFloat64() - orig.Max_ = ov - } + orig.SetMax(iter.ReadFloat64()) case "zeroThreshold", "zero_threshold": orig.ZeroThreshold = iter.ReadFloat64() @@ -460,45 +310,42 @@ func (orig *ExponentialHistogramDataPoint) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { n += 9 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } - if orig.Count != 0 { + if orig.Count != uint64(0) { n += 9 } - if orig, ok := orig.Sum_.(*ExponentialHistogramDataPoint_Sum); ok { - _ = orig + if orig.HasSum() { n += 9 } - if orig.Scale != 0 { + if orig.Scale != int32(0) { n += 1 + proto.Soz(uint64(orig.Scale)) } - if orig.ZeroCount != 0 { + if orig.ZeroCount != uint64(0) { n += 9 } l = orig.Positive.SizeProto() n += 1 + proto.Sov(uint64(l)) + l l = orig.Negative.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 1 + proto.Sov(uint64(orig.Flags)) } for i := range orig.Exemplars { l = orig.Exemplars[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig, ok := orig.Min_.(*ExponentialHistogramDataPoint_Min); ok { - _ = orig + if orig.HasMin() { n += 9 } - if orig, ok := orig.Max_.(*ExponentialHistogramDataPoint_Max); ok { - _ = orig + if orig.HasMax() { n += 9 } - if orig.ZeroThreshold != 0 { + if orig.ZeroThreshold != float64(0) { n += 9 } return n @@ -515,36 +362,36 @@ func (orig *ExponentialHistogramDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.StartTimeUnixNano)) pos-- buf[pos] = 0x11 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- buf[pos] = 0x19 } - if orig.Count != 0 { + if orig.Count != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.Count)) pos-- buf[pos] = 0x21 } - if orig, ok := orig.Sum_.(*ExponentialHistogramDataPoint_Sum); ok { + if orig.HasSum() { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Sum)) pos-- buf[pos] = 0x29 } - if orig.Scale != 0 { + if orig.Scale != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64((uint32(orig.Scale)<<1)^uint32(orig.Scale>>31))) pos-- buf[pos] = 0x30 } - if orig.ZeroCount != 0 { + if orig.ZeroCount != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.ZeroCount)) pos-- @@ -562,7 +409,7 @@ func (orig *ExponentialHistogramDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x4a - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Flags)) pos-- buf[pos] = 0x50 @@ -574,19 +421,19 @@ func (orig *ExponentialHistogramDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x5a } - if orig, ok := orig.Min_.(*ExponentialHistogramDataPoint_Min); ok { + if orig.HasMin() { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Min)) pos-- buf[pos] = 0x61 } - if orig, ok := orig.Max_.(*ExponentialHistogramDataPoint_Max); ok { + if orig.HasMax() { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Max)) pos-- buf[pos] = 0x69 } - if orig.ZeroThreshold != 0 { + if orig.ZeroThreshold != float64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.ZeroThreshold)) pos-- @@ -671,14 +518,7 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - var ov *ExponentialHistogramDataPoint_Sum - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Sum{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*ExponentialHistogramDataPoint_Sum) - } - ov.Sum = math.Float64frombits(num) - orig.Sum_ = ov + orig.SetSum(math.Float64frombits(num)) case 6: if wireType != proto.WireTypeVarint { @@ -689,7 +529,6 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Scale = int32(uint32(num>>1) ^ uint32(int32((num&1)<<31)>>31)) case 7: @@ -745,7 +584,6 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Flags = uint32(num) case 11: @@ -773,14 +611,7 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - var ov *ExponentialHistogramDataPoint_Min - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Min{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*ExponentialHistogramDataPoint_Min) - } - ov.Min = math.Float64frombits(num) - orig.Min_ = ov + orig.SetMin(math.Float64frombits(num)) case 13: if wireType != proto.WireTypeI64 { @@ -791,14 +622,7 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - var ov *ExponentialHistogramDataPoint_Max - if !UseProtoPooling.IsEnabled() { - ov = &ExponentialHistogramDataPoint_Max{} - } else { - ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*ExponentialHistogramDataPoint_Max) - } - ov.Max = math.Float64frombits(num) - orig.Max_ = ov + orig.SetMax(math.Float64frombits(num)) case 14: if wireType != proto.WireTypeI64 { @@ -809,7 +633,6 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.ZeroThreshold = math.Float64frombits(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) @@ -821,21 +644,72 @@ func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { return nil } +const fieldBlockExponentialHistogramDataPointSum = uint64(0 >> 6) +const fieldBitExponentialHistogramDataPointSum = uint64(1 << 0 & 0x3F) + +func (m *ExponentialHistogramDataPoint) SetSum(value float64) { + m.Sum = value + m.metadata[fieldBlockExponentialHistogramDataPointSum] |= fieldBitExponentialHistogramDataPointSum +} + +func (m *ExponentialHistogramDataPoint) RemoveSum() { + m.Sum = float64(0) + m.metadata[fieldBlockExponentialHistogramDataPointSum] &^= fieldBitExponentialHistogramDataPointSum +} + +func (m *ExponentialHistogramDataPoint) HasSum() bool { + return m.metadata[fieldBlockExponentialHistogramDataPointSum]&fieldBitExponentialHistogramDataPointSum != 0 +} + +const fieldBlockExponentialHistogramDataPointMin = uint64(1 >> 6) +const fieldBitExponentialHistogramDataPointMin = uint64(1 << 1 & 0x3F) + +func (m *ExponentialHistogramDataPoint) SetMin(value float64) { + m.Min = value + m.metadata[fieldBlockExponentialHistogramDataPointMin] |= fieldBitExponentialHistogramDataPointMin +} + +func (m *ExponentialHistogramDataPoint) RemoveMin() { + m.Min = float64(0) + m.metadata[fieldBlockExponentialHistogramDataPointMin] &^= fieldBitExponentialHistogramDataPointMin +} + +func (m *ExponentialHistogramDataPoint) HasMin() bool { + return m.metadata[fieldBlockExponentialHistogramDataPointMin]&fieldBitExponentialHistogramDataPointMin != 0 +} + +const fieldBlockExponentialHistogramDataPointMax = uint64(2 >> 6) +const fieldBitExponentialHistogramDataPointMax = uint64(1 << 2 & 0x3F) + +func (m *ExponentialHistogramDataPoint) SetMax(value float64) { + m.Max = value + m.metadata[fieldBlockExponentialHistogramDataPointMax] |= fieldBitExponentialHistogramDataPointMax +} + +func (m *ExponentialHistogramDataPoint) RemoveMax() { + m.Max = float64(0) + m.metadata[fieldBlockExponentialHistogramDataPointMax] &^= fieldBitExponentialHistogramDataPointMax +} + +func (m *ExponentialHistogramDataPoint) HasMax() bool { + return m.metadata[fieldBlockExponentialHistogramDataPointMax]&fieldBitExponentialHistogramDataPointMax != 0 +} + func GenTestExponentialHistogramDataPoint() *ExponentialHistogramDataPoint { orig := NewExponentialHistogramDataPoint() orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} orig.StartTimeUnixNano = uint64(13) orig.TimeUnixNano = uint64(13) orig.Count = uint64(13) - orig.Sum_ = &ExponentialHistogramDataPoint_Sum{Sum: float64(3.1415926)} + orig.SetSum(float64(3.1415926)) orig.Scale = int32(13) orig.ZeroCount = uint64(13) orig.Positive = *GenTestExponentialHistogramDataPointBuckets() orig.Negative = *GenTestExponentialHistogramDataPointBuckets() orig.Flags = uint32(13) orig.Exemplars = []Exemplar{{}, *GenTestExemplar()} - orig.Min_ = &ExponentialHistogramDataPoint_Min{Min: float64(3.1415926)} - orig.Max_ = &ExponentialHistogramDataPoint_Max{Max: float64(3.1415926)} + orig.SetMin(float64(3.1415926)) + orig.SetMax(float64(3.1415926)) orig.ZeroThreshold = float64(3.1415926) return orig } diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go index 459dfe0c38b..15243f12dd4 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go @@ -16,8 +16,8 @@ import ( // ExponentialHistogramDataPointBuckets are a set of bucket counts, encoded in a contiguous array of counts. type ExponentialHistogramDataPointBuckets struct { - Offset int32 BucketCounts []uint64 + Offset int32 } var ( @@ -65,7 +65,6 @@ func CopyExponentialHistogramDataPointBuckets(dest, src *ExponentialHistogramDat dest = NewExponentialHistogramDataPointBuckets() } dest.Offset = src.Offset - dest.BucketCounts = append(dest.BucketCounts[:0], src.BucketCounts...) return dest @@ -140,6 +139,7 @@ func (orig *ExponentialHistogramDataPointBuckets) MarshalJSON(dest *json.Stream) } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -164,9 +164,10 @@ func (orig *ExponentialHistogramDataPointBuckets) SizeProto() int { var n int var l int _ = l - if orig.Offset != 0 { + if orig.Offset != int32(0) { n += 1 + proto.Soz(uint64(orig.Offset)) } + if len(orig.BucketCounts) > 0 { l = 0 for _, e := range orig.BucketCounts { @@ -181,7 +182,7 @@ func (orig *ExponentialHistogramDataPointBuckets) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.Offset != 0 { + if orig.Offset != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64((uint32(orig.Offset)<<1)^uint32(orig.Offset>>31))) pos-- buf[pos] = 0x8 @@ -223,7 +224,6 @@ func (orig *ExponentialHistogramDataPointBuckets) UnmarshalProto(buf []byte) err if err != nil { return err } - orig.Offset = int32(uint32(num>>1) ^ uint32(int32((num&1)<<31)>>31)) case 2: switch wireType { diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go index f93525d3455..bccd38e7d26 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogspartialsuccess.go @@ -16,8 +16,8 @@ import ( // ExportPartialSuccess represents the details of a partially successful export request. type ExportLogsPartialSuccess struct { - RejectedLogRecords int64 ErrorMessage string + RejectedLogRecords int64 } var ( @@ -65,7 +65,6 @@ func CopyExportLogsPartialSuccess(dest, src *ExportLogsPartialSuccess) *ExportLo dest = NewExportLogsPartialSuccess() } dest.RejectedLogRecords = src.RejectedLogRecords - dest.ErrorMessage = src.ErrorMessage return dest @@ -155,9 +154,10 @@ func (orig *ExportLogsPartialSuccess) SizeProto() int { var n int var l int _ = l - if orig.RejectedLogRecords != 0 { + if orig.RejectedLogRecords != int64(0) { n += 1 + proto.Sov(uint64(orig.RejectedLogRecords)) } + l = len(orig.ErrorMessage) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -169,7 +169,7 @@ func (orig *ExportLogsPartialSuccess) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.RejectedLogRecords != 0 { + if orig.RejectedLogRecords != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedLogRecords)) pos-- buf[pos] = 0x8 @@ -209,7 +209,6 @@ func (orig *ExportLogsPartialSuccess) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.RejectedLogRecords = int64(num) case 2: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go index 1c849ec22db..7fb48b36a21 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsservicerequest.go @@ -44,11 +44,9 @@ func DeleteExportLogsServiceRequest(orig *ExportLogsServiceRequest, nullable boo orig.Reset() return } - for i := range orig.ResourceLogs { DeleteResourceLogs(orig.ResourceLogs[i], true) } - orig.Reset() if nullable { protoPoolExportLogsServiceRequest.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go index 7b78c73604d..5570fe93d33 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportlogsserviceresponse.go @@ -43,9 +43,7 @@ func DeleteExportLogsServiceResponse(orig *ExportLogsServiceResponse, nullable b orig.Reset() return } - DeleteExportLogsPartialSuccess(&orig.PartialSuccess, false) - orig.Reset() if nullable { protoPoolExportLogsServiceResponse.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go index ff18f954c52..4915d3cb741 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricspartialsuccess.go @@ -16,8 +16,8 @@ import ( // ExportPartialSuccess represents the details of a partially successful export request. type ExportMetricsPartialSuccess struct { - RejectedDataPoints int64 ErrorMessage string + RejectedDataPoints int64 } var ( @@ -65,7 +65,6 @@ func CopyExportMetricsPartialSuccess(dest, src *ExportMetricsPartialSuccess) *Ex dest = NewExportMetricsPartialSuccess() } dest.RejectedDataPoints = src.RejectedDataPoints - dest.ErrorMessage = src.ErrorMessage return dest @@ -155,9 +154,10 @@ func (orig *ExportMetricsPartialSuccess) SizeProto() int { var n int var l int _ = l - if orig.RejectedDataPoints != 0 { + if orig.RejectedDataPoints != int64(0) { n += 1 + proto.Sov(uint64(orig.RejectedDataPoints)) } + l = len(orig.ErrorMessage) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -169,7 +169,7 @@ func (orig *ExportMetricsPartialSuccess) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.RejectedDataPoints != 0 { + if orig.RejectedDataPoints != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedDataPoints)) pos-- buf[pos] = 0x8 @@ -209,7 +209,6 @@ func (orig *ExportMetricsPartialSuccess) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.RejectedDataPoints = int64(num) case 2: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go index f4a4a0fa7b2..76cc8020ca9 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsservicerequest.go @@ -44,11 +44,9 @@ func DeleteExportMetricsServiceRequest(orig *ExportMetricsServiceRequest, nullab orig.Reset() return } - for i := range orig.ResourceMetrics { DeleteResourceMetrics(orig.ResourceMetrics[i], true) } - orig.Reset() if nullable { protoPoolExportMetricsServiceRequest.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go index 19e69384ed6..ae78a10f9b8 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportmetricsserviceresponse.go @@ -43,9 +43,7 @@ func DeleteExportMetricsServiceResponse(orig *ExportMetricsServiceResponse, null orig.Reset() return } - DeleteExportMetricsPartialSuccess(&orig.PartialSuccess, false) - orig.Reset() if nullable { protoPoolExportMetricsServiceResponse.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go index 03a20a62483..5a75e7a657e 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilespartialsuccess.go @@ -16,8 +16,8 @@ import ( // ExportPartialSuccess represents the details of a partially successful export request. type ExportProfilesPartialSuccess struct { - RejectedProfiles int64 ErrorMessage string + RejectedProfiles int64 } var ( @@ -65,7 +65,6 @@ func CopyExportProfilesPartialSuccess(dest, src *ExportProfilesPartialSuccess) * dest = NewExportProfilesPartialSuccess() } dest.RejectedProfiles = src.RejectedProfiles - dest.ErrorMessage = src.ErrorMessage return dest @@ -155,9 +154,10 @@ func (orig *ExportProfilesPartialSuccess) SizeProto() int { var n int var l int _ = l - if orig.RejectedProfiles != 0 { + if orig.RejectedProfiles != int64(0) { n += 1 + proto.Sov(uint64(orig.RejectedProfiles)) } + l = len(orig.ErrorMessage) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -169,7 +169,7 @@ func (orig *ExportProfilesPartialSuccess) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.RejectedProfiles != 0 { + if orig.RejectedProfiles != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedProfiles)) pos-- buf[pos] = 0x8 @@ -209,7 +209,6 @@ func (orig *ExportProfilesPartialSuccess) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.RejectedProfiles = int64(num) case 2: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go index 5906ce52093..ba9ecbc4eed 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesservicerequest.go @@ -45,12 +45,10 @@ func DeleteExportProfilesServiceRequest(orig *ExportProfilesServiceRequest, null orig.Reset() return } - for i := range orig.ResourceProfiles { DeleteResourceProfiles(orig.ResourceProfiles[i], true) } DeleteProfilesDictionary(&orig.Dictionary, false) - orig.Reset() if nullable { protoPoolExportProfilesServiceRequest.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go index 0153c060994..e8fea55ea3a 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exportprofilesserviceresponse.go @@ -43,9 +43,7 @@ func DeleteExportProfilesServiceResponse(orig *ExportProfilesServiceResponse, nu orig.Reset() return } - DeleteExportProfilesPartialSuccess(&orig.PartialSuccess, false) - orig.Reset() if nullable { protoPoolExportProfilesServiceResponse.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go index df8025572b4..6df4657fa29 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttracepartialsuccess.go @@ -16,8 +16,8 @@ import ( // ExportPartialSuccess represents the details of a partially successful export request. type ExportTracePartialSuccess struct { - RejectedSpans int64 ErrorMessage string + RejectedSpans int64 } var ( @@ -65,7 +65,6 @@ func CopyExportTracePartialSuccess(dest, src *ExportTracePartialSuccess) *Export dest = NewExportTracePartialSuccess() } dest.RejectedSpans = src.RejectedSpans - dest.ErrorMessage = src.ErrorMessage return dest @@ -155,9 +154,10 @@ func (orig *ExportTracePartialSuccess) SizeProto() int { var n int var l int _ = l - if orig.RejectedSpans != 0 { + if orig.RejectedSpans != int64(0) { n += 1 + proto.Sov(uint64(orig.RejectedSpans)) } + l = len(orig.ErrorMessage) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -169,7 +169,7 @@ func (orig *ExportTracePartialSuccess) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.RejectedSpans != 0 { + if orig.RejectedSpans != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedSpans)) pos-- buf[pos] = 0x8 @@ -209,7 +209,6 @@ func (orig *ExportTracePartialSuccess) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.RejectedSpans = int64(num) case 2: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go index e64316f8f3c..2a4ff9ef34f 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceservicerequest.go @@ -44,11 +44,9 @@ func DeleteExportTraceServiceRequest(orig *ExportTraceServiceRequest, nullable b orig.Reset() return } - for i := range orig.ResourceSpans { DeleteResourceSpans(orig.ResourceSpans[i], true) } - orig.Reset() if nullable { protoPoolExportTraceServiceRequest.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go index 86be1a0fdaf..f3d35d4b9be 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_exporttraceserviceresponse.go @@ -43,9 +43,7 @@ func DeleteExportTraceServiceResponse(orig *ExportTraceServiceResponse, nullable orig.Reset() return } - DeleteExportTracePartialSuccess(&orig.PartialSuccess, false) - orig.Reset() if nullable { protoPoolExportTraceServiceResponse.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go index 4e822539092..06bc218b170 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_function.go @@ -67,11 +67,8 @@ func CopyFunction(dest, src *Function) *Function { dest = NewFunction() } dest.NameStrindex = src.NameStrindex - dest.SystemNameStrindex = src.SystemNameStrindex - dest.FilenameStrindex = src.FilenameStrindex - dest.StartLine = src.StartLine return dest @@ -173,16 +170,16 @@ func (orig *Function) SizeProto() int { var n int var l int _ = l - if orig.NameStrindex != 0 { + if orig.NameStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.NameStrindex)) } - if orig.SystemNameStrindex != 0 { + if orig.SystemNameStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.SystemNameStrindex)) } - if orig.FilenameStrindex != 0 { + if orig.FilenameStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.FilenameStrindex)) } - if orig.StartLine != 0 { + if orig.StartLine != int64(0) { n += 1 + proto.Sov(uint64(orig.StartLine)) } return n @@ -192,22 +189,22 @@ func (orig *Function) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.NameStrindex != 0 { + if orig.NameStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.NameStrindex)) pos-- buf[pos] = 0x8 } - if orig.SystemNameStrindex != 0 { + if orig.SystemNameStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.SystemNameStrindex)) pos-- buf[pos] = 0x10 } - if orig.FilenameStrindex != 0 { + if orig.FilenameStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.FilenameStrindex)) pos-- buf[pos] = 0x18 } - if orig.StartLine != 0 { + if orig.StartLine != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.StartLine)) pos-- buf[pos] = 0x20 @@ -239,7 +236,6 @@ func (orig *Function) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.NameStrindex = int32(num) case 2: @@ -251,7 +247,6 @@ func (orig *Function) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.SystemNameStrindex = int32(num) case 3: @@ -263,7 +258,6 @@ func (orig *Function) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.FilenameStrindex = int32(num) case 4: @@ -275,7 +269,6 @@ func (orig *Function) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.StartLine = int64(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go index e39eb2e7958..996d6624253 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_gauge.go @@ -43,11 +43,9 @@ func DeleteGauge(orig *Gauge, nullable bool) { orig.Reset() return } - for i := range orig.DataPoints { DeleteNumberDataPoint(orig.DataPoints[i], true) } - orig.Reset() if nullable { protoPoolGauge.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go index b35b328f913..09fab65bb80 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogram.go @@ -44,7 +44,6 @@ func DeleteHistogram(orig *Histogram, nullable bool) { orig.Reset() return } - for i := range orig.DataPoints { DeleteHistogramDataPoint(orig.DataPoints[i], true) } @@ -174,7 +173,7 @@ func (orig *Histogram) SizeProto() int { l = orig.DataPoints[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.AggregationTemporality != 0 { + if orig.AggregationTemporality != AggregationTemporality(0) { n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) } return n @@ -191,7 +190,7 @@ func (orig *Histogram) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.AggregationTemporality != 0 { + if orig.AggregationTemporality != AggregationTemporality(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) pos-- buf[pos] = 0x10 @@ -239,7 +238,6 @@ func (orig *Histogram) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.AggregationTemporality = AggregationTemporality(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go index 42953b3f91d..b43e3cbb8fb 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_histogramdatapoint.go @@ -16,73 +16,20 @@ import ( "go.opentelemetry.io/collector/pdata/internal/proto" ) -func (m *HistogramDataPoint) GetSum_() any { - if m != nil { - return m.Sum_ - } - return nil -} - -type HistogramDataPoint_Sum struct { - Sum float64 -} - -func (m *HistogramDataPoint) GetSum() float64 { - if v, ok := m.GetSum_().(*HistogramDataPoint_Sum); ok { - return v.Sum - } - return float64(0) -} - -func (m *HistogramDataPoint) GetMin_() any { - if m != nil { - return m.Min_ - } - return nil -} - -type HistogramDataPoint_Min struct { - Min float64 -} - -func (m *HistogramDataPoint) GetMin() float64 { - if v, ok := m.GetMin_().(*HistogramDataPoint_Min); ok { - return v.Min - } - return float64(0) -} - -func (m *HistogramDataPoint) GetMax_() any { - if m != nil { - return m.Max_ - } - return nil -} - -type HistogramDataPoint_Max struct { - Max float64 -} - -func (m *HistogramDataPoint) GetMax() float64 { - if v, ok := m.GetMax_().(*HistogramDataPoint_Max); ok { - return v.Max - } - return float64(0) -} - // HistogramDataPoint is a single data point in a timeseries that describes the time-varying values of a Histogram of values. type HistogramDataPoint struct { Attributes []KeyValue - StartTimeUnixNano uint64 - TimeUnixNano uint64 - Count uint64 - Sum_ any BucketCounts []uint64 ExplicitBounds []float64 Exemplars []Exemplar + StartTimeUnixNano uint64 + TimeUnixNano uint64 + Count uint64 + Sum float64 + Min float64 + Max float64 + metadata [1]uint64 Flags uint32 - Min_ any - Max_ any } var ( @@ -91,23 +38,6 @@ var ( return &HistogramDataPoint{} }, } - ProtoPoolHistogramDataPoint_Sum = sync.Pool{ - New: func() any { - return &HistogramDataPoint_Sum{} - }, - } - - ProtoPoolHistogramDataPoint_Min = sync.Pool{ - New: func() any { - return &HistogramDataPoint_Min{} - }, - } - - ProtoPoolHistogramDataPoint_Max = sync.Pool{ - New: func() any { - return &HistogramDataPoint_Max{} - }, - } ) func NewHistogramDataPoint() *HistogramDataPoint { @@ -126,37 +56,13 @@ func DeleteHistogramDataPoint(orig *HistogramDataPoint, nullable bool) { orig.Reset() return } - for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } - switch ov := orig.Sum_.(type) { - case *HistogramDataPoint_Sum: - if UseProtoPooling.IsEnabled() { - ov.Sum = float64(0) - ProtoPoolHistogramDataPoint_Sum.Put(ov) - } - } for i := range orig.Exemplars { DeleteExemplar(&orig.Exemplars[i], false) } - switch ov := orig.Min_.(type) { - case *HistogramDataPoint_Min: - if UseProtoPooling.IsEnabled() { - ov.Min = float64(0) - ProtoPoolHistogramDataPoint_Min.Put(ov) - } - - } - switch ov := orig.Max_.(type) { - case *HistogramDataPoint_Max: - if UseProtoPooling.IsEnabled() { - ov.Max = float64(0) - ProtoPoolHistogramDataPoint_Max.Put(ov) - } - - } orig.Reset() if nullable { @@ -180,57 +86,31 @@ func CopyHistogramDataPoint(dest, src *HistogramDataPoint) *HistogramDataPoint { dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.StartTimeUnixNano = src.StartTimeUnixNano - dest.TimeUnixNano = src.TimeUnixNano - dest.Count = src.Count - - switch t := src.Sum_.(type) { - case *HistogramDataPoint_Sum: - var ov *HistogramDataPoint_Sum - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Sum{} - } else { - ov = ProtoPoolHistogramDataPoint_Sum.Get().(*HistogramDataPoint_Sum) - } - ov.Sum = t.Sum - dest.Sum_ = ov - default: - dest.Sum_ = nil + if src.HasSum() { + dest.SetSum(src.Sum) + } else { + dest.RemoveSum() } dest.BucketCounts = append(dest.BucketCounts[:0], src.BucketCounts...) + dest.ExplicitBounds = append(dest.ExplicitBounds[:0], src.ExplicitBounds...) + dest.Exemplars = CopyExemplarSlice(dest.Exemplars, src.Exemplars) dest.Flags = src.Flags + if src.HasMin() { + dest.SetMin(src.Min) + } else { + dest.RemoveMin() + } - switch t := src.Min_.(type) { - case *HistogramDataPoint_Min: - var ov *HistogramDataPoint_Min - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Min{} - } else { - ov = ProtoPoolHistogramDataPoint_Min.Get().(*HistogramDataPoint_Min) - } - ov.Min = t.Min - dest.Min_ = ov - default: - dest.Min_ = nil - } - - switch t := src.Max_.(type) { - case *HistogramDataPoint_Max: - var ov *HistogramDataPoint_Max - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Max{} - } else { - ov = ProtoPoolHistogramDataPoint_Max.Get().(*HistogramDataPoint_Max) - } - ov.Max = t.Max - dest.Max_ = ov - default: - dest.Max_ = nil + if src.HasMax() { + dest.SetMax(src.Max) + } else { + dest.RemoveMax() } return dest @@ -313,7 +193,7 @@ func (orig *HistogramDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectField("count") dest.WriteUint64(orig.Count) } - if orig, ok := orig.Sum_.(*HistogramDataPoint_Sum); ok { + if orig.HasSum() { dest.WriteObjectField("sum") dest.WriteFloat64(orig.Sum) } @@ -327,6 +207,7 @@ func (orig *HistogramDataPoint) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + if len(orig.ExplicitBounds) > 0 { dest.WriteObjectField("explicitBounds") dest.WriteArrayStart() @@ -337,6 +218,7 @@ func (orig *HistogramDataPoint) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + if len(orig.Exemplars) > 0 { dest.WriteObjectField("exemplars") dest.WriteArrayStart() @@ -351,11 +233,11 @@ func (orig *HistogramDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectField("flags") dest.WriteUint32(orig.Flags) } - if orig, ok := orig.Min_.(*HistogramDataPoint_Min); ok { + if orig.HasMin() { dest.WriteObjectField("min") dest.WriteFloat64(orig.Min) } - if orig, ok := orig.Max_.(*HistogramDataPoint_Max); ok { + if orig.HasMax() { dest.WriteObjectField("max") dest.WriteFloat64(orig.Max) } @@ -379,16 +261,7 @@ func (orig *HistogramDataPoint) UnmarshalJSON(iter *json.Iterator) { case "count": orig.Count = iter.ReadUint64() case "sum": - { - var ov *HistogramDataPoint_Sum - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Sum{} - } else { - ov = ProtoPoolHistogramDataPoint_Sum.Get().(*HistogramDataPoint_Sum) - } - ov.Sum = iter.ReadFloat64() - orig.Sum_ = ov - } + orig.SetSum(iter.ReadFloat64()) case "bucketCounts", "bucket_counts": for iter.ReadArray() { @@ -409,28 +282,10 @@ func (orig *HistogramDataPoint) UnmarshalJSON(iter *json.Iterator) { case "flags": orig.Flags = iter.ReadUint32() case "min": - { - var ov *HistogramDataPoint_Min - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Min{} - } else { - ov = ProtoPoolHistogramDataPoint_Min.Get().(*HistogramDataPoint_Min) - } - ov.Min = iter.ReadFloat64() - orig.Min_ = ov - } + orig.SetMin(iter.ReadFloat64()) case "max": - { - var ov *HistogramDataPoint_Max - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Max{} - } else { - ov = ProtoPoolHistogramDataPoint_Max.Get().(*HistogramDataPoint_Max) - } - ov.Max = iter.ReadFloat64() - orig.Max_ = ov - } + orig.SetMax(iter.ReadFloat64()) default: iter.Skip() @@ -446,17 +301,16 @@ func (orig *HistogramDataPoint) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { n += 9 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } - if orig.Count != 0 { + if orig.Count != uint64(0) { n += 9 } - if orig, ok := orig.Sum_.(*HistogramDataPoint_Sum); ok { - _ = orig + if orig.HasSum() { n += 9 } l = len(orig.BucketCounts) @@ -473,15 +327,13 @@ func (orig *HistogramDataPoint) SizeProto() int { l = orig.Exemplars[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 1 + proto.Sov(uint64(orig.Flags)) } - if orig, ok := orig.Min_.(*HistogramDataPoint_Min); ok { - _ = orig + if orig.HasMin() { n += 9 } - if orig, ok := orig.Max_.(*HistogramDataPoint_Max); ok { - _ = orig + if orig.HasMax() { n += 9 } return n @@ -498,25 +350,25 @@ func (orig *HistogramDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x4a } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.StartTimeUnixNano)) pos-- buf[pos] = 0x11 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- buf[pos] = 0x19 } - if orig.Count != 0 { + if orig.Count != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.Count)) pos-- buf[pos] = 0x21 } - if orig, ok := orig.Sum_.(*HistogramDataPoint_Sum); ok { + if orig.HasSum() { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Sum)) pos-- @@ -549,18 +401,18 @@ func (orig *HistogramDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x42 } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Flags)) pos-- buf[pos] = 0x50 } - if orig, ok := orig.Min_.(*HistogramDataPoint_Min); ok { + if orig.HasMin() { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Min)) pos-- buf[pos] = 0x59 } - if orig, ok := orig.Max_.(*HistogramDataPoint_Max); ok { + if orig.HasMax() { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Max)) pos-- @@ -645,14 +497,7 @@ func (orig *HistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - var ov *HistogramDataPoint_Sum - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Sum{} - } else { - ov = ProtoPoolHistogramDataPoint_Sum.Get().(*HistogramDataPoint_Sum) - } - ov.Sum = math.Float64frombits(num) - orig.Sum_ = ov + orig.SetSum(math.Float64frombits(num)) case 6: switch wireType { case proto.WireTypeLen: @@ -743,7 +588,6 @@ func (orig *HistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Flags = uint32(num) case 11: @@ -755,14 +599,7 @@ func (orig *HistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - var ov *HistogramDataPoint_Min - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Min{} - } else { - ov = ProtoPoolHistogramDataPoint_Min.Get().(*HistogramDataPoint_Min) - } - ov.Min = math.Float64frombits(num) - orig.Min_ = ov + orig.SetMin(math.Float64frombits(num)) case 12: if wireType != proto.WireTypeI64 { @@ -773,14 +610,7 @@ func (orig *HistogramDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - var ov *HistogramDataPoint_Max - if !UseProtoPooling.IsEnabled() { - ov = &HistogramDataPoint_Max{} - } else { - ov = ProtoPoolHistogramDataPoint_Max.Get().(*HistogramDataPoint_Max) - } - ov.Max = math.Float64frombits(num) - orig.Max_ = ov + orig.SetMax(math.Float64frombits(num)) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) if err != nil { @@ -791,19 +621,70 @@ func (orig *HistogramDataPoint) UnmarshalProto(buf []byte) error { return nil } +const fieldBlockHistogramDataPointSum = uint64(0 >> 6) +const fieldBitHistogramDataPointSum = uint64(1 << 0 & 0x3F) + +func (m *HistogramDataPoint) SetSum(value float64) { + m.Sum = value + m.metadata[fieldBlockHistogramDataPointSum] |= fieldBitHistogramDataPointSum +} + +func (m *HistogramDataPoint) RemoveSum() { + m.Sum = float64(0) + m.metadata[fieldBlockHistogramDataPointSum] &^= fieldBitHistogramDataPointSum +} + +func (m *HistogramDataPoint) HasSum() bool { + return m.metadata[fieldBlockHistogramDataPointSum]&fieldBitHistogramDataPointSum != 0 +} + +const fieldBlockHistogramDataPointMin = uint64(1 >> 6) +const fieldBitHistogramDataPointMin = uint64(1 << 1 & 0x3F) + +func (m *HistogramDataPoint) SetMin(value float64) { + m.Min = value + m.metadata[fieldBlockHistogramDataPointMin] |= fieldBitHistogramDataPointMin +} + +func (m *HistogramDataPoint) RemoveMin() { + m.Min = float64(0) + m.metadata[fieldBlockHistogramDataPointMin] &^= fieldBitHistogramDataPointMin +} + +func (m *HistogramDataPoint) HasMin() bool { + return m.metadata[fieldBlockHistogramDataPointMin]&fieldBitHistogramDataPointMin != 0 +} + +const fieldBlockHistogramDataPointMax = uint64(2 >> 6) +const fieldBitHistogramDataPointMax = uint64(1 << 2 & 0x3F) + +func (m *HistogramDataPoint) SetMax(value float64) { + m.Max = value + m.metadata[fieldBlockHistogramDataPointMax] |= fieldBitHistogramDataPointMax +} + +func (m *HistogramDataPoint) RemoveMax() { + m.Max = float64(0) + m.metadata[fieldBlockHistogramDataPointMax] &^= fieldBitHistogramDataPointMax +} + +func (m *HistogramDataPoint) HasMax() bool { + return m.metadata[fieldBlockHistogramDataPointMax]&fieldBitHistogramDataPointMax != 0 +} + func GenTestHistogramDataPoint() *HistogramDataPoint { orig := NewHistogramDataPoint() orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} orig.StartTimeUnixNano = uint64(13) orig.TimeUnixNano = uint64(13) orig.Count = uint64(13) - orig.Sum_ = &HistogramDataPoint_Sum{Sum: float64(3.1415926)} + orig.SetSum(float64(3.1415926)) orig.BucketCounts = []uint64{uint64(0), uint64(13)} orig.ExplicitBounds = []float64{float64(0), float64(3.1415926)} orig.Exemplars = []Exemplar{{}, *GenTestExemplar()} orig.Flags = uint32(13) - orig.Min_ = &HistogramDataPoint_Min{Min: float64(3.1415926)} - orig.Max_ = &HistogramDataPoint_Max{Max: float64(3.1415926)} + orig.SetMin(float64(3.1415926)) + orig.SetMax(float64(3.1415926)) return orig } diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go index 1e64085e946..ab44a2eabb9 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_instrumentationscope.go @@ -71,9 +71,7 @@ func CopyInstrumentationScope(dest, src *InstrumentationScope) *InstrumentationS dest = NewInstrumentationScope() } dest.Name = src.Name - dest.Version = src.Version - dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.DroppedAttributesCount = src.DroppedAttributesCount @@ -187,10 +185,12 @@ func (orig *InstrumentationScope) SizeProto() int { var n int var l int _ = l + l = len(orig.Name) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.Version) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -199,7 +199,7 @@ func (orig *InstrumentationScope) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } return n @@ -232,7 +232,7 @@ func (orig *InstrumentationScope) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x20 @@ -304,7 +304,6 @@ func (orig *InstrumentationScope) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go index 2cd6029a63a..d77ec13a99a 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_ipaddr.go @@ -15,8 +15,8 @@ import ( ) type IPAddr struct { - IP []byte Zone string + IP []byte } var ( @@ -64,7 +64,6 @@ func CopyIPAddr(dest, src *IPAddr) *IPAddr { dest = NewIPAddr() } dest.IP = src.IP - dest.Zone = src.Zone return dest @@ -155,10 +154,12 @@ func (orig *IPAddr) SizeProto() int { var n int var l int _ = l + l = len(orig.IP) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.Zone) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go index 3208776fb65..038cb114d87 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalue.go @@ -15,8 +15,8 @@ import ( ) type KeyValue struct { - Key string Value AnyValue + Key string } var ( @@ -45,7 +45,6 @@ func DeleteKeyValue(orig *KeyValue, nullable bool) { } DeleteAnyValue(&orig.Value, false) - orig.Reset() if nullable { protoPoolKeyValue.Put(orig) @@ -66,7 +65,6 @@ func CopyKeyValue(dest, src *KeyValue) *KeyValue { dest = NewKeyValue() } dest.Key = src.Key - CopyAnyValue(&dest.Value, &src.Value) return dest @@ -155,6 +153,7 @@ func (orig *KeyValue) SizeProto() int { var n int var l int _ = l + l = len(orig.Key) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go index 14c2e763d97..493ad947fd5 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvalueandunit.go @@ -18,8 +18,8 @@ import ( // style of encoding attributes which is more convenient // for profiles than opentelemetry.proto.common.v1.KeyValue. type KeyValueAndUnit struct { - KeyStrindex int32 Value AnyValue + KeyStrindex int32 UnitStrindex int32 } @@ -70,7 +70,6 @@ func CopyKeyValueAndUnit(dest, src *KeyValueAndUnit) *KeyValueAndUnit { dest = NewKeyValueAndUnit() } dest.KeyStrindex = src.KeyStrindex - CopyAnyValue(&dest.Value, &src.Value) dest.UnitStrindex = src.UnitStrindex @@ -167,12 +166,12 @@ func (orig *KeyValueAndUnit) SizeProto() int { var n int var l int _ = l - if orig.KeyStrindex != 0 { + if orig.KeyStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.KeyStrindex)) } l = orig.Value.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.UnitStrindex != 0 { + if orig.UnitStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.UnitStrindex)) } return n @@ -182,7 +181,7 @@ func (orig *KeyValueAndUnit) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.KeyStrindex != 0 { + if orig.KeyStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.KeyStrindex)) pos-- buf[pos] = 0x8 @@ -193,7 +192,7 @@ func (orig *KeyValueAndUnit) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x12 - if orig.UnitStrindex != 0 { + if orig.UnitStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.UnitStrindex)) pos-- buf[pos] = 0x18 @@ -225,7 +224,6 @@ func (orig *KeyValueAndUnit) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.KeyStrindex = int32(num) case 2: @@ -253,7 +251,6 @@ func (orig *KeyValueAndUnit) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.UnitStrindex = int32(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go index 1cb1fef73c8..9e01d808a20 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_keyvaluelist.go @@ -43,11 +43,9 @@ func DeleteKeyValueList(orig *KeyValueList, nullable bool) { orig.Reset() return } - for i := range orig.Values { DeleteKeyValue(&orig.Values[i], false) } - orig.Reset() if nullable { protoPoolKeyValueList.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go index f9cde7b965a..f6db6871bb3 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_line.go @@ -66,9 +66,7 @@ func CopyLine(dest, src *Line) *Line { dest = NewLine() } dest.FunctionIndex = src.FunctionIndex - dest.Line = src.Line - dest.Column = src.Column return dest @@ -164,13 +162,13 @@ func (orig *Line) SizeProto() int { var n int var l int _ = l - if orig.FunctionIndex != 0 { + if orig.FunctionIndex != int32(0) { n += 1 + proto.Sov(uint64(orig.FunctionIndex)) } - if orig.Line != 0 { + if orig.Line != int64(0) { n += 1 + proto.Sov(uint64(orig.Line)) } - if orig.Column != 0 { + if orig.Column != int64(0) { n += 1 + proto.Sov(uint64(orig.Column)) } return n @@ -180,17 +178,17 @@ func (orig *Line) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.FunctionIndex != 0 { + if orig.FunctionIndex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.FunctionIndex)) pos-- buf[pos] = 0x8 } - if orig.Line != 0 { + if orig.Line != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Line)) pos-- buf[pos] = 0x10 } - if orig.Column != 0 { + if orig.Column != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Column)) pos-- buf[pos] = 0x18 @@ -222,7 +220,6 @@ func (orig *Line) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.FunctionIndex = int32(num) case 2: @@ -234,7 +231,6 @@ func (orig *Line) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Line = int64(num) case 3: @@ -246,7 +242,6 @@ func (orig *Line) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Column = int64(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go index 26962ad2712..6df8aa77f84 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_link.go @@ -44,10 +44,8 @@ func DeleteLink(orig *Link, nullable bool) { orig.Reset() return } - DeleteTraceID(&orig.TraceId, false) DeleteSpanID(&orig.SpanId, false) - orig.Reset() if nullable { protoPoolLink.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go index bceb7556171..a9eebb1f66c 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_location.go @@ -16,10 +16,10 @@ import ( // Location describes function and line table debug information. type Location struct { - MappingIndex int32 - Address uint64 Lines []*Line AttributeIndices []int32 + Address uint64 + MappingIndex int32 } var ( @@ -71,9 +71,7 @@ func CopyLocation(dest, src *Location) *Location { dest = NewLocation() } dest.MappingIndex = src.MappingIndex - dest.Address = src.Address - dest.Lines = CopyLinePtrSlice(dest.Lines, src.Lines) dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) @@ -164,6 +162,7 @@ func (orig *Location) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -196,16 +195,17 @@ func (orig *Location) SizeProto() int { var n int var l int _ = l - if orig.MappingIndex != 0 { + if orig.MappingIndex != int32(0) { n += 1 + proto.Sov(uint64(orig.MappingIndex)) } - if orig.Address != 0 { + if orig.Address != uint64(0) { n += 1 + proto.Sov(uint64(orig.Address)) } for i := range orig.Lines { l = orig.Lines[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + if len(orig.AttributeIndices) > 0 { l = 0 for _, e := range orig.AttributeIndices { @@ -220,12 +220,12 @@ func (orig *Location) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.MappingIndex != 0 { + if orig.MappingIndex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.MappingIndex)) pos-- buf[pos] = 0x8 } - if orig.Address != 0 { + if orig.Address != uint64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Address)) pos-- buf[pos] = 0x10 @@ -274,7 +274,6 @@ func (orig *Location) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.MappingIndex = int32(num) case 2: @@ -286,7 +285,6 @@ func (orig *Location) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Address = uint64(num) case 3: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go index 8ef100c1347..6d5057b5725 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logrecord.go @@ -18,17 +18,17 @@ import ( // LogRecord are experimental implementation of OpenTelemetry Log Data Model. type LogRecord struct { + Body AnyValue + SeverityText string + EventName string + Attributes []KeyValue TimeUnixNano uint64 ObservedTimeUnixNano uint64 SeverityNumber SeverityNumber - SeverityText string - Body AnyValue - Attributes []KeyValue DroppedAttributesCount uint32 Flags uint32 TraceId TraceID SpanId SpanID - EventName string } var ( @@ -60,6 +60,7 @@ func DeleteLogRecord(orig *LogRecord, nullable bool) { for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } + DeleteTraceID(&orig.TraceId, false) DeleteSpanID(&orig.SpanId, false) @@ -83,21 +84,15 @@ func CopyLogRecord(dest, src *LogRecord) *LogRecord { dest = NewLogRecord() } dest.TimeUnixNano = src.TimeUnixNano - dest.ObservedTimeUnixNano = src.ObservedTimeUnixNano - dest.SeverityNumber = src.SeverityNumber - dest.SeverityText = src.SeverityText - CopyAnyValue(&dest.Body, &src.Body) dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.Flags = src.Flags - CopyTraceID(&dest.TraceId, &src.TraceId) CopySpanID(&dest.SpanId, &src.SpanId) @@ -257,15 +252,16 @@ func (orig *LogRecord) SizeProto() int { var n int var l int _ = l - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } - if orig.ObservedTimeUnixNano != 0 { + if orig.ObservedTimeUnixNano != uint64(0) { n += 9 } - if orig.SeverityNumber != 0 { + if orig.SeverityNumber != SeverityNumber(0) { n += 1 + proto.Sov(uint64(orig.SeverityNumber)) } + l = len(orig.SeverityText) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -276,16 +272,17 @@ func (orig *LogRecord) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 5 } l = orig.TraceId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l l = orig.SpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l + l = len(orig.EventName) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -297,19 +294,19 @@ func (orig *LogRecord) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- buf[pos] = 0x9 } - if orig.ObservedTimeUnixNano != 0 { + if orig.ObservedTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.ObservedTimeUnixNano)) pos-- buf[pos] = 0x59 } - if orig.SeverityNumber != 0 { + if orig.SeverityNumber != SeverityNumber(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.SeverityNumber)) pos-- buf[pos] = 0x10 @@ -335,12 +332,12 @@ func (orig *LogRecord) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x32 } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x38 } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.Flags)) pos-- @@ -417,7 +414,6 @@ func (orig *LogRecord) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.SeverityNumber = SeverityNumber(num) case 3: @@ -473,7 +469,6 @@ func (orig *LogRecord) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) case 8: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go index 8b7cf668f93..747684f1c6b 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsdata.go @@ -45,11 +45,9 @@ func DeleteLogsData(orig *LogsData, nullable bool) { orig.Reset() return } - for i := range orig.ResourceLogs { DeleteResourceLogs(orig.ResourceLogs[i], true) } - orig.Reset() if nullable { protoPoolLogsData.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go index 60bae8a7894..94b915df049 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_logsrequest.go @@ -45,7 +45,6 @@ func DeleteLogsRequest(orig *LogsRequest, nullable bool) { orig.Reset() return } - DeleteRequestContext(orig.RequestContext, true) DeleteLogsData(&orig.LogsData, false) @@ -173,7 +172,7 @@ func (orig *LogsRequest) SizeProto() int { } l = orig.LogsData.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { n += 5 } return n @@ -196,7 +195,7 @@ func (orig *LogsRequest) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) pos-- diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go index 41b74624725..8a91a076290 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_mapping.go @@ -16,11 +16,11 @@ import ( // Mapping describes the mapping of a binary in memory, including its address range, file offset, and metadata like build ID type Mapping struct { + AttributeIndices []int32 MemoryStart uint64 MemoryLimit uint64 FileOffset uint64 FilenameStrindex int32 - AttributeIndices []int32 } var ( @@ -68,13 +68,9 @@ func CopyMapping(dest, src *Mapping) *Mapping { dest = NewMapping() } dest.MemoryStart = src.MemoryStart - dest.MemoryLimit = src.MemoryLimit - dest.FileOffset = src.FileOffset - dest.FilenameStrindex = src.FilenameStrindex - dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) return dest @@ -161,6 +157,7 @@ func (orig *Mapping) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -191,18 +188,19 @@ func (orig *Mapping) SizeProto() int { var n int var l int _ = l - if orig.MemoryStart != 0 { + if orig.MemoryStart != uint64(0) { n += 1 + proto.Sov(uint64(orig.MemoryStart)) } - if orig.MemoryLimit != 0 { + if orig.MemoryLimit != uint64(0) { n += 1 + proto.Sov(uint64(orig.MemoryLimit)) } - if orig.FileOffset != 0 { + if orig.FileOffset != uint64(0) { n += 1 + proto.Sov(uint64(orig.FileOffset)) } - if orig.FilenameStrindex != 0 { + if orig.FilenameStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.FilenameStrindex)) } + if len(orig.AttributeIndices) > 0 { l = 0 for _, e := range orig.AttributeIndices { @@ -217,22 +215,22 @@ func (orig *Mapping) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.MemoryStart != 0 { + if orig.MemoryStart != uint64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.MemoryStart)) pos-- buf[pos] = 0x8 } - if orig.MemoryLimit != 0 { + if orig.MemoryLimit != uint64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.MemoryLimit)) pos-- buf[pos] = 0x10 } - if orig.FileOffset != 0 { + if orig.FileOffset != uint64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.FileOffset)) pos-- buf[pos] = 0x18 } - if orig.FilenameStrindex != 0 { + if orig.FilenameStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.FilenameStrindex)) pos-- buf[pos] = 0x20 @@ -274,7 +272,6 @@ func (orig *Mapping) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.MemoryStart = uint64(num) case 2: @@ -286,7 +283,6 @@ func (orig *Mapping) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.MemoryLimit = uint64(num) case 3: @@ -298,7 +294,6 @@ func (orig *Mapping) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.FileOffset = uint64(num) case 4: @@ -310,7 +305,6 @@ func (orig *Mapping) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.FilenameStrindex = int32(num) case 5: switch wireType { diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go index b7f85b27a03..6e5fa339f8a 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metric.go @@ -162,12 +162,10 @@ func DeleteMetric(orig *Metric, nullable bool) { DeleteSummary(ov.Summary, true) ov.Summary = nil ProtoPoolMetric_Summary.Put(ov) - } for i := range orig.Metadata { DeleteKeyValue(&orig.Metadata[i], false) } - orig.Reset() if nullable { protoPoolMetric.Put(orig) @@ -188,11 +186,8 @@ func CopyMetric(dest, src *Metric) *Metric { dest = NewMetric() } dest.Name = src.Name - dest.Description = src.Description - dest.Unit = src.Unit - switch t := src.Data.(type) { case *Metric_Gauge: var ov *Metric_Gauge @@ -387,7 +382,6 @@ func (orig *Metric) UnmarshalJSON(iter *json.Iterator) { ov.Gauge.UnmarshalJSON(iter) orig.Data = ov } - case "sum": { var ov *Metric_Sum @@ -400,7 +394,6 @@ func (orig *Metric) UnmarshalJSON(iter *json.Iterator) { ov.Sum.UnmarshalJSON(iter) orig.Data = ov } - case "histogram": { var ov *Metric_Histogram @@ -413,7 +406,6 @@ func (orig *Metric) UnmarshalJSON(iter *json.Iterator) { ov.Histogram.UnmarshalJSON(iter) orig.Data = ov } - case "exponentialHistogram", "exponential_histogram": { var ov *Metric_ExponentialHistogram @@ -426,7 +418,6 @@ func (orig *Metric) UnmarshalJSON(iter *json.Iterator) { ov.ExponentialHistogram.UnmarshalJSON(iter) orig.Data = ov } - case "summary": { var ov *Metric_Summary @@ -456,14 +447,17 @@ func (orig *Metric) SizeProto() int { var n int var l int _ = l + l = len(orig.Name) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.Description) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.Unit) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go index ad560d67b4b..aa7900f672a 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsdata.go @@ -45,11 +45,9 @@ func DeleteMetricsData(orig *MetricsData, nullable bool) { orig.Reset() return } - for i := range orig.ResourceMetrics { DeleteResourceMetrics(orig.ResourceMetrics[i], true) } - orig.Reset() if nullable { protoPoolMetricsData.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go index e4cb0b38f17..c2cca74a1bc 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_metricsrequest.go @@ -45,7 +45,6 @@ func DeleteMetricsRequest(orig *MetricsRequest, nullable bool) { orig.Reset() return } - DeleteRequestContext(orig.RequestContext, true) DeleteMetricsData(&orig.MetricsData, false) @@ -173,7 +172,7 @@ func (orig *MetricsRequest) SizeProto() int { } l = orig.MetricsData.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { n += 5 } return n @@ -196,7 +195,7 @@ func (orig *MetricsRequest) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) pos-- diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go index 4b86a7f3a1b..e413d64078e 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_numberdatapoint.go @@ -47,11 +47,11 @@ func (m *NumberDataPoint) GetAsInt() int64 { // NumberDataPoint is a single data point in a timeseries that describes the time-varying value of a number metric. type NumberDataPoint struct { + Value any Attributes []KeyValue + Exemplars []Exemplar StartTimeUnixNano uint64 TimeUnixNano uint64 - Value any - Exemplars []Exemplar Flags uint32 } @@ -91,10 +91,10 @@ func DeleteNumberDataPoint(orig *NumberDataPoint, nullable bool) { orig.Reset() return } - for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } + switch ov := orig.Value.(type) { case *NumberDataPoint_AsDouble: if UseProtoPooling.IsEnabled() { @@ -106,7 +106,6 @@ func DeleteNumberDataPoint(orig *NumberDataPoint, nullable bool) { ov.AsInt = int64(0) ProtoPoolNumberDataPoint_AsInt.Put(ov) } - } for i := range orig.Exemplars { DeleteExemplar(&orig.Exemplars[i], false) @@ -134,9 +133,7 @@ func CopyNumberDataPoint(dest, src *NumberDataPoint) *NumberDataPoint { dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.StartTimeUnixNano = src.StartTimeUnixNano - dest.TimeUnixNano = src.TimeUnixNano - switch t := src.Value.(type) { case *NumberDataPoint_AsDouble: var ov *NumberDataPoint_AsDouble @@ -147,6 +144,7 @@ func CopyNumberDataPoint(dest, src *NumberDataPoint) *NumberDataPoint { } ov.AsDouble = t.AsDouble dest.Value = ov + case *NumberDataPoint_AsInt: var ov *NumberDataPoint_AsInt if !UseProtoPooling.IsEnabled() { @@ -156,6 +154,7 @@ func CopyNumberDataPoint(dest, src *NumberDataPoint) *NumberDataPoint { } ov.AsInt = t.AsInt dest.Value = ov + default: dest.Value = nil } @@ -290,7 +289,6 @@ func (orig *NumberDataPoint) UnmarshalJSON(iter *json.Iterator) { ov.AsDouble = iter.ReadFloat64() orig.Value = ov } - case "asInt", "as_int": { var ov *NumberDataPoint_AsInt @@ -325,10 +323,10 @@ func (orig *NumberDataPoint) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { n += 9 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } switch orig := orig.Value.(type) { @@ -336,15 +334,17 @@ func (orig *NumberDataPoint) SizeProto() int { _ = orig break case *NumberDataPoint_AsDouble: + n += 9 case *NumberDataPoint_AsInt: + n += 9 } for i := range orig.Exemplars { l = orig.Exemplars[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 1 + proto.Sov(uint64(orig.Flags)) } return n @@ -361,13 +361,13 @@ func (orig *NumberDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x3a } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.StartTimeUnixNano)) pos-- buf[pos] = 0x11 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- @@ -394,7 +394,7 @@ func (orig *NumberDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x2a } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Flags)) pos-- buf[pos] = 0x40 @@ -518,7 +518,6 @@ func (orig *NumberDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Flags = uint32(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go index c3a6460d20a..02167667df3 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profile.go @@ -18,17 +18,17 @@ import ( // Profile are an implementation of the pprofextended data model. type Profile struct { - SampleType ValueType + OriginalPayloadFormat string Samples []*Sample + OriginalPayload []byte + AttributeIndices []int32 TimeUnixNano uint64 DurationNano uint64 - PeriodType ValueType Period int64 - ProfileId ProfileID + SampleType ValueType + PeriodType ValueType DroppedAttributesCount uint32 - OriginalPayloadFormat string - OriginalPayload []byte - AttributeIndices []int32 + ProfileId ProfileID } var ( @@ -55,12 +55,13 @@ func DeleteProfile(orig *Profile, nullable bool) { orig.Reset() return } - DeleteValueType(&orig.SampleType, false) for i := range orig.Samples { DeleteSample(orig.Samples[i], true) } + DeleteValueType(&orig.PeriodType, false) + DeleteProfileID(&orig.ProfileId, false) orig.Reset() @@ -87,21 +88,15 @@ func CopyProfile(dest, src *Profile) *Profile { dest.Samples = CopySamplePtrSlice(dest.Samples, src.Samples) dest.TimeUnixNano = src.TimeUnixNano - dest.DurationNano = src.DurationNano - CopyValueType(&dest.PeriodType, &src.PeriodType) dest.Period = src.Period - CopyProfileID(&dest.ProfileId, &src.ProfileId) dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.OriginalPayloadFormat = src.OriginalPayloadFormat - dest.OriginalPayload = src.OriginalPayload - dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) return dest @@ -215,6 +210,7 @@ func (orig *Profile) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -270,30 +266,33 @@ func (orig *Profile) SizeProto() int { l = orig.Samples[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } - if orig.DurationNano != 0 { + if orig.DurationNano != uint64(0) { n += 1 + proto.Sov(uint64(orig.DurationNano)) } l = orig.PeriodType.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.Period != 0 { + if orig.Period != int64(0) { n += 1 + proto.Sov(uint64(orig.Period)) } l = orig.ProfileId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } + l = len(orig.OriginalPayloadFormat) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.OriginalPayload) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + if len(orig.AttributeIndices) > 0 { l = 0 for _, e := range orig.AttributeIndices { @@ -321,13 +320,13 @@ func (orig *Profile) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x12 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- buf[pos] = 0x19 } - if orig.DurationNano != 0 { + if orig.DurationNano != uint64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DurationNano)) pos-- buf[pos] = 0x20 @@ -338,7 +337,7 @@ func (orig *Profile) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x2a - if orig.Period != 0 { + if orig.Period != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Period)) pos-- buf[pos] = 0x30 @@ -349,7 +348,7 @@ func (orig *Profile) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x3a - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x40 @@ -451,7 +450,6 @@ func (orig *Profile) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DurationNano = uint64(num) case 5: @@ -479,7 +477,6 @@ func (orig *Profile) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Period = int64(num) case 7: @@ -507,7 +504,6 @@ func (orig *Profile) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) case 9: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go index f3d1c1a16d9..45a876f6deb 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdata.go @@ -46,12 +46,10 @@ func DeleteProfilesData(orig *ProfilesData, nullable bool) { orig.Reset() return } - for i := range orig.ResourceProfiles { DeleteResourceProfiles(orig.ResourceProfiles[i], true) } DeleteProfilesDictionary(&orig.Dictionary, false) - orig.Reset() if nullable { protoPoolProfilesData.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go index af6168e1174..8b8bef11c57 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesdictionary.go @@ -49,7 +49,6 @@ func DeleteProfilesDictionary(orig *ProfilesDictionary, nullable bool) { orig.Reset() return } - for i := range orig.MappingTable { DeleteMapping(orig.MappingTable[i], true) } @@ -62,13 +61,13 @@ func DeleteProfilesDictionary(orig *ProfilesDictionary, nullable bool) { for i := range orig.LinkTable { DeleteLink(orig.LinkTable[i], true) } + for i := range orig.AttributeTable { DeleteKeyValueAndUnit(orig.AttributeTable[i], true) } for i := range orig.StackTable { DeleteStack(orig.StackTable[i], true) } - orig.Reset() if nullable { protoPoolProfilesDictionary.Put(orig) @@ -97,6 +96,7 @@ func CopyProfilesDictionary(dest, src *ProfilesDictionary) *ProfilesDictionary { dest.LinkTable = CopyLinkPtrSlice(dest.LinkTable, src.LinkTable) dest.StringTable = append(dest.StringTable[:0], src.StringTable...) + dest.AttributeTable = CopyKeyValueAndUnitPtrSlice(dest.AttributeTable, src.AttributeTable) dest.StackTable = CopyStackPtrSlice(dest.StackTable, src.StackTable) @@ -209,6 +209,7 @@ func (orig *ProfilesDictionary) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + if len(orig.AttributeTable) > 0 { dest.WriteObjectField("attributeTable") dest.WriteArrayStart() diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go index 287b9ee4d5b..b8956807f7d 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_profilesrequest.go @@ -45,7 +45,6 @@ func DeleteProfilesRequest(orig *ProfilesRequest, nullable bool) { orig.Reset() return } - DeleteRequestContext(orig.RequestContext, true) DeleteProfilesData(&orig.ProfilesData, false) @@ -173,7 +172,7 @@ func (orig *ProfilesRequest) SizeProto() int { } l = orig.ProfilesData.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { n += 5 } return n @@ -196,7 +195,7 @@ func (orig *ProfilesRequest) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) pos-- diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go index 4921ea97f09..eab9a270bd1 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_requestcontext.go @@ -66,9 +66,9 @@ func (m *RequestContext) GetUnix() *UnixAddr { } type RequestContext struct { + ClientAddress any SpanContext *SpanContext ClientMetadata []KeyValue - ClientAddress any } var ( @@ -119,7 +119,6 @@ func DeleteRequestContext(orig *RequestContext, nullable bool) { orig.Reset() return } - DeleteSpanContext(orig.SpanContext, true) for i := range orig.ClientMetadata { DeleteKeyValue(&orig.ClientMetadata[i], false) @@ -141,9 +140,7 @@ func DeleteRequestContext(orig *RequestContext, nullable bool) { DeleteUnixAddr(ov.Unix, true) ov.Unix = nil ProtoPoolRequestContext_Unix.Put(ov) - } - orig.Reset() if nullable { protoPoolRequestContext.Put(orig) @@ -338,7 +335,6 @@ func (orig *RequestContext) UnmarshalJSON(iter *json.Iterator) { ov.IP.UnmarshalJSON(iter) orig.ClientAddress = ov } - case "tCP": { var ov *RequestContext_TCP @@ -351,7 +347,6 @@ func (orig *RequestContext) UnmarshalJSON(iter *json.Iterator) { ov.TCP.UnmarshalJSON(iter) orig.ClientAddress = ov } - case "uDP": { var ov *RequestContext_UDP @@ -364,7 +359,6 @@ func (orig *RequestContext) UnmarshalJSON(iter *json.Iterator) { ov.UDP.UnmarshalJSON(iter) orig.ClientAddress = ov } - case "unix": { var ov *RequestContext_Unix @@ -618,6 +612,7 @@ func (orig *RequestContext) UnmarshalProto(buf []byte) error { return err } orig.ClientAddress = ov + default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) if err != nil { diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go index 7bef0ffcb96..0b846c62b56 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resource.go @@ -17,8 +17,8 @@ import ( // Resource is a message representing the resource information. type Resource struct { Attributes []KeyValue - DroppedAttributesCount uint32 EntityRefs []*EntityRef + DroppedAttributesCount uint32 } var ( @@ -45,14 +45,13 @@ func DeleteResource(orig *Resource, nullable bool) { orig.Reset() return } - for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } + for i := range orig.EntityRefs { DeleteEntityRef(orig.EntityRefs[i], true) } - orig.Reset() if nullable { protoPoolResource.Put(orig) @@ -75,7 +74,6 @@ func CopyResource(dest, src *Resource) *Resource { dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.EntityRefs = CopyEntityRefPtrSlice(dest.EntityRefs, src.EntityRefs) return dest @@ -195,7 +193,7 @@ func (orig *Resource) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } for i := range orig.EntityRefs { @@ -216,7 +214,7 @@ func (orig *Resource) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x10 @@ -271,7 +269,6 @@ func (orig *Resource) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) case 3: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go index 57c32e3c17b..f7f64566672 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcelogs.go @@ -46,15 +46,14 @@ func DeleteResourceLogs(orig *ResourceLogs, nullable bool) { orig.Reset() return } - DeleteResource(&orig.Resource, false) for i := range orig.ScopeLogs { DeleteScopeLogs(orig.ScopeLogs[i], true) } + for i := range orig.DeprecatedScopeLogs { DeleteScopeLogs(orig.DeprecatedScopeLogs[i], true) } - orig.Reset() if nullable { protoPoolResourceLogs.Put(orig) @@ -79,7 +78,6 @@ func CopyResourceLogs(dest, src *ResourceLogs) *ResourceLogs { dest.ScopeLogs = CopyScopeLogsPtrSlice(dest.ScopeLogs, src.ScopeLogs) dest.SchemaUrl = src.SchemaUrl - dest.DeprecatedScopeLogs = CopyScopeLogsPtrSlice(dest.DeprecatedScopeLogs, src.DeprecatedScopeLogs) return dest @@ -206,6 +204,7 @@ func (orig *ResourceLogs) SizeProto() int { l = orig.ScopeLogs[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go index a260fe62e4d..dc61ce32cbd 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcemetrics.go @@ -46,15 +46,14 @@ func DeleteResourceMetrics(orig *ResourceMetrics, nullable bool) { orig.Reset() return } - DeleteResource(&orig.Resource, false) for i := range orig.ScopeMetrics { DeleteScopeMetrics(orig.ScopeMetrics[i], true) } + for i := range orig.DeprecatedScopeMetrics { DeleteScopeMetrics(orig.DeprecatedScopeMetrics[i], true) } - orig.Reset() if nullable { protoPoolResourceMetrics.Put(orig) @@ -79,7 +78,6 @@ func CopyResourceMetrics(dest, src *ResourceMetrics) *ResourceMetrics { dest.ScopeMetrics = CopyScopeMetricsPtrSlice(dest.ScopeMetrics, src.ScopeMetrics) dest.SchemaUrl = src.SchemaUrl - dest.DeprecatedScopeMetrics = CopyScopeMetricsPtrSlice(dest.DeprecatedScopeMetrics, src.DeprecatedScopeMetrics) return dest @@ -206,6 +204,7 @@ func (orig *ResourceMetrics) SizeProto() int { l = orig.ScopeMetrics[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go index 69522c24d84..e1b0910724b 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourceprofiles.go @@ -16,9 +16,9 @@ import ( // ResourceProfiles is a collection of profiles from a Resource. type ResourceProfiles struct { + SchemaUrl string Resource Resource ScopeProfiles []*ScopeProfiles - SchemaUrl string } var ( @@ -45,7 +45,6 @@ func DeleteResourceProfiles(orig *ResourceProfiles, nullable bool) { orig.Reset() return } - DeleteResource(&orig.Resource, false) for i := range orig.ScopeProfiles { DeleteScopeProfiles(orig.ScopeProfiles[i], true) @@ -184,6 +183,7 @@ func (orig *ResourceProfiles) SizeProto() int { l = orig.ScopeProfiles[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go index bd70dedb80e..fd29e905728 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_resourcespans.go @@ -46,15 +46,14 @@ func DeleteResourceSpans(orig *ResourceSpans, nullable bool) { orig.Reset() return } - DeleteResource(&orig.Resource, false) for i := range orig.ScopeSpans { DeleteScopeSpans(orig.ScopeSpans[i], true) } + for i := range orig.DeprecatedScopeSpans { DeleteScopeSpans(orig.DeprecatedScopeSpans[i], true) } - orig.Reset() if nullable { protoPoolResourceSpans.Put(orig) @@ -79,7 +78,6 @@ func CopyResourceSpans(dest, src *ResourceSpans) *ResourceSpans { dest.ScopeSpans = CopyScopeSpansPtrSlice(dest.ScopeSpans, src.ScopeSpans) dest.SchemaUrl = src.SchemaUrl - dest.DeprecatedScopeSpans = CopyScopeSpansPtrSlice(dest.DeprecatedScopeSpans, src.DeprecatedScopeSpans) return dest @@ -206,6 +204,7 @@ func (orig *ResourceSpans) SizeProto() int { l = orig.ScopeSpans[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go index df89e9b63e1..7a67e83f6dc 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sample.go @@ -17,11 +17,11 @@ import ( // Sample represents each record value encountered within a profiled program. type Sample struct { - StackIndex int32 Values []int64 AttributeIndices []int32 - LinkIndex int32 TimestampsUnixNano []uint64 + StackIndex int32 + LinkIndex int32 } var ( @@ -69,11 +69,11 @@ func CopySample(dest, src *Sample) *Sample { dest = NewSample() } dest.StackIndex = src.StackIndex - dest.Values = append(dest.Values[:0], src.Values...) + dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) - dest.LinkIndex = src.LinkIndex + dest.LinkIndex = src.LinkIndex dest.TimestampsUnixNano = append(dest.TimestampsUnixNano[:0], src.TimestampsUnixNano...) return dest @@ -148,6 +148,7 @@ func (orig *Sample) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + if len(orig.AttributeIndices) > 0 { dest.WriteObjectField("attributeIndices") dest.WriteArrayStart() @@ -158,6 +159,7 @@ func (orig *Sample) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + if orig.LinkIndex != int32(0) { dest.WriteObjectField("linkIndex") dest.WriteInt32(orig.LinkIndex) @@ -172,6 +174,7 @@ func (orig *Sample) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -208,9 +211,10 @@ func (orig *Sample) SizeProto() int { var n int var l int _ = l - if orig.StackIndex != 0 { + if orig.StackIndex != int32(0) { n += 1 + proto.Sov(uint64(orig.StackIndex)) } + if len(orig.Values) > 0 { l = 0 for _, e := range orig.Values { @@ -218,6 +222,7 @@ func (orig *Sample) SizeProto() int { } n += 1 + proto.Sov(uint64(l)) + l } + if len(orig.AttributeIndices) > 0 { l = 0 for _, e := range orig.AttributeIndices { @@ -225,7 +230,7 @@ func (orig *Sample) SizeProto() int { } n += 1 + proto.Sov(uint64(l)) + l } - if orig.LinkIndex != 0 { + if orig.LinkIndex != int32(0) { n += 1 + proto.Sov(uint64(orig.LinkIndex)) } l = len(orig.TimestampsUnixNano) @@ -240,7 +245,7 @@ func (orig *Sample) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.StackIndex != 0 { + if orig.StackIndex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.StackIndex)) pos-- buf[pos] = 0x8 @@ -265,7 +270,7 @@ func (orig *Sample) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a } - if orig.LinkIndex != 0 { + if orig.LinkIndex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.LinkIndex)) pos-- buf[pos] = 0x20 @@ -307,7 +312,6 @@ func (orig *Sample) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.StackIndex = int32(num) case 2: switch wireType { @@ -379,7 +383,6 @@ func (orig *Sample) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.LinkIndex = int32(num) case 5: switch wireType { diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go index 8f303264c73..606af0ffd39 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopelogs.go @@ -16,9 +16,9 @@ import ( // ScopeLogs is a collection of logs from a LibraryInstrumentation. type ScopeLogs struct { - Scope InstrumentationScope - LogRecords []*LogRecord SchemaUrl string + LogRecords []*LogRecord + Scope InstrumentationScope } var ( @@ -45,7 +45,6 @@ func DeleteScopeLogs(orig *ScopeLogs, nullable bool) { orig.Reset() return } - DeleteInstrumentationScope(&orig.Scope, false) for i := range orig.LogRecords { DeleteLogRecord(orig.LogRecords[i], true) @@ -184,6 +183,7 @@ func (orig *ScopeLogs) SizeProto() int { l = orig.LogRecords[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go index fc521a4017c..5c7a9d1d556 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopemetrics.go @@ -16,9 +16,9 @@ import ( // ScopeMetrics is a collection of metrics from a LibraryInstrumentation. type ScopeMetrics struct { - Scope InstrumentationScope - Metrics []*Metric SchemaUrl string + Metrics []*Metric + Scope InstrumentationScope } var ( @@ -45,7 +45,6 @@ func DeleteScopeMetrics(orig *ScopeMetrics, nullable bool) { orig.Reset() return } - DeleteInstrumentationScope(&orig.Scope, false) for i := range orig.Metrics { DeleteMetric(orig.Metrics[i], true) @@ -184,6 +183,7 @@ func (orig *ScopeMetrics) SizeProto() int { l = orig.Metrics[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go index c17284b1bbd..b88f3b1e1e2 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopeprofiles.go @@ -16,9 +16,9 @@ import ( // ScopeProfiles is a collection of profiles from a LibraryInstrumentation. type ScopeProfiles struct { - Scope InstrumentationScope - Profiles []*Profile SchemaUrl string + Profiles []*Profile + Scope InstrumentationScope } var ( @@ -45,7 +45,6 @@ func DeleteScopeProfiles(orig *ScopeProfiles, nullable bool) { orig.Reset() return } - DeleteInstrumentationScope(&orig.Scope, false) for i := range orig.Profiles { DeleteProfile(orig.Profiles[i], true) @@ -184,6 +183,7 @@ func (orig *ScopeProfiles) SizeProto() int { l = orig.Profiles[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go index a02a1c71557..6a1966527ab 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_scopespans.go @@ -16,9 +16,9 @@ import ( // ScopeSpans is a collection of spans from a LibraryInstrumentation. type ScopeSpans struct { - Scope InstrumentationScope - Spans []*Span SchemaUrl string + Spans []*Span + Scope InstrumentationScope } var ( @@ -45,7 +45,6 @@ func DeleteScopeSpans(orig *ScopeSpans, nullable bool) { orig.Reset() return } - DeleteInstrumentationScope(&orig.Scope, false) for i := range orig.Spans { DeleteSpan(orig.Spans[i], true) @@ -184,6 +183,7 @@ func (orig *ScopeSpans) SizeProto() int { l = orig.Spans[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.SchemaUrl) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go index 7d0ef5a6042..4df8e982e90 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_span.go @@ -18,22 +18,22 @@ import ( // Span represents a single operation within a trace. // See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto type Span struct { - TraceId TraceID - SpanId SpanID TraceState string - ParentSpanId SpanID - Flags uint32 Name string - Kind SpanKind + Attributes []KeyValue + Events []*SpanEvent + Links []*SpanLink + Status Status StartTimeUnixNano uint64 EndTimeUnixNano uint64 - Attributes []KeyValue + Flags uint32 + Kind SpanKind DroppedAttributesCount uint32 - Events []*SpanEvent DroppedEventsCount uint32 - Links []*SpanLink DroppedLinksCount uint32 - Status Status + TraceId TraceID + SpanId SpanID + ParentSpanId SpanID } var ( @@ -60,21 +60,24 @@ func DeleteSpan(orig *Span, nullable bool) { orig.Reset() return } - DeleteTraceID(&orig.TraceId, false) DeleteSpanID(&orig.SpanId, false) + DeleteSpanID(&orig.ParentSpanId, false) + for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } + for i := range orig.Events { DeleteSpanEvent(orig.Events[i], true) } + for i := range orig.Links { DeleteSpanLink(orig.Links[i], true) } - DeleteStatus(&orig.Status, false) + DeleteStatus(&orig.Status, false) orig.Reset() if nullable { protoPoolSpan.Put(orig) @@ -99,31 +102,22 @@ func CopySpan(dest, src *Span) *Span { CopySpanID(&dest.SpanId, &src.SpanId) dest.TraceState = src.TraceState - CopySpanID(&dest.ParentSpanId, &src.ParentSpanId) dest.Flags = src.Flags - dest.Name = src.Name - dest.Kind = src.Kind - dest.StartTimeUnixNano = src.StartTimeUnixNano - dest.EndTimeUnixNano = src.EndTimeUnixNano - dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.Events = CopySpanEventPtrSlice(dest.Events, src.Events) dest.DroppedEventsCount = src.DroppedEventsCount - dest.Links = CopySpanLinkPtrSlice(dest.Links, src.Links) dest.DroppedLinksCount = src.DroppedLinksCount - CopyStatus(&dest.Status, &src.Status) return dest @@ -334,47 +328,49 @@ func (orig *Span) SizeProto() int { n += 1 + proto.Sov(uint64(l)) + l l = orig.SpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l + l = len(orig.TraceState) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } l = orig.ParentSpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 6 } + l = len(orig.Name) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } - if orig.Kind != 0 { + if orig.Kind != SpanKind(0) { n += 1 + proto.Sov(uint64(orig.Kind)) } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { n += 9 } - if orig.EndTimeUnixNano != 0 { + if orig.EndTimeUnixNano != uint64(0) { n += 9 } for i := range orig.Attributes { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } for i := range orig.Events { l = orig.Events[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedEventsCount != 0 { + if orig.DroppedEventsCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedEventsCount)) } for i := range orig.Links { l = orig.Links[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedLinksCount != 0 { + if orig.DroppedLinksCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedLinksCount)) } l = orig.Status.SizeProto() @@ -412,7 +408,7 @@ func (orig *Span) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x22 - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.Flags)) pos-- @@ -428,18 +424,18 @@ func (orig *Span) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x2a } - if orig.Kind != 0 { + if orig.Kind != SpanKind(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Kind)) pos-- buf[pos] = 0x30 } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.StartTimeUnixNano)) pos-- buf[pos] = 0x39 } - if orig.EndTimeUnixNano != 0 { + if orig.EndTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.EndTimeUnixNano)) pos-- @@ -452,7 +448,7 @@ func (orig *Span) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x4a } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x50 @@ -464,7 +460,7 @@ func (orig *Span) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x5a } - if orig.DroppedEventsCount != 0 { + if orig.DroppedEventsCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedEventsCount)) pos-- buf[pos] = 0x60 @@ -476,7 +472,7 @@ func (orig *Span) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x6a } - if orig.DroppedLinksCount != 0 { + if orig.DroppedLinksCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedLinksCount)) pos-- buf[pos] = 0x70 @@ -598,7 +594,6 @@ func (orig *Span) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Kind = SpanKind(num) case 7: @@ -650,7 +645,6 @@ func (orig *Span) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) case 11: @@ -678,7 +672,6 @@ func (orig *Span) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedEventsCount = uint32(num) case 13: @@ -706,7 +699,6 @@ func (orig *Span) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedLinksCount = uint32(num) case 15: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go index 7d78787004d..2861cf11754 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spancontext.go @@ -16,10 +16,10 @@ import ( ) type SpanContext struct { + TraceState string + TraceFlags uint32 TraceID TraceID SpanID SpanID - TraceFlags uint32 - TraceState string Remote bool } @@ -47,7 +47,6 @@ func DeleteSpanContext(orig *SpanContext, nullable bool) { orig.Reset() return } - DeleteTraceID(&orig.TraceID, false) DeleteSpanID(&orig.SpanID, false) @@ -75,9 +74,7 @@ func CopySpanContext(dest, src *SpanContext) *SpanContext { CopySpanID(&dest.SpanID, &src.SpanID) dest.TraceFlags = src.TraceFlags - dest.TraceState = src.TraceState - dest.Remote = src.Remote return dest @@ -191,14 +188,15 @@ func (orig *SpanContext) SizeProto() int { n += 1 + proto.Sov(uint64(l)) + l l = orig.SpanID.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.TraceFlags != 0 { + if orig.TraceFlags != uint32(0) { n += 5 } + l = len(orig.TraceState) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } - if orig.Remote { + if orig.Remote != false { n += 2 } return n @@ -220,7 +218,7 @@ func (orig *SpanContext) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x12 - if orig.TraceFlags != 0 { + if orig.TraceFlags != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.TraceFlags)) pos-- @@ -234,7 +232,7 @@ func (orig *SpanContext) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x22 } - if orig.Remote { + if orig.Remote != false { pos-- if orig.Remote { buf[pos] = 1 @@ -327,7 +325,6 @@ func (orig *SpanContext) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Remote = num != 0 default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go index 14c0fe1627c..56d1ea50b5a 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanevent.go @@ -18,9 +18,9 @@ import ( // SpanEvent is a time-stamped annotation of the span, consisting of user-supplied // text description and key-value pairs. See OTLP for event definition. type SpanEvent struct { - TimeUnixNano uint64 Name string Attributes []KeyValue + TimeUnixNano uint64 DroppedAttributesCount uint32 } @@ -73,9 +73,7 @@ func CopySpanEvent(dest, src *SpanEvent) *SpanEvent { dest = NewSpanEvent() } dest.TimeUnixNano = src.TimeUnixNano - dest.Name = src.Name - dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.DroppedAttributesCount = src.DroppedAttributesCount @@ -189,9 +187,10 @@ func (orig *SpanEvent) SizeProto() int { var n int var l int _ = l - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } + l = len(orig.Name) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -200,7 +199,7 @@ func (orig *SpanEvent) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } return n @@ -210,7 +209,7 @@ func (orig *SpanEvent) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- @@ -231,7 +230,7 @@ func (orig *SpanEvent) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x20 @@ -303,7 +302,6 @@ func (orig *SpanEvent) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go index 07c42640bcf..a7f8a670db4 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_spanlink.go @@ -19,12 +19,12 @@ import ( // different trace. // See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto type SpanLink struct { - TraceId TraceID - SpanId SpanID TraceState string Attributes []KeyValue DroppedAttributesCount uint32 Flags uint32 + TraceId TraceID + SpanId SpanID } var ( @@ -51,9 +51,9 @@ func DeleteSpanLink(orig *SpanLink, nullable bool) { orig.Reset() return } - DeleteTraceID(&orig.TraceId, false) DeleteSpanID(&orig.SpanId, false) + for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } @@ -82,11 +82,9 @@ func CopySpanLink(dest, src *SpanLink) *SpanLink { CopySpanID(&dest.SpanId, &src.SpanId) dest.TraceState = src.TraceState - dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.Flags = src.Flags return dest @@ -216,6 +214,7 @@ func (orig *SpanLink) SizeProto() int { n += 1 + proto.Sov(uint64(l)) + l l = orig.SpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l + l = len(orig.TraceState) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -224,10 +223,10 @@ func (orig *SpanLink) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 5 } return n @@ -264,12 +263,12 @@ func (orig *SpanLink) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x22 } - if orig.DroppedAttributesCount != 0 { + if orig.DroppedAttributesCount != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) pos-- buf[pos] = 0x28 } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.Flags)) pos-- @@ -362,7 +361,6 @@ func (orig *SpanLink) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.DroppedAttributesCount = uint32(num) case 6: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go index a97599bfc65..be7a4ce48a7 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_stack.go @@ -134,6 +134,7 @@ func (orig *Stack) MarshalJSON(dest *json.Stream) { } dest.WriteArrayEnd() } + dest.WriteObjectEnd() } @@ -156,6 +157,7 @@ func (orig *Stack) SizeProto() int { var n int var l int _ = l + if len(orig.LocationIndices) > 0 { l = 0 for _, e := range orig.LocationIndices { diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go index c2f2d37754f..77b5fe39268 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_status.go @@ -66,7 +66,6 @@ func CopyStatus(dest, src *Status) *Status { dest = NewStatus() } dest.Message = src.Message - dest.Code = src.Code return dest @@ -157,11 +156,12 @@ func (orig *Status) SizeProto() int { var n int var l int _ = l + l = len(orig.Message) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } - if orig.Code != 0 { + if orig.Code != StatusCode(0) { n += 1 + proto.Sov(uint64(orig.Code)) } return n @@ -179,7 +179,7 @@ func (orig *Status) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x12 } - if orig.Code != 0 { + if orig.Code != StatusCode(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Code)) pos-- buf[pos] = 0x18 @@ -223,7 +223,6 @@ func (orig *Status) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Code = StatusCode(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go index 67be5d00f04..f419344b54d 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_sum.go @@ -45,7 +45,6 @@ func DeleteSum(orig *Sum, nullable bool) { orig.Reset() return } - for i := range orig.DataPoints { DeleteNumberDataPoint(orig.DataPoints[i], true) } @@ -72,7 +71,6 @@ func CopySum(dest, src *Sum) *Sum { dest.DataPoints = CopyNumberDataPointPtrSlice(dest.DataPoints, src.DataPoints) dest.AggregationTemporality = src.AggregationTemporality - dest.IsMonotonic = src.IsMonotonic return dest @@ -183,10 +181,10 @@ func (orig *Sum) SizeProto() int { l = orig.DataPoints[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.AggregationTemporality != 0 { + if orig.AggregationTemporality != AggregationTemporality(0) { n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) } - if orig.IsMonotonic { + if orig.IsMonotonic != false { n += 2 } return n @@ -203,12 +201,12 @@ func (orig *Sum) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.AggregationTemporality != 0 { + if orig.AggregationTemporality != AggregationTemporality(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) pos-- buf[pos] = 0x10 } - if orig.IsMonotonic { + if orig.IsMonotonic != false { pos-- if orig.IsMonotonic { buf[pos] = 1 @@ -261,7 +259,6 @@ func (orig *Sum) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.AggregationTemporality = AggregationTemporality(num) case 3: @@ -273,7 +270,6 @@ func (orig *Sum) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.IsMonotonic = num != 0 default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go index 8d40bd16603..5523e5af8b3 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summary.go @@ -43,11 +43,9 @@ func DeleteSummary(orig *Summary, nullable bool) { orig.Reset() return } - for i := range orig.DataPoints { DeleteSummaryDataPoint(orig.DataPoints[i], true) } - orig.Reset() if nullable { protoPoolSummary.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go index bf30987a669..ccd99fa1801 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapoint.go @@ -19,11 +19,11 @@ import ( // SummaryDataPoint is a single data point in a timeseries that describes the time-varying values of a Summary of double values. type SummaryDataPoint struct { Attributes []KeyValue + QuantileValues []*SummaryDataPointValueAtQuantile StartTimeUnixNano uint64 TimeUnixNano uint64 Count uint64 Sum float64 - QuantileValues []*SummaryDataPointValueAtQuantile Flags uint32 } @@ -51,10 +51,10 @@ func DeleteSummaryDataPoint(orig *SummaryDataPoint, nullable bool) { orig.Reset() return } - for i := range orig.Attributes { DeleteKeyValue(&orig.Attributes[i], false) } + for i := range orig.QuantileValues { DeleteSummaryDataPointValueAtQuantile(orig.QuantileValues[i], true) } @@ -81,13 +81,9 @@ func CopySummaryDataPoint(dest, src *SummaryDataPoint) *SummaryDataPoint { dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) dest.StartTimeUnixNano = src.StartTimeUnixNano - dest.TimeUnixNano = src.TimeUnixNano - dest.Count = src.Count - dest.Sum = src.Sum - dest.QuantileValues = CopySummaryDataPointValueAtQuantilePtrSlice(dest.QuantileValues, src.QuantileValues) dest.Flags = src.Flags @@ -233,23 +229,23 @@ func (orig *SummaryDataPoint) SizeProto() int { l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { n += 9 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { n += 9 } - if orig.Count != 0 { + if orig.Count != uint64(0) { n += 9 } - if orig.Sum != 0 { + if orig.Sum != float64(0) { n += 9 } for i := range orig.QuantileValues { l = orig.QuantileValues[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { n += 1 + proto.Sov(uint64(orig.Flags)) } return n @@ -266,25 +262,25 @@ func (orig *SummaryDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x3a } - if orig.StartTimeUnixNano != 0 { + if orig.StartTimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.StartTimeUnixNano)) pos-- buf[pos] = 0x11 } - if orig.TimeUnixNano != 0 { + if orig.TimeUnixNano != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.TimeUnixNano)) pos-- buf[pos] = 0x19 } - if orig.Count != 0 { + if orig.Count != uint64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.Count)) pos-- buf[pos] = 0x21 } - if orig.Sum != 0 { + if orig.Sum != float64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Sum)) pos-- @@ -297,7 +293,7 @@ func (orig *SummaryDataPoint) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x32 } - if orig.Flags != 0 { + if orig.Flags != uint32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Flags)) pos-- buf[pos] = 0x40 @@ -381,7 +377,6 @@ func (orig *SummaryDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Sum = math.Float64frombits(num) case 6: @@ -409,7 +404,6 @@ func (orig *SummaryDataPoint) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Flags = uint32(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go index ae92399aa41..3b10b8a9c6c 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_summarydatapointvalueatquantile.go @@ -67,7 +67,6 @@ func CopySummaryDataPointValueAtQuantile(dest, src *SummaryDataPointValueAtQuant dest = NewSummaryDataPointValueAtQuantile() } dest.Quantile = src.Quantile - dest.Value = src.Value return dest @@ -157,10 +156,10 @@ func (orig *SummaryDataPointValueAtQuantile) SizeProto() int { var n int var l int _ = l - if orig.Quantile != 0 { + if orig.Quantile != float64(0) { n += 9 } - if orig.Value != 0 { + if orig.Value != float64(0) { n += 9 } return n @@ -170,13 +169,13 @@ func (orig *SummaryDataPointValueAtQuantile) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.Quantile != 0 { + if orig.Quantile != float64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Quantile)) pos-- buf[pos] = 0x9 } - if orig.Value != 0 { + if orig.Value != float64(0) { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Value)) pos-- @@ -209,7 +208,6 @@ func (orig *SummaryDataPointValueAtQuantile) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Quantile = math.Float64frombits(num) case 2: @@ -221,7 +219,6 @@ func (orig *SummaryDataPointValueAtQuantile) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Value = math.Float64frombits(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go index d2590bdbb1f..08c350ffef6 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tcpaddr.go @@ -15,9 +15,9 @@ import ( ) type TCPAddr struct { + Zone string IP []byte Port int64 - Zone string } var ( @@ -65,9 +65,7 @@ func CopyTCPAddr(dest, src *TCPAddr) *TCPAddr { dest = NewTCPAddr() } dest.IP = src.IP - dest.Port = src.Port - dest.Zone = src.Zone return dest @@ -164,13 +162,15 @@ func (orig *TCPAddr) SizeProto() int { var n int var l int _ = l + l = len(orig.IP) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } - if orig.Port != 0 { + if orig.Port != int64(0) { n += 1 + proto.Sov(uint64(orig.Port)) } + l = len(orig.Zone) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -190,7 +190,7 @@ func (orig *TCPAddr) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.Port != 0 { + if orig.Port != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Port)) pos-- buf[pos] = 0x10 @@ -245,7 +245,6 @@ func (orig *TCPAddr) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Port = int64(num) case 3: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go index f63549f1cbc..2b54b6247a5 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesdata.go @@ -45,11 +45,9 @@ func DeleteTracesData(orig *TracesData, nullable bool) { orig.Reset() return } - for i := range orig.ResourceSpans { DeleteResourceSpans(orig.ResourceSpans[i], true) } - orig.Reset() if nullable { protoPoolTracesData.Put(orig) diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go index d3e3fd5633d..b8bb39687fd 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_tracesrequest.go @@ -45,7 +45,6 @@ func DeleteTracesRequest(orig *TracesRequest, nullable bool) { orig.Reset() return } - DeleteRequestContext(orig.RequestContext, true) DeleteTracesData(&orig.TracesData, false) @@ -173,7 +172,7 @@ func (orig *TracesRequest) SizeProto() int { } l = orig.TracesData.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { n += 5 } return n @@ -196,7 +195,7 @@ func (orig *TracesRequest) MarshalProto(buf []byte) int { pos-- buf[pos] = 0x1a - if orig.FormatVersion != 0 { + if orig.FormatVersion != uint32(0) { pos -= 4 binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) pos-- diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go index f197afd194a..dd2883de59c 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_udpaddr.go @@ -15,9 +15,9 @@ import ( ) type UDPAddr struct { + Zone string IP []byte Port int64 - Zone string } var ( @@ -65,9 +65,7 @@ func CopyUDPAddr(dest, src *UDPAddr) *UDPAddr { dest = NewUDPAddr() } dest.IP = src.IP - dest.Port = src.Port - dest.Zone = src.Zone return dest @@ -164,13 +162,15 @@ func (orig *UDPAddr) SizeProto() int { var n int var l int _ = l + l = len(orig.IP) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } - if orig.Port != 0 { + if orig.Port != int64(0) { n += 1 + proto.Sov(uint64(orig.Port)) } + l = len(orig.Zone) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l @@ -190,7 +190,7 @@ func (orig *UDPAddr) MarshalProto(buf []byte) int { pos-- buf[pos] = 0xa } - if orig.Port != 0 { + if orig.Port != int64(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.Port)) pos-- buf[pos] = 0x10 @@ -245,7 +245,6 @@ func (orig *UDPAddr) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.Port = int64(num) case 3: diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go index b7d25686c02..be00bfbd3c0 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_unixaddr.go @@ -64,7 +64,6 @@ func CopyUnixAddr(dest, src *UnixAddr) *UnixAddr { dest = NewUnixAddr() } dest.Name = src.Name - dest.Net = src.Net return dest @@ -154,10 +153,12 @@ func (orig *UnixAddr) SizeProto() int { var n int var l int _ = l + l = len(orig.Name) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } + l = len(orig.Net) if l > 0 { n += 1 + proto.Sov(uint64(l)) + l diff --git a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go index 7742846f24a..eccd89e6ef8 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go +++ b/vendor/go.opentelemetry.io/collector/pdata/internal/generated_proto_valuetype.go @@ -65,7 +65,6 @@ func CopyValueType(dest, src *ValueType) *ValueType { dest = NewValueType() } dest.TypeStrindex = src.TypeStrindex - dest.UnitStrindex = src.UnitStrindex return dest @@ -155,10 +154,10 @@ func (orig *ValueType) SizeProto() int { var n int var l int _ = l - if orig.TypeStrindex != 0 { + if orig.TypeStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.TypeStrindex)) } - if orig.UnitStrindex != 0 { + if orig.UnitStrindex != int32(0) { n += 1 + proto.Sov(uint64(orig.UnitStrindex)) } return n @@ -168,12 +167,12 @@ func (orig *ValueType) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - if orig.TypeStrindex != 0 { + if orig.TypeStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.TypeStrindex)) pos-- buf[pos] = 0x8 } - if orig.UnitStrindex != 0 { + if orig.UnitStrindex != int32(0) { pos = proto.EncodeVarint(buf, pos, uint64(orig.UnitStrindex)) pos-- buf[pos] = 0x10 @@ -205,7 +204,6 @@ func (orig *ValueType) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.TypeStrindex = int32(num) case 2: @@ -217,7 +215,6 @@ func (orig *ValueType) UnmarshalProto(buf []byte) error { if err != nil { return err } - orig.UnitStrindex = int32(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) diff --git a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exemplar.go b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exemplar.go index e0681f6d17f..12c9984abc6 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exemplar.go +++ b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exemplar.go @@ -95,9 +95,7 @@ func (ms Exemplar) SetDoubleValue(v float64) { } ov.AsDouble = v ms.orig.Value = ov -} - -// IntValue returns the int associated with this Exemplar. +} // IntValue returns the int associated with this Exemplar. func (ms Exemplar) IntValue() int64 { return ms.orig.GetAsInt() } diff --git a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exponentialhistogramdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exponentialhistogramdatapoint.go index 168fdebb97a..d21bb141025 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exponentialhistogramdatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_exponentialhistogramdatapoint.go @@ -91,25 +91,25 @@ func (ms ExponentialHistogramDataPoint) SetCount(v uint64) { // Sum returns the sum associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) Sum() float64 { - return ms.orig.GetSum() + return ms.orig.Sum } // HasSum returns true if the ExponentialHistogramDataPoint contains a // Sum value otherwise. func (ms ExponentialHistogramDataPoint) HasSum() bool { - return ms.orig.Sum_ != nil + return ms.orig.HasSum() } // SetSum replaces the sum associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) SetSum(v float64) { ms.state.AssertMutable() - ms.orig.Sum_ = &internal.ExponentialHistogramDataPoint_Sum{Sum: v} + ms.orig.SetSum(v) } // RemoveSum removes the sum associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) RemoveSum() { ms.state.AssertMutable() - ms.orig.Sum_ = nil + ms.orig.RemoveSum() } // Scale returns the scale associated with this ExponentialHistogramDataPoint. @@ -162,48 +162,48 @@ func (ms ExponentialHistogramDataPoint) Exemplars() ExemplarSlice { // Min returns the min associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) Min() float64 { - return ms.orig.GetMin() + return ms.orig.Min } // HasMin returns true if the ExponentialHistogramDataPoint contains a // Min value otherwise. func (ms ExponentialHistogramDataPoint) HasMin() bool { - return ms.orig.Min_ != nil + return ms.orig.HasMin() } // SetMin replaces the min associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) SetMin(v float64) { ms.state.AssertMutable() - ms.orig.Min_ = &internal.ExponentialHistogramDataPoint_Min{Min: v} + ms.orig.SetMin(v) } // RemoveMin removes the min associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) RemoveMin() { ms.state.AssertMutable() - ms.orig.Min_ = nil + ms.orig.RemoveMin() } // Max returns the max associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) Max() float64 { - return ms.orig.GetMax() + return ms.orig.Max } // HasMax returns true if the ExponentialHistogramDataPoint contains a // Max value otherwise. func (ms ExponentialHistogramDataPoint) HasMax() bool { - return ms.orig.Max_ != nil + return ms.orig.HasMax() } // SetMax replaces the max associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) SetMax(v float64) { ms.state.AssertMutable() - ms.orig.Max_ = &internal.ExponentialHistogramDataPoint_Max{Max: v} + ms.orig.SetMax(v) } // RemoveMax removes the max associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) RemoveMax() { ms.state.AssertMutable() - ms.orig.Max_ = nil + ms.orig.RemoveMax() } // ZeroThreshold returns the zerothreshold associated with this ExponentialHistogramDataPoint. diff --git a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_histogramdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_histogramdatapoint.go index 3ed9090a5c1..8426506ec66 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_histogramdatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_histogramdatapoint.go @@ -88,25 +88,25 @@ func (ms HistogramDataPoint) SetCount(v uint64) { // Sum returns the sum associated with this HistogramDataPoint. func (ms HistogramDataPoint) Sum() float64 { - return ms.orig.GetSum() + return ms.orig.Sum } // HasSum returns true if the HistogramDataPoint contains a // Sum value otherwise. func (ms HistogramDataPoint) HasSum() bool { - return ms.orig.Sum_ != nil + return ms.orig.HasSum() } // SetSum replaces the sum associated with this HistogramDataPoint. func (ms HistogramDataPoint) SetSum(v float64) { ms.state.AssertMutable() - ms.orig.Sum_ = &internal.HistogramDataPoint_Sum{Sum: v} + ms.orig.SetSum(v) } // RemoveSum removes the sum associated with this HistogramDataPoint. func (ms HistogramDataPoint) RemoveSum() { ms.state.AssertMutable() - ms.orig.Sum_ = nil + ms.orig.RemoveSum() } // BucketCounts returns the BucketCounts associated with this HistogramDataPoint. @@ -137,48 +137,48 @@ func (ms HistogramDataPoint) SetFlags(v DataPointFlags) { // Min returns the min associated with this HistogramDataPoint. func (ms HistogramDataPoint) Min() float64 { - return ms.orig.GetMin() + return ms.orig.Min } // HasMin returns true if the HistogramDataPoint contains a // Min value otherwise. func (ms HistogramDataPoint) HasMin() bool { - return ms.orig.Min_ != nil + return ms.orig.HasMin() } // SetMin replaces the min associated with this HistogramDataPoint. func (ms HistogramDataPoint) SetMin(v float64) { ms.state.AssertMutable() - ms.orig.Min_ = &internal.HistogramDataPoint_Min{Min: v} + ms.orig.SetMin(v) } // RemoveMin removes the min associated with this HistogramDataPoint. func (ms HistogramDataPoint) RemoveMin() { ms.state.AssertMutable() - ms.orig.Min_ = nil + ms.orig.RemoveMin() } // Max returns the max associated with this HistogramDataPoint. func (ms HistogramDataPoint) Max() float64 { - return ms.orig.GetMax() + return ms.orig.Max } // HasMax returns true if the HistogramDataPoint contains a // Max value otherwise. func (ms HistogramDataPoint) HasMax() bool { - return ms.orig.Max_ != nil + return ms.orig.HasMax() } // SetMax replaces the max associated with this HistogramDataPoint. func (ms HistogramDataPoint) SetMax(v float64) { ms.state.AssertMutable() - ms.orig.Max_ = &internal.HistogramDataPoint_Max{Max: v} + ms.orig.SetMax(v) } // RemoveMax removes the max associated with this HistogramDataPoint. func (ms HistogramDataPoint) RemoveMax() { ms.state.AssertMutable() - ms.orig.Max_ = nil + ms.orig.RemoveMax() } // CopyTo copies all properties from the current struct overriding the destination. diff --git a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_metric.go b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_metric.go index 04eebe8e09a..792d38da8fd 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_metric.go +++ b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_metric.go @@ -130,10 +130,7 @@ func (ms Metric) SetEmptyGauge() Gauge { ov.Gauge = internal.NewGauge() ms.orig.Data = ov return newGauge(ov.Gauge, ms.state) -} - -// Sum returns the sum associated with this Metric. -// +} // Sum returns the sum associated with this Metric. // Calling this function when Type() != MetricTypeSum returns an invalid // zero-initialized instance of Sum. Note that using such Sum instance can cause panic. // @@ -162,10 +159,7 @@ func (ms Metric) SetEmptySum() Sum { ov.Sum = internal.NewSum() ms.orig.Data = ov return newSum(ov.Sum, ms.state) -} - -// Histogram returns the histogram associated with this Metric. -// +} // Histogram returns the histogram associated with this Metric. // Calling this function when Type() != MetricTypeHistogram returns an invalid // zero-initialized instance of Histogram. Note that using such Histogram instance can cause panic. // @@ -194,10 +188,7 @@ func (ms Metric) SetEmptyHistogram() Histogram { ov.Histogram = internal.NewHistogram() ms.orig.Data = ov return newHistogram(ov.Histogram, ms.state) -} - -// ExponentialHistogram returns the exponentialhistogram associated with this Metric. -// +} // ExponentialHistogram returns the exponentialhistogram associated with this Metric. // Calling this function when Type() != MetricTypeExponentialHistogram returns an invalid // zero-initialized instance of ExponentialHistogram. Note that using such ExponentialHistogram instance can cause panic. // @@ -226,10 +217,7 @@ func (ms Metric) SetEmptyExponentialHistogram() ExponentialHistogram { ov.ExponentialHistogram = internal.NewExponentialHistogram() ms.orig.Data = ov return newExponentialHistogram(ov.ExponentialHistogram, ms.state) -} - -// Summary returns the summary associated with this Metric. -// +} // Summary returns the summary associated with this Metric. // Calling this function when Type() != MetricTypeSummary returns an invalid // zero-initialized instance of Summary. Note that using such Summary instance can cause panic. // diff --git a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_numberdatapoint.go b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_numberdatapoint.go index e61eba8a8c5..8dc926bbef4 100644 --- a/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_numberdatapoint.go +++ b/vendor/go.opentelemetry.io/collector/pdata/pmetric/generated_numberdatapoint.go @@ -103,9 +103,7 @@ func (ms NumberDataPoint) SetDoubleValue(v float64) { } ov.AsDouble = v ms.orig.Value = ov -} - -// IntValue returns the int associated with this NumberDataPoint. +} // IntValue returns the int associated with this NumberDataPoint. func (ms NumberDataPoint) IntValue() int64 { return ms.orig.GetAsInt() } diff --git a/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go b/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go index c4ace87b266..f506074eadf 100644 --- a/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go +++ b/vendor/google.golang.org/grpc/balancer/grpclb/grpc_lb_v1/load_balancer_grpc.pb.go @@ -19,7 +19,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.6.0 // - protoc v5.27.1 // source: grpc/lb/v1/load_balancer.proto diff --git a/vendor/google.golang.org/grpc/balancer/weightedroundrobin/balancer.go b/vendor/google.golang.org/grpc/balancer/weightedroundrobin/balancer.go index 0de02e5e508..7a89f63554e 100644 --- a/vendor/google.golang.org/grpc/balancer/weightedroundrobin/balancer.go +++ b/vendor/google.golang.org/grpc/balancer/weightedroundrobin/balancer.go @@ -62,7 +62,7 @@ var ( Description: "EXPERIMENTAL. Number of scheduler updates in which there were not enough endpoints with valid weight, which caused the WRR policy to fall back to RR behavior.", Unit: "{update}", Labels: []string{"grpc.target"}, - OptionalLabels: []string{"grpc.lb.locality"}, + OptionalLabels: []string{"grpc.lb.locality", "grpc.lb.backend_service"}, Default: false, }) @@ -71,7 +71,7 @@ var ( Description: "EXPERIMENTAL. Number of endpoints from each scheduler update that don't yet have usable weight information (i.e., either the load report has not yet been received, or it is within the blackout period).", Unit: "{endpoint}", Labels: []string{"grpc.target"}, - OptionalLabels: []string{"grpc.lb.locality"}, + OptionalLabels: []string{"grpc.lb.locality", "grpc.lb.backend_service"}, Default: false, }) @@ -80,7 +80,7 @@ var ( Description: "EXPERIMENTAL. Number of endpoints from each scheduler update whose latest weight is older than the expiration period.", Unit: "{endpoint}", Labels: []string{"grpc.target"}, - OptionalLabels: []string{"grpc.lb.locality"}, + OptionalLabels: []string{"grpc.lb.locality", "grpc.lb.backend_service"}, Default: false, }) endpointWeightsMetric = estats.RegisterFloat64Histo(estats.MetricDescriptor{ @@ -88,7 +88,7 @@ var ( Description: "EXPERIMENTAL. Weight of each endpoint, recorded on every scheduler update. Endpoints without usable weights will be recorded as weight 0.", Unit: "{endpoint}", Labels: []string{"grpc.target"}, - OptionalLabels: []string{"grpc.lb.locality"}, + OptionalLabels: []string{"grpc.lb.locality", "grpc.lb.backend_service"}, Default: false, }) ) @@ -173,6 +173,7 @@ func (b *wrrBalancer) updateEndpointsLocked(endpoints []resolver.Endpoint) { metricsRecorder: b.metricsRecorder, target: b.target, locality: b.locality, + clusterName: b.clusterName, } for _, addr := range endpoint.Addresses { b.addressWeights.Set(addr, ew) @@ -211,6 +212,7 @@ type wrrBalancer struct { mu sync.Mutex cfg *lbConfig // active config locality string + clusterName string stopPicker *grpcsync.Event addressWeights *resolver.AddressMapV2[*endpointWeight] endpointToWeight *resolver.EndpointMap[*endpointWeight] @@ -231,6 +233,7 @@ func (b *wrrBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error b.mu.Lock() b.cfg = cfg b.locality = weightedtarget.LocalityFromResolverState(ccs.ResolverState) + b.clusterName = backendServiceFromState(ccs.ResolverState) b.updateEndpointsLocked(ccs.ResolverState.Endpoints) b.mu.Unlock() @@ -288,6 +291,7 @@ func (b *wrrBalancer) UpdateState(state balancer.State) { metricsRecorder: b.metricsRecorder, locality: b.locality, target: b.target, + clusterName: b.clusterName, } b.stopPicker = grpcsync.NewEvent() @@ -420,6 +424,7 @@ type picker struct { // The following fields are immutable. target string locality string + clusterName string metricsRecorder estats.MetricsRecorder } @@ -499,6 +504,7 @@ type endpointWeight struct { target string metricsRecorder estats.MetricsRecorder locality string + clusterName string // The following fields are only accessed on calls into the LB policy, and // do not need a mutex. @@ -602,14 +608,14 @@ func (w *endpointWeight) weight(now time.Time, weightExpirationPeriod, blackoutP if recordMetrics { defer func() { - endpointWeightsMetric.Record(w.metricsRecorder, weight, w.target, w.locality) + endpointWeightsMetric.Record(w.metricsRecorder, weight, w.target, w.locality, w.clusterName) }() } // The endpoint has not received a load report (i.e. just turned READY with // no load report). if w.lastUpdated.Equal(time.Time{}) { - endpointWeightNotYetUsableMetric.Record(w.metricsRecorder, 1, w.target, w.locality) + endpointWeightNotYetUsableMetric.Record(w.metricsRecorder, 1, w.target, w.locality, w.clusterName) return 0 } @@ -618,7 +624,7 @@ func (w *endpointWeight) weight(now time.Time, weightExpirationPeriod, blackoutP // start getting data again in the future, and return 0. if now.Sub(w.lastUpdated) >= weightExpirationPeriod { if recordMetrics { - endpointWeightStaleMetric.Record(w.metricsRecorder, 1, w.target, w.locality) + endpointWeightStaleMetric.Record(w.metricsRecorder, 1, w.target, w.locality, w.clusterName) } w.nonEmptySince = time.Time{} return 0 @@ -627,10 +633,27 @@ func (w *endpointWeight) weight(now time.Time, weightExpirationPeriod, blackoutP // If we don't have at least blackoutPeriod worth of data, return 0. if blackoutPeriod != 0 && (w.nonEmptySince.Equal(time.Time{}) || now.Sub(w.nonEmptySince) < blackoutPeriod) { if recordMetrics { - endpointWeightNotYetUsableMetric.Record(w.metricsRecorder, 1, w.target, w.locality) + endpointWeightNotYetUsableMetric.Record(w.metricsRecorder, 1, w.target, w.locality, w.clusterName) } return 0 } return w.weightVal } + +type backendServiceKey struct{} + +// SetBackendService stores the backendService on the resolver state so +// that it can be used later as a label in wrr metrics. +func SetBackendService(state resolver.State, backendService string) resolver.State { + state.Attributes = state.Attributes.WithValue(backendServiceKey{}, backendService) + return state +} + +// getBackendServiceFromState retrieves the cluster name stored as an attribute +// in the resolver state. +func backendServiceFromState(state resolver.State) string { + v := state.Attributes.Value(backendServiceKey{}) + name, _ := v.(string) + return name +} diff --git a/vendor/google.golang.org/grpc/balancer/weightedroundrobin/scheduler.go b/vendor/google.golang.org/grpc/balancer/weightedroundrobin/scheduler.go index 7d3d6815eb7..8ed8d92a781 100644 --- a/vendor/google.golang.org/grpc/balancer/weightedroundrobin/scheduler.go +++ b/vendor/google.golang.org/grpc/balancer/weightedroundrobin/scheduler.go @@ -39,7 +39,7 @@ func (p *picker) newScheduler(recordMetrics bool) scheduler { } if n == 1 { if recordMetrics { - rrFallbackMetric.Record(p.metricsRecorder, 1, p.target, p.locality) + rrFallbackMetric.Record(p.metricsRecorder, 1, p.target, p.locality, p.clusterName) } return &rrScheduler{numSCs: 1, inc: p.inc} } @@ -58,7 +58,7 @@ func (p *picker) newScheduler(recordMetrics bool) scheduler { if numZero >= n-1 { if recordMetrics { - rrFallbackMetric.Record(p.metricsRecorder, 1, p.target, p.locality) + rrFallbackMetric.Record(p.metricsRecorder, 1, p.target, p.locality, p.clusterName) } return &rrScheduler{numSCs: uint32(n), inc: p.inc} } diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index c0c2c9a76ab..b767d3e33ee 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -35,6 +35,8 @@ import ( "google.golang.org/grpc/balancer/pickfirst" "google.golang.org/grpc/codes" "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/credentials" + expstats "google.golang.org/grpc/experimental/stats" "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/channelz" "google.golang.org/grpc/internal/grpcsync" @@ -98,6 +100,41 @@ var ( errTransportCredentialsMissing = errors.New("grpc: the credentials require transport level security (use grpc.WithTransportCredentials() to set)") ) +var ( + disconnectionsMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{ + Name: "grpc.subchannel.disconnections", + Description: "EXPERIMENTAL. Number of times the selected subchannel becomes disconnected.", + Unit: "{disconnection}", + Labels: []string{"grpc.target"}, + OptionalLabels: []string{"grpc.lb.backend_service", "grpc.lb.locality", "grpc.disconnect_error"}, + Default: false, + }) + connectionAttemptsSucceededMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{ + Name: "grpc.subchannel.connection_attempts_succeeded", + Description: "EXPERIMENTAL. Number of successful connection attempts.", + Unit: "{attempt}", + Labels: []string{"grpc.target"}, + OptionalLabels: []string{"grpc.lb.backend_service", "grpc.lb.locality"}, + Default: false, + }) + connectionAttemptsFailedMetric = expstats.RegisterInt64Count(expstats.MetricDescriptor{ + Name: "grpc.subchannel.connection_attempts_failed", + Description: "EXPERIMENTAL. Number of failed connection attempts.", + Unit: "{attempt}", + Labels: []string{"grpc.target"}, + OptionalLabels: []string{"grpc.lb.backend_service", "grpc.lb.locality"}, + Default: false, + }) + openConnectionsMetric = expstats.RegisterInt64UpDownCount(expstats.MetricDescriptor{ + Name: "grpc.subchannel.open_connections", + Description: "EXPERIMENTAL. Number of open connections.", + Unit: "{attempt}", + Labels: []string{"grpc.target"}, + OptionalLabels: []string{"grpc.lb.backend_service", "grpc.security_level", "grpc.lb.locality"}, + Default: false, + }) +) + const ( defaultClientMaxReceiveMessageSize = 1024 * 1024 * 4 defaultClientMaxSendMessageSize = math.MaxInt32 @@ -262,9 +299,10 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn * }() // This creates the name resolver, load balancer, etc. - if err := cc.idlenessMgr.ExitIdleMode(); err != nil { - return nil, err + if err := cc.exitIdleMode(); err != nil { + return nil, fmt.Errorf("failed to exit idle mode: %w", err) } + cc.idlenessMgr.UnsafeSetNotIdle() // Return now for non-blocking dials. if !cc.dopts.block { @@ -332,7 +370,7 @@ func (cc *ClientConn) addTraceEvent(msg string) { Severity: channelz.CtInfo, } } - channelz.AddTraceEvent(logger, cc.channelz, 0, ted) + channelz.AddTraceEvent(logger, cc.channelz, 1, ted) } type idler ClientConn @@ -341,14 +379,17 @@ func (i *idler) EnterIdleMode() { (*ClientConn)(i).enterIdleMode() } -func (i *idler) ExitIdleMode() error { - return (*ClientConn)(i).exitIdleMode() +func (i *idler) ExitIdleMode() { + // Ignore the error returned from this method, because from the perspective + // of the caller (idleness manager), the channel would have always moved out + // of IDLE by the time this method returns. + (*ClientConn)(i).exitIdleMode() } // exitIdleMode moves the channel out of idle mode by recreating the name // resolver and load balancer. This should never be called directly; use // cc.idlenessMgr.ExitIdleMode instead. -func (cc *ClientConn) exitIdleMode() (err error) { +func (cc *ClientConn) exitIdleMode() error { cc.mu.Lock() if cc.conns == nil { cc.mu.Unlock() @@ -356,11 +397,23 @@ func (cc *ClientConn) exitIdleMode() (err error) { } cc.mu.Unlock() + // Set state to CONNECTING before building the name resolver + // so the channel does not remain in IDLE. + cc.csMgr.updateState(connectivity.Connecting) + // This needs to be called without cc.mu because this builds a new resolver // which might update state or report error inline, which would then need to // acquire cc.mu. if err := cc.resolverWrapper.start(); err != nil { - return err + // If resolver creation fails, treat it like an error reported by the + // resolver before any valid updates. Set channel's state to + // TransientFailure, and set an erroring picker with the resolver build + // error, which will returned as part of any subsequent RPCs. + logger.Warningf("Failed to start resolver: %v", err) + cc.csMgr.updateState(connectivity.TransientFailure) + cc.mu.Lock() + cc.updateResolverStateAndUnlock(resolver.State{}, err) + return fmt.Errorf("failed to start resolver: %w", err) } cc.addTraceEvent("exiting idle mode") @@ -681,10 +734,8 @@ func (cc *ClientConn) GetState() connectivity.State { // Notice: This API is EXPERIMENTAL and may be changed or removed in a later // release. func (cc *ClientConn) Connect() { - if err := cc.idlenessMgr.ExitIdleMode(); err != nil { - cc.addTraceEvent(err.Error()) - return - } + cc.idlenessMgr.ExitIdleMode() + // If the ClientConn was not in idle mode, we need to call ExitIdle on the // LB policy so that connections can be created. cc.mu.Lock() @@ -735,8 +786,8 @@ func init() { internal.EnterIdleModeForTesting = func(cc *ClientConn) { cc.idlenessMgr.EnterIdleModeForTesting() } - internal.ExitIdleModeForTesting = func(cc *ClientConn) error { - return cc.idlenessMgr.ExitIdleMode() + internal.ExitIdleModeForTesting = func(cc *ClientConn) { + cc.idlenessMgr.ExitIdleMode() } } @@ -861,6 +912,7 @@ func (cc *ClientConn) newAddrConnLocked(addrs []resolver.Address, opts balancer. channelz: channelz.RegisterSubChannel(cc.channelz, ""), resetBackoff: make(chan struct{}), } + ac.updateTelemetryLabelsLocked() ac.ctx, ac.cancel = context.WithCancel(cc.ctx) // Start with our address set to the first address; this may be updated if // we connect to different addresses. @@ -977,7 +1029,7 @@ func (ac *addrConn) updateAddrs(addrs []resolver.Address) { } ac.addrs = addrs - + ac.updateTelemetryLabelsLocked() if ac.state == connectivity.Shutdown || ac.state == connectivity.TransientFailure || ac.state == connectivity.Idle { @@ -1216,6 +1268,9 @@ type addrConn struct { resetBackoff chan struct{} channelz *channelz.SubChannel + + localityLabel string + backendServiceLabel string } // Note: this requires a lock on ac.mu. @@ -1223,6 +1278,18 @@ func (ac *addrConn) updateConnectivityState(s connectivity.State, lastErr error) if ac.state == s { return } + + // If we are transitioning out of Ready, it means there is a disconnection. + // A SubConn can also transition from CONNECTING directly to IDLE when + // a transport is successfully created, but the connection fails + // before the SubConn can send the notification for READY. We treat + // this as a successful connection and transition to IDLE. + // TODO: https://github.com/grpc/grpc-go/issues/7862 - Remove the second + // part of the if condition below once the issue is fixed. + if ac.state == connectivity.Ready || (ac.state == connectivity.Connecting && s == connectivity.Idle) { + disconnectionsMetric.Record(ac.cc.metricsRecorderList, 1, ac.cc.target, ac.backendServiceLabel, ac.localityLabel, "unknown") + openConnectionsMetric.Record(ac.cc.metricsRecorderList, -1, ac.cc.target, ac.backendServiceLabel, ac.securityLevelLocked(), ac.localityLabel) + } ac.state = s ac.channelz.ChannelMetrics.State.Store(&s) if lastErr == nil { @@ -1280,6 +1347,15 @@ func (ac *addrConn) resetTransportAndUnlock() { ac.mu.Unlock() if err := ac.tryAllAddrs(acCtx, addrs, connectDeadline); err != nil { + if !errors.Is(err, context.Canceled) { + connectionAttemptsFailedMetric.Record(ac.cc.metricsRecorderList, 1, ac.cc.target, ac.backendServiceLabel, ac.localityLabel) + } else { + if logger.V(2) { + // This records cancelled connection attempts which can be later + // replaced by a metric. + logger.Infof("Context cancellation detected; not recording this as a failed connection attempt.") + } + } // TODO: #7534 - Move re-resolution requests into the pick_first LB policy // to ensure one resolution request per pass instead of per subconn failure. ac.cc.resolveNow(resolver.ResolveNowOptions{}) @@ -1319,10 +1395,50 @@ func (ac *addrConn) resetTransportAndUnlock() { } // Success; reset backoff. ac.mu.Lock() + connectionAttemptsSucceededMetric.Record(ac.cc.metricsRecorderList, 1, ac.cc.target, ac.backendServiceLabel, ac.localityLabel) + openConnectionsMetric.Record(ac.cc.metricsRecorderList, 1, ac.cc.target, ac.backendServiceLabel, ac.securityLevelLocked(), ac.localityLabel) ac.backoffIdx = 0 ac.mu.Unlock() } +// updateTelemetryLabelsLocked calculates and caches the telemetry labels based on the +// first address in addrConn. +func (ac *addrConn) updateTelemetryLabelsLocked() { + labelsFunc, ok := internal.AddressToTelemetryLabels.(func(resolver.Address) map[string]string) + if !ok || len(ac.addrs) == 0 { + // Reset defaults + ac.localityLabel = "" + ac.backendServiceLabel = "" + return + } + labels := labelsFunc(ac.addrs[0]) + ac.localityLabel = labels["grpc.lb.locality"] + ac.backendServiceLabel = labels["grpc.lb.backend_service"] +} + +type securityLevelKey struct{} + +func (ac *addrConn) securityLevelLocked() string { + var secLevel string + // During disconnection, ac.transport is nil. Fall back to the security level + // stored in the current address during connection. + if ac.transport == nil { + secLevel, _ = ac.curAddr.Attributes.Value(securityLevelKey{}).(string) + return secLevel + } + authInfo := ac.transport.Peer().AuthInfo + if ci, ok := authInfo.(interface { + GetCommonAuthInfo() credentials.CommonAuthInfo + }); ok { + secLevel = ci.GetCommonAuthInfo().SecurityLevel.String() + // Store the security level in the current address' attributes so + // that it remains available for disconnection metrics after the + // transport is closed. + ac.curAddr.Attributes = ac.curAddr.Attributes.WithValue(securityLevelKey{}, secLevel) + } + return secLevel +} + // tryAllAddrs tries to create a connection to the addresses, and stop when at // the first successful one. It returns an error if no address was successfully // connected, or updates ac appropriately with the new transport. diff --git a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go index 21cb01be66f..44b99ce7403 100644 --- a/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go +++ b/vendor/google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp/handshaker_grpc.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.6.0 // - protoc v5.27.1 // source: grpc/gcp/handshaker.proto diff --git a/vendor/google.golang.org/grpc/experimental/stats/metricregistry.go b/vendor/google.golang.org/grpc/experimental/stats/metricregistry.go index 2b57ba65a39..472813f58fa 100644 --- a/vendor/google.golang.org/grpc/experimental/stats/metricregistry.go +++ b/vendor/google.golang.org/grpc/experimental/stats/metricregistry.go @@ -76,6 +76,7 @@ const ( MetricTypeFloatHisto MetricTypeIntGauge MetricTypeIntUpDownCount + MetricTypeIntAsyncGauge ) // Int64CountHandle is a typed handle for a int count metric. This handle @@ -172,6 +173,30 @@ func (h *Int64GaugeHandle) Record(recorder MetricsRecorder, incr int64, labels . recorder.RecordInt64Gauge(h, incr, labels...) } +// AsyncMetric is a marker interface for asynchronous metric types. +type AsyncMetric interface { + isAsync() + Descriptor() *MetricDescriptor +} + +// Int64AsyncGaugeHandle is a typed handle for an int gauge metric. This handle is +// passed at the recording point in order to know which metric to record on. +type Int64AsyncGaugeHandle MetricDescriptor + +// isAsync implements the AsyncMetric interface. +func (h *Int64AsyncGaugeHandle) isAsync() {} + +// Descriptor returns the int64 gauge handle typecast to a pointer to a +// MetricDescriptor. +func (h *Int64AsyncGaugeHandle) Descriptor() *MetricDescriptor { + return (*MetricDescriptor)(h) +} + +// Record records the int64 gauge value on the metrics recorder provided. +func (h *Int64AsyncGaugeHandle) Record(recorder AsyncMetricsRecorder, value int64, labels ...string) { + recorder.RecordInt64AsyncGauge(h, value, labels...) +} + // registeredMetrics are the registered metric descriptor names. var registeredMetrics = make(map[string]bool) @@ -282,6 +307,20 @@ func RegisterInt64UpDownCount(descriptor MetricDescriptor) *Int64UpDownCountHand return (*Int64UpDownCountHandle)(descPtr) } +// RegisterInt64AsyncGauge registers the metric description onto the global registry. +// It returns a typed handle to use for recording data. +// +// NOTE: this function must only be called during initialization time (i.e. in +// an init() function), and is not thread-safe. If multiple metrics are +// registered with the same name, this function will panic. +func RegisterInt64AsyncGauge(descriptor MetricDescriptor) *Int64AsyncGaugeHandle { + registerMetric(descriptor.Name, descriptor.Default) + descriptor.Type = MetricTypeIntAsyncGauge + descPtr := &descriptor + metricsRegistry[descriptor.Name] = descPtr + return (*Int64AsyncGaugeHandle)(descPtr) +} + // snapshotMetricsRegistryForTesting snapshots the global data of the metrics // registry. Returns a cleanup function that sets the metrics registry to its // original state. diff --git a/vendor/google.golang.org/grpc/experimental/stats/metrics.go b/vendor/google.golang.org/grpc/experimental/stats/metrics.go index cb57f1a748b..d7d404cbe43 100644 --- a/vendor/google.golang.org/grpc/experimental/stats/metrics.go +++ b/vendor/google.golang.org/grpc/experimental/stats/metrics.go @@ -43,6 +43,13 @@ type MetricsRecorder interface { RecordInt64UpDownCount(handle *Int64UpDownCountHandle, incr int64, labels ...string) } +// AsyncMetricsRecorder records on asynchronous metrics derived from metric registry. +type AsyncMetricsRecorder interface { + // RecordInt64AsyncGauge records the measurement alongside labels on the int + // count associated with the provided handle asynchronously + RecordInt64AsyncGauge(handle *Int64AsyncGaugeHandle, incr int64, labels ...string) +} + // Metrics is an experimental legacy alias of the now-stable stats.MetricSet. // Metrics will be deleted in a future release. type Metrics = stats.MetricSet diff --git a/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go b/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go index f2c01f296ac..e99cd5c8385 100644 --- a/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go +++ b/vendor/google.golang.org/grpc/health/grpc_health_v1/health_grpc.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.6.0 // - protoc v5.27.1 // source: grpc/health/v1/health.proto diff --git a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go index ba25b898871..f38de74a493 100644 --- a/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go +++ b/vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go @@ -67,6 +67,10 @@ type Balancer struct { // balancerCurrent before the UpdateSubConnState is called on the // balancerCurrent. currentMu sync.Mutex + + // activeGoroutines tracks all the goroutines that this balancer has started + // and that should be waited on when the balancer closes. + activeGoroutines sync.WaitGroup } // swap swaps out the current lb with the pending lb and updates the ClientConn. @@ -76,7 +80,9 @@ func (gsb *Balancer) swap() { cur := gsb.balancerCurrent gsb.balancerCurrent = gsb.balancerPending gsb.balancerPending = nil + gsb.activeGoroutines.Add(1) go func() { + defer gsb.activeGoroutines.Done() gsb.currentMu.Lock() defer gsb.currentMu.Unlock() cur.Close() @@ -274,6 +280,7 @@ func (gsb *Balancer) Close() { currentBalancerToClose.Close() pendingBalancerToClose.Close() + gsb.activeGoroutines.Wait() } // balancerWrapper wraps a balancer.Balancer, and overrides some Balancer @@ -324,7 +331,12 @@ func (bw *balancerWrapper) UpdateState(state balancer.State) { defer bw.gsb.mu.Unlock() bw.lastState = state + // If Close() acquires the mutex before UpdateState(), the balancer + // will already have been removed from the current or pending state when + // reaching this point. if !bw.gsb.balancerCurrentOrPending(bw) { + // Returning here ensures that (*Balancer).swap() is not invoked after + // (*Balancer).Close() and therefore prevents "use after close". return } diff --git a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go index 91f760936c0..6414ee4bbe2 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go @@ -77,6 +77,11 @@ var ( // - Target resolution is disabled. // - The DNS resolver is being used. EnableDefaultPortForProxyTarget = boolFromEnv("GRPC_EXPERIMENTAL_ENABLE_DEFAULT_PORT_FOR_PROXY_TARGET", true) + + // XDSAuthorityRewrite indicates whether xDS authority rewriting is enabled. + // This feature is defined in gRFC A81 and is enabled by setting the + // environment variable GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE to "true". + XDSAuthorityRewrite = boolFromEnv("GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE", false) ) func boolFromEnv(envVar string, def bool) bool { diff --git a/vendor/google.golang.org/grpc/internal/experimental.go b/vendor/google.golang.org/grpc/internal/experimental.go index 7617be21589..c90cc51bdd2 100644 --- a/vendor/google.golang.org/grpc/internal/experimental.go +++ b/vendor/google.golang.org/grpc/internal/experimental.go @@ -25,4 +25,8 @@ var ( // BufferPool is implemented by the grpc package and returns a server // option to configure a shared buffer pool for a grpc.Server. BufferPool any // func (grpc.SharedBufferPool) grpc.ServerOption + + // AcceptCompressors is implemented by the grpc package and returns + // a call option that restricts the grpc-accept-encoding header for a call. + AcceptCompressors any // func(...string) grpc.CallOption ) diff --git a/vendor/google.golang.org/grpc/internal/idle/idle.go b/vendor/google.golang.org/grpc/internal/idle/idle.go index 2c13ee9dac7..d3cd24f80bd 100644 --- a/vendor/google.golang.org/grpc/internal/idle/idle.go +++ b/vendor/google.golang.org/grpc/internal/idle/idle.go @@ -21,7 +21,6 @@ package idle import ( - "fmt" "math" "sync" "sync/atomic" @@ -33,15 +32,15 @@ var timeAfterFunc = func(d time.Duration, f func()) *time.Timer { return time.AfterFunc(d, f) } -// Enforcer is the functionality provided by grpc.ClientConn to enter -// and exit from idle mode. -type Enforcer interface { - ExitIdleMode() error +// ClientConn is the functionality provided by grpc.ClientConn to enter and exit +// from idle mode. +type ClientConn interface { + ExitIdleMode() EnterIdleMode() } -// Manager implements idleness detection and calls the configured Enforcer to -// enter/exit idle mode when appropriate. Must be created by NewManager. +// Manager implements idleness detection and calls the ClientConn to enter/exit +// idle mode when appropriate. Must be created by NewManager. type Manager struct { // State accessed atomically. lastCallEndTime int64 // Unix timestamp in nanos; time when the most recent RPC completed. @@ -51,8 +50,8 @@ type Manager struct { // Can be accessed without atomics or mutex since these are set at creation // time and read-only after that. - enforcer Enforcer // Functionality provided by grpc.ClientConn. - timeout time.Duration + cc ClientConn // Functionality provided by grpc.ClientConn. + timeout time.Duration // idleMu is used to guarantee mutual exclusion in two scenarios: // - Opposing intentions: @@ -72,9 +71,9 @@ type Manager struct { // NewManager creates a new idleness manager implementation for the // given idle timeout. It begins in idle mode. -func NewManager(enforcer Enforcer, timeout time.Duration) *Manager { +func NewManager(cc ClientConn, timeout time.Duration) *Manager { return &Manager{ - enforcer: enforcer, + cc: cc, timeout: timeout, actuallyIdle: true, activeCallsCount: -math.MaxInt32, @@ -127,7 +126,7 @@ func (m *Manager) handleIdleTimeout() { // Now that we've checked that there has been no activity, attempt to enter // idle mode, which is very likely to succeed. - if m.tryEnterIdleMode() { + if m.tryEnterIdleMode(true) { // Successfully entered idle mode. No timer needed until we exit idle. return } @@ -142,10 +141,13 @@ func (m *Manager) handleIdleTimeout() { // that, it performs a last minute check to ensure that no new RPC has come in, // making the channel active. // +// checkActivity controls if a check for RPC activity, since the last time the +// idle_timeout fired, is made. + // Return value indicates whether or not the channel moved to idle mode. // // Holds idleMu which ensures mutual exclusion with exitIdleMode. -func (m *Manager) tryEnterIdleMode() bool { +func (m *Manager) tryEnterIdleMode(checkActivity bool) bool { // Setting the activeCallsCount to -math.MaxInt32 indicates to OnCallBegin() // that the channel is either in idle mode or is trying to get there. if !atomic.CompareAndSwapInt32(&m.activeCallsCount, 0, -math.MaxInt32) { @@ -166,7 +168,7 @@ func (m *Manager) tryEnterIdleMode() bool { atomic.AddInt32(&m.activeCallsCount, math.MaxInt32) return false } - if atomic.LoadInt32(&m.activeSinceLastTimerCheck) == 1 { + if checkActivity && atomic.LoadInt32(&m.activeSinceLastTimerCheck) == 1 { // A very short RPC could have come in (and also finished) after we // checked for calls count and activity in handleIdleTimeout(), but // before the CAS operation. So, we need to check for activity again. @@ -177,44 +179,37 @@ func (m *Manager) tryEnterIdleMode() bool { // No new RPCs have come in since we set the active calls count value to // -math.MaxInt32. And since we have the lock, it is safe to enter idle mode // unconditionally now. - m.enforcer.EnterIdleMode() + m.cc.EnterIdleMode() m.actuallyIdle = true return true } // EnterIdleModeForTesting instructs the channel to enter idle mode. func (m *Manager) EnterIdleModeForTesting() { - m.tryEnterIdleMode() + m.tryEnterIdleMode(false) } // OnCallBegin is invoked at the start of every RPC. -func (m *Manager) OnCallBegin() error { +func (m *Manager) OnCallBegin() { if m.isClosed() { - return nil + return } if atomic.AddInt32(&m.activeCallsCount, 1) > 0 { // Channel is not idle now. Set the activity bit and allow the call. atomic.StoreInt32(&m.activeSinceLastTimerCheck, 1) - return nil + return } // Channel is either in idle mode or is in the process of moving to idle // mode. Attempt to exit idle mode to allow this RPC. - if err := m.ExitIdleMode(); err != nil { - // Undo the increment to calls count, and return an error causing the - // RPC to fail. - atomic.AddInt32(&m.activeCallsCount, -1) - return err - } - + m.ExitIdleMode() atomic.StoreInt32(&m.activeSinceLastTimerCheck, 1) - return nil } -// ExitIdleMode instructs m to call the enforcer's ExitIdleMode and update m's +// ExitIdleMode instructs m to call the ClientConn's ExitIdleMode and update its // internal state. -func (m *Manager) ExitIdleMode() error { +func (m *Manager) ExitIdleMode() { // Holds idleMu which ensures mutual exclusion with tryEnterIdleMode. m.idleMu.Lock() defer m.idleMu.Unlock() @@ -231,12 +226,10 @@ func (m *Manager) ExitIdleMode() error { // m.ExitIdleMode. // // In any case, there is nothing to do here. - return nil + return } - if err := m.enforcer.ExitIdleMode(); err != nil { - return fmt.Errorf("failed to exit idle mode: %w", err) - } + m.cc.ExitIdleMode() // Undo the idle entry process. This also respects any new RPC attempts. atomic.AddInt32(&m.activeCallsCount, math.MaxInt32) @@ -244,7 +237,23 @@ func (m *Manager) ExitIdleMode() error { // Start a new timer to fire after the configured idle timeout. m.resetIdleTimerLocked(m.timeout) - return nil +} + +// UnsafeSetNotIdle instructs the Manager to update its internal state to +// reflect the reality that the channel is no longer in IDLE mode. +// +// N.B. This method is intended only for internal use by the gRPC client +// when it exits IDLE mode **manually** from `Dial`. The callsite must ensure: +// - The channel was **actually in IDLE mode** immediately prior to the call. +// - There is **no concurrent activity** that could cause the channel to exit +// IDLE mode *naturally* at the same time. +func (m *Manager) UnsafeSetNotIdle() { + m.idleMu.Lock() + defer m.idleMu.Unlock() + + atomic.AddInt32(&m.activeCallsCount, math.MaxInt32) + m.actuallyIdle = false + m.resetIdleTimerLocked(m.timeout) } // OnCallEnd is invoked at the end of every RPC. diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go index 2699223a27f..27bef83d97b 100644 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -244,6 +244,10 @@ var ( // When set, the function will be called before the stream enters // the blocking state. NewStreamWaitingForResolver = func() {} + + // AddressToTelemetryLabels is an xDS-provided function to extract telemetry + // labels from a resolver.Address. Callers must assert its type before calling. + AddressToTelemetryLabels any // func(addr resolver.Address) map[string]string ) // HealthChecker defines the signature of the client-side LB channel health diff --git a/vendor/google.golang.org/grpc/internal/proto/grpc_lookup_v1/rls_grpc.pb.go b/vendor/google.golang.org/grpc/internal/proto/grpc_lookup_v1/rls_grpc.pb.go index 16611074cac..5b34012939e 100644 --- a/vendor/google.golang.org/grpc/internal/proto/grpc_lookup_v1/rls_grpc.pb.go +++ b/vendor/google.golang.org/grpc/internal/proto/grpc_lookup_v1/rls_grpc.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.6.0 // - protoc v5.27.1 // source: grpc/lookup/v1/rls.proto diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_client.go b/vendor/google.golang.org/grpc/internal/transport/http2_client.go index 65b4ab2439e..38ca031af64 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_client.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_client.go @@ -370,7 +370,7 @@ func NewHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts }) t.logger = prefixLoggerForClientTransport(t) // Add peer information to the http2client context. - t.ctx = peer.NewContext(t.ctx, t.getPeer()) + t.ctx = peer.NewContext(t.ctx, t.Peer()) if md, ok := addr.Metadata.(*metadata.MD); ok { t.md = *md @@ -510,7 +510,7 @@ func (t *http2Client) newStream(ctx context.Context, callHdr *CallHdr) *ClientSt return s } -func (t *http2Client) getPeer() *peer.Peer { +func (t *http2Client) Peer() *peer.Peer { return &peer.Peer{ Addr: t.remoteAddr, AuthInfo: t.authInfo, // Can be nil @@ -551,6 +551,9 @@ func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) hfLen := 7 // :method, :scheme, :path, :authority, content-type, user-agent, te hfLen += len(authData) + len(callAuthData) registeredCompressors := t.registeredCompressors + if callHdr.AcceptedCompressors != nil { + registeredCompressors = *callHdr.AcceptedCompressors + } if callHdr.PreviousAttempts > 0 { hfLen++ } @@ -742,7 +745,7 @@ func (e NewStreamError) Error() string { // NewStream creates a stream and registers it into the transport as "active" // streams. All non-nil errors returned will be *NewStreamError. func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*ClientStream, error) { - ctx = peer.NewContext(ctx, t.getPeer()) + ctx = peer.NewContext(ctx, t.Peer()) // ServerName field of the resolver returned address takes precedence over // Host field of CallHdr to determine the :authority header. This is because, @@ -1485,7 +1488,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { case "grpc-status": code, err := strconv.ParseInt(hf.Value, 10, 32) if err != nil { - se := status.New(codes.Internal, fmt.Sprintf("transport: malformed grpc-status: %v", err)) + se := status.New(codes.Unknown, fmt.Sprintf("transport: malformed grpc-status: %v", err)) t.closeStream(s, se.Err(), true, http2.ErrCodeProtocol, se, nil, endStream) return } @@ -1807,8 +1810,6 @@ func (t *http2Client) socketMetrics() *channelz.EphemeralSocketMetrics { } } -func (t *http2Client) RemoteAddr() net.Addr { return t.remoteAddr } - func (t *http2Client) incrMsgSent() { if channelz.IsOn() { t.channelz.SocketMetrics.MessagesSent.Add(1) diff --git a/vendor/google.golang.org/grpc/internal/transport/http_util.go b/vendor/google.golang.org/grpc/internal/transport/http_util.go index 6209eb23cdc..5bbb641ad90 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http_util.go +++ b/vendor/google.golang.org/grpc/internal/transport/http_util.go @@ -411,12 +411,6 @@ var writeBufferPoolMap = make(map[int]*sync.Pool) var writeBufferMutex sync.Mutex func newFramer(conn io.ReadWriter, writeBufferSize, readBufferSize int, sharedWriteBuffer bool, maxHeaderListSize uint32, memPool mem.BufferPool) *framer { - if memPool == nil { - // Note that this is only supposed to be nil in tests. Otherwise, stream - // is always initialized with a BufferPool. - memPool = mem.DefaultBufferPool() - } - if writeBufferSize < 0 { writeBufferSize = 0 } diff --git a/vendor/google.golang.org/grpc/internal/transport/transport.go b/vendor/google.golang.org/grpc/internal/transport/transport.go index 5ff83a7d7d7..6daf1e002dc 100644 --- a/vendor/google.golang.org/grpc/internal/transport/transport.go +++ b/vendor/google.golang.org/grpc/internal/transport/transport.go @@ -553,6 +553,12 @@ type CallHdr struct { // outbound message. SendCompress string + // AcceptedCompressors overrides the grpc-accept-encoding header for this + // call. When nil, the transport advertises the default set of registered + // compressors. A non-nil pointer overrides that value (including the empty + // string to advertise none). + AcceptedCompressors *string + // Creds specifies credentials.PerRPCCredentials for a call. Creds credentials.PerRPCCredentials @@ -608,8 +614,9 @@ type ClientTransport interface { // with a human readable string with debug info. GetGoAwayReason() (GoAwayReason, string) - // RemoteAddr returns the remote network address. - RemoteAddr() net.Addr + // Peer returns information about the peer associated with the Transport. + // The returned information includes authentication and network address details. + Peer() *peer.Peer } // ServerTransport is the common interface for all gRPC server-side transport diff --git a/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cdsbalancer.go b/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cdsbalancer.go index 0ad77b85e9f..a94fc664fa4 100644 --- a/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cdsbalancer.go +++ b/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cdsbalancer.go @@ -448,7 +448,7 @@ func (b *cdsBalancer) annotateErrorWithNodeID(err error) error { // graph is resolved, generates child policy config and pushes it down. // // Only executed in the context of a serializer callback. -func (b *cdsBalancer) onClusterUpdate(name string, update xdsresource.ClusterUpdate) { +func (b *cdsBalancer) onClusterUpdate(name string, update *xdsresource.ClusterUpdate) { state := b.watchers[name] if state == nil { // We are currently not watching this cluster anymore. Return early. @@ -458,7 +458,7 @@ func (b *cdsBalancer) onClusterUpdate(name string, update xdsresource.ClusterUpd b.logger.Infof("Received Cluster resource: %s", pretty.ToJSON(update)) // Update the watchers map with the update for the cluster. - state.lastUpdate = &update + state.lastUpdate = update // For an aggregate cluster, always use the security configuration on the // root cluster. diff --git a/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cluster_watcher.go b/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cluster_watcher.go index dd702b125b3..355923964c3 100644 --- a/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cluster_watcher.go +++ b/vendor/google.golang.org/grpc/internal/xds/balancer/cdsbalancer/cluster_watcher.go @@ -32,8 +32,9 @@ type clusterWatcher struct { parent *cdsBalancer } -func (cw *clusterWatcher) ResourceChanged(u *xdsresource.ClusterResourceData, onDone func()) { - handleUpdate := func(context.Context) { cw.parent.onClusterUpdate(cw.name, u.Resource); onDone() } +func (cw *clusterWatcher) ResourceChanged(u *xdsresource.ClusterUpdate, onDone func()) { + handleUpdate := func(context.Context) { cw.parent.onClusterUpdate(cw.name, u); onDone() } + cw.parent.serializer.ScheduleOr(handleUpdate, onDone) } diff --git a/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/clusterimpl.go b/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/clusterimpl.go index cdc7bf2eb57..b5dc7737154 100644 --- a/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/clusterimpl.go +++ b/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/clusterimpl.go @@ -33,6 +33,7 @@ import ( "time" "google.golang.org/grpc/balancer" + "google.golang.org/grpc/balancer/weightedroundrobin" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/balancer/gracefulswitch" @@ -297,7 +298,7 @@ func (b *clusterImplBalancer) UpdateClientConnState(s balancer.ClientConnState) // Addresses and sub-balancer config are sent to sub-balancer. err = b.child.UpdateClientConnState(balancer.ClientConnState{ - ResolverState: s.ResolverState, + ResolverState: weightedroundrobin.SetBackendService(s.ResolverState, b.clusterName), BalancerConfig: parsedCfg, }) diff --git a/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/picker.go b/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/picker.go index 0c03326178c..d766a09a696 100644 --- a/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/picker.go +++ b/vendor/google.golang.org/grpc/internal/xds/balancer/clusterimpl/picker.go @@ -194,3 +194,25 @@ func (d *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) { return pr, err } + +// autoHostRewriteKey is the context key used to store the value of +// route's autoHostRewrite in the RPC context. +type autoHostRewriteKey struct{} + +// autoHostRewrite retrieves the autoHostRewrite value from the provided context. +func autoHostRewrite(ctx context.Context) bool { + v, _ := ctx.Value(autoHostRewriteKey{}).(bool) + return v +} + +// AutoHostRewriteForTesting returns the value of autoHostRewrite field; +// to be used for testing only. +func AutoHostRewriteForTesting(ctx context.Context) bool { + return autoHostRewrite(ctx) +} + +// SetAutoHostRewrite adds the autoHostRewrite value to the context for +// the xds_cluster_impl LB policy to pick. +func SetAutoHostRewrite(ctx context.Context, autohostRewrite bool) context.Context { + return context.WithValue(ctx, autoHostRewriteKey{}, autohostRewrite) +} diff --git a/vendor/google.golang.org/grpc/internal/xds/balancer/clusterresolver/resource_resolver_eds.go b/vendor/google.golang.org/grpc/internal/xds/balancer/clusterresolver/resource_resolver_eds.go index 18b517f111d..6dcdb898e5f 100644 --- a/vendor/google.golang.org/grpc/internal/xds/balancer/clusterresolver/resource_resolver_eds.go +++ b/vendor/google.golang.org/grpc/internal/xds/balancer/clusterresolver/resource_resolver_eds.go @@ -76,14 +76,14 @@ func newEDSResolver(nameToWatch string, producer xdsresource.Producer, topLevelR } // ResourceChanged is invoked to report an update for the resource being watched. -func (er *edsDiscoveryMechanism) ResourceChanged(update *xdsresource.EndpointsResourceData, onDone func()) { +func (er *edsDiscoveryMechanism) ResourceChanged(update *xdsresource.EndpointsUpdate, onDone func()) { if er.stopped.HasFired() { onDone() return } er.mu.Lock() - er.update = &update.Resource + er.update = update er.mu.Unlock() er.topLevelResolver.onUpdate(onDone) diff --git a/vendor/google.golang.org/grpc/internal/xds/bootstrap/bootstrap.go b/vendor/google.golang.org/grpc/internal/xds/bootstrap/bootstrap.go index f3960defc7b..79fb79020cf 100644 --- a/vendor/google.golang.org/grpc/internal/xds/bootstrap/bootstrap.go +++ b/vendor/google.golang.org/grpc/internal/xds/bootstrap/bootstrap.go @@ -44,6 +44,7 @@ import ( const ( serverFeaturesIgnoreResourceDeletion = "ignore_resource_deletion" + serverFeaturesTrustedXDSServer = "trusted_xds_server" gRPCUserAgentName = "gRPC Go" clientFeatureNoOverprovisioning = "envoy.lb.does_not_support_overprovisioning" clientFeatureResourceWrapper = "xds.config.resource-in-sotw" @@ -256,6 +257,18 @@ func (sc *ServerConfig) ServerFeaturesIgnoreResourceDeletion() bool { return false } +// ServerFeaturesTrustedXDSServer returns true if this server is trusted, +// and gRPC should accept security-config-affecting fields from the server +// as described in gRFC A81. +func (sc *ServerConfig) ServerFeaturesTrustedXDSServer() bool { + for _, sf := range sc.serverFeatures { + if sf == serverFeaturesTrustedXDSServer { + return true + } + } + return false +} + // SelectedChannelCreds returns the selected credentials configuration for // communicating with this server. func (sc *ServerConfig) SelectedChannelCreds() ChannelCreds { diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/internal/buffer/unbounded.go b/vendor/google.golang.org/grpc/internal/xds/clients/internal/buffer/unbounded.go index 3e6e99d0e8e..52b8dab892b 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/internal/buffer/unbounded.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/internal/buffer/unbounded.go @@ -83,6 +83,7 @@ func (b *Unbounded) Load() { default: } } else if b.closing && !b.closed { + b.closed = true close(b.c) } } diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/ads_stream.go b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/ads_stream.go index 3ad62ac16db..24e66b83471 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/ads_stream.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/ads_stream.go @@ -28,7 +28,6 @@ import ( igrpclog "google.golang.org/grpc/internal/grpclog" "google.golang.org/grpc/internal/xds/clients" "google.golang.org/grpc/internal/xds/clients/internal/backoff" - "google.golang.org/grpc/internal/xds/clients/internal/buffer" "google.golang.org/grpc/internal/xds/clients/internal/pretty" "google.golang.org/grpc/internal/xds/clients/xdsclient/internal/xdsresource" @@ -48,6 +47,13 @@ const ( perRPCVerbosityLevel = 9 ) +// request represents a queued request message to be sent on the ADS stream. It +// contains the type of the resource and the list of resource names to be sent. +type request struct { + typ ResourceType + resourceNames []string +} + // response represents a response received on the ADS stream. It contains the // type URL, version, and resources for the response. type response struct { @@ -76,9 +82,7 @@ type adsStreamEventHandler interface { type resourceTypeState struct { version string // Last acked version. Should not be reset when the stream breaks. nonce string // Last received nonce. Should be reset when the stream breaks. - bufferedRequests chan struct{} // Channel to buffer requests when writing is blocked. subscribedResources map[string]*xdsresource.ResourceWatchState // Map of subscribed resource names to their state. - pendingWrite bool // True if there is a pending write for this resource type. } // adsStreamImpl provides the functionality associated with an ADS (Aggregated @@ -99,15 +103,16 @@ type adsStreamImpl struct { // The following fields are initialized in the constructor and are not // written to afterwards, and hence can be accessed without a mutex. streamCh chan clients.Stream // New ADS streams are pushed here. - requestCh *buffer.Unbounded // Subscriptions and unsubscriptions are pushed here. runnerDoneCh chan struct{} // Notify completion of runner goroutine. cancel context.CancelFunc // To cancel the context passed to the runner goroutine. fc *adsFlowControl // Flow control for ADS stream. + notifySender chan struct{} // To notify the sending goroutine of a pending request. // Guards access to the below fields (and to the contents of the map). mu sync.Mutex resourceTypeState map[ResourceType]*resourceTypeState // Map of resource types to their state. firstRequest bool // False after the first request is sent out. + pendingRequests []request // Subscriptions and unsubscriptions are pushed here. } // adsStreamOpts contains the options for creating a new ADS Stream. @@ -132,9 +137,9 @@ func newADSStreamImpl(opts adsStreamOpts) *adsStreamImpl { watchExpiryTimeout: opts.watchExpiryTimeout, streamCh: make(chan clients.Stream, 1), - requestCh: buffer.NewUnbounded(), runnerDoneCh: make(chan struct{}), fc: newADSFlowControl(), + notifySender: make(chan struct{}, 1), resourceTypeState: make(map[ResourceType]*resourceTypeState), } @@ -151,76 +156,79 @@ func newADSStreamImpl(opts adsStreamOpts) *adsStreamImpl { func (s *adsStreamImpl) Stop() { s.cancel() s.fc.stop() - s.requestCh.Close() <-s.runnerDoneCh s.logger.Infof("Shutdown ADS stream") } // subscribe subscribes to the given resource. It is assumed that multiple // subscriptions for the same resource is deduped at the caller. A discovery -// request is sent out on the underlying stream for the resource type when there -// is sufficient flow control quota. +// request is sent out on the underlying stream, for the resource type with the +// newly subscribed resource. func (s *adsStreamImpl) subscribe(typ ResourceType, name string) { if s.logger.V(2) { s.logger.Infof("Subscribing to resource %q of type %q", name, typ.TypeName) } s.mu.Lock() - defer s.mu.Unlock() - state, ok := s.resourceTypeState[typ] if !ok { // An entry in the type state map is created as part of the first // subscription request for this type. - state = &resourceTypeState{ - subscribedResources: make(map[string]*xdsresource.ResourceWatchState), - bufferedRequests: make(chan struct{}, 1), - } + state = &resourceTypeState{subscribedResources: make(map[string]*xdsresource.ResourceWatchState)} s.resourceTypeState[typ] = state } // Create state for the newly subscribed resource. The watch timer will // be started when a request for this resource is actually sent out. state.subscribedResources[name] = &xdsresource.ResourceWatchState{State: xdsresource.ResourceWatchStateStarted} - state.pendingWrite = true // Send a request for the resource type with updated subscriptions. - s.requestCh.Put(typ) + s.pendingRequests = append(s.pendingRequests, request{typ: typ, resourceNames: resourceNames(state.subscribedResources)}) + s.mu.Unlock() + + select { + case s.notifySender <- struct{}{}: + default: + } } -// Unsubscribe cancels the subscription to the given resource. It is a no-op if +// unsubscribe cancels the subscription to the given resource. It is a no-op if // the given resource does not exist. The watch expiry timer associated with the // resource is stopped if one is active. A discovery request is sent out on the -// stream for the resource type when there is sufficient flow control quota. -func (s *adsStreamImpl) Unsubscribe(typ ResourceType, name string) { +// stream for the resource type with the updated set of resource names. +func (s *adsStreamImpl) unsubscribe(typ ResourceType, name string) { if s.logger.V(2) { s.logger.Infof("Unsubscribing to resource %q of type %q", name, typ.TypeName) } s.mu.Lock() - defer s.mu.Unlock() - state, ok := s.resourceTypeState[typ] if !ok { + s.mu.Unlock() return } - rs, ok := state.subscribedResources[name] if !ok { + s.mu.Unlock() return } if rs.ExpiryTimer != nil { rs.ExpiryTimer.Stop() } delete(state.subscribedResources, name) - state.pendingWrite = true // Send a request for the resource type with updated subscriptions. - s.requestCh.Put(typ) + s.pendingRequests = append(s.pendingRequests, request{typ: typ, resourceNames: resourceNames(state.subscribedResources)}) + s.mu.Unlock() + + select { + case s.notifySender <- struct{}{}: + default: + } } // runner is a long-running goroutine that handles the lifecycle of the ADS -// stream. It spwans another goroutine to handle writes of discovery request +// stream. It spawns another goroutine to handle writes of discovery request // messages on the stream. Whenever an existing stream fails, it performs // exponential backoff (if no messages were received on that stream) before // creating a new stream. @@ -280,53 +288,44 @@ func (s *adsStreamImpl) send(ctx context.Context) { stream = nil continue } - case req, ok := <-s.requestCh.Get(): - if !ok { - return + case <-s.notifySender: + // If there's no stream yet, skip the request. This request will be resent + // when a new stream is created. If no stream is created, the watcher will + // timeout (same as server not sending response back). + if stream == nil { + continue } - s.requestCh.Load() - typ := req.(ResourceType) - if err := s.sendNew(stream, typ); err != nil { + // Resetting the pendingRequests slice to nil works for both cases: + // - When we successfully sends the requests out on the wire. + // - When sending fails. This can happen only when the stream fails, + // and in this case, we rely on the `sendExisting` to send out + // requests for all subscriptions when the stream is recreated. + s.mu.Lock() + if err := s.sendNewLocked(stream, s.pendingRequests); err != nil { stream = nil - continue } + s.pendingRequests = nil + s.mu.Unlock() } } } -// sendNew attempts to send a discovery request based on a new subscription or -// unsubscription. If there is no flow control quota, the request is buffered -// and will be sent later. This method also starts the watch expiry timer for -// resources that were sent in the request for the first time, i.e. their watch -// state is `watchStateStarted`. -func (s *adsStreamImpl) sendNew(stream clients.Stream, typ ResourceType) error { - s.mu.Lock() - defer s.mu.Unlock() - - // If there's no stream yet, skip the request. This request will be resent - // when a new stream is created. If no stream is created, the watcher will - // timeout (same as server not sending response back). - if stream == nil { - return nil - } - - // If local processing of the most recently received response is not yet - // complete, i.e. fc.pending == true, queue this write and return early. - // This allows us to batch writes for requests which are generated as part - // of local processing of a received response. - state := s.resourceTypeState[typ] - bufferRequest := func() { - select { - case state.bufferedRequests <- struct{}{}: - default: +// sendNewLocked attempts to send a discovery request based on a new subscription or +// unsubscription. This method also starts the watch expiry timer for resources +// that were sent in the request for the first time, i.e. their watch state is +// `watchStateStarted`. +// +// Caller needs to hold c.mu. +func (s *adsStreamImpl) sendNewLocked(stream clients.Stream, requests []request) error { + for _, req := range requests { + state := s.resourceTypeState[req.typ] + if err := s.sendMessageLocked(stream, req.resourceNames, req.typ.TypeURL, state.version, state.nonce, nil); err != nil { + return err } + s.startWatchTimersLocked(req.typ, req.resourceNames) } - if s.fc.runIfPending(bufferRequest) { - return nil - } - - return s.sendMessageIfWritePendingLocked(stream, typ, state) + return nil } // sendExisting sends out discovery requests for existing resources when @@ -337,6 +336,10 @@ func (s *adsStreamImpl) sendExisting(stream clients.Stream) error { s.mu.Lock() defer s.mu.Unlock() + // Clear any queued requests. Previously subscribed to resources will be + // resent below. + s.pendingRequests = nil + for typ, state := range s.resourceTypeState { // Reset only the nonces map when the stream restarts. // @@ -355,69 +358,15 @@ func (s *adsStreamImpl) sendExisting(stream clients.Stream) error { continue } - state.pendingWrite = true - if err := s.sendMessageIfWritePendingLocked(stream, typ, state); err != nil { + names := resourceNames(state.subscribedResources) + if err := s.sendMessageLocked(stream, names, typ.TypeURL, state.version, state.nonce, nil); err != nil { return err } + s.startWatchTimersLocked(typ, names) } return nil } -// sendBuffered sends out discovery requests for resources that were buffered -// when they were subscribed to, because local processing of the previously -// received response was not yet complete. -// -// The stream argument is guaranteed to be non-nil. -func (s *adsStreamImpl) sendBuffered(stream clients.Stream) error { - s.mu.Lock() - defer s.mu.Unlock() - - for typ, state := range s.resourceTypeState { - select { - case <-state.bufferedRequests: - if err := s.sendMessageIfWritePendingLocked(stream, typ, state); err != nil { - return err - } - default: - // No buffered request. - continue - } - } - return nil -} - -// sendMessageIfWritePendingLocked attempts to sends a discovery request to the -// server, if there is a pending write for the given resource type. -// -// If the request is successfully sent, the pending write field is cleared and -// watch timers are started for the resources in the request. -// -// Caller needs to hold c.mu. -func (s *adsStreamImpl) sendMessageIfWritePendingLocked(stream clients.Stream, typ ResourceType, state *resourceTypeState) error { - if !state.pendingWrite { - if s.logger.V(2) { - s.logger.Infof("Skipping sending request for type %q, because all subscribed resources were already sent", typ.TypeURL) - } - return nil - } - - names := resourceNames(state.subscribedResources) - if err := s.sendMessageLocked(stream, names, typ.TypeURL, state.version, state.nonce, nil); err != nil { - return err - } - state.pendingWrite = false - - // Drain the buffered requests channel because we just sent a request for this - // resource type. - select { - case <-state.bufferedRequests: - default: - } - - s.startWatchTimersLocked(typ, names) - return nil -} - // sendMessageLocked sends a discovery request to the server, populating the // different fields of the message with the given parameters. Returns a non-nil // error if the request could not be sent. @@ -467,11 +416,9 @@ func (s *adsStreamImpl) sendMessageLocked(stream clients.Stream, names []string, // recv is responsible for receiving messages from the ADS stream. // // It performs the following actions: -// - Waits for local flow control to be available before sending buffered -// requests, if any. -// - Receives a message from the ADS stream. If an error is encountered here, -// it is handled by the onError method which propagates the error to all -// watchers. +// - Waits for local flow control to be available before it receives a message +// from the ADS stream. If an error is encountered here, it is handled by +// the onError method which propagates the error to all watchers. // - Invokes the event handler's OnADSResponse method to process the message. // - Sends an ACK or NACK to the server based on the response. // @@ -488,10 +435,6 @@ func (s *adsStreamImpl) recv(stream clients.Stream) bool { return msgReceived } - // Send out a request if anything was buffered while we were waiting for - // local processing of the previous response to complete. - s.sendBuffered(stream) - resources, url, version, nonce, err := s.recvMessage(stream) if err != nil { s.onError(err, msgReceived) @@ -760,23 +703,6 @@ func (fc *adsFlowControl) setPending(pending bool) { } } -func (fc *adsFlowControl) runIfPending(f func()) bool { - fc.mu.Lock() - defer fc.mu.Unlock() - - if fc.stopped { - return false - } - - // If there's a pending update, run the function while still holding the - // lock. This ensures that the pending state does not change between the - // check and the function call. - if fc.pending { - f() - } - return fc.pending -} - // wait blocks until all the watchers have consumed the most recent update. // Returns true if the flow control was stopped while waiting, false otherwise. func (fc *adsFlowControl) wait() bool { diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/authority.go b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/authority.go index e4425fa7b3c..b8cb78fbdfb 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/authority.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/authority.go @@ -470,7 +470,7 @@ func (a *authority) handleADSResourceUpdate(serverConfig *ServerConfig, rType Re // "resource-not-found" error. continue } - if serverConfig.IgnoreResourceDeletion { + if serverConfig.SupportsServerFeature(ServerFeatureIgnoreResourceDeletion) { // Per A53, resource deletions are ignored if the // `ignore_resource_deletion` server feature is enabled through the // xDS client configuration. If the resource deletion is to be diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/channel.go b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/channel.go index 7c40f1dab8f..9da5eb36186 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/channel.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/channel.go @@ -163,7 +163,7 @@ func (xc *xdsChannel) unsubscribe(typ ResourceType, name string) { } return } - xc.ads.Unsubscribe(typ, name) + xc.ads.unsubscribe(typ, name) } // The following onADSXxx() methods implement the StreamEventHandler interface diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/clientimpl_watchers.go b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/clientimpl_watchers.go index 68b29295ce2..b305b064d3f 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/clientimpl_watchers.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/clientimpl_watchers.go @@ -19,6 +19,7 @@ package xdsclient import ( + "context" "fmt" "google.golang.org/grpc/internal/xds/clients/xdsclient/internal/xdsresource" @@ -41,9 +42,11 @@ func (w *wrappingWatcher) ResourceError(err error, done func()) { // WatchResource starts watching the specified resource. // -// typeURL specifies the resource type implementation to use. The watch fails -// if there is no resource type implementation for the given typeURL. See the -// ResourceTypes field in the Config struct used to create the XDSClient. +// The watch fails to start if: +// - There is no ResourceType implementation for the given typeURL in the +// ResourceTypes field of the Config struct used to create the XDSClient. +// - The provided resourceName contains an authority that is not present in the +// Authorities field. // // The returned function cancels the watch and prevents future calls to the // watcher. @@ -61,8 +64,10 @@ func (c *XDSClient) WatchResource(typeURL, resourceName string, watcher Resource rType, ok := c.config.ResourceTypes[typeURL] if !ok { - logger.Warningf("ResourceType implementation for resource type url %v is not found", rType.TypeURL) - watcher.ResourceError(fmt.Errorf("ResourceType implementation for resource type url %v is not found", rType.TypeURL), func() {}) + logger.Warningf("ResourceType implementation for resource type url %q is not found", rType.TypeURL) + c.serializer.TrySchedule(func(context.Context) { + watcher.ResourceError(fmt.Errorf("no ResourceType implementation found for typeURL %q", rType.TypeURL), func() {}) + }) return func() {} } @@ -70,7 +75,9 @@ func (c *XDSClient) WatchResource(typeURL, resourceName string, watcher Resource a := c.getAuthorityForResource(n) if a == nil { logger.Warningf("Watch registered for name %q of type %q, authority %q is not found", rType.TypeName, resourceName, n.Authority) - watcher.ResourceError(fmt.Errorf("authority %q not found in bootstrap config for resource %q", n.Authority, resourceName), func() {}) + c.serializer.TrySchedule(func(context.Context) { + watcher.ResourceError(fmt.Errorf("authority %q not found in the config for resource %q", n.Authority, resourceName), func() {}) + }) return func() {} } // The watchResource method on the authority is invoked with n.String() diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/resource_watcher.go b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/resource_watcher.go index 37d01bc71e7..15891d9bef2 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/resource_watcher.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/resource_watcher.go @@ -21,6 +21,9 @@ package xdsclient // ResourceWatcher is notified of the resource updates and errors that are // received by the xDS client from the management server. // +// All methods on this interface are guaranteed to be called serially by the xDS +// client. +// // All methods contain a done parameter which should be called when processing // of the update has completed. For example, if processing a resource requires // watching new resources, those watches should be completed before done is diff --git a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/xdsconfig.go b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/xdsconfig.go index 9d376e508c4..14d64c1e0a5 100644 --- a/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/xdsconfig.go +++ b/vendor/google.golang.org/grpc/internal/xds/clients/xdsclient/xdsconfig.go @@ -24,6 +24,20 @@ import ( "google.golang.org/grpc/internal/xds/clients" ) +// ServerFeature indicates the features that will be supported by an xDS server. +type ServerFeature uint64 + +const ( + // ServerFeatureIgnoreResourceDeletion indicates that the server supports a + // feature where the xDS client can ignore resource deletions from this server, + // as described in gRFC A53. + ServerFeatureIgnoreResourceDeletion ServerFeature = 1 << iota + // ServerFeatureTrustedXDSServer returns true if this server is trusted, + // and gRPC should accept security-config-affecting fields from the server + // as described in gRFC A81. + ServerFeatureTrustedXDSServer +) + // Config is used to configure an xDS client. After one has been passed to the // xDS client's New function, no part of it may be modified. A Config may be // reused; the xdsclient package will also not modify it. @@ -74,17 +88,7 @@ type Config struct { // ServerConfig contains configuration for an xDS management server. type ServerConfig struct { ServerIdentifier clients.ServerIdentifier - - // IgnoreResourceDeletion is a server feature which if set to true, - // indicates that resource deletion errors from xDS management servers can - // be ignored and cached resource data can be used. - // - // This will be removed in the future once we implement gRFC A88 - // and two new fields FailOnDataErrors and - // ResourceTimerIsTransientError will be introduced. - IgnoreResourceDeletion bool - - // TODO: Link to gRFC A88 + ServerFeature ServerFeature // ServerFeature stores a bitmap of supported features. } // Authority contains configuration for an xDS control plane authority. @@ -98,5 +102,11 @@ type Authority struct { } func isServerConfigEqual(a, b *ServerConfig) bool { - return a.ServerIdentifier == b.ServerIdentifier && a.IgnoreResourceDeletion == b.IgnoreResourceDeletion + return a.ServerIdentifier == b.ServerIdentifier && a.ServerFeature == b.ServerFeature +} + +// SupportsServerFeature returns true if the server configuration indicates that +// the server supports the given feature. +func (s *ServerConfig) SupportsServerFeature(feature ServerFeature) bool { + return s.ServerFeature&feature != 0 } diff --git a/vendor/google.golang.org/grpc/internal/xds/matcher/string_matcher.go b/vendor/google.golang.org/grpc/internal/xds/matcher/string_matcher.go index c138f78735b..a6cf05dd3d1 100644 --- a/vendor/google.golang.org/grpc/internal/xds/matcher/string_matcher.go +++ b/vendor/google.golang.org/grpc/internal/xds/matcher/string_matcher.go @@ -48,24 +48,49 @@ type StringMatcher struct { // Match returns true if input matches the criteria in the given StringMatcher. func (sm StringMatcher) Match(input string) bool { - if sm.ignoreCase { - input = strings.ToLower(input) - } switch { case sm.exactMatch != nil: + if sm.ignoreCase { + input = strings.ToLower(input) + } return input == *sm.exactMatch case sm.prefixMatch != nil: + if sm.ignoreCase { + input = strings.ToLower(input) + } return strings.HasPrefix(input, *sm.prefixMatch) case sm.suffixMatch != nil: + if sm.ignoreCase { + input = strings.ToLower(input) + } return strings.HasSuffix(input, *sm.suffixMatch) - case sm.regexMatch != nil: - return grpcutil.FullMatchWithRegex(sm.regexMatch, input) case sm.containsMatch != nil: + if sm.ignoreCase { + input = strings.ToLower(input) + } return strings.Contains(input, *sm.containsMatch) + case sm.regexMatch != nil: + return grpcutil.FullMatchWithRegex(sm.regexMatch, input) } return false } +// newStrPtr allocates a new string that holds the value of input and returns a +// pointer to it. ignoreCase controls if a lower case version of input is used. +func newStrPtr(input *string, ignoreCase bool) *string { + if input == nil { + return nil + } + + s := new(string) + if ignoreCase { + *s = strings.ToLower(*input) + } else { + *s = *input + } + return s +} + // StringMatcherFromProto is a helper function to create a StringMatcher from // the corresponding StringMatcher proto. // @@ -78,26 +103,17 @@ func StringMatcherFromProto(matcherProto *v3matcherpb.StringMatcher) (StringMatc matcher := StringMatcher{ignoreCase: matcherProto.GetIgnoreCase()} switch mt := matcherProto.GetMatchPattern().(type) { case *v3matcherpb.StringMatcher_Exact: - matcher.exactMatch = &mt.Exact - if matcher.ignoreCase { - *matcher.exactMatch = strings.ToLower(*matcher.exactMatch) - } + matcher.exactMatch = newStrPtr(&mt.Exact, matcher.ignoreCase) case *v3matcherpb.StringMatcher_Prefix: if matcherProto.GetPrefix() == "" { return StringMatcher{}, errors.New("empty prefix is not allowed in StringMatcher") } - matcher.prefixMatch = &mt.Prefix - if matcher.ignoreCase { - *matcher.prefixMatch = strings.ToLower(*matcher.prefixMatch) - } + matcher.prefixMatch = newStrPtr(&mt.Prefix, matcher.ignoreCase) case *v3matcherpb.StringMatcher_Suffix: if matcherProto.GetSuffix() == "" { return StringMatcher{}, errors.New("empty suffix is not allowed in StringMatcher") } - matcher.suffixMatch = &mt.Suffix - if matcher.ignoreCase { - *matcher.suffixMatch = strings.ToLower(*matcher.suffixMatch) - } + matcher.suffixMatch = newStrPtr(&mt.Suffix, matcher.ignoreCase) case *v3matcherpb.StringMatcher_SafeRegex: regex := matcherProto.GetSafeRegex().GetRegex() re, err := regexp.Compile(regex) @@ -109,40 +125,59 @@ func StringMatcherFromProto(matcherProto *v3matcherpb.StringMatcher) (StringMatc if matcherProto.GetContains() == "" { return StringMatcher{}, errors.New("empty contains is not allowed in StringMatcher") } - matcher.containsMatch = &mt.Contains - if matcher.ignoreCase { - *matcher.containsMatch = strings.ToLower(*matcher.containsMatch) - } + matcher.containsMatch = newStrPtr(&mt.Contains, matcher.ignoreCase) default: return StringMatcher{}, fmt.Errorf("unrecognized string matcher: %+v", matcherProto) } return matcher, nil } -// StringMatcherForTesting is a helper function to create a StringMatcher based -// on the given arguments. Intended only for testing purposes. -func StringMatcherForTesting(exact, prefix, suffix, contains *string, regex *regexp.Regexp, ignoreCase bool) StringMatcher { - sm := StringMatcher{ - exactMatch: exact, - prefixMatch: prefix, - suffixMatch: suffix, - regexMatch: regex, - containsMatch: contains, +// NewExactStringMatcher creates a string matcher that requires the input string +// to exactly match the pattern specified here. The match will be case +// insensitive if ignore_case is true. +func NewExactStringMatcher(pattern string, ignoreCase bool) StringMatcher { + return StringMatcher{ + exactMatch: newStrPtr(&pattern, ignoreCase), + ignoreCase: ignoreCase, + } +} + +// NewPrefixStringMatcher creates a string matcher that requires the input +// string to contain the prefix specified here. The match will be case +// insensitive if ignore_case is true. +func NewPrefixStringMatcher(prefix string, ignoreCase bool) StringMatcher { + return StringMatcher{ + prefixMatch: newStrPtr(&prefix, ignoreCase), + ignoreCase: ignoreCase, + } +} + +// NewSuffixStringMatcher creates a string matcher that requires the input +// string to contain the suffix specified here. The match will be case +// insensitive if ignore_case is true. +func NewSuffixStringMatcher(suffix string, ignoreCase bool) StringMatcher { + return StringMatcher{ + suffixMatch: newStrPtr(&suffix, ignoreCase), + ignoreCase: ignoreCase, + } +} + +// NewContainsStringMatcher creates a string matcher that requires the input +// string to contain the pattern specified here. The match will be case +// insensitive if ignore_case is true. +func NewContainsStringMatcher(pattern string, ignoreCase bool) StringMatcher { + return StringMatcher{ + containsMatch: newStrPtr(&pattern, ignoreCase), ignoreCase: ignoreCase, } - if ignoreCase { - switch { - case sm.exactMatch != nil: - *sm.exactMatch = strings.ToLower(*exact) - case sm.prefixMatch != nil: - *sm.prefixMatch = strings.ToLower(*prefix) - case sm.suffixMatch != nil: - *sm.suffixMatch = strings.ToLower(*suffix) - case sm.containsMatch != nil: - *sm.containsMatch = strings.ToLower(*contains) - } +} + +// NewRegexStringMatcher creates a string matcher that requires the input string +// to match the regular expression specified here. +func NewRegexStringMatcher(regex *regexp.Regexp) StringMatcher { + return StringMatcher{ + regexMatch: regex, } - return sm } // ExactMatch returns the value of the configured exact match or an empty string diff --git a/vendor/google.golang.org/grpc/internal/xds/resolver/serviceconfig.go b/vendor/google.golang.org/grpc/internal/xds/resolver/serviceconfig.go index f2ceabe7a8d..e04163666dc 100644 --- a/vendor/google.golang.org/grpc/internal/xds/resolver/serviceconfig.go +++ b/vendor/google.golang.org/grpc/internal/xds/resolver/serviceconfig.go @@ -35,6 +35,7 @@ import ( iringhash "google.golang.org/grpc/internal/ringhash" "google.golang.org/grpc/internal/serviceconfig" "google.golang.org/grpc/internal/wrr" + "google.golang.org/grpc/internal/xds/balancer/clusterimpl" "google.golang.org/grpc/internal/xds/balancer/clustermanager" "google.golang.org/grpc/internal/xds/httpfilter" "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" @@ -97,17 +98,14 @@ func serviceConfigJSON(activeClusters map[string]*clusterInfo) []byte { } type virtualHost struct { - // map from filter name to its config - httpFilterConfigOverride map[string]httpfilter.FilterConfig // retry policy present in virtual host retryConfig *xdsresource.RetryConfig } // routeCluster holds information about a cluster as referenced by a route. type routeCluster struct { - name string - // map from filter name to its config - httpFilterConfigOverride map[string]httpfilter.FilterConfig + name string // Name of the cluster. + interceptor iresolver.ClientInterceptor // HTTP filters to run for RPCs matching this route. } type route struct { @@ -115,10 +113,9 @@ type route struct { actionType xdsresource.RouteActionType // holds route action type clusters wrr.WRR // holds *routeCluster entries maxStreamDuration time.Duration - // map from filter name to its config - httpFilterConfigOverride map[string]httpfilter.FilterConfig - retryConfig *xdsresource.RetryConfig - hashPolicies []*xdsresource.HashPolicy + retryConfig *xdsresource.RetryConfig + hashPolicies []*xdsresource.HashPolicy + autoHostRewrite bool } func (r route) String() string { @@ -200,13 +197,9 @@ func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RP ref := &cs.clusters[cluster.name].refCount atomic.AddInt32(ref, 1) - interceptor, err := cs.newInterceptor(rt, cluster) - if err != nil { - return nil, annotateErrorWithNodeID(err, cs.xdsNodeID) - } - lbCtx := clustermanager.SetPickedCluster(rpcInfo.Context, cluster.name) lbCtx = iringhash.SetXDSRequestHash(lbCtx, cs.generateHash(rpcInfo, rt.hashPolicies)) + lbCtx = clusterimpl.SetAutoHostRewrite(lbCtx, rt.autoHostRewrite) config := &iresolver.RPCConfig{ // Communicate to the LB policy the chosen cluster and request hash, if Ring Hash LB policy. @@ -220,7 +213,7 @@ func (cs *configSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*iresolver.RP cs.sendNewServiceConfig() } }, - Interceptor: interceptor, + Interceptor: cluster.interceptor, } if rt.maxStreamDuration != 0 { @@ -310,35 +303,6 @@ func (cs *configSelector) generateHash(rpcInfo iresolver.RPCInfo, hashPolicies [ return rand.Uint64() } -func (cs *configSelector) newInterceptor(rt *route, cluster *routeCluster) (iresolver.ClientInterceptor, error) { - if len(cs.httpFilterConfig) == 0 { - return nil, nil - } - interceptors := make([]iresolver.ClientInterceptor, 0, len(cs.httpFilterConfig)) - for _, filter := range cs.httpFilterConfig { - override := cluster.httpFilterConfigOverride[filter.Name] // cluster is highest priority - if override == nil { - override = rt.httpFilterConfigOverride[filter.Name] // route is second priority - } - if override == nil { - override = cs.virtualHost.httpFilterConfigOverride[filter.Name] // VH is third & lowest priority - } - ib, ok := filter.Filter.(httpfilter.ClientInterceptorBuilder) - if !ok { - // Should not happen if it passed xdsClient validation. - return nil, fmt.Errorf("filter does not support use in client") - } - i, err := ib.BuildClientInterceptor(filter.Config, override) - if err != nil { - return nil, fmt.Errorf("error constructing filter: %v", err) - } - if i != nil { - interceptors = append(interceptors, i) - } - } - return &interceptorList{interceptors: interceptors}, nil -} - // stop decrements refs of all clusters referenced by this config selector. func (cs *configSelector) stop() { // The resolver's old configSelector may be nil. Handle that here. @@ -363,6 +327,38 @@ func (cs *configSelector) stop() { } } +// newInterceptor builds a chain of client interceptors for the given filters +// and override configuration. The cluster override has the highest priority, +// followed by the route override, and finally the virtual host override. +func newInterceptor(filters []xdsresource.HTTPFilter, clusterOverride, routeOverride, virtualHostOverride map[string]httpfilter.FilterConfig) (iresolver.ClientInterceptor, error) { + if len(filters) == 0 { + return nil, nil + } + interceptors := make([]iresolver.ClientInterceptor, 0, len(filters)) + for _, filter := range filters { + override := clusterOverride[filter.Name] + if override == nil { + override = routeOverride[filter.Name] + } + if override == nil { + override = virtualHostOverride[filter.Name] + } + ib, ok := filter.Filter.(httpfilter.ClientInterceptorBuilder) + if !ok { + // Should not happen if it passed xdsClient validation. + return nil, fmt.Errorf("filter %q does not support use in client", filter.Name) + } + i, err := ib.BuildClientInterceptor(filter.Config, override) + if err != nil { + return nil, fmt.Errorf("error constructing filter: %v", err) + } + if i != nil { + interceptors = append(interceptors, i) + } + } + return &interceptorList{interceptors: interceptors}, nil +} + type interceptorList struct { interceptors []iresolver.ClientInterceptor } diff --git a/vendor/google.golang.org/grpc/internal/xds/resolver/watch_service.go b/vendor/google.golang.org/grpc/internal/xds/resolver/watch_service.go deleted file mode 100644 index 43ff23b7ca4..00000000000 --- a/vendor/google.golang.org/grpc/internal/xds/resolver/watch_service.go +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * 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 resolver - -import ( - "context" - - "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" -) - -type listenerWatcher struct { - resourceName string - cancel func() - parent *xdsResolver -} - -func newListenerWatcher(resourceName string, parent *xdsResolver) *listenerWatcher { - lw := &listenerWatcher{resourceName: resourceName, parent: parent} - lw.cancel = xdsresource.WatchListener(parent.xdsClient, resourceName, lw) - return lw -} - -func (l *listenerWatcher) ResourceChanged(update *xdsresource.ListenerUpdate, onDone func()) { - handleUpdate := func(context.Context) { l.parent.onListenerResourceUpdate(update); onDone() } - l.parent.serializer.ScheduleOr(handleUpdate, onDone) -} - -func (l *listenerWatcher) ResourceError(err error, onDone func()) { - handleError := func(context.Context) { l.parent.onListenerResourceError(err); onDone() } - l.parent.serializer.ScheduleOr(handleError, onDone) -} - -func (l *listenerWatcher) AmbientError(err error, onDone func()) { - handleError := func(context.Context) { l.parent.onListenerResourceAmbientError(err); onDone() } - l.parent.serializer.ScheduleOr(handleError, onDone) -} - -func (l *listenerWatcher) stop() { - l.cancel() - l.parent.logger.Infof("Canceling watch on Listener resource %q", l.resourceName) -} - -type routeConfigWatcher struct { - resourceName string - cancel func() - parent *xdsResolver -} - -func newRouteConfigWatcher(resourceName string, parent *xdsResolver) *routeConfigWatcher { - rw := &routeConfigWatcher{resourceName: resourceName, parent: parent} - rw.cancel = xdsresource.WatchRouteConfig(parent.xdsClient, resourceName, rw) - return rw -} - -func (r *routeConfigWatcher) ResourceChanged(u *xdsresource.RouteConfigResourceData, onDone func()) { - handleUpdate := func(context.Context) { - r.parent.onRouteConfigResourceUpdate(r.resourceName, u.Resource) - onDone() - } - r.parent.serializer.ScheduleOr(handleUpdate, onDone) -} - -func (r *routeConfigWatcher) ResourceError(err error, onDone func()) { - handleError := func(context.Context) { r.parent.onRouteConfigResourceError(r.resourceName, err); onDone() } - r.parent.serializer.ScheduleOr(handleError, onDone) -} - -func (r *routeConfigWatcher) AmbientError(err error, onDone func()) { - handleError := func(context.Context) { r.parent.onRouteConfigResourceAmbientError(r.resourceName, err); onDone() } - r.parent.serializer.ScheduleOr(handleError, onDone) -} - -func (r *routeConfigWatcher) stop() { - r.cancel() - r.parent.logger.Infof("Canceling watch on RouteConfiguration resource %q", r.resourceName) -} diff --git a/vendor/google.golang.org/grpc/internal/xds/resolver/xds_resolver.go b/vendor/google.golang.org/grpc/internal/xds/resolver/xds_resolver.go index 9180cd07689..44b7dd4b7b5 100644 --- a/vendor/google.golang.org/grpc/internal/xds/resolver/xds_resolver.go +++ b/vendor/google.golang.org/grpc/internal/xds/resolver/xds_resolver.go @@ -29,13 +29,13 @@ import ( "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/grpclog" "google.golang.org/grpc/internal/grpcsync" - "google.golang.org/grpc/internal/pretty" iresolver "google.golang.org/grpc/internal/resolver" "google.golang.org/grpc/internal/wrr" "google.golang.org/grpc/internal/xds/bootstrap" rinternal "google.golang.org/grpc/internal/xds/resolver/internal" "google.golang.org/grpc/internal/xds/xdsclient" "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" + "google.golang.org/grpc/internal/xds/xdsdepmgr" "google.golang.org/grpc/resolver" ) @@ -111,50 +111,46 @@ type xdsResolverBuilder struct { // The xds bootstrap process is performed (and a new xDS client is built) every // time an xds resolver is built. func (b *xdsResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (_ resolver.Resolver, retErr error) { - r := &xdsResolver{ - cc: cc, - activeClusters: make(map[string]*clusterInfo), - channelID: rand.Uint64(), - } - defer func() { - if retErr != nil { - r.Close() - } - }() - r.logger = prefixLogger(r) - r.logger.Infof("Creating resolver for target: %+v", target) - - // Initialize the serializer used to synchronize the following: - // - updates from the xDS client. This could lead to generation of new - // service config if resolution is complete. - // - completion of an RPC to a removed cluster causing the associated ref - // count to become zero, resulting in generation of new service config. - // - stopping of a config selector that results in generation of new service - // config. - ctx, cancel := context.WithCancel(context.Background()) - r.serializer = grpcsync.NewCallbackSerializer(ctx) - r.serializerCancel = cancel - // Initialize the xDS client. newXDSClient := rinternal.NewXDSClient.(func(string, estats.MetricsRecorder) (xdsclient.XDSClient, func(), error)) if b.newXDSClient != nil { newXDSClient = b.newXDSClient } - client, closeFn, err := newXDSClient(target.String(), opts.MetricsRecorder) + client, xdsClientClose, err := newXDSClient(target.String(), opts.MetricsRecorder) if err != nil { return nil, fmt.Errorf("xds: failed to create xds-client: %v", err) } - r.xdsClient = client - r.xdsClientClose = closeFn - // Determine the listener resource name and start a watcher for it. - template, err := r.sanityChecksOnBootstrapConfig(target, opts, r.xdsClient) + template, err := sanityChecksOnBootstrapConfig(target, client) if err != nil { + xdsClientClose() return nil, err } - r.dataplaneAuthority = opts.Authority - r.ldsResourceName = bootstrap.PopulateResourceTemplate(template, target.Endpoint()) - r.listenerWatcher = newListenerWatcher(r.ldsResourceName, r) + ldsResourceName := bootstrap.PopulateResourceTemplate(template, target.Endpoint()) + + ctx, cancel := context.WithCancel(context.Background()) + r := &xdsResolver{ + cc: cc, + xdsClient: client, + xdsClientClose: xdsClientClose, + activeClusters: make(map[string]*clusterInfo), + channelID: rand.Uint64(), + ldsResourceName: ldsResourceName, + + // serializer used to synchronize the following: + // - updates from the dependency manager. This could lead to generation + // of new service config if resolution is complete. + // - completion of an RPC to a removed cluster causing the associated + // ref count to become zero, resulting in generation of new service + // config. + // - stopping of a config selector that results in generation of new + // service config. + serializer: grpcsync.NewCallbackSerializer(ctx), + serializerCancel: cancel, + } + r.logger = prefixLogger(r) + r.logger.Infof("Creating resolver for target: %+v", target) + r.dm = xdsdepmgr.New(r.ldsResourceName, opts.Authority, r.xdsClient, r) return r, nil } @@ -167,7 +163,7 @@ func (b *xdsResolverBuilder) Build(target resolver.Target, cc resolver.ClientCon // // Returns the listener resource name template to use. If any of the above // validations fail, a non-nil error is returned. -func (r *xdsResolver) sanityChecksOnBootstrapConfig(target resolver.Target, _ resolver.BuildOptions, client xdsclient.XDSClient) (string, error) { +func sanityChecksOnBootstrapConfig(target resolver.Target, client xdsclient.XDSClient) (string, error) { bootstrapConfig := client.BootstrapConfig() if bootstrapConfig == nil { // This is never expected to happen after a successful xDS client @@ -205,50 +201,32 @@ func (*xdsResolverBuilder) Scheme() string { // xdsResolver implements the resolver.Resolver interface. // -// It registers a watcher for ServiceConfig updates with the xdsClient object -// (which performs LDS/RDS queries for the same), and passes the received -// updates to the ClientConn. +// It manages the dependency manager which in turn manages all xDS resource +// watches. It receives the xDS resource config and passes them to ClientConn. type xdsResolver struct { - cc resolver.ClientConn - logger *grpclog.PrefixLogger - // The underlying xdsClient which performs all xDS requests and responses. - xdsClient xdsclient.XDSClient - xdsClientClose func() - // A random number which uniquely identifies the channel which owns this - // resolver. - channelID uint64 - + // The following fields are initialized at creation time and are read-only + // after that. + cc resolver.ClientConn + logger *grpclog.PrefixLogger + ldsResourceName string + dm *xdsdepmgr.DependencyManager + xdsClient xdsclient.XDSClient + xdsClientClose func() + channelID uint64 // Unique random ID for the channel owning this resolver. // All methods on the xdsResolver type except for the ones invoked by gRPC, // i.e ResolveNow() and Close(), are guaranteed to execute in the context of - // this serializer's callback. And since the serializer guarantees mutual - // exclusion among these callbacks, we can get by without any mutexes to - // access all of the below defined state. The only exception is Close(), - // which does access some of this shared state, but it does so after - // cancelling the context passed to the serializer. + // this serializer's callback. We use the serializer because these shared + // states are accessed by each RPC when it is committed, and so + // serializer is preffered over a mutex. serializer *grpcsync.CallbackSerializer serializerCancel context.CancelFunc - // dataplaneAuthority is the authority used for the data plane connections, - // which is also used to select the VirtualHost within the xDS - // RouteConfiguration. This is %-encoded to match with VirtualHost Domain - // in xDS RouteConfiguration. - dataplaneAuthority string - - ldsResourceName string - listenerWatcher *listenerWatcher - listenerUpdateRecvd bool - currentListener *xdsresource.ListenerUpdate - - rdsResourceName string - routeConfigWatcher *routeConfigWatcher - routeConfigUpdateRecvd bool - currentRouteConfig xdsresource.RouteConfigUpdate - currentVirtualHost *xdsresource.VirtualHost // Matched virtual host for quick access. - + // The following fields are accessed only from within the serializer + // callbacks. + xdsConfig *xdsresource.XDSConfig // activeClusters is a map from cluster name to information about the // cluster that includes a ref count and load balancing configuration. - activeClusters map[string]*clusterInfo - + activeClusters map[string]*clusterInfo curConfigSelector stoppableConfigSelector } @@ -262,22 +240,53 @@ func (r *xdsResolver) Close() { r.serializerCancel() <-r.serializer.Done() - // Note that Close needs to check for nils even if some of them are always - // set in the constructor. This is because the constructor defers Close() in - // error cases, and the fields might not be set when the error happens. - - if r.listenerWatcher != nil { - r.listenerWatcher.stop() - } - if r.routeConfigWatcher != nil { - r.routeConfigWatcher.stop() + if r.dm != nil { + r.dm.Close() } + if r.xdsClientClose != nil { r.xdsClientClose() } r.logger.Infof("Shutdown") } +// Update is called when there is a new xDS config available from the dependency +// manager and does the following: +// - creates a new config selector (this involves incrementing references to +// clusters owned by this config selector). +// - stops the old config selector (this involves decrementing references to +// clusters owned by this config selector). +// - prunes active clusters and pushes a new service config to the channel. +// - updates the current config selector used by the resolver. +func (r *xdsResolver) Update(config *xdsresource.XDSConfig) { + r.serializer.TrySchedule(func(context.Context) { + r.xdsConfig = config + cs, err := r.newConfigSelector() + if err != nil { + r.onResourceError(err) + return + } + if !r.sendNewServiceConfig(cs) { + // Channel didn't like the update we provided (unexpected); erase + // this config selector and ignore this update, continuing with + // the previous config selector. + cs.stop() + return + } + + if r.curConfigSelector != nil { + r.curConfigSelector.stop() + } + r.curConfigSelector = cs + }) +} + +func (r *xdsResolver) Error(err error) { + r.serializer.TrySchedule(func(context.Context) { + r.onResourceError(err) + }) +} + // sendNewServiceConfig prunes active clusters, generates a new service config // based on the current set of active clusters, and sends an update to the // channel with that service config and the provided config selector. Returns @@ -308,7 +317,9 @@ func (r *xdsResolver) sendNewServiceConfig(cs stoppableConfigSelector) bool { } sc := serviceConfigJSON(r.activeClusters) - r.logger.Infof("For Listener resource %q and RouteConfiguration resource %q, generated service config: %v", r.ldsResourceName, r.rdsResourceName, pretty.FormatJSON(sc)) + if r.logger.V(2) { + r.logger.Infof("For Listener resource %q and RouteConfiguration resource %q, generated service config: %+v", r.ldsResourceName, r.xdsConfig.Listener.RouteConfigName, sc) + } // Send the update to the ClientConn. state := iresolver.SetConfigSelector(resolver.State{ @@ -328,7 +339,7 @@ func (r *xdsResolver) sendNewServiceConfig(cs stoppableConfigSelector) bool { // r.activeClusters for previously-unseen clusters. // // Only executed in the context of a serializer callback. -func (r *xdsResolver) newConfigSelector() *configSelector { +func (r *xdsResolver) newConfigSelector() (*configSelector, error) { cs := &configSelector{ channelID: r.channelID, xdsNodeID: r.xdsClient.BootstrapConfig().Node().GetId(), @@ -338,30 +349,31 @@ func (r *xdsResolver) newConfigSelector() *configSelector { }) }, virtualHost: virtualHost{ - httpFilterConfigOverride: r.currentVirtualHost.HTTPFilterConfigOverride, - retryConfig: r.currentVirtualHost.RetryConfig, + retryConfig: r.xdsConfig.VirtualHost.RetryConfig, }, - routes: make([]route, len(r.currentVirtualHost.Routes)), + routes: make([]route, len(r.xdsConfig.VirtualHost.Routes)), clusters: make(map[string]*clusterInfo), - httpFilterConfig: r.currentListener.HTTPFilters, + httpFilterConfig: r.xdsConfig.Listener.HTTPFilters, } - for i, rt := range r.currentVirtualHost.Routes { + for i, rt := range r.xdsConfig.VirtualHost.Routes { clusters := rinternal.NewWRR.(func() wrr.WRR)() if rt.ClusterSpecifierPlugin != "" { clusterName := clusterSpecifierPluginPrefix + rt.ClusterSpecifierPlugin - clusters.Add(&routeCluster{ - name: clusterName, - }, 1) + clusters.Add(&routeCluster{name: clusterName}, 1) ci := r.addOrGetActiveClusterInfo(clusterName) - ci.cfg = xdsChildConfig{ChildPolicy: balancerConfig(r.currentRouteConfig.ClusterSpecifierPlugins[rt.ClusterSpecifierPlugin])} + ci.cfg = xdsChildConfig{ChildPolicy: balancerConfig(r.xdsConfig.RouteConfig.ClusterSpecifierPlugins[rt.ClusterSpecifierPlugin])} cs.clusters[clusterName] = ci } else { for _, wc := range rt.WeightedClusters { clusterName := clusterPrefix + wc.Name + interceptor, err := newInterceptor(r.xdsConfig.Listener.HTTPFilters, wc.HTTPFilterConfigOverride, rt.HTTPFilterConfigOverride, r.xdsConfig.VirtualHost.HTTPFilterConfigOverride) + if err != nil { + return nil, err + } clusters.Add(&routeCluster{ - name: clusterName, - httpFilterConfigOverride: wc.HTTPFilterConfigOverride, + name: clusterName, + interceptor: interceptor, }, int64(wc.Weight)) ci := r.addOrGetActiveClusterInfo(clusterName) ci.cfg = xdsChildConfig{ChildPolicy: newBalancerConfig(cdsName, cdsBalancerConfig{Cluster: wc.Name})} @@ -373,14 +385,14 @@ func (r *xdsResolver) newConfigSelector() *configSelector { cs.routes[i].m = xdsresource.RouteToMatcher(rt) cs.routes[i].actionType = rt.ActionType if rt.MaxStreamDuration == nil { - cs.routes[i].maxStreamDuration = r.currentListener.MaxStreamDuration + cs.routes[i].maxStreamDuration = r.xdsConfig.Listener.MaxStreamDuration } else { cs.routes[i].maxStreamDuration = *rt.MaxStreamDuration } - cs.routes[i].httpFilterConfigOverride = rt.HTTPFilterConfigOverride cs.routes[i].retryConfig = rt.RetryConfig cs.routes[i].hashPolicies = rt.HashPolicies + cs.routes[i].autoHostRewrite = rt.AutoHostRewrite } // Account for this config selector's clusters. Do this after no further @@ -390,7 +402,7 @@ func (r *xdsResolver) newConfigSelector() *configSelector { atomic.AddInt32(&ci.refCount, 1) } - return cs + return cs, nil } // pruneActiveClusters deletes entries in r.activeClusters with zero @@ -422,70 +434,6 @@ type clusterInfo struct { cfg xdsChildConfig } -// Determines if the xdsResolver has received all required configuration, i.e -// Listener and RouteConfiguration resources, from the management server, and -// whether a matching virtual host was found in the RouteConfiguration resource. -func (r *xdsResolver) resolutionComplete() bool { - return r.listenerUpdateRecvd && r.routeConfigUpdateRecvd && r.currentVirtualHost != nil -} - -// onResolutionComplete performs the following actions when resolution is -// complete, i.e Listener and RouteConfiguration resources have been received -// from the management server and a matching virtual host is found in the -// latter. -// - creates a new config selector (this involves incrementing references to -// clusters owned by this config selector). -// - stops the old config selector (this involves decrementing references to -// clusters owned by this config selector). -// - prunes active clusters and pushes a new service config to the channel. -// - updates the current config selector used by the resolver. -// -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onResolutionComplete() { - if !r.resolutionComplete() { - return - } - - cs := r.newConfigSelector() - if !r.sendNewServiceConfig(cs) { - // Channel didn't like the update we provided (unexpected); erase - // this config selector and ignore this update, continuing with - // the previous config selector. - cs.stop() - return - } - - if r.curConfigSelector != nil { - r.curConfigSelector.stop() - } - r.curConfigSelector = cs -} - -func (r *xdsResolver) applyRouteConfigUpdate(update xdsresource.RouteConfigUpdate) { - matchVh := xdsresource.FindBestMatchingVirtualHost(r.dataplaneAuthority, update.VirtualHosts) - if matchVh == nil { - // TODO(purnesh42h): Should this be a resource or ambient error? Note - // that its being called only from resource update methods when we have - // finished removing the previous update. - r.onAmbientError(fmt.Errorf("no matching virtual host found for %q", r.dataplaneAuthority)) - return - } - r.currentRouteConfig = update - r.currentVirtualHost = matchVh - r.routeConfigUpdateRecvd = true - - r.onResolutionComplete() -} - -// onAmbientError propagates the error up to the channel. And since this is -// invoked only for non resource errors, we don't have to update resolver -// state and we can keep using the old config. -// -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onAmbientError(err error) { - r.cc.ReportError(err) -} - // Contains common functionality to be executed when resources of either type // are removed. // @@ -508,107 +456,3 @@ func (r *xdsResolver) onResourceError(err error) { } r.curConfigSelector = cs } - -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onListenerResourceUpdate(update *xdsresource.ListenerUpdate) { - if r.logger.V(2) { - r.logger.Infof("Received update for Listener resource %q: %v", r.ldsResourceName, pretty.ToJSON(update)) - } - - r.currentListener = update - r.listenerUpdateRecvd = true - - if update.InlineRouteConfig != nil { - // If there was a previous route config watcher because of a non-inline - // route configuration, cancel it. - r.rdsResourceName = "" - if r.routeConfigWatcher != nil { - r.routeConfigWatcher.stop() - r.routeConfigWatcher = nil - } - - r.applyRouteConfigUpdate(*update.InlineRouteConfig) - return - } - - // We get here only if there was no inline route configuration. - - // If the route config name has not changed, send an update with existing - // route configuration and the newly received listener configuration. - if r.rdsResourceName == update.RouteConfigName { - r.onResolutionComplete() - return - } - - // If the route config name has changed, cancel the old watcher and start a - // new one. At this point, since we have not yet resolved the new route - // config name, we don't send an update to the channel, and therefore - // continue using the old route configuration (if received) until the new - // one is received. - r.rdsResourceName = update.RouteConfigName - if r.routeConfigWatcher != nil { - r.routeConfigWatcher.stop() - r.currentVirtualHost = nil - r.routeConfigUpdateRecvd = false - } - r.routeConfigWatcher = newRouteConfigWatcher(r.rdsResourceName, r) -} - -func (r *xdsResolver) onListenerResourceAmbientError(err error) { - if r.logger.V(2) { - r.logger.Infof("Received ambient error for Listener resource %q: %v", r.ldsResourceName, err) - } - r.onAmbientError(err) -} - -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onListenerResourceError(err error) { - if r.logger.V(2) { - r.logger.Infof("Received resource error for Listener resource %q: %v", r.ldsResourceName, err) - } - - r.listenerUpdateRecvd = false - if r.routeConfigWatcher != nil { - r.routeConfigWatcher.stop() - } - r.rdsResourceName = "" - r.currentVirtualHost = nil - r.routeConfigUpdateRecvd = false - r.routeConfigWatcher = nil - - r.onResourceError(err) -} - -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onRouteConfigResourceUpdate(name string, update xdsresource.RouteConfigUpdate) { - if r.logger.V(2) { - r.logger.Infof("Received update for RouteConfiguration resource %q: %v", name, pretty.ToJSON(update)) - } - - if r.rdsResourceName != name { - // Drop updates from canceled watchers. - return - } - - r.applyRouteConfigUpdate(update) -} - -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onRouteConfigResourceAmbientError(name string, err error) { - if r.logger.V(2) { - r.logger.Infof("Received ambient error for RouteConfiguration resource %q: %v", name, err) - } - r.onAmbientError(err) -} - -// Only executed in the context of a serializer callback. -func (r *xdsResolver) onRouteConfigResourceError(name string, err error) { - if r.logger.V(2) { - r.logger.Infof("Received resource error for RouteConfiguration resource %q: %v", name, err) - } - - if r.rdsResourceName != name { - return - } - r.onResourceError(err) -} diff --git a/vendor/google.golang.org/grpc/internal/xds/server/listener_wrapper.go b/vendor/google.golang.org/grpc/internal/xds/server/listener_wrapper.go index 49cfdb635a2..15f6c17c3a5 100644 --- a/vendor/google.golang.org/grpc/internal/xds/server/listener_wrapper.go +++ b/vendor/google.golang.org/grpc/internal/xds/server/listener_wrapper.go @@ -59,8 +59,7 @@ type ServingModeCallback func(addr net.Addr, mode connectivity.ServingMode, err // XDSClient wraps the methods on the XDSClient which are required by // the listenerWrapper. type XDSClient interface { - WatchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) (cancel func()) - WatchResourceV2(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) + WatchResource(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) BootstrapConfig() *bootstrap.Config } diff --git a/vendor/google.golang.org/grpc/internal/xds/server/rds_handler.go b/vendor/google.golang.org/grpc/internal/xds/server/rds_handler.go index bf78c37c829..53ebef5e36d 100644 --- a/vendor/google.golang.org/grpc/internal/xds/server/rds_handler.go +++ b/vendor/google.golang.org/grpc/internal/xds/server/rds_handler.go @@ -135,7 +135,7 @@ type rdsWatcher struct { canceled bool // eats callbacks if true } -func (rw *rdsWatcher) ResourceChanged(update *xdsresource.RouteConfigResourceData, onDone func()) { +func (rw *rdsWatcher) ResourceChanged(update *xdsresource.RouteConfigUpdate, onDone func()) { defer onDone() rw.mu.Lock() if rw.canceled { @@ -144,11 +144,11 @@ func (rw *rdsWatcher) ResourceChanged(update *xdsresource.RouteConfigResourceDat } rw.mu.Unlock() if rw.logger.V(2) { - rw.logger.Infof("RDS watch for resource %q received update: %#v", rw.routeName, update.Resource) + rw.logger.Infof("RDS watch for resource %q received update: %#v", rw.routeName, update) } routeName := rw.routeName - rwu := rdsWatcherUpdate{data: &update.Resource} + rwu := rdsWatcherUpdate{data: update} rw.parent.updates[routeName] = rwu rw.parent.callback(routeName, rwu) } diff --git a/vendor/google.golang.org/grpc/internal/xds/xds.go b/vendor/google.golang.org/grpc/internal/xds/xds.go index 4d5a85ef35a..866fc53ba59 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xds.go +++ b/vendor/google.golang.org/grpc/internal/xds/xds.go @@ -24,6 +24,7 @@ import ( "fmt" "google.golang.org/grpc/attributes" + "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/xds/clients" "google.golang.org/grpc/resolver" ) @@ -46,6 +47,17 @@ func GetXDSHandshakeClusterName(attr *attributes.Attributes) (string, bool) { return name, ok } +// addressToTelemetryLabels prepares a telemetry label map from resolver +// address attributes. +func addressToTelemetryLabels(addr resolver.Address) map[string]string { + cluster, _ := GetXDSHandshakeClusterName(addr.Attributes) + locality := LocalityString(GetLocalityID(addr)) + return map[string]string{ + "grpc.lb.locality": locality, + "grpc.lb.backend_service": cluster, + } +} + // LocalityString generates a string representation of clients.Locality in the // format specified in gRFC A76. func LocalityString(l clients.Locality) string { @@ -99,3 +111,7 @@ var UnknownCSMLabels = map[string]string{ "csm.service_name": "unknown", "csm.service_namespace_name": "unknown", } + +func init() { + internal.AddressToTelemetryLabels = addressToTelemetryLabels +} diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/client.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/client.go index 1d803402c4d..d05382d0b11 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/client.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/client.go @@ -26,7 +26,6 @@ import ( "google.golang.org/grpc/internal/xds/bootstrap" "google.golang.org/grpc/internal/xds/clients/lrsclient" "google.golang.org/grpc/internal/xds/clients/xdsclient" - "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" v3statuspb "github.com/envoyproxy/go-control-plane/envoy/service/status/v3" ) @@ -49,12 +48,7 @@ type XDSClient interface { // During a race (e.g. an xDS response is received while the user is calling // cancel()), there's a small window where the callback can be called after // the watcher is canceled. Callers need to handle this case. - WatchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) (cancel func()) - - // WatchResourceV2 matches the API of the external xdsclient interface. - // Once all users of xdsclient have been moved to this watch API, we can - // remove the WatchResource API above, and rename this to WatchResource. - WatchResourceV2(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) + WatchResource(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) ReportLoad(*bootstrap.ServerConfig) (*lrsclient.LoadStore, func(context.Context)) diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl.go index f2325e0e552..b2088647011 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl.go @@ -162,6 +162,32 @@ func (c *clientImpl) decrRef() int32 { return atomic.AddInt32(&c.refCount, -1) } +func buildServerConfigs(bootstrapSC []*bootstrap.ServerConfig, grpcTransportConfigs map[string]grpctransport.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) ([]xdsclient.ServerConfig, error) { + var gServerCfg []xdsclient.ServerConfig + for _, sc := range bootstrapSC { + if err := populateGRPCTransportConfigsFromServerConfig(sc, grpcTransportConfigs); err != nil { + return nil, err + } + var serverFeatures xdsclient.ServerFeature + if sc.ServerFeaturesIgnoreResourceDeletion() { + serverFeatures = serverFeatures | xdsclient.ServerFeatureIgnoreResourceDeletion + } + if sc.ServerFeaturesTrustedXDSServer() { + serverFeatures = serverFeatures | xdsclient.ServerFeatureTrustedXDSServer + } + gsc := xdsclient.ServerConfig{ + ServerIdentifier: clients.ServerIdentifier{ + ServerURI: sc.ServerURI(), + Extensions: grpctransport.ServerIdentifierExtension{ConfigName: sc.SelectedChannelCreds().Type}, + }, + ServerFeature: serverFeatures, + } + gServerCfg = append(gServerCfg, gsc) + gServerCfgMap[gsc] = sc + } + return gServerCfg, nil +} + // buildXDSClientConfig builds the xdsclient.Config from the bootstrap.Config. func buildXDSClientConfig(config *bootstrap.Config, metricsRecorder estats.MetricsRecorder, target string, watchExpiryTimeout time.Duration) (xdsclient.Config, error) { grpcTransportConfigs := make(map[string]grpctransport.Config) @@ -175,30 +201,16 @@ func buildXDSClientConfig(config *bootstrap.Config, metricsRecorder estats.Metri if len(cfg.XDSServers) >= 1 { serverCfg = cfg.XDSServers } - var gServerCfg []xdsclient.ServerConfig - for _, sc := range serverCfg { - if err := populateGRPCTransportConfigsFromServerConfig(sc, grpcTransportConfigs); err != nil { - return xdsclient.Config{}, err - } - gsc := xdsclient.ServerConfig{ - ServerIdentifier: clients.ServerIdentifier{ServerURI: sc.ServerURI(), Extensions: grpctransport.ServerIdentifierExtension{ConfigName: sc.SelectedChannelCreds().Type}}, - IgnoreResourceDeletion: sc.ServerFeaturesIgnoreResourceDeletion()} - gServerCfg = append(gServerCfg, gsc) - gServerCfgMap[gsc] = sc + gsc, err := buildServerConfigs(serverCfg, grpcTransportConfigs, gServerCfgMap) + if err != nil { + return xdsclient.Config{}, err } - gAuthorities[name] = xdsclient.Authority{XDSServers: gServerCfg} + gAuthorities[name] = xdsclient.Authority{XDSServers: gsc} } - gServerCfgs := make([]xdsclient.ServerConfig, 0, len(config.XDSServers())) - for _, sc := range config.XDSServers() { - if err := populateGRPCTransportConfigsFromServerConfig(sc, grpcTransportConfigs); err != nil { - return xdsclient.Config{}, err - } - gsc := xdsclient.ServerConfig{ - ServerIdentifier: clients.ServerIdentifier{ServerURI: sc.ServerURI(), Extensions: grpctransport.ServerIdentifierExtension{ConfigName: sc.SelectedChannelCreds().Type}}, - IgnoreResourceDeletion: sc.ServerFeaturesIgnoreResourceDeletion()} - gServerCfgs = append(gServerCfgs, gsc) - gServerCfgMap[gsc] = sc + gServerCfgs, err := buildServerConfigs(config.XDSServers(), grpcTransportConfigs, gServerCfgMap) + if err != nil { + return xdsclient.Config{}, err } node := config.Node() diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl_watchers.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl_watchers.go deleted file mode 100644 index b90d3d36c66..00000000000 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/clientimpl_watchers.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright 2020 gRPC authors. - * - * 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 xdsclient - -import ( - "google.golang.org/grpc/internal/xds/clients/xdsclient" - "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" -) - -// WatchResource uses xDS to discover the resource associated with the provided -// resource name. The resource type implementation determines how xDS responses -// are are deserialized and validated, as received from the xDS management -// server. Upon receipt of a response from the management server, an -// appropriate callback on the watcher is invoked. -func (c *clientImpl) WatchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) (cancel func()) { - return c.XDSClient.WatchResource(rType.TypeURL(), resourceName, xdsresource.GenericResourceWatcher(watcher)) -} - -func (c *clientImpl) WatchResourceV2(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) { - return c.XDSClient.WatchResource(typeURL, resourceName, watcher) -} diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/resource_types.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/resource_types.go index a044eedf829..29d1ed4cbf4 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/resource_types.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/resource_types.go @@ -36,19 +36,19 @@ func supportedResourceTypes(config *bootstrap.Config, gServerCfgMap map[xdsclien TypeURL: version.V3RouteConfigURL, TypeName: xdsresource.RouteConfigTypeName, AllResourcesRequiredInSotW: false, - Decoder: xdsresource.NewGenericRouteConfigResourceTypeDecoder(), + Decoder: xdsresource.NewRouteConfigResourceTypeDecoder(config), }, version.V3ClusterURL: { TypeURL: version.V3ClusterURL, TypeName: xdsresource.ClusterResourceTypeName, AllResourcesRequiredInSotW: true, - Decoder: xdsresource.NewGenericClusterResourceTypeDecoder(config, gServerCfgMap), + Decoder: xdsresource.NewClusterResourceTypeDecoder(config, gServerCfgMap), }, version.V3EndpointsURL: { TypeURL: version.V3EndpointsURL, TypeName: xdsresource.EndpointsResourceTypeName, AllResourcesRequiredInSotW: false, - Decoder: xdsresource.NewGenericEndpointsResourceTypeDecoder(), + Decoder: xdsresource.NewEndpointsResourceTypeDecoder(config), }, } } diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/cluster_resource_type.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/cluster_resource_type.go index 2a6a08f9064..af4e785b5a4 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/cluster_resource_type.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/cluster_resource_type.go @@ -18,12 +18,12 @@ package xdsresource import ( - "google.golang.org/grpc/internal/pretty" + "bytes" + "fmt" + "google.golang.org/grpc/internal/xds/bootstrap" xdsclient "google.golang.org/grpc/internal/xds/clients/xdsclient" "google.golang.org/grpc/internal/xds/xdsclient/xdsresource/version" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" ) const ( @@ -32,81 +32,62 @@ const ( ClusterResourceTypeName = "ClusterResource" ) -var ( - // Compile time interface checks. - _ Type = clusterResourceType{} - - // Singleton instantiation of the resource type implementation. - clusterType = clusterResourceType{ - resourceTypeState: resourceTypeState{ - typeURL: version.V3ClusterURL, - typeName: ClusterResourceTypeName, - allResourcesRequiredInSotW: true, - }, - } -) - -// clusterResourceType provides the resource-type specific functionality for a -// Cluster resource. -// -// Implements the Type interface. -type clusterResourceType struct { - resourceTypeState +// clusterResourceDecoder is an implementation of the xdsclient.Decoder +// interface for listener resources. +type clusterResourceDecoder struct { + bootstrapConfig *bootstrap.Config + serverConfigs map[xdsclient.ServerConfig]*bootstrap.ServerConfig } -// Decode deserializes and validates an xDS resource serialized inside the -// provided `Any` proto, as received from the xDS management server. -func (clusterResourceType) Decode(opts *DecodeOptions, resource *anypb.Any) (*DecodeResult, error) { - name, cluster, err := unmarshalClusterResource(resource, opts.ServerConfig) - switch { - case name == "": +func (d *clusterResourceDecoder) Decode(resource *xdsclient.AnyProto, opts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) { + serverCfg, ok := d.serverConfigs[*opts.ServerConfig] + if !ok { + return nil, fmt.Errorf("no server config found for {%+v}", opts.ServerConfig) + } + name, cluster, err := unmarshalClusterResource(resource.ToAny(), serverCfg) + if name == "" { // Name is unset only when protobuf deserialization fails. return nil, err - case err != nil: + } + if err != nil { // Protobuf deserialization succeeded, but resource validation failed. - return &DecodeResult{Name: name, Resource: &ClusterResourceData{Resource: ClusterUpdate{}}}, err + return &xdsclient.DecodeResult{ + Name: name, + Resource: &ClusterResourceData{Resource: ClusterUpdate{}}, + }, err } // Perform extra validation here. - if err := securityConfigValidator(opts.BootstrapConfig, cluster.SecurityCfg); err != nil { - return &DecodeResult{Name: name, Resource: &ClusterResourceData{Resource: ClusterUpdate{}}}, err + if err := securityConfigValidator(d.bootstrapConfig, cluster.SecurityCfg); err != nil { + return &xdsclient.DecodeResult{ + Name: name, + Resource: &ClusterResourceData{Resource: ClusterUpdate{}}, + }, err } - return &DecodeResult{Name: name, Resource: &ClusterResourceData{Resource: cluster}}, nil - + return &xdsclient.DecodeResult{ + Name: name, + Resource: &ClusterResourceData{Resource: cluster}, + }, nil } // ClusterResourceData wraps the configuration of a Cluster resource as received // from the management server. -// -// Implements the ResourceData interface. type ClusterResourceData struct { - ResourceData - - // TODO: We have always stored update structs by value. See if this can be - // switched to a pointer? Resource ClusterUpdate } -// RawEqual returns true if other is equal to r. -func (c *ClusterResourceData) RawEqual(other ResourceData) bool { - if c == nil && other == nil { - return true - } - if (c == nil) != (other == nil) { +// Equal returns true if other is equal to c. +func (c *ClusterResourceData) Equal(other xdsclient.ResourceData) bool { + if other == nil { return false } - return proto.Equal(c.Resource.Raw, other.Raw()) -} - -// ToJSON returns a JSON string representation of the resource data. -func (c *ClusterResourceData) ToJSON() string { - return pretty.ToJSON(c.Resource) + return bytes.Equal(c.Bytes(), other.Bytes()) } -// Raw returns the underlying raw protobuf form of the cluster resource. -func (c *ClusterResourceData) Raw() *anypb.Any { - return c.Resource.Raw +// Bytes returns the protobuf serialized bytes of the cluster resource proto. +func (c *ClusterResourceData) Bytes() []byte { + return c.Resource.Raw.GetValue() } // ClusterWatcher wraps the callbacks to be invoked for different events @@ -114,7 +95,7 @@ func (c *ClusterResourceData) Raw() *anypb.Any { // exhaustive list of what method is invoked under what conditions. type ClusterWatcher interface { // ResourceChanged indicates a new version of the resource is available. - ResourceChanged(resource *ClusterResourceData, done func()) + ResourceChanged(resource *ClusterUpdate, done func()) // ResourceError indicates an error occurred while trying to fetch or // decode the associated resource. The previous version of the resource @@ -133,9 +114,9 @@ type delegatingClusterWatcher struct { watcher ClusterWatcher } -func (d *delegatingClusterWatcher) ResourceChanged(data ResourceData, onDone func()) { +func (d *delegatingClusterWatcher) ResourceChanged(data xdsclient.ResourceData, onDone func()) { c := data.(*ClusterResourceData) - d.watcher.ResourceChanged(c, onDone) + d.watcher.ResourceChanged(&c.Resource, onDone) } func (d *delegatingClusterWatcher) ResourceError(err error, onDone func()) { @@ -149,12 +130,11 @@ func (d *delegatingClusterWatcher) AmbientError(err error, onDone func()) { // WatchCluster uses xDS to discover the configuration associated with the // provided cluster resource name. func WatchCluster(p Producer, name string, w ClusterWatcher) (cancel func()) { - delegator := &delegatingClusterWatcher{watcher: w} - return p.WatchResource(clusterType, name, delegator) + return p.WatchResource(version.V3ClusterURL, name, &delegatingClusterWatcher{watcher: w}) } -// NewGenericClusterResourceTypeDecoder returns a xdsclient.Decoder that -// wraps the xdsresource.clusterType. -func NewGenericClusterResourceTypeDecoder(bc *bootstrap.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) xdsclient.Decoder { - return &GenericResourceTypeDecoder{ResourceType: clusterType, BootstrapConfig: bc, ServerConfigMap: gServerCfgMap} +// NewClusterResourceTypeDecoder returns a xdsclient.Decoder that wraps +// the xdsresource.clusterType. +func NewClusterResourceTypeDecoder(bc *bootstrap.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) xdsclient.Decoder { + return &clusterResourceDecoder{bootstrapConfig: bc, serverConfigs: gServerCfgMap} } diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/endpoints_resource_type.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/endpoints_resource_type.go index 7ca45ec6ad0..cf72c49574a 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/endpoints_resource_type.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/endpoints_resource_type.go @@ -18,11 +18,11 @@ package xdsresource import ( - "google.golang.org/grpc/internal/pretty" + "bytes" + + "google.golang.org/grpc/internal/xds/bootstrap" xdsclient "google.golang.org/grpc/internal/xds/clients/xdsclient" "google.golang.org/grpc/internal/xds/xdsclient/xdsresource/version" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" ) const ( @@ -31,77 +31,49 @@ const ( EndpointsResourceTypeName = "EndpointsResource" ) -var ( - // Compile time interface checks. - _ Type = endpointsResourceType{} - - // Singleton instantiation of the resource type implementation. - endpointsType = endpointsResourceType{ - resourceTypeState: resourceTypeState{ - typeURL: version.V3EndpointsURL, - typeName: "EndpointsResource", - allResourcesRequiredInSotW: false, - }, - } -) - -// endpointsResourceType provides the resource-type specific functionality for a -// ClusterLoadAssignment (or Endpoints) resource. -// -// Implements the Type interface. -type endpointsResourceType struct { - resourceTypeState +// endpointsResourceDecoder is an implementation of the xdsclient.Decoder +// interface for endpoints resources. +type endpointsResourceDecoder struct { + bootstrapConfig *bootstrap.Config } -// Decode deserializes and validates an xDS resource serialized inside the -// provided `Any` proto, as received from the xDS management server. -func (endpointsResourceType) Decode(_ *DecodeOptions, resource *anypb.Any) (*DecodeResult, error) { - name, rc, err := unmarshalEndpointsResource(resource) - switch { - case name == "": +func (d *endpointsResourceDecoder) Decode(resource *xdsclient.AnyProto, _ xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) { + name, endpoints, err := unmarshalEndpointsResource(resource.ToAny()) + if name == "" { // Name is unset only when protobuf deserialization fails. return nil, err - case err != nil: + } + if err != nil { // Protobuf deserialization succeeded, but resource validation failed. - return &DecodeResult{Name: name, Resource: &EndpointsResourceData{Resource: EndpointsUpdate{}}}, err + return &xdsclient.DecodeResult{ + Name: name, + Resource: &ListenerResourceData{Resource: ListenerUpdate{}}, + }, err } - return &DecodeResult{Name: name, Resource: &EndpointsResourceData{Resource: rc}}, nil - + return &xdsclient.DecodeResult{ + Name: name, + Resource: &EndpointsResourceData{Resource: endpoints}, + }, nil } -// EndpointsResourceData wraps the configuration of an Endpoints resource as -// received from the management server. -// -// Implements the ResourceData interface. +// EndpointsResourceData is an implementation of the xdsclient.ResourceData +// interface for endpoints resources. type EndpointsResourceData struct { - ResourceData - - // TODO: We have always stored update structs by value. See if this can be - // switched to a pointer? Resource EndpointsUpdate } -// RawEqual returns true if other is equal to r. -func (e *EndpointsResourceData) RawEqual(other ResourceData) bool { - if e == nil && other == nil { - return true - } - if (e == nil) != (other == nil) { +// Equal returns true if other is equal to e. +func (e *EndpointsResourceData) Equal(other xdsclient.ResourceData) bool { + if other == nil { return false } - return proto.Equal(e.Resource.Raw, other.Raw()) - -} - -// ToJSON returns a JSON string representation of the resource data. -func (e *EndpointsResourceData) ToJSON() string { - return pretty.ToJSON(e.Resource) + return bytes.Equal(e.Bytes(), other.Bytes()) } -// Raw returns the underlying raw protobuf form of the listener resource. -func (e *EndpointsResourceData) Raw() *anypb.Any { - return e.Resource.Raw +// Bytes returns the protobuf serialized bytes of the listener resource proto. +func (e *EndpointsResourceData) Bytes() []byte { + return e.Resource.Raw.GetValue() } // EndpointsWatcher wraps the callbacks to be invoked for different @@ -109,7 +81,7 @@ func (e *EndpointsResourceData) Raw() *anypb.Any { // contains an exhaustive list of what method is invoked under what conditions. type EndpointsWatcher interface { // ResourceChanged indicates a new version of the resource is available. - ResourceChanged(resource *EndpointsResourceData, done func()) + ResourceChanged(resource *EndpointsUpdate, done func()) // ResourceError indicates an error occurred while trying to fetch or // decode the associated resource. The previous version of the resource @@ -128,9 +100,9 @@ type delegatingEndpointsWatcher struct { watcher EndpointsWatcher } -func (d *delegatingEndpointsWatcher) ResourceChanged(data ResourceData, onDone func()) { +func (d *delegatingEndpointsWatcher) ResourceChanged(data xdsclient.ResourceData, onDone func()) { e := data.(*EndpointsResourceData) - d.watcher.ResourceChanged(e, onDone) + d.watcher.ResourceChanged(&e.Resource, onDone) } func (d *delegatingEndpointsWatcher) ResourceError(err error, onDone func()) { @@ -144,12 +116,11 @@ func (d *delegatingEndpointsWatcher) AmbientError(err error, onDone func()) { // WatchEndpoints uses xDS to discover the configuration associated with the // provided endpoints resource name. func WatchEndpoints(p Producer, name string, w EndpointsWatcher) (cancel func()) { - delegator := &delegatingEndpointsWatcher{watcher: w} - return p.WatchResource(endpointsType, name, delegator) + return p.WatchResource(version.V3EndpointsURL, name, &delegatingEndpointsWatcher{watcher: w}) } -// NewGenericEndpointsResourceTypeDecoder returns a xdsclient.Decoder that -// wraps the xdsresource.endpointsType. -func NewGenericEndpointsResourceTypeDecoder() xdsclient.Decoder { - return &GenericResourceTypeDecoder{ResourceType: endpointsType} +// NewEndpointsResourceTypeDecoder returns a xdsclient.Decoder that wraps +// the xdsresource.endpointsType. +func NewEndpointsResourceTypeDecoder(bc *bootstrap.Config) xdsclient.Decoder { + return &endpointsResourceDecoder{bootstrapConfig: bc} } diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/filter_chain.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/filter_chain.go index 76ace1090d6..50b72e0de6b 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/filter_chain.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/filter_chain.go @@ -680,7 +680,7 @@ func processNetworkFilters(filters []*v3listenerpb.Filter) (*FilterChain, error) // server-side." - A36 // Can specify v3 here, as will never get to this function // if v2. - routeU, err := generateRDSUpdateFromRouteConfiguration(hcm.GetRouteConfig()) + routeU, err := generateRDSUpdateFromRouteConfiguration(hcm.GetRouteConfig(), nil) if err != nil { return nil, fmt.Errorf("failed to parse inline RDS resp: %v", err) } diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/listener_resource_type.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/listener_resource_type.go index a1e1c672c88..2b9000fdf2b 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/listener_resource_type.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/listener_resource_type.go @@ -35,8 +35,8 @@ type listenerResourceDecoder struct { bootstrapConfig *bootstrap.Config } -func (d *listenerResourceDecoder) Decode(resource *xdsclient.AnyProto, _ xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) { - name, listener, err := unmarshalListenerResource(resource.ToAny()) +func (d *listenerResourceDecoder) Decode(resource *xdsclient.AnyProto, opts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) { + name, listener, err := unmarshalListenerResource(resource.ToAny(), &opts) if name == "" { // Name is unset only when protobuf deserialization fails. return nil, err @@ -149,8 +149,8 @@ func (d *delegatingListenerWatcher) AmbientError(err error, onDone func()) { // WatchListener uses xDS to discover the configuration associated with the // provided listener resource name. -func WatchListener(p ProducerV2, name string, w ListenerWatcher) (cancel func()) { - return p.WatchResourceV2(version.V3ListenerURL, name, &delegatingListenerWatcher{watcher: w}) +func WatchListener(p Producer, name string, w ListenerWatcher) (cancel func()) { + return p.WatchResource(version.V3ListenerURL, name, &delegatingListenerWatcher{watcher: w}) } // NewListenerResourceTypeDecoder returns a xdsclient.Decoder that wraps diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/resource_type.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/resource_type.go index aaa30cecfb1..05f0d58f50e 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/resource_type.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/resource_type.go @@ -25,8 +25,6 @@ package xdsresource import ( - "fmt" - "google.golang.org/grpc/internal/xds/bootstrap" "google.golang.org/grpc/internal/xds/clients/xdsclient" "google.golang.org/protobuf/types/known/anypb" @@ -42,16 +40,7 @@ type Producer interface { // xDS responses are are deserialized and validated, as received from the // xDS management server. Upon receipt of a response from the management // server, an appropriate callback on the watcher is invoked. - WatchResource(rType Type, resourceName string, watcher ResourceWatcher) (cancel func()) -} - -// ProducerV2 is like Producer, but uses the external xdsclient API. -// -// Once all resource type implementations have been migrated to use the external -// xdsclient API, this interface will be renamed to Producer and the existing -// Producer interface will be deleted. -type ProducerV2 interface { - WatchResourceV2(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) + WatchResource(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func()) } // ResourceWatcher is notified of the resource updates and errors that are @@ -148,136 +137,3 @@ type DecodeResult struct { // watched. Resource ResourceData } - -// resourceTypeState wraps the static state associated with concrete resource -// type implementations, which can then embed this struct and get the methods -// implemented here for free. -type resourceTypeState struct { - typeURL string - typeName string - allResourcesRequiredInSotW bool -} - -func (r resourceTypeState) TypeURL() string { - return r.typeURL -} - -func (r resourceTypeState) TypeName() string { - return r.typeName -} - -func (r resourceTypeState) AllResourcesRequiredInSotW() bool { - return r.allResourcesRequiredInSotW -} - -// GenericResourceTypeDecoder wraps an xdsresource.Type and implements -// xdsclient.Decoder. -// -// TODO: #8313 - Delete this once the internal xdsclient usages are updated -// to use the generic xdsclient.ResourceType interface directly. -type GenericResourceTypeDecoder struct { - ResourceType Type - BootstrapConfig *bootstrap.Config - ServerConfigMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig -} - -// Decode deserialize and validate resource bytes of an xDS resource received -// from the xDS management server. -func (gd *GenericResourceTypeDecoder) Decode(resource *xdsclient.AnyProto, gOpts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) { - opts := &DecodeOptions{BootstrapConfig: gd.BootstrapConfig} - if gOpts.ServerConfig != nil { - opts.ServerConfig = gd.ServerConfigMap[*gOpts.ServerConfig] - } - - result, err := gd.ResourceType.Decode(opts, resource.ToAny()) - if result == nil { - return nil, err - } - if err != nil { - return &xdsclient.DecodeResult{Name: result.Name}, err - } - - return &xdsclient.DecodeResult{Name: result.Name, Resource: &genericResourceData{resourceData: result.Resource}}, nil -} - -// genericResourceData embed an xdsresource.ResourceData and implements -// xdsclient.ResourceData. -// -// TODO: #8313 - Delete this once the internal xdsclient usages are updated -// to use the generic xdsclient.ResourceData interface directly. -type genericResourceData struct { - resourceData ResourceData -} - -// Equal returns true if the passed in xdsclient.ResourceData -// is equal to that of the receiver. -func (grd *genericResourceData) Equal(other xdsclient.ResourceData) bool { - if other == nil { - return false - } - otherResourceData, ok := other.(*genericResourceData) - if !ok { - return false - } - return grd.resourceData.RawEqual(otherResourceData.resourceData) -} - -// Bytes returns the underlying raw bytes of the wrapped resource. -func (grd *genericResourceData) Bytes() []byte { - rawAny := grd.resourceData.Raw() - if rawAny == nil { - return nil - } - return rawAny.Value -} - -// genericResourceWatcher wraps xdsresource.ResourceWatcher and implements -// xdsclient.ResourceWatcher. -// -// TODO: #8313 - Delete this once the internal xdsclient usages are updated -// to use the generic xdsclient.ResourceWatcher interface directly. -type genericResourceWatcher struct { - xdsResourceWatcher ResourceWatcher -} - -// ResourceChanged indicates a new version of the wrapped resource is -// available. -func (gw *genericResourceWatcher) ResourceChanged(gData xdsclient.ResourceData, done func()) { - if gData == nil { - gw.xdsResourceWatcher.ResourceChanged(nil, done) - return - } - - grd, ok := gData.(*genericResourceData) - if !ok { - err := fmt.Errorf("genericResourceWatcher received unexpected xdsclient.ResourceData type %T, want *genericResourceData", gData) - gw.xdsResourceWatcher.ResourceError(err, done) - return - } - gw.xdsResourceWatcher.ResourceChanged(grd.resourceData, done) -} - -// ResourceError indicates an error occurred while trying to fetch or -// decode the associated wrapped resource. The previous version of the -// wrapped resource should be considered invalid. -func (gw *genericResourceWatcher) ResourceError(err error, done func()) { - gw.xdsResourceWatcher.ResourceError(err, done) -} - -// AmbientError indicates an error occurred after a resource has been -// received that should not modify the use of that wrapped resource but may -// provide useful information about the state of the XDSClient for debugging -// purposes. The previous version of the wrapped resource should still be -// considered valid. -func (gw *genericResourceWatcher) AmbientError(err error, done func()) { - gw.xdsResourceWatcher.AmbientError(err, done) -} - -// GenericResourceWatcher returns a xdsclient.ResourceWatcher that wraps an -// xdsresource.ResourceWatcher to make it compatible with xdsclient.ResourceWatcher. -func GenericResourceWatcher(xdsResourceWatcher ResourceWatcher) xdsclient.ResourceWatcher { - if xdsResourceWatcher == nil { - return nil - } - return &genericResourceWatcher{xdsResourceWatcher: xdsResourceWatcher} -} diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/route_config_resource_type.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/route_config_resource_type.go index 912dc1b762b..1104fe9f2b4 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/route_config_resource_type.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/route_config_resource_type.go @@ -18,11 +18,11 @@ package xdsresource import ( - "google.golang.org/grpc/internal/pretty" + "bytes" + + "google.golang.org/grpc/internal/xds/bootstrap" xdsclient "google.golang.org/grpc/internal/xds/clients/xdsclient" "google.golang.org/grpc/internal/xds/xdsclient/xdsresource/version" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" ) const ( @@ -31,78 +31,49 @@ const ( RouteConfigTypeName = "RouteConfigResource" ) -var ( - // Compile time interface checks. - _ Type = routeConfigResourceType{} - - // Singleton instantiation of the resource type implementation. - routeConfigType = routeConfigResourceType{ - resourceTypeState: resourceTypeState{ - typeURL: version.V3RouteConfigURL, - typeName: "RouteConfigResource", - allResourcesRequiredInSotW: false, - }, - } -) - -// routeConfigResourceType provides the resource-type specific functionality for -// a RouteConfiguration resource. -// -// Implements the Type interface. -type routeConfigResourceType struct { - resourceTypeState +// routeConfigResourceDecoder is an implementation of the xdsclient.Decoder +// interface for route configuration resources. +type routeConfigResourceDecoder struct { + bootstrapConfig *bootstrap.Config } -// Decode deserializes and validates an xDS resource serialized inside the -// provided `Any` proto, as received from the xDS management server. -func (routeConfigResourceType) Decode(_ *DecodeOptions, resource *anypb.Any) (*DecodeResult, error) { - name, rc, err := unmarshalRouteConfigResource(resource) - switch { - case name == "": +func (d *routeConfigResourceDecoder) Decode(resource *xdsclient.AnyProto, opts xdsclient.DecodeOptions) (*xdsclient.DecodeResult, error) { + name, rc, err := unmarshalRouteConfigResource(resource.ToAny(), &opts) + if name == "" { // Name is unset only when protobuf deserialization fails. return nil, err - case err != nil: + } + if err != nil { // Protobuf deserialization succeeded, but resource validation failed. - return &DecodeResult{Name: name, Resource: &RouteConfigResourceData{Resource: RouteConfigUpdate{}}}, err + return &xdsclient.DecodeResult{ + Name: name, + Resource: &RouteConfigResourceData{Resource: RouteConfigUpdate{}}, + }, err } - return &DecodeResult{Name: name, Resource: &RouteConfigResourceData{Resource: rc}}, nil - + return &xdsclient.DecodeResult{ + Name: name, + Resource: &RouteConfigResourceData{Resource: rc}, + }, nil } -// RouteConfigResourceData wraps the configuration of a RouteConfiguration -// resource as received from the management server. -// -// Implements the ResourceData interface. +// RouteConfigResourceData is an implementation of the xdsclient.ResourceData +// interface for route configuration resources. type RouteConfigResourceData struct { - ResourceData - - // TODO: We have always stored update structs by value. See if this can be - // switched to a pointer? Resource RouteConfigUpdate } -// RawEqual returns true if other is equal to r. -func (r *RouteConfigResourceData) RawEqual(other ResourceData) bool { - if r == nil && other == nil { - return true - } - if (r == nil) != (other == nil) { +// Equal returns true if other is equal to er. +func (r *RouteConfigResourceData) Equal(other xdsclient.ResourceData) bool { + if other == nil { return false } - return proto.Equal(r.Resource.Raw, other.Raw()) - -} - -// ToJSON returns a JSON string representation of the resource data. -func (r *RouteConfigResourceData) ToJSON() string { - return pretty.ToJSON(r.Resource) + return bytes.Equal(r.Bytes(), other.Bytes()) } -// Raw returns the underlying raw protobuf form of the route configuration -// resource. -func (r *RouteConfigResourceData) Raw() *anypb.Any { - return r.Resource.Raw +// Bytes returns the protobuf serialized bytes of the route config resource proto. +func (r *RouteConfigResourceData) Bytes() []byte { + return r.Resource.Raw.GetValue() } // RouteConfigWatcher wraps the callbacks to be invoked for different @@ -111,7 +82,7 @@ func (r *RouteConfigResourceData) Raw() *anypb.Any { // conditions. type RouteConfigWatcher interface { // ResourceChanged indicates a new version of the resource is available. - ResourceChanged(resource *RouteConfigResourceData, done func()) + ResourceChanged(resource *RouteConfigUpdate, done func()) // ResourceError indicates an error occurred while trying to fetch or // decode the associated resource. The previous version of the resource @@ -130,9 +101,9 @@ type delegatingRouteConfigWatcher struct { watcher RouteConfigWatcher } -func (d *delegatingRouteConfigWatcher) ResourceChanged(data ResourceData, onDone func()) { +func (d *delegatingRouteConfigWatcher) ResourceChanged(data xdsclient.ResourceData, onDone func()) { rc := data.(*RouteConfigResourceData) - d.watcher.ResourceChanged(rc, onDone) + d.watcher.ResourceChanged(&rc.Resource, onDone) } func (d *delegatingRouteConfigWatcher) ResourceError(err error, onDone func()) { @@ -146,12 +117,11 @@ func (d *delegatingRouteConfigWatcher) AmbientError(err error, onDone func()) { // WatchRouteConfig uses xDS to discover the configuration associated with the // provided route configuration resource name. func WatchRouteConfig(p Producer, name string, w RouteConfigWatcher) (cancel func()) { - delegator := &delegatingRouteConfigWatcher{watcher: w} - return p.WatchResource(routeConfigType, name, delegator) + return p.WatchResource(version.V3RouteConfigURL, name, &delegatingRouteConfigWatcher{watcher: w}) } -// NewGenericRouteConfigResourceTypeDecoder returns a xdsclient.Decoder that -// wraps the xdsresource.routeConfigType. -func NewGenericRouteConfigResourceTypeDecoder() xdsclient.Decoder { - return &GenericResourceTypeDecoder{ResourceType: routeConfigType} +// NewRouteConfigResourceTypeDecoder returns a xdsclient.Decoder that wraps +// the xdsresource.routeConfigType. +func NewRouteConfigResourceTypeDecoder(bc *bootstrap.Config) xdsclient.Decoder { + return &routeConfigResourceDecoder{bootstrapConfig: bc} } diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_eds.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_eds.go index a8d568e1826..39b2ba74ddc 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_eds.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_eds.go @@ -54,6 +54,7 @@ type Endpoint struct { Weight uint32 HashKey string Metadata map[string]any + Hostname string } // Locality contains information of a locality. diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_rds.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_rds.go index 0cde9738d5f..48e8051b322 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_rds.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/type_rds.go @@ -150,6 +150,9 @@ type Route struct { // ClusterSpecifierPlugin is the name of the Cluster Specifier Plugin that // this Route is linked to, if specified by xDS. ClusterSpecifierPlugin string + // AutoHostRewrite indicates that the ":authority" header can be rewritten + // to the hostname of the upstream endpoint. + AutoHostRewrite bool } // WeightedCluster contains settings for an xds ActionType.WeightedCluster. diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_eds.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_eds.go index c5b9723a79a..ebf47961c45 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_eds.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_eds.go @@ -132,6 +132,7 @@ func parseEndpoints(lbEndpoints []*v3endpointpb.LbEndpoint, uniqueEndpointAddrs Weight: weight, HashKey: hashKey, Metadata: endpointMetadata, + Hostname: lbEndpoint.GetEndpoint().GetHostname(), }) } return endpoints, nil diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_lds.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_lds.go index 25c607b48a4..604c086ba42 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_lds.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_lds.go @@ -27,12 +27,13 @@ import ( v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3" + "google.golang.org/grpc/internal/xds/clients/xdsclient" "google.golang.org/grpc/internal/xds/httpfilter" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" ) -func unmarshalListenerResource(r *anypb.Any) (string, ListenerUpdate, error) { +func unmarshalListenerResource(r *anypb.Any, opts *xdsclient.DecodeOptions) (string, ListenerUpdate, error) { r, err := UnwrapResource(r) if err != nil { return "", ListenerUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err) @@ -46,7 +47,7 @@ func unmarshalListenerResource(r *anypb.Any) (string, ListenerUpdate, error) { return "", ListenerUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err) } - lu, err := processListener(lis) + lu, err := processListener(lis, opts) if err != nil { return lis.GetName(), ListenerUpdate{}, err } @@ -54,16 +55,16 @@ func unmarshalListenerResource(r *anypb.Any) (string, ListenerUpdate, error) { return lis.GetName(), *lu, nil } -func processListener(lis *v3listenerpb.Listener) (*ListenerUpdate, error) { +func processListener(lis *v3listenerpb.Listener, opts *xdsclient.DecodeOptions) (*ListenerUpdate, error) { if lis.GetApiListener() != nil { - return processClientSideListener(lis) + return processClientSideListener(lis, opts) } return processServerSideListener(lis) } // processClientSideListener checks if the provided Listener proto meets // the expected criteria. If so, it returns a non-empty routeConfigName. -func processClientSideListener(lis *v3listenerpb.Listener) (*ListenerUpdate, error) { +func processClientSideListener(lis *v3listenerpb.Listener, opts *xdsclient.DecodeOptions) (*ListenerUpdate, error) { update := &ListenerUpdate{} apiLisAny := lis.GetApiListener().GetApiListener() @@ -95,7 +96,7 @@ func processClientSideListener(lis *v3listenerpb.Listener) (*ListenerUpdate, err } update.RouteConfigName = name case *v3httppb.HttpConnectionManager_RouteConfig: - routeU, err := generateRDSUpdateFromRouteConfiguration(apiLis.GetRouteConfig()) + routeU, err := generateRDSUpdateFromRouteConfiguration(apiLis.GetRouteConfig(), opts) if err != nil { return nil, fmt.Errorf("failed to parse inline RDS resp: %v", err) } diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_rds.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_rds.go index 479d023f40a..d988b4e77f9 100644 --- a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_rds.go +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/unmarshal_rds.go @@ -25,6 +25,8 @@ import ( "time" "google.golang.org/grpc/codes" + "google.golang.org/grpc/internal/envconfig" + "google.golang.org/grpc/internal/xds/clients/xdsclient" "google.golang.org/grpc/internal/xds/clusterspecifier" "google.golang.org/grpc/internal/xds/matcher" "google.golang.org/protobuf/proto" @@ -34,7 +36,7 @@ import ( v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3" ) -func unmarshalRouteConfigResource(r *anypb.Any) (string, RouteConfigUpdate, error) { +func unmarshalRouteConfigResource(r *anypb.Any, opts *xdsclient.DecodeOptions) (string, RouteConfigUpdate, error) { r, err := UnwrapResource(r) if err != nil { return "", RouteConfigUpdate{}, fmt.Errorf("failed to unwrap resource: %v", err) @@ -48,7 +50,7 @@ func unmarshalRouteConfigResource(r *anypb.Any) (string, RouteConfigUpdate, erro return "", RouteConfigUpdate{}, fmt.Errorf("failed to unmarshal resource: %v", err) } - u, err := generateRDSUpdateFromRouteConfiguration(rc) + u, err := generateRDSUpdateFromRouteConfiguration(rc, opts) if err != nil { return rc.GetName(), RouteConfigUpdate{}, err } @@ -67,12 +69,12 @@ func unmarshalRouteConfigResource(r *anypb.Any) (string, RouteConfigUpdate, erro // The RouteConfiguration includes a list of virtualHosts, which may have zero // or more elements. We are interested in the element whose domains field // matches the server name specified in the "xds:" URI. The only field in the -// VirtualHost proto that the we are interested in is the list of routes. We +// VirtualHost proto that we are interested in is the list of routes. We // only look at the last route in the list (the default route), whose match -// field must be empty and whose route field must be set. Inside that route +// field must be empty and whose route field must be set. Inside that route // message, the cluster field will contain the clusterName or weighted clusters // we are looking for. -func generateRDSUpdateFromRouteConfiguration(rc *v3routepb.RouteConfiguration) (RouteConfigUpdate, error) { +func generateRDSUpdateFromRouteConfiguration(rc *v3routepb.RouteConfiguration, opts *xdsclient.DecodeOptions) (RouteConfigUpdate, error) { vhs := make([]*VirtualHost, 0, len(rc.GetVirtualHosts())) csps, err := processClusterSpecifierPlugins(rc.ClusterSpecifierPlugins) if err != nil { @@ -83,7 +85,7 @@ func generateRDSUpdateFromRouteConfiguration(rc *v3routepb.RouteConfiguration) ( // ignored and not emitted by the xdsclient. var cspNames = make(map[string]bool) for _, vh := range rc.GetVirtualHosts() { - routes, cspNs, err := routesProtoToSlice(vh.Routes, csps) + routes, cspNs, err := routesProtoToSlice(vh.Routes, csps, opts) if err != nil { return RouteConfigUpdate{}, fmt.Errorf("received route is invalid: %v", err) } @@ -206,7 +208,7 @@ func generateRetryConfig(rp *v3routepb.RetryPolicy) (*RetryConfig, error) { return cfg, nil } -func routesProtoToSlice(routes []*v3routepb.Route, csps map[string]clusterspecifier.BalancerConfig) ([]*Route, map[string]bool, error) { +func routesProtoToSlice(routes []*v3routepb.Route, csps map[string]clusterspecifier.BalancerConfig, opts *xdsclient.DecodeOptions) ([]*Route, map[string]bool, error) { var routesRet []*Route var cspNames = make(map[string]bool) for _, r := range routes { @@ -302,6 +304,12 @@ func routesProtoToSlice(routes []*v3routepb.Route, csps map[string]clusterspecif case *v3routepb.Route_Route: action := r.GetRoute() + if envconfig.XDSAuthorityRewrite { + if opts != nil && opts.ServerConfig != nil && opts.ServerConfig.SupportsServerFeature(xdsclient.ServerFeatureTrustedXDSServer) { + route.AutoHostRewrite = action.GetAutoHostRewrite().GetValue() + } + } + // Hash Policies are only applicable for a Ring Hash LB. hp, err := hashPoliciesProtoToSlice(action.HashPolicy) if err != nil { diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/xdsconfig.go b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/xdsconfig.go new file mode 100644 index 00000000000..5c13714a26b --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/xds/xdsclient/xdsresource/xdsconfig.go @@ -0,0 +1,114 @@ +/* + * + * Copyright 2025 gRPC authors. + * + * 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 xdsresource + +import "google.golang.org/grpc/resolver" + +// XDSConfig holds the complete gRPC client-side xDS configuration containing +// all necessary resources. +type XDSConfig struct { + // Listener holds the listener configuration. It is guaranteed to be + // non-nil. + Listener *ListenerUpdate + + // RouteConfig holds the route configuration. It will be populated even if + // the route configuration was inlined into the Listener resource. It is + // guaranteed to be non-nil. + RouteConfig *RouteConfigUpdate + + // VirtualHost is selected from the route configuration whose domain field + // offers the best match against the provided dataplane authority. It is + // guaranteed to be non-nil. + VirtualHost *VirtualHost + + // Clusters is a map from cluster name to its configuration. + Clusters map[string]*ClusterResult +} + +// ClusterResult contains a cluster's configuration when a valid resource is +// received from the management server. It contains an error when: +// - an invalid resource is received from the management server and +// a valid resource was not already present or +// - the cluster resource does not exist on the management server +type ClusterResult struct { + Config ClusterConfig + Err error +} + +// ClusterConfig contains configuration for a single cluster. +type ClusterConfig struct { + // Cluster configuration for the cluster. This field is always set to a + // non-nil value. + Cluster *ClusterUpdate + // EndpointConfig contains endpoint configuration for a leaf cluster. This + // field is only set for EDS and LOGICAL_DNS clusters. + EndpointConfig *EndpointConfig + // AggregateConfig contains configuration for an aggregate cluster. This + // field is only set for AGGREGATE clusters. + AggregateConfig *AggregateConfig +} + +// AggregateConfig holds the configuration for an aggregate cluster. +type AggregateConfig struct { + // LeafClusters contains a prioritized list of names of the leaf clusters + // for the cluster. + LeafClusters []string +} + +// EndpointConfig contains configuration corresponding to the endpoints in a +// cluster. Only one of EDSUpdate or DNSEndpoints will be populated based on the +// cluster type. +type EndpointConfig struct { + // Endpoint configurartion for the EDS clusters. + EDSUpdate *EndpointsUpdate + // Endpoint configuration for the LOGICAL_DNS clusters. + DNSEndpoints *DNSUpdate + // ResolutionNote stores error encountered while obtaining endpoints data + // for the cluster. It will contain a nil value when a valid endpoint data is + // received. It contains an error when: + // - an invalid resource is received from the management server or + // - the endpoint resource does not exist on the management server + ResolutionNote error +} + +// DNSUpdate represents the result of a DNS resolution, containing a list of +// discovered endpoints. +type DNSUpdate struct { + // Endpoints is the complete list of endpoints returned by the DNS resolver. + Endpoints []resolver.Endpoint +} + +// xdsConfigkey is the type used as the key to store XDSConfig in the Attributes +// field of resolver.State. +type xdsConfigkey struct{} + +// SetXDSConfig returns a copy of state in which the Attributes field is updated +// with the XDSConfig. +func SetXDSConfig(state resolver.State, config *XDSConfig) resolver.State { + state.Attributes = state.Attributes.WithValue(xdsConfigkey{}, config) + return state +} + +// XDSConfigFromResolverState returns XDSConfig stored as an attribute in the +// resolver state. +func XDSConfigFromResolverState(state resolver.State) *XDSConfig { + if v := state.Attributes.Value(xdsConfigkey{}); v != nil { + return v.(*XDSConfig) + } + return nil +} diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/watch_service.go b/vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/watch_service.go new file mode 100644 index 00000000000..73f1b703519 --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/watch_service.go @@ -0,0 +1,83 @@ +/* + * + * Copyright 2025 gRPC authors. + * + * 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 xdsdepmgr + +import "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" + +type listenerWatcher struct { + resourceName string + cancel func() + depMgr *DependencyManager +} + +func newListenerWatcher(resourceName string, depMgr *DependencyManager) *listenerWatcher { + lw := &listenerWatcher{resourceName: resourceName, depMgr: depMgr} + lw.cancel = xdsresource.WatchListener(depMgr.xdsClient, resourceName, lw) + return lw +} + +func (l *listenerWatcher) ResourceChanged(update *xdsresource.ListenerUpdate, onDone func()) { + l.depMgr.onListenerResourceUpdate(update, onDone) +} + +func (l *listenerWatcher) ResourceError(err error, onDone func()) { + l.depMgr.onListenerResourceError(err, onDone) +} + +func (l *listenerWatcher) AmbientError(err error, onDone func()) { + l.depMgr.onListenerResourceAmbientError(err, onDone) +} + +func (l *listenerWatcher) stop() { + l.cancel() + if l.depMgr.logger.V(2) { + l.depMgr.logger.Infof("Canceling watch on Listener resource %q", l.resourceName) + } +} + +type routeConfigWatcher struct { + resourceName string + cancel func() + depMgr *DependencyManager +} + +func newRouteConfigWatcher(resourceName string, depMgr *DependencyManager) *routeConfigWatcher { + rw := &routeConfigWatcher{resourceName: resourceName, depMgr: depMgr} + rw.cancel = xdsresource.WatchRouteConfig(depMgr.xdsClient, resourceName, rw) + return rw +} + +func (r *routeConfigWatcher) ResourceChanged(u *xdsresource.RouteConfigUpdate, onDone func()) { + r.depMgr.onRouteConfigResourceUpdate(r.resourceName, u, onDone) +} + +func (r *routeConfigWatcher) ResourceError(err error, onDone func()) { + r.depMgr.onRouteConfigResourceError(r.resourceName, err, onDone) +} + +func (r *routeConfigWatcher) AmbientError(err error, onDone func()) { + r.depMgr.onRouteConfigResourceAmbientError(r.resourceName, err, onDone) +} + +func (r *routeConfigWatcher) stop() { + r.cancel() + if r.depMgr.logger.V(2) { + r.depMgr.logger.Infof("Canceling watch on RouteConfiguration resource %q", r.resourceName) + } +} diff --git a/vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/xds_dependency_manager.go b/vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/xds_dependency_manager.go new file mode 100644 index 00000000000..fae5ca962d4 --- /dev/null +++ b/vendor/google.golang.org/grpc/internal/xds/xdsdepmgr/xds_dependency_manager.go @@ -0,0 +1,279 @@ +/* + * Copyright 2025 gRPC authors. + * + * 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 xdsdepmgr provides the implementation of the xDS dependency manager +// that manages all the xDS watches and resources as described in gRFC A74. +package xdsdepmgr + +import ( + "fmt" + "sync" + + "google.golang.org/grpc/grpclog" + internalgrpclog "google.golang.org/grpc/internal/grpclog" + "google.golang.org/grpc/internal/xds/xdsclient" + "google.golang.org/grpc/internal/xds/xdsclient/xdsresource" +) + +const prefix = "[xdsdepmgr %p] " + +var logger = grpclog.Component("xds") + +func prefixLogger(p *DependencyManager) *internalgrpclog.PrefixLogger { + return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(prefix, p)) +} + +// ConfigWatcher is the interface for consumers of aggregated xDS configuration +// from the DependencyManager. The only consumer of this configuration is +// currently the xDS resolver. +type ConfigWatcher interface { + // Update is invoked when a new, validated xDS configuration is available. + // + // Implementations must treat the received config as read-only and should + // not modify it. + Update(*xdsresource.XDSConfig) + + // Error is invoked when an error is received from the listener or route + // resource watcher. This includes cases where: + // - The listener or route resource watcher reports a resource error. + // - The received listener resource is a socket listener, not an API + // listener. TODO(i/8114): Implement this check. + // - The received route configuration does not contain a virtual host + // matching the channel's default authority. + Error(error) +} + +// DependencyManager registers watches on the xDS client for all required xDS +// resources, resolves dependencies between them, and returns a complete +// configuration to the xDS resolver. +type DependencyManager struct { + // The following fields are initialized at creation time and are read-only + // after that. + logger *internalgrpclog.PrefixLogger + watcher ConfigWatcher + xdsClient xdsclient.XDSClient + ldsResourceName string + dataplaneAuthority string + nodeID string + + // All the fields below are protected by mu. + mu sync.Mutex + stopped bool + + listenerWatcher *listenerWatcher + currentListenerUpdate *xdsresource.ListenerUpdate + routeConfigWatcher *routeConfigWatcher + rdsResourceName string + currentRouteConfig *xdsresource.RouteConfigUpdate + currentVirtualHost *xdsresource.VirtualHost +} + +// New creates a new DependencyManager. +// +// - listenerName is the name of the Listener resource to request from the +// management server. +// - dataplaneAuthority is used to select the best matching virtual host from +// the route configuration received from the management server. +// - xdsClient is the xDS client to use to register resource watches. +// - watcher is the ConfigWatcher interface that will receive the aggregated +// XDSConfig updates and errors. +func New(listenerName, dataplaneAuthority string, xdsClient xdsclient.XDSClient, watcher ConfigWatcher) *DependencyManager { + dm := &DependencyManager{ + ldsResourceName: listenerName, + dataplaneAuthority: dataplaneAuthority, + xdsClient: xdsClient, + watcher: watcher, + nodeID: xdsClient.BootstrapConfig().Node().GetId(), + } + dm.logger = prefixLogger(dm) + + // Start the listener watch. Listener watch will start the other resource + // watches as needed. + dm.listenerWatcher = newListenerWatcher(listenerName, dm) + return dm +} + +// Close cancels all registered resource watches. +func (m *DependencyManager) Close() { + m.mu.Lock() + defer m.mu.Unlock() + + if m.stopped { + return + } + + m.stopped = true + if m.listenerWatcher != nil { + m.listenerWatcher.stop() + } + if m.routeConfigWatcher != nil { + m.routeConfigWatcher.stop() + } +} + +// annotateErrorWithNodeID annotates the given error with the provided xDS node +// ID. +func (m *DependencyManager) annotateErrorWithNodeID(err error) error { + return fmt.Errorf("[xDS node id: %v]: %v", m.nodeID, err) +} + +// maybeSendUpdateLocked checks that all the resources have been received and sends +// the current aggregated xDS configuration to the watcher if all the updates +// are available. +func (m *DependencyManager) maybeSendUpdateLocked() { + m.watcher.Update(&xdsresource.XDSConfig{ + Listener: m.currentListenerUpdate, + RouteConfig: m.currentRouteConfig, + VirtualHost: m.currentVirtualHost, + }) +} + +func (m *DependencyManager) applyRouteConfigUpdateLocked(update *xdsresource.RouteConfigUpdate) { + matchVH := xdsresource.FindBestMatchingVirtualHost(m.dataplaneAuthority, update.VirtualHosts) + if matchVH == nil { + m.watcher.Error(m.annotateErrorWithNodeID(fmt.Errorf("could not find VirtualHost for %q", m.dataplaneAuthority))) + return + } + m.currentRouteConfig = update + m.currentVirtualHost = matchVH + m.maybeSendUpdateLocked() +} + +func (m *DependencyManager) onListenerResourceUpdate(update *xdsresource.ListenerUpdate, onDone func()) { + m.mu.Lock() + defer m.mu.Unlock() + + defer onDone() + if m.stopped { + return + } + + if m.logger.V(2) { + m.logger.Infof("Received update for Listener resource %q: %+v", m.ldsResourceName, update) + } + + m.currentListenerUpdate = update + + if update.InlineRouteConfig != nil { + // If there was a previous route config watcher because of a non-inline + // route configuration, cancel it. + m.rdsResourceName = "" + if m.routeConfigWatcher != nil { + m.routeConfigWatcher.stop() + m.routeConfigWatcher = nil + } + m.applyRouteConfigUpdateLocked(update.InlineRouteConfig) + return + } + + // We get here only if there was no inline route configuration. If the route + // config name has not changed, send an update with existing route + // configuration and the newly received listener configuration. + if m.rdsResourceName == update.RouteConfigName { + m.maybeSendUpdateLocked() + return + } + + // If the route config name has changed, cancel the old watcher and start a + // new one. At this point, since the new route config name has not yet been + // resolved, no update is sent to the channel, and therefore the old route + // configuration (if received) is used until the new one is received. + m.rdsResourceName = update.RouteConfigName + if m.routeConfigWatcher != nil { + m.routeConfigWatcher.stop() + m.currentVirtualHost = nil + } + m.routeConfigWatcher = newRouteConfigWatcher(m.rdsResourceName, m) +} + +func (m *DependencyManager) onListenerResourceError(err error, onDone func()) { + m.mu.Lock() + defer m.mu.Unlock() + + defer onDone() + if m.stopped { + return + } + + m.logger.Warningf("Received resource error for Listener resource %q: %v", m.ldsResourceName, m.annotateErrorWithNodeID(err)) + + if m.routeConfigWatcher != nil { + m.routeConfigWatcher.stop() + } + m.rdsResourceName = "" + m.currentVirtualHost = nil + m.routeConfigWatcher = nil + m.watcher.Error(fmt.Errorf("listener resource error: %v", m.annotateErrorWithNodeID(err))) +} + +// onListenerResourceAmbientError handles ambient errors received from the +// listener resource watcher. Since ambient errors do not impact the current +// state of the resource, no change is made to the current configuration and the +// errors are only logged for visibility. +func (m *DependencyManager) onListenerResourceAmbientError(err error, onDone func()) { + m.mu.Lock() + defer m.mu.Unlock() + + defer onDone() + if m.stopped { + return + } + + m.logger.Warningf("Listener resource ambient error: %v", m.annotateErrorWithNodeID(err)) +} + +func (m *DependencyManager) onRouteConfigResourceUpdate(resourceName string, update *xdsresource.RouteConfigUpdate, onDone func()) { + m.mu.Lock() + defer m.mu.Unlock() + + defer onDone() + if m.stopped || m.rdsResourceName != resourceName { + return + } + + if m.logger.V(2) { + m.logger.Infof("Received update for RouteConfiguration resource %q: %+v", resourceName, update) + } + m.applyRouteConfigUpdateLocked(update) +} + +func (m *DependencyManager) onRouteConfigResourceError(resourceName string, err error, onDone func()) { + m.mu.Lock() + defer m.mu.Unlock() + + defer onDone() + if m.stopped || m.rdsResourceName != resourceName { + return + } + m.logger.Warningf("Received resource error for RouteConfiguration resource %q: %v", resourceName, m.annotateErrorWithNodeID(err)) + m.watcher.Error(fmt.Errorf("route resource error: %v", m.annotateErrorWithNodeID(err))) +} + +// onRouteResourceAmbientError handles ambient errors received from the route +// resource watcher. Since ambient errors do not impact the current state of the +// resource, no change is made to the current configuration and the errors are +// only logged for visibility. +func (m *DependencyManager) onRouteConfigResourceAmbientError(resourceName string, err error, onDone func()) { + m.mu.Lock() + defer m.mu.Unlock() + + defer onDone() + if m.stopped || m.rdsResourceName != resourceName { + return + } + + m.logger.Warningf("Route resource ambient error %q: %v", resourceName, m.annotateErrorWithNodeID(err)) +} diff --git a/vendor/google.golang.org/grpc/mem/buffer_pool.go b/vendor/google.golang.org/grpc/mem/buffer_pool.go index f211e727451..e37afdd1981 100644 --- a/vendor/google.golang.org/grpc/mem/buffer_pool.go +++ b/vendor/google.golang.org/grpc/mem/buffer_pool.go @@ -38,9 +38,11 @@ type BufferPool interface { Put(*[]byte) } +const goPageSize = 4 << 10 // 4KiB. N.B. this must be a power of 2. + var defaultBufferPoolSizes = []int{ 256, - 4 << 10, // 4KB (go page size) + goPageSize, 16 << 10, // 16KB (max HTTP/2 frame size used by gRPC) 32 << 10, // 32KB (default buffer size for io.Copy) 1 << 20, // 1MB @@ -172,7 +174,14 @@ func (p *simpleBufferPool) Get(size int) *[]byte { p.pool.Put(bs) } - b := make([]byte, size) + // If we're going to allocate, round up to the nearest page. This way if + // requests frequently arrive with small variation we don't allocate + // repeatedly if we get unlucky and they increase over time. By default we + // only allocate here if size > 1MiB. Because goPageSize is a power of 2, we + // can round up efficiently. + allocSize := (size + goPageSize - 1) & ^(goPageSize - 1) + + b := make([]byte, size, allocSize) return &b } diff --git a/vendor/google.golang.org/grpc/resolver_wrapper.go b/vendor/google.golang.org/grpc/resolver_wrapper.go index 80e16a327cd..6e613764372 100644 --- a/vendor/google.golang.org/grpc/resolver_wrapper.go +++ b/vendor/google.golang.org/grpc/resolver_wrapper.go @@ -69,6 +69,7 @@ func (ccr *ccResolverWrapper) start() error { errCh := make(chan error) ccr.serializer.TrySchedule(func(ctx context.Context) { if ctx.Err() != nil { + errCh <- ctx.Err() return } opts := resolver.BuildOptions{ diff --git a/vendor/google.golang.org/grpc/rpc_util.go b/vendor/google.golang.org/grpc/rpc_util.go index 6b04c9e8735..8160f943040 100644 --- a/vendor/google.golang.org/grpc/rpc_util.go +++ b/vendor/google.golang.org/grpc/rpc_util.go @@ -33,6 +33,8 @@ import ( "google.golang.org/grpc/credentials" "google.golang.org/grpc/encoding" "google.golang.org/grpc/encoding/proto" + "google.golang.org/grpc/internal" + "google.golang.org/grpc/internal/grpcutil" "google.golang.org/grpc/internal/transport" "google.golang.org/grpc/mem" "google.golang.org/grpc/metadata" @@ -41,6 +43,10 @@ import ( "google.golang.org/grpc/status" ) +func init() { + internal.AcceptCompressors = acceptCompressors +} + // Compressor defines the interface gRPC uses to compress a message. // // Deprecated: use package encoding. @@ -151,16 +157,32 @@ func (d *gzipDecompressor) Type() string { // callInfo contains all related configuration and information about an RPC. type callInfo struct { - compressorName string - failFast bool - maxReceiveMessageSize *int - maxSendMessageSize *int - creds credentials.PerRPCCredentials - contentSubtype string - codec baseCodec - maxRetryRPCBufferSize int - onFinish []func(err error) - authority string + compressorName string + failFast bool + maxReceiveMessageSize *int + maxSendMessageSize *int + creds credentials.PerRPCCredentials + contentSubtype string + codec baseCodec + maxRetryRPCBufferSize int + onFinish []func(err error) + authority string + acceptedResponseCompressors []string +} + +func acceptedCompressorAllows(allowed []string, name string) bool { + if allowed == nil { + return true + } + if name == "" || name == encoding.Identity { + return true + } + for _, a := range allowed { + if a == name { + return true + } + } + return false } func defaultCallInfo() *callInfo { @@ -170,6 +192,29 @@ func defaultCallInfo() *callInfo { } } +func newAcceptedCompressionConfig(names []string) ([]string, error) { + if len(names) == 0 { + return nil, nil + } + var allowed []string + seen := make(map[string]struct{}, len(names)) + for _, name := range names { + name = strings.TrimSpace(name) + if name == "" || name == encoding.Identity { + continue + } + if !grpcutil.IsCompressorNameRegistered(name) { + return nil, status.Errorf(codes.InvalidArgument, "grpc: compressor %q is not registered", name) + } + if _, dup := seen[name]; dup { + continue + } + seen[name] = struct{}{} + allowed = append(allowed, name) + } + return allowed, nil +} + // CallOption configures a Call before it starts or extracts information from // a Call after it completes. type CallOption interface { @@ -471,6 +516,31 @@ func (o CompressorCallOption) before(c *callInfo) error { } func (o CompressorCallOption) after(*callInfo, *csAttempt) {} +// acceptCompressors returns a CallOption that limits the compression algorithms +// advertised in the grpc-accept-encoding header for response messages. +// Compression algorithms not in the provided list will not be advertised, and +// responses compressed with non-listed algorithms will be rejected. +func acceptCompressors(names ...string) CallOption { + cp := append([]string(nil), names...) + return acceptCompressorsCallOption{names: cp} +} + +// acceptCompressorsCallOption is a CallOption that limits response compression. +type acceptCompressorsCallOption struct { + names []string +} + +func (o acceptCompressorsCallOption) before(c *callInfo) error { + allowed, err := newAcceptedCompressionConfig(o.names) + if err != nil { + return err + } + c.acceptedResponseCompressors = allowed + return nil +} + +func (acceptCompressorsCallOption) after(*callInfo, *csAttempt) {} + // CallContentSubtype returns a CallOption that will set the content-subtype // for a call. For example, if content-subtype is "json", the Content-Type over // the wire will be "application/grpc+json". The content-subtype is converted @@ -857,8 +927,7 @@ func (p *payloadInfo) free() { // the buffer is no longer needed. // TODO: Refactor this function to reduce the number of arguments. // See: https://google.github.io/styleguide/go/best-practices.html#function-argument-lists -func recvAndDecompress(p *parser, s recvCompressor, dc Decompressor, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor, isServer bool, -) (out mem.BufferSlice, err error) { +func recvAndDecompress(p *parser, s recvCompressor, dc Decompressor, maxReceiveMessageSize int, payInfo *payloadInfo, compressor encoding.Compressor, isServer bool) (out mem.BufferSlice, err error) { pf, compressed, err := p.recvMsg(maxReceiveMessageSize) if err != nil { return nil, err diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go index ca87ff9776e..ec9577b2789 100644 --- a/vendor/google.golang.org/grpc/stream.go +++ b/vendor/google.golang.org/grpc/stream.go @@ -25,6 +25,7 @@ import ( "math" rand "math/rand/v2" "strconv" + "strings" "sync" "time" @@ -179,13 +180,41 @@ func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth var emptyMethodConfig = serviceconfig.MethodConfig{} +// endOfClientStream performs cleanup actions required for both successful and +// failed streams. This includes incrementing channelz stats and invoking all +// registered OnFinish call options. +func endOfClientStream(cc *ClientConn, err error, opts ...CallOption) { + if channelz.IsOn() { + if err != nil { + cc.incrCallsFailed() + } else { + cc.incrCallsSucceeded() + } + } + + for _, o := range opts { + if o, ok := o.(OnFinishCallOption); ok { + o.OnFinish(err) + } + } +} + func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (_ ClientStream, err error) { + if channelz.IsOn() { + cc.incrCallsStarted() + } + defer func() { + if err != nil { + // Ensure cleanup when stream creation fails. + endOfClientStream(cc, err, opts...) + } + }() + // Start tracking the RPC for idleness purposes. This is where a stream is // created for both streaming and unary RPCs, and hence is a good place to // track active RPC count. - if err := cc.idlenessMgr.OnCallBegin(); err != nil { - return nil, err - } + cc.idlenessMgr.OnCallBegin() + // Add a calloption, to decrement the active call count, that gets executed // when the RPC completes. opts = append([]CallOption{OnFinish(func(error) { cc.idlenessMgr.OnCallEnd() })}, opts...) @@ -204,14 +233,6 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth } } } - if channelz.IsOn() { - cc.incrCallsStarted() - defer func() { - if err != nil { - cc.incrCallsFailed() - } - }() - } // Provide an opportunity for the first RPC to see the first service config // provided by the resolver. nameResolutionDelayed, err := cc.waitForResolvedAddrs(ctx) @@ -301,6 +322,10 @@ func newClientStreamWithParams(ctx context.Context, desc *StreamDesc, cc *Client DoneFunc: doneFunc, Authority: callInfo.authority, } + if allowed := callInfo.acceptedResponseCompressors; len(allowed) > 0 { + headerValue := strings.Join(allowed, ",") + callHdr.AcceptedCompressors = &headerValue + } // Set our outgoing compression according to the UseCompressor CallOption, if // set. In that case, also find the compressor from the encoding package. @@ -484,7 +509,7 @@ func (a *csAttempt) getTransport() error { return err } if a.trInfo != nil { - a.trInfo.firstLine.SetRemoteAddr(a.transport.RemoteAddr()) + a.trInfo.firstLine.SetRemoteAddr(a.transport.Peer().Addr) } if pick.blocked && a.statsHandler != nil { a.statsHandler.HandleRPC(a.ctx, &stats.DelayedPickComplete{}) @@ -1042,9 +1067,6 @@ func (cs *clientStream) finish(err error) { return } cs.finished = true - for _, onFinish := range cs.callInfo.onFinish { - onFinish(err) - } cs.commitAttemptLocked() if cs.attempt != nil { cs.attempt.finish(err) @@ -1084,13 +1106,7 @@ func (cs *clientStream) finish(err error) { if err == nil { cs.retryThrottler.successfulRPC() } - if channelz.IsOn() { - if err != nil { - cs.cc.incrCallsFailed() - } else { - cs.cc.incrCallsSucceeded() - } - } + endOfClientStream(cs.cc, err, cs.opts...) cs.cancel() } @@ -1134,6 +1150,10 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) { a.decompressorV0 = nil a.decompressorV1 = encoding.GetCompressor(ct) } + // Validate that the compression method is acceptable for this call. + if !acceptedCompressorAllows(cs.callInfo.acceptedResponseCompressors, ct) { + return status.Errorf(codes.Internal, "grpc: peer compressed the response with %q which is not allowed by AcceptCompressors", ct) + } } else { // No compression is used; disable our decompressor. a.decompressorV0 = nil @@ -1479,6 +1499,10 @@ func (as *addrConnStream) RecvMsg(m any) (err error) { as.decompressorV0 = nil as.decompressorV1 = encoding.GetCompressor(ct) } + // Validate that the compression method is acceptable for this call. + if !acceptedCompressorAllows(as.callInfo.acceptedResponseCompressors, ct) { + return status.Errorf(codes.Internal, "grpc: peer compressed the response with %q which is not allowed by AcceptCompressors", ct) + } } else { // No compression is used; disable our decompressor. as.decompressorV0 = nil diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index 9e6d018fb7f..ff7840fd8e1 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.77.0" +const Version = "1.78.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index a9ac97a4227..52853f4c839 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1324,7 +1324,7 @@ github.com/hashicorp/go-sockaddr # github.com/hashicorp/go-uuid v1.0.3 ## explicit github.com/hashicorp/go-uuid -# github.com/hashicorp/go-version v1.7.0 +# github.com/hashicorp/go-version v1.8.0 ## explicit github.com/hashicorp/go-version # github.com/hashicorp/golang-lru v1.0.2 @@ -2164,10 +2164,10 @@ go.opentelemetry.io/collector/confmap/xconfmap ## explicit; go 1.24.0 go.opentelemetry.io/collector/consumer go.opentelemetry.io/collector/consumer/internal -# go.opentelemetry.io/collector/featuregate v1.47.0 +# go.opentelemetry.io/collector/featuregate v1.49.0 ## explicit; go 1.24.0 go.opentelemetry.io/collector/featuregate -# go.opentelemetry.io/collector/pdata v1.47.0 +# go.opentelemetry.io/collector/pdata v1.49.0 ## explicit; go 1.24.0 go.opentelemetry.io/collector/pdata/internal go.opentelemetry.io/collector/pdata/internal/json @@ -2566,7 +2566,7 @@ google.golang.org/genproto/googleapis/api/monitoredres google.golang.org/genproto/googleapis/rpc/code google.golang.org/genproto/googleapis/rpc/errdetails google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.77.0 +# google.golang.org/grpc v1.78.0 ## explicit; go 1.24.0 google.golang.org/grpc google.golang.org/grpc/attributes @@ -2701,6 +2701,7 @@ google.golang.org/grpc/internal/xds/xdsclient/xdslbregistry google.golang.org/grpc/internal/xds/xdsclient/xdslbregistry/converter google.golang.org/grpc/internal/xds/xdsclient/xdsresource google.golang.org/grpc/internal/xds/xdsclient/xdsresource/version +google.golang.org/grpc/internal/xds/xdsdepmgr google.golang.org/grpc/keepalive google.golang.org/grpc/mem google.golang.org/grpc/metadata