diff --git a/.chloggen/rm-gogo-proto.yaml b/.chloggen/rm-gogo-proto.yaml new file mode 100644 index 00000000000..40a5516f0ea --- /dev/null +++ b/.chloggen/rm-gogo-proto.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: pkg/pdata + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove usage of gogo proto and generate the structs with pdatagen + +# One or more tracking issues or pull requests related to the change +issues: [14069] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/Makefile b/Makefile index a0a2577c804..9358c78d36a 100644 --- a/Makefile +++ b/Makefile @@ -176,95 +176,24 @@ ocb: $(MAKE) -C cmd/builder config $(MAKE) -C cmd/builder ocb -# Definitions for ProtoBuf generation. - -# The source directory for OTLP ProtoBufs. -OPENTELEMETRY_PROTO_SRC_DIR=pdata/internal/opentelemetry-proto - -# The branch matching the current version of the proto to use -OPENTELEMETRY_PROTO_VERSION=v1.8.0 - -# Find all .proto files. -OPENTELEMETRY_PROTO_FILES := $(subst $(OPENTELEMETRY_PROTO_SRC_DIR)/,,$(wildcard $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/*/v1development/*.proto $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/collector/*/v1development/*.proto)) - -# Target directory to write generated files to. -PROTO_TARGET_GEN_DIR=pdata/internal/data/protogen - -# Go package name to use for generated files. -PROTO_PACKAGE=go.opentelemetry.io/collector/$(PROTO_TARGET_GEN_DIR) - -# Intermediate directory used during generation. -PROTO_INTERMEDIATE_DIR=pdata/internal/.patched-otlp-proto - -DOCKERCMD ?= docker -DOCKER_PROTOBUF ?= otel/build-protobuf:0.23.0 -PROTOC := $(DOCKERCMD) run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD}/$(PROTO_INTERMEDIATE_DIR) ${DOCKER_PROTOBUF} --proto_path=${PWD} -PROTO_INCLUDES := -I/usr/include/github.com/gogo/protobuf -I./ - -# Cleanup temporary directory -genproto-cleanup: - rm -Rf ${OPENTELEMETRY_PROTO_SRC_DIR} - -# Generate OTLP Protobuf Go files. This will place generated files in PROTO_TARGET_GEN_DIR. -genproto: genproto-cleanup - mkdir -p ${OPENTELEMETRY_PROTO_SRC_DIR} - curl -sSL https://api.github.com/repos/open-telemetry/opentelemetry-proto/tarball/${OPENTELEMETRY_PROTO_VERSION} | tar xz --strip 1 -C ${OPENTELEMETRY_PROTO_SRC_DIR} - # Call a sub-make to ensure OPENTELEMETRY_PROTO_FILES is populated - $(MAKE) genproto_sub - $(MAKE) genproto_internal - $(MAKE) fmt - $(MAKE) genproto-cleanup - -genproto_sub: - @echo Generating code for the following files: - @$(foreach file,$(OPENTELEMETRY_PROTO_FILES),$(call exec-command,echo $(file))) - - @echo Delete intermediate directory. - @rm -rf $(PROTO_INTERMEDIATE_DIR) - - @echo Copy .proto file to intermediate directory. - mkdir -p $(PROTO_INTERMEDIATE_DIR)/opentelemetry - cp -R $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/* $(PROTO_INTERMEDIATE_DIR)/opentelemetry - - # Patch proto files. See proto_patch.sed for patching rules. - @echo Modify them in the intermediate directory. - $(foreach file,$(OPENTELEMETRY_PROTO_FILES),$(call exec-command,sed -f proto_patch.sed $(OPENTELEMETRY_PROTO_SRC_DIR)/$(file) > $(PROTO_INTERMEDIATE_DIR)/$(file))) - - # HACK: Workaround for istio 1.15 / envoy 1.23.1 mistakenly emitting deprecated field. - # reserved 1000 -> repeated ScopeLogs deprecated_scope_logs = 1000; - sed 's/reserved 1000;/repeated ScopeLogs deprecated_scope_logs = 1000;/g' $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/logs/v1/logs.proto 1<> $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/logs/v1/logs.proto - # reserved 1000 -> repeated ScopeMetrics deprecated_scope_metrics = 1000; - sed 's/reserved 1000;/repeated ScopeMetrics deprecated_scope_metrics = 1000;/g' $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/metrics/v1/metrics.proto 1<> $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/metrics/v1/metrics.proto - # reserved 1000 -> repeated ScopeSpans deprecated_scope_spans = 1000; - sed 's/reserved 1000;/repeated ScopeSpans deprecated_scope_spans = 1000;/g' $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/trace/v1/trace.proto 1<> $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/trace/v1/trace.proto - - - @echo Generate Go code from .proto files in intermediate directory. - $(foreach file,$(OPENTELEMETRY_PROTO_FILES),$(call exec-command,$(PROTOC) $(PROTO_INCLUDES) --gogofaster_out=plugins=grpc:./ $(file))) - - @echo Move generated code to target directory. - mkdir -p $(PROTO_TARGET_GEN_DIR) - cp -R $(PROTO_INTERMEDIATE_DIR)/$(PROTO_PACKAGE)/* $(PROTO_TARGET_GEN_DIR)/ - rm -rf $(PROTO_INTERMEDIATE_DIR)/go.opentelemetry.io - - @rm -rf $(OPENTELEMETRY_PROTO_SRC_DIR)/* - @rm -rf $(OPENTELEMETRY_PROTO_SRC_DIR)/.* > /dev/null 2>&1 || true - -# Generate structs, functions and tests for pdata package. Must be used after any changes -# to proto and after running `make genproto` +# Generate structs, functions and tests for pdata package. genpdata: cd internal/cmd/pdatagen && $(GOCMD) run main.go -C $(SRC_ROOT) $(MAKE) -C pdata fmt -INTERNAL_PROTO_SRC_DIRS := exporter/exporterhelper/internal/queue pdata/xpdata/request/internal -INTERNAL_PROTO_FILES := $(foreach dir,$(INTERNAL_PROTO_SRC_DIRS),$(wildcard $(dir)/*.proto)) -INTERNAL_PROTOC := $(DOCKERCMD) run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF} --proto_path=${PWD} -I/usr/include/github.com/gogo/protobuf -I${PWD}/$(PROTO_INTERMEDIATE_DIR) --gogofaster_out=plugins=grpc,paths=source_relative:. +DOCKERCMD ?= docker +DOCKER_PROTOBUF ?= otel/build-protobuf:0.23.0 + +PROTO_SRC_DIRS := exporter/exporterhelper/internal/queue +PROTO_FILES := $(foreach dir,$(PROTO_SRC_DIRS),$(wildcard $(dir)/*.proto)) +PROTOC := $(DOCKERCMD) run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD} ${DOCKER_PROTOBUF} --proto_path=${PWD} -I/usr/include/github.com/gogo/protobuf --gogofaster_out=plugins=grpc,paths=source_relative:. -.PHONY: genproto_internal -genproto_internal: - @echo "Generating Go code for internal proto files" - @echo "Found proto files: $(INTERNAL_PROTO_FILES)" - $(foreach file,$(INTERNAL_PROTO_FILES),$(call exec-command,$(INTERNAL_PROTOC) $(file))) +.PHONY: genproto +genproto: + @echo "Generating Go code for proto files" + @echo "Found proto files: $(PROTO_FILES)" + $(foreach file,$(PROTO_FILES),$(call exec-command,$(PROTOC) $(file))) + $(MAKE) fmt ALL_MOD_PATHS := "" $(ALL_MODULES:.%=%) diff --git a/client/go.mod b/client/go.mod index 6012ca760a7..cd780cdf62c 100644 --- a/client/go.mod +++ b/client/go.mod @@ -11,7 +11,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -19,12 +18,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/client/go.sum b/client/go.sum index 37229a7ff62..8bbbde46ac2 100644 --- a/client/go.sum +++ b/client/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +24,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,43 +34,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/cmd/mdatagen/go.mod b/cmd/mdatagen/go.mod index c7dfff6edbe..073427a940e 100644 --- a/cmd/mdatagen/go.mod +++ b/cmd/mdatagen/go.mod @@ -40,7 +40,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -70,7 +69,6 @@ require ( go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.44.0 // indirect golang.org/x/sys v0.36.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect google.golang.org/grpc v1.76.0 // indirect diff --git a/cmd/mdatagen/go.sum b/cmd/mdatagen/go.sum index dc31e8ad84b..f3d65342ac0 100644 --- a/cmd/mdatagen/go.sum +++ b/cmd/mdatagen/go.sum @@ -11,8 +11,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -26,8 +24,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -61,8 +57,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -89,39 +83,12 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/component/componentstatus/go.mod b/component/componentstatus/go.mod index c44dd6a4fc6..2c9dcba40af 100644 --- a/component/componentstatus/go.mod +++ b/component/componentstatus/go.mod @@ -11,7 +11,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -20,16 +19,9 @@ require ( go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/component/componentstatus/go.sum b/component/componentstatus/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/component/componentstatus/go.sum +++ b/component/componentstatus/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/component/componenttest/go.mod b/component/componenttest/go.mod index 6a525268be8..7a0fc2317bb 100644 --- a/component/componenttest/go.mod +++ b/component/componenttest/go.mod @@ -19,7 +19,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -29,12 +28,7 @@ require ( go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/component/componenttest/go.sum b/component/componenttest/go.sum index 1839d792534..f34047270f4 100644 --- a/component/componenttest/go.sum +++ b/component/componenttest/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/component/go.mod b/component/go.mod index 4829dedd7b5..cfc416bb219 100644 --- a/component/go.mod +++ b/component/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -22,14 +21,7 @@ require ( github.com/rogpeppe/go-internal v1.13.1 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/component/go.sum b/component/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/component/go.sum +++ b/component/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/config/configauth/go.mod b/config/configauth/go.mod index 6c744d9429e..8038496ac66 100644 --- a/config/configauth/go.mod +++ b/config/configauth/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -26,10 +25,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/config/configauth/go.sum b/config/configauth/go.sum index e57ea2a3cda..7ace083d536 100644 --- a/config/configauth/go.sum +++ b/config/configauth/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,39 +50,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= +golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/config/configgrpc/go.mod b/config/configgrpc/go.mod index a29863a71a9..615e6cecac6 100644 --- a/config/configgrpc/go.mod +++ b/config/configgrpc/go.mod @@ -36,7 +36,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-tpm v0.9.6 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/config/configgrpc/go.sum b/config/configgrpc/go.sum index 489431dd230..d0cd51af52a 100644 --- a/config/configgrpc/go.sum +++ b/config/configgrpc/go.sum @@ -16,8 +16,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= @@ -35,8 +33,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -69,8 +65,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 h1:YH4g8lQroajqUwWbq/tr2QX1JFmEXaDLgG+ew9bLMWo= @@ -99,39 +93,14 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod index afc0fd51720..386153a67ab 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -39,7 +39,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/go-tpm v0.9.6 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect diff --git a/config/confighttp/go.sum b/config/confighttp/go.sum index b0927b73918..dfad7b45870 100644 --- a/config/confighttp/go.sum +++ b/config/confighttp/go.sum @@ -18,8 +18,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= @@ -37,8 +35,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -73,8 +69,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18= @@ -103,39 +97,14 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/config/confighttp/xconfighttp/go.mod b/config/confighttp/xconfighttp/go.mod index b8415a290be..9676b69be1e 100644 --- a/config/confighttp/xconfighttp/go.mod +++ b/config/confighttp/xconfighttp/go.mod @@ -20,7 +20,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v1.0.0 // indirect github.com/google/go-tpm v0.9.6 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/config/confighttp/xconfighttp/go.sum b/config/confighttp/xconfighttp/go.sum index b0927b73918..dfad7b45870 100644 --- a/config/confighttp/xconfighttp/go.sum +++ b/config/confighttp/xconfighttp/go.sum @@ -18,8 +18,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= @@ -37,8 +35,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -73,8 +69,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18= @@ -103,39 +97,14 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/config/configmiddleware/go.mod b/config/configmiddleware/go.mod index 3db109cdea1..dd1984d88f8 100644 --- a/config/configmiddleware/go.mod +++ b/config/configmiddleware/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/config/configmiddleware/go.sum b/config/configmiddleware/go.sum index e57ea2a3cda..616759db1b5 100644 --- a/config/configmiddleware/go.sum +++ b/config/configmiddleware/go.sum @@ -5,8 +5,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -18,8 +16,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +34,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= +go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,37 +58,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/connector/connectortest/go.mod b/connector/connectortest/go.mod index ca645e12d93..7a3977ad403 100644 --- a/connector/connectortest/go.mod +++ b/connector/connectortest/go.mod @@ -21,7 +21,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -39,12 +38,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/connector/connectortest/go.sum b/connector/connectortest/go.sum index 1839d792534..f34047270f4 100644 --- a/connector/connectortest/go.sum +++ b/connector/connectortest/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/connector/forwardconnector/go.mod b/connector/forwardconnector/go.mod index de656a470bc..3d481902138 100644 --- a/connector/forwardconnector/go.mod +++ b/connector/forwardconnector/go.mod @@ -22,7 +22,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -49,12 +48,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/connector/forwardconnector/go.sum b/connector/forwardconnector/go.sum index 0b7379d1cba..ed7c48df3b7 100644 --- a/connector/forwardconnector/go.sum +++ b/connector/forwardconnector/go.sum @@ -10,10 +10,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -23,8 +19,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -53,8 +47,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -81,43 +73,8 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/connector/go.mod b/connector/go.mod index f56d9d4e1d4..c89940a094a 100644 --- a/connector/go.mod +++ b/connector/go.mod @@ -17,7 +17,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -28,15 +27,8 @@ require ( go.opentelemetry.io/collector/pdata/pprofile v0.138.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/connector/go.sum b/connector/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/connector/go.sum +++ b/connector/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/connector/xconnector/go.mod b/connector/xconnector/go.mod index 6cfb845c4a6..a3e669afc37 100644 --- a/connector/xconnector/go.mod +++ b/connector/xconnector/go.mod @@ -18,7 +18,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -31,12 +30,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/connector/xconnector/go.sum b/connector/xconnector/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/connector/xconnector/go.sum +++ b/connector/xconnector/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/consumer/consumererror/go.mod b/consumer/consumererror/go.mod index 329dc0303e0..da5fb275912 100644 --- a/consumer/consumererror/go.mod +++ b/consumer/consumererror/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -21,9 +20,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/consumer/consumererror/go.sum b/consumer/consumererror/go.sum index 37229a7ff62..13415b6c2a5 100644 --- a/consumer/consumererror/go.sum +++ b/consumer/consumererror/go.sum @@ -1,25 +1,15 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +28,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,39 +38,12 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/consumer/consumererror/xconsumererror/go.mod b/consumer/consumererror/xconsumererror/go.mod index cb8c4cd10cf..1e607c79b61 100644 --- a/consumer/consumererror/xconsumererror/go.mod +++ b/consumer/consumererror/xconsumererror/go.mod @@ -11,7 +11,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -20,12 +19,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.opentelemetry.io/collector/pdata v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/consumer/consumererror/xconsumererror/go.sum b/consumer/consumererror/xconsumererror/go.sum index 37229a7ff62..8bbbde46ac2 100644 --- a/consumer/consumererror/xconsumererror/go.sum +++ b/consumer/consumererror/xconsumererror/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +24,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,43 +34,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/consumer/consumertest/go.mod b/consumer/consumertest/go.mod index a12bcb6309f..88cbdcd1a16 100644 --- a/consumer/consumertest/go.mod +++ b/consumer/consumertest/go.mod @@ -16,7 +16,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -24,12 +23,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/consumer/consumertest/go.sum b/consumer/consumertest/go.sum index 37229a7ff62..8bbbde46ac2 100644 --- a/consumer/consumertest/go.sum +++ b/consumer/consumertest/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +24,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,43 +34,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/consumer/go.mod b/consumer/go.mod index e859eb3c5f0..b5bbf397415 100644 --- a/consumer/go.mod +++ b/consumer/go.mod @@ -10,7 +10,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -18,12 +17,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/consumer/go.sum b/consumer/go.sum index 37229a7ff62..8bbbde46ac2 100644 --- a/consumer/go.sum +++ b/consumer/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +24,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,43 +34,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/consumer/xconsumer/go.mod b/consumer/xconsumer/go.mod index e9ff8476182..36b2b51cb4c 100644 --- a/consumer/xconsumer/go.mod +++ b/consumer/xconsumer/go.mod @@ -10,7 +10,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -19,12 +18,6 @@ require ( go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.opentelemetry.io/collector/pdata v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/consumer/xconsumer/go.sum b/consumer/xconsumer/go.sum index 37229a7ff62..8bbbde46ac2 100644 --- a/consumer/xconsumer/go.sum +++ b/consumer/xconsumer/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +24,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,43 +34,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/exporter/debugexporter/go.mod b/exporter/debugexporter/go.mod index 86644e669ce..c8498d7cfd3 100644 --- a/exporter/debugexporter/go.mod +++ b/exporter/debugexporter/go.mod @@ -66,8 +66,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/exporter/debugexporter/go.sum b/exporter/debugexporter/go.sum index b5d798e58e2..3c7cef890c8 100644 --- a/exporter/debugexporter/go.sum +++ b/exporter/debugexporter/go.sum @@ -114,8 +114,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/exporter/exporterhelper/go.mod b/exporter/exporterhelper/go.mod index d1e1b5f1033..719ec2452f5 100644 --- a/exporter/exporterhelper/go.mod +++ b/exporter/exporterhelper/go.mod @@ -61,9 +61,7 @@ require ( go.opentelemetry.io/collector/receiver/receivertest v0.138.0 // indirect go.opentelemetry.io/collector/receiver/xreceiver v0.138.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/exporter/exporterhelper/go.sum b/exporter/exporterhelper/go.sum index 22f5f8376dd..3c7ff38c89c 100644 --- a/exporter/exporterhelper/go.sum +++ b/exporter/exporterhelper/go.sum @@ -114,8 +114,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/exporter/exporterhelper/xexporterhelper/go.mod b/exporter/exporterhelper/xexporterhelper/go.mod index 0f09f82c211..a7e9543a854 100644 --- a/exporter/exporterhelper/xexporterhelper/go.mod +++ b/exporter/exporterhelper/xexporterhelper/go.mod @@ -62,9 +62,7 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/exporter/exporterhelper/xexporterhelper/go.sum b/exporter/exporterhelper/xexporterhelper/go.sum index 22f5f8376dd..3c7ff38c89c 100644 --- a/exporter/exporterhelper/xexporterhelper/go.sum +++ b/exporter/exporterhelper/xexporterhelper/go.sum @@ -114,8 +114,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/exporter/exportertest/go.mod b/exporter/exportertest/go.mod index 6f85dc2c4e6..ab31a333a26 100644 --- a/exporter/exportertest/go.mod +++ b/exporter/exportertest/go.mod @@ -59,9 +59,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/exporter/exportertest/go.sum b/exporter/exportertest/go.sum index 22f5f8376dd..3c7ff38c89c 100644 --- a/exporter/exportertest/go.sum +++ b/exporter/exportertest/go.sum @@ -114,8 +114,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/exporter/go.mod b/exporter/go.mod index 31022219ef1..6539d136bf0 100644 --- a/exporter/go.mod +++ b/exporter/go.mod @@ -47,9 +47,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/exporter/go.sum b/exporter/go.sum index eec50b1b773..0256208aa46 100644 --- a/exporter/go.sum +++ b/exporter/go.sum @@ -113,8 +113,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/exporter/nopexporter/go.mod b/exporter/nopexporter/go.mod index 458a3060241..d1d44e13dd8 100644 --- a/exporter/nopexporter/go.mod +++ b/exporter/nopexporter/go.mod @@ -20,7 +20,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -51,9 +50,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/exporter/nopexporter/go.sum b/exporter/nopexporter/go.sum index 22f5f8376dd..d26efef51e5 100644 --- a/exporter/nopexporter/go.sum +++ b/exporter/nopexporter/go.sum @@ -25,8 +25,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -55,8 +53,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -83,39 +79,12 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/exporter/xexporter/go.mod b/exporter/xexporter/go.mod index db914621aa4..533c393c367 100644 --- a/exporter/xexporter/go.mod +++ b/exporter/xexporter/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -25,16 +24,9 @@ require ( go.opentelemetry.io/collector/pdata/pprofile v0.138.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/exporter/xexporter/go.sum b/exporter/xexporter/go.sum index eec50b1b773..41a66ef85f8 100644 --- a/exporter/xexporter/go.sum +++ b/exporter/xexporter/go.sum @@ -13,19 +13,13 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -54,18 +48,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -82,39 +70,8 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/extension/extensionauth/extensionauthtest/go.mod b/extension/extensionauth/extensionauthtest/go.mod index aaa0e88ffdb..4233762ee71 100644 --- a/extension/extensionauth/extensionauthtest/go.mod +++ b/extension/extensionauth/extensionauthtest/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -26,10 +25,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/extensionauth/extensionauthtest/go.sum b/extension/extensionauth/extensionauthtest/go.sum index e57ea2a3cda..7ace083d536 100644 --- a/extension/extensionauth/extensionauthtest/go.sum +++ b/extension/extensionauth/extensionauthtest/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,39 +50,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= +golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/extension/extensioncapabilities/go.mod b/extension/extensioncapabilities/go.mod index ac711057b20..73decbee73f 100644 --- a/extension/extensioncapabilities/go.mod +++ b/extension/extensioncapabilities/go.mod @@ -11,7 +11,6 @@ require ( require ( github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/knadh/koanf/maps v0.1.2 // indirect @@ -29,12 +28,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect ) replace go.opentelemetry.io/collector/extension => ../ diff --git a/extension/extensioncapabilities/go.sum b/extension/extensioncapabilities/go.sum index 6e4774ef343..4d1867a8eb2 100644 --- a/extension/extensioncapabilities/go.sum +++ b/extension/extensioncapabilities/go.sum @@ -9,21 +9,13 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -52,18 +44,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -80,43 +66,6 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/extension/extensionmiddleware/extensionmiddlewaretest/go.mod b/extension/extensionmiddleware/extensionmiddlewaretest/go.mod index 642c533e124..ad08ffa6640 100644 --- a/extension/extensionmiddleware/extensionmiddlewaretest/go.mod +++ b/extension/extensionmiddleware/extensionmiddlewaretest/go.mod @@ -12,7 +12,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/extension/extensionmiddleware/extensionmiddlewaretest/go.sum b/extension/extensionmiddleware/extensionmiddlewaretest/go.sum index e57ea2a3cda..616759db1b5 100644 --- a/extension/extensionmiddleware/extensionmiddlewaretest/go.sum +++ b/extension/extensionmiddleware/extensionmiddlewaretest/go.sum @@ -5,8 +5,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -18,8 +16,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +34,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= +go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,37 +58,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/extension/extensiontest/go.mod b/extension/extensiontest/go.mod index a94f357b8fc..797abe93bc0 100644 --- a/extension/extensiontest/go.mod +++ b/extension/extensiontest/go.mod @@ -16,7 +16,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -32,12 +31,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/extensiontest/go.sum b/extension/extensiontest/go.sum index 1839d792534..f34047270f4 100644 --- a/extension/extensiontest/go.sum +++ b/extension/extensiontest/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/extension/go.mod b/extension/go.mod index 5968ced86d7..c8e71ca2943 100644 --- a/extension/go.mod +++ b/extension/go.mod @@ -10,7 +10,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -20,16 +19,9 @@ require ( go.opentelemetry.io/collector/pdata v1.44.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/go.sum b/extension/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/extension/go.sum +++ b/extension/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/extension/memorylimiterextension/go.mod b/extension/memorylimiterextension/go.mod index dc99ea8ea5e..5181c60b3c3 100644 --- a/extension/memorylimiterextension/go.mod +++ b/extension/memorylimiterextension/go.mod @@ -22,7 +22,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -50,12 +49,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/extension/memorylimiterextension/go.sum b/extension/memorylimiterextension/go.sum index 95f584033a8..a0c1e9bf001 100644 --- a/extension/memorylimiterextension/go.sum +++ b/extension/memorylimiterextension/go.sum @@ -14,10 +14,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= @@ -28,8 +24,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -68,8 +62,6 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= @@ -98,45 +90,11 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/extension/xextension/go.mod b/extension/xextension/go.mod index b039f55b6e0..247ca89a023 100644 --- a/extension/xextension/go.mod +++ b/extension/xextension/go.mod @@ -8,7 +8,6 @@ require ( ) require ( - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -20,12 +19,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect ) replace go.opentelemetry.io/collector/extension => ../ diff --git a/extension/xextension/go.sum b/extension/xextension/go.sum index 92d72d577c4..cb8fb07c43b 100644 --- a/extension/xextension/go.sum +++ b/extension/xextension/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -32,18 +24,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -58,43 +44,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/extension/zpagesextension/go.mod b/extension/zpagesextension/go.mod index e5ccf5d49b2..9bcb03bc2f7 100644 --- a/extension/zpagesextension/go.mod +++ b/extension/zpagesextension/go.mod @@ -30,7 +30,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v1.0.0 // indirect github.com/google/go-tpm v0.9.6 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/extension/zpagesextension/go.sum b/extension/zpagesextension/go.sum index 0552c4ee524..4cb6c138f9f 100644 --- a/extension/zpagesextension/go.sum +++ b/extension/zpagesextension/go.sum @@ -18,8 +18,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= @@ -37,8 +35,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -73,8 +69,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18= @@ -105,39 +99,14 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/internal/cmd/pdatagen/internal/pdata/base_slices.go b/internal/cmd/pdatagen/internal/pdata/base_slices.go index e7f07e4e2f9..08f9dee8447 100644 --- a/internal/cmd/pdatagen/internal/pdata/base_slices.go +++ b/internal/cmd/pdatagen/internal/pdata/base_slices.go @@ -4,6 +4,7 @@ package pdata // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/pdata" import ( + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" ) @@ -24,6 +25,10 @@ type messageSlice struct { element *messageStruct } +func (ss *messageSlice) getProtoMessage() *proto.Message { + return nil +} + func (ss *messageSlice) getName() string { return ss.structName } @@ -44,24 +49,19 @@ func (ss *messageSlice) generateInternal(packageInfo *PackageInfo) []byte { return []byte(template.Execute(sliceInternalTemplate, ss.templateFields(packageInfo))) } -func (ss *messageSlice) generateInternalTests(packageInfo *PackageInfo) []byte { - return []byte(template.Execute(sliceInternalTestTemplate, ss.templateFields(packageInfo))) -} - func (ss *messageSlice) templateFields(packageInfo *PackageInfo) map[string]any { hasWrapper := usedByOtherDataTypes(ss.packageName) return map[string]any{ - "hasWrapper": usedByOtherDataTypes(ss.packageName), - "structName": ss.structName, - "elementName": ss.element.getName(), - "elementOriginFullName": ss.element.originFullName, - "elementOriginName": ss.getElementOriginName(), - "elementNullable": ss.elementNullable, - "origAccessor": origAccessor(hasWrapper), - "stateAccessor": stateAccessor(hasWrapper), - "packageName": packageInfo.name, - "imports": packageInfo.imports, - "testImports": packageInfo.testImports, + "hasWrapper": usedByOtherDataTypes(ss.packageName), + "structName": ss.structName, + "elementName": ss.element.getName(), + "elementOriginName": ss.getElementOriginName(), + "elementNullable": ss.elementNullable, + "origAccessor": origAccessor(hasWrapper), + "stateAccessor": stateAccessor(hasWrapper), + "packageName": packageInfo.name, + "imports": packageInfo.imports, + "testImports": packageInfo.testImports, } } @@ -77,7 +77,7 @@ func (ss *messageSlice) getHasWrapper() bool { return usedByOtherDataTypes(ss.packageName) } -func (ss *messageSlice) getHasOnlyOrig() bool { +func (ss *messageSlice) getHasOnlyInternal() bool { return false } diff --git a/internal/cmd/pdatagen/internal/pdata/base_struct.go b/internal/cmd/pdatagen/internal/pdata/base_struct.go index f04095b5007..c57eb2e596f 100644 --- a/internal/cmd/pdatagen/internal/pdata/base_struct.go +++ b/internal/cmd/pdatagen/internal/pdata/base_struct.go @@ -13,23 +13,25 @@ type baseStruct interface { getOriginName() string getOriginFullName() string getHasWrapper() bool - getHasOnlyOrig() bool + getHasOnlyInternal() bool generate(packageInfo *PackageInfo) []byte generateTests(packageInfo *PackageInfo) []byte generateInternal(packageInfo *PackageInfo) []byte - generateInternalTests(packageInfo *PackageInfo) []byte + + getProtoMessage() *proto.Message } // messageStruct generates a struct for a proto message. The struct can be generated both as a common struct // that can be used as a field in struct from other packages and as an isolated struct with depending on a package name. type messageStruct struct { - structName string - packageName string - description string - originFullName string - fields []Field - hasWrapper bool - hasOnlyOrig bool + structName string + packageName string + description string + protoName string + upstreamProto string + fields []Field + hasWrapper bool + hasOnlyInternal bool } func (ms *messageStruct) getName() string { @@ -48,8 +50,17 @@ func (ms *messageStruct) generateInternal(packageInfo *PackageInfo) []byte { return []byte(template.Execute(messageInternalTemplate, ms.templateFields(packageInfo))) } -func (ms *messageStruct) generateInternalTests(packageInfo *PackageInfo) []byte { - return []byte(template.Execute(messageInternalTestTemplate, ms.templateFields(packageInfo))) +func (ms *messageStruct) getProtoMessage() *proto.Message { + fields := make([]proto.FieldInterface, len(ms.fields)) + for i := range ms.fields { + fields[i] = ms.fields[i].toProtoField(ms) + } + return &proto.Message{ + Name: ms.protoName, + Description: ms.description, + UpstreamMessage: ms.upstreamProto, + Fields: fields, + } } func (ms *messageStruct) templateFields(packageInfo *PackageInfo) map[string]any { @@ -58,18 +69,18 @@ func (ms *messageStruct) templateFields(packageInfo *PackageInfo) map[string]any hasWrapper = usedByOtherDataTypes(ms.packageName) } return map[string]any{ - "messageStruct": ms, - "fields": ms.fields, - "structName": ms.getName(), - "originFullName": ms.getOriginFullName(), - "originName": ms.getOriginName(), - "description": ms.description, - "hasWrapper": hasWrapper, - "origAccessor": origAccessor(hasWrapper), - "stateAccessor": stateAccessor(hasWrapper), - "packageName": packageInfo.name, - "imports": packageInfo.imports, - "testImports": packageInfo.testImports, + "messageStruct": ms, + "fields": ms.fields, + "structName": ms.getName(), + "protoName": ms.getOriginFullName(), + "originName": ms.getOriginName(), + "description": ms.description, + "hasWrapper": hasWrapper, + "origAccessor": origAccessor(hasWrapper), + "stateAccessor": stateAccessor(hasWrapper), + "packageName": packageInfo.name, + "imports": packageInfo.imports, + "testImports": packageInfo.testImports, } } @@ -77,22 +88,22 @@ func (ms *messageStruct) getHasWrapper() bool { if ms.hasWrapper { return true } - if ms.hasOnlyOrig { + if ms.hasOnlyInternal { return false } return usedByOtherDataTypes(ms.packageName) } -func (ms *messageStruct) getHasOnlyOrig() bool { - return ms.hasOnlyOrig +func (ms *messageStruct) getHasOnlyInternal() bool { + return ms.hasOnlyInternal } func (ms *messageStruct) getOriginName() string { - return proto.ExtractNameFromFull(ms.originFullName) + return ms.protoName } func (ms *messageStruct) getOriginFullName() string { - return ms.originFullName + return ms.protoName } var _ baseStruct = (*messageStruct)(nil) diff --git a/internal/cmd/pdatagen/internal/pdata/field.go b/internal/cmd/pdatagen/internal/pdata/field.go index b81af12134f..2fb096d27d7 100644 --- a/internal/cmd/pdatagen/internal/pdata/field.go +++ b/internal/cmd/pdatagen/internal/pdata/field.go @@ -2,6 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 package pdata // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/pdata" +import ( + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" +) type Field interface { GenerateAccessors(ms *messageStruct) string @@ -10,25 +13,7 @@ type Field interface { GenerateTestValue(ms *messageStruct) string - GenerateTestFailingUnmarshalProtoValues(ms *messageStruct) string - - GenerateTestEncodingValues(ms *messageStruct) string - - GeneratePoolOrig(ms *messageStruct) string - - GenerateDeleteOrig(ms *messageStruct) string - - GenerateCopyOrig(ms *messageStruct) string - - GenerateMarshalJSON(ms *messageStruct) string - - GenerateUnmarshalJSON(ms *messageStruct) string - - GenerateSizeProto(ms *messageStruct) string - - GenerateMarshalProto(ms *messageStruct) string - - GenerateUnmarshalProto(*messageStruct) string + toProtoField(ms *messageStruct) proto.FieldInterface } func origAccessor(hasWrapper bool) string { diff --git a/internal/cmd/pdatagen/internal/pdata/message_field.go b/internal/cmd/pdatagen/internal/pdata/message_field.go index bcfa23de5d9..624c22d7cfd 100644 --- a/internal/cmd/pdatagen/internal/pdata/message_field.go +++ b/internal/cmd/pdatagen/internal/pdata/message_field.go @@ -13,7 +13,7 @@ import ( const messageAccessorsTemplate = `// {{ .fieldName }} returns the {{ .lowerFieldName }} associated with this {{ .structName }}. func (ms {{ .structName }}) {{ .fieldName }}() {{ .packageName }}{{ .returnType }} { {{- if .messageHasWrapper }} - return {{ .packageName }}{{ .returnType }}(internal.New{{ .returnType }}(&ms.{{ .origAccessor }}.{{ .fieldOriginFullName }}, ms.{{ .stateAccessor }})) + return {{ .packageName }}{{ .returnType }}(internal.New{{ .returnType }}Wrapper(&ms.{{ .origAccessor }}.{{ .fieldOriginFullName }}, ms.{{ .stateAccessor }})) {{- else }} return new{{ .returnType }}(&ms.{{ .origAccessor }}.{{ .fieldOriginFullName }}, ms.{{ .stateAccessor }}) {{- end }} @@ -22,21 +22,20 @@ func (ms {{ .structName }}) {{ .fieldName }}() {{ .packageName }}{{ .returnType const messageAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldName }}(t *testing.T) { ms := New{{ .structName }}() assert.Equal(t, {{ .packageName }}New{{ .returnType }}{{- if eq .returnType "Value" }}Empty{{- end }}(), ms.{{ .fieldName }}()) - ms.{{ .origAccessor }}.{{ .fieldOriginFullName }} = *internal.GenTestOrig{{ .fieldOriginName }}() + ms.{{ .origAccessor }}.{{ .fieldOriginFullName }} = *internal.GenTest{{ .fieldOriginName }}() {{- if .messageHasWrapper }} - assert.Equal(t, {{ .packageName }}{{ .returnType }}(internal.New{{ .returnType }}(internal.GenTestOrig{{ .fieldOriginName }}(), ms.{{ .stateAccessor }})), ms.{{ .fieldName }}()) + assert.Equal(t, {{ .packageName }}{{ .returnType }}(internal.GenTest{{ .returnType }}Wrapper()), ms.{{ .fieldName }}()) {{- else }} assert.Equal(t, generateTest{{ .returnType }}(), ms.{{ .fieldName }}()) {{- end }} }` -const messageSetTestTemplate = `orig.{{ .fieldOriginFullName }} = *GenTestOrig{{ .fieldOriginName }}()` - -const messageCopyOrigTemplate = `CopyOrig{{ .fieldOriginName }}(&dest.{{ .fieldOriginFullName }}, &src.{{ .fieldOriginFullName }})` +const messageSetTestTemplate = `orig.{{ .fieldOriginFullName }} = *GenTest{{ .fieldOriginName }}()` type MessageField struct { fieldName string protoID uint32 + nullable bool returnMessage *messageStruct } @@ -55,58 +54,18 @@ func (mf *MessageField) GenerateTestValue(ms *messageStruct) string { return template.Execute(t, mf.templateFields(ms)) } -func (mf *MessageField) GenerateTestFailingUnmarshalProtoValues(*messageStruct) string { - return mf.toProtoField().GenTestFailingUnmarshalProtoValues() -} - -func (mf *MessageField) GenerateTestEncodingValues(*messageStruct) string { - return mf.toProtoField().GenTestEncodingValues() -} - -func (mf *MessageField) GenerateDeleteOrig(*messageStruct) string { - return mf.toProtoField().GenDeleteOrig() -} - -func (mf *MessageField) GenerateCopyOrig(ms *messageStruct) string { - t := template.Parse("messageCopyOrigTemplate", []byte(messageCopyOrigTemplate)) - return template.Execute(t, mf.templateFields(ms)) -} - -func (mf *MessageField) GeneratePoolOrig(*messageStruct) string { - return "" -} - -func (mf *MessageField) GenerateMarshalJSON(*messageStruct) string { - return mf.toProtoField().GenMarshalJSON() -} - -func (mf *MessageField) GenerateUnmarshalJSON(*messageStruct) string { - return mf.toProtoField().GenUnmarshalJSON() -} - -func (mf *MessageField) GenerateSizeProto(*messageStruct) string { - return mf.toProtoField().GenSizeProto() -} - -func (mf *MessageField) GenerateMarshalProto(*messageStruct) string { - return mf.toProtoField().GenMarshalProto() -} - -func (mf *MessageField) GenerateUnmarshalProto(*messageStruct) string { - return mf.toProtoField().GenUnmarshalProto() -} - -func (mf *MessageField) toProtoField() *proto.Field { +func (mf *MessageField) toProtoField(ms *messageStruct) proto.FieldInterface { pt := proto.TypeMessage if mf.returnMessage.getName() == "TraceState" { pt = proto.TypeString } return &proto.Field{ - Type: pt, - ID: mf.protoID, - Name: mf.fieldName, - MessageFullName: mf.returnMessage.getOriginFullName(), - Nullable: false, + Type: pt, + ID: mf.protoID, + Name: mf.fieldName, + MessageName: mf.returnMessage.getOriginName(), + ParentMessageName: ms.protoName, + Nullable: mf.nullable, } } diff --git a/internal/cmd/pdatagen/internal/pdata/one_of_field.go b/internal/cmd/pdatagen/internal/pdata/one_of_field.go index 4f1f5e73e01..d0610bd3a5b 100644 --- a/internal/cmd/pdatagen/internal/pdata/one_of_field.go +++ b/internal/cmd/pdatagen/internal/pdata/one_of_field.go @@ -6,6 +6,7 @@ package pdata // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/int import ( "strings" + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" ) @@ -35,65 +36,80 @@ const oneOfAccessorTestTemplate = `func Test{{ .structName }}_{{ .typeFuncName } ` const oneOfTestFailingUnmarshalProtoValuesTemplate = ` - {{- range .values }} - {{ .GenerateTestFailingUnmarshalProtoValues $.baseStruct $.OneOfField }} + {{- range .fields }} + {{ .GenTestFailingUnmarshalProtoValues }} {{- end }}` const oneOfTestValuesTemplate = ` - {{- range .values }} - {{ .GenerateTestEncodingValues $.baseStruct $.OneOfField }} + {{- range .fields }} + {{ .GenTestEncodingValues }} {{- end }}` const oneOfPoolOrigTemplate = ` - {{- range .values }} - {{ .GeneratePoolOrig $.baseStruct $.OneOfField }} + {{- range .fields }} + {{ .GenPool }} {{- end }}` +const oneOfMessageOrigTemplate = ` +func (m *{{ .protoName }}) Get{{ .originFieldName }}() any { + if m != nil { + return m.{{ .originFieldName }} + } + return nil +} + +{{- range .fields }} +{{ .GenOneOfMessages }} +{{- end }}` + const oneOfDeleteOrigTemplate = `switch ov := orig.{{ .originFieldName }}.(type) { - {{ range .values -}} - case *{{ $.originTypePrefix }}{{ .GetOriginFieldName }}: - {{ .GenerateDeleteOrig $.baseStruct $.OneOfField }}{{- end }} + {{ range .fields -}} + case *{{ $.protoName }}_{{ .GetName }}: + {{ .GenDelete }}{{- end }} } ` const oneOfCopyOrigTemplate = `switch t := src.{{ .originFieldName }}.(type) { -{{- range .values }} -{{ .GenerateCopyOrig $.baseStruct $.OneOfField }} +{{- range .fields }} + case *{{ $.protoName }}_{{ .GetName }}: + {{ .GenCopy }} {{- end }} + default: + dest.{{ .originFieldName }} = nil }` const oneOfMarshalJSONTemplate = `switch orig := orig.{{ .originFieldName }}.(type) { - {{- range .values }} - case *{{ $.originTypePrefix }}{{ .GetOriginFieldName }}: - {{ .GenerateMarshalJSON $.baseStruct $.OneOfField }} + {{- range .fields }} + case *{{ $.protoName }}_{{ .GetName }}: + {{ .GenMarshalJSON }} {{- end }} }` const oneOfUnmarshalJSONTemplate = ` - {{- range .values }} - {{ .GenerateUnmarshalJSON $.baseStruct $.OneOfField }} + {{- range .fields }} + {{ .GenUnmarshalJSON }} {{- end }}` const oneOfSizeProtoTemplate = `switch orig := orig.{{ .originFieldName }}.(type) { case nil: _ = orig break - {{ range .values -}} - case *{{ $.originTypePrefix }}{{ .GetOriginFieldName }}: - {{ .GenerateSizeProto $.baseStruct $.OneOfField }} + {{ range .fields -}} + case *{{ $.protoName }}_{{ .GetName }}: + {{ .GenSizeProto }} {{ end -}} }` const oneOfMarshalProtoTemplate = `switch orig := orig.{{ .originFieldName }}.(type) { - {{- range .values }} - case *{{ $.originTypePrefix }}{{ .GetOriginFieldName }}: - {{ .GenerateMarshalProto $.baseStruct $.OneOfField }} + {{- range .fields }} + case *{{ $.protoName }}_{{ .GetName }}: + {{ .GenMarshalProto }} {{- end }} }` const oneOfUnmarshalProtoTemplate = ` - {{- range .values }} - {{ .GenerateUnmarshalProto $.baseStruct $.OneOfField }} + {{- range .fields }} + {{ .GenUnmarshalProto }} {{- end }}` type OneOfField struct { @@ -124,47 +140,97 @@ func (of *OneOfField) GenerateTestValue(ms *messageStruct) string { return of.values[of.testValueIdx].GenerateTestValue(ms, of) } -func (of *OneOfField) GenerateTestFailingUnmarshalProtoValues(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfTestFailingUnmarshalProtoValuesTemplate", []byte(oneOfTestFailingUnmarshalProtoValuesTemplate)), of.templateFields(ms)) +func (of *OneOfField) toProtoField(ms *messageStruct) proto.FieldInterface { + fields := make([]proto.FieldInterface, len(of.values)) + for i := range of.values { + fields[i] = of.values[i].toProtoField(ms, of) + } + return &oneOfProtoField{ + originFieldName: of.originFieldName, + protoName: ms.protoName, + fields: fields, + } +} + +type oneOfProtoField struct { + originFieldName string + protoName string + fields []proto.FieldInterface +} + +func (of *oneOfProtoField) GenMessageField() string { + return of.originFieldName + " any" +} + +func (of *oneOfProtoField) GenOneOfMessages() string { + return template.Execute(template.Parse("oneOfMessageOrigTemplate", []byte(oneOfMessageOrigTemplate)), of.templateFields()) +} + +func (of *oneOfProtoField) GetName() string { + return of.originFieldName } -func (of *OneOfField) GenerateTestEncodingValues(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfTestValuesTemplate", []byte(oneOfTestValuesTemplate)), of.templateFields(ms)) +func (of *oneOfProtoField) GoType() string { + panic("implement me") } -func (of *OneOfField) GeneratePoolOrig(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfPoolOrigTemplate", []byte(oneOfPoolOrigTemplate)), of.templateFields(ms)) +func (of *oneOfProtoField) DefaultValue() string { + panic("implement me") } -func (of *OneOfField) GenerateDeleteOrig(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfDeleteOrigTemplate", []byte(oneOfDeleteOrigTemplate)), of.templateFields(ms)) +func (of *oneOfProtoField) TestValue() string { + return "&" + of.protoName + "_" + of.fields[0].GetName() + "{" + of.fields[0].GetName() + ": " + of.fields[0].TestValue() + "}" } -func (of *OneOfField) GenerateCopyOrig(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfCopyOrigTemplate", []byte(oneOfCopyOrigTemplate)), of.templateFields(ms)) +func (of *oneOfProtoField) GenTestFailingUnmarshalProtoValues() string { + return template.Execute(template.Parse("oneOfTestFailingUnmarshalProtoValuesTemplate", []byte(oneOfTestFailingUnmarshalProtoValuesTemplate)), of.templateFields()) } -func (of *OneOfField) GenerateMarshalJSON(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfMarshalJSONTemplate", []byte(oneOfMarshalJSONTemplate)), of.templateFields(ms)) +func (of *oneOfProtoField) GenTestEncodingValues() string { + return template.Execute(template.Parse("oneOfTestValuesTemplate", []byte(oneOfTestValuesTemplate)), of.templateFields()) } -func (of *OneOfField) GenerateUnmarshalJSON(ms *messageStruct) string { - return template.Execute(template.Parse("oneOfUnmarshalJSONTemplate", []byte(oneOfUnmarshalJSONTemplate)), of.templateFields(ms)) +func (of *oneOfProtoField) GenPool() string { + return template.Execute(template.Parse("oneOfPoolOrigTemplate", []byte(oneOfPoolOrigTemplate)), of.templateFields()) } -func (of *OneOfField) GenerateSizeProto(ms *messageStruct) string { +func (of *oneOfProtoField) GenDelete() string { + return template.Execute(template.Parse("oneOfDeleteOrigTemplate", []byte(oneOfDeleteOrigTemplate)), of.templateFields()) +} + +func (of *oneOfProtoField) GenCopy() string { + return template.Execute(template.Parse("oneOfCopyOrigTemplate", []byte(oneOfCopyOrigTemplate)), of.templateFields()) +} + +func (of *oneOfProtoField) GenMarshalJSON() string { + return template.Execute(template.Parse("oneOfMarshalJSONTemplate", []byte(oneOfMarshalJSONTemplate)), of.templateFields()) +} + +func (of *oneOfProtoField) GenUnmarshalJSON() string { + return template.Execute(template.Parse("oneOfUnmarshalJSONTemplate", []byte(oneOfUnmarshalJSONTemplate)), of.templateFields()) +} + +func (of *oneOfProtoField) GenSizeProto() string { t := template.Parse("oneOfSizeProtoTemplate", []byte(oneOfSizeProtoTemplate)) - return template.Execute(t, of.templateFields(ms)) + return template.Execute(t, of.templateFields()) } -func (of *OneOfField) GenerateMarshalProto(ms *messageStruct) string { +func (of *oneOfProtoField) GenMarshalProto() string { t := template.Parse("oneOfMarshalProtoTemplate", []byte(oneOfMarshalProtoTemplate)) - return template.Execute(t, of.templateFields(ms)) + return template.Execute(t, of.templateFields()) } -func (of *OneOfField) GenerateUnmarshalProto(ms *messageStruct) string { +func (of *oneOfProtoField) GenUnmarshalProto() string { t := template.Parse("oneOfUnmarshalProtoTemplate", []byte(oneOfUnmarshalProtoTemplate)) - return template.Execute(t, of.templateFields(ms)) + return template.Execute(t, of.templateFields()) +} + +func (of *oneOfProtoField) templateFields() map[string]any { + return map[string]any{ + "originFieldName": of.originFieldName, + "fields": of.fields, + "protoName": of.protoName, + } } func (of *OneOfField) templateFields(ms *messageStruct) map[string]any { @@ -181,7 +247,6 @@ func (of *OneOfField) templateFields(ms *messageStruct) map[string]any { "origAccessor": origAccessor(ms.getHasWrapper()), "stateAccessor": stateAccessor(ms.getHasWrapper()), "values": of.values, - "originTypePrefix": ms.originFullName + "_", } } @@ -190,17 +255,8 @@ var _ Field = (*OneOfField)(nil) type oneOfValue interface { GetOriginFieldName() string GenerateAccessors(ms *messageStruct, of *OneOfField) string + GenerateType(ms *messageStruct, of *OneOfField) string GenerateTests(ms *messageStruct, of *OneOfField) string GenerateTestValue(ms *messageStruct, of *OneOfField) string - GenerateTestFailingUnmarshalProtoValues(ms *messageStruct, of *OneOfField) string - GenerateTestEncodingValues(ms *messageStruct, of *OneOfField) string - GeneratePoolOrig(ms *messageStruct, of *OneOfField) string - GenerateDeleteOrig(ms *messageStruct, of *OneOfField) string - GenerateCopyOrig(ms *messageStruct, of *OneOfField) string - GenerateType(ms *messageStruct, of *OneOfField) string - GenerateMarshalJSON(ms *messageStruct, of *OneOfField) string - GenerateUnmarshalJSON(ms *messageStruct, of *OneOfField) string - GenerateSizeProto(ms *messageStruct, of *OneOfField) string - GenerateMarshalProto(ms *messageStruct, of *OneOfField) string - GenerateUnmarshalProto(ms *messageStruct, of *OneOfField) string + toProtoField(ms *messageStruct, of *OneOfField) proto.FieldInterface } diff --git a/internal/cmd/pdatagen/internal/pdata/one_of_message_value.go b/internal/cmd/pdatagen/internal/pdata/one_of_message_value.go index 4d5ecc66109..d015703c05b 100644 --- a/internal/cmd/pdatagen/internal/pdata/one_of_message_value.go +++ b/internal/cmd/pdatagen/internal/pdata/one_of_message_value.go @@ -17,7 +17,7 @@ const oneOfMessageAccessorsTemplate = `// {{ .fieldName }} returns the {{ .lower // // Calling this function on zero-initialized {{ .structName }} will cause a panic. func (ms {{ .structName }}) {{ .fieldName }}() {{ .returnType }} { - v, ok := ms.orig.Get{{ .originOneOfFieldName }}().(*{{ .originStructType }}) + v, ok := ms.orig.Get{{ .originOneOfFieldName }}().(*internal.{{ .originStructType }}) if !ok { return {{ .returnType }}{} } @@ -31,13 +31,13 @@ func (ms {{ .structName }}) {{ .fieldName }}() {{ .returnType }} { // Calling this function on zero-initialized {{ .structName }} will cause a panic. func (ms {{ .structName }}) SetEmpty{{ .fieldName }}() {{ .returnType }} { ms.state.AssertMutable() - var ov *{{ .originStructType }} + var ov *internal.{{ .originStructType }} if !internal.UseProtoPooling.IsEnabled() { - ov = &{{ .originStructType }}{} + ov = &internal.{{ .originStructType }}{} } else { - ov = internal.ProtoPool{{ .oneOfName }}.Get().(*{{ .originStructType }}) + ov = internal.ProtoPool{{ .oneOfName }}.Get().(*internal.{{ .originStructType }}) } - ov.{{ .fieldName }} = internal.NewOrig{{ .fieldOriginName }}() + ov.{{ .fieldName }} = internal.New{{ .fieldOriginName }}() ms.orig.{{ .originOneOfFieldName }} = ov return new{{ .returnType }}(ov.{{ .fieldName }}, ms.state) }` @@ -46,30 +46,19 @@ const oneOfMessageAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldN ms := New{{ .structName }}() ms.SetEmpty{{ .fieldName }}() assert.Equal(t, New{{ .returnType }}(), ms.{{ .fieldName }}()) - ms.orig.Get{{ .originOneOfFieldName }}().(*{{ .originStructType }}).{{ .fieldName }} = internal.GenTestOrig{{ .returnType }}() + ms.orig.Get{{ .originOneOfFieldName }}().(*internal.{{ .originStructType }}).{{ .fieldName }} = internal.GenTest{{ .returnType }}() assert.Equal(t, {{ .typeName }}, ms.{{ .originOneOfTypeFuncName }}()) assert.Equal(t, generateTest{{ .returnType }}(), ms.{{ .fieldName }}()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { new{{ .structName }}(&{{ .originStructName }}{}, sharedState).SetEmpty{{ .fieldName }}() }) + assert.Panics(t, func() { new{{ .structName }}(internal.New{{ .originStructName }}(), sharedState).SetEmpty{{ .fieldName }}() }) } ` -const oneOfMessageSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &{{ .originStructType }}{ -{{- .fieldName }}: GenTestOrig{{ .fieldOriginName }}() }` - -const oneOfMessageCopyOrigTemplate = ` case *{{ .originStructType }}: - var ov *{{ .originStructType }} - if !UseProtoPooling.IsEnabled() { - ov = &{{ .originStructType }}{} - } else { - ov = ProtoPool{{ .oneOfName }}.Get().(*{{ .originStructType }}) - } - ov.{{ .fieldName }} = NewOrig{{ .fieldOriginName }}() - CopyOrig{{ .fieldOriginName }}(ov.{{ .fieldName }}, t.{{ .fieldName }}) - dest.{{ .originOneOfFieldName }} = ov` - -const oneOfMessageTypeTemplate = `case *{{ .originStructType }}: +const oneOfMessageSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &internal.{{ .originStructType }}{ +{{- .fieldName }}: GenTest{{ .fieldOriginName }}() }` + +const oneOfMessageTypeTemplate = `case *internal.{{ .originStructType }}: return {{ .typeName }}` type OneOfMessageValue struct { @@ -97,61 +86,21 @@ func (omv *OneOfMessageValue) GenerateTestValue(ms *messageStruct, of *OneOfFiel return template.Execute(t, omv.templateFields(ms, of)) } -func (omv *OneOfMessageValue) GenerateTestFailingUnmarshalProtoValues(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenTestFailingUnmarshalProtoValues() -} - -func (omv *OneOfMessageValue) GenerateTestEncodingValues(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenTestEncodingValues() -} - -func (omv *OneOfMessageValue) GeneratePoolOrig(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenPoolVarOrig() -} - -func (omv *OneOfMessageValue) GenerateDeleteOrig(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenDeleteOrig() -} - -func (omv *OneOfMessageValue) GenerateCopyOrig(ms *messageStruct, of *OneOfField) string { - t := template.Parse("oneOfMessageCopyOrigTemplate", []byte(oneOfMessageCopyOrigTemplate)) - return template.Execute(t, omv.templateFields(ms, of)) -} - func (omv *OneOfMessageValue) GenerateType(ms *messageStruct, of *OneOfField) string { t := template.Parse("oneOfMessageTypeTemplate", []byte(oneOfMessageTypeTemplate)) return template.Execute(t, omv.templateFields(ms, of)) } -func (omv *OneOfMessageValue) GenerateMarshalJSON(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenMarshalJSON() -} - -func (omv *OneOfMessageValue) GenerateUnmarshalJSON(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenUnmarshalJSON() -} - -func (omv *OneOfMessageValue) GenerateSizeProto(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenSizeProto() -} - -func (omv *OneOfMessageValue) GenerateMarshalProto(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenMarshalProto() -} - -func (omv *OneOfMessageValue) GenerateUnmarshalProto(ms *messageStruct, of *OneOfField) string { - return omv.toProtoField(ms, of).GenUnmarshalProto() -} - -func (omv *OneOfMessageValue) toProtoField(ms *messageStruct, of *OneOfField) *proto.Field { +func (omv *OneOfMessageValue) toProtoField(ms *messageStruct, of *OneOfField) proto.FieldInterface { return &proto.Field{ - Type: proto.TypeMessage, - ID: omv.protoID, - OneOfGroup: of.originFieldName, - OneOfMessageFullName: ms.originFullName + "_" + omv.fieldName, - Name: omv.fieldName, - MessageFullName: omv.returnMessage.getOriginFullName(), - Nullable: true, + Type: proto.TypeMessage, + ID: omv.protoID, + OneOfGroup: of.originFieldName, + OneOfMessageName: ms.protoName + "_" + omv.fieldName, + Name: omv.fieldName, + MessageName: omv.returnMessage.getOriginFullName(), + ParentMessageName: ms.protoName, + Nullable: true, } } @@ -165,9 +114,9 @@ func (omv *OneOfMessageValue) templateFields(ms *messageStruct, of *OneOfField) "returnType": omv.returnMessage.getName(), "originOneOfTypeFuncName": of.typeFuncName(), "lowerFieldName": strings.ToLower(omv.fieldName), - "originStructName": ms.originFullName, - "originStructType": ms.originFullName + "_" + omv.fieldName, - "oneOfName": proto.ExtractNameFromFull(ms.originFullName + "_" + omv.fieldName), + "originStructName": ms.protoName, + "originStructType": ms.protoName + "_" + omv.fieldName, + "oneOfName": proto.ExtractNameFromFull(ms.protoName + "_" + omv.fieldName), } } diff --git a/internal/cmd/pdatagen/internal/pdata/one_of_primitive_value.go b/internal/cmd/pdatagen/internal/pdata/one_of_primitive_value.go index 467d58c7e00..ea140f808f9 100644 --- a/internal/cmd/pdatagen/internal/pdata/one_of_primitive_value.go +++ b/internal/cmd/pdatagen/internal/pdata/one_of_primitive_value.go @@ -18,11 +18,11 @@ func (ms {{ .structName }}) {{ .accessorFieldName }}() {{ .returnType }} { // Set{{ .accessorFieldName }} replaces the {{ .lowerFieldName }} associated with this {{ .structName }}. func (ms {{ .structName }}) Set{{ .accessorFieldName }}(v {{ .returnType }}) { ms.state.AssertMutable() - var ov *{{ .originStructType }} + var ov *internal.{{ .originStructType }} if !internal.UseProtoPooling.IsEnabled() { - ov = &{{ .originStructType }}{} + ov = &internal.{{ .originStructType }}{} } else { - ov = internal.ProtoPool{{ .oneOfName }}.Get().(*{{ .originStructType }}) + ov = internal.ProtoPool{{ .oneOfName }}.Get().(*internal.{{ .originStructType }}) } ov.{{ .originFieldName }} = v ms.orig.{{ .originOneOfFieldName }} = ov @@ -48,24 +48,14 @@ const oneOfPrimitiveAccessorTestTemplate = `func Test{{ .structName }}_{{ .acces assert.Equal(t, {{ .typeName }}, ms.{{ .originOneOfTypeFuncName }}()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { new{{ .structName }}(&{{ .originStructName }}{}, sharedState).Set{{ .accessorFieldName }}({{ .testValue }}) }) + assert.Panics(t, func() { new{{ .structName }}(internal.New{{ .originStructName }}(), sharedState).Set{{ .accessorFieldName }}({{ .testValue }}) }) } ` -const oneOfPrimitiveSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &{{ .originStructType }}{ +const oneOfPrimitiveSetTestTemplate = `orig.{{ .originOneOfFieldName }} = &internal.{{ .originStructType }}{ {{- .originFieldName }}: {{ .testValue }}}` -const oneOfPrimitiveCopyOrigTemplate = `case *{{ .originStructType }}: - var ov *{{ .originStructType }} - if !UseProtoPooling.IsEnabled() { - ov = &{{ .originStructType }}{} - } else { - ov = ProtoPool{{ .oneOfName }}.Get().(*{{ .originStructType }}) - } - ov.{{ .originFieldName }} = t.{{ .originFieldName }} - dest.{{ .originOneOfFieldName }} = ov` - -const oneOfPrimitiveTypeTemplate = `case *{{ .originStructType }}: +const oneOfPrimitiveTypeTemplate = `case *internal.{{ .originStructType }}: return {{ .typeName }}` type OneOfPrimitiveValue struct { @@ -94,60 +84,20 @@ func (opv *OneOfPrimitiveValue) GenerateTestValue(ms *messageStruct, of *OneOfFi return template.Execute(t, opv.templateFields(ms, of)) } -func (opv *OneOfPrimitiveValue) GenerateTestFailingUnmarshalProtoValues(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenTestFailingUnmarshalProtoValues() -} - -func (opv *OneOfPrimitiveValue) GenerateTestEncodingValues(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenTestEncodingValues() -} - -func (opv *OneOfPrimitiveValue) GeneratePoolOrig(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenPoolVarOrig() -} - -func (opv *OneOfPrimitiveValue) GenerateDeleteOrig(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenDeleteOrig() -} - -func (opv *OneOfPrimitiveValue) GenerateCopyOrig(ms *messageStruct, of *OneOfField) string { - t := template.Parse("oneOfPrimitiveCopyOrigTemplate", []byte(oneOfPrimitiveCopyOrigTemplate)) - return template.Execute(t, opv.templateFields(ms, of)) -} - func (opv *OneOfPrimitiveValue) GenerateType(ms *messageStruct, of *OneOfField) string { t := template.Parse("oneOfPrimitiveCopyOrigTemplate", []byte(oneOfPrimitiveTypeTemplate)) return template.Execute(t, opv.templateFields(ms, of)) } -func (opv *OneOfPrimitiveValue) GenerateMarshalJSON(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenMarshalJSON() -} - -func (opv *OneOfPrimitiveValue) GenerateUnmarshalJSON(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenUnmarshalJSON() -} - -func (opv *OneOfPrimitiveValue) GenerateSizeProto(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenSizeProto() -} - -func (opv *OneOfPrimitiveValue) GenerateMarshalProto(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenMarshalProto() -} - -func (opv *OneOfPrimitiveValue) GenerateUnmarshalProto(ms *messageStruct, of *OneOfField) string { - return opv.toProtoField(ms, of).GenUnmarshalProto() -} - -func (opv *OneOfPrimitiveValue) toProtoField(ms *messageStruct, of *OneOfField) *proto.Field { +func (opv *OneOfPrimitiveValue) toProtoField(ms *messageStruct, of *OneOfField) proto.FieldInterface { pf := &proto.Field{ - Type: opv.protoType, - ID: opv.protoID, - OneOfGroup: of.originFieldName, - Name: opv.originFieldName, - OneOfMessageFullName: ms.originFullName + "_" + opv.originFieldName, - Nullable: true, + Type: opv.protoType, + ID: opv.protoID, + OneOfGroup: of.originFieldName, + Name: opv.originFieldName, + OneOfMessageName: ms.protoName + "_" + opv.originFieldName, + ParentMessageName: ms.protoName, + Nullable: true, } return pf } @@ -166,9 +116,9 @@ func (opv *OneOfPrimitiveValue) templateFields(ms *messageStruct, of *OneOfField "returnType": pf.GoType(), "originFieldName": opv.originFieldName, "originOneOfFieldName": of.originFieldName, - "originStructName": ms.originFullName, - "originStructType": ms.originFullName + "_" + opv.originFieldName, - "oneOfName": proto.ExtractNameFromFull(ms.originFullName + "_" + opv.originFieldName), + "originStructName": ms.protoName, + "originStructType": ms.protoName + "_" + opv.originFieldName, + "oneOfName": proto.ExtractNameFromFull(ms.protoName + "_" + opv.originFieldName), } } diff --git a/internal/cmd/pdatagen/internal/pdata/optional_primitive_field.go b/internal/cmd/pdatagen/internal/pdata/optional_primitive_field.go index bc66804f15b..b917664d88c 100644 --- a/internal/cmd/pdatagen/internal/pdata/optional_primitive_field.go +++ b/internal/cmd/pdatagen/internal/pdata/optional_primitive_field.go @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 package pdata // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/pdata" - import ( "strings" @@ -24,7 +23,7 @@ func (ms {{ .structName }}) Has{{ .fieldName }}() bool { // Set{{ .fieldName }} replaces the {{ .lowerFieldName }} associated with this {{ .structName }}. func (ms {{ .structName }}) Set{{ .fieldName }}(v {{ .returnType }}) { ms.state.AssertMutable() - ms.orig.{{ .fieldName }}_ = &{{ .originStructType }}{{ "{" }}{{ .fieldName }}: v} + ms.orig.{{ .fieldName }}_ = &internal.{{ .originStructType }}{{ "{" }}{{ .fieldName }}: v} } // Remove{{ .fieldName }} removes the {{ .lowerFieldName }} associated with this {{ .structName }}. @@ -55,19 +54,18 @@ const optionalPrimitiveAccessorsTestTemplate = `func Test{{ .structName }}_{{ .f assert.False(t, dest.Has{{ .fieldName }}()) }` -const optionalPrimitiveSetTestTemplate = `orig.{{ .fieldName }}_ = &{{ .originStructType }}{ +const optionalPrimitiveSetTestTemplate = `orig.{{ .fieldName }}_ = &internal.{{ .originStructType }}{ {{- .fieldName }}: {{ .testValue }}}` -const optionalPrimitiveCopyOrigTemplate = `if src{{ .fieldName }}, ok := src.{{ .fieldName }}_.(*{{ .originStructType }}); ok { - dest{{ .fieldName }}, ok := dest.{{ .fieldName }}_.(*{{ .originStructType }}) - if !ok { - dest{{ .fieldName }} = &{{ .originStructType }}{} - dest.{{ .fieldName }}_ = dest{{ .fieldName }} +const optionalOneOfMessageOrigTemplate = ` +func (m *{{ .ParentMessageName }}) Get{{ .OneOfGroup }}() any { + if m != nil { + return m.{{ .Name }}_ } - dest{{ .fieldName }}.{{ .fieldName }} = src{{ .fieldName }}.{{ .fieldName }} -} else { - dest.{{ .fieldName }}_ = nil -}` + return nil +} + +` type OptionalPrimitiveField struct { fieldName string @@ -87,65 +85,66 @@ func (opv *OptionalPrimitiveField) GenerateTestValue(ms *messageStruct) string { return template.Execute(template.Parse("optionalPrimitiveSetTestTemplate", []byte(optionalPrimitiveSetTestTemplate)), opv.templateFields(ms)) } -func (opv *OptionalPrimitiveField) GenerateTestFailingUnmarshalProtoValues(ms *messageStruct) string { - return opv.toProtoField(ms).GenTestFailingUnmarshalProtoValues() +type optionalPrimitiveProtoField struct { + *proto.Field } -func (opv *OptionalPrimitiveField) GenerateTestEncodingValues(ms *messageStruct) string { - return opv.toProtoField(ms).GenTestEncodingValues() +func (opv optionalPrimitiveProtoField) GetName() string { + return opv.Name + "_" } -func (opv *OptionalPrimitiveField) GeneratePoolOrig(ms *messageStruct) string { - return opv.toProtoField(ms).GenPoolVarOrig() +func (opv optionalPrimitiveProtoField) TestValue() string { + return "&" + opv.OneOfMessageName + "{" + opv.Name + ": " + opv.Field.TestValue() + "}" } -func (opv *OptionalPrimitiveField) GenerateDeleteOrig(ms *messageStruct) string { - return "switch ov := orig." + opv.fieldName + "_.(type) {\n\tcase *" + ms.getOriginFullName() + "_" + opv.fieldName + ":\n\t" + opv.toProtoField(ms).GenDeleteOrig() + "\n}\n" +func (opv optionalPrimitiveProtoField) GenMessageField() string { + return opv.Name + "_ any" } -func (opv *OptionalPrimitiveField) GenerateCopyOrig(ms *messageStruct) string { - return template.Execute(template.Parse("optionalPrimitiveCopyOrigTemplate", []byte(optionalPrimitiveCopyOrigTemplate)), opv.templateFields(ms)) +func (opv optionalPrimitiveProtoField) GenOneOfMessages() string { + return template.Execute(template.Parse("optionalOneOfMessageOrigTemplate", []byte(optionalOneOfMessageOrigTemplate)), opv.Field) + opv.Field.GenOneOfMessages() } -func (opv *OptionalPrimitiveField) GenerateMarshalJSON(ms *messageStruct) string { - return "if orig, ok := orig." + opv.fieldName + "_.(*" + ms.originFullName + "_" + opv.fieldName + "); ok {\n\t" + opv.toProtoField(ms).GenMarshalJSON() + "}" +func (opv optionalPrimitiveProtoField) GenCopy() string { + return "switch t := src." + opv.Name + "_.(type) {\n\tcase *" + opv.OneOfMessageName + ":\n\t" + opv.Field.GenCopy() + "\ndefault: dest." + opv.Name + "_ = nil\n}\n" } -func (opv *OptionalPrimitiveField) GenerateUnmarshalJSON(ms *messageStruct) string { - return opv.toProtoField(ms).GenUnmarshalJSON() +func (opv optionalPrimitiveProtoField) GenDelete() string { + return "switch ov := orig." + opv.Name + "_.(type) {\n\tcase *" + opv.OneOfMessageName + ":\n\t" + opv.Field.GenDelete() + "\n}\n" } -func (opv *OptionalPrimitiveField) GenerateSizeProto(ms *messageStruct) string { - return "if orig, ok := orig." + opv.fieldName + "_.(*" + ms.originFullName + "_" + opv.fieldName + "); ok {\n\t_ = orig\n\t" + opv.toProtoField(ms).GenSizeProto() + "}" +func (opv optionalPrimitiveProtoField) GenMarshalJSON() string { + return "if orig, ok := orig." + opv.Name + "_.(*" + opv.OneOfMessageName + "); ok {\n\t" + opv.Field.GenMarshalJSON() + "}" } -func (opv *OptionalPrimitiveField) GenerateMarshalProto(ms *messageStruct) string { - return "if orig, ok := orig." + opv.fieldName + "_.(*" + ms.originFullName + "_" + opv.fieldName + "); ok {\n\t" + opv.toProtoField(ms).GenMarshalProto() + "}" +func (opv optionalPrimitiveProtoField) GenSizeProto() string { + return "if orig, ok := orig." + opv.Name + "_.(*" + opv.OneOfMessageName + "); ok {\n\t_ = orig\n\t" + opv.Field.GenSizeProto() + "}" } -func (opv *OptionalPrimitiveField) GenerateUnmarshalProto(ms *messageStruct) string { - return opv.toProtoField(ms).GenUnmarshalProto() +func (opv optionalPrimitiveProtoField) GenMarshalProto() string { + return "if orig, ok := orig." + opv.Name + "_.(*" + opv.OneOfMessageName + "); ok {\n\t" + opv.Field.GenMarshalProto() + "}" } -func (opv *OptionalPrimitiveField) toProtoField(ms *messageStruct) *proto.Field { - return &proto.Field{ - Type: opv.protoType, - ID: opv.protoID, - OneOfGroup: opv.fieldName + "_", - Name: opv.fieldName, - OneOfMessageFullName: ms.originFullName + "_" + opv.fieldName, - Nullable: true, - } +func (opv *OptionalPrimitiveField) toProtoField(ms *messageStruct) proto.FieldInterface { + return optionalPrimitiveProtoField{&proto.Field{ + Type: opv.protoType, + ID: opv.protoID, + OneOfGroup: opv.fieldName + "_", + Name: opv.fieldName, + OneOfMessageName: ms.protoName + "_" + opv.fieldName, + ParentMessageName: ms.protoName, + Nullable: true, + }} } func (opv *OptionalPrimitiveField) templateFields(ms *messageStruct) map[string]any { - pf := opv.toProtoField(ms) + pf := opv.toProtoField(ms).(optionalPrimitiveProtoField) return map[string]any{ "structName": ms.getName(), "defaultVal": pf.DefaultValue(), "fieldName": opv.fieldName, "lowerFieldName": strings.ToLower(opv.fieldName), - "testValue": pf.TestValue(), + "testValue": pf.Field.TestValue(), "returnType": pf.GoType(), "originName": ms.getOriginName(), "originStructName": ms.getOriginFullName(), diff --git a/internal/cmd/pdatagen/internal/pdata/packages.go b/internal/cmd/pdatagen/internal/pdata/packages.go index 28442d84953..c35d873d413 100644 --- a/internal/cmd/pdatagen/internal/pdata/packages.go +++ b/internal/cmd/pdatagen/internal/pdata/packages.go @@ -8,6 +8,8 @@ import ( "path/filepath" "slices" "strings" + + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" ) var nonInternalDeps = []string{ @@ -32,6 +34,7 @@ var AllPackages = []*Package{ pprofile, pprofileotlp, xpdataEntity, + prequest, } // Package is a struct used to generate files. @@ -39,6 +42,7 @@ type Package struct { info *PackageInfo // Can be any of sliceStruct, sliceOfValues, messageStruct. structs []baseStruct + enums []*proto.Enum } type PackageInfo struct { @@ -51,7 +55,7 @@ type PackageInfo struct { // GenerateFiles generates files with the configured data structures for this Package. func (p *Package) GenerateFiles() error { for _, s := range p.structs { - if s.getHasOnlyOrig() { + if s.getHasOnlyInternal() { continue } path := filepath.Join("pdata", p.info.path, "generated_"+strings.ToLower(s.getName())+".go") @@ -65,7 +69,7 @@ func (p *Package) GenerateFiles() error { // GenerateTestFiles generates files with tests for the configured data structures for this Package. func (p *Package) GenerateTestFiles() error { for _, s := range p.structs { - if s.getHasOnlyOrig() { + if s.getHasOnlyInternal() { continue } path := filepath.Join("pdata", p.info.path, "generated_"+strings.ToLower(s.getName())+"_test.go") @@ -79,6 +83,9 @@ func (p *Package) GenerateTestFiles() error { // GenerateInternalFiles generates files with internal structs for this Package. func (p *Package) GenerateInternalFiles() error { for _, s := range p.structs { + if !s.getHasWrapper() { + continue + } path := filepath.Join("pdata", "internal", "generated_wrapper_"+strings.ToLower(s.getOriginName())+".go") saveImports := slices.Clone(p.info.imports) p.info.imports = slices.DeleteFunc(p.info.imports, func(s string) bool { @@ -92,15 +99,19 @@ func (p *Package) GenerateInternalFiles() error { return nil } -// GenerateInternalTestsFiles generates files with internal tests for this Package. -func (p *Package) GenerateInternalTestsFiles() error { +// GenerateProtoMessageFiles generates files with proto messages for this Package. +func (p *Package) GenerateProtoMessageFiles() error { for _, s := range p.structs { + pm := s.getProtoMessage() + if pm == nil { + continue + } saveTestImports := slices.Clone(p.info.testImports) p.info.testImports = slices.DeleteFunc(p.info.testImports, func(s string) bool { return slices.Contains(nonInternalDeps, s) }) - path := filepath.Join("pdata", "internal", "generated_wrapper_"+strings.ToLower(s.getOriginName())+"_test.go") - if err := os.WriteFile(path, s.generateInternalTests(p.info), 0o600); err != nil { + path := filepath.Join("pdata", "internal", "generated_proto_"+strings.ToLower(s.getOriginName())+".go") + if err := os.WriteFile(path, pm.GenerateMessage(p.info.imports, p.info.testImports), 0o600); err != nil { return err } p.info.testImports = saveTestImports @@ -108,6 +119,37 @@ func (p *Package) GenerateInternalTestsFiles() error { return nil } +// GenerateProtoMessageTestsFiles generates files with proto messages tests for this Package. +func (p *Package) GenerateProtoMessageTestsFiles() error { + for _, s := range p.structs { + pm := s.getProtoMessage() + if pm == nil { + continue + } + saveTestImports := slices.Clone(p.info.testImports) + p.info.testImports = slices.DeleteFunc(p.info.testImports, func(s string) bool { + return slices.Contains(nonInternalDeps, s) + }) + path := filepath.Join("pdata", "internal", "generated_proto_"+strings.ToLower(pm.Name)+"_test.go") + if err := os.WriteFile(path, pm.GenerateMessageTests(p.info.imports, p.info.testImports), 0o600); err != nil { + return err + } + p.info.testImports = saveTestImports + } + return nil +} + +// GenerateProtoEnumFiles generates files with proto messages for this Package. +func (p *Package) GenerateProtoEnumFiles() error { + for _, s := range p.enums { + path := filepath.Join("pdata", "internal", "generated_enum_"+strings.ToLower(s.Name)+".go") + if err := os.WriteFile(path, s.GenerateEnum(), 0o600); err != nil { + return err + } + } + return nil +} + // usedByOtherDataTypes defines if the package is used by other data types and orig fields of the package's structs // need to be accessible from other pdata packages. func usedByOtherDataTypes(packageName string) bool { diff --git a/internal/cmd/pdatagen/internal/pdata/pcommon_package.go b/internal/cmd/pdatagen/internal/pdata/pcommon_package.go index 12245f3595b..087b1e49413 100644 --- a/internal/cmd/pdatagen/internal/pdata/pcommon_package.go +++ b/internal/cmd/pdatagen/internal/pdata/pcommon_package.go @@ -21,8 +21,6 @@ var pcommon = &Package{ `"go.opentelemetry.io/collector/pdata/internal"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/internal/proto"`, - `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, - `otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1"`, }, testImports: []string{ `"strconv"`, @@ -35,14 +33,13 @@ var pcommon = &Package{ `gootlpresource "go.opentelemetry.io/proto/slim/otlp/resource/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, - `otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, }, }, structs: []baseStruct{ anyValueStruct, arrayValueStruct, + keyValueStruct, keyValueListStruct, anyValueSlice, scope, @@ -57,10 +54,11 @@ var pcommon = &Package{ } var scope = &messageStruct{ - structName: "InstrumentationScope", - packageName: "pcommon", - description: "// InstrumentationScope is a message representing the instrumentation scope information.", - originFullName: "otlpcommon.InstrumentationScope", + structName: "InstrumentationScope", + packageName: "pcommon", + description: "// InstrumentationScope is a message representing the instrumentation scope information.", + protoName: "InstrumentationScope", + upstreamProto: "gootlpcommon.InstrumentationScope", fields: []Field{ &PrimitiveField{ fieldName: "Name", @@ -92,36 +90,42 @@ var mapStruct = &messageSlice{ structName: "Map", packageName: "pcommon", elementNullable: false, - element: &messageStruct{ - originFullName: "otlpcommon.KeyValue", - fields: []Field{ - &PrimitiveField{ - fieldName: "Key", - protoID: 1, - protoType: proto.TypeString, - }, - &MessageField{ - fieldName: "Value", - protoID: 2, - returnMessage: anyValue, - }, + element: keyValueStruct, +} + +var keyValueStruct = &messageStruct{ + structName: "KeyValue", + protoName: "KeyValue", + upstreamProto: "gootlpcommon.KeyValue", + fields: []Field{ + &PrimitiveField{ + fieldName: "Key", + protoID: 1, + protoType: proto.TypeString, + }, + &MessageField{ + fieldName: "Value", + protoID: 2, + returnMessage: anyValueClone, }, }, + hasOnlyInternal: true, } -var anyValue = &messageStruct{ - structName: "Value", - packageName: "pcommon", - originFullName: "otlpcommon.AnyValue", +var anyValueClone = &messageStruct{ + structName: "Value", + protoName: "AnyValue", } // anyValueStruct needs to be different from anyValue because otherwise we cause initialization circular deps with mapStruct. var anyValueStruct = &messageStruct{ - structName: "Value", - originFullName: "otlpcommon.AnyValue", + structName: "Value", + packageName: "pcommon", + protoName: "AnyValue", + upstreamProto: "gootlpcommon.AnyValue", fields: []Field{ &OneOfField{ - typeName: "MetricType", + typeName: "ValueType", originFieldName: "Value", testValueIdx: 1, // omitOriginFieldNameInNames: true, @@ -169,13 +173,14 @@ var anyValueStruct = &messageStruct{ }, }, }, - hasOnlyOrig: true, + hasOnlyInternal: true, } var keyValueListStruct = &messageStruct{ - structName: "KeyValueList", - description: "KeyValueList is a list of KeyValue messages. We need KeyValueList as a message since oneof in AnyValue does not allow repeated fields.", - originFullName: "otlpcommon.KeyValueList", + structName: "KeyValueList", + description: "// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message since oneof in AnyValue does not allow repeated fields.", + protoName: "KeyValueList", + upstreamProto: "gootlpcommon.KeyValueList", fields: []Field{ &SliceField{ fieldName: "Values", @@ -184,13 +189,14 @@ var keyValueListStruct = &messageStruct{ returnSlice: mapStruct, }, }, - hasOnlyOrig: true, + hasOnlyInternal: true, } var arrayValueStruct = &messageStruct{ - structName: "ArrayValue", - description: "// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message since oneof in AnyValue does not allow repeated fields.", - originFullName: "otlpcommon.ArrayValue", + structName: "ArrayValue", + description: "// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message since oneof in AnyValue does not allow repeated fields.", + protoName: "ArrayValue", + upstreamProto: "gootlpcommon.ArrayValue", fields: []Field{ &SliceField{ fieldName: "Values", @@ -199,20 +205,20 @@ var arrayValueStruct = &messageStruct{ returnSlice: anyValueSlice, }, }, - hasOnlyOrig: true, + hasOnlyInternal: true, } var anyValueSlice = &messageSlice{ structName: "Slice", packageName: "pcommon", elementNullable: false, - element: anyValue, + element: anyValueClone, } var traceState = &messageStruct{ - structName: "TraceState", - packageName: "pcommon", - originFullName: "otlpcommon.TraceState", // Fake name to generate correct CopyOrig* name. + structName: "TraceState", + packageName: "pcommon", + protoName: "TraceState", // Fake name to generate correct CopyOrig* name. } var timestampType = &TypedType{ @@ -227,25 +233,26 @@ var traceIDType = &TypedType{ structName: "TraceID", packageName: "pcommon", protoType: proto.TypeMessage, - messageName: "data.TraceID", - defaultVal: "data.TraceID([16]byte{})", - testVal: "data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})", + messageName: "TraceID", + defaultVal: "TraceID([16]byte{})", + testVal: "TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})", } var spanIDType = &TypedType{ structName: "SpanID", packageName: "pcommon", protoType: proto.TypeMessage, - messageName: "data.SpanID", - defaultVal: "data.SpanID([8]byte{})", - testVal: "data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})", + messageName: "SpanID", + defaultVal: "SpanID([8]byte{})", + testVal: "SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})", } var resource = &messageStruct{ - structName: "Resource", - packageName: "pcommon", - description: "// Resource is a message representing the resource information.", - originFullName: "otlpresource.Resource", + structName: "Resource", + packageName: "pcommon", + description: "// Resource is a message representing the resource information.", + protoName: "Resource", + upstreamProto: "gootlpresource.Resource", fields: []Field{ &SliceField{ fieldName: "Attributes", diff --git a/internal/cmd/pdatagen/internal/pdata/plog_package.go b/internal/cmd/pdatagen/internal/pdata/plog_package.go index 880d8896704..331f434cae2 100644 --- a/internal/cmd/pdatagen/internal/pdata/plog_package.go +++ b/internal/cmd/pdatagen/internal/pdata/plog_package.go @@ -19,11 +19,8 @@ var plog = &Package{ `"sync"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/internal/proto"`, - `otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`, - `otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, testImports: []string{ @@ -38,15 +35,13 @@ var plog = &Package{ `gootlplogs "go.opentelemetry.io/proto/slim/otlp/logs/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, - `otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`, - `otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, }, structs: []baseStruct{ logs, + logsData, resourceLogsSlice, resourceLogs, scopeLogsSlice, @@ -54,12 +49,16 @@ var plog = &Package{ logSlice, logRecord, }, + enums: []*proto.Enum{ + severityNumberEnum, + }, } var logs = &messageStruct{ - structName: "Logs", - description: "// Logs is the top-level struct that is propagated through the logs pipeline.\n// Use NewLogs to create new instance, zero-initialized instance is not valid for use.", - originFullName: "otlpcollectorlogs.ExportLogsServiceRequest", + structName: "Logs", + description: "// Logs is the top-level struct that is propagated through the logs pipeline.\n// Use NewLogs to create new instance, zero-initialized instance is not valid for use.", + protoName: "ExportLogsServiceRequest", + upstreamProto: "gootlpcollectorlogs.ExportLogsServiceRequest", fields: []Field{ &SliceField{ fieldName: "ResourceLogs", @@ -71,6 +70,22 @@ var logs = &messageStruct{ hasWrapper: true, } +var logsData = &messageStruct{ + structName: "LogsData", + description: "// LogsData represents the logs data that can be stored in a persistent storage,\n// OR can be embedded by other protocols that transfer OTLP logs data but do not\n// implement the OTLP protocol.", + protoName: "LogsData", + upstreamProto: "gootlplogs.LogsData", + fields: []Field{ + &SliceField{ + fieldName: "ResourceLogs", + protoID: 1, + protoType: proto.TypeMessage, + returnSlice: resourceLogsSlice, + }, + }, + hasOnlyInternal: true, +} + var resourceLogsSlice = &messageSlice{ structName: "ResourceLogsSlice", elementNullable: true, @@ -78,9 +93,10 @@ var resourceLogsSlice = &messageSlice{ } var resourceLogs = &messageStruct{ - structName: "ResourceLogs", - description: "// ResourceLogs is a collection of logs from a Resource.", - originFullName: "otlplogs.ResourceLogs", + structName: "ResourceLogs", + description: "// ResourceLogs is a collection of logs from a Resource.", + protoName: "ResourceLogs", + upstreamProto: "gootlplogs.ResourceLogs", fields: []Field{ &MessageField{ fieldName: "Resource", @@ -98,6 +114,15 @@ var resourceLogs = &messageStruct{ protoID: 3, protoType: proto.TypeString, }, + &SliceField{ + fieldName: "DeprecatedScopeLogs", + protoType: proto.TypeMessage, + protoID: 1000, + returnSlice: scopeLogsSlice, + // Hide accessors for this field because it is a HACK: + // Workaround for istio 1.15 / envoy 1.23.1 mistakenly emitting deprecated field. + hideAccessors: true, + }, }, } @@ -108,9 +133,10 @@ var scopeLogsSlice = &messageSlice{ } var scopeLogs = &messageStruct{ - structName: "ScopeLogs", - description: "// ScopeLogs is a collection of logs from a LibraryInstrumentation.", - originFullName: "otlplogs.ScopeLogs", + structName: "ScopeLogs", + description: "// ScopeLogs is a collection of logs from a LibraryInstrumentation.", + protoName: "ScopeLogs", + upstreamProto: "gootlplogs.ScopeLogs", fields: []Field{ &MessageField{ fieldName: "Scope", @@ -138,9 +164,10 @@ var logSlice = &messageSlice{ } var logRecord = &messageStruct{ - structName: "LogRecord", - description: "// LogRecord are experimental implementation of OpenTelemetry Log Data Model.\n", - originFullName: "otlplogs.LogRecord", + structName: "LogRecord", + description: "// LogRecord are experimental implementation of OpenTelemetry Log Data Model.\n", + protoName: "LogRecord", + upstreamProto: "gootlplogs.LogRecord", fields: []Field{ &TypedField{ fieldName: "Timestamp", @@ -160,9 +187,9 @@ var logRecord = &messageStruct{ returnType: &TypedType{ structName: "SeverityNumber", protoType: proto.TypeEnum, - messageName: "otlplogs.SeverityNumber", - defaultVal: `otlplogs.SeverityNumber(0)`, - testVal: `otlplogs.SeverityNumber(5)`, + messageName: "SeverityNumber", + defaultVal: `SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED`, + testVal: `SeverityNumber_SEVERITY_NUMBER_DEBUG`, }, }, &PrimitiveField{ @@ -173,7 +200,7 @@ var logRecord = &messageStruct{ &MessageField{ fieldName: "Body", protoID: 5, - returnMessage: anyValue, + returnMessage: anyValueStruct, }, &SliceField{ fieldName: "Attributes", @@ -215,3 +242,35 @@ var logRecord = &messageStruct{ }, }, } + +var severityNumberEnum = &proto.Enum{ + Name: "SeverityNumber", + Description: "// SeverityNumber represent possible values for LogRecord.SeverityNumber", + Fields: []*proto.EnumField{ + {Name: "SEVERITY_NUMBER_UNSPECIFIED", Value: 0}, + {Name: "SEVERITY_NUMBER_TRACE ", Value: 1}, + {Name: "SEVERITY_NUMBER_TRACE2", Value: 2}, + {Name: "SEVERITY_NUMBER_TRACE3", Value: 3}, + {Name: "SEVERITY_NUMBER_TRACE4", Value: 4}, + {Name: "SEVERITY_NUMBER_DEBUG", Value: 5}, + {Name: "SEVERITY_NUMBER_DEBUG2", Value: 6}, + {Name: "SEVERITY_NUMBER_DEBUG3", Value: 7}, + {Name: "SEVERITY_NUMBER_DEBUG4", Value: 8}, + {Name: "SEVERITY_NUMBER_INFO", Value: 9}, + {Name: "SEVERITY_NUMBER_INFO2", Value: 10}, + {Name: "SEVERITY_NUMBER_INFO3", Value: 11}, + {Name: "SEVERITY_NUMBER_INFO4", Value: 12}, + {Name: "SEVERITY_NUMBER_WARN", Value: 13}, + {Name: "SEVERITY_NUMBER_WARN2", Value: 14}, + {Name: "SEVERITY_NUMBER_WARN3", Value: 15}, + {Name: "SEVERITY_NUMBER_WARN4", Value: 16}, + {Name: "SEVERITY_NUMBER_ERROR", Value: 17}, + {Name: "SEVERITY_NUMBER_ERROR2", Value: 18}, + {Name: "SEVERITY_NUMBER_ERROR3", Value: 19}, + {Name: "SEVERITY_NUMBER_ERROR4", Value: 20}, + {Name: "SEVERITY_NUMBER_FATAL", Value: 21}, + {Name: "SEVERITY_NUMBER_FATAL2", Value: 22}, + {Name: "SEVERITY_NUMBER_FATAL3", Value: 23}, + {Name: "SEVERITY_NUMBER_FATAL4", Value: 24}, + }, +} diff --git a/internal/cmd/pdatagen/internal/pdata/plogotlp_package.go b/internal/cmd/pdatagen/internal/pdata/plogotlp_package.go index ab526c7405a..d75f2bb57aa 100644 --- a/internal/cmd/pdatagen/internal/pdata/plogotlp_package.go +++ b/internal/cmd/pdatagen/internal/pdata/plogotlp_package.go @@ -20,7 +20,7 @@ var plogotlp = &Package{ `"sort"`, `"sync"`, ``, - `otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`, + `"go.opentelemetry.io/collector/pdata/internal"`, }, testImports: []string{ `"strconv"`, @@ -32,7 +32,6 @@ var plogotlp = &Package{ `gootlpcollectorlogs "go.opentelemetry.io/proto/slim/otlp/collector/logs/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`, }, }, structs: []baseStruct{ @@ -42,9 +41,10 @@ var plogotlp = &Package{ } var exportLogsResponse = &messageStruct{ - structName: "ExportResponse", - description: "// ExportResponse represents the response for gRPC/HTTP client/server.", - originFullName: "otlpcollectorlogs.ExportLogsServiceResponse", + structName: "ExportResponse", + description: "// ExportResponse represents the response for gRPC/HTTP client/server.", + protoName: "ExportLogsServiceResponse", + upstreamProto: "gootlpcollectorlogs.ExportLogsServiceResponse", fields: []Field{ &MessageField{ fieldName: "PartialSuccess", @@ -55,9 +55,10 @@ var exportLogsResponse = &messageStruct{ } var exportLogsPartialSuccess = &messageStruct{ - structName: "ExportPartialSuccess", - description: "// ExportPartialSuccess represents the details of a partially successful export request.", - originFullName: "otlpcollectorlogs.ExportLogsPartialSuccess", + structName: "ExportPartialSuccess", + description: "// ExportPartialSuccess represents the details of a partially successful export request.", + protoName: "ExportLogsPartialSuccess", + upstreamProto: "gootlpcollectorlogs.ExportLogsPartialSuccess", fields: []Field{ &PrimitiveField{ fieldName: "RejectedLogRecords", diff --git a/internal/cmd/pdatagen/internal/pdata/pmetric_package.go b/internal/cmd/pdatagen/internal/pdata/pmetric_package.go index 83f452d7cc2..84c317fe7c5 100644 --- a/internal/cmd/pdatagen/internal/pdata/pmetric_package.go +++ b/internal/cmd/pdatagen/internal/pdata/pmetric_package.go @@ -19,11 +19,8 @@ var pmetric = &Package{ `"sync"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/internal/proto"`, - `otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`, - `otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, testImports: []string{ @@ -38,15 +35,13 @@ var pmetric = &Package{ `gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, - `otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`, - `otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, }, structs: []baseStruct{ metrics, + metricsData, resourceMetricsSlice, resourceMetrics, scopeMetricsSlice, @@ -72,12 +67,16 @@ var pmetric = &Package{ exemplarSlice, exemplar, }, + enums: []*proto.Enum{ + aggregationTemporalityEnum, + }, } var metrics = &messageStruct{ - structName: "Metrics", - description: "// Metrics is the top-level struct that is propagated through the metrics pipeline.\n// Use NewMetrics to create new instance, zero-initialized instance is not valid for use.", - originFullName: "otlpcollectormetrics.ExportMetricsServiceRequest", + structName: "Metrics", + description: "// Metrics is the top-level struct that is propagated through the metrics pipeline.\n// Use NewMetrics to create new instance, zero-initialized instance is not valid for use.", + protoName: "ExportMetricsServiceRequest", + upstreamProto: "gootlpcollectormetrics.ExportMetricsServiceRequest", fields: []Field{ &SliceField{ fieldName: "ResourceMetrics", @@ -89,6 +88,22 @@ var metrics = &messageStruct{ hasWrapper: true, } +var metricsData = &messageStruct{ + structName: "MetricsData", + description: "// MetricsData represents the metrics data that can be stored in a persistent storage,\n// OR can be embedded by other protocols that transfer OTLP metrics data but do not\n// implement the OTLP protocol..", + protoName: "MetricsData", + upstreamProto: "gootlpmetrics.MetricsData", + fields: []Field{ + &SliceField{ + fieldName: "ResourceMetrics", + protoID: 1, + protoType: proto.TypeMessage, + returnSlice: resourceMetricsSlice, + }, + }, + hasOnlyInternal: true, +} + var resourceMetricsSlice = &messageSlice{ structName: "ResourceMetricsSlice", elementNullable: true, @@ -96,9 +111,10 @@ var resourceMetricsSlice = &messageSlice{ } var resourceMetrics = &messageStruct{ - structName: "ResourceMetrics", - description: "// ResourceMetrics is a collection of metrics from a Resource.", - originFullName: "otlpmetrics.ResourceMetrics", + structName: "ResourceMetrics", + description: "// ResourceMetrics is a collection of metrics from a Resource.", + protoName: "ResourceMetrics", + upstreamProto: "gootlpmetrics.ResourceMetrics", fields: []Field{ &MessageField{ fieldName: "Resource", @@ -116,6 +132,15 @@ var resourceMetrics = &messageStruct{ protoID: 3, protoType: proto.TypeString, }, + &SliceField{ + fieldName: "DeprecatedScopeMetrics", + protoType: proto.TypeMessage, + protoID: 1000, + returnSlice: scopeMetricsSlice, + // Hide accessors for this field because it is a HACK: + // Workaround for istio 1.15 / envoy 1.23.1 mistakenly emitting deprecated field. + hideAccessors: true, + }, }, } @@ -126,9 +151,10 @@ var scopeMetricsSlice = &messageSlice{ } var scopeMetrics = &messageStruct{ - structName: "ScopeMetrics", - description: "// ScopeMetrics is a collection of metrics from a LibraryInstrumentation.", - originFullName: "otlpmetrics.ScopeMetrics", + structName: "ScopeMetrics", + description: "// ScopeMetrics is a collection of metrics from a LibraryInstrumentation.", + protoName: "ScopeMetrics", + upstreamProto: "gootlpmetrics.ScopeMetrics", fields: []Field{ &MessageField{ fieldName: "Scope", @@ -159,7 +185,8 @@ var metric = &messageStruct{ structName: "Metric", description: "// Metric represents one metric as a collection of datapoints.\n" + "// See Metric definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/metrics/v1/metrics.proto", - originFullName: "otlpmetrics.Metric", + protoName: "Metric", + upstreamProto: "gootlpmetrics.Metric", fields: []Field{ &PrimitiveField{ fieldName: "Name", @@ -219,9 +246,10 @@ var metric = &messageStruct{ } var gauge = &messageStruct{ - structName: "Gauge", - description: "// Gauge represents the type of a numeric metric that always exports the \"current value\" for every data point.", - originFullName: "otlpmetrics.Gauge", + structName: "Gauge", + description: "// Gauge represents the type of a numeric metric that always exports the \"current value\" for every data point.", + protoName: "Gauge", + upstreamProto: "gootlpmetrics.Gauge", fields: []Field{ &SliceField{ fieldName: "DataPoints", @@ -233,9 +261,10 @@ var gauge = &messageStruct{ } var sum = &messageStruct{ - structName: "Sum", - description: "// Sum represents the type of a numeric metric that is calculated as a sum of all reported measurements over a time interval.", - originFullName: "otlpmetrics.Sum", + structName: "Sum", + description: "// Sum represents the type of a numeric metric that is calculated as a sum of all reported measurements over a time interval.", + protoName: "Sum", + upstreamProto: "gootlpmetrics.Sum", fields: []Field{ &SliceField{ fieldName: "DataPoints", @@ -257,9 +286,10 @@ var sum = &messageStruct{ } var histogram = &messageStruct{ - structName: "Histogram", - description: "// Histogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported measurements over a time interval.", - originFullName: "otlpmetrics.Histogram", + structName: "Histogram", + description: "// Histogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported measurements over a time interval.", + protoName: "Histogram", + upstreamProto: "gootlpmetrics.Histogram", fields: []Field{ &SliceField{ fieldName: "DataPoints", @@ -279,7 +309,8 @@ var exponentialHistogram = &messageStruct{ structName: "ExponentialHistogram", description: `// ExponentialHistogram represents the type of a metric that is calculated by aggregating // as a ExponentialHistogram of all reported double measurements over a time interval.`, - originFullName: "otlpmetrics.ExponentialHistogram", + protoName: "ExponentialHistogram", + upstreamProto: "gootlpmetrics.ExponentialHistogram", fields: []Field{ &SliceField{ fieldName: "DataPoints", @@ -296,9 +327,10 @@ var exponentialHistogram = &messageStruct{ } var summary = &messageStruct{ - structName: "Summary", - description: "// Summary represents the type of a metric that is calculated by aggregating as a Summary of all reported double measurements over a time interval.", - originFullName: "otlpmetrics.Summary", + structName: "Summary", + description: "// Summary represents the type of a metric that is calculated by aggregating as a Summary of all reported double measurements over a time interval.", + protoName: "Summary", + upstreamProto: "gootlpmetrics.Summary", fields: []Field{ &SliceField{ fieldName: "DataPoints", @@ -316,9 +348,10 @@ var numberDataPointSlice = &messageSlice{ } var numberDataPoint = &messageStruct{ - structName: "NumberDataPoint", - description: "// NumberDataPoint is a single data point in a timeseries that describes the time-varying value of a number metric.", - originFullName: "otlpmetrics.NumberDataPoint", + structName: "NumberDataPoint", + description: "// NumberDataPoint is a single data point in a timeseries that describes the time-varying value of a number metric.", + protoName: "NumberDataPoint", + upstreamProto: "gootlpmetrics.NumberDataPoint", fields: []Field{ &SliceField{ fieldName: "Attributes", @@ -383,9 +416,10 @@ var histogramDataPointSlice = &messageSlice{ } var histogramDataPoint = &messageStruct{ - structName: "HistogramDataPoint", - description: "// HistogramDataPoint is a single data point in a timeseries that describes the time-varying values of a Histogram of values.", - originFullName: "otlpmetrics.HistogramDataPoint", + structName: "HistogramDataPoint", + description: "// HistogramDataPoint is a single data point in a timeseries that describes the time-varying values of a Histogram of values.", + protoName: "HistogramDataPoint", + upstreamProto: "gootlpmetrics.HistogramDataPoint", fields: []Field{ &SliceField{ fieldName: "Attributes", @@ -468,7 +502,8 @@ var exponentialHistogramDataPoint = &messageStruct{ // 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.`, - originFullName: "otlpmetrics.ExponentialHistogramDataPoint", + protoName: "ExponentialHistogramDataPoint", + upstreamProto: "gootlpmetrics.ExponentialHistogramDataPoint", fields: []Field{ &SliceField{ fieldName: "Attributes", @@ -553,9 +588,10 @@ var exponentialHistogramDataPoint = &messageStruct{ } var bucketsValues = &messageStruct{ - structName: "ExponentialHistogramDataPointBuckets", - description: "// ExponentialHistogramDataPointBuckets are a set of bucket counts, encoded in a contiguous array of counts.", - originFullName: "otlpmetrics.ExponentialHistogramDataPoint_Buckets", + structName: "ExponentialHistogramDataPointBuckets", + description: "// ExponentialHistogramDataPointBuckets are a set of bucket counts, encoded in a contiguous array of counts.", + protoName: "ExponentialHistogramDataPointBuckets", + upstreamProto: "gootlpmetrics.ExponentialHistogramDataPoint_Buckets", fields: []Field{ &PrimitiveField{ fieldName: "Offset", @@ -578,9 +614,10 @@ var summaryDataPointSlice = &messageSlice{ } var summaryDataPoint = &messageStruct{ - structName: "SummaryDataPoint", - description: "// SummaryDataPoint is a single data point in a timeseries that describes the time-varying values of a Summary of double values.", - originFullName: "otlpmetrics.SummaryDataPoint", + structName: "SummaryDataPoint", + description: "// SummaryDataPoint is a single data point in a timeseries that describes the time-varying values of a Summary of double values.", + protoName: "SummaryDataPoint", + upstreamProto: "gootlpmetrics.SummaryDataPoint", fields: []Field{ &SliceField{ fieldName: "Attributes", @@ -636,9 +673,10 @@ var quantileValuesSlice = &messageSlice{ } var quantileValues = &messageStruct{ - structName: "SummaryDataPointValueAtQuantile", - description: "// SummaryDataPointValueAtQuantile is a quantile value within a Summary data point.", - originFullName: "otlpmetrics.SummaryDataPoint_ValueAtQuantile", + structName: "SummaryDataPointValueAtQuantile", + description: "// SummaryDataPointValueAtQuantile is a quantile value within a Summary data point.", + protoName: "SummaryDataPointValueAtQuantile", + upstreamProto: "gootlpmetrics.SummaryDataPoint_ValueAtQuantile", fields: []Field{ &PrimitiveField{ fieldName: "Quantile", @@ -664,8 +702,8 @@ var exemplar = &messageStruct{ description: "// Exemplar is a sample input double measurement.\n//\n" + "// Exemplars also hold information about the environment when the measurement was recorded,\n" + "// for example the span and trace ID of the active span when the exemplar was recorded.", - - originFullName: "otlpmetrics.Exemplar", + protoName: "Exemplar", + upstreamProto: "gootlpmetrics.Exemplar", fields: []Field{ &SliceField{ fieldName: "FilteredAttributes", @@ -698,25 +736,35 @@ var exemplar = &messageStruct{ }, }, }, - &TypedField{ - fieldName: "SpanID", - originFieldName: "SpanId", - protoID: 4, - returnType: spanIDType, - }, &TypedField{ fieldName: "TraceID", originFieldName: "TraceId", protoID: 5, returnType: traceIDType, }, + &TypedField{ + fieldName: "SpanID", + originFieldName: "SpanId", + protoID: 4, + returnType: spanIDType, + }, }, } var aggregationTemporalityType = &TypedType{ structName: "AggregationTemporality", protoType: proto.TypeEnum, - messageName: "otlpmetrics.AggregationTemporality", - defaultVal: "otlpmetrics.AggregationTemporality(0)", - testVal: "otlpmetrics.AggregationTemporality(1)", + messageName: "AggregationTemporality", + defaultVal: "AggregationTemporality(0)", + testVal: "AggregationTemporality(1)", +} + +var aggregationTemporalityEnum = &proto.Enum{ + Name: "AggregationTemporality", + Description: "// AggregationTemporality defines how a metric aggregator reports aggregated values.\n// It describes how those values relate to the time interval over which they are aggregated.", + Fields: []*proto.EnumField{ + {Name: "AGGREGATION_TEMPORALITY_UNSPECIFIED", Value: 0}, + {Name: "AGGREGATION_TEMPORALITY_DELTA", Value: 1}, + {Name: "AGGREGATION_TEMPORALITY_CUMULATIVE", Value: 2}, + }, } diff --git a/internal/cmd/pdatagen/internal/pdata/pmetricotlp_package.go b/internal/cmd/pdatagen/internal/pdata/pmetricotlp_package.go index f9748ab4b13..b6b4a7a280d 100644 --- a/internal/cmd/pdatagen/internal/pdata/pmetricotlp_package.go +++ b/internal/cmd/pdatagen/internal/pdata/pmetricotlp_package.go @@ -21,7 +21,7 @@ var pmetricotlp = &Package{ `"sort"`, `"sync"`, ``, - `otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`, + `"go.opentelemetry.io/collector/pdata/internal"`, }, testImports: []string{ `"strconv"`, @@ -33,7 +33,6 @@ var pmetricotlp = &Package{ `gootlpcollectormetrics "go.opentelemetry.io/proto/slim/otlp/collector/metrics/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`, }, }, structs: []baseStruct{ @@ -43,9 +42,10 @@ var pmetricotlp = &Package{ } var exportMetricsResponse = &messageStruct{ - structName: "ExportResponse", - description: "// ExportResponse represents the response for gRPC/HTTP client/server.", - originFullName: "otlpcollectormetrics.ExportMetricsServiceResponse", + structName: "ExportResponse", + description: "// ExportResponse represents the response for gRPC/HTTP client/server.", + protoName: "ExportMetricsServiceResponse", + upstreamProto: "gootlpcollectormetrics.ExportMetricsServiceResponse", fields: []Field{ &MessageField{ fieldName: "PartialSuccess", @@ -56,9 +56,10 @@ var exportMetricsResponse = &messageStruct{ } var exportMetricsPartialSuccess = &messageStruct{ - structName: "ExportPartialSuccess", - description: "// ExportPartialSuccess represents the details of a partially successful export request.", - originFullName: "otlpcollectormetrics.ExportMetricsPartialSuccess", + structName: "ExportPartialSuccess", + description: "// ExportPartialSuccess represents the details of a partially successful export request.", + protoName: "ExportMetricsPartialSuccess", + upstreamProto: "gootlpcollectormetrics.ExportMetricsPartialSuccess", fields: []Field{ &PrimitiveField{ fieldName: "RejectedDataPoints", diff --git a/internal/cmd/pdatagen/internal/pdata/pprofile_package.go b/internal/cmd/pdatagen/internal/pdata/pprofile_package.go index 4f1078ce6d1..3c426cc5b4b 100644 --- a/internal/cmd/pdatagen/internal/pdata/pprofile_package.go +++ b/internal/cmd/pdatagen/internal/pdata/pprofile_package.go @@ -19,12 +19,8 @@ var pprofile = &Package{ `"sync"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/internal/proto"`, - `otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development"`, - `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, - `otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, testImports: []string{ @@ -41,13 +37,12 @@ var pprofile = &Package{ ``, `"go.opentelemetry.io/collector/pdata/internal"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, - `otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development"`, - `otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, }, structs: []baseStruct{ profiles, + profilesData, resourceProfilesSlice, resourceProfiles, profilesDictionary, @@ -77,9 +72,31 @@ var pprofile = &Package{ } var profiles = &messageStruct{ - structName: "Profiles", - description: "// Profiles is the top-level struct that is propagated through the profiles pipeline.\n// Use NewProfiles to create new instance, zero-initialized instance is not valid for use.", - originFullName: "otlpcollectorprofiles.ExportProfilesServiceRequest", + structName: "Profiles", + description: "// Profiles is the top-level struct that is propagated through the profiles pipeline.\n// Use NewProfiles to create new instance, zero-initialized instance is not valid for use.", + protoName: "ExportProfilesServiceRequest", + upstreamProto: "gootlpcollectorprofiles.ExportProfilesServiceRequest", + fields: []Field{ + &SliceField{ + fieldName: "ResourceProfiles", + protoID: 1, + protoType: proto.TypeMessage, + returnSlice: resourceProfilesSlice, + }, + &MessageField{ + fieldName: "Dictionary", + protoID: 2, + returnMessage: profilesDictionary, + }, + }, + hasWrapper: true, +} + +var profilesData = &messageStruct{ + structName: "ProfilesData", + description: "// ProfilesData represents the profiles data that can be stored in persistent storage,\n// OR can be embedded by other protocols that transfer OTLP profiles data but do not\n// implement the OTLP protocol.", + protoName: "ProfilesData", + upstreamProto: "gootlpprofiles.ProfilesData", fields: []Field{ &SliceField{ fieldName: "ResourceProfiles", @@ -103,9 +120,10 @@ var resourceProfilesSlice = &messageSlice{ } var resourceProfiles = &messageStruct{ - structName: "ResourceProfiles", - description: "// ResourceProfiles is a collection of profiles from a Resource.", - originFullName: "otlpprofiles.ResourceProfiles", + structName: "ResourceProfiles", + description: "// ResourceProfiles is a collection of profiles from a Resource.", + protoName: "ResourceProfiles", + upstreamProto: "gootlpprofiles.ResourceProfiles", fields: []Field{ &MessageField{ fieldName: "Resource", @@ -127,9 +145,10 @@ var resourceProfiles = &messageStruct{ } var profilesDictionary = &messageStruct{ - structName: "ProfilesDictionary", - description: "// ProfilesDictionary is the reference table containing all data shared by profiles across the message being sent.", - originFullName: "otlpprofiles.ProfilesDictionary", + structName: "ProfilesDictionary", + description: "// ProfilesDictionary is the reference table containing all data shared by profiles across the message being sent.", + protoName: "ProfilesDictionary", + upstreamProto: "gootlpprofiles.ProfilesDictionary", fields: []Field{ &SliceField{ fieldName: "MappingTable", @@ -183,9 +202,10 @@ var scopeProfilesSlice = &messageSlice{ } var scopeProfiles = &messageStruct{ - structName: "ScopeProfiles", - description: "// ScopeProfiles is a collection of profiles from a LibraryInstrumentation.", - originFullName: "otlpprofiles.ScopeProfiles", + structName: "ScopeProfiles", + description: "// ScopeProfiles is a collection of profiles from a LibraryInstrumentation.", + protoName: "ScopeProfiles", + upstreamProto: "gootlpprofiles.ScopeProfiles", fields: []Field{ &MessageField{ fieldName: "Scope", @@ -213,9 +233,10 @@ var profilesSlice = &messageSlice{ } var profile = &messageStruct{ - structName: "Profile", - description: "// Profile are an implementation of the pprofextended data model.\n", - originFullName: "otlpprofiles.Profile", + structName: "Profile", + description: "// Profile are an implementation of the pprofextended data model.\n", + protoName: "Profile", + upstreamProto: "gootlpprofiles.Profile", fields: []Field{ &MessageField{ fieldName: "SampleType", @@ -269,9 +290,9 @@ var profile = &messageStruct{ returnType: &TypedType{ structName: "ProfileID", protoType: proto.TypeMessage, - messageName: "data.ProfileID", - defaultVal: "data.ProfileID([16]byte{})", - testVal: "data.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})", + messageName: "ProfileID", + defaultVal: "ProfileID([16]byte{})", + testVal: "ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})", }, }, &PrimitiveField{ @@ -310,7 +331,8 @@ var keyValueAndUnit = &messageStruct{ description: `// KeyValueAndUnit represents a custom 'dictionary native' // style of encoding attributes which is more convenient // for profiles than opentelemetry.proto.common.v1.KeyValue.`, - originFullName: "otlpprofiles.KeyValueAndUnit", + protoName: "KeyValueAndUnit", + upstreamProto: "gootlpprofiles.KeyValueAndUnit", fields: []Field{ &PrimitiveField{ fieldName: "KeyStrindex", @@ -320,7 +342,7 @@ var keyValueAndUnit = &messageStruct{ &MessageField{ fieldName: "Value", protoID: 2, - returnMessage: anyValue, + returnMessage: anyValueStruct, }, &PrimitiveField{ fieldName: "UnitStrindex", @@ -337,9 +359,10 @@ var linkSlice = &messageSlice{ } var link = &messageStruct{ - structName: "Link", - description: "// Link represents a pointer from a profile Sample to a trace Span.", - originFullName: "otlpprofiles.Link", + structName: "Link", + description: "// Link represents a pointer from a profile Sample to a trace Span.", + protoName: "Link", + upstreamProto: "gootlpprofiles.Link", fields: []Field{ &TypedField{ fieldName: "TraceID", @@ -363,9 +386,10 @@ var valueTypeSlice = &messageSlice{ } var valueType = &messageStruct{ - structName: "ValueType", - description: "// ValueType describes the type and units of a value, with an optional aggregation temporality.", - originFullName: "otlpprofiles.ValueType", + structName: "ValueType", + description: "// ValueType describes the type and units of a value, with an optional aggregation temporality.", + protoName: "ValueType", + upstreamProto: "gootlpprofiles.ValueType", fields: []Field{ &PrimitiveField{ fieldName: "TypeStrindex", @@ -383,9 +407,9 @@ var valueType = &messageStruct{ returnType: &TypedType{ structName: "AggregationTemporality", protoType: proto.TypeEnum, - messageName: "otlpprofiles.AggregationTemporality", - defaultVal: "otlpprofiles.AggregationTemporality(0)", - testVal: "otlpprofiles.AggregationTemporality(1)", + messageName: "AggregationTemporality", + defaultVal: "AggregationTemporality(0)", + testVal: "AggregationTemporality(1)", }, }, }, @@ -398,9 +422,10 @@ var sampleSlice = &messageSlice{ } var sample = &messageStruct{ - structName: "Sample", - description: "// Sample represents each record value encountered within a profiled program.", - originFullName: "otlpprofiles.Sample", + structName: "Sample", + description: "// Sample represents each record value encountered within a profiled program.", + protoName: "Sample", + upstreamProto: "gootlpprofiles.Sample", fields: []Field{ &PrimitiveField{ fieldName: "StackIndex", @@ -440,9 +465,10 @@ var mappingSlice = &messageSlice{ } var mapping = &messageStruct{ - structName: "Mapping", - description: "// Mapping describes the mapping of a binary in memory, including its address range, file offset, and metadata like build ID", - originFullName: "otlpprofiles.Mapping", + structName: "Mapping", + description: "// Mapping describes the mapping of a binary in memory, including its address range, file offset, and metadata like build ID", + protoName: "Mapping", + upstreamProto: "gootlpprofiles.Mapping", fields: []Field{ &PrimitiveField{ fieldName: "MemoryStart", @@ -480,9 +506,10 @@ var locationSlice = &messageSlice{ } var location = &messageStruct{ - structName: "Location", - description: "// Location describes function and line table debug information.", - originFullName: "otlpprofiles.Location", + structName: "Location", + description: "// Location describes function and line table debug information.", + protoName: "Location", + upstreamProto: "gootlpprofiles.Location", fields: []Field{ &PrimitiveField{ fieldName: "MappingIndex", @@ -516,9 +543,10 @@ var lineSlice = &messageSlice{ } var line = &messageStruct{ - structName: "Line", - description: "// Line details a specific line in a source code, linked to a function.", - originFullName: "otlpprofiles.Line", + structName: "Line", + description: "// Line details a specific line in a source code, linked to a function.", + protoName: "Line", + upstreamProto: "gootlpprofiles.Line", fields: []Field{ &PrimitiveField{ fieldName: "FunctionIndex", @@ -545,9 +573,10 @@ var functionSlice = &messageSlice{ } var function = &messageStruct{ - structName: "Function", - description: "// Function describes a function, including its human-readable name, system name, source file, and starting line number in the source.", - originFullName: "otlpprofiles.Function", + structName: "Function", + description: "// Function describes a function, including its human-readable name, system name, source file, and starting line number in the source.", + protoName: "Function", + upstreamProto: "gootlpprofiles.Function", fields: []Field{ &PrimitiveField{ fieldName: "NameStrindex", @@ -579,9 +608,10 @@ var stackSlice = &messageSlice{ } var stack = &messageStruct{ - structName: "Stack", - description: "// Stack represents a stack trace as a list of locations.\n", - originFullName: "otlpprofiles.Stack", + structName: "Stack", + description: "// Stack represents a stack trace as a list of locations.\n", + protoName: "Stack", + upstreamProto: "gootlpprofiles.Stack", fields: []Field{ &SliceField{ fieldName: "LocationIndices", diff --git a/internal/cmd/pdatagen/internal/pdata/pprofileotlp_package.go b/internal/cmd/pdatagen/internal/pdata/pprofileotlp_package.go index fe1a7b149c7..f2cdfbba436 100644 --- a/internal/cmd/pdatagen/internal/pdata/pprofileotlp_package.go +++ b/internal/cmd/pdatagen/internal/pdata/pprofileotlp_package.go @@ -20,7 +20,7 @@ var pprofileotlp = &Package{ `"sort"`, `"sync"`, ``, - `otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development"`, + `"go.opentelemetry.io/collector/pdata/internal"`, }, testImports: []string{ `"strconv"`, @@ -32,7 +32,6 @@ var pprofileotlp = &Package{ `gootlpcollectorprofiles "go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development"`, }, }, structs: []baseStruct{ @@ -42,9 +41,10 @@ var pprofileotlp = &Package{ } var exportProfilesResponse = &messageStruct{ - structName: "ExportResponse", - description: "// ExportResponse represents the response for gRPC/HTTP client/server.", - originFullName: "otlpcollectorprofiles.ExportProfilesServiceResponse", + structName: "ExportResponse", + description: "// ExportResponse represents the response for gRPC/HTTP client/server.", + protoName: "ExportProfilesServiceResponse", + upstreamProto: "gootlpcollectorprofiles.ExportProfilesServiceResponse", fields: []Field{ &MessageField{ fieldName: "PartialSuccess", @@ -55,9 +55,10 @@ var exportProfilesResponse = &messageStruct{ } var exportProfilesPartialSuccess = &messageStruct{ - structName: "ExportPartialSuccess", - description: "// ExportPartialSuccess represents the details of a partially successful export request.", - originFullName: "otlpcollectorprofiles.ExportProfilesPartialSuccess", + structName: "ExportPartialSuccess", + description: "// ExportPartialSuccess represents the details of a partially successful export request.", + protoName: "ExportProfilesPartialSuccess", + upstreamProto: "gootlpcollectorprofiles.ExportProfilesPartialSuccess", fields: []Field{ &PrimitiveField{ fieldName: "RejectedProfiles", diff --git a/internal/cmd/pdatagen/internal/pdata/primitive_field.go b/internal/cmd/pdatagen/internal/pdata/primitive_field.go index a0ae3ca3d67..43a50198730 100644 --- a/internal/cmd/pdatagen/internal/pdata/primitive_field.go +++ b/internal/cmd/pdatagen/internal/pdata/primitive_field.go @@ -44,13 +44,11 @@ const primitiveAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldName {{- end }} sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { new{{ .structName }}(&{{ .originStructName }}{}, sharedState).Set{{ .fieldName }}({{ .testValue }}) }) + assert.Panics(t, func() { new{{ .structName }}(internal.New{{ .originStructName }}(), sharedState).Set{{ .fieldName }}({{ .testValue }}) }) }` const primitiveSetTestTemplate = `orig.{{ .originFieldName }} = {{ .testValue }}` -const primitiveCopyOrigTemplate = `dest.{{ .originFieldName }} = src.{{ .originFieldName }}` - type PrimitiveField struct { fieldName string protoType proto.Type @@ -72,48 +70,7 @@ func (pf *PrimitiveField) GenerateTestValue(ms *messageStruct) string { return template.Execute(t, pf.templateFields(ms)) } -func (pf *PrimitiveField) GenerateTestFailingUnmarshalProtoValues(*messageStruct) string { - return pf.toProtoField().GenTestFailingUnmarshalProtoValues() -} - -func (pf *PrimitiveField) GenerateTestEncodingValues(*messageStruct) string { - return pf.toProtoField().GenTestEncodingValues() -} - -func (pf *PrimitiveField) GeneratePoolOrig(*messageStruct) string { - return "" -} - -func (pf *PrimitiveField) GenerateDeleteOrig(*messageStruct) string { - return pf.toProtoField().GenDeleteOrig() -} - -func (pf *PrimitiveField) GenerateCopyOrig(ms *messageStruct) string { - t := template.Parse("primitiveCopyOrigTemplate", []byte(primitiveCopyOrigTemplate)) - return template.Execute(t, pf.templateFields(ms)) -} - -func (pf *PrimitiveField) GenerateMarshalJSON(*messageStruct) string { - return pf.toProtoField().GenMarshalJSON() -} - -func (pf *PrimitiveField) GenerateUnmarshalJSON(*messageStruct) string { - return pf.toProtoField().GenUnmarshalJSON() -} - -func (pf *PrimitiveField) GenerateSizeProto(*messageStruct) string { - return pf.toProtoField().GenSizeProto() -} - -func (pf *PrimitiveField) GenerateMarshalProto(*messageStruct) string { - return pf.toProtoField().GenMarshalProto() -} - -func (pf *PrimitiveField) GenerateUnmarshalProto(*messageStruct) string { - return pf.toProtoField().GenUnmarshalProto() -} - -func (pf *PrimitiveField) toProtoField() *proto.Field { +func (pf *PrimitiveField) toProtoField(*messageStruct) proto.FieldInterface { return &proto.Field{ Type: pf.protoType, ID: pf.protoID, @@ -122,7 +79,7 @@ func (pf *PrimitiveField) toProtoField() *proto.Field { } func (pf *PrimitiveField) templateFields(ms *messageStruct) map[string]any { - prf := pf.toProtoField() + prf := pf.toProtoField(ms) return map[string]any{ "structName": ms.getName(), "packageName": "", @@ -133,7 +90,7 @@ func (pf *PrimitiveField) templateFields(ms *messageStruct) map[string]any { "returnType": prf.GoType(), "origAccessor": origAccessor(ms.getHasWrapper()), "stateAccessor": stateAccessor(ms.getHasWrapper()), - "originStructName": ms.originFullName, + "originStructName": ms.protoName, "originFieldName": pf.fieldName, } } diff --git a/internal/cmd/pdatagen/internal/pdata/primitive_slice_structs.go b/internal/cmd/pdatagen/internal/pdata/primitive_slice_structs.go index 0450a120758..b9d054f4f80 100644 --- a/internal/cmd/pdatagen/internal/pdata/primitive_slice_structs.go +++ b/internal/cmd/pdatagen/internal/pdata/primitive_slice_structs.go @@ -6,6 +6,7 @@ package pdata // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/int import ( "strings" + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" ) @@ -42,10 +43,6 @@ func (iss *primitiveSliceStruct) generateInternal(packageInfo *PackageInfo) []by return []byte(template.Execute(primitiveSliceInternalTemplate, iss.templateFields(packageInfo))) } -func (iss *primitiveSliceStruct) generateInternalTests(packageInfo *PackageInfo) []byte { - return []byte(template.Execute(primitiveSliceInternalTestTemplate, iss.templateFields(packageInfo))) -} - func (iss *primitiveSliceStruct) getOriginName() string { return iss.getName() } @@ -58,7 +55,7 @@ func (iss *primitiveSliceStruct) getHasWrapper() bool { return usedByOtherDataTypes(iss.packageName) } -func (iss *primitiveSliceStruct) getHasOnlyOrig() bool { +func (iss *primitiveSliceStruct) getHasOnlyInternal() bool { return false } @@ -70,6 +67,10 @@ func (iss *primitiveSliceStruct) getElementNullable() bool { return false } +func (iss *primitiveSliceStruct) getProtoMessage() *proto.Message { + return nil +} + func (iss *primitiveSliceStruct) templateFields(packageInfo *PackageInfo) map[string]any { return map[string]any{ "structName": iss.getName(), diff --git a/internal/cmd/pdatagen/internal/pdata/ptrace_package.go b/internal/cmd/pdatagen/internal/pdata/ptrace_package.go index 288873cc0b4..0be778281fc 100644 --- a/internal/cmd/pdatagen/internal/pdata/ptrace_package.go +++ b/internal/cmd/pdatagen/internal/pdata/ptrace_package.go @@ -19,11 +19,8 @@ var ptrace = &Package{ `"sync"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/internal/proto"`, - `otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`, - `otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, testImports: []string{ @@ -38,15 +35,13 @@ var ptrace = &Package{ `gootlptrace "go.opentelemetry.io/proto/slim/otlp/trace/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, - `otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`, - `otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, }, structs: []baseStruct{ traces, + tracesData, resourceSpansSlice, resourceSpans, scopeSpansSlice, @@ -59,12 +54,17 @@ var ptrace = &Package{ spanLink, spanStatus, }, + enums: []*proto.Enum{ + spanKindEnum, + statusCodeEnum, + }, } var traces = &messageStruct{ - structName: "Traces", - description: "// Traces is the top-level struct that is propagated through the traces pipeline.\n// Use NewTraces to create new instance, zero-initialized instance is not valid for use.", - originFullName: "otlpcollectortrace.ExportTraceServiceRequest", + structName: "Traces", + description: "// Traces is the top-level struct that is propagated through the traces pipeline.\n// Use NewTraces to create new instance, zero-initialized instance is not valid for use.", + protoName: "ExportTraceServiceRequest", + upstreamProto: "gootlpcollectortrace.ExportTraceServiceRequest", fields: []Field{ &SliceField{ fieldName: "ResourceSpans", @@ -76,6 +76,22 @@ var traces = &messageStruct{ hasWrapper: true, } +var tracesData = &messageStruct{ + structName: "TracesData", + description: "// TracesData represents the traces data that can be stored in a persistent storage,\n// OR can be embedded by other protocols that transfer OTLP traces data but do not\n// implement the OTLP protocol.", + protoName: "TracesData", + upstreamProto: "gootlptrace.TracesData", + fields: []Field{ + &SliceField{ + fieldName: "ResourceSpans", + protoID: 1, + protoType: proto.TypeMessage, + returnSlice: resourceSpansSlice, + }, + }, + hasOnlyInternal: true, +} + var resourceSpansSlice = &messageSlice{ structName: "ResourceSpansSlice", elementNullable: true, @@ -83,9 +99,10 @@ var resourceSpansSlice = &messageSlice{ } var resourceSpans = &messageStruct{ - structName: "ResourceSpans", - description: "// ResourceSpans is a collection of spans from a Resource.", - originFullName: "otlptrace.ResourceSpans", + structName: "ResourceSpans", + description: "// ResourceSpans is a collection of spans from a Resource.", + protoName: "ResourceSpans", + upstreamProto: "gootlptrace.ResourceSpans", fields: []Field{ &MessageField{ fieldName: "Resource", @@ -103,6 +120,15 @@ var resourceSpans = &messageStruct{ protoID: 3, protoType: proto.TypeString, }, + &SliceField{ + fieldName: "DeprecatedScopeSpans", + protoType: proto.TypeMessage, + protoID: 1000, + returnSlice: scopeSpansSlice, + // Hide accessors for this field because it is a HACK: + // Workaround for istio 1.15 / envoy 1.23.1 mistakenly emitting deprecated field. + hideAccessors: true, + }, }, } @@ -113,9 +139,10 @@ var scopeSpansSlice = &messageSlice{ } var scopeSpans = &messageStruct{ - structName: "ScopeSpans", - description: "// ScopeSpans is a collection of spans from a LibraryInstrumentation.", - originFullName: "otlptrace.ScopeSpans", + structName: "ScopeSpans", + description: "// ScopeSpans is a collection of spans from a LibraryInstrumentation.", + protoName: "ScopeSpans", + upstreamProto: "gootlptrace.ScopeSpans", fields: []Field{ &MessageField{ fieldName: "Scope", @@ -146,7 +173,8 @@ var span = &messageStruct{ structName: "Span", description: "// Span represents a single operation within a trace.\n" + "// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto", - originFullName: "otlptrace.Span", + protoName: "Span", + upstreamProto: "gootlptrace.Span", fields: []Field{ &TypedField{ fieldName: "TraceID", @@ -187,9 +215,9 @@ var span = &messageStruct{ returnType: &TypedType{ structName: "SpanKind", protoType: proto.TypeEnum, - messageName: "otlptrace.Span_SpanKind", - defaultVal: "otlptrace.Span_SpanKind(0)", - testVal: "otlptrace.Span_SpanKind(3)", + messageName: "SpanKind", + defaultVal: "SpanKind_SPAN_KIND_UNSPECIFIED", + testVal: "SpanKind_SPAN_KIND_CLIENT", }, }, &TypedField{ @@ -255,7 +283,8 @@ var spanEvent = &messageStruct{ structName: "SpanEvent", description: "// SpanEvent is a time-stamped annotation of the span, consisting of user-supplied\n" + "// text description and key-value pairs. See OTLP for event definition.", - originFullName: "otlptrace.Span_Event", + protoName: "SpanEvent", + upstreamProto: "gootlptrace.Span_Event", fields: []Field{ &TypedField{ fieldName: "Timestamp", @@ -293,7 +322,8 @@ var spanLink = &messageStruct{ description: "// SpanLink is a pointer from the current span to another span in the same trace or in a\n" + "// different trace.\n" + "// See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto", - originFullName: "otlptrace.Span_Link", + protoName: "SpanLink", + upstreamProto: "gootlptrace.Span_Link", fields: []Field{ &TypedField{ fieldName: "TraceID", @@ -335,7 +365,8 @@ var spanStatus = &messageStruct{ structName: "Status", description: "// Status is an optional final status for this span. Semantically, when Status was not\n" + "// set, that means the span ended without errors and to assume Status.Ok (code = 0).", - originFullName: "otlptrace.Status", + protoName: "Status", + upstreamProto: "gootlptrace.Status", fields: []Field{ &PrimitiveField{ fieldName: "Message", @@ -348,10 +379,33 @@ var spanStatus = &messageStruct{ returnType: &TypedType{ structName: "StatusCode", protoType: proto.TypeEnum, - messageName: "otlptrace.Status_StatusCode", - defaultVal: "otlptrace.Status_StatusCode(0)", - testVal: "otlptrace.Status_StatusCode(1)", + messageName: "StatusCode", + defaultVal: "StatusCode_STATUS_CODE_UNSET", + testVal: "StatusCode_STATUS_CODE_OK", }, }, }, } + +var spanKindEnum = &proto.Enum{ + Name: "SpanKind", + Description: "// SpanKind is the type of span.\n// Can be used to specify additional relationships between spans in addition to a parent/child relationship.", + Fields: []*proto.EnumField{ + {Name: "SPAN_KIND_UNSPECIFIED", Value: 0}, + {Name: "SPAN_KIND_INTERNAL", Value: 1}, + {Name: "SPAN_KIND_SERVER", Value: 2}, + {Name: "SPAN_KIND_CLIENT", Value: 3}, + {Name: "SPAN_KIND_PRODUCER", Value: 4}, + {Name: "SPAN_KIND_CONSUMER", Value: 5}, + }, +} + +var statusCodeEnum = &proto.Enum{ + Name: "StatusCode", + Description: "// StatusCode is the status of the span, for the semantics of codes see\n// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status", + Fields: []*proto.EnumField{ + {Name: "STATUS_CODE_UNSET", Value: 0}, + {Name: "STATUS_CODE_OK", Value: 1}, + {Name: "STATUS_CODE_ERROR", Value: 2}, + }, +} diff --git a/internal/cmd/pdatagen/internal/pdata/ptraceotlp_package.go b/internal/cmd/pdatagen/internal/pdata/ptraceotlp_package.go index 4aa00b08711..74346d74ac8 100644 --- a/internal/cmd/pdatagen/internal/pdata/ptraceotlp_package.go +++ b/internal/cmd/pdatagen/internal/pdata/ptraceotlp_package.go @@ -21,7 +21,7 @@ var ptraceotlp = &Package{ `"sort"`, `"sync"`, ``, - `otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`, + `"go.opentelemetry.io/collector/pdata/internal"`, }, testImports: []string{ `"strconv"`, @@ -33,7 +33,6 @@ var ptraceotlp = &Package{ `gootlpcollectortrace "go.opentelemetry.io/proto/slim/otlp/collector/trace/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`, }, }, structs: []baseStruct{ @@ -43,9 +42,10 @@ var ptraceotlp = &Package{ } var exportTraceResponse = &messageStruct{ - structName: "ExportResponse", - description: "// ExportResponse represents the response for gRPC/HTTP client/server.", - originFullName: "otlpcollectortrace.ExportTraceServiceResponse", + structName: "ExportResponse", + description: "// ExportResponse represents the response for gRPC/HTTP client/server.", + protoName: "ExportTraceServiceResponse", + upstreamProto: "gootlpcollectortrace.ExportTraceServiceResponse", fields: []Field{ &MessageField{ fieldName: "PartialSuccess", @@ -56,9 +56,10 @@ var exportTraceResponse = &messageStruct{ } var exportTracePartialSuccess = &messageStruct{ - structName: "ExportPartialSuccess", - description: "// ExportPartialSuccess represents the details of a partially successful export request.", - originFullName: "otlpcollectortrace.ExportTracePartialSuccess", + structName: "ExportPartialSuccess", + description: "// ExportPartialSuccess represents the details of a partially successful export request.", + protoName: "ExportTracePartialSuccess", + upstreamProto: "gootlpcollectortrace.ExportTracePartialSuccess", fields: []Field{ &PrimitiveField{ fieldName: "RejectedSpans", diff --git a/internal/cmd/pdatagen/internal/pdata/request_package.go b/internal/cmd/pdatagen/internal/pdata/request_package.go new file mode 100644 index 00000000000..d52370add07 --- /dev/null +++ b/internal/cmd/pdatagen/internal/pdata/request_package.go @@ -0,0 +1,330 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package pdata // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/pdata" + +import ( + "path/filepath" + + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" +) + +var prequest = &Package{ + info: &PackageInfo{ + name: "request", + path: filepath.Join("xpdata", "request", "internal"), + imports: []string{ + `"encoding/binary"`, + `"fmt"`, + `"iter"`, + `"math"`, + `"sort"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `"go.opentelemetry.io/collector/pdata/internal/json"`, + `"go.opentelemetry.io/collector/pdata/internal/proto"`, + `"go.opentelemetry.io/collector/pdata/pcommon"`, + }, + testImports: []string{ + `"testing"`, + ``, + `"github.com/stretchr/testify/assert"`, + `"google.golang.org/protobuf/types/known/emptypb"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `"go.opentelemetry.io/collector/pdata/internal/json"`, + `"go.opentelemetry.io/collector/pdata/pcommon"`, + }, + }, + structs: []baseStruct{ + spanContext, + ipAddr, + tcpAddr, + udpAddr, + unixAddr, + requestContext, + tracesRequest, + metricsRequest, + logsRequest, + profilesRequest, + }, +} + +var spanContext = &messageStruct{ + structName: "SpanContext", + packageName: "request", + protoName: "SpanContext", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &TypedField{ + fieldName: "TraceID", + protoID: 1, + returnType: traceIDType, + }, + &TypedField{ + fieldName: "SpanID", + protoID: 2, + returnType: spanIDType, + }, + &PrimitiveField{ + fieldName: "TraceFlags", + protoID: 3, + protoType: proto.TypeFixed32, + }, + &MessageField{ + fieldName: "TraceState", + protoID: 4, + returnMessage: traceState, + }, + &PrimitiveField{ + fieldName: "Remote", + protoID: 5, + protoType: proto.TypeBool, + }, + }, + hasOnlyInternal: true, +} + +var ipAddr = &messageStruct{ + structName: "IPAddr", + packageName: "request", + protoName: "IPAddr", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &PrimitiveField{ + fieldName: "IP", + protoID: 1, + protoType: proto.TypeBytes, + }, + &PrimitiveField{ + fieldName: "Zone", + protoID: 2, + protoType: proto.TypeString, + }, + }, + hasOnlyInternal: true, +} + +var tcpAddr = &messageStruct{ + structName: "TCPAddr", + packageName: "request", + protoName: "TCPAddr", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &PrimitiveField{ + fieldName: "IP", + protoID: 1, + protoType: proto.TypeBytes, + }, + &PrimitiveField{ + fieldName: "Port", + protoID: 2, + protoType: proto.TypeInt64, + }, + &PrimitiveField{ + fieldName: "Zone", + protoID: 3, + protoType: proto.TypeString, + }, + }, + hasOnlyInternal: true, +} + +var udpAddr = &messageStruct{ + structName: "UDPAddr", + packageName: "request", + protoName: "UDPAddr", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &PrimitiveField{ + fieldName: "IP", + protoID: 1, + protoType: proto.TypeBytes, + }, + &PrimitiveField{ + fieldName: "Port", + protoID: 2, + protoType: proto.TypeInt64, + }, + &PrimitiveField{ + fieldName: "Zone", + protoID: 3, + protoType: proto.TypeString, + }, + }, + hasOnlyInternal: true, +} + +var unixAddr = &messageStruct{ + structName: "UnixAddr", + packageName: "request", + protoName: "UnixAddr", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &PrimitiveField{ + fieldName: "Name", + protoID: 1, + protoType: proto.TypeString, + }, + &PrimitiveField{ + fieldName: "Net", + protoID: 2, + protoType: proto.TypeString, + }, + }, + hasOnlyInternal: true, +} + +var requestContext = &messageStruct{ + structName: "RequestContext", + packageName: "request", + protoName: "RequestContext", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &MessageField{ + fieldName: "SpanContext", + protoID: 1, + nullable: true, + returnMessage: spanContext, + }, + &SliceField{ + fieldName: "ClientMetadata", + protoID: 2, + protoType: proto.TypeMessage, + returnSlice: mapStruct, + }, + &OneOfField{ + typeName: "ClientAddressType", + originFieldName: "ClientAddress", + testValueIdx: 1, // + omitOriginFieldNameInNames: true, + values: []oneOfValue{ + &OneOfMessageValue{ + fieldName: "IP", + protoID: 3, + returnMessage: ipAddr, + }, + &OneOfMessageValue{ + fieldName: "TCP", + protoID: 4, + returnMessage: tcpAddr, + }, + &OneOfMessageValue{ + fieldName: "UDP", + protoID: 5, + returnMessage: udpAddr, + }, + &OneOfMessageValue{ + fieldName: "Unix", + protoID: 6, + returnMessage: unixAddr, + }, + }, + }, + }, + hasOnlyInternal: true, +} + +var tracesRequest = &messageStruct{ + structName: "TracesRequest", + packageName: "request", + protoName: "TracesRequest", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &MessageField{ + fieldName: "RequestContext", + protoID: 2, + nullable: true, + returnMessage: requestContext, + }, + &MessageField{ + fieldName: "TracesData", + protoID: 3, + returnMessage: tracesData, + }, + &PrimitiveField{ + fieldName: "FormatVersion", + protoID: 1, + protoType: proto.TypeFixed32, + }, + }, + hasOnlyInternal: true, +} + +var metricsRequest = &messageStruct{ + structName: "MetricsRequest", + packageName: "request", + protoName: "MetricsRequest", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &MessageField{ + fieldName: "RequestContext", + protoID: 2, + nullable: true, + returnMessage: requestContext, + }, + &MessageField{ + fieldName: "MetricsData", + protoID: 3, + returnMessage: metricsData, + }, + &PrimitiveField{ + fieldName: "FormatVersion", + protoID: 1, + protoType: proto.TypeFixed32, + }, + }, + hasOnlyInternal: true, +} + +var logsRequest = &messageStruct{ + structName: "LogsRequest", + packageName: "request", + protoName: "LogsRequest", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &MessageField{ + fieldName: "RequestContext", + protoID: 2, + nullable: true, + returnMessage: requestContext, + }, + &MessageField{ + fieldName: "LogsData", + protoID: 3, + returnMessage: logsData, + }, + &PrimitiveField{ + fieldName: "FormatVersion", + protoID: 1, + protoType: proto.TypeFixed32, + }, + }, + hasOnlyInternal: true, +} + +var profilesRequest = &messageStruct{ + structName: "ProfilesRequest", + packageName: "request", + protoName: "ProfilesRequest", + upstreamProto: "emptypb.Empty", + fields: []Field{ + &MessageField{ + fieldName: "RequestContext", + protoID: 2, + nullable: true, + returnMessage: requestContext, + }, + &MessageField{ + fieldName: "ProfilesData", + protoID: 3, + returnMessage: profilesData, + }, + &PrimitiveField{ + fieldName: "FormatVersion", + protoID: 1, + protoType: proto.TypeFixed32, + }, + }, + hasOnlyInternal: true, +} diff --git a/internal/cmd/pdatagen/internal/pdata/slice_field.go b/internal/cmd/pdatagen/internal/pdata/slice_field.go index 97ccd004f7f..d9f355b5bb7 100644 --- a/internal/cmd/pdatagen/internal/pdata/slice_field.go +++ b/internal/cmd/pdatagen/internal/pdata/slice_field.go @@ -11,7 +11,7 @@ import ( const sliceAccessorTemplate = `// {{ .fieldName }} returns the {{ .fieldName }} associated with this {{ .structName }}. func (ms {{ .structName }}) {{ .fieldName }}() {{ .packageName }}{{ .returnType }} { {{- if .elementHasWrapper }} - return {{ .packageName }}{{ .returnType }}(internal.New{{ .returnType }}(&ms.{{ .origAccessor }}.{{ .originFieldName }}, ms.{{ .stateAccessor }})) + return {{ .packageName }}{{ .returnType }}(internal.New{{ .returnType }}Wrapper(&ms.{{ .origAccessor }}.{{ .originFieldName }}, ms.{{ .stateAccessor }})) {{- else }} return new{{ .returnType }}(&ms.{{ .origAccessor }}.{{ .originFieldName }}, ms.{{ .stateAccessor }}) {{- end }} @@ -20,17 +20,15 @@ func (ms {{ .structName }}) {{ .fieldName }}() {{ .packageName }}{{ .returnType const sliceAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldName }}(t *testing.T) { ms := New{{ .structName }}() assert.Equal(t, {{ .packageName }}New{{ .returnType }}(), ms.{{ .fieldName }}()) - ms.{{ .origAccessor }}.{{ .originFieldName }} = internal.GenerateOrigTest{{ .elementOriginName }}Slice() + ms.{{ .origAccessor }}.{{ .originFieldName }} = internal.GenTest{{ .elementOriginName }}{{ if .elementNullable }}Ptr{{ end }}Slice() {{- if .elementHasWrapper }} - assert.Equal(t, {{ .packageName }}{{ .returnType }}(internal.GenerateTest{{ .returnType }}()), ms.{{ .fieldName }}()) + assert.Equal(t, {{ .packageName }}{{ .returnType }}(internal.GenTest{{ .returnType }}Wrapper()), ms.{{ .fieldName }}()) {{- else }} assert.Equal(t, generateTest{{ .returnType }}(), ms.{{ .fieldName }}()) {{- end }} }` -const sliceSetTestTemplate = `orig.{{ .originFieldName }} = GenerateOrigTest{{ .elementOriginName }}Slice()` - -const sliceCopyOrigTemplate = `dest.{{ .originFieldName }} = CopyOrig{{ .elementOriginName }}Slice(dest.{{ .originFieldName }}, src.{{ .originFieldName }})` +const sliceSetTestTemplate = `orig.{{ .originFieldName }} = internal.GenTest{{ .elementOriginName }}{{ if .elementNullable }}Ptr{{ end }}Slice()` type SliceField struct { fieldName string @@ -61,55 +59,15 @@ func (sf *SliceField) GenerateTestValue(ms *messageStruct) string { return template.Execute(t, sf.templateFields(ms)) } -func (sf *SliceField) GenerateTestFailingUnmarshalProtoValues(*messageStruct) string { - return sf.toProtoField().GenTestFailingUnmarshalProtoValues() -} - -func (sf *SliceField) GenerateTestEncodingValues(*messageStruct) string { - return sf.toProtoField().GenTestEncodingValues() -} - -func (sf *SliceField) GeneratePoolOrig(*messageStruct) string { - return "" -} - -func (sf *SliceField) GenerateDeleteOrig(*messageStruct) string { - return sf.toProtoField().GenDeleteOrig() -} - -func (sf *SliceField) GenerateCopyOrig(ms *messageStruct) string { - t := template.Parse("sliceCopyOrigTemplate", []byte(sliceCopyOrigTemplate)) - return template.Execute(t, sf.templateFields(ms)) -} - -func (sf *SliceField) GenerateMarshalJSON(*messageStruct) string { - return sf.toProtoField().GenMarshalJSON() -} - -func (sf *SliceField) GenerateUnmarshalJSON(*messageStruct) string { - return sf.toProtoField().GenUnmarshalJSON() -} - -func (sf *SliceField) GenerateSizeProto(*messageStruct) string { - return sf.toProtoField().GenSizeProto() -} - -func (sf *SliceField) GenerateMarshalProto(*messageStruct) string { - return sf.toProtoField().GenMarshalProto() -} - -func (sf *SliceField) GenerateUnmarshalProto(*messageStruct) string { - return sf.toProtoField().GenUnmarshalProto() -} - -func (sf *SliceField) toProtoField() *proto.Field { +func (sf *SliceField) toProtoField(ms *messageStruct) proto.FieldInterface { return &proto.Field{ - Type: sf.protoType, - ID: sf.protoID, - Name: sf.fieldName, - MessageFullName: sf.returnSlice.getOriginFullName(), - Repeated: sf.protoType != proto.TypeBytes, - Nullable: sf.returnSlice.getElementNullable(), + Type: sf.protoType, + ID: sf.protoID, + Name: sf.fieldName, + MessageName: sf.returnSlice.getElementOriginName(), + ParentMessageName: ms.protoName, + Repeated: sf.protoType != proto.TypeBytes, + Nullable: sf.returnSlice.getElementNullable(), } } @@ -129,6 +87,7 @@ func (sf *SliceField) templateFields(ms *messageStruct) map[string]any { "origAccessor": origAccessor(ms.getHasWrapper()), "stateAccessor": stateAccessor(ms.getHasWrapper()), "elementHasWrapper": sf.returnSlice.getHasWrapper(), + "elementNullable": sf.returnSlice.getElementNullable(), } } diff --git a/internal/cmd/pdatagen/internal/pdata/templates.go b/internal/cmd/pdatagen/internal/pdata/templates.go index ff3bfe08d1c..4c90a05be89 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates.go +++ b/internal/cmd/pdatagen/internal/pdata/templates.go @@ -18,10 +18,6 @@ var ( messageInternalTemplateBytes []byte messageInternalTemplate = template.Parse("message_internal.go", messageInternalTemplateBytes) - //go:embed templates/message_internal_test.go.tmpl - messageInternalTestTemplateBytes []byte - messageInternalTestTemplate = template.Parse("message_internal_test.go", messageInternalTestTemplateBytes) - //go:embed templates/message_test.go.tmpl messageTestTemplateBytes []byte messageTestTemplate = template.Parse("message_test.go", messageTestTemplateBytes) @@ -34,10 +30,6 @@ var ( primitiveSliceInternalTemplateBytes []byte primitiveSliceInternalTemplate = template.Parse("primitive_slice_internal.go", primitiveSliceInternalTemplateBytes) - //go:embed templates/primitive_slice_internal_test.go.tmpl - primitiveSliceInternalTestTemplateBytes []byte - primitiveSliceInternalTestTemplate = template.Parse("primitive_slice_internal_test.go", primitiveSliceInternalTestTemplateBytes) - //go:embed templates/primitive_slice_test.go.tmpl primitiveSliceTestTemplateBytes []byte primitiveSliceTestTemplate = template.Parse("primitive_slice_test.go", primitiveSliceTestTemplateBytes) @@ -50,10 +42,6 @@ var ( sliceInternalTemplateBytes []byte sliceInternalTemplate = template.Parse("slice_internal.go", sliceInternalTemplateBytes) - //go:embed templates/slice_internal_test.go.tmpl - sliceInternalTestTemplateBytes []byte - sliceInternalTestTemplate = template.Parse("slice_internal_test.go", sliceInternalTestTemplateBytes) - //go:embed templates/slice_test.go.tmpl sliceTestTemplateBytes []byte sliceTestTemplate = template.Parse("slice_test.go", sliceTestTemplateBytes) diff --git a/internal/cmd/pdatagen/internal/pdata/templates/message.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/message.go.tmpl index 49bc5e95ca0..6aa857f2434 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/message.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/message.go.tmpl @@ -20,17 +20,17 @@ import ( // Must use New{{ .structName }} function to create new instances. // Important: zero-initialized instance is not valid for use. {{- if .hasWrapper }} -type {{ .structName }} internal.{{ .structName }} +type {{ .structName }} internal.{{ .structName }}Wrapper {{- else }} type {{ .structName }} struct { - orig *{{ .originFullName }} + orig *internal.{{ .originName }} state *internal.State } {{- end }} -func new{{ .structName }}(orig *{{ .originFullName }}, state *internal.State) {{ .structName }} { +func new{{ .structName }}(orig *internal.{{ .originName }}, state *internal.State) {{ .structName }} { {{- if .hasWrapper }} - return {{ .structName }}(internal.New{{ .structName }}(orig, state)) + return {{ .structName }}(internal.New{{ .structName }}Wrapper(orig, state)) {{- else }} return {{ .structName }}{orig: orig, state: state} {{- end }} @@ -41,7 +41,7 @@ func new{{ .structName }}(orig *{{ .originFullName }}, state *internal.State) {{ // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func New{{ .structName }}() {{ .structName }} { - return new{{ .structName }}(internal.NewOrig{{ .originName }}(), internal.NewState()) + return new{{ .structName }}(internal.New{{ .originName }}(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -53,7 +53,7 @@ func (ms {{ .structName }}) MoveTo(dest {{ .structName }}) { if ms.{{ .origAccessor }} == dest.{{ .origAccessor }} { return } - internal.DeleteOrig{{ .originName }}(dest.{{ .origAccessor }}, false) + internal.Delete{{ .originName }}(dest.{{ .origAccessor }}, false) *dest.{{ .origAccessor }}, *ms.{{ .origAccessor }} = *ms.{{ .origAccessor }}, *dest.{{ .origAccessor }} } @@ -64,15 +64,15 @@ func (ms {{ .structName }}) MoveTo(dest {{ .structName }}) { // CopyTo copies all properties from the current struct overriding the destination. func (ms {{ .structName }}) CopyTo(dest {{ .structName }}) { dest.{{ .stateAccessor }}.AssertMutable() - internal.CopyOrig{{ .originName }}(dest.{{ .origAccessor }}, ms.{{ .origAccessor }}) + internal.Copy{{ .originName }}(dest.{{ .origAccessor }}, ms.{{ .origAccessor }}) } {{ if .hasWrapper -}} -func (ms {{ .structName }}) getOrig() *{{ .originFullName }} { - return internal.GetOrig{{ .structName }}(internal.{{ .structName }}(ms)) +func (ms {{ .structName }}) getOrig() *internal.{{ .originName }} { + return internal.Get{{ .structName }}Orig(internal.{{ .structName }}Wrapper(ms)) } func (ms {{ .structName }}) getState() *internal.State { - return internal.Get{{ .structName }}State(internal.{{ .structName }}(ms)) + return internal.Get{{ .structName }}State(internal.{{ .structName }}Wrapper(ms)) } {{- end }} diff --git a/internal/cmd/pdatagen/internal/pdata/templates/message_internal.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/message_internal.go.tmpl index b7bfded762e..8464fd0582f 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/message_internal.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/message_internal.go.tmpl @@ -11,145 +11,24 @@ import ( {{ $element }} {{ end }} ) -{{ if .hasWrapper }} -type {{ .structName }} struct { - orig *{{ .originFullName }} +type {{ .structName }}Wrapper struct { + orig *{{ .originName }} state *State } -func GetOrig{{ .structName }}(ms {{ .structName }}) *{{ .originFullName }} { +func Get{{ .structName }}Orig(ms {{ .structName }}Wrapper) *{{ .originName }} { return ms.orig } -func Get{{ .structName }}State(ms {{ .structName }}) *State { +func Get{{ .structName }}State(ms {{ .structName }}Wrapper) *State { return ms.state } -func New{{ .structName }}(orig *{{ .originFullName }}, state *State) {{ .structName }} { - return {{ .structName }}{orig: orig, state: state} +func New{{ .structName }}Wrapper(orig *{{ .originName }}, state *State) {{ .structName }}Wrapper { + return {{ .structName }}Wrapper{orig: orig, state: state} } -{{ end }} - -var ( - protoPool{{ .originName }} = sync.Pool{ - New: func() any { - return &{{ .originFullName }}{} - }, - } - {{- range .fields }}{{ .GeneratePoolOrig $.messageStruct }}{{- end }} -) - - -func NewOrig{{ .originName }}() *{{ .originFullName }} { - if !UseProtoPooling.IsEnabled() { - return &{{ .originFullName }}{} - } - return protoPool{{ .originName }}.Get().(*{{ .originFullName }}) -} - -func DeleteOrig{{ .originName }}(orig *{{ .originFullName }}, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - {{ range .fields }}{{ .GenerateDeleteOrig $.messageStruct }}{{ end }} - orig.Reset() - if nullable { - protoPool{{ .originName }}.Put(orig) - } -} - -func CopyOrig{{ .originName }}(dest, src *{{ .originFullName }}) { - // If copying to same object, just return. - if src == dest { - return - } - - {{- range .fields }} - {{ .GenerateCopyOrig $.messageStruct }} - {{- end }} -} - -func GenTestOrig{{ .originName }}() *{{ .originFullName }} { - orig := NewOrig{{ .originName }}() - {{- range .fields }} - {{ .GenerateTestValue $.messageStruct }} - {{- end }} - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrig{{ .originName }}(orig *{{ .originFullName }}, dest *json.Stream) { - dest.WriteObjectStart() - {{ range .fields -}} - {{ .GenerateMarshalJSON $.messageStruct }} - {{ end -}} - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrig{{ .structName }} unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrig{{ .originName }}(orig *{{ .originFullName }}, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - {{ range .fields -}} - {{ .GenerateUnmarshalJSON $.messageStruct }} - {{ end -}} - default: - iter.Skip() - } - } -} - -func SizeProtoOrig{{ .originName }}(orig *{{ .originFullName }}) int { - var n int - var l int - _ = l - {{ range .fields -}} - {{ .GenerateSizeProto $.messageStruct }} - {{ end -}} - return n -} - -func MarshalProtoOrig{{ .originName }}(orig *{{ .originFullName }}, buf []byte) int { - pos := len(buf) - var l int - _ = l - {{ range .fields -}} - {{ .GenerateMarshalProto $.messageStruct }} - {{ end -}} - return len(buf) - pos -} - -func UnmarshalProtoOrig{{ .originName }}(orig *{{ .originFullName }}, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - {{ range .fields -}} - {{ .GenerateUnmarshalProto $.messageStruct }} - {{ end -}} - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} +func GenTest{{ .structName }}Wrapper() {{ .structName }}Wrapper { + return New{{ .structName }}Wrapper(GenTest{{ .originName }}(), NewState()) +} \ No newline at end of file diff --git a/internal/cmd/pdatagen/internal/pdata/templates/message_internal_test.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/message_internal_test.go.tmpl deleted file mode 100644 index 0b496d5a9be..00000000000 --- a/internal/cmd/pdatagen/internal/pdata/templates/message_internal_test.go.tmpl +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - {{ range $index, $element := .testImports -}} - {{ $element }} - {{ end }} -) - -func TestCopyOrig{{ .originName }}(t *testing.T) { - for name, src := range genTestEncodingValues{{ .originName }}() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrig{{ .originName }}() - CopyOrig{{ .originName }}(dest, src) - assert.Equal(t, src, dest) - CopyOrig{{ .originName }}(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrig{{ .originName }}Unknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrig{{ .originName }}() - UnmarshalJSONOrig{{ .originName }}(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrig{{ .originName }}(), dest) -} - -func TestMarshalAndUnmarshalJSONOrig{{ .originName }}(t *testing.T) { - for name, src := range genTestEncodingValues{{ .originName }}() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrig{{ .originName }}(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrig{{ .originName }}() - UnmarshalJSONOrig{{ .originName }}(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrig{{ .originName }}(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrig{{ .originName }}Failing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValues{{ .originName }}() { - t.Run(name, func(t *testing.T) { - dest := NewOrig{{ .originName }}() - require.Error(t, UnmarshalProtoOrig{{ .originName }}(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrig{{ .originName }}Unknown(t *testing.T) { - dest := NewOrig{{ .originName }}() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrig{{ .originName }}(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrig{{ .originName }}(), dest) -} - -func TestMarshalAndUnmarshalProtoOrig{{ .originName }}(t *testing.T) { - for name, src := range genTestEncodingValues{{ .originName }}(){ - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrig{{ .originName }}(src)) - gotSize := MarshalProtoOrig{{ .originName }}(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrig{{ .originName }}() - require.NoError(t, UnmarshalProtoOrig{{ .originName }}(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrig{{ .originName }}(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobuf{{ .originName }}(t *testing.T) { - for name, src := range genTestEncodingValues{{ .originName }}(){ - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrig{{ .originName }}(src)) - gotSize := MarshalProtoOrig{{ .originName }}(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &go{{ .originFullName }}{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrig{{ .originName }}() - require.NoError(t, UnmarshalProtoOrig{{ .originName }}(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValues{{ .originName }}() map[string][]byte { - return map[string][]byte{ - "invalid_field": { 0x02 }, - {{- range .fields }}{{ .GenerateTestFailingUnmarshalProtoValues $.messageStruct }}{{- end }} - } -} - -func genTestEncodingValues{{ .originName }}() map[string]*{{ .originFullName }} { - return map[string]*{{ .originFullName }}{ - "empty": NewOrig{{ .originName }}(), - {{- range .fields }}{{ .GenerateTestEncodingValues $.messageStruct }}{{- end }} - } -} diff --git a/internal/cmd/pdatagen/internal/pdata/templates/message_test.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/message_test.go.tmpl index d440e9e8f78..ecb93ebc8d9 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/message_test.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/message_test.go.tmpl @@ -22,8 +22,8 @@ func Test{{ .structName }}_MoveTo(t *testing.T) { assert.Equal(t, generateTest{{ .structName }}(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(new{{ .structName }}(internal.NewOrig{{ .originName }}(), sharedState)) }) - assert.Panics(t, func() { new{{ .structName }}(internal.NewOrig{{ .originName }}(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(new{{ .structName }}(internal.New{{ .originName }}(), sharedState)) }) + assert.Panics(t, func() { new{{ .structName }}(internal.New{{ .originName }}(), sharedState).MoveTo(dest) }) } func Test{{ .structName }}_CopyTo(t *testing.T) { @@ -36,7 +36,7 @@ func Test{{ .structName }}_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(new{{ .structName }}(internal.NewOrig{{ .originName }}(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(new{{ .structName }}(internal.New{{ .originName }}(), sharedState)) }) } {{ range .fields }} @@ -44,6 +44,5 @@ func Test{{ .structName }}_CopyTo(t *testing.T) { {{ end }} func generateTest{{ .structName }}() {{ .structName }} { - ms := new{{ .structName }}(internal.GenTestOrig{{ .originName }}(), internal.NewState()) - return ms + return new{{ .structName }}(internal.GenTest{{ .originName }}(), internal.NewState()) } diff --git a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice.go.tmpl index c9f1941a4b0..a0b24e6e306 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice.go.tmpl @@ -17,31 +17,31 @@ import ( // // Must use New{{ .structName }} function to create new instances. // Important: zero-initialized instance is not valid for use. -type {{ .structName }} internal.{{ .structName }} +type {{ .structName }} internal.{{ .structName }}Wrapper func (ms {{ .structName }}) getOrig() *[]{{ .itemType }} { - return internal.GetOrig{{ .structName }}(internal.{{ .structName }}(ms)) + return internal.Get{{ .structName }}Orig(internal.{{ .structName }}Wrapper(ms)) } func (ms {{ .structName }}) getState() *internal.State { - return internal.Get{{ .structName }}State(internal.{{ .structName }}(ms)) + return internal.Get{{ .structName }}State(internal.{{ .structName }}Wrapper(ms)) } // New{{ .structName }} creates a new empty {{ .structName }}. func New{{ .structName }}() {{ .structName }} { orig := []{{ .itemType }}(nil) - return {{ .structName }}(internal.New{{ .structName }}(&orig, internal.NewState())) + return {{ .structName }}(internal.New{{ .structName }}Wrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []{{ .itemType }} slice. func (ms {{ .structName }}) AsRaw() []{{ .itemType }} { - return internal.CopyOrig{{ .elementOriginName }}Slice(nil, *ms.getOrig()) + return copy{{ .elementOriginName }}Slice(nil, *ms.getOrig()) } // FromRaw copies raw []{{ .itemType }} into the slice {{ .structName }}. func (ms {{ .structName }}) FromRaw(val []{{ .itemType }}) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrig{{ .elementOriginName }}Slice(*ms.getOrig(), val) + *ms.getOrig() = copy{{ .elementOriginName }}Slice(*ms.getOrig(), val) } // Len returns length of the []{{ .itemType }} slice value. @@ -154,10 +154,14 @@ func (ms {{ .structName }}) CopyTo(dest {{ .structName }}) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrig{{ .elementOriginName }}Slice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copy{{ .elementOriginName }}Slice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another {{ .structName }} func (ms {{ .structName }}) Equal(val {{ .structName }}) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copy{{ .elementOriginName }}Slice(dst, src []{{ .itemType }}) []{{ .itemType }} { + return append(dst[:0], src...) +} \ No newline at end of file diff --git a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal.go.tmpl index 96894127d38..10ee0b7d13c 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal.go.tmpl @@ -12,32 +12,28 @@ import ( {{ end }} ) -type {{ .structName }} struct { +type {{ .structName }}Wrapper struct { orig *[]{{ .itemType }} state *State } -func GetOrig{{ .structName }}(ms {{ .structName }}) *[]{{ .itemType }} { +func Get{{ .structName }}Orig(ms {{ .structName }}Wrapper) *[]{{ .itemType }} { return ms.orig } -func Get{{ .structName }}State(ms {{ .structName }}) *State { +func Get{{ .structName }}State(ms {{ .structName }}Wrapper) *State { return ms.state } -func New{{ .structName }}(orig *[]{{ .itemType }}, state *State) {{ .structName }} { - return {{ .structName }}{orig: orig, state: state} +func New{{ .structName }}Wrapper(orig *[]{{ .itemType }}, state *State) {{ .structName }}Wrapper { + return {{ .structName }}Wrapper{orig: orig, state: state} } -func GenerateTest{{ .structName }}() {{ .structName }} { - orig := GenerateOrigTest{{ .elementOriginName }}Slice() - return New{{ .structName }}(&orig, NewState()) +func GenTest{{ .structName }}Wrapper() {{ .structName }}Wrapper { + orig := []{{ .itemType }}{ {{ .testOrigVal }} } + return New{{ .structName }}Wrapper(&orig, NewState()) } -func CopyOrig{{ .elementOriginName }}Slice(dst, src []{{ .itemType }}) []{{ .itemType }} { - return append(dst[:0], src...) -} - -func GenerateOrigTest{{ .elementOriginName }}Slice() []{{ .itemType }} { - return []{{ .itemType }}{ {{ .testOrigVal }} } -} +func GenTest{{ .elementOriginName }}Slice() []{{ .itemType }} { + return []{{ .itemType }}{ {{ .testOrigVal }} } +} \ No newline at end of file diff --git a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal_test.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal_test.go.tmpl deleted file mode 100644 index 6715822be27..00000000000 --- a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_internal_test.go.tmpl +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - {{ range $index, $element := .testImports -}} - {{ $element }} - {{ end }} -) - -func TestCopyOrig{{ .elementOriginName }}Slice(t *testing.T) { - src := []{{ .itemType }}{} - dest := []{{ .itemType }}{} - // Copy empty - dest = CopyOrig{{ .elementOriginName }}Slice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTest{{ .elementOriginName }}Slice() - dest = CopyOrig{{ .elementOriginName }}Slice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_test.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_test.go.tmpl index ec49056cf79..0bb165063f2 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_test.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/primitive_slice_test.go.tmpl @@ -78,7 +78,7 @@ func Test{{ .structName }}ReadOnly(t *testing.T) { raw := []{{ .itemType }}{ {{ .testOrigVal }}} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := {{ .structName }}(internal.New{{ .structName }}(&raw, sharedState)) + ms := {{ .structName }}(internal.New{{ .structName }}Wrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) {{- if eq .itemType "float64" }} diff --git a/internal/cmd/pdatagen/internal/pdata/templates/slice.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/slice.go.tmpl index 9ff3aa6f5ce..e07b4a427cd 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/slice.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/slice.go.tmpl @@ -20,17 +20,17 @@ import ( // Must use New{{ .structName }} function to create new instances. // Important: zero-initialized instance is not valid for use. {{- if .hasWrapper }} -type {{ .structName }} internal.{{ .structName }} +type {{ .structName }} internal.{{ .structName }}Wrapper {{- else }} type {{ .structName }} struct { - orig *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} + orig *[]{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }} state *internal.State } {{- end }} -func new{{ .structName }}(orig *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}, state *internal.State) {{ .structName }} { +func new{{ .structName }}(orig *[]{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }}, state *internal.State) {{ .structName }} { {{- if .hasWrapper }} - return {{ .structName }}(internal.New{{ .structName }}(orig, state)) + return {{ .structName }}(internal.New{{ .structName }}Wrapper(orig, state)) {{- else }} return {{ .structName }}{orig: orig, state: state} {{- end }} @@ -39,7 +39,7 @@ func new{{ .structName }}(orig *[]{{ if .elementNullable }}*{{ end }}{{ .element // New{{ .structName }} creates a {{ .structName }} with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func New{{ .structName }}() {{ .structName }} { - orig := []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}(nil) + orig := []{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }}(nil) return new{{ .structName }}(&orig, internal.NewState()) } @@ -94,7 +94,7 @@ func (es {{ .structName }}) EnsureCapacity(newCap int) { return } - newOrig := make([]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}, len(*es.{{ .origAccessor }}), newCap) + newOrig := make([]{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }}, len(*es.{{ .origAccessor }}), newCap) copy(newOrig, *es.{{ .origAccessor }}) *es.{{ .origAccessor }} = newOrig } @@ -103,7 +103,7 @@ func (es {{ .structName }}) EnsureCapacity(newCap int) { // It returns the newly added {{ .elementName }}. func (es {{ .structName }}) AppendEmpty() {{ .elementName }} { es.{{ .stateAccessor }}.AssertMutable() - *es.{{ .origAccessor }} = append(*es.{{ .origAccessor }}, {{- if .elementNullable }}internal.NewOrig{{ .elementOriginName }}(){{ else }}{{ .elementOriginFullName }}{}{{ end }}) + *es.{{ .origAccessor }} = append(*es.{{ .origAccessor }}, {{- if .elementNullable }}internal.New{{ .elementOriginName }}(){{ else }}internal.{{ .elementOriginName }}{}{{ end }}) return es.At(es.Len() - 1) } @@ -133,10 +133,10 @@ func (es {{ .structName }}) RemoveIf(f func({{ .elementName }}) bool) { for i := 0; i < len(*es.{{ .origAccessor }}); i++ { if f(es.At(i)) { {{ if .elementNullable -}} - internal.DeleteOrig{{ .elementOriginName }}((*es.{{ .origAccessor }})[i], true) + internal.Delete{{ .elementOriginName }}((*es.{{ .origAccessor }})[i], true) (*es.{{ .origAccessor }})[i] = nil {{ else -}} - internal.DeleteOrig{{ .elementOriginName }}(&(*es.{{ .origAccessor }})[i], false) + internal.Delete{{ .elementOriginName }}(&(*es.{{ .origAccessor }})[i], false) {{- end }} continue } @@ -163,7 +163,7 @@ func (es {{ .structName }}) CopyTo(dest {{ .structName }}) { if es.{{ .origAccessor }} == dest.{{ .origAccessor }} { return } - *dest.{{ .origAccessor }} = internal.CopyOrig{{ .elementOriginName }}Slice(*dest.{{ .origAccessor }}, *es.{{ .origAccessor }}) + *dest.{{ .origAccessor }} = internal.Copy{{ .elementOriginName }}{{ if .elementNullable }}Ptr{{ end }}Slice(*dest.{{ .origAccessor }}, *es.{{ .origAccessor }}) } {{ if .elementNullable -}} @@ -177,11 +177,11 @@ func (es {{ .structName }}) Sort(less func(a, b {{ .elementName }}) bool) { {{- end }} {{ if .hasWrapper -}} -func (ms {{ .structName }}) getOrig() *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} { - return internal.GetOrig{{ .structName }}(internal.{{ .structName }}(ms)) +func (ms {{ .structName }}) getOrig() *[]{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }} { + return internal.Get{{ .structName }}Orig(internal.{{ .structName }}Wrapper(ms)) } func (ms {{ .structName }}) getState() *internal.State { - return internal.Get{{ .structName }}State(internal.{{ .structName }}(ms)) + return internal.Get{{ .structName }}State(internal.{{ .structName }}Wrapper(ms)) } {{- end }} diff --git a/internal/cmd/pdatagen/internal/pdata/templates/slice_internal.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/slice_internal.go.tmpl index 414756b9d01..e55083c6a15 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/slice_internal.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/slice_internal.go.tmpl @@ -11,80 +11,25 @@ import ( {{ $element }} {{ end }} ) -{{ if .hasWrapper }} -type {{ .structName }} struct { - orig *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} +type {{ .structName }}Wrapper struct { + orig *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginName }} state *State } -func GetOrig{{ .structName }}(ms {{ .structName }}) *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} { +func Get{{ .structName }}Orig(ms {{ .structName }}Wrapper) *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginName }} { return ms.orig } -func Get{{ .structName }}State(ms {{ .structName }}) *State { +func Get{{ .structName }}State(ms {{ .structName }}Wrapper) *State { return ms.state } -func New{{ .structName }}(orig *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}, state *State) {{ .structName }} { - return {{ .structName }}{orig: orig, state: state} +func New{{ .structName }}Wrapper(orig *[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginName }}, state *State) {{ .structName }}Wrapper { + return {{ .structName }}Wrapper{orig: orig, state: state} } -func GenerateTest{{ .structName }}() {{ .structName }} { - orig := GenerateOrigTest{{ .elementOriginName }}Slice() - return New{{ .structName }}(&orig, NewState()) -} -{{ end }} - -func CopyOrig{{ .elementOriginName }}Slice(dest, src []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}) []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} { - var newDest []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} - if cap(dest) < len(src) { - {{ if .elementNullable -}} - newDest = make([]*{{ .elementOriginFullName }}, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrig{{ .elementOriginName }}() - }{{ else -}} - newDest = make([]{{ .elementOriginFullName }}, len(src)) - {{- end }} - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - {{ if .elementNullable -}} - for i := len(src); i < len(dest); i++ { - DeleteOrig{{ .elementOriginName }}(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrig{{ .elementOriginName }}() - }{{ else -}} - for i := len(src); i < len(dest); i++ { - DeleteOrig{{ .elementOriginName }}(&dest[i], false) - } - {{- end }} - } - for i := range src { - CopyOrig{{ .elementOriginName }}({{ if not .elementNullable }}&{{ end }}newDest[i], {{ if not .elementNullable }}&{{ end }}src[i]) - } - return newDest -} - -func GenerateOrigTest{{ .elementOriginName }}Slice() []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }} { - {{ if .elementNullable -}} - orig := make([]*{{ .elementOriginFullName }}, 5) - orig[0] = NewOrig{{ .elementOriginName }}() - orig[1] = GenTestOrig{{ .elementOriginName }}() - orig[2] = NewOrig{{ .elementOriginName }}() - orig[3] = GenTestOrig{{ .elementOriginName }}() - orig[4] = NewOrig{{ .elementOriginName }}(){{ else -}} - orig := make([]{{ .elementOriginFullName }}, 5) - orig[1] = *GenTestOrig{{ .elementOriginName }}() - orig[3] = *GenTestOrig{{ .elementOriginName }}() - {{- end }} - return orig -} +func GenTest{{ .structName }}Wrapper() {{ .structName }}Wrapper { + orig := GenTest{{ .elementOriginName }}{{ if .elementNullable }}Ptr{{ end }}Slice() + return New{{ .structName }}Wrapper(&orig, NewState()) +} \ No newline at end of file diff --git a/internal/cmd/pdatagen/internal/pdata/templates/slice_internal_test.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/slice_internal_test.go.tmpl deleted file mode 100644 index d76250ee580..00000000000 --- a/internal/cmd/pdatagen/internal/pdata/templates/slice_internal_test.go.tmpl +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - {{ range $index, $element := .testImports -}} - {{ $element }} - {{ end }} -) - -func TestCopyOrig{{ .elementOriginName }}Slice(t *testing.T) { - src := []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}{} - dest := []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}{} - // Test CopyTo empty - dest = CopyOrig{{ .elementOriginName }}Slice(dest, src) - assert.Equal(t, []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTest{{ .elementOriginName }}Slice() - dest = CopyOrig{{ .elementOriginName }}Slice(dest, src) - assert.Equal(t, GenerateOrigTest{{ .elementOriginName }}Slice(), dest) - - // Test CopyTo same size slice - dest = CopyOrig{{ .elementOriginName }}Slice(dest, src) - assert.Equal(t, GenerateOrigTest{{ .elementOriginName }}Slice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrig{{ .elementOriginName }}Slice(dest, []{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrig{{ .elementOriginName }}Slice(dest, src) - assert.Equal(t, GenerateOrigTest{{ .elementOriginName }}Slice(), dest) -} diff --git a/internal/cmd/pdatagen/internal/pdata/templates/slice_test.go.tmpl b/internal/cmd/pdatagen/internal/pdata/templates/slice_test.go.tmpl index 2f3d339743b..f47398268ec 100644 --- a/internal/cmd/pdatagen/internal/pdata/templates/slice_test.go.tmpl +++ b/internal/cmd/pdatagen/internal/pdata/templates/slice_test.go.tmpl @@ -15,7 +15,7 @@ import ( func Test{{ .structName }}(t *testing.T) { es := New{{ .structName }}() assert.Equal(t, 0, es.Len()) - es = new{{ .structName }}(&[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}{}, internal.NewState()) + es = new{{ .structName }}(&[]{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }}{}, internal.NewState()) assert.Equal(t, 0, es.Len()) {{ if eq .elementName "Value" -}} @@ -24,14 +24,14 @@ func Test{{ .structName }}(t *testing.T) { emptyVal := New{{ .elementName }}() {{- end }} {{- if .hasWrapper }} - testVal := {{ .elementName }}(internal.New{{ .elementName }}(internal.GenTestOrig{{ .elementOriginName }}(), internal.NewState())) + testVal := {{ .elementName }}(internal.GenTest{{ .elementName }}Wrapper()) {{- else }} testVal := generateTest{{ .elementName }}() {{- end }} for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.{{ .origAccessor }})[i] = {{ if not .elementNullable }}*{{ end }}internal.GenTestOrig{{ .elementOriginName }}() + (*es.{{ .origAccessor }})[i] = {{ if not .elementNullable }}*{{ end }}internal.GenTest{{ .elementOriginName }}() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -40,7 +40,7 @@ func Test{{ .structName }}(t *testing.T) { func Test{{ .structName }}ReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := new{{ .structName }}(&[]{{ if .elementNullable }}*{{ end }}{{ .elementOriginFullName }}{}, sharedState) + es := new{{ .structName }}(&[]{{ if .elementNullable }}*{{ end }}internal.{{ .elementOriginName }}{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -168,6 +168,6 @@ func Test{{ .structName }}_Sort(t *testing.T) { func generateTest{{ .structName }}() {{ .structName }} { ms := New{{ .structName }}() - *ms.{{ .origAccessor }} = internal.GenerateOrigTest{{ .elementOriginName }}Slice() + *ms.{{ .origAccessor }} = internal.GenTest{{ .elementOriginName }}{{ if .elementNullable }}Ptr{{ end }}Slice() return ms } diff --git a/internal/cmd/pdatagen/internal/pdata/typed_field.go b/internal/cmd/pdatagen/internal/pdata/typed_field.go index d15b1946041..1445066f441 100644 --- a/internal/cmd/pdatagen/internal/pdata/typed_field.go +++ b/internal/cmd/pdatagen/internal/pdata/typed_field.go @@ -18,7 +18,7 @@ func (ms {{ .structName }}) {{ .fieldName }}() {{ .packageName }}{{ .returnType // Set{{ .fieldName }} replaces the {{ .lowerFieldName }} associated with this {{ .structName }}. func (ms {{ .structName }}) Set{{ .fieldName }}(v {{ .packageName }}{{ .returnType }}) { ms.state.AssertMutable() - ms.orig.{{ .originFieldName }} = {{ .rawType }}(v) + ms.orig.{{ .originFieldName }} = {{ .messageType }}(v) }` const typedAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldName }}(t *testing.T) { @@ -31,8 +31,6 @@ const typedAccessorsTestTemplate = `func Test{{ .structName }}_{{ .fieldName }}( const typedSetTestTemplate = `orig.{{ .originFieldName }} = {{ .testValue }}` -const typedCopyOrigTemplate = `dest.{{ .originFieldName }} = src.{{ .originFieldName }}` - // TypedField is a field that has defined a custom type (e.g. "type Timestamp uint64") type TypedField struct { fieldName string @@ -67,64 +65,47 @@ func (ptf *TypedField) GenerateTestValue(ms *messageStruct) string { return template.Execute(t, ptf.templateFields(ms)) } -func (ptf *TypedField) GenerateTestFailingUnmarshalProtoValues(*messageStruct) string { - return ptf.toProtoField().GenTestFailingUnmarshalProtoValues() -} - -func (ptf *TypedField) GenerateTestEncodingValues(*messageStruct) string { - return ptf.toProtoField().GenTestEncodingValues() -} - -func (ptf *TypedField) GeneratePoolOrig(*messageStruct) string { - return "" -} - -func (ptf *TypedField) GenerateDeleteOrig(*messageStruct) string { - return ptf.toProtoField().GenDeleteOrig() +type ProtoTypedField struct { + *proto.Field } -func (ptf *TypedField) GenerateCopyOrig(ms *messageStruct) string { - t := template.Parse("typedCopyOrigTemplate", []byte(typedCopyOrigTemplate)) - return template.Execute(t, ptf.templateFields(ms)) -} - -func (ptf *TypedField) GenerateMarshalJSON(*messageStruct) string { - if strings.HasPrefix(ptf.returnType.messageName, "data.") { - return "if orig." + ptf.getOriginFieldName() + " != " + ptf.returnType.defaultVal + "{\n" + ptf.toProtoField().GenMarshalJSON() + "\n}" +func (ptf ProtoTypedField) GenMarshalJSON() string { + if ptf.MessageName == "TraceID" || ptf.MessageName == "SpanID" || ptf.MessageName == "ProfileID" { + return "if !orig." + ptf.Name + ".IsEmpty() {\n" + ptf.Field.GenMarshalJSON() + "\n}" } - return ptf.toProtoField().GenMarshalJSON() -} - -func (ptf *TypedField) GenerateUnmarshalJSON(*messageStruct) string { - return ptf.toProtoField().GenUnmarshalJSON() -} - -func (ptf *TypedField) GenerateSizeProto(*messageStruct) string { - return ptf.toProtoField().GenSizeProto() -} - -func (ptf *TypedField) GenerateMarshalProto(*messageStruct) string { - return ptf.toProtoField().GenMarshalProto() + return ptf.Field.GenMarshalJSON() } -func (ptf *TypedField) GenerateUnmarshalProto(*messageStruct) string { - return ptf.toProtoField().GenUnmarshalProto() +func (ptf *TypedField) toProtoField(ms *messageStruct) proto.FieldInterface { + return ProtoTypedField{&proto.Field{ + Type: ptf.returnType.protoType, + ID: ptf.protoID, + Name: ptf.getOriginFieldName(), + MessageName: ptf.returnType.messageName, + ParentMessageName: ms.protoName, + }} } -func (ptf *TypedField) toProtoField() *proto.Field { - return &proto.Field{ - Type: ptf.returnType.protoType, - ID: ptf.protoID, - Name: ptf.getOriginFieldName(), - MessageFullName: ptf.returnType.messageName, +func (ptf *TypedField) getOriginFieldName() string { + if ptf.originFieldName == "" { + return ptf.fieldName } + return ptf.originFieldName } func (ptf *TypedField) templateFields(ms *messageStruct) map[string]any { - pf := ptf.toProtoField() + pf := ptf.toProtoField(ms) + messageType := pf.GoType() + defaultVal := ptf.returnType.defaultVal + testVal := ptf.returnType.testVal + if ptf.returnType.protoType == proto.TypeMessage || ptf.returnType.protoType == proto.TypeEnum { + messageType = "internal." + messageType + defaultVal = "internal." + defaultVal + testVal = "internal." + testVal + } return map[string]any{ "structName": ms.getName(), - "defaultVal": ptf.returnType.defaultVal, + "defaultVal": defaultVal, "packageName": func() string { if ptf.returnType.packageName != ms.packageName { return ptf.returnType.packageName + "." @@ -134,18 +115,11 @@ func (ptf *TypedField) templateFields(ms *messageStruct) map[string]any { "hasWrapper": usedByOtherDataTypes(ptf.returnType.packageName), "returnType": ptf.returnType.structName, "fieldName": ptf.fieldName, - "lowerFieldName": strings.ToLower(ptf.fieldName), - "testValue": ptf.returnType.testVal, - "rawType": pf.GoType(), "originFieldName": ptf.getOriginFieldName(), + "lowerFieldName": strings.ToLower(ptf.fieldName), + "testValue": testVal, + "messageType": messageType, } } -func (ptf *TypedField) getOriginFieldName() string { - if ptf.originFieldName == "" { - return ptf.fieldName - } - return ptf.originFieldName -} - var _ Field = (*TypedField)(nil) diff --git a/internal/cmd/pdatagen/internal/pdata/xpdata_entity_package.go b/internal/cmd/pdatagen/internal/pdata/xpdata_entity_package.go index 437b2ff4b04..26ea79549e6 100644 --- a/internal/cmd/pdatagen/internal/pdata/xpdata_entity_package.go +++ b/internal/cmd/pdatagen/internal/pdata/xpdata_entity_package.go @@ -21,7 +21,6 @@ var xpdataEntity = &Package{ `"sort"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/internal/proto"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, @@ -33,7 +32,6 @@ var xpdataEntity = &Package{ `gootlpcommon "go.opentelemetry.io/proto/slim/otlp/common/v1"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1"`, `"go.opentelemetry.io/collector/pdata/internal/json"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, @@ -52,9 +50,10 @@ var entityRefSlice = &messageSlice{ } var entityRef = &messageStruct{ - structName: "EntityRef", - packageName: "entity", - originFullName: "otlpcommon.EntityRef", + structName: "EntityRef", + packageName: "entity", + protoName: "EntityRef", + upstreamProto: "gootlpcommon.EntityRef", fields: []Field{ &PrimitiveField{ fieldName: "SchemaUrl", diff --git a/internal/cmd/pdatagen/internal/proto/copy.go b/internal/cmd/pdatagen/internal/proto/copy.go new file mode 100644 index 00000000000..5afcb141702 --- /dev/null +++ b/internal/cmd/pdatagen/internal/proto/copy.go @@ -0,0 +1,50 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package proto // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" + +import ( + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" +) + +const copyOther = `{{ if .repeated -}} + dest.{{ .fieldName }} = append(dest.{{ .fieldName }}[:0], src.{{ .fieldName }}...) +{{- else if not .nullable -}} + dest.{{ .fieldName }} = src.{{ .fieldName }} +{{ else -}} + var ov *{{ .oneOfMessageName }} + if !UseProtoPooling.IsEnabled() { + ov = &{{ .oneOfMessageName }}{} + } else { + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) + } + ov.{{ .fieldName }} = t.{{ .fieldName }} + dest.{{ .oneOfGroup }} = ov +{{- end }}` + +const copyMessage = `{{ if .repeated -}} + dest.{{ .fieldName }} = Copy{{ .messageName }}{{ if .nullable }}Ptr{{ end }}Slice(dest.{{ .fieldName }}, src.{{ .fieldName }}) +{{- else if ne .oneOfGroup "" -}} + var ov *{{ .oneOfMessageName }} + if !UseProtoPooling.IsEnabled() { + ov = &{{ .oneOfMessageName }}{} + } else { + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) + } + ov.{{ .fieldName }} = New{{ .messageName }}() + Copy{{ .messageName }}(ov.{{ .fieldName }}, t.{{ .fieldName }}) + dest.{{ .oneOfGroup }} = ov +{{- else if .nullable -}} + dest.{{ .fieldName }} = Copy{{ .messageName }}(dest.{{ .fieldName }}, src.{{ .fieldName }}) +{{- else -}} + Copy{{ .messageName }}(&dest.{{ .fieldName }}, &src.{{ .fieldName }}) +{{- end }} +` + +func (pf *Field) GenCopy() string { + tf := pf.getTemplateFields() + if pf.Type == TypeMessage { + return template.Execute(template.Parse("copyMessage", []byte(copyMessage)), tf) + } + return template.Execute(template.Parse("copyOther", []byte(copyOther)), tf) +} diff --git a/internal/cmd/pdatagen/internal/proto/delete.go b/internal/cmd/pdatagen/internal/proto/delete.go index b85bc966a45..9ddc23d2c41 100644 --- a/internal/cmd/pdatagen/internal/proto/delete.go +++ b/internal/cmd/pdatagen/internal/proto/delete.go @@ -7,39 +7,39 @@ import ( "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" ) -const deleteOrigOther = `{{ if ne .oneOfGroup "" -}} +const deleteOther = `{{ if ne .oneOfGroup "" -}} if UseProtoPooling.IsEnabled() { ov.{{ .fieldName }} = {{ .defaultValue }} ProtoPool{{ .oneOfMessageName }}.Put(ov) } {{ end }}` -const deleteOrigMessage = `{{ if .repeated -}} +const deleteMessage = `{{ if .repeated -}} for i := range orig.{{ .fieldName }} { {{ if .nullable -}} - DeleteOrig{{ .origName }}(orig.{{ .fieldName }}[i], true) + Delete{{ .messageName }}(orig.{{ .fieldName }}[i], true) {{- else -}} - DeleteOrig{{ .origName }}(&orig.{{ .fieldName }}[i], false) + Delete{{ .messageName }}(&orig.{{ .fieldName }}[i], false) {{- end }} } {{- else if ne .oneOfGroup "" -}} - DeleteOrig{{ .origName }}(ov.{{ .fieldName }}, true) + Delete{{ .messageName }}(ov.{{ .fieldName }}, true) ov.{{ .fieldName }} = nil ProtoPool{{ .oneOfMessageName }}.Put(ov) {{- else if .nullable -}} - DeleteOrig{{ .origName }}(orig.{{ .fieldName }}, true) + Delete{{ .messageName }}(orig.{{ .fieldName }}, true) {{- else -}} - DeleteOrig{{ .origName }}(&orig.{{ .fieldName }}, false) + Delete{{ .messageName }}(&orig.{{ .fieldName }}, false) {{- end }} ` -func (pf *Field) GenDeleteOrig() string { +func (pf *Field) GenDelete() string { tf := pf.getTemplateFields() if pf.Type == TypeMessage { - return template.Execute(template.Parse("deleteOrigMessage", []byte(deleteOrigMessage)), tf) + return template.Execute(template.Parse("deleteMessage", []byte(deleteMessage)), tf) } if pf.OneOfGroup != "" { - return template.Execute(template.Parse("deleteOrigOther", []byte(deleteOrigOther)), tf) + return template.Execute(template.Parse("deleteOther", []byte(deleteOther)), tf) } return "" } diff --git a/internal/cmd/pdatagen/internal/proto/enum.go b/internal/cmd/pdatagen/internal/proto/enum.go new file mode 100644 index 00000000000..f347c11cf90 --- /dev/null +++ b/internal/cmd/pdatagen/internal/proto/enum.go @@ -0,0 +1,65 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package proto // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" + +import ( + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" +) + +const enumMessageTemplate = ` +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +const ( + {{- range .Fields }} + {{ $.Name }}_{{ .Name }} = {{ $.Name }}({{ .Value }}) + {{- end }} +) + +{{ .Description }} +type {{ .Name }} int32 + +var {{ .Name }}_name = map[int32]string { + {{- range .Fields }} + {{ .Value }}: "{{ .Name }}", + {{- end }} +} + +var {{ .Name }}_value = map[string]int32 { + {{- range .Fields }} + "{{ .Name }}": {{ .Value }}, + {{- end }} +} + +` + +type Enum struct { + Name string + Description string + Fields []*EnumField +} + +type EnumField struct { + Name string + Value int +} + +func (ms *Enum) GenerateEnum() []byte { + return []byte(template.Execute(template.Parse("enumMessageTemplate", []byte(enumMessageTemplate)), ms)) +} + +func (ms *Enum) templateFields(imports, testImports []string) map[string]any { + return map[string]any{ + "fields": ms.Fields, + "messageName": ms.Name, + "description": ms.Description, + "imports": imports, + "testImports": testImports, + } +} diff --git a/internal/cmd/pdatagen/internal/proto/field.go b/internal/cmd/pdatagen/internal/proto/field.go index e5051181648..1fe80faba40 100644 --- a/internal/cmd/pdatagen/internal/proto/field.go +++ b/internal/cmd/pdatagen/internal/proto/field.go @@ -8,17 +8,56 @@ import ( "strings" ) +// FieldInterface temporary interface until we generate the proto fields with pdatagen. +// TODO: Remove when no more wrappers needed. +type FieldInterface interface { + GenTestFailingUnmarshalProtoValues() string + + GenTestEncodingValues() string + + GenPool() string + + GenDelete() string + + GenCopy() string + + GenMarshalJSON() string + + GenUnmarshalJSON() string + + GenSizeProto() string + + GenMarshalProto() string + + GenUnmarshalProto() string + + GenMessageField() string + + GenOneOfMessages() string + + GoType() string + + DefaultValue() string + + TestValue() string + + GetName() string +} + type Field struct { - Type Type - Name string - OneOfGroup string - OneOfMessageFullName string - MessageFullName string - ID uint32 - Repeated bool - Nullable bool + Type Type + Name string + OneOfGroup string + OneOfMessageName string + MessageName string + ParentMessageName string + ID uint32 + Repeated bool + Nullable bool } +func (pf *Field) GetName() string { return pf.Name } + func (pf *Field) wireType() WireType { switch pf.Type { case TypeInt32, TypeInt64, TypeUint32, TypeUint64, TypeSInt32, TypeSInt64, TypeBool, TypeEnum: @@ -57,13 +96,23 @@ func (pf *Field) DefaultValue() string { case TypeString: return `""` case TypeMessage: - return pf.MessageFullName + `{}` + if pf.Nullable { + return `&` + pf.MessageName + `{}` + } + return pf.MessageName + `{}` default: panic("unsupported field type") } } func (pf *Field) TestValue() string { + if pf.Repeated { + return pf.MemberGoType() + "{" + pf.DefaultValue() + ", " + pf.rawTestValue() + "}" + } + return pf.rawTestValue() +} + +func (pf *Field) rawTestValue() string { switch pf.Type { case TypeInt32, TypeInt64, TypeUint32, TypeUint64, TypeSInt32, TypeSInt64, TypeEnum, TypeFixed32, TypeSFixed32, TypeFixed64, TypeSFixed64: return pf.GoType() + "(13)" @@ -76,7 +125,10 @@ func (pf *Field) TestValue() string { case TypeString: return `"test_` + strings.ToLower(pf.Name) + `"` case TypeMessage: - return `GenTestOrig` + pf.messageName() + `()` + if pf.Nullable { + return `GenTest` + pf.MessageName + `()` + } + return `*GenTest` + pf.MessageName + `()` default: panic("unsupported field type") } @@ -103,12 +155,29 @@ func (pf *Field) GoType() string { case TypeBytes: return "[]byte" case TypeMessage, TypeEnum: - return pf.MessageFullName + return pf.MessageName default: panic("unsupported field type") } } +func (pf *Field) MemberGoType() string { + ptrGoType := func() string { + if pf.Nullable { + return "*" + pf.GoType() + } + return pf.GoType() + } + if pf.Repeated { + return "[]" + ptrGoType() + } + return ptrGoType() +} + +func (pf *Field) GenMessageField() string { + return pf.Name + " " + pf.MemberGoType() +} + func (pf *Field) getTemplateFields() map[string]any { bitSize := 0 switch pf.Type { @@ -120,29 +189,24 @@ func (pf *Field) getTemplateFields() map[string]any { protoTag := genProtoTag(pf.ID, pf.wireType()) return map[string]any{ - "protoTagSize": len(protoTag), - "protoTag": protoTag, - "protoFieldID": pf.ID, - "jsonTag": genJSONTag(pf.Name), - "fieldName": pf.Name, - "origName": pf.messageName(), - "origFullName": pf.MessageFullName, - "oneOfGroup": pf.OneOfGroup, - "oneOfMessageName": ExtractNameFromFull(pf.OneOfMessageFullName), - "oneOfMessageFullName": pf.OneOfMessageFullName, - "repeated": pf.Repeated, - "nullable": pf.Nullable, - "bitSize": bitSize, - "goType": pf.GoType(), - "defaultValue": pf.DefaultValue(), - "testValue": pf.TestValue(), + "protoTagSize": len(protoTag), + "protoTag": protoTag, + "protoFieldID": pf.ID, + "jsonTag": genJSONTag(pf.Name), + "fieldName": pf.Name, + "messageName": pf.MessageName, + "parentMessageName": pf.ParentMessageName, + "oneOfGroup": pf.OneOfGroup, + "oneOfMessageName": pf.OneOfMessageName, + "repeated": pf.Repeated, + "nullable": pf.Nullable, + "bitSize": bitSize, + "goType": pf.GoType(), + "defaultValue": pf.DefaultValue(), + "testValue": pf.TestValue(), } } -func (pf *Field) messageName() string { - return ExtractNameFromFull(pf.MessageFullName) -} - func genJSONTag(fieldName string) string { // Extract last word because for Enums we use the full name. return lowerFirst(ExtractNameFromFull(fieldName)) diff --git a/internal/cmd/pdatagen/internal/proto/json_marshal.go b/internal/cmd/pdatagen/internal/proto/json_marshal.go index 8f9dd433026..d2ef34b0ff8 100644 --- a/internal/cmd/pdatagen/internal/proto/json_marshal.go +++ b/internal/cmd/pdatagen/internal/proto/json_marshal.go @@ -52,10 +52,10 @@ const marshalJSONMessage = `{{ if .repeated -}} if len(orig.{{ .fieldName }}) > 0 { dest.WriteObjectField("{{ .jsonTag }}") dest.WriteArrayStart() - MarshalJSONOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}[0], dest) + orig.{{ .fieldName }}[0].MarshalJSON(dest) for i := 1; i < len(orig.{{ .fieldName }}); i++ { dest.WriteMore() - MarshalJSONOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}[i], dest) + orig.{{ .fieldName }}[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -64,7 +64,7 @@ const marshalJSONMessage = `{{ if .repeated -}} if orig.{{ .fieldName }} != nil { {{ end -}} dest.WriteObjectField("{{ .jsonTag }}") - MarshalJSONOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}, dest) + orig.{{ .fieldName }}.MarshalJSON(dest) {{- if .nullable -}} } {{- end }}{{- end }}` diff --git a/internal/cmd/pdatagen/internal/proto/json_unmarshal.go b/internal/cmd/pdatagen/internal/proto/json_unmarshal.go index 2df317786e0..bdb288640f6 100644 --- a/internal/cmd/pdatagen/internal/proto/json_unmarshal.go +++ b/internal/cmd/pdatagen/internal/proto/json_unmarshal.go @@ -19,11 +19,11 @@ const unmarshalJSONPrimitive = ` case {{ .allJSONTags }}: } {{ else if .nullable -}} { - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = iter.Read{{ upperFirst .goType }}() orig.{{ .oneOfGroup }} = ov @@ -35,32 +35,33 @@ const unmarshalJSONPrimitive = ` case {{ .allJSONTags }}: const unmarshalJSONEnum = ` case {{ .allJSONTags }}: {{ if .repeated -}} for iter.ReadArray() { - orig.{{ .fieldName }} = append(orig.{{ .fieldName }}, {{ .origFullName }}(iter.ReadEnumValue({{ .origFullName }}_value))) + orig.{{ .fieldName }} = append(orig.{{ .fieldName }}, {{ .messageName }}(iter.ReadEnumValue({{ .messageName }}_value))) } {{ else -}} - orig.{{ .fieldName }} = {{ .origFullName }}(iter.ReadEnumValue({{ .origFullName }}_value)) + orig.{{ .fieldName }} = {{ .messageName }}(iter.ReadEnumValue({{ .messageName }}_value)) {{- end }}` const unmarshalJSONMessage = ` case {{ .allJSONTags }}: {{ if .repeated -}} for iter.ReadArray() { - orig.{{ .fieldName }} = append(orig.{{ .fieldName }}, {{ if .nullable }}NewOrig{{ .origName }}(){{ else }}{{ .defaultValue }}{{ end }}) - UnmarshalJSONOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}[len(orig.{{ .fieldName }}) - 1], iter) + orig.{{ .fieldName }} = append(orig.{{ .fieldName }}, {{ if .nullable }}New{{ .messageName }}(){{ else }}{{ .defaultValue }}{{ end }}) + orig.{{ .fieldName }}[len(orig.{{ .fieldName }}) - 1].UnmarshalJSON(iter) } {{ else if ne .oneOfGroup "" -}} { - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } - ov.{{ .fieldName }} = NewOrig{{ .origName }}() - UnmarshalJSONOrig{{ .origName }}(ov.{{ .fieldName }}, iter) + ov.{{ .fieldName }} = New{{ .messageName }}() + ov.{{ .fieldName }}.UnmarshalJSON(iter) orig.{{ .oneOfGroup }} = ov } {{ else -}} - UnmarshalJSONOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}, iter) + {{ if .nullable }}orig.{{ .fieldName }} = New{{ .messageName }}(){{ end }} + orig.{{ .fieldName }}.UnmarshalJSON(iter) {{- end }}` const unmarshalJSONBytes = ` case {{ .allJSONTags }}: @@ -70,11 +71,11 @@ const unmarshalJSONBytes = ` case {{ .allJSONTags }}: } {{ else if ne .oneOfGroup "" -}} { - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = iter.ReadBytes() orig.{{ .oneOfGroup }} = ov diff --git a/internal/cmd/pdatagen/internal/proto/message.go b/internal/cmd/pdatagen/internal/proto/message.go new file mode 100644 index 00000000000..f7f060f6955 --- /dev/null +++ b/internal/cmd/pdatagen/internal/proto/message.go @@ -0,0 +1,47 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package proto // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" + +import ( + _ "embed" + + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" +) + +var ( + //go:embed templates/message.go.tmpl + messageTemplateBytes []byte + messageTemplate = template.Parse("message_internal_test.go", messageTemplateBytes) + + //go:embed templates/message_test.go.tmpl + messageTestTemplateBytes []byte + messageTestTemplate = template.Parse("message_internal_test.go", messageTestTemplateBytes) +) + +type Message struct { + Name string + Description string + OriginFullName string + UpstreamMessage string + Fields []FieldInterface +} + +func (ms *Message) GenerateMessage(imports, testImports []string) []byte { + return []byte(template.Execute(messageTemplate, ms.templateFields(imports, testImports))) +} + +func (ms *Message) GenerateMessageTests(imports, testImports []string) []byte { + return []byte(template.Execute(messageTestTemplate, ms.templateFields(imports, testImports))) +} + +func (ms *Message) templateFields(imports, testImports []string) map[string]any { + return map[string]any{ + "fields": ms.Fields, + "messageName": ms.Name, + "upstreamMessage": ms.UpstreamMessage, + "description": ms.Description, + "imports": imports, + "testImports": testImports, + } +} diff --git a/internal/cmd/pdatagen/internal/proto/oneof_message.go b/internal/cmd/pdatagen/internal/proto/oneof_message.go new file mode 100644 index 00000000000..0b5213ed87d --- /dev/null +++ b/internal/cmd/pdatagen/internal/proto/oneof_message.go @@ -0,0 +1,45 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package proto // import "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/proto" + +import ( + "go.opentelemetry.io/collector/internal/cmd/pdatagen/internal/template" +) + +const oneOfMessageOrigOtherTemplate = ` +type {{ .oneOfMessageName }} struct { + {{ .fieldName }} {{ .goType }} +} + +func (m *{{ .parentMessageName }}) Get{{ .fieldName }}() {{ .goType }} { + if v, ok := m.Get{{ .oneOfGroup }}().(*{{ .oneOfMessageName }}); ok { + return v.{{ .fieldName }} + } + return {{ .defaultValue }} +} +` + +const oneOfMessageOrigMessageTemplate = ` +type {{ .oneOfMessageName }} struct { + {{ .fieldName }} *{{ .goType }} +} + +func (m *{{ .parentMessageName }}) Get{{ .fieldName }}() *{{ .goType }} { + if v, ok := m.Get{{ .oneOfGroup }}().(*{{ .oneOfMessageName }}); ok { + return v.{{ .fieldName }} + } + return nil +} +` + +func (pf *Field) GenOneOfMessages() string { + tf := pf.getTemplateFields() + if pf.OneOfGroup != "" { + if pf.Type == TypeMessage { + return template.Execute(template.Parse("oneOfMessageOrigMessageTemplate", []byte(oneOfMessageOrigMessageTemplate)), tf) + } + return template.Execute(template.Parse("oneOfMessageOrigOtherTemplate", []byte(oneOfMessageOrigOtherTemplate)), tf) + } + return "" +} diff --git a/internal/cmd/pdatagen/internal/proto/pools.go b/internal/cmd/pdatagen/internal/proto/pools.go index 89da7165b76..f028aa9d7fb 100644 --- a/internal/cmd/pdatagen/internal/proto/pools.go +++ b/internal/cmd/pdatagen/internal/proto/pools.go @@ -10,12 +10,12 @@ import ( const poolVarOrigTemplate = ` ProtoPool{{ .oneOfMessageName }} = sync.Pool{ New: func() any { - return &{{ .oneOfMessageFullName }}{} + return &{{ .oneOfMessageName }}{} }, } ` -func (pf *Field) GenPoolVarOrig() string { +func (pf *Field) GenPool() string { tf := pf.getTemplateFields() if pf.OneOfGroup != "" { return template.Execute(template.Parse("poolVarOrigTemplate", []byte(poolVarOrigTemplate)), tf) diff --git a/internal/cmd/pdatagen/internal/proto/proto_marshal.go b/internal/cmd/pdatagen/internal/proto/proto_marshal.go index 22e2e55d55e..62713bfc874 100644 --- a/internal/cmd/pdatagen/internal/proto/proto_marshal.go +++ b/internal/cmd/pdatagen/internal/proto/proto_marshal.go @@ -153,7 +153,7 @@ const marshalProtoBytesString = `{{ if .repeated -}} const marshalProtoMessage = `{{ if .repeated -}} for i := len(orig.{{ .fieldName }}) - 1; i >= 0; i-- { - l = MarshalProtoOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}[i], buf[:pos]) + l = orig.{{ .fieldName }}[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) {{ range .protoTag -}} @@ -161,8 +161,18 @@ const marshalProtoMessage = `{{ if .repeated -}} buf[pos] = {{ . }} {{ end -}} } -{{- else }} - l = MarshalProtoOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}, buf[:pos]) +{{- else if .nullable -}} + if orig.{{ .fieldName }} != nil { + l = orig.{{ .fieldName }}.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + {{ range .protoTag -}} + pos-- + buf[pos] = {{ . }} + {{ end -}} + } +{{- else -}} + l = orig.{{ .fieldName }}.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) {{ range .protoTag -}} diff --git a/internal/cmd/pdatagen/internal/proto/proto_size.go b/internal/cmd/pdatagen/internal/proto/proto_size.go index 615c5401d95..26cbb50ec3b 100644 --- a/internal/cmd/pdatagen/internal/proto/proto_size.go +++ b/internal/cmd/pdatagen/internal/proto/proto_size.go @@ -83,11 +83,16 @@ const sizeProtoBytesString = `{{ if .repeated -}} const sizeProtoMessage = `{{ if .repeated -}} for i := range orig.{{ .fieldName }} { - l = SizeProtoOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}[i]) + l = orig.{{ .fieldName }}[i].SizeProto() + n+= {{ .protoTagSize }} + proto.Sov(uint64(l)) + l + } +{{- else if .nullable -}} + if orig.{{ .fieldName }} != nil { + l = orig.{{ .fieldName }}.SizeProto() n+= {{ .protoTagSize }} + proto.Sov(uint64(l)) + l } {{- else -}} - l = SizeProtoOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}) + l = orig.{{ .fieldName }}.SizeProto() n+= {{ .protoTagSize }} + proto.Sov(uint64(l)) + l {{- end }}` diff --git a/internal/cmd/pdatagen/internal/proto/proto_unmarshal.go b/internal/cmd/pdatagen/internal/proto/proto_unmarshal.go index ed35d82f08d..9d9f68ed421 100644 --- a/internal/cmd/pdatagen/internal/proto/proto_unmarshal.go +++ b/internal/cmd/pdatagen/internal/proto/proto_unmarshal.go @@ -53,11 +53,11 @@ const unmarshalProtoFloat = `{{ if .repeated -}} return err } {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = math.Float{{ .bitSize }}frombits(num) orig.{{ .oneOfGroup }} = ov @@ -109,11 +109,11 @@ const unmarshalProtoFixed = `{{ if .repeated -}} return err } {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = {{ .goType }}(num) orig.{{ .oneOfGroup }} = ov @@ -165,11 +165,11 @@ const unmarshalProtoBool = `{{ if .repeated -}} return err } {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = num != 0 orig.{{ .oneOfGroup }} = ov @@ -219,11 +219,11 @@ const unmarshalProtoVarint = `{{ if .repeated -}} return err } {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = {{ .goType }}(num) orig.{{ .oneOfGroup }} = ov @@ -243,11 +243,11 @@ const unmarshalProtoString = ` } startPos := pos - length {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = string(buf[startPos:pos]) orig.{{ .oneOfGroup }} = ov @@ -269,11 +269,11 @@ const unmarshalProtoBytes = ` } startPos := pos - length {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } if length != 0 { ov.{{ .fieldName }} = make([]byte, length) @@ -306,27 +306,27 @@ const unmarshalProtoMessage = ` } startPos := pos - length {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } - ov.{{ .fieldName }} = NewOrig{{ .origName }}() - err = UnmarshalProtoOrig{{ .origName }}(ov.{{ .fieldName }}, buf[startPos:pos]) + ov.{{ .fieldName }} = New{{ .messageName }}() + err = ov.{{ .fieldName }}.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } orig.{{ .oneOfGroup }} = ov {{- else if .repeated -}} - orig.{{ .fieldName }} = append(orig.{{ .fieldName }}, {{ if .nullable }}NewOrig{{ .origName }}(){{ else }}{{ .defaultValue }}{{ end }}) - err = UnmarshalProtoOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}[len(orig.{{ .fieldName }})-1], buf[startPos:pos]) + orig.{{ .fieldName }} = append(orig.{{ .fieldName }}, {{ if .nullable }}New{{ .messageName }}(){{ else }}{{ .defaultValue }}{{ end }}) + err = orig.{{ .fieldName }}[len(orig.{{ .fieldName }})-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } {{- else }} - {{ if .nullable }}orig.{{ .fieldName }} = NewOrig{{ .origName }}(){{ end }} - err = UnmarshalProtoOrig{{ .origName }}({{ if not .nullable }}&{{ end }}orig.{{ .fieldName }}, buf[startPos:pos]) + {{ if .nullable }}orig.{{ .fieldName }} = New{{ .messageName }}(){{ end }} + err = orig.{{ .fieldName }}.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -377,11 +377,11 @@ const unmarshalProtoSignedVarint = `{{ if .repeated -}} return err } {{ if ne .oneOfGroup "" -}} - var ov *{{ .oneOfMessageFullName }} + var ov *{{ .oneOfMessageName }} if !UseProtoPooling.IsEnabled() { - ov = &{{ .oneOfMessageFullName }}{} + ov = &{{ .oneOfMessageName }}{} } else { - ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageFullName }}) + ov = ProtoPool{{ .oneOfMessageName }}.Get().(*{{ .oneOfMessageName }}) } ov.{{ .fieldName }} = int{{ .bitSize }}(uint{{ .bitSize }}(num >> 1) ^ uint{{ .bitSize }}(int{{ .bitSize }}((num&1)<<{{ sub .bitSize 1 }})>>{{ sub .bitSize 1 }})) orig.{{ .oneOfGroup }} = ov diff --git a/internal/cmd/pdatagen/internal/proto/templates/message.go.tmpl b/internal/cmd/pdatagen/internal/proto/templates/message.go.tmpl new file mode 100644 index 00000000000..2c722a6a8c8 --- /dev/null +++ b/internal/cmd/pdatagen/internal/proto/templates/message.go.tmpl @@ -0,0 +1,225 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + {{ range $index, $element := .imports -}} + {{ $element }} + {{ end }} +) + +{{- range .fields }} +{{ .GenOneOfMessages }} +{{- end }} + +{{ .description }} +type {{ .messageName }} struct { +{{- range .fields }} + {{ .GenMessageField }} +{{- end }}} + +var ( + protoPool{{ .messageName }} = sync.Pool{ + New: func() any { + return &{{ .messageName }}{} + }, + } + {{- range .fields }}{{ .GenPool }}{{- end }} +) + + +func New{{ .messageName }}() *{{ .messageName }} { + if !UseProtoPooling.IsEnabled() { + return &{{ .messageName }}{} + } + return protoPool{{ .messageName }}.Get().(*{{ .messageName }}) +} + +func Delete{{ .messageName }}(orig *{{ .messageName }}, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + {{ range .fields }}{{ .GenDelete }}{{ end }} + orig.Reset() + if nullable { + protoPool{{ .messageName }}.Put(orig) + } +} + +func Copy{{ .messageName }}(dest, src *{{ .messageName }}) *{{ .messageName }}{ + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil; + } + + if dest == nil { + dest = New{{ .messageName }}(); + } + + {{- range .fields }} + {{ .GenCopy }} + {{- end }} + + return dest +} + +func Copy{{ .messageName }}Slice(dest, src []{{ .messageName }}) []{{ .messageName }} { + var newDest []{{ .messageName }} + if cap(dest) < len(src) { + newDest = make([]{{ .messageName }}, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + Delete{{ .messageName }}(&dest[i], false) + } + } + for i := range src { + Copy{{ .messageName }}(&newDest[i], &src[i]) + } + return newDest +} + +func Copy{{ .messageName }}PtrSlice(dest, src []*{{ .messageName }}) []*{{ .messageName }} { + var newDest []*{{ .messageName }} + if cap(dest) < len(src) { + newDest = make([]*{{ .messageName }}, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = New{{ .messageName }}() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + Delete{{ .messageName }}(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = New{{ .messageName }}() + } + } + for i := range src { + Copy{{ .messageName }}(newDest[i], src[i]) + } + return newDest +} + + +func (orig *{{ .messageName }}) Reset() { + *orig = {{ .messageName }}{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *{{ .messageName }}) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + {{ range .fields -}} + {{ .GenMarshalJSON }} + {{ end -}} + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *{{ .messageName }}) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + {{ range .fields -}} + {{ .GenUnmarshalJSON }} + {{ end -}} + default: + iter.Skip() + } + } +} + +func (orig *{{ .messageName }}) SizeProto() int { + var n int + var l int + _ = l + {{ range .fields -}} + {{ .GenSizeProto }} + {{ end -}} + return n +} + +func (orig *{{ .messageName }}) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + {{ range .fields -}} + {{ .GenMarshalProto }} + {{ end -}} + return len(buf) - pos +} + +func (orig *{{ .messageName }}) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + {{ range .fields -}} + {{ .GenUnmarshalProto }} + {{ end -}} + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTest{{ .messageName }}() *{{ .messageName }} { + orig := New{{ .messageName }}() + {{- range .fields }} + orig.{{ .GetName }} = {{ .TestValue }} + {{- end }} + return orig +} + +func GenTest{{ .messageName }}PtrSlice() []*{{ .messageName }} { + orig := make([]*{{ .messageName }}, 5) + orig[0] = New{{ .messageName }}() + orig[1] = GenTest{{ .messageName }}() + orig[2] = New{{ .messageName }}() + orig[3] = GenTest{{ .messageName }}() + orig[4] = New{{ .messageName }}() + return orig +} + +func GenTest{{ .messageName }}Slice() []{{ .messageName }} { + orig := make([]{{ .messageName }}, 5) + orig[1] = *GenTest{{ .messageName }}() + orig[3] = *GenTest{{ .messageName }}() + return orig +} \ No newline at end of file diff --git a/internal/cmd/pdatagen/internal/proto/templates/message_test.go.tmpl b/internal/cmd/pdatagen/internal/proto/templates/message_test.go.tmpl new file mode 100644 index 00000000000..36ae9ae3a37 --- /dev/null +++ b/internal/cmd/pdatagen/internal/proto/templates/message_test.go.tmpl @@ -0,0 +1,194 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + {{ range $index, $element := .testImports -}} + {{ $element }} + {{ end }} +) + +func TestCopy{{ .messageName }}(t *testing.T) { + for name, src := range genTestEncodingValues{{ .messageName }}() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := New{{ .messageName }}() + Copy{{ .messageName }}(dest, src) + assert.Equal(t, src, dest) + Copy{{ .messageName }}(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopy{{ .messageName }}Slice(t *testing.T) { + src := []{{ .messageName }}{} + dest := []{{ .messageName }}{} + // Test CopyTo empty + dest = Copy{{ .messageName }}Slice(dest, src) + assert.Equal(t, []{{ .messageName }}{}, dest) + + // Test CopyTo larger slice + src = GenTest{{ .messageName }}Slice() + dest = Copy{{ .messageName }}Slice(dest, src) + assert.Equal(t, GenTest{{ .messageName }}Slice(), dest) + + // Test CopyTo same size slice + dest = Copy{{ .messageName }}Slice(dest, src) + assert.Equal(t, GenTest{{ .messageName }}Slice(), dest) + + // Test CopyTo smaller size slice + dest = Copy{{ .messageName }}Slice(dest, []{{ .messageName }}{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = Copy{{ .messageName }}Slice(dest, src) + assert.Equal(t, GenTest{{ .messageName }}Slice(), dest) +} + +func TestCopy{{ .messageName }}PtrSlice(t *testing.T) { + src := []*{{ .messageName }}{} + dest := []*{{ .messageName }}{} + // Test CopyTo empty + dest = Copy{{ .messageName }}PtrSlice(dest, src) + assert.Equal(t, []*{{ .messageName }}{}, dest) + + // Test CopyTo larger slice + src = GenTest{{ .messageName }}PtrSlice() + dest = Copy{{ .messageName }}PtrSlice(dest, src) + assert.Equal(t, GenTest{{ .messageName }}PtrSlice(), dest) + + // Test CopyTo same size slice + dest = Copy{{ .messageName }}PtrSlice(dest, src) + assert.Equal(t, GenTest{{ .messageName }}PtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = Copy{{ .messageName }}PtrSlice(dest, []*{{ .messageName }}{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = Copy{{ .messageName }}PtrSlice(dest, src) + assert.Equal(t, GenTest{{ .messageName }}PtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSON{{ .messageName }}Unknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := New{{ .messageName }}() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, New{{ .messageName }}(), dest) +} + +func TestMarshalAndUnmarshalJSON{{ .messageName }}(t *testing.T) { + for name, src := range genTestEncodingValues{{ .messageName }}() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := New{{ .messageName }}() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + Delete{{ .messageName }}(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProto{{ .messageName }}Failing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValues{{ .messageName }}() { + t.Run(name, func(t *testing.T) { + dest := New{{ .messageName }}() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProto{{ .messageName }}Unknown(t *testing.T) { + dest := New{{ .messageName }}() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, New{{ .messageName }}(), dest) +} + +func TestMarshalAndUnmarshalProto{{ .messageName }}(t *testing.T) { + for name, src := range genTestEncodingValues{{ .messageName }}(){ + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := New{{ .messageName }}() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + Delete{{ .messageName }}(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobuf{{ .messageName }}(t *testing.T) { + for name, src := range genTestEncodingValues{{ .messageName }}(){ + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &{{ .upstreamMessage }}{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := New{{ .messageName }}() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValues{{ .messageName }}() map[string][]byte { + return map[string][]byte{ + "invalid_field": { 0x02 }, + {{- range .fields }}{{ .GenTestFailingUnmarshalProtoValues }}{{- end }} + } +} + +func genTestEncodingValues{{ .messageName }}() map[string]*{{ .messageName }} { + return map[string]*{{ .messageName }}{ + "empty": New{{ .messageName }}(), + {{- range .fields }}{{ .GenTestEncodingValues }}{{- end }} + } +} diff --git a/internal/cmd/pdatagen/internal/proto/test_encoding_values.go b/internal/cmd/pdatagen/internal/proto/test_encoding_values.go index d4e760560ee..40071693160 100644 --- a/internal/cmd/pdatagen/internal/proto/test_encoding_values.go +++ b/internal/cmd/pdatagen/internal/proto/test_encoding_values.go @@ -11,21 +11,17 @@ import ( ) const encodingTestValuesScalar = `{{ if ne .oneOfGroup "" -}} -"{{ .fieldName }}/default": { {{ .oneOfGroup }}: &{{ .oneOfMessageFullName }}{{ "{" }}{{ .fieldName }}: {{ .defaultValue }}} }, -"{{ .fieldName }}/test": { {{ .oneOfGroup }}: &{{ .oneOfMessageFullName }}{{ "{" }}{{ .fieldName }}: {{ .testValue }}} }, -{{- else if .repeated }} -"{{ .fieldName }}/default_and_test": { {{ .fieldName }}: []{{ if .nullable }}*{{ end }}{{ .goType }}{ {{ .defaultValue }}, {{ .testValue }} } }, +"{{ .fieldName }}/default": { {{ .oneOfGroup }}: &{{ .oneOfMessageName }}{{ "{" }}{{ .fieldName }}: {{ .defaultValue }}} }, +"{{ .fieldName }}/test": { {{ .oneOfGroup }}: &{{ .oneOfMessageName }}{{ "{" }}{{ .fieldName }}: {{ .testValue }}} }, {{- else }} "{{ .fieldName }}/test": { {{ .fieldName }}: {{ .testValue }} }, {{- end }}` const encodingTestValuesMessage = `{{ if ne .oneOfGroup "" -}} -"{{ .fieldName }}/default": { {{ .oneOfGroup }}: &{{ .oneOfMessageFullName }}{{ "{" }}{{ .fieldName }}: {{ if .nullable }}&{{ end }}{{ .defaultValue }}} }, -"{{ .fieldName }}/test": { {{ .oneOfGroup }}: &{{ .oneOfMessageFullName }}{{ "{" }}{{ .fieldName }}: {{ .testValue }}} }, -{{- else if .repeated }} -"{{ .fieldName }}/default_and_test": { {{ .fieldName }}: []{{ if .nullable }}*{{ end }}{{ .goType }}{ {{ if .nullable }}&{{ end }}{{ .defaultValue }}, {{ if not .nullable }}*{{ end }}{{ .testValue }} } }, +"{{ .fieldName }}/default": { {{ .oneOfGroup }}: &{{ .oneOfMessageName }}{{ "{" }}{{ .fieldName }}: {{ .defaultValue }}} }, +"{{ .fieldName }}/test": { {{ .oneOfGroup }}: &{{ .oneOfMessageName }}{{ "{" }}{{ .fieldName }}: {{ .testValue }}} }, {{- else }} -"{{ .fieldName }}/test": { {{ .fieldName }}: {{ if not .nullable }}*{{ end }}{{ .testValue }} }, +"{{ .fieldName }}/test": { {{ .fieldName }}: {{ .testValue }} }, {{- end }}` func (pf *Field) GenTestEncodingValues() string { diff --git a/internal/cmd/pdatagen/main.go b/internal/cmd/pdatagen/main.go index 5285ce4c987..93bf92c2ce4 100644 --- a/internal/cmd/pdatagen/main.go +++ b/internal/cmd/pdatagen/main.go @@ -29,6 +29,8 @@ func main() { checkErr(fp.GenerateFiles()) checkErr(fp.GenerateTestFiles()) checkErr(fp.GenerateInternalFiles()) - checkErr(fp.GenerateInternalTestsFiles()) + checkErr(fp.GenerateProtoMessageFiles()) + checkErr(fp.GenerateProtoMessageTestsFiles()) + checkErr(fp.GenerateProtoEnumFiles()) } } diff --git a/internal/fanoutconsumer/go.mod b/internal/fanoutconsumer/go.mod index 1388d9add1b..e31f2d4d850 100644 --- a/internal/fanoutconsumer/go.mod +++ b/internal/fanoutconsumer/go.mod @@ -16,19 +16,12 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/internal/fanoutconsumer/go.sum b/internal/fanoutconsumer/go.sum index 37229a7ff62..8bbbde46ac2 100644 --- a/internal/fanoutconsumer/go.sum +++ b/internal/fanoutconsumer/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,20 +24,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -62,43 +34,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/memorylimiter/go.mod b/internal/memorylimiter/go.mod index 3e6baab3147..cd10164a65a 100644 --- a/internal/memorylimiter/go.mod +++ b/internal/memorylimiter/go.mod @@ -17,7 +17,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/knadh/koanf/maps v0.1.2 // indirect @@ -37,16 +36,10 @@ require ( go.opentelemetry.io/collector/pdata v1.44.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/internal/memorylimiter/go.sum b/internal/memorylimiter/go.sum index 110e9c1befb..31e01096edc 100644 --- a/internal/memorylimiter/go.sum +++ b/internal/memorylimiter/go.sum @@ -13,22 +13,14 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -67,8 +59,6 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= @@ -77,10 +67,6 @@ go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -97,45 +83,11 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/sharedcomponent/go.mod b/internal/sharedcomponent/go.mod index 40151bc0ae3..bea76d1fe0f 100644 --- a/internal/sharedcomponent/go.mod +++ b/internal/sharedcomponent/go.mod @@ -14,7 +14,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -32,12 +31,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/internal/sharedcomponent/go.sum b/internal/sharedcomponent/go.sum index 1839d792534..f34047270f4 100644 --- a/internal/sharedcomponent/go.sum +++ b/internal/sharedcomponent/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/telemetry/go.mod b/internal/telemetry/go.mod index 2f8a78b1947..cd9e5a92467 100644 --- a/internal/telemetry/go.mod +++ b/internal/telemetry/go.mod @@ -14,7 +14,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -22,12 +21,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/collector/pdata v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/internal/telemetry/go.sum b/internal/telemetry/go.sum index 1fb66343e32..8953e68cd37 100644 --- a/internal/telemetry/go.sum +++ b/internal/telemetry/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/otelcol/go.mod b/otelcol/go.mod index b5a6dd7171c..7f6e573cff9 100644 --- a/otelcol/go.mod +++ b/otelcol/go.mod @@ -48,7 +48,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect diff --git a/otelcol/go.sum b/otelcol/go.sum index d7ea7762c1f..af08af16ee4 100644 --- a/otelcol/go.sum +++ b/otelcol/go.sum @@ -51,8 +51,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -116,8 +114,6 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= @@ -190,43 +186,19 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY= diff --git a/otelcol/otelcoltest/go.mod b/otelcol/otelcoltest/go.mod index 4d9bb159fff..3fa6a9c11b4 100644 --- a/otelcol/otelcoltest/go.mod +++ b/otelcol/otelcoltest/go.mod @@ -33,7 +33,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect diff --git a/otelcol/otelcoltest/go.sum b/otelcol/otelcoltest/go.sum index d7ea7762c1f..af08af16ee4 100644 --- a/otelcol/otelcoltest/go.sum +++ b/otelcol/otelcoltest/go.sum @@ -51,8 +51,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -116,8 +114,6 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= @@ -190,43 +186,19 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY= diff --git a/pdata/go.mod b/pdata/go.mod index 4b6c658f71f..50ea322319f 100644 --- a/pdata/go.mod +++ b/pdata/go.mod @@ -3,7 +3,6 @@ module go.opentelemetry.io/collector/pdata go 1.24.0 require ( - github.com/gogo/protobuf v1.3.2 github.com/json-iterator/go v1.1.12 github.com/stretchr/testify v1.11.1 go.opentelemetry.io/collector/featuregate v1.44.0 diff --git a/pdata/go.sum b/pdata/go.sum index c1cbc037422..99a90d158d1 100644 --- a/pdata/go.sum +++ b/pdata/go.sum @@ -6,8 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -19,8 +17,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +35,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= @@ -63,37 +57,12 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/pdata/internal/data/bytesid.go b/pdata/internal/bytesid.go similarity index 89% rename from pdata/internal/data/bytesid.go rename to pdata/internal/bytesid.go index 239adaf6c0e..dbf368d3d11 100644 --- a/pdata/internal/data/bytesid.go +++ b/pdata/internal/bytesid.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package data // import "go.opentelemetry.io/collector/pdata/internal/data" +package internal // import "go.opentelemetry.io/collector/pdata/internal" import ( "encoding/hex" diff --git a/pdata/internal/data/bytesid_test.go b/pdata/internal/bytesid_test.go similarity index 98% rename from pdata/internal/data/bytesid_test.go rename to pdata/internal/bytesid_test.go index e5371683f60..03307641170 100644 --- a/pdata/internal/data/bytesid_test.go +++ b/pdata/internal/bytesid_test.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package data +package internal import ( "testing" diff --git a/pdata/internal/data/package_test.go b/pdata/internal/data/package_test.go deleted file mode 100644 index 72cf48754c0..00000000000 --- a/pdata/internal/data/package_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package data - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} diff --git a/pdata/internal/data/profileid.go b/pdata/internal/data/profileid.go deleted file mode 100644 index 72b5f5752e6..00000000000 --- a/pdata/internal/data/profileid.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package data // import "go.opentelemetry.io/collector/pdata/internal/data" - -import ( - "encoding/hex" - "errors" - - "github.com/gogo/protobuf/proto" - - "go.opentelemetry.io/collector/pdata/internal/json" -) - -const profileIDSize = 16 - -var ( - errMarshalProfileID = errors.New("marshal: invalid buffer length for ProfileID") - errUnmarshalProfileID = errors.New("unmarshal: invalid ProfileID length") -) - -// ProfileID is a custom data type that is used for all profile_id fields in OTLP -// Protobuf messages. -type ProfileID [profileIDSize]byte - -var _ proto.Sizer = (*ProfileID)(nil) - -// Size returns the size of the data to serialize. -func (tid ProfileID) Size() int { - if tid.IsEmpty() { - return 0 - } - return profileIDSize -} - -// IsEmpty returns true if id contains at leas one non-zero byte. -func (tid ProfileID) IsEmpty() bool { - return tid == [profileIDSize]byte{} -} - -// MarshalTo converts profile ID into a binary representation. Called by Protobuf serialization. -func (tid ProfileID) MarshalTo(data []byte) (n int, err error) { - if tid.IsEmpty() { - return 0, nil - } - - if len(data) < profileIDSize { - return 0, errMarshalProfileID - } - - return copy(data, tid[:]), nil -} - -// Unmarshal inflates this profile ID from binary representation. Called by Protobuf serialization. -func (tid *ProfileID) Unmarshal(data []byte) error { - if len(data) == 0 { - *tid = [profileIDSize]byte{} - return nil - } - - if len(data) != profileIDSize { - return errUnmarshalProfileID - } - - copy(tid[:], data) - return nil -} - -// MarshalJSONStream converts ProfileID into a hex string. -func (tid ProfileID) MarshalJSONStream(dest *json.Stream) { - dest.WriteString(hex.EncodeToString(tid[:])) -} - -// UnmarshalJSONIter decodes ProfileID from hex string. -func (tid *ProfileID) UnmarshalJSONIter(iter *json.Iterator) { - *tid = [profileIDSize]byte{} - unmarshalJSON(tid[:], iter) -} diff --git a/pdata/internal/data/profileid_test.go b/pdata/internal/data/profileid_test.go deleted file mode 100644 index e1e27c2dbe6..00000000000 --- a/pdata/internal/data/profileid_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package data - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestProfileID(t *testing.T) { - tid := ProfileID([16]byte{}) - assert.EqualValues(t, [16]byte{}, tid) - assert.Equal(t, 0, tid.Size()) - - b := [16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} - tid = b - assert.EqualValues(t, b, tid) - assert.Equal(t, 16, tid.Size()) -} - -func TestProfileIDMarshal(t *testing.T) { - buf := make([]byte, 20) - - tid := ProfileID([16]byte{}) - n, err := tid.MarshalTo(buf) - assert.Equal(t, 0, n) - require.NoError(t, err) - - tid = [16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} - n, err = tid.MarshalTo(buf) - assert.Equal(t, 16, n) - assert.Equal(t, []byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}, buf[0:16]) - require.NoError(t, err) - - _, err = tid.MarshalTo(buf[0:1]) - assert.Error(t, err) -} - -func TestProfileIDUnmarshal(t *testing.T) { - buf := [16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} - - tid := ProfileID{} - err := tid.Unmarshal(buf[0:16]) - require.NoError(t, err) - assert.EqualValues(t, buf, tid) - - err = tid.Unmarshal(buf[0:0]) - require.NoError(t, err) - assert.EqualValues(t, [16]byte{}, tid) - - err = tid.Unmarshal(nil) - require.NoError(t, err) - assert.EqualValues(t, [16]byte{}, tid) -} - -func TestProfileIDMarshalAndUnmarshalJSON(t *testing.T) { - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - src := ProfileID([16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}) - src.MarshalJSONStream(stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := ProfileID{} - dest.UnmarshalJSONIter(iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/data/protogen/collector/logs/v1/logs_service.pb.go b/pdata/internal/data/protogen/collector/logs/v1/logs_service.pb.go deleted file mode 100644 index 53b69b07267..00000000000 --- a/pdata/internal/data/protogen/collector/logs/v1/logs_service.pb.go +++ /dev/null @@ -1,840 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/collector/logs/v1/logs_service.proto - -package v1 - -import ( - context "context" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type ExportLogsServiceRequest struct { - // An array of ResourceLogs. - // For data coming from a single resource this array will typically contain one - // element. Intermediary nodes (such as OpenTelemetry Collector) that receive - // data from multiple origins typically batch the data before forwarding further and - // in that case this array will contain multiple elements. - ResourceLogs []*v1.ResourceLogs `protobuf:"bytes,1,rep,name=resource_logs,json=resourceLogs,proto3" json:"resource_logs,omitempty"` -} - -func (m *ExportLogsServiceRequest) Reset() { *m = ExportLogsServiceRequest{} } -func (m *ExportLogsServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ExportLogsServiceRequest) ProtoMessage() {} -func (*ExportLogsServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8e3bf87aaa43acd4, []int{0} -} -func (m *ExportLogsServiceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportLogsServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportLogsServiceRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportLogsServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportLogsServiceRequest.Merge(m, src) -} -func (m *ExportLogsServiceRequest) XXX_Size() int { - return m.Size() -} -func (m *ExportLogsServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ExportLogsServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportLogsServiceRequest proto.InternalMessageInfo - -func (m *ExportLogsServiceRequest) GetResourceLogs() []*v1.ResourceLogs { - if m != nil { - return m.ResourceLogs - } - return nil -} - -type ExportLogsServiceResponse struct { - // The details of a partially successful export request. - // - // If the request is only partially accepted - // (i.e. when the server accepts only parts of the data and rejects the rest) - // the server MUST initialize the `partial_success` field and MUST - // set the `rejected_` with the number of items it rejected. - // - // Servers MAY also make use of the `partial_success` field to convey - // warnings/suggestions to senders even when the request was fully accepted. - // In such cases, the `rejected_` MUST have a value of `0` and - // the `error_message` MUST be non-empty. - // - // A `partial_success` message with an empty value (rejected_ = 0 and - // `error_message` = "") is equivalent to it not being set/present. Senders - // SHOULD interpret it the same way as in the full success case. - PartialSuccess ExportLogsPartialSuccess `protobuf:"bytes,1,opt,name=partial_success,json=partialSuccess,proto3" json:"partial_success"` -} - -func (m *ExportLogsServiceResponse) Reset() { *m = ExportLogsServiceResponse{} } -func (m *ExportLogsServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ExportLogsServiceResponse) ProtoMessage() {} -func (*ExportLogsServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8e3bf87aaa43acd4, []int{1} -} -func (m *ExportLogsServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportLogsServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportLogsServiceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportLogsServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportLogsServiceResponse.Merge(m, src) -} -func (m *ExportLogsServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *ExportLogsServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ExportLogsServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportLogsServiceResponse proto.InternalMessageInfo - -func (m *ExportLogsServiceResponse) GetPartialSuccess() ExportLogsPartialSuccess { - if m != nil { - return m.PartialSuccess - } - return ExportLogsPartialSuccess{} -} - -type ExportLogsPartialSuccess struct { - // The number of rejected log records. - // - // A `rejected_` field holding a `0` value indicates that the - // request was fully accepted. - RejectedLogRecords int64 `protobuf:"varint,1,opt,name=rejected_log_records,json=rejectedLogRecords,proto3" json:"rejected_log_records,omitempty"` - // A developer-facing human-readable message in English. It should be used - // either to explain why the server rejected parts of the data during a partial - // success or to convey warnings/suggestions during a full success. The message - // should offer guidance on how users can address such issues. - // - // error_message is an optional field. An error_message with an empty value - // is equivalent to it not being set. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` -} - -func (m *ExportLogsPartialSuccess) Reset() { *m = ExportLogsPartialSuccess{} } -func (m *ExportLogsPartialSuccess) String() string { return proto.CompactTextString(m) } -func (*ExportLogsPartialSuccess) ProtoMessage() {} -func (*ExportLogsPartialSuccess) Descriptor() ([]byte, []int) { - return fileDescriptor_8e3bf87aaa43acd4, []int{2} -} -func (m *ExportLogsPartialSuccess) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportLogsPartialSuccess) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportLogsPartialSuccess.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportLogsPartialSuccess) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportLogsPartialSuccess.Merge(m, src) -} -func (m *ExportLogsPartialSuccess) XXX_Size() int { - return m.Size() -} -func (m *ExportLogsPartialSuccess) XXX_DiscardUnknown() { - xxx_messageInfo_ExportLogsPartialSuccess.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportLogsPartialSuccess proto.InternalMessageInfo - -func (m *ExportLogsPartialSuccess) GetRejectedLogRecords() int64 { - if m != nil { - return m.RejectedLogRecords - } - return 0 -} - -func (m *ExportLogsPartialSuccess) GetErrorMessage() string { - if m != nil { - return m.ErrorMessage - } - return "" -} - -func init() { - proto.RegisterType((*ExportLogsServiceRequest)(nil), "opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest") - proto.RegisterType((*ExportLogsServiceResponse)(nil), "opentelemetry.proto.collector.logs.v1.ExportLogsServiceResponse") - proto.RegisterType((*ExportLogsPartialSuccess)(nil), "opentelemetry.proto.collector.logs.v1.ExportLogsPartialSuccess") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/collector/logs/v1/logs_service.proto", fileDescriptor_8e3bf87aaa43acd4) -} - -var fileDescriptor_8e3bf87aaa43acd4 = []byte{ - // 430 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xc1, 0x6e, 0x13, 0x31, - 0x10, 0x86, 0xd7, 0x2d, 0xaa, 0x84, 0xd3, 0x02, 0xb2, 0x7a, 0x08, 0x39, 0x2c, 0x55, 0x50, 0x51, - 0xb8, 0x78, 0x49, 0xb8, 0x70, 0x03, 0x05, 0x71, 0x0b, 0x10, 0x6d, 0x11, 0x07, 0x2e, 0xab, 0xc5, - 0x19, 0x59, 0x5b, 0x6d, 0x77, 0xdc, 0xb1, 0x13, 0xc1, 0x33, 0x20, 0x24, 0x5e, 0x80, 0x17, 0xe0, - 0x49, 0x7a, 0xe0, 0xd0, 0x23, 0x27, 0x84, 0x92, 0x17, 0x41, 0x5e, 0x97, 0xb0, 0x0b, 0x39, 0x04, - 0x4e, 0xbb, 0x1e, 0xcf, 0xff, 0xfd, 0xff, 0xd8, 0x32, 0x7f, 0x84, 0x06, 0x2a, 0x07, 0x25, 0x9c, - 0x81, 0xa3, 0xf7, 0x89, 0x21, 0x74, 0x98, 0x28, 0x2c, 0x4b, 0x50, 0x0e, 0x29, 0x29, 0x51, 0xdb, - 0x64, 0x31, 0xac, 0xbf, 0x99, 0x05, 0x5a, 0x14, 0x0a, 0x64, 0xdd, 0x24, 0x8e, 0x5b, 0xca, 0x50, - 0x94, 0x6b, 0xa5, 0xf4, 0x0a, 0xb9, 0x18, 0xf6, 0x0e, 0x35, 0x6a, 0x0c, 0x58, 0xff, 0x17, 0xfa, - 0x7a, 0xf7, 0x36, 0xd9, 0x36, 0xcd, 0x42, 0x5f, 0xff, 0x94, 0x77, 0x9f, 0xbd, 0x33, 0x48, 0x6e, - 0x82, 0xda, 0x9e, 0x04, 0xff, 0x14, 0xce, 0xe7, 0x60, 0x9d, 0x78, 0xc1, 0x0f, 0x08, 0x2c, 0xce, - 0x49, 0x41, 0xe6, 0x25, 0x5d, 0x76, 0xb4, 0x3b, 0xe8, 0x8c, 0xee, 0xcb, 0x4d, 0xc1, 0xae, 0xe2, - 0xc8, 0xf4, 0x4a, 0xe1, 0x79, 0xe9, 0x3e, 0x35, 0x56, 0xfd, 0x0f, 0x8c, 0xdf, 0xde, 0x60, 0x66, - 0x0d, 0x56, 0x16, 0x44, 0xc5, 0x6f, 0x9a, 0x9c, 0x5c, 0x91, 0x97, 0x99, 0x9d, 0x2b, 0x05, 0xd6, - 0xfb, 0xb1, 0x41, 0x67, 0xf4, 0x58, 0x6e, 0x75, 0x10, 0xf2, 0x37, 0x7a, 0x1a, 0x38, 0x27, 0x01, - 0x33, 0xbe, 0x76, 0xf1, 0xfd, 0x4e, 0x94, 0xde, 0x30, 0xad, 0x6a, 0xff, 0xbc, 0x39, 0x79, 0x5b, - 0x21, 0x1e, 0xf0, 0x43, 0x82, 0x53, 0x50, 0x0e, 0x66, 0x7e, 0xf2, 0x8c, 0x40, 0x21, 0xcd, 0x42, - 0xa0, 0xdd, 0x54, 0xfc, 0xda, 0x9b, 0xa0, 0x4e, 0xc3, 0x8e, 0xb8, 0xcb, 0x0f, 0x80, 0x08, 0x29, - 0x3b, 0x03, 0x6b, 0x73, 0x0d, 0xdd, 0x9d, 0x23, 0x36, 0xb8, 0x9e, 0xee, 0xd7, 0xc5, 0xe7, 0xa1, - 0x36, 0xfa, 0xcc, 0x78, 0xa7, 0x31, 0xba, 0xf8, 0xc8, 0xf8, 0x5e, 0xc8, 0x20, 0xfe, 0x7d, 0xc8, - 0xf6, 0x65, 0xf5, 0x9e, 0xfc, 0x3f, 0x20, 0x5c, 0x40, 0x3f, 0x1a, 0x7f, 0x65, 0x17, 0xcb, 0x98, - 0x5d, 0x2e, 0x63, 0xf6, 0x63, 0x19, 0xb3, 0x4f, 0xab, 0x38, 0xba, 0x5c, 0xc5, 0xd1, 0xb7, 0x55, - 0x1c, 0xf1, 0x41, 0x81, 0xdb, 0x19, 0x8c, 0x6f, 0x35, 0xd8, 0x53, 0xdf, 0x33, 0x65, 0x6f, 0x26, - 0xfa, 0x4f, 0x75, 0xd1, 0x7c, 0x04, 0x66, 0x96, 0xbb, 0x3c, 0x29, 0x2a, 0x07, 0x54, 0xe5, 0x65, - 0x52, 0xaf, 0x6a, 0xbc, 0x86, 0xea, 0xef, 0xb7, 0xf2, 0x65, 0xe7, 0xf8, 0xa5, 0x81, 0xea, 0xd5, - 0x9a, 0x55, 0xbb, 0xc8, 0xa7, 0xeb, 0x24, 0x3e, 0x80, 0x7c, 0x3d, 0x7c, 0xbb, 0x57, 0x33, 0x1e, - 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xf0, 0xaf, 0x6c, 0x7d, 0x83, 0x03, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// LogsServiceClient is the client API for LogsService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type LogsServiceClient interface { - Export(ctx context.Context, in *ExportLogsServiceRequest, opts ...grpc.CallOption) (*ExportLogsServiceResponse, error) -} - -type logsServiceClient struct { - cc *grpc.ClientConn -} - -func NewLogsServiceClient(cc *grpc.ClientConn) LogsServiceClient { - return &logsServiceClient{cc} -} - -func (c *logsServiceClient) Export(ctx context.Context, in *ExportLogsServiceRequest, opts ...grpc.CallOption) (*ExportLogsServiceResponse, error) { - out := new(ExportLogsServiceResponse) - err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.logs.v1.LogsService/Export", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// LogsServiceServer is the server API for LogsService service. -type LogsServiceServer interface { - Export(context.Context, *ExportLogsServiceRequest) (*ExportLogsServiceResponse, error) -} - -// UnimplementedLogsServiceServer can be embedded to have forward compatible implementations. -type UnimplementedLogsServiceServer struct { -} - -func (*UnimplementedLogsServiceServer) Export(ctx context.Context, req *ExportLogsServiceRequest) (*ExportLogsServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") -} - -func RegisterLogsServiceServer(s *grpc.Server, srv LogsServiceServer) { - s.RegisterService(&_LogsService_serviceDesc, srv) -} - -func _LogsService_Export_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExportLogsServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LogsServiceServer).Export(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LogsServiceServer).Export(ctx, req.(*ExportLogsServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _LogsService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "opentelemetry.proto.collector.logs.v1.LogsService", - HandlerType: (*LogsServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Export", - Handler: _LogsService_Export_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "opentelemetry/proto/collector/logs/v1/logs_service.proto", -} - -func (m *ExportLogsServiceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportLogsServiceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportLogsServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ResourceLogs) > 0 { - for iNdEx := len(m.ResourceLogs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogsService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExportLogsServiceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportLogsServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportLogsServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.PartialSuccess.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogsService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ExportLogsPartialSuccess) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportLogsPartialSuccess) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportLogsPartialSuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ErrorMessage) > 0 { - i -= len(m.ErrorMessage) - copy(dAtA[i:], m.ErrorMessage) - i = encodeVarintLogsService(dAtA, i, uint64(len(m.ErrorMessage))) - i-- - dAtA[i] = 0x12 - } - if m.RejectedLogRecords != 0 { - i = encodeVarintLogsService(dAtA, i, uint64(m.RejectedLogRecords)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintLogsService(dAtA []byte, offset int, v uint64) int { - offset -= sovLogsService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ExportLogsServiceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceLogs) > 0 { - for _, e := range m.ResourceLogs { - l = e.Size() - n += 1 + l + sovLogsService(uint64(l)) - } - } - return n -} - -func (m *ExportLogsServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PartialSuccess.Size() - n += 1 + l + sovLogsService(uint64(l)) - return n -} - -func (m *ExportLogsPartialSuccess) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RejectedLogRecords != 0 { - n += 1 + sovLogsService(uint64(m.RejectedLogRecords)) - } - l = len(m.ErrorMessage) - if l > 0 { - n += 1 + l + sovLogsService(uint64(l)) - } - return n -} - -func sovLogsService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozLogsService(x uint64) (n int) { - return sovLogsService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ExportLogsServiceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportLogsServiceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportLogsServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogsService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogsService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceLogs = append(m.ResourceLogs, &v1.ResourceLogs{}) - if err := m.ResourceLogs[len(m.ResourceLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogsService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogsService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportLogsServiceResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportLogsServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportLogsServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogsService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogsService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PartialSuccess.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogsService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogsService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportLogsPartialSuccess) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportLogsPartialSuccess: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportLogsPartialSuccess: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedLogRecords", wireType) - } - m.RejectedLogRecords = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RejectedLogRecords |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLogsService - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLogsService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ErrorMessage = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogsService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogsService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipLogsService(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowLogsService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowLogsService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowLogsService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthLogsService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupLogsService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthLogsService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthLogsService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowLogsService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupLogsService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go b/pdata/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go deleted file mode 100644 index bfdc29395a3..00000000000 --- a/pdata/internal/data/protogen/collector/metrics/v1/metrics_service.pb.go +++ /dev/null @@ -1,840 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/collector/metrics/v1/metrics_service.proto - -package v1 - -import ( - context "context" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type ExportMetricsServiceRequest struct { - // An array of ResourceMetrics. - // For data coming from a single resource this array will typically contain one - // element. Intermediary nodes (such as OpenTelemetry Collector) that receive - // data from multiple origins typically batch the data before forwarding further and - // in that case this array will contain multiple elements. - ResourceMetrics []*v1.ResourceMetrics `protobuf:"bytes,1,rep,name=resource_metrics,json=resourceMetrics,proto3" json:"resource_metrics,omitempty"` -} - -func (m *ExportMetricsServiceRequest) Reset() { *m = ExportMetricsServiceRequest{} } -func (m *ExportMetricsServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ExportMetricsServiceRequest) ProtoMessage() {} -func (*ExportMetricsServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_75fb6015e6e64798, []int{0} -} -func (m *ExportMetricsServiceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportMetricsServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportMetricsServiceRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportMetricsServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportMetricsServiceRequest.Merge(m, src) -} -func (m *ExportMetricsServiceRequest) XXX_Size() int { - return m.Size() -} -func (m *ExportMetricsServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ExportMetricsServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportMetricsServiceRequest proto.InternalMessageInfo - -func (m *ExportMetricsServiceRequest) GetResourceMetrics() []*v1.ResourceMetrics { - if m != nil { - return m.ResourceMetrics - } - return nil -} - -type ExportMetricsServiceResponse struct { - // The details of a partially successful export request. - // - // If the request is only partially accepted - // (i.e. when the server accepts only parts of the data and rejects the rest) - // the server MUST initialize the `partial_success` field and MUST - // set the `rejected_` with the number of items it rejected. - // - // Servers MAY also make use of the `partial_success` field to convey - // warnings/suggestions to senders even when the request was fully accepted. - // In such cases, the `rejected_` MUST have a value of `0` and - // the `error_message` MUST be non-empty. - // - // A `partial_success` message with an empty value (rejected_ = 0 and - // `error_message` = "") is equivalent to it not being set/present. Senders - // SHOULD interpret it the same way as in the full success case. - PartialSuccess ExportMetricsPartialSuccess `protobuf:"bytes,1,opt,name=partial_success,json=partialSuccess,proto3" json:"partial_success"` -} - -func (m *ExportMetricsServiceResponse) Reset() { *m = ExportMetricsServiceResponse{} } -func (m *ExportMetricsServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ExportMetricsServiceResponse) ProtoMessage() {} -func (*ExportMetricsServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_75fb6015e6e64798, []int{1} -} -func (m *ExportMetricsServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportMetricsServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportMetricsServiceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportMetricsServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportMetricsServiceResponse.Merge(m, src) -} -func (m *ExportMetricsServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *ExportMetricsServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ExportMetricsServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportMetricsServiceResponse proto.InternalMessageInfo - -func (m *ExportMetricsServiceResponse) GetPartialSuccess() ExportMetricsPartialSuccess { - if m != nil { - return m.PartialSuccess - } - return ExportMetricsPartialSuccess{} -} - -type ExportMetricsPartialSuccess struct { - // The number of rejected data points. - // - // A `rejected_` field holding a `0` value indicates that the - // request was fully accepted. - RejectedDataPoints int64 `protobuf:"varint,1,opt,name=rejected_data_points,json=rejectedDataPoints,proto3" json:"rejected_data_points,omitempty"` - // A developer-facing human-readable message in English. It should be used - // either to explain why the server rejected parts of the data during a partial - // success or to convey warnings/suggestions during a full success. The message - // should offer guidance on how users can address such issues. - // - // error_message is an optional field. An error_message with an empty value - // is equivalent to it not being set. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` -} - -func (m *ExportMetricsPartialSuccess) Reset() { *m = ExportMetricsPartialSuccess{} } -func (m *ExportMetricsPartialSuccess) String() string { return proto.CompactTextString(m) } -func (*ExportMetricsPartialSuccess) ProtoMessage() {} -func (*ExportMetricsPartialSuccess) Descriptor() ([]byte, []int) { - return fileDescriptor_75fb6015e6e64798, []int{2} -} -func (m *ExportMetricsPartialSuccess) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportMetricsPartialSuccess) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportMetricsPartialSuccess.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportMetricsPartialSuccess) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportMetricsPartialSuccess.Merge(m, src) -} -func (m *ExportMetricsPartialSuccess) XXX_Size() int { - return m.Size() -} -func (m *ExportMetricsPartialSuccess) XXX_DiscardUnknown() { - xxx_messageInfo_ExportMetricsPartialSuccess.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportMetricsPartialSuccess proto.InternalMessageInfo - -func (m *ExportMetricsPartialSuccess) GetRejectedDataPoints() int64 { - if m != nil { - return m.RejectedDataPoints - } - return 0 -} - -func (m *ExportMetricsPartialSuccess) GetErrorMessage() string { - if m != nil { - return m.ErrorMessage - } - return "" -} - -func init() { - proto.RegisterType((*ExportMetricsServiceRequest)(nil), "opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest") - proto.RegisterType((*ExportMetricsServiceResponse)(nil), "opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceResponse") - proto.RegisterType((*ExportMetricsPartialSuccess)(nil), "opentelemetry.proto.collector.metrics.v1.ExportMetricsPartialSuccess") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/collector/metrics/v1/metrics_service.proto", fileDescriptor_75fb6015e6e64798) -} - -var fileDescriptor_75fb6015e6e64798 = []byte{ - // 427 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xbf, 0x8e, 0xd3, 0x30, - 0x18, 0x8f, 0xef, 0xd0, 0x49, 0xf8, 0xe0, 0x0e, 0x99, 0x1b, 0x4e, 0x05, 0x85, 0x53, 0x58, 0x22, - 0x81, 0x1c, 0x5a, 0x76, 0x86, 0xc2, 0xb1, 0x9d, 0x1a, 0xa5, 0x88, 0xa1, 0x4b, 0x64, 0xdc, 0x4f, - 0x51, 0x50, 0x1a, 0x1b, 0xdb, 0xad, 0xe8, 0x5b, 0x30, 0xb0, 0xf0, 0x0a, 0x88, 0x07, 0xe9, 0xd8, - 0xb1, 0x13, 0x42, 0xed, 0x8b, 0xa0, 0xc4, 0x69, 0xc1, 0x25, 0x43, 0xc5, 0x6d, 0xce, 0xcf, 0xdf, - 0xef, 0x4f, 0x7e, 0xd6, 0x87, 0x5f, 0x09, 0x09, 0xa5, 0x81, 0x02, 0x26, 0x60, 0xd4, 0x3c, 0x92, - 0x4a, 0x18, 0x11, 0x71, 0x51, 0x14, 0xc0, 0x8d, 0x50, 0x51, 0x85, 0xe6, 0x5c, 0x47, 0xb3, 0xee, - 0xf6, 0x98, 0x6a, 0x50, 0xb3, 0x9c, 0x03, 0xad, 0x47, 0x49, 0xe8, 0xf0, 0x2d, 0x48, 0x77, 0x7c, - 0xda, 0x90, 0xe8, 0xac, 0xdb, 0xb9, 0xc8, 0x44, 0x26, 0xac, 0x7e, 0x75, 0xb2, 0xa3, 0x9d, 0xe7, - 0x6d, 0xfe, 0xff, 0xba, 0xda, 0xe9, 0x60, 0x8e, 0x1f, 0x5d, 0x7f, 0x96, 0x42, 0x99, 0x1b, 0x0b, - 0x0f, 0x6d, 0x96, 0x04, 0x3e, 0x4d, 0x41, 0x1b, 0x32, 0xc2, 0x0f, 0x14, 0x68, 0x31, 0x55, 0x1c, - 0xd2, 0x86, 0x78, 0x89, 0xae, 0x8e, 0xc3, 0xd3, 0x5e, 0x44, 0xdb, 0x72, 0xfe, 0x49, 0x47, 0x93, - 0x86, 0xd7, 0x08, 0x27, 0xe7, 0xca, 0x05, 0x82, 0xaf, 0x08, 0x3f, 0x6e, 0xf7, 0xd6, 0x52, 0x94, - 0x1a, 0x88, 0xc1, 0xe7, 0x92, 0x29, 0x93, 0xb3, 0x22, 0xd5, 0x53, 0xce, 0x41, 0x57, 0xde, 0x28, - 0x3c, 0xed, 0x5d, 0xd3, 0x43, 0x3b, 0xa2, 0x8e, 0x41, 0x6c, 0xd5, 0x86, 0x56, 0xac, 0x7f, 0x67, - 0xf1, 0xf3, 0x89, 0x97, 0x9c, 0x49, 0x07, 0x0d, 0xcc, 0x5e, 0x23, 0x2e, 0x89, 0xbc, 0xc0, 0x17, - 0x0a, 0x3e, 0x02, 0x37, 0x30, 0x4e, 0xc7, 0xcc, 0xb0, 0x54, 0x8a, 0xbc, 0x34, 0x36, 0xd9, 0x71, - 0x42, 0xb6, 0x77, 0x6f, 0x98, 0x61, 0x71, 0x7d, 0x43, 0x9e, 0xe2, 0xfb, 0xa0, 0x94, 0x50, 0xe9, - 0x04, 0xb4, 0x66, 0x19, 0x5c, 0x1e, 0x5d, 0xa1, 0xf0, 0x6e, 0x72, 0xaf, 0x06, 0x6f, 0x2c, 0xd6, - 0xfb, 0x81, 0xf0, 0x99, 0x5b, 0x03, 0xf9, 0x86, 0xf0, 0x89, 0x4d, 0x42, 0xfe, 0xf7, 0x87, 0xdd, - 0xd7, 0xec, 0xbc, 0xbd, 0xad, 0x8c, 0x7d, 0x98, 0xc0, 0xeb, 0xaf, 0xd0, 0x62, 0xed, 0xa3, 0xe5, - 0xda, 0x47, 0xbf, 0xd6, 0x3e, 0xfa, 0xb2, 0xf1, 0xbd, 0xe5, 0xc6, 0xf7, 0x56, 0x1b, 0xdf, 0xc3, - 0xcf, 0x72, 0x71, 0xb0, 0x4d, 0xff, 0xa1, 0xeb, 0x10, 0x57, 0x93, 0x31, 0x1a, 0x0d, 0xb2, 0x7d, - 0x8d, 0xfc, 0xef, 0x1d, 0x92, 0x55, 0xf1, 0x51, 0x5e, 0x1a, 0x50, 0x25, 0x2b, 0xa2, 0xfa, 0xab, - 0x36, 0xc9, 0xa0, 0x6c, 0x5d, 0xb5, 0xef, 0x47, 0xe1, 0x40, 0x42, 0xf9, 0x6e, 0x27, 0x57, 0x1b, - 0xd1, 0xd7, 0xbb, 0x48, 0x4d, 0x0c, 0xfa, 0xbe, 0xfb, 0xe1, 0xa4, 0x56, 0x7a, 0xf9, 0x3b, 0x00, - 0x00, 0xff, 0xff, 0x47, 0xf2, 0x5f, 0x42, 0xc8, 0x03, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MetricsServiceClient is the client API for MetricsService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MetricsServiceClient interface { - Export(ctx context.Context, in *ExportMetricsServiceRequest, opts ...grpc.CallOption) (*ExportMetricsServiceResponse, error) -} - -type metricsServiceClient struct { - cc *grpc.ClientConn -} - -func NewMetricsServiceClient(cc *grpc.ClientConn) MetricsServiceClient { - return &metricsServiceClient{cc} -} - -func (c *metricsServiceClient) Export(ctx context.Context, in *ExportMetricsServiceRequest, opts ...grpc.CallOption) (*ExportMetricsServiceResponse, error) { - out := new(ExportMetricsServiceResponse) - err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MetricsServiceServer is the server API for MetricsService service. -type MetricsServiceServer interface { - Export(context.Context, *ExportMetricsServiceRequest) (*ExportMetricsServiceResponse, error) -} - -// UnimplementedMetricsServiceServer can be embedded to have forward compatible implementations. -type UnimplementedMetricsServiceServer struct { -} - -func (*UnimplementedMetricsServiceServer) Export(ctx context.Context, req *ExportMetricsServiceRequest) (*ExportMetricsServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") -} - -func RegisterMetricsServiceServer(s *grpc.Server, srv MetricsServiceServer) { - s.RegisterService(&_MetricsService_serviceDesc, srv) -} - -func _MetricsService_Export_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExportMetricsServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MetricsServiceServer).Export(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MetricsServiceServer).Export(ctx, req.(*ExportMetricsServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _MetricsService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "opentelemetry.proto.collector.metrics.v1.MetricsService", - HandlerType: (*MetricsServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Export", - Handler: _MetricsService_Export_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "opentelemetry/proto/collector/metrics/v1/metrics_service.proto", -} - -func (m *ExportMetricsServiceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportMetricsServiceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportMetricsServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ResourceMetrics) > 0 { - for iNdEx := len(m.ResourceMetrics) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceMetrics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetricsService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExportMetricsServiceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportMetricsServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportMetricsServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.PartialSuccess.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetricsService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ExportMetricsPartialSuccess) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportMetricsPartialSuccess) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportMetricsPartialSuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ErrorMessage) > 0 { - i -= len(m.ErrorMessage) - copy(dAtA[i:], m.ErrorMessage) - i = encodeVarintMetricsService(dAtA, i, uint64(len(m.ErrorMessage))) - i-- - dAtA[i] = 0x12 - } - if m.RejectedDataPoints != 0 { - i = encodeVarintMetricsService(dAtA, i, uint64(m.RejectedDataPoints)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintMetricsService(dAtA []byte, offset int, v uint64) int { - offset -= sovMetricsService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ExportMetricsServiceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceMetrics) > 0 { - for _, e := range m.ResourceMetrics { - l = e.Size() - n += 1 + l + sovMetricsService(uint64(l)) - } - } - return n -} - -func (m *ExportMetricsServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PartialSuccess.Size() - n += 1 + l + sovMetricsService(uint64(l)) - return n -} - -func (m *ExportMetricsPartialSuccess) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RejectedDataPoints != 0 { - n += 1 + sovMetricsService(uint64(m.RejectedDataPoints)) - } - l = len(m.ErrorMessage) - if l > 0 { - n += 1 + l + sovMetricsService(uint64(l)) - } - return n -} - -func sovMetricsService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMetricsService(x uint64) (n int) { - return sovMetricsService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ExportMetricsServiceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportMetricsServiceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportMetricsServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceMetrics", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetricsService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetricsService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceMetrics = append(m.ResourceMetrics, &v1.ResourceMetrics{}) - if err := m.ResourceMetrics[len(m.ResourceMetrics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetricsService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetricsService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportMetricsServiceResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportMetricsServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportMetricsServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetricsService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetricsService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PartialSuccess.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetricsService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetricsService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportMetricsPartialSuccess) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportMetricsPartialSuccess: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportMetricsPartialSuccess: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedDataPoints", wireType) - } - m.RejectedDataPoints = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RejectedDataPoints |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetricsService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMetricsService - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMetricsService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ErrorMessage = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetricsService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetricsService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipMetricsService(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMetricsService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMetricsService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMetricsService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthMetricsService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMetricsService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMetricsService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthMetricsService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMetricsService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMetricsService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/collector/profiles/v1development/profiles_service.pb.go b/pdata/internal/data/protogen/collector/profiles/v1development/profiles_service.pb.go deleted file mode 100644 index 80eae38f558..00000000000 --- a/pdata/internal/data/protogen/collector/profiles/v1development/profiles_service.pb.go +++ /dev/null @@ -1,897 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/collector/profiles/v1development/profiles_service.proto - -package v1development - -import ( - context "context" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - - v1development "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type ExportProfilesServiceRequest struct { - // An array of ResourceProfiles. - // For data coming from a single resource this array will typically contain one - // element. Intermediary nodes (such as OpenTelemetry Collector) that receive - // data from multiple origins typically batch the data before forwarding further and - // in that case this array will contain multiple elements. - ResourceProfiles []*v1development.ResourceProfiles `protobuf:"bytes,1,rep,name=resource_profiles,json=resourceProfiles,proto3" json:"resource_profiles,omitempty"` - // The reference table containing all data shared by profiles across the message being sent. - Dictionary v1development.ProfilesDictionary `protobuf:"bytes,2,opt,name=dictionary,proto3" json:"dictionary"` -} - -func (m *ExportProfilesServiceRequest) Reset() { *m = ExportProfilesServiceRequest{} } -func (m *ExportProfilesServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ExportProfilesServiceRequest) ProtoMessage() {} -func (*ExportProfilesServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_ad3943ce836e7720, []int{0} -} -func (m *ExportProfilesServiceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportProfilesServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportProfilesServiceRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportProfilesServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportProfilesServiceRequest.Merge(m, src) -} -func (m *ExportProfilesServiceRequest) XXX_Size() int { - return m.Size() -} -func (m *ExportProfilesServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ExportProfilesServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportProfilesServiceRequest proto.InternalMessageInfo - -func (m *ExportProfilesServiceRequest) GetResourceProfiles() []*v1development.ResourceProfiles { - if m != nil { - return m.ResourceProfiles - } - return nil -} - -func (m *ExportProfilesServiceRequest) GetDictionary() v1development.ProfilesDictionary { - if m != nil { - return m.Dictionary - } - return v1development.ProfilesDictionary{} -} - -type ExportProfilesServiceResponse struct { - // The details of a partially successful export request. - // - // If the request is only partially accepted - // (i.e. when the server accepts only parts of the data and rejects the rest) - // the server MUST initialize the `partial_success` field and MUST - // set the `rejected_` with the number of items it rejected. - // - // Servers MAY also make use of the `partial_success` field to convey - // warnings/suggestions to senders even when the request was fully accepted. - // In such cases, the `rejected_` MUST have a value of `0` and - // the `error_message` MUST be non-empty. - // - // A `partial_success` message with an empty value (rejected_ = 0 and - // `error_message` = "") is equivalent to it not being set/present. Senders - // SHOULD interpret it the same way as in the full success case. - PartialSuccess ExportProfilesPartialSuccess `protobuf:"bytes,1,opt,name=partial_success,json=partialSuccess,proto3" json:"partial_success"` -} - -func (m *ExportProfilesServiceResponse) Reset() { *m = ExportProfilesServiceResponse{} } -func (m *ExportProfilesServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ExportProfilesServiceResponse) ProtoMessage() {} -func (*ExportProfilesServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ad3943ce836e7720, []int{1} -} -func (m *ExportProfilesServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportProfilesServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportProfilesServiceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportProfilesServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportProfilesServiceResponse.Merge(m, src) -} -func (m *ExportProfilesServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *ExportProfilesServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ExportProfilesServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportProfilesServiceResponse proto.InternalMessageInfo - -func (m *ExportProfilesServiceResponse) GetPartialSuccess() ExportProfilesPartialSuccess { - if m != nil { - return m.PartialSuccess - } - return ExportProfilesPartialSuccess{} -} - -type ExportProfilesPartialSuccess struct { - // The number of rejected profiles. - // - // A `rejected_` field holding a `0` value indicates that the - // request was fully accepted. - RejectedProfiles int64 `protobuf:"varint,1,opt,name=rejected_profiles,json=rejectedProfiles,proto3" json:"rejected_profiles,omitempty"` - // A developer-facing human-readable message in English. It should be used - // either to explain why the server rejected parts of the data during a partial - // success or to convey warnings/suggestions during a full success. The message - // should offer guidance on how users can address such issues. - // - // error_message is an optional field. An error_message with an empty value - // is equivalent to it not being set. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` -} - -func (m *ExportProfilesPartialSuccess) Reset() { *m = ExportProfilesPartialSuccess{} } -func (m *ExportProfilesPartialSuccess) String() string { return proto.CompactTextString(m) } -func (*ExportProfilesPartialSuccess) ProtoMessage() {} -func (*ExportProfilesPartialSuccess) Descriptor() ([]byte, []int) { - return fileDescriptor_ad3943ce836e7720, []int{2} -} -func (m *ExportProfilesPartialSuccess) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportProfilesPartialSuccess) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportProfilesPartialSuccess.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportProfilesPartialSuccess) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportProfilesPartialSuccess.Merge(m, src) -} -func (m *ExportProfilesPartialSuccess) XXX_Size() int { - return m.Size() -} -func (m *ExportProfilesPartialSuccess) XXX_DiscardUnknown() { - xxx_messageInfo_ExportProfilesPartialSuccess.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportProfilesPartialSuccess proto.InternalMessageInfo - -func (m *ExportProfilesPartialSuccess) GetRejectedProfiles() int64 { - if m != nil { - return m.RejectedProfiles - } - return 0 -} - -func (m *ExportProfilesPartialSuccess) GetErrorMessage() string { - if m != nil { - return m.ErrorMessage - } - return "" -} - -func init() { - proto.RegisterType((*ExportProfilesServiceRequest)(nil), "opentelemetry.proto.collector.profiles.v1development.ExportProfilesServiceRequest") - proto.RegisterType((*ExportProfilesServiceResponse)(nil), "opentelemetry.proto.collector.profiles.v1development.ExportProfilesServiceResponse") - proto.RegisterType((*ExportProfilesPartialSuccess)(nil), "opentelemetry.proto.collector.profiles.v1development.ExportProfilesPartialSuccess") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/collector/profiles/v1development/profiles_service.proto", fileDescriptor_ad3943ce836e7720) -} - -var fileDescriptor_ad3943ce836e7720 = []byte{ - // 467 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x8a, 0xd3, 0x40, - 0x18, 0xc7, 0x33, 0xbb, 0xb2, 0xe0, 0xac, 0xba, 0x1a, 0xf6, 0xb0, 0x14, 0x8d, 0x4b, 0xbc, 0x14, - 0x84, 0x09, 0x5b, 0x17, 0x44, 0x10, 0x0f, 0x75, 0x3d, 0x89, 0x18, 0x52, 0xf1, 0xa0, 0x87, 0x10, - 0x27, 0x9f, 0x61, 0x24, 0x9d, 0x19, 0x67, 0xa6, 0xc5, 0x1e, 0x7d, 0x03, 0xdf, 0xc1, 0x9b, 0x57, - 0x1f, 0xc2, 0x1e, 0x7b, 0xf4, 0x24, 0xd2, 0x3e, 0x80, 0x4f, 0x20, 0x48, 0x32, 0x4d, 0x6c, 0x42, - 0xa5, 0x58, 0x7a, 0xcb, 0x7c, 0xc3, 0xff, 0xf7, 0xff, 0x7f, 0xdf, 0x17, 0x06, 0x3f, 0x15, 0x12, - 0xb8, 0x81, 0x1c, 0x86, 0x60, 0xd4, 0x24, 0x90, 0x4a, 0x18, 0x11, 0x50, 0x91, 0xe7, 0x40, 0x8d, - 0x50, 0xc5, 0xf9, 0x2d, 0xcb, 0x41, 0x07, 0xe3, 0xb3, 0x14, 0xc6, 0x90, 0x0b, 0x39, 0x04, 0x6e, - 0xea, 0x72, 0xac, 0x41, 0x8d, 0x19, 0x05, 0x52, 0xea, 0xdc, 0xf3, 0x06, 0xcc, 0x16, 0x49, 0x0d, - 0x23, 0x95, 0x8a, 0x34, 0x60, 0x9d, 0xe3, 0x4c, 0x64, 0xc2, 0x1a, 0x17, 0x5f, 0x56, 0xd6, 0x79, - 0xb0, 0x2e, 0xd8, 0x86, 0x38, 0x56, 0xea, 0xff, 0x42, 0xf8, 0xe6, 0x93, 0x0f, 0x52, 0x28, 0x13, - 0x2e, 0x2f, 0x06, 0x36, 0x66, 0x04, 0xef, 0x47, 0xa0, 0x8d, 0xcb, 0xf0, 0x0d, 0x05, 0x5a, 0x8c, - 0x14, 0x85, 0xb8, 0xd2, 0x9e, 0xa0, 0xd3, 0xfd, 0xee, 0x61, 0xef, 0x21, 0x59, 0xd7, 0xc3, 0xfa, - 0xe4, 0x24, 0x5a, 0x42, 0x2a, 0x9b, 0xe8, 0xba, 0x6a, 0x55, 0xdc, 0x14, 0xe3, 0x94, 0x51, 0xc3, - 0x04, 0x4f, 0xd4, 0xe4, 0x64, 0xef, 0x14, 0x75, 0x0f, 0x7b, 0x8f, 0xfe, 0xc7, 0xa3, 0x22, 0x5d, - 0xd4, 0x94, 0xfe, 0xa5, 0xe9, 0x8f, 0xdb, 0x4e, 0xb4, 0xc2, 0xf5, 0x3f, 0x23, 0x7c, 0xeb, 0x1f, - 0x1d, 0x6b, 0x29, 0xb8, 0x06, 0xf7, 0x23, 0xc2, 0x47, 0x32, 0x51, 0x86, 0x25, 0x79, 0xac, 0x47, - 0x94, 0x82, 0x2e, 0x3a, 0x2e, 0xd2, 0x44, 0x64, 0x9b, 0xad, 0x91, 0xa6, 0x5d, 0x68, 0xd1, 0x03, - 0x4b, 0x5e, 0x26, 0xbc, 0x26, 0x1b, 0x55, 0x5f, 0xb6, 0xd7, 0xd2, 0x54, 0xb9, 0x77, 0x8b, 0xb5, - 0xbc, 0x03, 0x6a, 0x20, 0x5d, 0x5d, 0x0b, 0xea, 0xee, 0x17, 0x83, 0xb5, 0x17, 0xf5, 0x60, 0xef, - 0xe0, 0xab, 0xa0, 0x94, 0x50, 0xf1, 0x10, 0xb4, 0x4e, 0x32, 0x28, 0x67, 0x7b, 0x39, 0xba, 0x52, - 0x16, 0x9f, 0xd9, 0x5a, 0xef, 0x1b, 0xc2, 0x47, 0xad, 0x89, 0xb8, 0x5f, 0x11, 0x3e, 0xb0, 0x31, - 0xdc, 0x9d, 0xb4, 0xde, 0xfc, 0xb7, 0x3a, 0x83, 0x9d, 0x32, 0xed, 0xf6, 0x7c, 0xa7, 0xff, 0x1b, - 0x4d, 0xe7, 0x1e, 0x9a, 0xcd, 0x3d, 0xf4, 0x73, 0xee, 0xa1, 0x4f, 0x0b, 0xcf, 0x99, 0x2d, 0x3c, - 0xe7, 0xfb, 0xc2, 0x73, 0xf0, 0x7d, 0x26, 0xb6, 0xf2, 0xec, 0x1f, 0xb7, 0xec, 0xc2, 0x42, 0x16, - 0xa2, 0x57, 0xaf, 0xb3, 0x36, 0x90, 0x35, 0xde, 0x84, 0x34, 0x31, 0x49, 0xc0, 0xb8, 0x01, 0xc5, - 0x93, 0x3c, 0x28, 0x4f, 0xa5, 0x63, 0x06, 0x7c, 0xe3, 0xd3, 0xf1, 0x65, 0xef, 0xfc, 0xb9, 0x04, - 0xfe, 0xa2, 0x46, 0x97, 0xa6, 0xe4, 0x71, 0x9d, 0xb5, 0xca, 0x44, 0x5e, 0x9e, 0x5d, 0xfc, 0x95, - 0xbd, 0x39, 0x28, 0x1d, 0xee, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0x40, 0xb9, 0xb5, 0x6e, 0xb0, - 0x04, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// ProfilesServiceClient is the client API for ProfilesService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type ProfilesServiceClient interface { - Export(ctx context.Context, in *ExportProfilesServiceRequest, opts ...grpc.CallOption) (*ExportProfilesServiceResponse, error) -} - -type profilesServiceClient struct { - cc *grpc.ClientConn -} - -func NewProfilesServiceClient(cc *grpc.ClientConn) ProfilesServiceClient { - return &profilesServiceClient{cc} -} - -func (c *profilesServiceClient) Export(ctx context.Context, in *ExportProfilesServiceRequest, opts ...grpc.CallOption) (*ExportProfilesServiceResponse, error) { - out := new(ExportProfilesServiceResponse) - err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ProfilesServiceServer is the server API for ProfilesService service. -type ProfilesServiceServer interface { - Export(context.Context, *ExportProfilesServiceRequest) (*ExportProfilesServiceResponse, error) -} - -// UnimplementedProfilesServiceServer can be embedded to have forward compatible implementations. -type UnimplementedProfilesServiceServer struct { -} - -func (*UnimplementedProfilesServiceServer) Export(ctx context.Context, req *ExportProfilesServiceRequest) (*ExportProfilesServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") -} - -func RegisterProfilesServiceServer(s *grpc.Server, srv ProfilesServiceServer) { - s.RegisterService(&_ProfilesService_serviceDesc, srv) -} - -func _ProfilesService_Export_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExportProfilesServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProfilesServiceServer).Export(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProfilesServiceServer).Export(ctx, req.(*ExportProfilesServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _ProfilesService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "opentelemetry.proto.collector.profiles.v1development.ProfilesService", - HandlerType: (*ProfilesServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Export", - Handler: _ProfilesService_Export_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "opentelemetry/proto/collector/profiles/v1development/profiles_service.proto", -} - -func (m *ExportProfilesServiceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportProfilesServiceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportProfilesServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Dictionary.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfilesService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ResourceProfiles) > 0 { - for iNdEx := len(m.ResourceProfiles) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceProfiles[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfilesService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExportProfilesServiceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportProfilesServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportProfilesServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.PartialSuccess.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfilesService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ExportProfilesPartialSuccess) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportProfilesPartialSuccess) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportProfilesPartialSuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ErrorMessage) > 0 { - i -= len(m.ErrorMessage) - copy(dAtA[i:], m.ErrorMessage) - i = encodeVarintProfilesService(dAtA, i, uint64(len(m.ErrorMessage))) - i-- - dAtA[i] = 0x12 - } - if m.RejectedProfiles != 0 { - i = encodeVarintProfilesService(dAtA, i, uint64(m.RejectedProfiles)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintProfilesService(dAtA []byte, offset int, v uint64) int { - offset -= sovProfilesService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ExportProfilesServiceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceProfiles) > 0 { - for _, e := range m.ResourceProfiles { - l = e.Size() - n += 1 + l + sovProfilesService(uint64(l)) - } - } - l = m.Dictionary.Size() - n += 1 + l + sovProfilesService(uint64(l)) - return n -} - -func (m *ExportProfilesServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PartialSuccess.Size() - n += 1 + l + sovProfilesService(uint64(l)) - return n -} - -func (m *ExportProfilesPartialSuccess) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RejectedProfiles != 0 { - n += 1 + sovProfilesService(uint64(m.RejectedProfiles)) - } - l = len(m.ErrorMessage) - if l > 0 { - n += 1 + l + sovProfilesService(uint64(l)) - } - return n -} - -func sovProfilesService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozProfilesService(x uint64) (n int) { - return sovProfilesService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ExportProfilesServiceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportProfilesServiceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportProfilesServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceProfiles", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfilesService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfilesService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceProfiles = append(m.ResourceProfiles, &v1development.ResourceProfiles{}) - if err := m.ResourceProfiles[len(m.ResourceProfiles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Dictionary", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfilesService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfilesService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Dictionary.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfilesService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfilesService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportProfilesServiceResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportProfilesServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportProfilesServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfilesService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfilesService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PartialSuccess.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfilesService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfilesService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportProfilesPartialSuccess) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportProfilesPartialSuccess: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportProfilesPartialSuccess: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedProfiles", wireType) - } - m.RejectedProfiles = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RejectedProfiles |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfilesService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProfilesService - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProfilesService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ErrorMessage = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfilesService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfilesService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipProfilesService(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProfilesService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProfilesService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProfilesService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthProfilesService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupProfilesService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthProfilesService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthProfilesService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowProfilesService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupProfilesService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/collector/trace/v1/trace_service.pb.go b/pdata/internal/data/protogen/collector/trace/v1/trace_service.pb.go deleted file mode 100644 index 5b547b8a7a9..00000000000 --- a/pdata/internal/data/protogen/collector/trace/v1/trace_service.pb.go +++ /dev/null @@ -1,839 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/collector/trace/v1/trace_service.proto - -package v1 - -import ( - context "context" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type ExportTraceServiceRequest struct { - // An array of ResourceSpans. - // For data coming from a single resource this array will typically contain one - // element. Intermediary nodes (such as OpenTelemetry Collector) that receive - // data from multiple origins typically batch the data before forwarding further and - // in that case this array will contain multiple elements. - ResourceSpans []*v1.ResourceSpans `protobuf:"bytes,1,rep,name=resource_spans,json=resourceSpans,proto3" json:"resource_spans,omitempty"` -} - -func (m *ExportTraceServiceRequest) Reset() { *m = ExportTraceServiceRequest{} } -func (m *ExportTraceServiceRequest) String() string { return proto.CompactTextString(m) } -func (*ExportTraceServiceRequest) ProtoMessage() {} -func (*ExportTraceServiceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_192a962890318cf4, []int{0} -} -func (m *ExportTraceServiceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportTraceServiceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportTraceServiceRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportTraceServiceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportTraceServiceRequest.Merge(m, src) -} -func (m *ExportTraceServiceRequest) XXX_Size() int { - return m.Size() -} -func (m *ExportTraceServiceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ExportTraceServiceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportTraceServiceRequest proto.InternalMessageInfo - -func (m *ExportTraceServiceRequest) GetResourceSpans() []*v1.ResourceSpans { - if m != nil { - return m.ResourceSpans - } - return nil -} - -type ExportTraceServiceResponse struct { - // The details of a partially successful export request. - // - // If the request is only partially accepted - // (i.e. when the server accepts only parts of the data and rejects the rest) - // the server MUST initialize the `partial_success` field and MUST - // set the `rejected_` with the number of items it rejected. - // - // Servers MAY also make use of the `partial_success` field to convey - // warnings/suggestions to senders even when the request was fully accepted. - // In such cases, the `rejected_` MUST have a value of `0` and - // the `error_message` MUST be non-empty. - // - // A `partial_success` message with an empty value (rejected_ = 0 and - // `error_message` = "") is equivalent to it not being set/present. Senders - // SHOULD interpret it the same way as in the full success case. - PartialSuccess ExportTracePartialSuccess `protobuf:"bytes,1,opt,name=partial_success,json=partialSuccess,proto3" json:"partial_success"` -} - -func (m *ExportTraceServiceResponse) Reset() { *m = ExportTraceServiceResponse{} } -func (m *ExportTraceServiceResponse) String() string { return proto.CompactTextString(m) } -func (*ExportTraceServiceResponse) ProtoMessage() {} -func (*ExportTraceServiceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_192a962890318cf4, []int{1} -} -func (m *ExportTraceServiceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportTraceServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportTraceServiceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportTraceServiceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportTraceServiceResponse.Merge(m, src) -} -func (m *ExportTraceServiceResponse) XXX_Size() int { - return m.Size() -} -func (m *ExportTraceServiceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ExportTraceServiceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportTraceServiceResponse proto.InternalMessageInfo - -func (m *ExportTraceServiceResponse) GetPartialSuccess() ExportTracePartialSuccess { - if m != nil { - return m.PartialSuccess - } - return ExportTracePartialSuccess{} -} - -type ExportTracePartialSuccess struct { - // The number of rejected spans. - // - // A `rejected_` field holding a `0` value indicates that the - // request was fully accepted. - RejectedSpans int64 `protobuf:"varint,1,opt,name=rejected_spans,json=rejectedSpans,proto3" json:"rejected_spans,omitempty"` - // A developer-facing human-readable message in English. It should be used - // either to explain why the server rejected parts of the data during a partial - // success or to convey warnings/suggestions during a full success. The message - // should offer guidance on how users can address such issues. - // - // error_message is an optional field. An error_message with an empty value - // is equivalent to it not being set. - ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` -} - -func (m *ExportTracePartialSuccess) Reset() { *m = ExportTracePartialSuccess{} } -func (m *ExportTracePartialSuccess) String() string { return proto.CompactTextString(m) } -func (*ExportTracePartialSuccess) ProtoMessage() {} -func (*ExportTracePartialSuccess) Descriptor() ([]byte, []int) { - return fileDescriptor_192a962890318cf4, []int{2} -} -func (m *ExportTracePartialSuccess) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExportTracePartialSuccess) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExportTracePartialSuccess.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExportTracePartialSuccess) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExportTracePartialSuccess.Merge(m, src) -} -func (m *ExportTracePartialSuccess) XXX_Size() int { - return m.Size() -} -func (m *ExportTracePartialSuccess) XXX_DiscardUnknown() { - xxx_messageInfo_ExportTracePartialSuccess.DiscardUnknown(m) -} - -var xxx_messageInfo_ExportTracePartialSuccess proto.InternalMessageInfo - -func (m *ExportTracePartialSuccess) GetRejectedSpans() int64 { - if m != nil { - return m.RejectedSpans - } - return 0 -} - -func (m *ExportTracePartialSuccess) GetErrorMessage() string { - if m != nil { - return m.ErrorMessage - } - return "" -} - -func init() { - proto.RegisterType((*ExportTraceServiceRequest)(nil), "opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest") - proto.RegisterType((*ExportTraceServiceResponse)(nil), "opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse") - proto.RegisterType((*ExportTracePartialSuccess)(nil), "opentelemetry.proto.collector.trace.v1.ExportTracePartialSuccess") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/collector/trace/v1/trace_service.proto", fileDescriptor_192a962890318cf4) -} - -var fileDescriptor_192a962890318cf4 = []byte{ - // 413 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x4f, 0xeb, 0xd3, 0x30, - 0x18, 0x6e, 0x36, 0x19, 0x98, 0xfd, 0x11, 0x8b, 0x87, 0xd9, 0x43, 0x1d, 0x15, 0x47, 0x45, 0x48, - 0xd9, 0xbc, 0x79, 0xb3, 0xe2, 0x71, 0x38, 0xba, 0xe1, 0xc1, 0xcb, 0x88, 0xdd, 0x4b, 0xa9, 0x74, - 0x4d, 0x4c, 0xb2, 0xa1, 0x5f, 0x42, 0xf4, 0x2b, 0x78, 0xf4, 0x93, 0xec, 0xb8, 0xa3, 0x27, 0x91, - 0xed, 0x8b, 0x48, 0x12, 0x2d, 0xad, 0xf4, 0x30, 0x7e, 0xbf, 0x5b, 0xf2, 0xf0, 0x3e, 0x7f, 0xde, - 0x27, 0x04, 0xbf, 0x60, 0x1c, 0x4a, 0x05, 0x05, 0xec, 0x40, 0x89, 0xcf, 0x11, 0x17, 0x4c, 0xb1, - 0x28, 0x65, 0x45, 0x01, 0xa9, 0x62, 0x22, 0x52, 0x82, 0xa6, 0x10, 0x1d, 0x66, 0xf6, 0xb0, 0x91, - 0x20, 0x0e, 0x79, 0x0a, 0xc4, 0x8c, 0xb9, 0xd3, 0x06, 0xd7, 0x82, 0xa4, 0xe2, 0x12, 0x43, 0x21, - 0x87, 0x99, 0xf7, 0x20, 0x63, 0x19, 0xb3, 0xca, 0xfa, 0x64, 0x07, 0xbd, 0xb0, 0xcd, 0xb9, 0xe9, - 0x67, 0x27, 0x03, 0x86, 0x1f, 0xbe, 0xfe, 0xc4, 0x99, 0x50, 0x6b, 0x0d, 0xae, 0x6c, 0x86, 0x04, - 0x3e, 0xee, 0x41, 0x2a, 0x37, 0xc1, 0x23, 0x01, 0x92, 0xed, 0x85, 0x8e, 0xc7, 0x69, 0x29, 0xc7, - 0x68, 0xd2, 0x0d, 0xfb, 0xf3, 0x67, 0xa4, 0x2d, 0xdd, 0xbf, 0x4c, 0x24, 0xf9, 0xcb, 0x59, 0x69, - 0x4a, 0x32, 0x14, 0xf5, 0x6b, 0xf0, 0x05, 0x61, 0xaf, 0xcd, 0x51, 0x72, 0x56, 0x4a, 0x70, 0x39, - 0xbe, 0xc7, 0xa9, 0x50, 0x39, 0x2d, 0x36, 0x72, 0x9f, 0xa6, 0x20, 0xb5, 0x27, 0x0a, 0xfb, 0xf3, - 0x97, 0xe4, 0xba, 0x46, 0x48, 0x4d, 0x7c, 0x69, 0x95, 0x56, 0x56, 0x28, 0xbe, 0x73, 0xfc, 0xf5, - 0xc8, 0x49, 0x46, 0xbc, 0x81, 0x06, 0x59, 0xa3, 0x81, 0x26, 0xc5, 0x7d, 0xa2, 0x1b, 0xf8, 0x00, - 0xa9, 0x82, 0x6d, 0xd5, 0x00, 0x0a, 0xbb, 0x7a, 0x29, 0x8b, 0x9a, 0xa5, 0xdc, 0xc7, 0x78, 0x08, - 0x42, 0x30, 0xb1, 0xd9, 0x81, 0x94, 0x34, 0x83, 0x71, 0x67, 0x82, 0xc2, 0xbb, 0xc9, 0xc0, 0x80, - 0x0b, 0x8b, 0xcd, 0xbf, 0x23, 0x3c, 0xa8, 0xef, 0xec, 0x7e, 0x43, 0xb8, 0x67, 0xad, 0xdd, 0x9b, - 0x6c, 0xd7, 0x7c, 0x2c, 0x2f, 0xbe, 0x8d, 0x84, 0x6d, 0x3f, 0x70, 0xe2, 0x13, 0x3a, 0x9e, 0x7d, - 0x74, 0x3a, 0xfb, 0xe8, 0xf7, 0xd9, 0x47, 0x5f, 0x2f, 0xbe, 0x73, 0xba, 0xf8, 0xce, 0xcf, 0x8b, - 0xef, 0xe0, 0xa7, 0x39, 0xbb, 0xd2, 0x22, 0xbe, 0x5f, 0x57, 0x5f, 0xea, 0xa9, 0x25, 0x7a, 0xb7, - 0xc8, 0xfe, 0xe7, 0xe7, 0xf5, 0xef, 0xc0, 0xb7, 0x54, 0xd1, 0x28, 0x2f, 0x15, 0x88, 0x92, 0x16, - 0x91, 0xb9, 0x19, 0x83, 0x0c, 0xca, 0x96, 0x5f, 0xf3, 0xa3, 0x33, 0x7d, 0xc3, 0xa1, 0x5c, 0x57, - 0x62, 0xc6, 0x86, 0xbc, 0xaa, 0xc2, 0x98, 0x08, 0xe4, 0xed, 0xec, 0x7d, 0xcf, 0xa8, 0x3c, 0xff, - 0x13, 0x00, 0x00, 0xff, 0xff, 0x82, 0xce, 0x78, 0xc7, 0x8f, 0x03, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// TraceServiceClient is the client API for TraceService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type TraceServiceClient interface { - Export(ctx context.Context, in *ExportTraceServiceRequest, opts ...grpc.CallOption) (*ExportTraceServiceResponse, error) -} - -type traceServiceClient struct { - cc *grpc.ClientConn -} - -func NewTraceServiceClient(cc *grpc.ClientConn) TraceServiceClient { - return &traceServiceClient{cc} -} - -func (c *traceServiceClient) Export(ctx context.Context, in *ExportTraceServiceRequest, opts ...grpc.CallOption) (*ExportTraceServiceResponse, error) { - out := new(ExportTraceServiceResponse) - err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// TraceServiceServer is the server API for TraceService service. -type TraceServiceServer interface { - Export(context.Context, *ExportTraceServiceRequest) (*ExportTraceServiceResponse, error) -} - -// UnimplementedTraceServiceServer can be embedded to have forward compatible implementations. -type UnimplementedTraceServiceServer struct { -} - -func (*UnimplementedTraceServiceServer) Export(ctx context.Context, req *ExportTraceServiceRequest) (*ExportTraceServiceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") -} - -func RegisterTraceServiceServer(s *grpc.Server, srv TraceServiceServer) { - s.RegisterService(&_TraceService_serviceDesc, srv) -} - -func _TraceService_Export_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ExportTraceServiceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TraceServiceServer).Export(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/opentelemetry.proto.collector.trace.v1.TraceService/Export", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TraceServiceServer).Export(ctx, req.(*ExportTraceServiceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _TraceService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "opentelemetry.proto.collector.trace.v1.TraceService", - HandlerType: (*TraceServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Export", - Handler: _TraceService_Export_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "opentelemetry/proto/collector/trace/v1/trace_service.proto", -} - -func (m *ExportTraceServiceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportTraceServiceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportTraceServiceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ResourceSpans) > 0 { - for iNdEx := len(m.ResourceSpans) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceSpans[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTraceService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExportTraceServiceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportTraceServiceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportTraceServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.PartialSuccess.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTraceService(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ExportTracePartialSuccess) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExportTracePartialSuccess) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExportTracePartialSuccess) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ErrorMessage) > 0 { - i -= len(m.ErrorMessage) - copy(dAtA[i:], m.ErrorMessage) - i = encodeVarintTraceService(dAtA, i, uint64(len(m.ErrorMessage))) - i-- - dAtA[i] = 0x12 - } - if m.RejectedSpans != 0 { - i = encodeVarintTraceService(dAtA, i, uint64(m.RejectedSpans)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintTraceService(dAtA []byte, offset int, v uint64) int { - offset -= sovTraceService(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ExportTraceServiceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceSpans) > 0 { - for _, e := range m.ResourceSpans { - l = e.Size() - n += 1 + l + sovTraceService(uint64(l)) - } - } - return n -} - -func (m *ExportTraceServiceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PartialSuccess.Size() - n += 1 + l + sovTraceService(uint64(l)) - return n -} - -func (m *ExportTracePartialSuccess) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RejectedSpans != 0 { - n += 1 + sovTraceService(uint64(m.RejectedSpans)) - } - l = len(m.ErrorMessage) - if l > 0 { - n += 1 + l + sovTraceService(uint64(l)) - } - return n -} - -func sovTraceService(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTraceService(x uint64) (n int) { - return sovTraceService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ExportTraceServiceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportTraceServiceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportTraceServiceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceSpans", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceSpans = append(m.ResourceSpans, &v1.ResourceSpans{}) - if err := m.ResourceSpans[len(m.ResourceSpans)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTraceService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportTraceServiceResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportTraceServiceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportTraceServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTraceService - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTraceService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PartialSuccess.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTraceService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExportTracePartialSuccess) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExportTracePartialSuccess: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExportTracePartialSuccess: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedSpans", wireType) - } - m.RejectedSpans = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RejectedSpans |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTraceService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTraceService - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTraceService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ErrorMessage = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTraceService(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTraceService - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTraceService(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTraceService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTraceService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTraceService - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTraceService - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTraceService - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTraceService - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTraceService = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTraceService = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTraceService = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/common/v1/common.pb.go b/pdata/internal/data/protogen/common/v1/common.pb.go deleted file mode 100644 index 179aa9d5d95..00000000000 --- a/pdata/internal/data/protogen/common/v1/common.pb.go +++ /dev/null @@ -1,2080 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/common/v1/common.proto - -package v1 - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// AnyValue is used to represent any type of attribute value. AnyValue may contain a -// primitive value such as a string or integer or it may contain an arbitrary nested -// object containing arrays, key-value lists and primitives. -type AnyValue struct { - // The value is one of the listed fields. It is valid for all values to be unspecified - // in which case this AnyValue is considered to be "empty". - // - // Types that are valid to be assigned to Value: - // *AnyValue_StringValue - // *AnyValue_BoolValue - // *AnyValue_IntValue - // *AnyValue_DoubleValue - // *AnyValue_ArrayValue - // *AnyValue_KvlistValue - // *AnyValue_BytesValue - Value isAnyValue_Value `protobuf_oneof:"value"` -} - -func (m *AnyValue) Reset() { *m = AnyValue{} } -func (m *AnyValue) String() string { return proto.CompactTextString(m) } -func (*AnyValue) ProtoMessage() {} -func (*AnyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{0} -} -func (m *AnyValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AnyValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AnyValue.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *AnyValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_AnyValue.Merge(m, src) -} -func (m *AnyValue) XXX_Size() int { - return m.Size() -} -func (m *AnyValue) XXX_DiscardUnknown() { - xxx_messageInfo_AnyValue.DiscardUnknown(m) -} - -var xxx_messageInfo_AnyValue proto.InternalMessageInfo - -type isAnyValue_Value interface { - isAnyValue_Value() - MarshalTo([]byte) (int, error) - Size() int -} - -type AnyValue_StringValue struct { - StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3,oneof" json:"string_value,omitempty"` -} -type AnyValue_BoolValue struct { - BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof" json:"bool_value,omitempty"` -} -type AnyValue_IntValue struct { - IntValue int64 `protobuf:"varint,3,opt,name=int_value,json=intValue,proto3,oneof" json:"int_value,omitempty"` -} -type AnyValue_DoubleValue struct { - DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue,proto3,oneof" json:"double_value,omitempty"` -} -type AnyValue_ArrayValue struct { - ArrayValue *ArrayValue `protobuf:"bytes,5,opt,name=array_value,json=arrayValue,proto3,oneof" json:"array_value,omitempty"` -} -type AnyValue_KvlistValue struct { - KvlistValue *KeyValueList `protobuf:"bytes,6,opt,name=kvlist_value,json=kvlistValue,proto3,oneof" json:"kvlist_value,omitempty"` -} -type AnyValue_BytesValue struct { - BytesValue []byte `protobuf:"bytes,7,opt,name=bytes_value,json=bytesValue,proto3,oneof" json:"bytes_value,omitempty"` -} - -func (*AnyValue_StringValue) isAnyValue_Value() {} -func (*AnyValue_BoolValue) isAnyValue_Value() {} -func (*AnyValue_IntValue) isAnyValue_Value() {} -func (*AnyValue_DoubleValue) isAnyValue_Value() {} -func (*AnyValue_ArrayValue) isAnyValue_Value() {} -func (*AnyValue_KvlistValue) isAnyValue_Value() {} -func (*AnyValue_BytesValue) isAnyValue_Value() {} - -func (m *AnyValue) GetValue() isAnyValue_Value { - if m != nil { - return m.Value - } - return nil -} - -func (m *AnyValue) GetStringValue() string { - if x, ok := m.GetValue().(*AnyValue_StringValue); ok { - return x.StringValue - } - return "" -} - -func (m *AnyValue) GetBoolValue() bool { - if x, ok := m.GetValue().(*AnyValue_BoolValue); ok { - return x.BoolValue - } - return false -} - -func (m *AnyValue) GetIntValue() int64 { - if x, ok := m.GetValue().(*AnyValue_IntValue); ok { - return x.IntValue - } - return 0 -} - -func (m *AnyValue) GetDoubleValue() float64 { - if x, ok := m.GetValue().(*AnyValue_DoubleValue); ok { - return x.DoubleValue - } - return 0 -} - -func (m *AnyValue) GetArrayValue() *ArrayValue { - if x, ok := m.GetValue().(*AnyValue_ArrayValue); ok { - return x.ArrayValue - } - return nil -} - -func (m *AnyValue) GetKvlistValue() *KeyValueList { - if x, ok := m.GetValue().(*AnyValue_KvlistValue); ok { - return x.KvlistValue - } - return nil -} - -func (m *AnyValue) GetBytesValue() []byte { - if x, ok := m.GetValue().(*AnyValue_BytesValue); ok { - return x.BytesValue - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*AnyValue) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*AnyValue_StringValue)(nil), - (*AnyValue_BoolValue)(nil), - (*AnyValue_IntValue)(nil), - (*AnyValue_DoubleValue)(nil), - (*AnyValue_ArrayValue)(nil), - (*AnyValue_KvlistValue)(nil), - (*AnyValue_BytesValue)(nil), - } -} - -// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message -// since oneof in AnyValue does not allow repeated fields. -type ArrayValue struct { - // Array of values. The array may be empty (contain 0 elements). - Values []AnyValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values"` -} - -func (m *ArrayValue) Reset() { *m = ArrayValue{} } -func (m *ArrayValue) String() string { return proto.CompactTextString(m) } -func (*ArrayValue) ProtoMessage() {} -func (*ArrayValue) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{1} -} -func (m *ArrayValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ArrayValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ArrayValue.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ArrayValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_ArrayValue.Merge(m, src) -} -func (m *ArrayValue) XXX_Size() int { - return m.Size() -} -func (m *ArrayValue) XXX_DiscardUnknown() { - xxx_messageInfo_ArrayValue.DiscardUnknown(m) -} - -var xxx_messageInfo_ArrayValue proto.InternalMessageInfo - -func (m *ArrayValue) GetValues() []AnyValue { - if m != nil { - return m.Values - } - return nil -} - -// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message -// since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need -// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to -// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches -// are semantically equivalent. -type KeyValueList struct { - // A collection of key/value pairs of key-value pairs. The list may be empty (may - // contain 0 elements). - // The keys MUST be unique (it is not allowed to have more than one - // value with the same key). - Values []KeyValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values"` -} - -func (m *KeyValueList) Reset() { *m = KeyValueList{} } -func (m *KeyValueList) String() string { return proto.CompactTextString(m) } -func (*KeyValueList) ProtoMessage() {} -func (*KeyValueList) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{2} -} -func (m *KeyValueList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *KeyValueList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_KeyValueList.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *KeyValueList) XXX_Merge(src proto.Message) { - xxx_messageInfo_KeyValueList.Merge(m, src) -} -func (m *KeyValueList) XXX_Size() int { - return m.Size() -} -func (m *KeyValueList) XXX_DiscardUnknown() { - xxx_messageInfo_KeyValueList.DiscardUnknown(m) -} - -var xxx_messageInfo_KeyValueList proto.InternalMessageInfo - -func (m *KeyValueList) GetValues() []KeyValue { - if m != nil { - return m.Values - } - return nil -} - -// KeyValue is a key-value pair that is used to store Span attributes, Link -// attributes, etc. -type KeyValue struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value AnyValue `protobuf:"bytes,2,opt,name=value,proto3" json:"value"` -} - -func (m *KeyValue) Reset() { *m = KeyValue{} } -func (m *KeyValue) String() string { return proto.CompactTextString(m) } -func (*KeyValue) ProtoMessage() {} -func (*KeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{3} -} -func (m *KeyValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *KeyValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_KeyValue.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *KeyValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_KeyValue.Merge(m, src) -} -func (m *KeyValue) XXX_Size() int { - return m.Size() -} -func (m *KeyValue) XXX_DiscardUnknown() { - xxx_messageInfo_KeyValue.DiscardUnknown(m) -} - -var xxx_messageInfo_KeyValue proto.InternalMessageInfo - -func (m *KeyValue) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *KeyValue) GetValue() AnyValue { - if m != nil { - return m.Value - } - return AnyValue{} -} - -// InstrumentationScope is a message representing the instrumentation scope information -// such as the fully qualified name and version. -type InstrumentationScope struct { - // An empty instrumentation scope name means the name is unknown. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - // Additional attributes that describe the scope. [Optional]. - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - Attributes []KeyValue `protobuf:"bytes,3,rep,name=attributes,proto3" json:"attributes"` - DroppedAttributesCount uint32 `protobuf:"varint,4,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` -} - -func (m *InstrumentationScope) Reset() { *m = InstrumentationScope{} } -func (m *InstrumentationScope) String() string { return proto.CompactTextString(m) } -func (*InstrumentationScope) ProtoMessage() {} -func (*InstrumentationScope) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{4} -} -func (m *InstrumentationScope) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstrumentationScope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstrumentationScope.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstrumentationScope) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstrumentationScope.Merge(m, src) -} -func (m *InstrumentationScope) XXX_Size() int { - return m.Size() -} -func (m *InstrumentationScope) XXX_DiscardUnknown() { - xxx_messageInfo_InstrumentationScope.DiscardUnknown(m) -} - -var xxx_messageInfo_InstrumentationScope proto.InternalMessageInfo - -func (m *InstrumentationScope) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *InstrumentationScope) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - -func (m *InstrumentationScope) GetAttributes() []KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *InstrumentationScope) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -// A reference to an Entity. -// Entity represents an object of interest associated with produced telemetry: e.g spans, metrics, profiles, or logs. -// -// Status: [Development] -type EntityRef struct { - // The Schema URL, if known. This is the identifier of the Schema that the entity data - // is recorded in. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // - // This schema_url applies to the data in this message and to the Resource attributes - // referenced by id_keys and description_keys. - // TODO: discuss if we are happy with this somewhat complicated definition of what - // the schema_url applies to. - // - // This field obsoletes the schema_url field in ResourceMetrics/ResourceSpans/ResourceLogs. - SchemaUrl string `protobuf:"bytes,1,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` - // Defines the type of the entity. MUST not change during the lifetime of the entity. - // For example: "service" or "host". This field is required and MUST not be empty - // for valid entities. - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - // Attribute Keys that identify the entity. - // MUST not change during the lifetime of the entity. The Id must contain at least one attribute. - // These keys MUST exist in the containing {message}.attributes. - IdKeys []string `protobuf:"bytes,3,rep,name=id_keys,json=idKeys,proto3" json:"id_keys,omitempty"` - // Descriptive (non-identifying) attribute keys of the entity. - // MAY change over the lifetime of the entity. MAY be empty. - // These attribute keys are not part of entity's identity. - // These keys MUST exist in the containing {message}.attributes. - DescriptionKeys []string `protobuf:"bytes,4,rep,name=description_keys,json=descriptionKeys,proto3" json:"description_keys,omitempty"` -} - -func (m *EntityRef) Reset() { *m = EntityRef{} } -func (m *EntityRef) String() string { return proto.CompactTextString(m) } -func (*EntityRef) ProtoMessage() {} -func (*EntityRef) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{5} -} -func (m *EntityRef) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EntityRef) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EntityRef.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EntityRef) XXX_Merge(src proto.Message) { - xxx_messageInfo_EntityRef.Merge(m, src) -} -func (m *EntityRef) XXX_Size() int { - return m.Size() -} -func (m *EntityRef) XXX_DiscardUnknown() { - xxx_messageInfo_EntityRef.DiscardUnknown(m) -} - -var xxx_messageInfo_EntityRef proto.InternalMessageInfo - -func (m *EntityRef) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -func (m *EntityRef) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *EntityRef) GetIdKeys() []string { - if m != nil { - return m.IdKeys - } - return nil -} - -func (m *EntityRef) GetDescriptionKeys() []string { - if m != nil { - return m.DescriptionKeys - } - return nil -} - -func init() { - proto.RegisterType((*AnyValue)(nil), "opentelemetry.proto.common.v1.AnyValue") - proto.RegisterType((*ArrayValue)(nil), "opentelemetry.proto.common.v1.ArrayValue") - proto.RegisterType((*KeyValueList)(nil), "opentelemetry.proto.common.v1.KeyValueList") - proto.RegisterType((*KeyValue)(nil), "opentelemetry.proto.common.v1.KeyValue") - proto.RegisterType((*InstrumentationScope)(nil), "opentelemetry.proto.common.v1.InstrumentationScope") - proto.RegisterType((*EntityRef)(nil), "opentelemetry.proto.common.v1.EntityRef") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/common/v1/common.proto", fileDescriptor_62ba46dcb97aa817) -} - -var fileDescriptor_62ba46dcb97aa817 = []byte{ - // 608 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4f, 0x4f, 0x13, 0x41, - 0x14, 0xdf, 0xa1, 0xa5, 0xed, 0xbe, 0xd6, 0x48, 0x26, 0x44, 0x1b, 0x93, 0x96, 0xb5, 0x1e, 0x5c, - 0x34, 0x69, 0x03, 0x5e, 0xbc, 0x52, 0x24, 0xa9, 0x01, 0x23, 0x59, 0x84, 0x83, 0x97, 0x66, 0xdb, - 0x7d, 0xd6, 0x09, 0xdb, 0x99, 0xcd, 0xec, 0xb4, 0xc9, 0x5e, 0xfd, 0x04, 0x7e, 0x0e, 0x2f, 0x7e, - 0x0d, 0x2e, 0x26, 0x1c, 0x3d, 0x19, 0x02, 0x5f, 0xc4, 0xcc, 0x9f, 0x16, 0xe4, 0x00, 0xc1, 0xdb, - 0x7b, 0xbf, 0xf7, 0x7b, 0xbf, 0xf7, 0x7e, 0x33, 0x93, 0x81, 0x57, 0x22, 0x43, 0xae, 0x30, 0xc5, - 0x29, 0x2a, 0x59, 0xf4, 0x32, 0x29, 0x94, 0xe8, 0x8d, 0xc5, 0x74, 0x2a, 0x78, 0x6f, 0xbe, 0xe5, - 0xa2, 0xae, 0x81, 0x69, 0xeb, 0x1f, 0xae, 0x05, 0xbb, 0x8e, 0x31, 0xdf, 0x7a, 0xb6, 0x3e, 0x11, - 0x13, 0x61, 0x05, 0x74, 0x64, 0xeb, 0x9d, 0x8b, 0x15, 0xa8, 0xed, 0xf0, 0xe2, 0x24, 0x4e, 0x67, - 0x48, 0x5f, 0x40, 0x23, 0x57, 0x92, 0xf1, 0xc9, 0x70, 0xae, 0xf3, 0x26, 0x09, 0x48, 0xe8, 0x0f, - 0xbc, 0xa8, 0x6e, 0x51, 0x4b, 0xda, 0x00, 0x18, 0x09, 0x91, 0x3a, 0xca, 0x4a, 0x40, 0xc2, 0xda, - 0xc0, 0x8b, 0x7c, 0x8d, 0x59, 0x42, 0x0b, 0x7c, 0xc6, 0x95, 0xab, 0x97, 0x02, 0x12, 0x96, 0x06, - 0x5e, 0x54, 0x63, 0x5c, 0x2d, 0x87, 0x24, 0x62, 0x36, 0x4a, 0xd1, 0x31, 0xca, 0x01, 0x09, 0x89, - 0x1e, 0x62, 0x51, 0x4b, 0x3a, 0x80, 0x7a, 0x2c, 0x65, 0x5c, 0x38, 0xce, 0x6a, 0x40, 0xc2, 0xfa, - 0xf6, 0x66, 0xf7, 0x4e, 0x87, 0xdd, 0x1d, 0xdd, 0x61, 0xfa, 0x07, 0x5e, 0x04, 0xf1, 0x32, 0xa3, - 0x87, 0xd0, 0x38, 0x9d, 0xa7, 0x2c, 0x5f, 0x2c, 0x55, 0x31, 0x72, 0xaf, 0xef, 0x91, 0xdb, 0x47, - 0xdb, 0x7e, 0xc0, 0x72, 0xa5, 0xf7, 0xb3, 0x12, 0x56, 0xf1, 0x39, 0xd4, 0x47, 0x85, 0xc2, 0xdc, - 0x09, 0x56, 0x03, 0x12, 0x36, 0xf4, 0x50, 0x03, 0x1a, 0x4a, 0xbf, 0x0a, 0xab, 0xa6, 0xd8, 0x39, - 0x02, 0xb8, 0xde, 0x8c, 0xee, 0x41, 0xc5, 0xc0, 0x79, 0x93, 0x04, 0xa5, 0xb0, 0xbe, 0xfd, 0xf2, - 0x3e, 0x53, 0xee, 0x72, 0xfa, 0xe5, 0xb3, 0x3f, 0x1b, 0x5e, 0xe4, 0x9a, 0x3b, 0xc7, 0xd0, 0xb8, - 0xb9, 0xdf, 0x83, 0x65, 0x17, 0xcd, 0xb7, 0x64, 0x63, 0xa8, 0x2d, 0x2a, 0x74, 0x0d, 0x4a, 0xa7, - 0x58, 0xd8, 0x47, 0x10, 0xe9, 0x90, 0xee, 0x3a, 0x4b, 0xe6, 0xd6, 0x1f, 0xbc, 0xba, 0x3b, 0x8e, - 0x5f, 0x04, 0xd6, 0xdf, 0xf3, 0x5c, 0xc9, 0xd9, 0x14, 0xb9, 0x8a, 0x15, 0x13, 0xfc, 0x68, 0x2c, - 0x32, 0xa4, 0x14, 0xca, 0x3c, 0x9e, 0xba, 0x57, 0x17, 0x99, 0x98, 0x36, 0xa1, 0x3a, 0x47, 0x99, - 0x33, 0xc1, 0xcd, 0x4c, 0x3f, 0x5a, 0xa4, 0xf4, 0x03, 0x40, 0xac, 0x94, 0x64, 0xa3, 0x99, 0xc2, - 0xbc, 0x59, 0xfa, 0x1f, 0xd3, 0x37, 0x04, 0xe8, 0x5b, 0x68, 0x26, 0x52, 0x64, 0x19, 0x26, 0xc3, - 0x6b, 0x74, 0x38, 0x16, 0x33, 0xae, 0xcc, 0x0b, 0x7d, 0x14, 0x3d, 0x71, 0xf5, 0x9d, 0x65, 0x79, - 0x57, 0x57, 0x3b, 0xdf, 0x08, 0xf8, 0x7b, 0x5c, 0x31, 0x55, 0x44, 0xf8, 0x85, 0xb6, 0x00, 0xf2, - 0xf1, 0x57, 0x9c, 0xc6, 0xc3, 0x99, 0x4c, 0x9d, 0x15, 0xdf, 0x22, 0xc7, 0x32, 0xd5, 0x1e, 0x55, - 0x91, 0xa1, 0x33, 0x63, 0x62, 0xfa, 0x14, 0xaa, 0x2c, 0x19, 0x9e, 0x62, 0x61, 0x6d, 0xf8, 0x51, - 0x85, 0x25, 0xfb, 0x58, 0xe4, 0x74, 0x13, 0xd6, 0x12, 0xcc, 0xc7, 0x92, 0x65, 0xfa, 0x90, 0x2c, - 0xa3, 0x6c, 0x18, 0x8f, 0x6f, 0xe0, 0x9a, 0xda, 0xff, 0x49, 0xce, 0x2e, 0xdb, 0xe4, 0xfc, 0xb2, - 0x4d, 0x2e, 0x2e, 0xdb, 0xe4, 0xfb, 0x55, 0xdb, 0x3b, 0xbf, 0x6a, 0x7b, 0xbf, 0xaf, 0xda, 0x1e, - 0x04, 0x4c, 0xdc, 0x7d, 0x2c, 0xfd, 0xfa, 0xae, 0x09, 0x0f, 0x35, 0x7c, 0x48, 0x3e, 0xbf, 0x9b, - 0xdc, 0x6e, 0x60, 0xfa, 0xcf, 0x49, 0x53, 0x1c, 0x2b, 0x21, 0x7b, 0x59, 0x12, 0xab, 0xb8, 0xc7, - 0xb8, 0x42, 0xc9, 0xe3, 0xb4, 0x67, 0x32, 0xa3, 0x38, 0x41, 0x7e, 0xfd, 0x35, 0xfd, 0x58, 0x69, - 0x7d, 0xcc, 0x90, 0x7f, 0x5a, 0x6a, 0x18, 0xf5, 0xae, 0x9d, 0xd4, 0x3d, 0xd9, 0x1a, 0x55, 0x4c, - 0xcf, 0x9b, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x8b, 0xd4, 0x3b, 0xe2, 0x04, 0x00, 0x00, -} - -func (m *AnyValue) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AnyValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Value != nil { - { - size := m.Value.Size() - i -= size - if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *AnyValue_StringValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_StringValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= len(m.StringValue) - copy(dAtA[i:], m.StringValue) - i = encodeVarintCommon(dAtA, i, uint64(len(m.StringValue))) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} -func (m *AnyValue_BoolValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_BoolValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i-- - if m.BoolValue { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - return len(dAtA) - i, nil -} -func (m *AnyValue_IntValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_IntValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i = encodeVarintCommon(dAtA, i, uint64(m.IntValue)) - i-- - dAtA[i] = 0x18 - return len(dAtA) - i, nil -} -func (m *AnyValue_DoubleValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_DoubleValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.DoubleValue)))) - i-- - dAtA[i] = 0x21 - return len(dAtA) - i, nil -} -func (m *AnyValue_ArrayValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_ArrayValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ArrayValue != nil { - { - size, err := m.ArrayValue.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - return len(dAtA) - i, nil -} -func (m *AnyValue_KvlistValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_KvlistValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.KvlistValue != nil { - { - size, err := m.KvlistValue.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - return len(dAtA) - i, nil -} -func (m *AnyValue_BytesValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AnyValue_BytesValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.BytesValue != nil { - i -= len(m.BytesValue) - copy(dAtA[i:], m.BytesValue) - i = encodeVarintCommon(dAtA, i, uint64(len(m.BytesValue))) - i-- - dAtA[i] = 0x3a - } - return len(dAtA) - i, nil -} -func (m *ArrayValue) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ArrayValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ArrayValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Values) > 0 { - for iNdEx := len(m.Values) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Values[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *KeyValueList) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KeyValueList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *KeyValueList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Values) > 0 { - for iNdEx := len(m.Values) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Values[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *KeyValue) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KeyValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *KeyValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InstrumentationScope) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstrumentationScope) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstrumentationScope) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.DroppedAttributesCount != 0 { - i = encodeVarintCommon(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x20 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommon(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EntityRef) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EntityRef) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EntityRef) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DescriptionKeys) > 0 { - for iNdEx := len(m.DescriptionKeys) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.DescriptionKeys[iNdEx]) - copy(dAtA[i:], m.DescriptionKeys[iNdEx]) - i = encodeVarintCommon(dAtA, i, uint64(len(m.DescriptionKeys[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if len(m.IdKeys) > 0 { - for iNdEx := len(m.IdKeys) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.IdKeys[iNdEx]) - copy(dAtA[i:], m.IdKeys[iNdEx]) - i = encodeVarintCommon(dAtA, i, uint64(len(m.IdKeys[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintCommon(dAtA, i, uint64(len(m.Type))) - i-- - dAtA[i] = 0x12 - } - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintCommon(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintCommon(dAtA []byte, offset int, v uint64) int { - offset -= sovCommon(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AnyValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Value != nil { - n += m.Value.Size() - } - return n -} - -func (m *AnyValue_StringValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StringValue) - n += 1 + l + sovCommon(uint64(l)) - return n -} -func (m *AnyValue_BoolValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 2 - return n -} -func (m *AnyValue_IntValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 1 + sovCommon(uint64(m.IntValue)) - return n -} -func (m *AnyValue_DoubleValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *AnyValue_ArrayValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ArrayValue != nil { - l = m.ArrayValue.Size() - n += 1 + l + sovCommon(uint64(l)) - } - return n -} -func (m *AnyValue_KvlistValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.KvlistValue != nil { - l = m.KvlistValue.Size() - n += 1 + l + sovCommon(uint64(l)) - } - return n -} -func (m *AnyValue_BytesValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BytesValue != nil { - l = len(m.BytesValue) - n += 1 + l + sovCommon(uint64(l)) - } - return n -} -func (m *ArrayValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Values) > 0 { - for _, e := range m.Values { - l = e.Size() - n += 1 + l + sovCommon(uint64(l)) - } - } - return n -} - -func (m *KeyValueList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Values) > 0 { - for _, e := range m.Values { - l = e.Size() - n += 1 + l + sovCommon(uint64(l)) - } - } - return n -} - -func (m *KeyValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - l = m.Value.Size() - n += 1 + l + sovCommon(uint64(l)) - return n -} - -func (m *InstrumentationScope) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - l = len(m.Version) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovCommon(uint64(l)) - } - } - if m.DroppedAttributesCount != 0 { - n += 1 + sovCommon(uint64(m.DroppedAttributesCount)) - } - return n -} - -func (m *EntityRef) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - l = len(m.Type) - if l > 0 { - n += 1 + l + sovCommon(uint64(l)) - } - if len(m.IdKeys) > 0 { - for _, s := range m.IdKeys { - l = len(s) - n += 1 + l + sovCommon(uint64(l)) - } - } - if len(m.DescriptionKeys) > 0 { - for _, s := range m.DescriptionKeys { - l = len(s) - n += 1 + l + sovCommon(uint64(l)) - } - } - return n -} - -func sovCommon(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozCommon(x uint64) (n int) { - return sovCommon(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *AnyValue) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AnyValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AnyValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StringValue", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = &AnyValue_StringValue{string(dAtA[iNdEx:postIndex])} - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BoolValue", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - b := bool(v != 0) - m.Value = &AnyValue_BoolValue{b} - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IntValue", wireType) - } - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Value = &AnyValue_IntValue{v} - case 4: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field DoubleValue", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = &AnyValue_DoubleValue{float64(math.Float64frombits(v))} - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ArrayValue", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ArrayValue{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &AnyValue_ArrayValue{v} - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KvlistValue", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &KeyValueList{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &AnyValue_KvlistValue{v} - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BytesValue", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Value = &AnyValue_BytesValue{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ArrayValue) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ArrayValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ArrayValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Values = append(m.Values, AnyValue{}) - if err := m.Values[len(m.Values)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KeyValueList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KeyValueList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KeyValueList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Values = append(m.Values, KeyValue{}) - if err := m.Values[len(m.Values)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KeyValue) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KeyValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KeyValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstrumentationScope) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstrumentationScope: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstrumentationScope: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Version = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EntityRef) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EntityRef: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EntityRef: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IdKeys", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.IdKeys = append(m.IdKeys, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DescriptionKeys", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthCommon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DescriptionKeys = append(m.DescriptionKeys, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommon(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCommon - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipCommon(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommon - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommon - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommon - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthCommon - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCommon - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthCommon - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthCommon = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCommon = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCommon = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/logs/v1/logs.pb.go b/pdata/internal/data/protogen/logs/v1/logs.pb.go deleted file mode 100644 index da266d167d2..00000000000 --- a/pdata/internal/data/protogen/logs/v1/logs.pb.go +++ /dev/null @@ -1,1834 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/logs/v1/logs.proto - -package v1 - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - - go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" - v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Possible values for LogRecord.SeverityNumber. -type SeverityNumber int32 - -const ( - // UNSPECIFIED is the default SeverityNumber, it MUST NOT be used. - SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED SeverityNumber = 0 - SeverityNumber_SEVERITY_NUMBER_TRACE SeverityNumber = 1 - SeverityNumber_SEVERITY_NUMBER_TRACE2 SeverityNumber = 2 - SeverityNumber_SEVERITY_NUMBER_TRACE3 SeverityNumber = 3 - SeverityNumber_SEVERITY_NUMBER_TRACE4 SeverityNumber = 4 - SeverityNumber_SEVERITY_NUMBER_DEBUG SeverityNumber = 5 - SeverityNumber_SEVERITY_NUMBER_DEBUG2 SeverityNumber = 6 - SeverityNumber_SEVERITY_NUMBER_DEBUG3 SeverityNumber = 7 - SeverityNumber_SEVERITY_NUMBER_DEBUG4 SeverityNumber = 8 - SeverityNumber_SEVERITY_NUMBER_INFO SeverityNumber = 9 - SeverityNumber_SEVERITY_NUMBER_INFO2 SeverityNumber = 10 - SeverityNumber_SEVERITY_NUMBER_INFO3 SeverityNumber = 11 - SeverityNumber_SEVERITY_NUMBER_INFO4 SeverityNumber = 12 - SeverityNumber_SEVERITY_NUMBER_WARN SeverityNumber = 13 - SeverityNumber_SEVERITY_NUMBER_WARN2 SeverityNumber = 14 - SeverityNumber_SEVERITY_NUMBER_WARN3 SeverityNumber = 15 - SeverityNumber_SEVERITY_NUMBER_WARN4 SeverityNumber = 16 - SeverityNumber_SEVERITY_NUMBER_ERROR SeverityNumber = 17 - SeverityNumber_SEVERITY_NUMBER_ERROR2 SeverityNumber = 18 - SeverityNumber_SEVERITY_NUMBER_ERROR3 SeverityNumber = 19 - SeverityNumber_SEVERITY_NUMBER_ERROR4 SeverityNumber = 20 - SeverityNumber_SEVERITY_NUMBER_FATAL SeverityNumber = 21 - SeverityNumber_SEVERITY_NUMBER_FATAL2 SeverityNumber = 22 - SeverityNumber_SEVERITY_NUMBER_FATAL3 SeverityNumber = 23 - SeverityNumber_SEVERITY_NUMBER_FATAL4 SeverityNumber = 24 -) - -var SeverityNumber_name = map[int32]string{ - 0: "SEVERITY_NUMBER_UNSPECIFIED", - 1: "SEVERITY_NUMBER_TRACE", - 2: "SEVERITY_NUMBER_TRACE2", - 3: "SEVERITY_NUMBER_TRACE3", - 4: "SEVERITY_NUMBER_TRACE4", - 5: "SEVERITY_NUMBER_DEBUG", - 6: "SEVERITY_NUMBER_DEBUG2", - 7: "SEVERITY_NUMBER_DEBUG3", - 8: "SEVERITY_NUMBER_DEBUG4", - 9: "SEVERITY_NUMBER_INFO", - 10: "SEVERITY_NUMBER_INFO2", - 11: "SEVERITY_NUMBER_INFO3", - 12: "SEVERITY_NUMBER_INFO4", - 13: "SEVERITY_NUMBER_WARN", - 14: "SEVERITY_NUMBER_WARN2", - 15: "SEVERITY_NUMBER_WARN3", - 16: "SEVERITY_NUMBER_WARN4", - 17: "SEVERITY_NUMBER_ERROR", - 18: "SEVERITY_NUMBER_ERROR2", - 19: "SEVERITY_NUMBER_ERROR3", - 20: "SEVERITY_NUMBER_ERROR4", - 21: "SEVERITY_NUMBER_FATAL", - 22: "SEVERITY_NUMBER_FATAL2", - 23: "SEVERITY_NUMBER_FATAL3", - 24: "SEVERITY_NUMBER_FATAL4", -} - -var SeverityNumber_value = map[string]int32{ - "SEVERITY_NUMBER_UNSPECIFIED": 0, - "SEVERITY_NUMBER_TRACE": 1, - "SEVERITY_NUMBER_TRACE2": 2, - "SEVERITY_NUMBER_TRACE3": 3, - "SEVERITY_NUMBER_TRACE4": 4, - "SEVERITY_NUMBER_DEBUG": 5, - "SEVERITY_NUMBER_DEBUG2": 6, - "SEVERITY_NUMBER_DEBUG3": 7, - "SEVERITY_NUMBER_DEBUG4": 8, - "SEVERITY_NUMBER_INFO": 9, - "SEVERITY_NUMBER_INFO2": 10, - "SEVERITY_NUMBER_INFO3": 11, - "SEVERITY_NUMBER_INFO4": 12, - "SEVERITY_NUMBER_WARN": 13, - "SEVERITY_NUMBER_WARN2": 14, - "SEVERITY_NUMBER_WARN3": 15, - "SEVERITY_NUMBER_WARN4": 16, - "SEVERITY_NUMBER_ERROR": 17, - "SEVERITY_NUMBER_ERROR2": 18, - "SEVERITY_NUMBER_ERROR3": 19, - "SEVERITY_NUMBER_ERROR4": 20, - "SEVERITY_NUMBER_FATAL": 21, - "SEVERITY_NUMBER_FATAL2": 22, - "SEVERITY_NUMBER_FATAL3": 23, - "SEVERITY_NUMBER_FATAL4": 24, -} - -func (x SeverityNumber) String() string { - return proto.EnumName(SeverityNumber_name, int32(x)) -} - -func (SeverityNumber) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d1c030a3ec7e961e, []int{0} -} - -// LogRecordFlags represents constants used to interpret the -// LogRecord.flags field, which is protobuf 'fixed32' type and is to -// be used as bit-fields. Each non-zero value defined in this enum is -// a bit-mask. To extract the bit-field, for example, use an -// expression like: -// -// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK) -type LogRecordFlags int32 - -const ( - // The zero value for the enum. Should not be used for comparisons. - // Instead use bitwise "and" with the appropriate mask as shown above. - LogRecordFlags_LOG_RECORD_FLAGS_DO_NOT_USE LogRecordFlags = 0 - // Bits 0-7 are used for trace flags. - LogRecordFlags_LOG_RECORD_FLAGS_TRACE_FLAGS_MASK LogRecordFlags = 255 -) - -var LogRecordFlags_name = map[int32]string{ - 0: "LOG_RECORD_FLAGS_DO_NOT_USE", - 255: "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK", -} - -var LogRecordFlags_value = map[string]int32{ - "LOG_RECORD_FLAGS_DO_NOT_USE": 0, - "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK": 255, -} - -func (x LogRecordFlags) String() string { - return proto.EnumName(LogRecordFlags_name, int32(x)) -} - -func (LogRecordFlags) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d1c030a3ec7e961e, []int{1} -} - -// LogsData represents the logs data that can be stored in a persistent storage, -// OR can be embedded by other protocols that transfer OTLP logs data but do not -// implement the OTLP protocol. -// -// The main difference between this message and collector protocol is that -// in this message there will not be any "control" or "metadata" specific to -// OTLP protocol. -// -// When new fields are added into this message, the OTLP request MUST be updated -// as well. -type LogsData struct { - // An array of ResourceLogs. - // For data coming from a single resource this array will typically contain - // one element. Intermediary nodes that receive data from multiple origins - // typically batch the data before forwarding further and in that case this - // array will contain multiple elements. - ResourceLogs []*ResourceLogs `protobuf:"bytes,1,rep,name=resource_logs,json=resourceLogs,proto3" json:"resource_logs,omitempty"` -} - -func (m *LogsData) Reset() { *m = LogsData{} } -func (m *LogsData) String() string { return proto.CompactTextString(m) } -func (*LogsData) ProtoMessage() {} -func (*LogsData) Descriptor() ([]byte, []int) { - return fileDescriptor_d1c030a3ec7e961e, []int{0} -} -func (m *LogsData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LogsData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LogsData.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LogsData) XXX_Merge(src proto.Message) { - xxx_messageInfo_LogsData.Merge(m, src) -} -func (m *LogsData) XXX_Size() int { - return m.Size() -} -func (m *LogsData) XXX_DiscardUnknown() { - xxx_messageInfo_LogsData.DiscardUnknown(m) -} - -var xxx_messageInfo_LogsData proto.InternalMessageInfo - -func (m *LogsData) GetResourceLogs() []*ResourceLogs { - if m != nil { - return m.ResourceLogs - } - return nil -} - -// A collection of ScopeLogs from a Resource. -type ResourceLogs struct { - DeprecatedScopeLogs []*ScopeLogs `protobuf:"bytes,1000,rep,name=deprecated_scope_logs,json=deprecatedScopeLogs,proto3" json:"deprecated_scope_logs,omitempty"` - // The resource for the logs in this message. - // If this field is not set then resource info is unknown. - Resource v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource"` - // A list of ScopeLogs that originate from a resource. - ScopeLogs []*ScopeLogs `protobuf:"bytes,2,rep,name=scope_logs,json=scopeLogs,proto3" json:"scope_logs,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the resource data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to the data in the "resource" field. It does not apply - // to the data in the "scope_logs" field which have their own schema_url field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ResourceLogs) Reset() { *m = ResourceLogs{} } -func (m *ResourceLogs) String() string { return proto.CompactTextString(m) } -func (*ResourceLogs) ProtoMessage() {} -func (*ResourceLogs) Descriptor() ([]byte, []int) { - return fileDescriptor_d1c030a3ec7e961e, []int{1} -} -func (m *ResourceLogs) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ResourceLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ResourceLogs.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ResourceLogs) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResourceLogs.Merge(m, src) -} -func (m *ResourceLogs) XXX_Size() int { - return m.Size() -} -func (m *ResourceLogs) XXX_DiscardUnknown() { - xxx_messageInfo_ResourceLogs.DiscardUnknown(m) -} - -var xxx_messageInfo_ResourceLogs proto.InternalMessageInfo - -func (m *ResourceLogs) GetDeprecatedScopeLogs() []*ScopeLogs { - if m != nil { - return m.DeprecatedScopeLogs - } - return nil -} - -func (m *ResourceLogs) GetResource() v1.Resource { - if m != nil { - return m.Resource - } - return v1.Resource{} -} - -func (m *ResourceLogs) GetScopeLogs() []*ScopeLogs { - if m != nil { - return m.ScopeLogs - } - return nil -} - -func (m *ResourceLogs) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// A collection of Logs produced by a Scope. -type ScopeLogs struct { - // The instrumentation scope information for the logs in this message. - // Semantically when InstrumentationScope isn't set, it is equivalent with - // an empty instrumentation scope name (unknown). - Scope v11.InstrumentationScope `protobuf:"bytes,1,opt,name=scope,proto3" json:"scope"` - // A list of log records. - LogRecords []*LogRecord `protobuf:"bytes,2,rep,name=log_records,json=logRecords,proto3" json:"log_records,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the log data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to all logs in the "logs" field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ScopeLogs) Reset() { *m = ScopeLogs{} } -func (m *ScopeLogs) String() string { return proto.CompactTextString(m) } -func (*ScopeLogs) ProtoMessage() {} -func (*ScopeLogs) Descriptor() ([]byte, []int) { - return fileDescriptor_d1c030a3ec7e961e, []int{2} -} -func (m *ScopeLogs) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ScopeLogs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ScopeLogs.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ScopeLogs) XXX_Merge(src proto.Message) { - xxx_messageInfo_ScopeLogs.Merge(m, src) -} -func (m *ScopeLogs) XXX_Size() int { - return m.Size() -} -func (m *ScopeLogs) XXX_DiscardUnknown() { - xxx_messageInfo_ScopeLogs.DiscardUnknown(m) -} - -var xxx_messageInfo_ScopeLogs proto.InternalMessageInfo - -func (m *ScopeLogs) GetScope() v11.InstrumentationScope { - if m != nil { - return m.Scope - } - return v11.InstrumentationScope{} -} - -func (m *ScopeLogs) GetLogRecords() []*LogRecord { - if m != nil { - return m.LogRecords - } - return nil -} - -func (m *ScopeLogs) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// A log record according to OpenTelemetry Log Data Model: -// https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md -type LogRecord struct { - // time_unix_nano is the time when the event occurred. - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // Value of 0 indicates unknown or missing timestamp. - TimeUnixNano uint64 `protobuf:"fixed64,1,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // Time when the event was observed by the collection system. - // For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) - // this timestamp is typically set at the generation time and is equal to Timestamp. - // For events originating externally and collected by OpenTelemetry (e.g. using - // Collector) this is the time when OpenTelemetry's code observed the event measured - // by the clock of the OpenTelemetry code. This field MUST be set once the event is - // observed by OpenTelemetry. - // - // For converting OpenTelemetry log data to formats that support only one timestamp or - // when receiving OpenTelemetry log data by recipients that support only one timestamp - // internally the following logic is recommended: - // - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // Value of 0 indicates unknown or missing timestamp. - ObservedTimeUnixNano uint64 `protobuf:"fixed64,11,opt,name=observed_time_unix_nano,json=observedTimeUnixNano,proto3" json:"observed_time_unix_nano,omitempty"` - // Numerical value of the severity, normalized to values described in Log Data Model. - // [Optional]. - SeverityNumber SeverityNumber `protobuf:"varint,2,opt,name=severity_number,json=severityNumber,proto3,enum=opentelemetry.proto.logs.v1.SeverityNumber" json:"severity_number,omitempty"` - // The severity text (also known as log level). The original string representation as - // it is known at the source. [Optional]. - SeverityText string `protobuf:"bytes,3,opt,name=severity_text,json=severityText,proto3" json:"severity_text,omitempty"` - // A value containing the body of the log record. Can be for example a human-readable - // string message (including multi-line) describing the event in a free form or it can - // be a structured data composed of arrays and maps of other values. [Optional]. - Body v11.AnyValue `protobuf:"bytes,5,opt,name=body,proto3" json:"body"` - // Additional attributes that describe the specific event occurrence. [Optional]. - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - Attributes []v11.KeyValue `protobuf:"bytes,6,rep,name=attributes,proto3" json:"attributes"` - DroppedAttributesCount uint32 `protobuf:"varint,7,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` - // Flags, a bit field. 8 least significant bits are the trace flags as - // defined in W3C Trace Context specification. 24 most significant bits are reserved - // and must be set to 0. Readers must not assume that 24 most significant bits - // will be zero and must correctly mask the bits when reading 8-bit trace flag (use - // flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional]. - Flags uint32 `protobuf:"fixed32,8,opt,name=flags,proto3" json:"flags,omitempty"` - // A unique identifier for a trace. All logs from the same trace share - // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR - // of length other than 16 bytes is considered invalid (empty string in OTLP/JSON - // is zero-length and thus is also invalid). - // - // This field is optional. - // - // The receivers SHOULD assume that the log record is not associated with a - // trace if any of the following is true: - // - the field is not present, - // - the field contains an invalid value. - TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` - // A unique identifier for a span within a trace, assigned when the span - // is created. The ID is an 8-byte array. An ID with all zeroes OR of length - // other than 8 bytes is considered invalid (empty string in OTLP/JSON - // is zero-length and thus is also invalid). - // - // This field is optional. If the sender specifies a valid span_id then it SHOULD also - // specify a valid trace_id. - // - // The receivers SHOULD assume that the log record is not associated with a - // span if any of the following is true: - // - the field is not present, - // - the field contains an invalid value. - SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,10,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` - // A unique identifier of event category/type. - // All events with the same event_name are expected to conform to the same - // schema for both their attributes and their body. - // - // Recommended to be fully qualified and short (no longer than 256 characters). - // - // Presence of event_name on the log record identifies this record - // as an event. - // - // [Optional]. - EventName string `protobuf:"bytes,12,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` -} - -func (m *LogRecord) Reset() { *m = LogRecord{} } -func (m *LogRecord) String() string { return proto.CompactTextString(m) } -func (*LogRecord) ProtoMessage() {} -func (*LogRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_d1c030a3ec7e961e, []int{3} -} -func (m *LogRecord) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LogRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LogRecord.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LogRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_LogRecord.Merge(m, src) -} -func (m *LogRecord) XXX_Size() int { - return m.Size() -} -func (m *LogRecord) XXX_DiscardUnknown() { - xxx_messageInfo_LogRecord.DiscardUnknown(m) -} - -var xxx_messageInfo_LogRecord proto.InternalMessageInfo - -func (m *LogRecord) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *LogRecord) GetObservedTimeUnixNano() uint64 { - if m != nil { - return m.ObservedTimeUnixNano - } - return 0 -} - -func (m *LogRecord) GetSeverityNumber() SeverityNumber { - if m != nil { - return m.SeverityNumber - } - return SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED -} - -func (m *LogRecord) GetSeverityText() string { - if m != nil { - return m.SeverityText - } - return "" -} - -func (m *LogRecord) GetBody() v11.AnyValue { - if m != nil { - return m.Body - } - return v11.AnyValue{} -} - -func (m *LogRecord) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *LogRecord) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -func (m *LogRecord) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -func (m *LogRecord) GetEventName() string { - if m != nil { - return m.EventName - } - return "" -} - -func init() { - proto.RegisterEnum("opentelemetry.proto.logs.v1.SeverityNumber", SeverityNumber_name, SeverityNumber_value) - proto.RegisterEnum("opentelemetry.proto.logs.v1.LogRecordFlags", LogRecordFlags_name, LogRecordFlags_value) - proto.RegisterType((*LogsData)(nil), "opentelemetry.proto.logs.v1.LogsData") - proto.RegisterType((*ResourceLogs)(nil), "opentelemetry.proto.logs.v1.ResourceLogs") - proto.RegisterType((*ScopeLogs)(nil), "opentelemetry.proto.logs.v1.ScopeLogs") - proto.RegisterType((*LogRecord)(nil), "opentelemetry.proto.logs.v1.LogRecord") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/logs/v1/logs.proto", fileDescriptor_d1c030a3ec7e961e) -} - -var fileDescriptor_d1c030a3ec7e961e = []byte{ - // 971 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x96, 0x41, 0x6f, 0xe2, 0x46, - 0x1b, 0xc7, 0x71, 0x12, 0x02, 0x4c, 0x08, 0x3b, 0xef, 0x2c, 0xc9, 0xfa, 0x4d, 0x54, 0x42, 0xd3, - 0x2a, 0xa5, 0xa9, 0x04, 0x0a, 0x50, 0x69, 0x7b, 0xab, 0x09, 0x26, 0xa2, 0x21, 0x10, 0x0d, 0x90, - 0x2a, 0xdb, 0x4a, 0x96, 0xc1, 0x53, 0x6a, 0xc9, 0xcc, 0x58, 0xf6, 0x80, 0x92, 0x6f, 0xd1, 0x4f, - 0xd0, 0x4b, 0x0f, 0x95, 0xfa, 0x35, 0xda, 0xc3, 0x1e, 0xf7, 0x58, 0xf5, 0xb0, 0xaa, 0x92, 0x4b, - 0xbf, 0x45, 0xab, 0x19, 0x0c, 0x21, 0xa9, 0x9d, 0x34, 0x27, 0x66, 0x9e, 0xdf, 0xff, 0xf9, 0x3f, - 0xcf, 0x78, 0xc6, 0x83, 0xc1, 0x01, 0x73, 0x09, 0xe5, 0xc4, 0x21, 0x63, 0xc2, 0xbd, 0xeb, 0x92, - 0xeb, 0x31, 0xce, 0x4a, 0x0e, 0x1b, 0xf9, 0xa5, 0xe9, 0x91, 0xfc, 0x2d, 0xca, 0x10, 0xda, 0xbd, - 0xa7, 0x9b, 0x05, 0x8b, 0x92, 0x4f, 0x8f, 0x76, 0xb2, 0x23, 0x36, 0x62, 0xb3, 0x54, 0x31, 0x9a, - 0xd1, 0x9d, 0xc3, 0x30, 0xeb, 0x21, 0x1b, 0x8f, 0x19, 0x15, 0xe6, 0xb3, 0x51, 0xa0, 0x2d, 0x86, - 0x69, 0x3d, 0xe2, 0xb3, 0x89, 0x37, 0x24, 0x42, 0x3d, 0x1f, 0xcf, 0xf4, 0xfb, 0x6f, 0x40, 0xb2, - 0xc5, 0x46, 0x7e, 0xdd, 0xe4, 0x26, 0x6a, 0x83, 0xcd, 0x39, 0x35, 0x44, 0x47, 0xaa, 0x92, 0x5f, - 0x2d, 0x6c, 0x94, 0x3f, 0x2d, 0x3e, 0xd2, 0x72, 0x11, 0x07, 0x19, 0xc2, 0x05, 0xa7, 0xbd, 0xa5, - 0xd9, 0xfe, 0x8f, 0x2b, 0x20, 0xbd, 0x8c, 0xd1, 0x37, 0x60, 0xcb, 0x22, 0xae, 0x47, 0x86, 0x26, - 0x27, 0x96, 0xe1, 0x0f, 0x99, 0x1b, 0x14, 0xfa, 0x2b, 0x21, 0x2b, 0x1d, 0x3c, 0x5a, 0xa9, 0x2b, - 0xf4, 0xb2, 0xcc, 0xcb, 0x3b, 0x97, 0x45, 0x10, 0x9d, 0x82, 0xe4, 0xbc, 0xba, 0xaa, 0xe4, 0x95, - 0xc8, 0xc6, 0x17, 0x0f, 0x60, 0xa9, 0xf9, 0xda, 0xda, 0xdb, 0xf7, 0x7b, 0x31, 0xbc, 0x30, 0x40, - 0x3a, 0x00, 0x4b, 0xed, 0xad, 0x3c, 0xab, 0xbb, 0x94, 0xbf, 0xe8, 0xe9, 0x03, 0x61, 0xf3, 0x3d, - 0x19, 0x9b, 0xc6, 0xc4, 0x73, 0xd4, 0xd5, 0xbc, 0x52, 0x48, 0x09, 0x2c, 0x22, 0x7d, 0xcf, 0xd9, - 0xff, 0x4d, 0x01, 0xa9, 0xbb, 0x05, 0x74, 0x40, 0x5c, 0x66, 0x06, 0xdd, 0x57, 0x42, 0xcb, 0x05, - 0x9b, 0x3d, 0x3d, 0x2a, 0x36, 0xa9, 0xcf, 0xbd, 0xc9, 0x98, 0x50, 0x6e, 0x72, 0x9b, 0x51, 0xe9, - 0x13, 0xac, 0x63, 0xe6, 0x83, 0x4e, 0xc0, 0x86, 0xc3, 0x46, 0x86, 0x47, 0x86, 0xcc, 0xb3, 0xfe, - 0xdb, 0x2a, 0x5a, 0x6c, 0x84, 0xa5, 0x1c, 0x03, 0x67, 0x3e, 0x7c, 0x72, 0x19, 0x3f, 0xc5, 0x41, - 0x6a, 0x91, 0x88, 0x3e, 0x06, 0x19, 0x6e, 0x8f, 0x89, 0x31, 0xa1, 0xf6, 0x95, 0x41, 0x4d, 0xca, - 0xe4, 0x7a, 0xd6, 0x71, 0x5a, 0x44, 0xfb, 0xd4, 0xbe, 0x6a, 0x9b, 0x94, 0xa1, 0xcf, 0xc1, 0x2b, - 0x36, 0xf0, 0x89, 0x37, 0x25, 0x96, 0xf1, 0x40, 0xbe, 0x21, 0xe5, 0xd9, 0x39, 0xee, 0x2d, 0xa7, - 0xf5, 0xc0, 0x0b, 0x9f, 0x4c, 0x89, 0x67, 0xf3, 0x6b, 0x83, 0x4e, 0xc6, 0x03, 0xe2, 0xa9, 0x2b, - 0x79, 0xa5, 0x90, 0x29, 0x7f, 0xf6, 0xf8, 0xe6, 0x04, 0x39, 0x6d, 0x99, 0x82, 0x33, 0xfe, 0xbd, - 0x39, 0xfa, 0x08, 0x6c, 0x2e, 0x5c, 0x39, 0xb9, 0xe2, 0xc1, 0x12, 0xd3, 0xf3, 0x60, 0x8f, 0x5c, - 0x71, 0xa4, 0x81, 0xb5, 0x01, 0xb3, 0xae, 0xd5, 0xb8, 0xdc, 0x9d, 0x4f, 0x9e, 0xd8, 0x1d, 0x8d, - 0x5e, 0x5f, 0x98, 0xce, 0x64, 0xbe, 0x23, 0x32, 0x15, 0x9d, 0x01, 0x60, 0x72, 0xee, 0xd9, 0x83, - 0x09, 0x27, 0xbe, 0xba, 0x2e, 0xf7, 0xe3, 0x29, 0xa3, 0x53, 0x72, 0xcf, 0x68, 0xc9, 0x00, 0xbd, - 0x06, 0xaa, 0xe5, 0x31, 0xd7, 0x25, 0x96, 0x71, 0x17, 0x35, 0x86, 0x6c, 0x42, 0xb9, 0x9a, 0xc8, - 0x2b, 0x85, 0x4d, 0xbc, 0x1d, 0x70, 0x6d, 0x81, 0x8f, 0x05, 0x45, 0x59, 0x10, 0xff, 0xce, 0x31, - 0x47, 0xbe, 0x9a, 0xcc, 0x2b, 0x85, 0x04, 0x9e, 0x4d, 0xd0, 0xb7, 0x20, 0xc9, 0x3d, 0x73, 0x48, - 0x0c, 0xdb, 0x52, 0x53, 0x79, 0xa5, 0x90, 0xae, 0x69, 0xa2, 0xe6, 0x1f, 0xef, 0xf7, 0xbe, 0x18, - 0xb1, 0x07, 0x6d, 0xda, 0xe2, 0x06, 0x72, 0x1c, 0x32, 0xe4, 0xcc, 0x2b, 0xb9, 0x96, 0xc9, 0xcd, - 0x92, 0x4d, 0x39, 0xf1, 0xa8, 0xe9, 0x94, 0xc4, 0xac, 0xd8, 0x13, 0x4e, 0xcd, 0x3a, 0x4e, 0x48, - 0xcb, 0xa6, 0x85, 0x2e, 0x41, 0xc2, 0x77, 0x4d, 0x2a, 0xcc, 0x81, 0x34, 0xff, 0x32, 0x30, 0x7f, - 0xfd, 0x7c, 0xf3, 0xae, 0x6b, 0xd2, 0x66, 0x1d, 0xaf, 0x0b, 0xc3, 0xa6, 0x25, 0xce, 0x27, 0x99, - 0x12, 0xca, 0x0d, 0x6a, 0x8e, 0x89, 0x9a, 0x9e, 0x9d, 0x4f, 0x19, 0x69, 0x9b, 0x63, 0xf2, 0xd5, - 0x5a, 0x72, 0x0d, 0xc6, 0x0f, 0x7f, 0x8d, 0x83, 0xcc, 0xfd, 0x73, 0x80, 0xf6, 0xc0, 0x6e, 0x57, - 0xbf, 0xd0, 0x71, 0xb3, 0x77, 0x69, 0xb4, 0xfb, 0x67, 0x35, 0x1d, 0x1b, 0xfd, 0x76, 0xf7, 0x5c, - 0x3f, 0x6e, 0x36, 0x9a, 0x7a, 0x1d, 0xc6, 0xd0, 0xff, 0xc1, 0xd6, 0x43, 0x41, 0x0f, 0x6b, 0xc7, - 0x3a, 0x54, 0xd0, 0x0e, 0xd8, 0x0e, 0x45, 0x65, 0xb8, 0x12, 0xc9, 0x2a, 0x70, 0x35, 0x92, 0x55, - 0xe1, 0x5a, 0x58, 0xb9, 0xba, 0x5e, 0xeb, 0x9f, 0xc0, 0x78, 0x58, 0x9a, 0x44, 0x65, 0xb8, 0x1e, - 0xc9, 0x2a, 0x30, 0x11, 0xc9, 0xaa, 0x30, 0x89, 0x54, 0x90, 0x7d, 0xc8, 0x9a, 0xed, 0x46, 0x07, - 0xa6, 0xc2, 0x1a, 0x11, 0xa4, 0x0c, 0x41, 0x14, 0xaa, 0xc0, 0x8d, 0x28, 0x54, 0x85, 0xe9, 0xb0, - 0x52, 0x5f, 0x6b, 0xb8, 0x0d, 0x37, 0xc3, 0x92, 0x04, 0x29, 0xc3, 0x4c, 0x14, 0xaa, 0xc0, 0x17, - 0x51, 0xa8, 0x0a, 0x61, 0x18, 0xd2, 0x31, 0xee, 0x60, 0xf8, 0xbf, 0xb0, 0x87, 0x21, 0x51, 0x19, - 0xa2, 0x48, 0x56, 0x81, 0x2f, 0x23, 0x59, 0x15, 0x66, 0xc3, 0xca, 0x35, 0xb4, 0x9e, 0xd6, 0x82, - 0x5b, 0x61, 0x69, 0x12, 0x95, 0xe1, 0x76, 0x24, 0xab, 0xc0, 0x57, 0x91, 0xac, 0x0a, 0xd5, 0xc3, - 0x4b, 0x90, 0x59, 0x5c, 0xb5, 0x0d, 0xf9, 0xd6, 0xee, 0x81, 0xdd, 0x56, 0xe7, 0xc4, 0xc0, 0xfa, - 0x71, 0x07, 0xd7, 0x8d, 0x46, 0x4b, 0x3b, 0xe9, 0x1a, 0xf5, 0x8e, 0xd1, 0xee, 0xf4, 0x8c, 0x7e, - 0x57, 0x87, 0x31, 0x74, 0x00, 0x3e, 0xfc, 0x97, 0x40, 0x1e, 0xb9, 0x60, 0x7c, 0xa6, 0x75, 0x4f, - 0xe1, 0xdf, 0x4a, 0xed, 0x67, 0xe5, 0xed, 0x4d, 0x4e, 0x79, 0x77, 0x93, 0x53, 0xfe, 0xbc, 0xc9, - 0x29, 0x3f, 0xdc, 0xe6, 0x62, 0xef, 0x6e, 0x73, 0xb1, 0xdf, 0x6f, 0x73, 0x31, 0x90, 0xb3, 0xd9, - 0x63, 0xf7, 0x6b, 0x4d, 0x5c, 0xff, 0xfe, 0xb9, 0x08, 0x9d, 0x2b, 0x6f, 0x6a, 0xcf, 0x7e, 0x9f, - 0x67, 0x9f, 0x29, 0x23, 0x42, 0xe7, 0x1f, 0x4c, 0xbf, 0xac, 0xec, 0x76, 0x5c, 0x42, 0x7b, 0x0b, - 0x07, 0xe9, 0x2d, 0xfe, 0x9d, 0xfc, 0xe2, 0xc5, 0xd1, 0x60, 0x5d, 0xea, 0x2b, 0xff, 0x04, 0x00, - 0x00, 0xff, 0xff, 0xc9, 0xbc, 0x36, 0x44, 0x74, 0x09, 0x00, 0x00, -} - -func (m *LogsData) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LogsData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LogsData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ResourceLogs) > 0 { - for iNdEx := len(m.ResourceLogs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ResourceLogs) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ResourceLogs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ResourceLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DeprecatedScopeLogs) > 0 { - for iNdEx := len(m.DeprecatedScopeLogs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DeprecatedScopeLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3e - i-- - dAtA[i] = 0xc2 - } - } - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintLogs(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.ScopeLogs) > 0 { - for iNdEx := len(m.ScopeLogs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ScopeLogs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Resource.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ScopeLogs) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ScopeLogs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ScopeLogs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintLogs(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.LogRecords) > 0 { - for iNdEx := len(m.LogRecords) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LogRecords[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Scope.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *LogRecord) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LogRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LogRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.EventName) > 0 { - i -= len(m.EventName) - copy(dAtA[i:], m.EventName) - i = encodeVarintLogs(dAtA, i, uint64(len(m.EventName))) - i-- - dAtA[i] = 0x62 - } - if m.ObservedTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.ObservedTimeUnixNano)) - i-- - dAtA[i] = 0x59 - } - { - size := m.SpanId.Size() - i -= size - if _, err := m.SpanId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - { - size := m.TraceId.Size() - i -= size - if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - if m.Flags != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Flags)) - i-- - dAtA[i] = 0x45 - } - if m.DroppedAttributesCount != 0 { - i = encodeVarintLogs(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x38 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } - { - size, err := m.Body.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLogs(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if len(m.SeverityText) > 0 { - i -= len(m.SeverityText) - copy(dAtA[i:], m.SeverityText) - i = encodeVarintLogs(dAtA, i, uint64(len(m.SeverityText))) - i-- - dAtA[i] = 0x1a - } - if m.SeverityNumber != 0 { - i = encodeVarintLogs(dAtA, i, uint64(m.SeverityNumber)) - i-- - dAtA[i] = 0x10 - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x9 - } - return len(dAtA) - i, nil -} - -func encodeVarintLogs(dAtA []byte, offset int, v uint64) int { - offset -= sovLogs(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *LogsData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceLogs) > 0 { - for _, e := range m.ResourceLogs { - l = e.Size() - n += 1 + l + sovLogs(uint64(l)) - } - } - return n -} - -func (m *ResourceLogs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Resource.Size() - n += 1 + l + sovLogs(uint64(l)) - if len(m.ScopeLogs) > 0 { - for _, e := range m.ScopeLogs { - l = e.Size() - n += 1 + l + sovLogs(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } - if len(m.DeprecatedScopeLogs) > 0 { - for _, e := range m.DeprecatedScopeLogs { - l = e.Size() - n += 2 + l + sovLogs(uint64(l)) - } - } - return n -} - -func (m *ScopeLogs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Scope.Size() - n += 1 + l + sovLogs(uint64(l)) - if len(m.LogRecords) > 0 { - for _, e := range m.LogRecords { - l = e.Size() - n += 1 + l + sovLogs(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } - return n -} - -func (m *LogRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TimeUnixNano != 0 { - n += 9 - } - if m.SeverityNumber != 0 { - n += 1 + sovLogs(uint64(m.SeverityNumber)) - } - l = len(m.SeverityText) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } - l = m.Body.Size() - n += 1 + l + sovLogs(uint64(l)) - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovLogs(uint64(l)) - } - } - if m.DroppedAttributesCount != 0 { - n += 1 + sovLogs(uint64(m.DroppedAttributesCount)) - } - if m.Flags != 0 { - n += 5 - } - l = m.TraceId.Size() - n += 1 + l + sovLogs(uint64(l)) - l = m.SpanId.Size() - n += 1 + l + sovLogs(uint64(l)) - if m.ObservedTimeUnixNano != 0 { - n += 9 - } - l = len(m.EventName) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } - return n -} - -func sovLogs(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozLogs(x uint64) (n int) { - return sovLogs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *LogsData) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LogsData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LogsData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceLogs = append(m.ResourceLogs, &ResourceLogs{}) - if err := m.ResourceLogs[len(m.ResourceLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ResourceLogs) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ResourceLogs: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceLogs: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeLogs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ScopeLogs = append(m.ScopeLogs, &ScopeLogs{}) - if err := m.ScopeLogs[len(m.ScopeLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 1000: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedScopeLogs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DeprecatedScopeLogs = append(m.DeprecatedScopeLogs, &ScopeLogs{}) - if err := m.DeprecatedScopeLogs[len(m.DeprecatedScopeLogs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ScopeLogs) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ScopeLogs: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeLogs: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Scope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LogRecords", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LogRecords = append(m.LogRecords, &LogRecord{}) - if err := m.LogRecords[len(m.LogRecords)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LogRecord) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LogRecord: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LogRecord: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SeverityNumber", wireType) - } - m.SeverityNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SeverityNumber |= SeverityNumber(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SeverityText", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SeverityText = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Body.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.Flags = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SpanId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field ObservedTimeUnixNano", wireType) - } - m.ObservedTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.ObservedTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EventName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLogs - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLogs - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLogs - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EventName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipLogs(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLogs - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipLogs(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowLogs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowLogs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowLogs - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthLogs - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupLogs - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthLogs - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthLogs = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowLogs = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupLogs = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/metrics/v1/metrics.pb.go b/pdata/internal/data/protogen/metrics/v1/metrics.pb.go deleted file mode 100644 index 719652cceb2..00000000000 --- a/pdata/internal/data/protogen/metrics/v1/metrics.pb.go +++ /dev/null @@ -1,6695 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/metrics/v1/metrics.proto - -package v1 - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - - go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" - v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// AggregationTemporality defines how a metric aggregator reports aggregated -// values. It describes how those values relate to the time interval over -// which they are aggregated. -type AggregationTemporality int32 - -const ( - // UNSPECIFIED is the default AggregationTemporality, it MUST not be used. - AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED AggregationTemporality = 0 - // DELTA is an AggregationTemporality for a metric aggregator which reports - // changes since last report time. Successive metrics contain aggregation of - // values from continuous and non-overlapping intervals. - // - // The values for a DELTA metric are based only on the time interval - // associated with one measurement cycle. There is no dependency on - // previous measurements like is the case for CUMULATIVE metrics. - // - // For example, consider a system measuring the number of requests that - // it receives and reports the sum of these requests every second as a - // DELTA metric: - // - // 1. The system starts receiving at time=t_0. - // 2. A request is received, the system measures 1 request. - // 3. A request is received, the system measures 1 request. - // 4. A request is received, the system measures 1 request. - // 5. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0 to - // t_0+1 with a value of 3. - // 6. A request is received, the system measures 1 request. - // 7. A request is received, the system measures 1 request. - // 8. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0+1 to - // t_0+2 with a value of 2. - AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA AggregationTemporality = 1 - // CUMULATIVE is an AggregationTemporality for a metric aggregator which - // reports changes since a fixed start time. This means that current values - // of a CUMULATIVE metric depend on all previous measurements since the - // start time. Because of this, the sender is required to retain this state - // in some form. If this state is lost or invalidated, the CUMULATIVE metric - // values MUST be reset and a new fixed start time following the last - // reported measurement time sent MUST be used. - // - // For example, consider a system measuring the number of requests that - // it receives and reports the sum of these requests every second as a - // CUMULATIVE metric: - // - // 1. The system starts receiving at time=t_0. - // 2. A request is received, the system measures 1 request. - // 3. A request is received, the system measures 1 request. - // 4. A request is received, the system measures 1 request. - // 5. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0 to - // t_0+1 with a value of 3. - // 6. A request is received, the system measures 1 request. - // 7. A request is received, the system measures 1 request. - // 8. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_0 to - // t_0+2 with a value of 5. - // 9. The system experiences a fault and loses state. - // 10. The system recovers and resumes receiving at time=t_1. - // 11. A request is received, the system measures 1 request. - // 12. The 1 second collection cycle ends. A metric is exported for the - // number of requests received over the interval of time t_1 to - // t_0+1 with a value of 1. - // - // Note: Even though, when reporting changes since last report time, using - // CUMULATIVE is valid, it is not recommended. This may cause problems for - // systems that do not use start_time to determine when the aggregation - // value was reset (e.g. Prometheus). - AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE AggregationTemporality = 2 -) - -var AggregationTemporality_name = map[int32]string{ - 0: "AGGREGATION_TEMPORALITY_UNSPECIFIED", - 1: "AGGREGATION_TEMPORALITY_DELTA", - 2: "AGGREGATION_TEMPORALITY_CUMULATIVE", -} - -var AggregationTemporality_value = map[string]int32{ - "AGGREGATION_TEMPORALITY_UNSPECIFIED": 0, - "AGGREGATION_TEMPORALITY_DELTA": 1, - "AGGREGATION_TEMPORALITY_CUMULATIVE": 2, -} - -func (x AggregationTemporality) String() string { - return proto.EnumName(AggregationTemporality_name, int32(x)) -} - -func (AggregationTemporality) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{0} -} - -// DataPointFlags is defined as a protobuf 'uint32' type and is to be used as a -// bit-field representing 32 distinct boolean flags. Each flag defined in this -// enum is a bit-mask. To test the presence of a single flag in the flags of -// a data point, for example, use an expression like: -// -// (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK -type DataPointFlags int32 - -const ( - // The zero value for the enum. Should not be used for comparisons. - // Instead use bitwise "and" with the appropriate mask as shown above. - DataPointFlags_DATA_POINT_FLAGS_DO_NOT_USE DataPointFlags = 0 - // This DataPoint is valid but has no recorded value. This value - // SHOULD be used to reflect explicitly missing data in a series, as - // for an equivalent to the Prometheus "staleness marker". - DataPointFlags_DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK DataPointFlags = 1 -) - -var DataPointFlags_name = map[int32]string{ - 0: "DATA_POINT_FLAGS_DO_NOT_USE", - 1: "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK", -} - -var DataPointFlags_value = map[string]int32{ - "DATA_POINT_FLAGS_DO_NOT_USE": 0, - "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK": 1, -} - -func (x DataPointFlags) String() string { - return proto.EnumName(DataPointFlags_name, int32(x)) -} - -func (DataPointFlags) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{1} -} - -// MetricsData represents the metrics data that can be stored in a persistent -// storage, OR can be embedded by other protocols that transfer OTLP metrics -// data but do not implement the OTLP protocol. -// -// MetricsData -// └─── ResourceMetrics -// -// ├── Resource -// ├── SchemaURL -// └── ScopeMetrics -// ├── Scope -// ├── SchemaURL -// └── Metric -// ├── Name -// ├── Description -// ├── Unit -// └── data -// ├── Gauge -// ├── Sum -// ├── Histogram -// ├── ExponentialHistogram -// └── Summary -// -// The main difference between this message and collector protocol is that -// in this message there will not be any "control" or "metadata" specific to -// OTLP protocol. -// -// When new fields are added into this message, the OTLP request MUST be updated -// as well. -type MetricsData struct { - // An array of ResourceMetrics. - // For data coming from a single resource this array will typically contain - // one element. Intermediary nodes that receive data from multiple origins - // typically batch the data before forwarding further and in that case this - // array will contain multiple elements. - ResourceMetrics []*ResourceMetrics `protobuf:"bytes,1,rep,name=resource_metrics,json=resourceMetrics,proto3" json:"resource_metrics,omitempty"` -} - -func (m *MetricsData) Reset() { *m = MetricsData{} } -func (m *MetricsData) String() string { return proto.CompactTextString(m) } -func (*MetricsData) ProtoMessage() {} -func (*MetricsData) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{0} -} -func (m *MetricsData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MetricsData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MetricsData.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MetricsData) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricsData.Merge(m, src) -} -func (m *MetricsData) XXX_Size() int { - return m.Size() -} -func (m *MetricsData) XXX_DiscardUnknown() { - xxx_messageInfo_MetricsData.DiscardUnknown(m) -} - -var xxx_messageInfo_MetricsData proto.InternalMessageInfo - -func (m *MetricsData) GetResourceMetrics() []*ResourceMetrics { - if m != nil { - return m.ResourceMetrics - } - return nil -} - -// A collection of ScopeMetrics from a Resource. -type ResourceMetrics struct { - DeprecatedScopeMetrics []*ScopeMetrics `protobuf:"bytes,1000,rep,name=deprecated_scope_metrics,json=deprecatedScopeMetrics,proto3" json:"deprecated_scope_metrics,omitempty"` - // The resource for the metrics in this message. - // If this field is not set then no resource info is known. - Resource v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource"` - // A list of metrics that originate from a resource. - ScopeMetrics []*ScopeMetrics `protobuf:"bytes,2,rep,name=scope_metrics,json=scopeMetrics,proto3" json:"scope_metrics,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the resource data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to the data in the "resource" field. It does not apply - // to the data in the "scope_metrics" field which have their own schema_url field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ResourceMetrics) Reset() { *m = ResourceMetrics{} } -func (m *ResourceMetrics) String() string { return proto.CompactTextString(m) } -func (*ResourceMetrics) ProtoMessage() {} -func (*ResourceMetrics) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{1} -} -func (m *ResourceMetrics) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ResourceMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ResourceMetrics.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ResourceMetrics) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResourceMetrics.Merge(m, src) -} -func (m *ResourceMetrics) XXX_Size() int { - return m.Size() -} -func (m *ResourceMetrics) XXX_DiscardUnknown() { - xxx_messageInfo_ResourceMetrics.DiscardUnknown(m) -} - -var xxx_messageInfo_ResourceMetrics proto.InternalMessageInfo - -func (m *ResourceMetrics) GetDeprecatedScopeMetrics() []*ScopeMetrics { - if m != nil { - return m.DeprecatedScopeMetrics - } - return nil -} - -func (m *ResourceMetrics) GetResource() v1.Resource { - if m != nil { - return m.Resource - } - return v1.Resource{} -} - -func (m *ResourceMetrics) GetScopeMetrics() []*ScopeMetrics { - if m != nil { - return m.ScopeMetrics - } - return nil -} - -func (m *ResourceMetrics) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// A collection of Metrics produced by an Scope. -type ScopeMetrics struct { - // The instrumentation scope information for the metrics in this message. - // Semantically when InstrumentationScope isn't set, it is equivalent with - // an empty instrumentation scope name (unknown). - Scope v11.InstrumentationScope `protobuf:"bytes,1,opt,name=scope,proto3" json:"scope"` - // A list of metrics that originate from an instrumentation library. - Metrics []*Metric `protobuf:"bytes,2,rep,name=metrics,proto3" json:"metrics,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the metric data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to all metrics in the "metrics" field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ScopeMetrics) Reset() { *m = ScopeMetrics{} } -func (m *ScopeMetrics) String() string { return proto.CompactTextString(m) } -func (*ScopeMetrics) ProtoMessage() {} -func (*ScopeMetrics) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{2} -} -func (m *ScopeMetrics) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ScopeMetrics) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ScopeMetrics.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ScopeMetrics) XXX_Merge(src proto.Message) { - xxx_messageInfo_ScopeMetrics.Merge(m, src) -} -func (m *ScopeMetrics) XXX_Size() int { - return m.Size() -} -func (m *ScopeMetrics) XXX_DiscardUnknown() { - xxx_messageInfo_ScopeMetrics.DiscardUnknown(m) -} - -var xxx_messageInfo_ScopeMetrics proto.InternalMessageInfo - -func (m *ScopeMetrics) GetScope() v11.InstrumentationScope { - if m != nil { - return m.Scope - } - return v11.InstrumentationScope{} -} - -func (m *ScopeMetrics) GetMetrics() []*Metric { - if m != nil { - return m.Metrics - } - return nil -} - -func (m *ScopeMetrics) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// Defines a Metric which has one or more timeseries. The following is a -// brief summary of the Metric data model. For more details, see: -// -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md -// -// The data model and relation between entities is shown in the -// diagram below. Here, "DataPoint" is the term used to refer to any -// one of the specific data point value types, and "points" is the term used -// to refer to any one of the lists of points contained in the Metric. -// -// - Metric is composed of a metadata and data. -// -// - Metadata part contains a name, description, unit. -// -// - Data is one of the possible types (Sum, Gauge, Histogram, Summary). -// -// - DataPoint contains timestamps, attributes, and one of the possible value type -// fields. -// -// Metric -// +------------+ -// |name | -// |description | -// |unit | +------------------------------------+ -// |data |---> |Gauge, Sum, Histogram, Summary, ... | -// +------------+ +------------------------------------+ -// -// Data [One of Gauge, Sum, Histogram, Summary, ...] -// +-----------+ -// |... | // Metadata about the Data. -// |points |--+ -// +-----------+ | -// | +---------------------------+ -// | |DataPoint 1 | -// v |+------+------+ +------+ | -// +-----+ ||label |label |...|label | | -// | 1 |-->||value1|value2|...|valueN| | -// +-----+ |+------+------+ +------+ | -// | . | |+-----+ | -// | . | ||value| | -// | . | |+-----+ | -// | . | +---------------------------+ -// | . | . -// | . | . -// | . | . -// | . | +---------------------------+ -// | . | |DataPoint M | -// +-----+ |+------+------+ +------+ | -// | M |-->||label |label |...|label | | -// +-----+ ||value1|value2|...|valueN| | -// |+------+------+ +------+ | -// |+-----+ | -// ||value| | -// |+-----+ | -// +---------------------------+ -// -// Each distinct type of DataPoint represents the output of a specific -// aggregation function, the result of applying the DataPoint's -// associated function of to one or more measurements. -// -// All DataPoint types have three common fields: -// - Attributes includes key-value pairs associated with the data point -// - TimeUnixNano is required, set to the end time of the aggregation -// - StartTimeUnixNano is optional, but strongly encouraged for DataPoints -// having an AggregationTemporality field, as discussed below. -// -// Both TimeUnixNano and StartTimeUnixNano values are expressed as -// UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. -// -// # TimeUnixNano -// -// This field is required, having consistent interpretation across -// DataPoint types. TimeUnixNano is the moment corresponding to when -// the data point's aggregate value was captured. -// -// Data points with the 0 value for TimeUnixNano SHOULD be rejected -// by consumers. -// -// # StartTimeUnixNano -// -// StartTimeUnixNano in general allows detecting when a sequence of -// observations is unbroken. This field indicates to consumers the -// start time for points with cumulative and delta -// AggregationTemporality, and it should be included whenever possible -// to support correct rate calculation. Although it may be omitted -// when the start time is truly unknown, setting StartTimeUnixNano is -// strongly encouraged. -type Metric struct { - // name of the metric. - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - // description of the metric, which can be used in documentation. - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - // unit in which the metric value is reported. Follows the format - // described by https://unitsofmeasure.org/ucum.html. - Unit string `protobuf:"bytes,3,opt,name=unit,proto3" json:"unit,omitempty"` - // Data determines the aggregation type (if any) of the metric, what is the - // reported value type for the data points, as well as the relatationship to - // the time interval over which they are reported. - // - // Types that are valid to be assigned to Data: - // *Metric_Gauge - // *Metric_Sum - // *Metric_Histogram - // *Metric_ExponentialHistogram - // *Metric_Summary - Data isMetric_Data `protobuf_oneof:"data"` - // Additional metadata attributes that describe the metric. [Optional]. - // Attributes are non-identifying. - // Consumers SHOULD NOT need to be aware of these attributes. - // These attributes MAY be used to encode information allowing - // for lossless roundtrip translation to / from another data model. - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - Metadata []v11.KeyValue `protobuf:"bytes,12,rep,name=metadata,proto3" json:"metadata"` -} - -func (m *Metric) Reset() { *m = Metric{} } -func (m *Metric) String() string { return proto.CompactTextString(m) } -func (*Metric) ProtoMessage() {} -func (*Metric) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{3} -} -func (m *Metric) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Metric) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Metric.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Metric) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metric.Merge(m, src) -} -func (m *Metric) XXX_Size() int { - return m.Size() -} -func (m *Metric) XXX_DiscardUnknown() { - xxx_messageInfo_Metric.DiscardUnknown(m) -} - -var xxx_messageInfo_Metric proto.InternalMessageInfo - -type isMetric_Data interface { - isMetric_Data() - MarshalTo([]byte) (int, error) - Size() int -} - -type Metric_Gauge struct { - Gauge *Gauge `protobuf:"bytes,5,opt,name=gauge,proto3,oneof" json:"gauge,omitempty"` -} -type Metric_Sum struct { - Sum *Sum `protobuf:"bytes,7,opt,name=sum,proto3,oneof" json:"sum,omitempty"` -} -type Metric_Histogram struct { - Histogram *Histogram `protobuf:"bytes,9,opt,name=histogram,proto3,oneof" json:"histogram,omitempty"` -} -type Metric_ExponentialHistogram struct { - ExponentialHistogram *ExponentialHistogram `protobuf:"bytes,10,opt,name=exponential_histogram,json=exponentialHistogram,proto3,oneof" json:"exponential_histogram,omitempty"` -} -type Metric_Summary struct { - Summary *Summary `protobuf:"bytes,11,opt,name=summary,proto3,oneof" json:"summary,omitempty"` -} - -func (*Metric_Gauge) isMetric_Data() {} -func (*Metric_Sum) isMetric_Data() {} -func (*Metric_Histogram) isMetric_Data() {} -func (*Metric_ExponentialHistogram) isMetric_Data() {} -func (*Metric_Summary) isMetric_Data() {} - -func (m *Metric) GetData() isMetric_Data { - if m != nil { - return m.Data - } - return nil -} - -func (m *Metric) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Metric) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Metric) GetUnit() string { - if m != nil { - return m.Unit - } - return "" -} - -func (m *Metric) GetGauge() *Gauge { - if x, ok := m.GetData().(*Metric_Gauge); ok { - return x.Gauge - } - return nil -} - -func (m *Metric) GetSum() *Sum { - if x, ok := m.GetData().(*Metric_Sum); ok { - return x.Sum - } - return nil -} - -func (m *Metric) GetHistogram() *Histogram { - if x, ok := m.GetData().(*Metric_Histogram); ok { - return x.Histogram - } - return nil -} - -func (m *Metric) GetExponentialHistogram() *ExponentialHistogram { - if x, ok := m.GetData().(*Metric_ExponentialHistogram); ok { - return x.ExponentialHistogram - } - return nil -} - -func (m *Metric) GetSummary() *Summary { - if x, ok := m.GetData().(*Metric_Summary); ok { - return x.Summary - } - return nil -} - -func (m *Metric) GetMetadata() []v11.KeyValue { - if m != nil { - return m.Metadata - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Metric) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Metric_Gauge)(nil), - (*Metric_Sum)(nil), - (*Metric_Histogram)(nil), - (*Metric_ExponentialHistogram)(nil), - (*Metric_Summary)(nil), - } -} - -// Gauge represents the type of a scalar metric that always exports the -// "current value" for every data point. It should be used for an "unknown" -// aggregation. -// -// A Gauge does not support different aggregation temporalities. Given the -// aggregation is unknown, points cannot be combined using the same -// aggregation, regardless of aggregation temporalities. Therefore, -// AggregationTemporality is not included. Consequently, this also means -// "StartTimeUnixNano" is ignored for all data points. -type Gauge struct { - DataPoints []*NumberDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` -} - -func (m *Gauge) Reset() { *m = Gauge{} } -func (m *Gauge) String() string { return proto.CompactTextString(m) } -func (*Gauge) ProtoMessage() {} -func (*Gauge) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{4} -} -func (m *Gauge) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Gauge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Gauge.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Gauge) XXX_Merge(src proto.Message) { - xxx_messageInfo_Gauge.Merge(m, src) -} -func (m *Gauge) XXX_Size() int { - return m.Size() -} -func (m *Gauge) XXX_DiscardUnknown() { - xxx_messageInfo_Gauge.DiscardUnknown(m) -} - -var xxx_messageInfo_Gauge proto.InternalMessageInfo - -func (m *Gauge) GetDataPoints() []*NumberDataPoint { - if m != nil { - return m.DataPoints - } - return nil -} - -// Sum represents the type of a scalar metric that is calculated as a sum of all -// reported measurements over a time interval. -type Sum struct { - DataPoints []*NumberDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` - // aggregation_temporality describes if the aggregator reports delta changes - // since last report time, or cumulative changes since a fixed start time. - AggregationTemporality AggregationTemporality `protobuf:"varint,2,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.metrics.v1.AggregationTemporality" json:"aggregation_temporality,omitempty"` - // If "true" means that the sum is monotonic. - IsMonotonic bool `protobuf:"varint,3,opt,name=is_monotonic,json=isMonotonic,proto3" json:"is_monotonic,omitempty"` -} - -func (m *Sum) Reset() { *m = Sum{} } -func (m *Sum) String() string { return proto.CompactTextString(m) } -func (*Sum) ProtoMessage() {} -func (*Sum) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{5} -} -func (m *Sum) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Sum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Sum.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Sum) XXX_Merge(src proto.Message) { - xxx_messageInfo_Sum.Merge(m, src) -} -func (m *Sum) XXX_Size() int { - return m.Size() -} -func (m *Sum) XXX_DiscardUnknown() { - xxx_messageInfo_Sum.DiscardUnknown(m) -} - -var xxx_messageInfo_Sum proto.InternalMessageInfo - -func (m *Sum) GetDataPoints() []*NumberDataPoint { - if m != nil { - return m.DataPoints - } - return nil -} - -func (m *Sum) GetAggregationTemporality() AggregationTemporality { - if m != nil { - return m.AggregationTemporality - } - return AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED -} - -func (m *Sum) GetIsMonotonic() bool { - if m != nil { - return m.IsMonotonic - } - return false -} - -// Histogram represents the type of a metric that is calculated by aggregating -// as a Histogram of all reported measurements over a time interval. -type Histogram struct { - DataPoints []*HistogramDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` - // aggregation_temporality describes if the aggregator reports delta changes - // since last report time, or cumulative changes since a fixed start time. - AggregationTemporality AggregationTemporality `protobuf:"varint,2,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.metrics.v1.AggregationTemporality" json:"aggregation_temporality,omitempty"` -} - -func (m *Histogram) Reset() { *m = Histogram{} } -func (m *Histogram) String() string { return proto.CompactTextString(m) } -func (*Histogram) ProtoMessage() {} -func (*Histogram) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{6} -} -func (m *Histogram) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Histogram) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Histogram.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Histogram) XXX_Merge(src proto.Message) { - xxx_messageInfo_Histogram.Merge(m, src) -} -func (m *Histogram) XXX_Size() int { - return m.Size() -} -func (m *Histogram) XXX_DiscardUnknown() { - xxx_messageInfo_Histogram.DiscardUnknown(m) -} - -var xxx_messageInfo_Histogram proto.InternalMessageInfo - -func (m *Histogram) GetDataPoints() []*HistogramDataPoint { - if m != nil { - return m.DataPoints - } - return nil -} - -func (m *Histogram) GetAggregationTemporality() AggregationTemporality { - if m != nil { - return m.AggregationTemporality - } - return AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED -} - -// ExponentialHistogram represents the type of a metric that is calculated by aggregating -// as a ExponentialHistogram of all reported double measurements over a time interval. -type ExponentialHistogram struct { - DataPoints []*ExponentialHistogramDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` - // aggregation_temporality describes if the aggregator reports delta changes - // since last report time, or cumulative changes since a fixed start time. - AggregationTemporality AggregationTemporality `protobuf:"varint,2,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.metrics.v1.AggregationTemporality" json:"aggregation_temporality,omitempty"` -} - -func (m *ExponentialHistogram) Reset() { *m = ExponentialHistogram{} } -func (m *ExponentialHistogram) String() string { return proto.CompactTextString(m) } -func (*ExponentialHistogram) ProtoMessage() {} -func (*ExponentialHistogram) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{7} -} -func (m *ExponentialHistogram) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExponentialHistogram) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExponentialHistogram.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExponentialHistogram) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExponentialHistogram.Merge(m, src) -} -func (m *ExponentialHistogram) XXX_Size() int { - return m.Size() -} -func (m *ExponentialHistogram) XXX_DiscardUnknown() { - xxx_messageInfo_ExponentialHistogram.DiscardUnknown(m) -} - -var xxx_messageInfo_ExponentialHistogram proto.InternalMessageInfo - -func (m *ExponentialHistogram) GetDataPoints() []*ExponentialHistogramDataPoint { - if m != nil { - return m.DataPoints - } - return nil -} - -func (m *ExponentialHistogram) GetAggregationTemporality() AggregationTemporality { - if m != nil { - return m.AggregationTemporality - } - return AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED -} - -// Summary metric data are used to convey quantile summaries, -// a Prometheus (see: https://prometheus.io/docs/concepts/metric_types/#summary) -// and OpenMetrics (see: https://github.com/prometheus/OpenMetrics/blob/4dbf6075567ab43296eed941037c12951faafb92/protos/prometheus.proto#L45) -// data type. These data points cannot always be merged in a meaningful way. -// While they can be useful in some applications, histogram data points are -// recommended for new applications. -// Summary metrics do not have an aggregation temporality field. This is -// because the count and sum fields of a SummaryDataPoint are assumed to be -// cumulative values. -type Summary struct { - DataPoints []*SummaryDataPoint `protobuf:"bytes,1,rep,name=data_points,json=dataPoints,proto3" json:"data_points,omitempty"` -} - -func (m *Summary) Reset() { *m = Summary{} } -func (m *Summary) String() string { return proto.CompactTextString(m) } -func (*Summary) ProtoMessage() {} -func (*Summary) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{8} -} -func (m *Summary) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Summary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Summary.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Summary) XXX_Merge(src proto.Message) { - xxx_messageInfo_Summary.Merge(m, src) -} -func (m *Summary) XXX_Size() int { - return m.Size() -} -func (m *Summary) XXX_DiscardUnknown() { - xxx_messageInfo_Summary.DiscardUnknown(m) -} - -var xxx_messageInfo_Summary proto.InternalMessageInfo - -func (m *Summary) GetDataPoints() []*SummaryDataPoint { - if m != nil { - return m.DataPoints - } - return nil -} - -// NumberDataPoint is a single data point in a timeseries that describes the -// time-varying scalar value of a metric. -type NumberDataPoint struct { - // The set of key/value pairs that uniquely identify the timeseries from - // where this point belongs. The list may be empty (may contain 0 elements). - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,7,rep,name=attributes,proto3" json:"attributes"` - // StartTimeUnixNano is optional but strongly encouraged, see the - // the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - StartTimeUnixNano uint64 `protobuf:"fixed64,2,opt,name=start_time_unix_nano,json=startTimeUnixNano,proto3" json:"start_time_unix_nano,omitempty"` - // TimeUnixNano is required, see the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - TimeUnixNano uint64 `protobuf:"fixed64,3,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // The value itself. A point is considered invalid when one of the recognized - // value fields is not present inside this oneof. - // - // Types that are valid to be assigned to Value: - // *NumberDataPoint_AsDouble - // *NumberDataPoint_AsInt - Value isNumberDataPoint_Value `protobuf_oneof:"value"` - // (Optional) List of exemplars collected from - // measurements that were used to form the data point - Exemplars []Exemplar `protobuf:"bytes,5,rep,name=exemplars,proto3" json:"exemplars"` - // Flags that apply to this specific data point. See DataPointFlags - // for the available flags and their meaning. - Flags uint32 `protobuf:"varint,8,opt,name=flags,proto3" json:"flags,omitempty"` -} - -func (m *NumberDataPoint) Reset() { *m = NumberDataPoint{} } -func (m *NumberDataPoint) String() string { return proto.CompactTextString(m) } -func (*NumberDataPoint) ProtoMessage() {} -func (*NumberDataPoint) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{9} -} -func (m *NumberDataPoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NumberDataPoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NumberDataPoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *NumberDataPoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_NumberDataPoint.Merge(m, src) -} -func (m *NumberDataPoint) XXX_Size() int { - return m.Size() -} -func (m *NumberDataPoint) XXX_DiscardUnknown() { - xxx_messageInfo_NumberDataPoint.DiscardUnknown(m) -} - -var xxx_messageInfo_NumberDataPoint proto.InternalMessageInfo - -type isNumberDataPoint_Value interface { - isNumberDataPoint_Value() - MarshalTo([]byte) (int, error) - Size() int -} - -type NumberDataPoint_AsDouble struct { - AsDouble float64 `protobuf:"fixed64,4,opt,name=as_double,json=asDouble,proto3,oneof" json:"as_double,omitempty"` -} -type NumberDataPoint_AsInt struct { - AsInt int64 `protobuf:"fixed64,6,opt,name=as_int,json=asInt,proto3,oneof" json:"as_int,omitempty"` -} - -func (*NumberDataPoint_AsDouble) isNumberDataPoint_Value() {} -func (*NumberDataPoint_AsInt) isNumberDataPoint_Value() {} - -func (m *NumberDataPoint) GetValue() isNumberDataPoint_Value { - if m != nil { - return m.Value - } - return nil -} - -func (m *NumberDataPoint) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *NumberDataPoint) GetStartTimeUnixNano() uint64 { - if m != nil { - return m.StartTimeUnixNano - } - return 0 -} - -func (m *NumberDataPoint) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *NumberDataPoint) GetAsDouble() float64 { - if x, ok := m.GetValue().(*NumberDataPoint_AsDouble); ok { - return x.AsDouble - } - return 0 -} - -func (m *NumberDataPoint) GetAsInt() int64 { - if x, ok := m.GetValue().(*NumberDataPoint_AsInt); ok { - return x.AsInt - } - return 0 -} - -func (m *NumberDataPoint) GetExemplars() []Exemplar { - if m != nil { - return m.Exemplars - } - return nil -} - -func (m *NumberDataPoint) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*NumberDataPoint) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*NumberDataPoint_AsDouble)(nil), - (*NumberDataPoint_AsInt)(nil), - } -} - -// HistogramDataPoint is a single data point in a timeseries that describes the -// time-varying values of a Histogram. A Histogram contains summary statistics -// for a population of values, it may optionally contain the distribution of -// those values across a set of buckets. -// -// If the histogram contains the distribution of values, then both -// "explicit_bounds" and "bucket counts" fields must be defined. -// If the histogram does not contain the distribution of values, then both -// "explicit_bounds" and "bucket_counts" must be omitted and only "count" and -// "sum" are known. -type HistogramDataPoint struct { - // The set of key/value pairs that uniquely identify the timeseries from - // where this point belongs. The list may be empty (may contain 0 elements). - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,9,rep,name=attributes,proto3" json:"attributes"` - // StartTimeUnixNano is optional but strongly encouraged, see the - // the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - StartTimeUnixNano uint64 `protobuf:"fixed64,2,opt,name=start_time_unix_nano,json=startTimeUnixNano,proto3" json:"start_time_unix_nano,omitempty"` - // TimeUnixNano is required, see the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - TimeUnixNano uint64 `protobuf:"fixed64,3,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // count is the number of values in the population. Must be non-negative. This - // value must be equal to the sum of the "count" fields in buckets if a - // histogram is provided. - Count uint64 `protobuf:"fixed64,4,opt,name=count,proto3" json:"count,omitempty"` - // sum of the values in the population. If count is zero then this field - // must be zero. - // - // Note: Sum should only be filled out when measuring non-negative discrete - // events, and is assumed to be monotonic over the values of these events. - // Negative events *can* be recorded, but sum should not be filled out when - // doing so. This is specifically to enforce compatibility w/ OpenMetrics, - // see: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#histogram - // - // Types that are valid to be assigned to Sum_: - // *HistogramDataPoint_Sum - Sum_ isHistogramDataPoint_Sum_ `protobuf_oneof:"sum_"` - // bucket_counts is an optional field contains the count values of histogram - // for each bucket. - // - // The sum of the bucket_counts must equal the value in the count field. - // - // The number of elements in bucket_counts array must be by one greater than - // the number of elements in explicit_bounds array. The exception to this rule - // is when the length of bucket_counts is 0, then the length of explicit_bounds - // must also be 0. - BucketCounts []uint64 `protobuf:"fixed64,6,rep,packed,name=bucket_counts,json=bucketCounts,proto3" json:"bucket_counts,omitempty"` - // explicit_bounds specifies buckets with explicitly defined bounds for values. - // - // The boundaries for bucket at index i are: - // - // (-infinity, explicit_bounds[i]] for i == 0 - // (explicit_bounds[i-1], explicit_bounds[i]] for 0 < i < size(explicit_bounds) - // (explicit_bounds[i-1], +infinity) for i == size(explicit_bounds) - // - // The values in the explicit_bounds array must be strictly increasing. - // - // Histogram buckets are inclusive of their upper boundary, except the last - // bucket where the boundary is at infinity. This format is intentionally - // compatible with the OpenMetrics histogram definition. - // - // If bucket_counts length is 0 then explicit_bounds length must also be 0, - // otherwise the data point is invalid. - ExplicitBounds []float64 `protobuf:"fixed64,7,rep,packed,name=explicit_bounds,json=explicitBounds,proto3" json:"explicit_bounds,omitempty"` - // (Optional) List of exemplars collected from - // measurements that were used to form the data point - Exemplars []Exemplar `protobuf:"bytes,8,rep,name=exemplars,proto3" json:"exemplars"` - // Flags that apply to this specific data point. See DataPointFlags - // for the available flags and their meaning. - Flags uint32 `protobuf:"varint,10,opt,name=flags,proto3" json:"flags,omitempty"` - // min is the minimum value over (start_time, end_time]. - // - // Types that are valid to be assigned to Min_: - // *HistogramDataPoint_Min - Min_ isHistogramDataPoint_Min_ `protobuf_oneof:"min_"` - // max is the maximum value over (start_time, end_time]. - // - // Types that are valid to be assigned to Max_: - // *HistogramDataPoint_Max - Max_ isHistogramDataPoint_Max_ `protobuf_oneof:"max_"` -} - -func (m *HistogramDataPoint) Reset() { *m = HistogramDataPoint{} } -func (m *HistogramDataPoint) String() string { return proto.CompactTextString(m) } -func (*HistogramDataPoint) ProtoMessage() {} -func (*HistogramDataPoint) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{10} -} -func (m *HistogramDataPoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HistogramDataPoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HistogramDataPoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *HistogramDataPoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_HistogramDataPoint.Merge(m, src) -} -func (m *HistogramDataPoint) XXX_Size() int { - return m.Size() -} -func (m *HistogramDataPoint) XXX_DiscardUnknown() { - xxx_messageInfo_HistogramDataPoint.DiscardUnknown(m) -} - -var xxx_messageInfo_HistogramDataPoint proto.InternalMessageInfo - -type isHistogramDataPoint_Sum_ interface { - isHistogramDataPoint_Sum_() - MarshalTo([]byte) (int, error) - Size() int -} -type isHistogramDataPoint_Min_ interface { - isHistogramDataPoint_Min_() - MarshalTo([]byte) (int, error) - Size() int -} -type isHistogramDataPoint_Max_ interface { - isHistogramDataPoint_Max_() - MarshalTo([]byte) (int, error) - Size() int -} - -type HistogramDataPoint_Sum struct { - Sum float64 `protobuf:"fixed64,5,opt,name=sum,proto3,oneof" json:"sum,omitempty"` -} -type HistogramDataPoint_Min struct { - Min float64 `protobuf:"fixed64,11,opt,name=min,proto3,oneof" json:"min,omitempty"` -} -type HistogramDataPoint_Max struct { - Max float64 `protobuf:"fixed64,12,opt,name=max,proto3,oneof" json:"max,omitempty"` -} - -func (*HistogramDataPoint_Sum) isHistogramDataPoint_Sum_() {} -func (*HistogramDataPoint_Min) isHistogramDataPoint_Min_() {} -func (*HistogramDataPoint_Max) isHistogramDataPoint_Max_() {} - -func (m *HistogramDataPoint) GetSum_() isHistogramDataPoint_Sum_ { - if m != nil { - return m.Sum_ - } - return nil -} -func (m *HistogramDataPoint) GetMin_() isHistogramDataPoint_Min_ { - if m != nil { - return m.Min_ - } - return nil -} -func (m *HistogramDataPoint) GetMax_() isHistogramDataPoint_Max_ { - if m != nil { - return m.Max_ - } - return nil -} - -func (m *HistogramDataPoint) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *HistogramDataPoint) GetStartTimeUnixNano() uint64 { - if m != nil { - return m.StartTimeUnixNano - } - return 0 -} - -func (m *HistogramDataPoint) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *HistogramDataPoint) GetCount() uint64 { - if m != nil { - return m.Count - } - return 0 -} - -func (m *HistogramDataPoint) GetSum() float64 { - if x, ok := m.GetSum_().(*HistogramDataPoint_Sum); ok { - return x.Sum - } - return 0 -} - -func (m *HistogramDataPoint) GetBucketCounts() []uint64 { - if m != nil { - return m.BucketCounts - } - return nil -} - -func (m *HistogramDataPoint) GetExplicitBounds() []float64 { - if m != nil { - return m.ExplicitBounds - } - return nil -} - -func (m *HistogramDataPoint) GetExemplars() []Exemplar { - if m != nil { - return m.Exemplars - } - return nil -} - -func (m *HistogramDataPoint) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -func (m *HistogramDataPoint) GetMin() float64 { - if x, ok := m.GetMin_().(*HistogramDataPoint_Min); ok { - return x.Min - } - return 0 -} - -func (m *HistogramDataPoint) GetMax() float64 { - if x, ok := m.GetMax_().(*HistogramDataPoint_Max); ok { - return x.Max - } - return 0 -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*HistogramDataPoint) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*HistogramDataPoint_Sum)(nil), - (*HistogramDataPoint_Min)(nil), - (*HistogramDataPoint_Max)(nil), - } -} - -// 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 { - // The set of key/value pairs that uniquely identify the timeseries from - // where this point belongs. The list may be empty (may contain 0 elements). - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,1,rep,name=attributes,proto3" json:"attributes"` - // StartTimeUnixNano is optional but strongly encouraged, see the - // the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - StartTimeUnixNano uint64 `protobuf:"fixed64,2,opt,name=start_time_unix_nano,json=startTimeUnixNano,proto3" json:"start_time_unix_nano,omitempty"` - // TimeUnixNano is required, see the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - TimeUnixNano uint64 `protobuf:"fixed64,3,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // count is the number of values in the population. Must be - // non-negative. This value must be equal to the sum of the "bucket_counts" - // values in the positive and negative Buckets plus the "zero_count" field. - Count uint64 `protobuf:"fixed64,4,opt,name=count,proto3" json:"count,omitempty"` - // sum of the values in the population. If count is zero then this field - // must be zero. - // - // Note: Sum should only be filled out when measuring non-negative discrete - // events, and is assumed to be monotonic over the values of these events. - // Negative events *can* be recorded, but sum should not be filled out when - // doing so. This is specifically to enforce compatibility w/ OpenMetrics, - // see: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#histogram - // - // Types that are valid to be assigned to Sum_: - // *ExponentialHistogramDataPoint_Sum - Sum_ isExponentialHistogramDataPoint_Sum_ `protobuf_oneof:"sum_"` - // scale describes the resolution of the histogram. Boundaries are - // located at powers of the base, where: - // - // base = (2^(2^-scale)) - // - // The histogram bucket identified by `index`, a signed integer, - // contains values that are greater than (base^index) and - // less than or equal to (base^(index+1)). - // - // The positive and negative ranges of the histogram are expressed - // separately. Negative values are mapped by their absolute value - // into the negative range using the same scale as the positive range. - // - // scale is not restricted by the protocol, as the permissible - // values depend on the range of the data. - Scale int32 `protobuf:"zigzag32,6,opt,name=scale,proto3" json:"scale,omitempty"` - // zero_count is the count of values that are either exactly zero or - // within the region considered zero by the instrumentation at the - // tolerated degree of precision. This bucket stores values that - // cannot be expressed using the standard exponential formula as - // well as values that have been rounded to zero. - // - // Implementations MAY consider the zero bucket to have probability - // mass equal to (zero_count / count). - ZeroCount uint64 `protobuf:"fixed64,7,opt,name=zero_count,json=zeroCount,proto3" json:"zero_count,omitempty"` - // positive carries the positive range of exponential bucket counts. - Positive ExponentialHistogramDataPoint_Buckets `protobuf:"bytes,8,opt,name=positive,proto3" json:"positive"` - // negative carries the negative range of exponential bucket counts. - Negative ExponentialHistogramDataPoint_Buckets `protobuf:"bytes,9,opt,name=negative,proto3" json:"negative"` - // Flags that apply to this specific data point. See DataPointFlags - // for the available flags and their meaning. - Flags uint32 `protobuf:"varint,10,opt,name=flags,proto3" json:"flags,omitempty"` - // (Optional) List of exemplars collected from - // measurements that were used to form the data point - Exemplars []Exemplar `protobuf:"bytes,11,rep,name=exemplars,proto3" json:"exemplars"` - // min is the minimum value over (start_time, end_time]. - // - // Types that are valid to be assigned to Min_: - // *ExponentialHistogramDataPoint_Min - Min_ isExponentialHistogramDataPoint_Min_ `protobuf_oneof:"min_"` - // max is the maximum value over (start_time, end_time]. - // - // Types that are valid to be assigned to Max_: - // *ExponentialHistogramDataPoint_Max - Max_ isExponentialHistogramDataPoint_Max_ `protobuf_oneof:"max_"` - // ZeroThreshold may be optionally set to convey the width of the zero - // region. Where the zero region is defined as the closed interval - // [-ZeroThreshold, ZeroThreshold]. - // When ZeroThreshold is 0, zero count bucket stores values that cannot be - // expressed using the standard exponential formula as well as values that - // have been rounded to zero. - ZeroThreshold float64 `protobuf:"fixed64,14,opt,name=zero_threshold,json=zeroThreshold,proto3" json:"zero_threshold,omitempty"` -} - -func (m *ExponentialHistogramDataPoint) Reset() { *m = ExponentialHistogramDataPoint{} } -func (m *ExponentialHistogramDataPoint) String() string { return proto.CompactTextString(m) } -func (*ExponentialHistogramDataPoint) ProtoMessage() {} -func (*ExponentialHistogramDataPoint) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{11} -} -func (m *ExponentialHistogramDataPoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExponentialHistogramDataPoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExponentialHistogramDataPoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExponentialHistogramDataPoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExponentialHistogramDataPoint.Merge(m, src) -} -func (m *ExponentialHistogramDataPoint) XXX_Size() int { - return m.Size() -} -func (m *ExponentialHistogramDataPoint) XXX_DiscardUnknown() { - xxx_messageInfo_ExponentialHistogramDataPoint.DiscardUnknown(m) -} - -var xxx_messageInfo_ExponentialHistogramDataPoint proto.InternalMessageInfo - -type isExponentialHistogramDataPoint_Sum_ interface { - isExponentialHistogramDataPoint_Sum_() - MarshalTo([]byte) (int, error) - Size() int -} -type isExponentialHistogramDataPoint_Min_ interface { - isExponentialHistogramDataPoint_Min_() - MarshalTo([]byte) (int, error) - Size() int -} -type isExponentialHistogramDataPoint_Max_ interface { - isExponentialHistogramDataPoint_Max_() - MarshalTo([]byte) (int, error) - Size() int -} - -type ExponentialHistogramDataPoint_Sum struct { - Sum float64 `protobuf:"fixed64,5,opt,name=sum,proto3,oneof" json:"sum,omitempty"` -} -type ExponentialHistogramDataPoint_Min struct { - Min float64 `protobuf:"fixed64,12,opt,name=min,proto3,oneof" json:"min,omitempty"` -} -type ExponentialHistogramDataPoint_Max struct { - Max float64 `protobuf:"fixed64,13,opt,name=max,proto3,oneof" json:"max,omitempty"` -} - -func (*ExponentialHistogramDataPoint_Sum) isExponentialHistogramDataPoint_Sum_() {} -func (*ExponentialHistogramDataPoint_Min) isExponentialHistogramDataPoint_Min_() {} -func (*ExponentialHistogramDataPoint_Max) isExponentialHistogramDataPoint_Max_() {} - -func (m *ExponentialHistogramDataPoint) GetSum_() isExponentialHistogramDataPoint_Sum_ { - if m != nil { - return m.Sum_ - } - return nil -} -func (m *ExponentialHistogramDataPoint) GetMin_() isExponentialHistogramDataPoint_Min_ { - if m != nil { - return m.Min_ - } - return nil -} -func (m *ExponentialHistogramDataPoint) GetMax_() isExponentialHistogramDataPoint_Max_ { - if m != nil { - return m.Max_ - } - return nil -} - -func (m *ExponentialHistogramDataPoint) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *ExponentialHistogramDataPoint) GetStartTimeUnixNano() uint64 { - if m != nil { - return m.StartTimeUnixNano - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetCount() uint64 { - if m != nil { - return m.Count - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetSum() float64 { - if x, ok := m.GetSum_().(*ExponentialHistogramDataPoint_Sum); ok { - return x.Sum - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetScale() int32 { - if m != nil { - return m.Scale - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetZeroCount() uint64 { - if m != nil { - return m.ZeroCount - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetPositive() ExponentialHistogramDataPoint_Buckets { - if m != nil { - return m.Positive - } - return ExponentialHistogramDataPoint_Buckets{} -} - -func (m *ExponentialHistogramDataPoint) GetNegative() ExponentialHistogramDataPoint_Buckets { - if m != nil { - return m.Negative - } - return ExponentialHistogramDataPoint_Buckets{} -} - -func (m *ExponentialHistogramDataPoint) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetExemplars() []Exemplar { - if m != nil { - return m.Exemplars - } - return nil -} - -func (m *ExponentialHistogramDataPoint) GetMin() float64 { - if x, ok := m.GetMin_().(*ExponentialHistogramDataPoint_Min); ok { - return x.Min - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetMax() float64 { - if x, ok := m.GetMax_().(*ExponentialHistogramDataPoint_Max); ok { - return x.Max - } - return 0 -} - -func (m *ExponentialHistogramDataPoint) GetZeroThreshold() float64 { - if m != nil { - return m.ZeroThreshold - } - return 0 -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*ExponentialHistogramDataPoint) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*ExponentialHistogramDataPoint_Sum)(nil), - (*ExponentialHistogramDataPoint_Min)(nil), - (*ExponentialHistogramDataPoint_Max)(nil), - } -} - -// Buckets are a set of bucket counts, encoded in a contiguous array -// of counts. -type ExponentialHistogramDataPoint_Buckets struct { - // Offset is the bucket index of the first entry in the bucket_counts array. - // - // Note: This uses a varint encoding as a simple form of compression. - Offset int32 `protobuf:"zigzag32,1,opt,name=offset,proto3" json:"offset,omitempty"` - // bucket_counts is an array of count values, where bucket_counts[i] carries - // the count of the bucket at index (offset+i). bucket_counts[i] is the count - // of values greater than base^(offset+i) and less than or equal to - // base^(offset+i+1). - // - // Note: By contrast, the explicit HistogramDataPoint uses - // fixed64. This field is expected to have many buckets, - // especially zeros, so uint64 has been selected to ensure - // varint encoding. - BucketCounts []uint64 `protobuf:"varint,2,rep,packed,name=bucket_counts,json=bucketCounts,proto3" json:"bucket_counts,omitempty"` -} - -func (m *ExponentialHistogramDataPoint_Buckets) Reset() { *m = ExponentialHistogramDataPoint_Buckets{} } -func (m *ExponentialHistogramDataPoint_Buckets) String() string { return proto.CompactTextString(m) } -func (*ExponentialHistogramDataPoint_Buckets) ProtoMessage() {} -func (*ExponentialHistogramDataPoint_Buckets) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{11, 0} -} -func (m *ExponentialHistogramDataPoint_Buckets) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ExponentialHistogramDataPoint_Buckets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ExponentialHistogramDataPoint_Buckets.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ExponentialHistogramDataPoint_Buckets) XXX_Merge(src proto.Message) { - xxx_messageInfo_ExponentialHistogramDataPoint_Buckets.Merge(m, src) -} -func (m *ExponentialHistogramDataPoint_Buckets) XXX_Size() int { - return m.Size() -} -func (m *ExponentialHistogramDataPoint_Buckets) XXX_DiscardUnknown() { - xxx_messageInfo_ExponentialHistogramDataPoint_Buckets.DiscardUnknown(m) -} - -var xxx_messageInfo_ExponentialHistogramDataPoint_Buckets proto.InternalMessageInfo - -func (m *ExponentialHistogramDataPoint_Buckets) GetOffset() int32 { - if m != nil { - return m.Offset - } - return 0 -} - -func (m *ExponentialHistogramDataPoint_Buckets) GetBucketCounts() []uint64 { - if m != nil { - return m.BucketCounts - } - return nil -} - -// SummaryDataPoint is a single data point in a timeseries that describes the -// time-varying values of a Summary metric. The count and sum fields represent -// cumulative values. -type SummaryDataPoint struct { - // The set of key/value pairs that uniquely identify the timeseries from - // where this point belongs. The list may be empty (may contain 0 elements). - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,7,rep,name=attributes,proto3" json:"attributes"` - // StartTimeUnixNano is optional but strongly encouraged, see the - // the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - StartTimeUnixNano uint64 `protobuf:"fixed64,2,opt,name=start_time_unix_nano,json=startTimeUnixNano,proto3" json:"start_time_unix_nano,omitempty"` - // TimeUnixNano is required, see the detailed comments above Metric. - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - TimeUnixNano uint64 `protobuf:"fixed64,3,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // count is the number of values in the population. Must be non-negative. - Count uint64 `protobuf:"fixed64,4,opt,name=count,proto3" json:"count,omitempty"` - // sum of the values in the population. If count is zero then this field - // must be zero. - // - // Note: Sum should only be filled out when measuring non-negative discrete - // events, and is assumed to be monotonic over the values of these events. - // Negative events *can* be recorded, but sum should not be filled out when - // doing so. This is specifically to enforce compatibility w/ OpenMetrics, - // see: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#summary - Sum float64 `protobuf:"fixed64,5,opt,name=sum,proto3" json:"sum,omitempty"` - // (Optional) list of values at different quantiles of the distribution calculated - // from the current snapshot. The quantiles must be strictly increasing. - QuantileValues []*SummaryDataPoint_ValueAtQuantile `protobuf:"bytes,6,rep,name=quantile_values,json=quantileValues,proto3" json:"quantile_values,omitempty"` - // Flags that apply to this specific data point. See DataPointFlags - // for the available flags and their meaning. - Flags uint32 `protobuf:"varint,8,opt,name=flags,proto3" json:"flags,omitempty"` -} - -func (m *SummaryDataPoint) Reset() { *m = SummaryDataPoint{} } -func (m *SummaryDataPoint) String() string { return proto.CompactTextString(m) } -func (*SummaryDataPoint) ProtoMessage() {} -func (*SummaryDataPoint) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{12} -} -func (m *SummaryDataPoint) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SummaryDataPoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SummaryDataPoint.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SummaryDataPoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_SummaryDataPoint.Merge(m, src) -} -func (m *SummaryDataPoint) XXX_Size() int { - return m.Size() -} -func (m *SummaryDataPoint) XXX_DiscardUnknown() { - xxx_messageInfo_SummaryDataPoint.DiscardUnknown(m) -} - -var xxx_messageInfo_SummaryDataPoint proto.InternalMessageInfo - -func (m *SummaryDataPoint) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *SummaryDataPoint) GetStartTimeUnixNano() uint64 { - if m != nil { - return m.StartTimeUnixNano - } - return 0 -} - -func (m *SummaryDataPoint) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *SummaryDataPoint) GetCount() uint64 { - if m != nil { - return m.Count - } - return 0 -} - -func (m *SummaryDataPoint) GetSum() float64 { - if m != nil { - return m.Sum - } - return 0 -} - -func (m *SummaryDataPoint) GetQuantileValues() []*SummaryDataPoint_ValueAtQuantile { - if m != nil { - return m.QuantileValues - } - return nil -} - -func (m *SummaryDataPoint) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -// Represents the value at a given quantile of a distribution. -// -// To record Min and Max values following conventions are used: -// - The 1.0 quantile is equivalent to the maximum value observed. -// - The 0.0 quantile is equivalent to the minimum value observed. -// -// See the following issue for more context: -// https://github.com/open-telemetry/opentelemetry-proto/issues/125 -type SummaryDataPoint_ValueAtQuantile struct { - // The quantile of a distribution. Must be in the interval - // [0.0, 1.0]. - Quantile float64 `protobuf:"fixed64,1,opt,name=quantile,proto3" json:"quantile,omitempty"` - // The value at the given quantile of a distribution. - // - // Quantile values must NOT be negative. - Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (m *SummaryDataPoint_ValueAtQuantile) Reset() { *m = SummaryDataPoint_ValueAtQuantile{} } -func (m *SummaryDataPoint_ValueAtQuantile) String() string { return proto.CompactTextString(m) } -func (*SummaryDataPoint_ValueAtQuantile) ProtoMessage() {} -func (*SummaryDataPoint_ValueAtQuantile) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{12, 0} -} -func (m *SummaryDataPoint_ValueAtQuantile) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SummaryDataPoint_ValueAtQuantile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SummaryDataPoint_ValueAtQuantile.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SummaryDataPoint_ValueAtQuantile) XXX_Merge(src proto.Message) { - xxx_messageInfo_SummaryDataPoint_ValueAtQuantile.Merge(m, src) -} -func (m *SummaryDataPoint_ValueAtQuantile) XXX_Size() int { - return m.Size() -} -func (m *SummaryDataPoint_ValueAtQuantile) XXX_DiscardUnknown() { - xxx_messageInfo_SummaryDataPoint_ValueAtQuantile.DiscardUnknown(m) -} - -var xxx_messageInfo_SummaryDataPoint_ValueAtQuantile proto.InternalMessageInfo - -func (m *SummaryDataPoint_ValueAtQuantile) GetQuantile() float64 { - if m != nil { - return m.Quantile - } - return 0 -} - -func (m *SummaryDataPoint_ValueAtQuantile) GetValue() float64 { - if m != nil { - return m.Value - } - return 0 -} - -// A representation of an exemplar, which is a sample input measurement. -// 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 { - // The set of key/value pairs that were filtered out by the aggregator, but - // recorded alongside the original measurement. Only key/value pairs that were - // filtered out by the aggregator should be included - FilteredAttributes []v11.KeyValue `protobuf:"bytes,7,rep,name=filtered_attributes,json=filteredAttributes,proto3" json:"filtered_attributes"` - // time_unix_nano is the exact time when this exemplar was recorded - // - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - // 1970. - TimeUnixNano uint64 `protobuf:"fixed64,2,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // The value of the measurement that was recorded. An exemplar is - // considered invalid when one of the recognized value fields is not present - // inside this oneof. - // - // Types that are valid to be assigned to Value: - // *Exemplar_AsDouble - // *Exemplar_AsInt - Value isExemplar_Value `protobuf_oneof:"value"` - // (Optional) Span ID of the exemplar trace. - // span_id may be missing if the measurement is not recorded inside a trace - // or if the trace is not sampled. - SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,4,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` - // (Optional) Trace ID of the exemplar trace. - // trace_id may be missing if the measurement is not recorded inside a trace - // or if the trace is not sampled. - TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` -} - -func (m *Exemplar) Reset() { *m = Exemplar{} } -func (m *Exemplar) String() string { return proto.CompactTextString(m) } -func (*Exemplar) ProtoMessage() {} -func (*Exemplar) Descriptor() ([]byte, []int) { - return fileDescriptor_3c3112f9fa006917, []int{13} -} -func (m *Exemplar) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Exemplar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Exemplar.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Exemplar) XXX_Merge(src proto.Message) { - xxx_messageInfo_Exemplar.Merge(m, src) -} -func (m *Exemplar) XXX_Size() int { - return m.Size() -} -func (m *Exemplar) XXX_DiscardUnknown() { - xxx_messageInfo_Exemplar.DiscardUnknown(m) -} - -var xxx_messageInfo_Exemplar proto.InternalMessageInfo - -type isExemplar_Value interface { - isExemplar_Value() - MarshalTo([]byte) (int, error) - Size() int -} - -type Exemplar_AsDouble struct { - AsDouble float64 `protobuf:"fixed64,3,opt,name=as_double,json=asDouble,proto3,oneof" json:"as_double,omitempty"` -} -type Exemplar_AsInt struct { - AsInt int64 `protobuf:"fixed64,6,opt,name=as_int,json=asInt,proto3,oneof" json:"as_int,omitempty"` -} - -func (*Exemplar_AsDouble) isExemplar_Value() {} -func (*Exemplar_AsInt) isExemplar_Value() {} - -func (m *Exemplar) GetValue() isExemplar_Value { - if m != nil { - return m.Value - } - return nil -} - -func (m *Exemplar) GetFilteredAttributes() []v11.KeyValue { - if m != nil { - return m.FilteredAttributes - } - return nil -} - -func (m *Exemplar) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *Exemplar) GetAsDouble() float64 { - if x, ok := m.GetValue().(*Exemplar_AsDouble); ok { - return x.AsDouble - } - return 0 -} - -func (m *Exemplar) GetAsInt() int64 { - if x, ok := m.GetValue().(*Exemplar_AsInt); ok { - return x.AsInt - } - return 0 -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Exemplar) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Exemplar_AsDouble)(nil), - (*Exemplar_AsInt)(nil), - } -} - -func init() { - proto.RegisterEnum("opentelemetry.proto.metrics.v1.AggregationTemporality", AggregationTemporality_name, AggregationTemporality_value) - proto.RegisterEnum("opentelemetry.proto.metrics.v1.DataPointFlags", DataPointFlags_name, DataPointFlags_value) - proto.RegisterType((*MetricsData)(nil), "opentelemetry.proto.metrics.v1.MetricsData") - proto.RegisterType((*ResourceMetrics)(nil), "opentelemetry.proto.metrics.v1.ResourceMetrics") - proto.RegisterType((*ScopeMetrics)(nil), "opentelemetry.proto.metrics.v1.ScopeMetrics") - proto.RegisterType((*Metric)(nil), "opentelemetry.proto.metrics.v1.Metric") - proto.RegisterType((*Gauge)(nil), "opentelemetry.proto.metrics.v1.Gauge") - proto.RegisterType((*Sum)(nil), "opentelemetry.proto.metrics.v1.Sum") - proto.RegisterType((*Histogram)(nil), "opentelemetry.proto.metrics.v1.Histogram") - proto.RegisterType((*ExponentialHistogram)(nil), "opentelemetry.proto.metrics.v1.ExponentialHistogram") - proto.RegisterType((*Summary)(nil), "opentelemetry.proto.metrics.v1.Summary") - proto.RegisterType((*NumberDataPoint)(nil), "opentelemetry.proto.metrics.v1.NumberDataPoint") - proto.RegisterType((*HistogramDataPoint)(nil), "opentelemetry.proto.metrics.v1.HistogramDataPoint") - proto.RegisterType((*ExponentialHistogramDataPoint)(nil), "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint") - proto.RegisterType((*ExponentialHistogramDataPoint_Buckets)(nil), "opentelemetry.proto.metrics.v1.ExponentialHistogramDataPoint.Buckets") - proto.RegisterType((*SummaryDataPoint)(nil), "opentelemetry.proto.metrics.v1.SummaryDataPoint") - proto.RegisterType((*SummaryDataPoint_ValueAtQuantile)(nil), "opentelemetry.proto.metrics.v1.SummaryDataPoint.ValueAtQuantile") - proto.RegisterType((*Exemplar)(nil), "opentelemetry.proto.metrics.v1.Exemplar") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/metrics/v1/metrics.proto", fileDescriptor_3c3112f9fa006917) -} - -var fileDescriptor_3c3112f9fa006917 = []byte{ - // 1568 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x4f, 0x1b, 0x49, - 0x16, 0x77, 0xfb, 0xdb, 0xcf, 0x06, 0x9c, 0x5a, 0x96, 0xb4, 0x58, 0xe1, 0x38, 0xce, 0x26, 0xb0, - 0xd9, 0xc8, 0x5e, 0xc8, 0x6a, 0x3f, 0x0e, 0x91, 0x62, 0x63, 0x03, 0x26, 0x80, 0x49, 0xd9, 0x20, - 0x25, 0x8a, 0xd2, 0x2a, 0xec, 0xc2, 0xb4, 0xd2, 0xdd, 0xe5, 0xed, 0xae, 0x46, 0xb0, 0xff, 0xc1, - 0x4a, 0x7b, 0xc8, 0xdf, 0xb1, 0xca, 0x6d, 0x4f, 0x73, 0x9b, 0x63, 0x8e, 0x99, 0xdb, 0x68, 0x34, - 0x8a, 0x46, 0xe4, 0x30, 0x23, 0xcd, 0x3f, 0x31, 0xaa, 0xea, 0x6e, 0xfc, 0x81, 0x89, 0xc9, 0xc7, - 0x21, 0x39, 0xb9, 0xea, 0xd5, 0x7b, 0xbf, 0x7a, 0xaf, 0xde, 0xef, 0xd5, 0x2b, 0x37, 0xdc, 0x63, - 0x3d, 0x6a, 0x71, 0x6a, 0x50, 0x93, 0x72, 0xfb, 0xb4, 0xd4, 0xb3, 0x19, 0x67, 0x25, 0x31, 0xd6, - 0xdb, 0x4e, 0xe9, 0x78, 0x39, 0x18, 0x16, 0xe5, 0x02, 0xca, 0x0d, 0x69, 0x7b, 0xc2, 0x62, 0xa0, - 0x72, 0xbc, 0x3c, 0x3f, 0xdb, 0x65, 0x5d, 0xe6, 0x61, 0x88, 0x91, 0xa7, 0x30, 0x7f, 0x77, 0xdc, - 0x1e, 0x6d, 0x66, 0x9a, 0xcc, 0x12, 0x5b, 0x78, 0x23, 0x5f, 0xb7, 0x38, 0x4e, 0xd7, 0xa6, 0x0e, - 0x73, 0xed, 0x36, 0x15, 0xda, 0xc1, 0xd8, 0xd3, 0x2f, 0xe8, 0x90, 0xde, 0xf6, 0xf6, 0xaf, 0x12, - 0x4e, 0xd0, 0x53, 0xc8, 0x06, 0x0a, 0x9a, 0xef, 0x97, 0xaa, 0xe4, 0x23, 0x4b, 0xe9, 0x95, 0x52, - 0xf1, 0xfd, 0xbe, 0x17, 0xb1, 0x6f, 0xe7, 0xc3, 0xe1, 0x19, 0x7b, 0x58, 0x50, 0xf8, 0x26, 0x0c, - 0x33, 0x23, 0x4a, 0xa8, 0x0b, 0x6a, 0x87, 0xf6, 0x6c, 0xda, 0x26, 0x9c, 0x76, 0x34, 0xa7, 0xcd, - 0x7a, 0xfd, 0x7d, 0x7f, 0x49, 0xc8, 0x8d, 0xef, 0x4d, 0xda, 0xb8, 0x29, 0xac, 0x82, 0x5d, 0xe7, - 0xfa, 0x70, 0x83, 0x72, 0xf4, 0x08, 0x92, 0x81, 0x3f, 0xaa, 0x92, 0x57, 0x96, 0xd2, 0x2b, 0x7f, - 0x1a, 0x8b, 0x7b, 0x7e, 0x3c, 0x03, 0x11, 0x55, 0xa2, 0xaf, 0xdf, 0xde, 0x08, 0xe1, 0x73, 0x00, - 0xf4, 0x18, 0xa6, 0x86, 0x5d, 0x0d, 0x7f, 0x84, 0xa7, 0x19, 0x67, 0xd0, 0xbf, 0x05, 0x00, 0xa7, - 0x7d, 0x44, 0x4d, 0xa2, 0xb9, 0xb6, 0xa1, 0x46, 0xf2, 0xca, 0x52, 0x0a, 0xa7, 0x3c, 0xc9, 0x9e, - 0x6d, 0x14, 0xbe, 0x55, 0x20, 0x33, 0x14, 0x4f, 0x03, 0x62, 0xd2, 0xde, 0x0f, 0xe6, 0xfe, 0xd8, - 0xad, 0x7d, 0x66, 0x1c, 0x2f, 0x17, 0xeb, 0x96, 0xc3, 0x6d, 0xd7, 0xa4, 0x16, 0x27, 0x5c, 0x67, - 0x96, 0x84, 0xf2, 0xc3, 0xf2, 0x70, 0xd0, 0x43, 0x48, 0x0c, 0x47, 0x73, 0x67, 0x52, 0x34, 0x9e, - 0x2b, 0x38, 0x30, 0x9b, 0x14, 0xc2, 0xab, 0x28, 0xc4, 0x3d, 0x13, 0x84, 0x20, 0x6a, 0x11, 0xd3, - 0xf3, 0x3d, 0x85, 0xe5, 0x18, 0xe5, 0x21, 0xdd, 0xa1, 0x4e, 0xdb, 0xd6, 0x7b, 0xc2, 0x41, 0x35, - 0x2c, 0x97, 0x06, 0x45, 0xc2, 0xca, 0xb5, 0x74, 0xee, 0x23, 0xcb, 0x31, 0x7a, 0x00, 0xb1, 0x2e, - 0x71, 0xbb, 0x54, 0x8d, 0xc9, 0x63, 0xb8, 0x3d, 0xc9, 0xe7, 0x75, 0xa1, 0xbc, 0x11, 0xc2, 0x9e, - 0x15, 0xfa, 0x3b, 0x44, 0x1c, 0xd7, 0x54, 0x13, 0xd2, 0xf8, 0xd6, 0xc4, 0xf4, 0xb9, 0xe6, 0x46, - 0x08, 0x0b, 0x0b, 0x54, 0x87, 0xd4, 0x91, 0xee, 0x70, 0xd6, 0xb5, 0x89, 0xa9, 0xa6, 0xde, 0xc3, - 0xa7, 0x01, 0xf3, 0x8d, 0xc0, 0x60, 0x23, 0x84, 0xfb, 0xd6, 0xe8, 0x05, 0xfc, 0x9e, 0x9e, 0xf4, - 0x98, 0x45, 0x2d, 0xae, 0x13, 0x43, 0xeb, 0xc3, 0x82, 0x84, 0xfd, 0xeb, 0x24, 0xd8, 0x5a, 0xdf, - 0x78, 0x70, 0x87, 0x59, 0x3a, 0x46, 0x8e, 0x56, 0x21, 0xe1, 0xb8, 0xa6, 0x49, 0xec, 0x53, 0x35, - 0x2d, 0xe1, 0x17, 0xaf, 0x10, 0xb4, 0x50, 0xdf, 0x08, 0xe1, 0xc0, 0x12, 0xd5, 0x21, 0x69, 0x52, - 0x4e, 0x3a, 0x84, 0x13, 0x35, 0x23, 0xb9, 0xb2, 0x38, 0x81, 0x7e, 0x8f, 0xe8, 0xe9, 0x3e, 0x31, - 0xdc, 0xf3, 0x4a, 0x0a, 0xcc, 0x2b, 0x71, 0x88, 0x8a, 0xdf, 0xcd, 0x68, 0x32, 0x9a, 0x8d, 0x6d, - 0x46, 0x93, 0xf1, 0x6c, 0x62, 0x33, 0x9a, 0x4c, 0x66, 0x53, 0x85, 0x27, 0x10, 0x93, 0xc9, 0x42, - 0xbb, 0x90, 0x16, 0x2a, 0x5a, 0x8f, 0xe9, 0x16, 0xbf, 0xf2, 0x6d, 0xb4, 0xe3, 0x9a, 0x07, 0xd4, - 0x16, 0x77, 0xda, 0xae, 0xb0, 0xc3, 0xd0, 0x09, 0x86, 0x4e, 0xe1, 0x57, 0x05, 0x22, 0x4d, 0xd7, - 0xfc, 0xfc, 0xc8, 0x88, 0xc1, 0x75, 0xd2, 0xed, 0xda, 0xb4, 0x2b, 0xab, 0x4c, 0xe3, 0xd4, 0xec, - 0x31, 0x9b, 0x18, 0x3a, 0x3f, 0x95, 0x84, 0x9e, 0x5e, 0xf9, 0xdb, 0x24, 0xf4, 0x72, 0xdf, 0xbc, - 0xd5, 0xb7, 0xc6, 0x73, 0x64, 0xac, 0x1c, 0xdd, 0x84, 0x8c, 0xee, 0x68, 0x26, 0xb3, 0x18, 0x67, - 0x96, 0xde, 0x96, 0xb5, 0x91, 0xc4, 0x69, 0xdd, 0xd9, 0x0e, 0x44, 0x85, 0xef, 0x14, 0x48, 0xf5, - 0x09, 0xd0, 0x1c, 0x17, 0xf3, 0xca, 0x95, 0xa9, 0xfb, 0x65, 0x84, 0x5d, 0xf8, 0x59, 0x81, 0xd9, - 0x71, 0xbc, 0x47, 0xcf, 0xc7, 0x85, 0xf7, 0xe0, 0x63, 0x4a, 0xe8, 0x0b, 0x89, 0xf4, 0x19, 0x24, - 0xfc, 0x0a, 0x44, 0x8f, 0xc7, 0xc5, 0xf6, 0x97, 0x2b, 0xd6, 0xef, 0xf8, 0x4a, 0x38, 0x0b, 0xc3, - 0xcc, 0x08, 0x9f, 0xd1, 0x36, 0x00, 0xe1, 0xdc, 0xd6, 0x0f, 0x5c, 0x4e, 0x1d, 0x35, 0xf1, 0x31, - 0xf5, 0x3d, 0x00, 0x80, 0x4a, 0x30, 0xeb, 0x70, 0x62, 0x73, 0x8d, 0xeb, 0x26, 0xd5, 0x5c, 0x4b, - 0x3f, 0xd1, 0x2c, 0x62, 0x31, 0x79, 0x5c, 0x71, 0x7c, 0x4d, 0xae, 0xb5, 0x74, 0x93, 0xee, 0x59, - 0xfa, 0xc9, 0x0e, 0xb1, 0x18, 0xfa, 0x23, 0x4c, 0x8f, 0xa8, 0x46, 0xa4, 0x6a, 0x86, 0x0f, 0x6a, - 0x2d, 0x40, 0x8a, 0x38, 0x5a, 0x87, 0xb9, 0x07, 0x06, 0x55, 0xa3, 0x79, 0x65, 0x49, 0xd9, 0x08, - 0xe1, 0x24, 0x71, 0xaa, 0x52, 0x82, 0xae, 0x43, 0x9c, 0x38, 0x9a, 0x6e, 0x71, 0x35, 0x9e, 0x57, - 0x96, 0xb2, 0xe2, 0xc6, 0x27, 0x4e, 0xdd, 0xe2, 0x68, 0x0b, 0x52, 0xf4, 0x84, 0x9a, 0x3d, 0x83, - 0xd8, 0x8e, 0x1a, 0x93, 0xc1, 0x2d, 0x4d, 0xa6, 0x87, 0x67, 0xe0, 0x47, 0xd7, 0x07, 0x40, 0xb3, - 0x10, 0x3b, 0x34, 0x48, 0xd7, 0x51, 0x93, 0x79, 0x65, 0x69, 0x0a, 0x7b, 0x93, 0x4a, 0x02, 0x62, - 0xc7, 0xe2, 0x34, 0x36, 0xa3, 0x49, 0x25, 0x1b, 0x2e, 0xfc, 0x18, 0x01, 0x74, 0x91, 0x56, 0x23, - 0xe7, 0x9c, 0xfa, 0x42, 0xcf, 0x79, 0x16, 0x62, 0x6d, 0xe6, 0x5a, 0x5c, 0x9e, 0x71, 0x1c, 0x7b, - 0x13, 0x84, 0xbc, 0xbe, 0x19, 0xf3, 0xcf, 0x5d, 0xb6, 0xc4, 0x5b, 0x30, 0x75, 0xe0, 0xb6, 0x5f, - 0x50, 0xae, 0x49, 0x1d, 0x47, 0x8d, 0xe7, 0x23, 0x02, 0xce, 0x13, 0xae, 0x4a, 0x19, 0x5a, 0x84, - 0x19, 0x7a, 0xd2, 0x33, 0xf4, 0xb6, 0xce, 0xb5, 0x03, 0xe6, 0x5a, 0x1d, 0x8f, 0x61, 0x0a, 0x9e, - 0x0e, 0xc4, 0x15, 0x29, 0x1d, 0xce, 0x53, 0xf2, 0xb3, 0xe5, 0x09, 0x06, 0xf2, 0x24, 0xa2, 0x30, - 0x75, 0x4b, 0x36, 0x42, 0x65, 0x43, 0xc1, 0x62, 0x22, 0x65, 0xe4, 0x44, 0xcd, 0x48, 0x59, 0x18, - 0x8b, 0x89, 0x68, 0x52, 0x8e, 0x6b, 0x6a, 0xe2, 0xd7, 0xd4, 0x2d, 0xef, 0x97, 0x9c, 0x68, 0x7e, - 0x7a, 0xff, 0x13, 0x87, 0x85, 0xf7, 0x5e, 0x20, 0x23, 0x99, 0x56, 0xbe, 0xfa, 0x4c, 0xcf, 0x8a, - 0xb7, 0x27, 0x31, 0xa8, 0xac, 0xad, 0x6b, 0xd8, 0x9b, 0x88, 0xe7, 0xdf, 0xbf, 0xa9, 0xcd, 0xbc, - 0xec, 0xcb, 0x27, 0x55, 0x1c, 0xa7, 0x84, 0x44, 0xa6, 0x1e, 0x75, 0x21, 0xd9, 0x63, 0x8e, 0xce, - 0xf5, 0x63, 0x2a, 0xab, 0x25, 0xbd, 0x52, 0xfb, 0xa4, 0x6b, 0xb9, 0x58, 0x91, 0xbc, 0x72, 0x82, - 0x27, 0x45, 0x00, 0x2e, 0x36, 0xb2, 0xe4, 0x45, 0x7a, 0x4c, 0xfd, 0x97, 0xd9, 0xe7, 0xdd, 0x28, - 0x00, 0xbf, 0x84, 0x54, 0x43, 0xc4, 0x4d, 0x7f, 0x2a, 0x71, 0x7d, 0x8a, 0x66, 0xc6, 0x50, 0x74, - 0x6a, 0x80, 0xa2, 0xe8, 0x36, 0x4c, 0xcb, 0xc3, 0xe7, 0x47, 0x36, 0x75, 0x8e, 0x98, 0xd1, 0x51, - 0xa7, 0xc5, 0x32, 0x9e, 0x12, 0xd2, 0x56, 0x20, 0x9c, 0x5f, 0x83, 0x84, 0x1f, 0x0d, 0x9a, 0x83, - 0x38, 0x3b, 0x3c, 0x74, 0x28, 0x97, 0xaf, 0xf0, 0x6b, 0xd8, 0x9f, 0x5d, 0x2c, 0x63, 0xf1, 0x6f, - 0x20, 0x3a, 0x5c, 0xc6, 0x97, 0x55, 0x44, 0xe1, 0x55, 0x04, 0xb2, 0xa3, 0x0d, 0xe7, 0x2b, 0x69, - 0x28, 0xe3, 0xe9, 0x9f, 0x1d, 0xa0, 0xbf, 0x47, 0x7e, 0x1d, 0x66, 0xfe, 0xe5, 0x12, 0x8b, 0xeb, - 0x06, 0xd5, 0xe4, 0x2d, 0xef, 0x5d, 0x74, 0xe9, 0x95, 0x87, 0x1f, 0xda, 0x89, 0x8b, 0x32, 0xc2, - 0x32, 0x7f, 0xec, 0xc3, 0xe1, 0xe9, 0x00, 0x58, 0x2e, 0x5c, 0xd2, 0x5d, 0xe6, 0x57, 0x61, 0x66, - 0xc4, 0x10, 0xcd, 0x43, 0x32, 0x30, 0x95, 0xd9, 0x54, 0xf0, 0xf9, 0x5c, 0x80, 0x48, 0x37, 0xe5, - 0xf9, 0x28, 0x78, 0xa8, 0x33, 0xbd, 0x8c, 0x40, 0x32, 0xe0, 0x1e, 0x7a, 0x0e, 0xbf, 0x3b, 0xd4, - 0x0d, 0x4e, 0x6d, 0xda, 0xd1, 0x3e, 0x35, 0x5f, 0x28, 0x40, 0x2a, 0xf7, 0xf3, 0x76, 0x31, 0x0d, - 0xe1, 0x49, 0x7d, 0x3d, 0x72, 0xf5, 0xbe, 0xfe, 0x04, 0x12, 0x4e, 0x8f, 0x58, 0x9a, 0xde, 0x91, - 0x09, 0xcc, 0x54, 0x1e, 0x0a, 0x47, 0x7e, 0x78, 0x7b, 0xe3, 0x1f, 0x5d, 0x36, 0xe2, 0xbb, 0xce, - 0x4a, 0x6d, 0x66, 0x18, 0xb4, 0xcd, 0x99, 0x5d, 0xea, 0x89, 0xd7, 0x50, 0x49, 0xb7, 0x38, 0xb5, - 0x2d, 0x62, 0x94, 0xc4, 0xac, 0xd8, 0xec, 0x11, 0xab, 0x5e, 0xc5, 0x71, 0x01, 0x58, 0xef, 0xa0, - 0x67, 0x90, 0xe4, 0x36, 0x69, 0x53, 0x81, 0x1d, 0x93, 0xd8, 0x65, 0x1f, 0xfb, 0x9f, 0x1f, 0x8e, - 0xdd, 0x12, 0x48, 0xf5, 0x2a, 0x4e, 0x48, 0xc8, 0x7a, 0x67, 0xe4, 0xb1, 0x70, 0xf7, 0xbf, 0x0a, - 0xcc, 0x8d, 0x7f, 0x22, 0xa2, 0x45, 0xb8, 0x55, 0x5e, 0x5f, 0xc7, 0xb5, 0xf5, 0x72, 0xab, 0xde, - 0xd8, 0xd1, 0x5a, 0xb5, 0xed, 0xdd, 0x06, 0x2e, 0x6f, 0xd5, 0x5b, 0x4f, 0xb4, 0xbd, 0x9d, 0xe6, - 0x6e, 0x6d, 0xb5, 0xbe, 0x56, 0xaf, 0x55, 0xb3, 0x21, 0x74, 0x13, 0x16, 0x2e, 0x53, 0xac, 0xd6, - 0xb6, 0x5a, 0xe5, 0xac, 0x82, 0xee, 0x40, 0xe1, 0x32, 0x95, 0xd5, 0xbd, 0xed, 0xbd, 0xad, 0x72, - 0xab, 0xbe, 0x5f, 0xcb, 0x86, 0xef, 0x3e, 0x87, 0xe9, 0x73, 0xbe, 0xae, 0xc9, 0xfb, 0xed, 0x06, - 0xfc, 0xa1, 0x5a, 0x6e, 0x95, 0xb5, 0xdd, 0x46, 0x7d, 0xa7, 0xa5, 0xad, 0x6d, 0x95, 0xd7, 0x9b, - 0x5a, 0xb5, 0xa1, 0xed, 0x34, 0x5a, 0xda, 0x5e, 0xb3, 0x96, 0x0d, 0xa1, 0x3f, 0xc3, 0xe2, 0x05, - 0x85, 0x9d, 0x86, 0x86, 0x6b, 0xab, 0x0d, 0x5c, 0xad, 0x55, 0xb5, 0xfd, 0xf2, 0xd6, 0x5e, 0x4d, - 0xdb, 0x2e, 0x37, 0x1f, 0x65, 0x95, 0xca, 0xff, 0x95, 0xd7, 0x67, 0x39, 0xe5, 0xcd, 0x59, 0x4e, - 0xf9, 0xe9, 0x2c, 0xa7, 0xbc, 0x7c, 0x97, 0x0b, 0xbd, 0x79, 0x97, 0x0b, 0x7d, 0xff, 0x2e, 0x17, - 0x82, 0x9b, 0x3a, 0x9b, 0x50, 0x51, 0x95, 0x8c, 0xff, 0x35, 0x64, 0x57, 0x2c, 0xec, 0x2a, 0x4f, - 0x6b, 0x1f, 0x9c, 0x0f, 0xef, 0x03, 0x59, 0x97, 0x5a, 0x03, 0xdf, 0xec, 0xfe, 0x17, 0xce, 0x35, - 0x7a, 0xd4, 0x6a, 0x9d, 0x83, 0x48, 0x78, 0xff, 0x73, 0x87, 0x53, 0xdc, 0x5f, 0x3e, 0x88, 0x4b, - 0xab, 0xfb, 0xbf, 0x05, 0x00, 0x00, 0xff, 0xff, 0x00, 0xa3, 0x78, 0x2c, 0xfd, 0x13, 0x00, 0x00, -} - -func (m *MetricsData) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MetricsData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ResourceMetrics) > 0 { - for iNdEx := len(m.ResourceMetrics) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceMetrics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ResourceMetrics) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ResourceMetrics) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ResourceMetrics) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DeprecatedScopeMetrics) > 0 { - for iNdEx := len(m.DeprecatedScopeMetrics) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DeprecatedScopeMetrics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3e - i-- - dAtA[i] = 0xc2 - } - } - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.ScopeMetrics) > 0 { - for iNdEx := len(m.ScopeMetrics) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ScopeMetrics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Resource.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ScopeMetrics) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ScopeMetrics) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ScopeMetrics) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.Metrics) > 0 { - for iNdEx := len(m.Metrics) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Metrics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Scope.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Metric) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Metric) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metric) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Metadata) > 0 { - for iNdEx := len(m.Metadata) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Metadata[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - } - } - if m.Data != nil { - { - size := m.Data.Size() - i -= size - if _, err := m.Data.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if len(m.Unit) > 0 { - i -= len(m.Unit) - copy(dAtA[i:], m.Unit) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.Unit))) - i-- - dAtA[i] = 0x1a - } - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Metric_Gauge) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metric_Gauge) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Gauge != nil { - { - size, err := m.Gauge.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - return len(dAtA) - i, nil -} -func (m *Metric_Sum) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metric_Sum) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Sum != nil { - { - size, err := m.Sum.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - return len(dAtA) - i, nil -} -func (m *Metric_Histogram) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metric_Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Histogram != nil { - { - size, err := m.Histogram.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - return len(dAtA) - i, nil -} -func (m *Metric_ExponentialHistogram) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metric_ExponentialHistogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ExponentialHistogram != nil { - { - size, err := m.ExponentialHistogram.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - return len(dAtA) - i, nil -} -func (m *Metric_Summary) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metric_Summary) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Summary != nil { - { - size, err := m.Summary.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } - return len(dAtA) - i, nil -} -func (m *Gauge) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Gauge) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Gauge) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DataPoints) > 0 { - for iNdEx := len(m.DataPoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DataPoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Sum) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Sum) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Sum) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsMonotonic { - i-- - if m.IsMonotonic { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } - if m.AggregationTemporality != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.AggregationTemporality)) - i-- - dAtA[i] = 0x10 - } - if len(m.DataPoints) > 0 { - for iNdEx := len(m.DataPoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DataPoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Histogram) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Histogram) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AggregationTemporality != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.AggregationTemporality)) - i-- - dAtA[i] = 0x10 - } - if len(m.DataPoints) > 0 { - for iNdEx := len(m.DataPoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DataPoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExponentialHistogram) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExponentialHistogram) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExponentialHistogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AggregationTemporality != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.AggregationTemporality)) - i-- - dAtA[i] = 0x10 - } - if len(m.DataPoints) > 0 { - for iNdEx := len(m.DataPoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DataPoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Summary) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Summary) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Summary) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DataPoints) > 0 { - for iNdEx := len(m.DataPoints) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DataPoints[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *NumberDataPoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NumberDataPoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NumberDataPoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Flags != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.Flags)) - i-- - dAtA[i] = 0x40 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if m.Value != nil { - { - size := m.Value.Size() - i -= size - if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if len(m.Exemplars) > 0 { - for iNdEx := len(m.Exemplars) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Exemplars[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x19 - } - if m.StartTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.StartTimeUnixNano)) - i-- - dAtA[i] = 0x11 - } - return len(dAtA) - i, nil -} - -func (m *NumberDataPoint_AsDouble) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NumberDataPoint_AsDouble) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.AsDouble)))) - i-- - dAtA[i] = 0x21 - return len(dAtA) - i, nil -} -func (m *NumberDataPoint_AsInt) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NumberDataPoint_AsInt) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.AsInt)) - i-- - dAtA[i] = 0x31 - return len(dAtA) - i, nil -} -func (m *HistogramDataPoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HistogramDataPoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HistogramDataPoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Max_ != nil { - { - size := m.Max_.Size() - i -= size - if _, err := m.Max_.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if m.Min_ != nil { - { - size := m.Min_.Size() - i -= size - if _, err := m.Min_.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if m.Flags != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.Flags)) - i-- - dAtA[i] = 0x50 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - } - if len(m.Exemplars) > 0 { - for iNdEx := len(m.Exemplars) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Exemplars[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - } - if len(m.ExplicitBounds) > 0 { - for iNdEx := len(m.ExplicitBounds) - 1; iNdEx >= 0; iNdEx-- { - f8 := math.Float64bits(float64(m.ExplicitBounds[iNdEx])) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f8)) - } - i = encodeVarintMetrics(dAtA, i, uint64(len(m.ExplicitBounds)*8)) - i-- - dAtA[i] = 0x3a - } - if len(m.BucketCounts) > 0 { - for iNdEx := len(m.BucketCounts) - 1; iNdEx >= 0; iNdEx-- { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.BucketCounts[iNdEx])) - } - i = encodeVarintMetrics(dAtA, i, uint64(len(m.BucketCounts)*8)) - i-- - dAtA[i] = 0x32 - } - if m.Sum_ != nil { - { - size := m.Sum_.Size() - i -= size - if _, err := m.Sum_.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if m.Count != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Count)) - i-- - dAtA[i] = 0x21 - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x19 - } - if m.StartTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.StartTimeUnixNano)) - i-- - dAtA[i] = 0x11 - } - return len(dAtA) - i, nil -} - -func (m *HistogramDataPoint_Sum) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HistogramDataPoint_Sum) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Sum)))) - i-- - dAtA[i] = 0x29 - return len(dAtA) - i, nil -} -func (m *HistogramDataPoint_Min) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HistogramDataPoint_Min) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Min)))) - i-- - dAtA[i] = 0x59 - return len(dAtA) - i, nil -} -func (m *HistogramDataPoint_Max) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HistogramDataPoint_Max) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Max)))) - i-- - dAtA[i] = 0x61 - return len(dAtA) - i, nil -} -func (m *ExponentialHistogramDataPoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExponentialHistogramDataPoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExponentialHistogramDataPoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ZeroThreshold != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.ZeroThreshold)))) - i-- - dAtA[i] = 0x71 - } - if m.Max_ != nil { - { - size := m.Max_.Size() - i -= size - if _, err := m.Max_.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if m.Min_ != nil { - { - size := m.Min_.Size() - i -= size - if _, err := m.Min_.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if len(m.Exemplars) > 0 { - for iNdEx := len(m.Exemplars) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Exemplars[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } - } - if m.Flags != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.Flags)) - i-- - dAtA[i] = 0x50 - } - { - size, err := m.Negative.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - { - size, err := m.Positive.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - if m.ZeroCount != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.ZeroCount)) - i-- - dAtA[i] = 0x39 - } - if m.Scale != 0 { - i = encodeVarintMetrics(dAtA, i, uint64((uint32(m.Scale)<<1)^uint32((m.Scale>>31)))) - i-- - dAtA[i] = 0x30 - } - if m.Sum_ != nil { - { - size := m.Sum_.Size() - i -= size - if _, err := m.Sum_.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if m.Count != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Count)) - i-- - dAtA[i] = 0x21 - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x19 - } - if m.StartTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.StartTimeUnixNano)) - i-- - dAtA[i] = 0x11 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ExponentialHistogramDataPoint_Sum) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExponentialHistogramDataPoint_Sum) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Sum)))) - i-- - dAtA[i] = 0x29 - return len(dAtA) - i, nil -} -func (m *ExponentialHistogramDataPoint_Min) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExponentialHistogramDataPoint_Min) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Min)))) - i-- - dAtA[i] = 0x61 - return len(dAtA) - i, nil -} -func (m *ExponentialHistogramDataPoint_Max) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExponentialHistogramDataPoint_Max) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Max)))) - i-- - dAtA[i] = 0x69 - return len(dAtA) - i, nil -} -func (m *ExponentialHistogramDataPoint_Buckets) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ExponentialHistogramDataPoint_Buckets) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ExponentialHistogramDataPoint_Buckets) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BucketCounts) > 0 { - dAtA12 := make([]byte, len(m.BucketCounts)*10) - var j11 int - for _, num := range m.BucketCounts { - for num >= 1<<7 { - dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j11++ - } - dAtA12[j11] = uint8(num) - j11++ - } - i -= j11 - copy(dAtA[i:], dAtA12[:j11]) - i = encodeVarintMetrics(dAtA, i, uint64(j11)) - i-- - dAtA[i] = 0x12 - } - if m.Offset != 0 { - i = encodeVarintMetrics(dAtA, i, uint64((uint32(m.Offset)<<1)^uint32((m.Offset>>31)))) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *SummaryDataPoint) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SummaryDataPoint) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SummaryDataPoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Flags != 0 { - i = encodeVarintMetrics(dAtA, i, uint64(m.Flags)) - i-- - dAtA[i] = 0x40 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if len(m.QuantileValues) > 0 { - for iNdEx := len(m.QuantileValues) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.QuantileValues[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } - if m.Sum != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Sum)))) - i-- - dAtA[i] = 0x29 - } - if m.Count != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.Count)) - i-- - dAtA[i] = 0x21 - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x19 - } - if m.StartTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.StartTimeUnixNano)) - i-- - dAtA[i] = 0x11 - } - return len(dAtA) - i, nil -} - -func (m *SummaryDataPoint_ValueAtQuantile) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SummaryDataPoint_ValueAtQuantile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SummaryDataPoint_ValueAtQuantile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Value != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) - i-- - dAtA[i] = 0x11 - } - if m.Quantile != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Quantile)))) - i-- - dAtA[i] = 0x9 - } - return len(dAtA) - i, nil -} - -func (m *Exemplar) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Exemplar) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Exemplar) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FilteredAttributes) > 0 { - for iNdEx := len(m.FilteredAttributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FilteredAttributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if m.Value != nil { - { - size := m.Value.Size() - i -= size - if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - { - size := m.TraceId.Size() - i -= size - if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.SpanId.Size() - i -= size - if _, err := m.SpanId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMetrics(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x11 - } - return len(dAtA) - i, nil -} - -func (m *Exemplar_AsDouble) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Exemplar_AsDouble) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.AsDouble)))) - i-- - dAtA[i] = 0x19 - return len(dAtA) - i, nil -} -func (m *Exemplar_AsInt) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Exemplar_AsInt) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.AsInt)) - i-- - dAtA[i] = 0x31 - return len(dAtA) - i, nil -} -func encodeVarintMetrics(dAtA []byte, offset int, v uint64) int { - offset -= sovMetrics(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MetricsData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceMetrics) > 0 { - for _, e := range m.ResourceMetrics { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - return n -} - -func (m *ResourceMetrics) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Resource.Size() - n += 1 + l + sovMetrics(uint64(l)) - if len(m.ScopeMetrics) > 0 { - for _, e := range m.ScopeMetrics { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } - if len(m.DeprecatedScopeMetrics) > 0 { - for _, e := range m.DeprecatedScopeMetrics { - l = e.Size() - n += 2 + l + sovMetrics(uint64(l)) - } - } - return n -} - -func (m *ScopeMetrics) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Scope.Size() - n += 1 + l + sovMetrics(uint64(l)) - if len(m.Metrics) > 0 { - for _, e := range m.Metrics { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } - return n -} - -func (m *Metric) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } - l = len(m.Unit) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } - if m.Data != nil { - n += m.Data.Size() - } - if len(m.Metadata) > 0 { - for _, e := range m.Metadata { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - return n -} - -func (m *Metric_Gauge) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Gauge != nil { - l = m.Gauge.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - return n -} -func (m *Metric_Sum) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sum != nil { - l = m.Sum.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - return n -} -func (m *Metric_Histogram) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Histogram != nil { - l = m.Histogram.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - return n -} -func (m *Metric_ExponentialHistogram) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ExponentialHistogram != nil { - l = m.ExponentialHistogram.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - return n -} -func (m *Metric_Summary) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Summary != nil { - l = m.Summary.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - return n -} -func (m *Gauge) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DataPoints) > 0 { - for _, e := range m.DataPoints { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - return n -} - -func (m *Sum) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DataPoints) > 0 { - for _, e := range m.DataPoints { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.AggregationTemporality != 0 { - n += 1 + sovMetrics(uint64(m.AggregationTemporality)) - } - if m.IsMonotonic { - n += 2 - } - return n -} - -func (m *Histogram) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DataPoints) > 0 { - for _, e := range m.DataPoints { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.AggregationTemporality != 0 { - n += 1 + sovMetrics(uint64(m.AggregationTemporality)) - } - return n -} - -func (m *ExponentialHistogram) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DataPoints) > 0 { - for _, e := range m.DataPoints { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.AggregationTemporality != 0 { - n += 1 + sovMetrics(uint64(m.AggregationTemporality)) - } - return n -} - -func (m *Summary) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.DataPoints) > 0 { - for _, e := range m.DataPoints { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - return n -} - -func (m *NumberDataPoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StartTimeUnixNano != 0 { - n += 9 - } - if m.TimeUnixNano != 0 { - n += 9 - } - if m.Value != nil { - n += m.Value.Size() - } - if len(m.Exemplars) > 0 { - for _, e := range m.Exemplars { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.Flags != 0 { - n += 1 + sovMetrics(uint64(m.Flags)) - } - return n -} - -func (m *NumberDataPoint_AsDouble) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *NumberDataPoint_AsInt) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *HistogramDataPoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StartTimeUnixNano != 0 { - n += 9 - } - if m.TimeUnixNano != 0 { - n += 9 - } - if m.Count != 0 { - n += 9 - } - if m.Sum_ != nil { - n += m.Sum_.Size() - } - if len(m.BucketCounts) > 0 { - n += 1 + sovMetrics(uint64(len(m.BucketCounts)*8)) + len(m.BucketCounts)*8 - } - if len(m.ExplicitBounds) > 0 { - n += 1 + sovMetrics(uint64(len(m.ExplicitBounds)*8)) + len(m.ExplicitBounds)*8 - } - if len(m.Exemplars) > 0 { - for _, e := range m.Exemplars { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.Flags != 0 { - n += 1 + sovMetrics(uint64(m.Flags)) - } - if m.Min_ != nil { - n += m.Min_.Size() - } - if m.Max_ != nil { - n += m.Max_.Size() - } - return n -} - -func (m *HistogramDataPoint_Sum) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *HistogramDataPoint_Min) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *HistogramDataPoint_Max) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *ExponentialHistogramDataPoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.StartTimeUnixNano != 0 { - n += 9 - } - if m.TimeUnixNano != 0 { - n += 9 - } - if m.Count != 0 { - n += 9 - } - if m.Sum_ != nil { - n += m.Sum_.Size() - } - if m.Scale != 0 { - n += 1 + sozMetrics(uint64(m.Scale)) - } - if m.ZeroCount != 0 { - n += 9 - } - l = m.Positive.Size() - n += 1 + l + sovMetrics(uint64(l)) - l = m.Negative.Size() - n += 1 + l + sovMetrics(uint64(l)) - if m.Flags != 0 { - n += 1 + sovMetrics(uint64(m.Flags)) - } - if len(m.Exemplars) > 0 { - for _, e := range m.Exemplars { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.Min_ != nil { - n += m.Min_.Size() - } - if m.Max_ != nil { - n += m.Max_.Size() - } - if m.ZeroThreshold != 0 { - n += 9 - } - return n -} - -func (m *ExponentialHistogramDataPoint_Sum) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *ExponentialHistogramDataPoint_Min) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *ExponentialHistogramDataPoint_Max) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *ExponentialHistogramDataPoint_Buckets) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Offset != 0 { - n += 1 + sozMetrics(uint64(m.Offset)) - } - if len(m.BucketCounts) > 0 { - l = 0 - for _, e := range m.BucketCounts { - l += sovMetrics(uint64(e)) - } - n += 1 + sovMetrics(uint64(l)) + l - } - return n -} - -func (m *SummaryDataPoint) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StartTimeUnixNano != 0 { - n += 9 - } - if m.TimeUnixNano != 0 { - n += 9 - } - if m.Count != 0 { - n += 9 - } - if m.Sum != 0 { - n += 9 - } - if len(m.QuantileValues) > 0 { - for _, e := range m.QuantileValues { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - if m.Flags != 0 { - n += 1 + sovMetrics(uint64(m.Flags)) - } - return n -} - -func (m *SummaryDataPoint_ValueAtQuantile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Quantile != 0 { - n += 9 - } - if m.Value != 0 { - n += 9 - } - return n -} - -func (m *Exemplar) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TimeUnixNano != 0 { - n += 9 - } - if m.Value != nil { - n += m.Value.Size() - } - l = m.SpanId.Size() - n += 1 + l + sovMetrics(uint64(l)) - l = m.TraceId.Size() - n += 1 + l + sovMetrics(uint64(l)) - if len(m.FilteredAttributes) > 0 { - for _, e := range m.FilteredAttributes { - l = e.Size() - n += 1 + l + sovMetrics(uint64(l)) - } - } - return n -} - -func (m *Exemplar_AsDouble) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} -func (m *Exemplar_AsInt) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += 9 - return n -} - -func sovMetrics(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMetrics(x uint64) (n int) { - return sovMetrics(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MetricsData) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceMetrics", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceMetrics = append(m.ResourceMetrics, &ResourceMetrics{}) - if err := m.ResourceMetrics[len(m.ResourceMetrics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ResourceMetrics) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ResourceMetrics: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceMetrics: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeMetrics", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ScopeMetrics = append(m.ScopeMetrics, &ScopeMetrics{}) - if err := m.ScopeMetrics[len(m.ScopeMetrics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 1000: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedScopeMetrics", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DeprecatedScopeMetrics = append(m.DeprecatedScopeMetrics, &ScopeMetrics{}) - if err := m.DeprecatedScopeMetrics[len(m.DeprecatedScopeMetrics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ScopeMetrics) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ScopeMetrics: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeMetrics: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Scope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metrics = append(m.Metrics, &Metric{}) - if err := m.Metrics[len(m.Metrics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Metric) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Metric: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Metric: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Unit", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Unit = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gauge", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Gauge{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &Metric_Gauge{v} - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Sum{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &Metric_Sum{v} - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Histogram", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Histogram{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &Metric_Histogram{v} - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExponentialHistogram", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ExponentialHistogram{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &Metric_ExponentialHistogram{v} - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Summary", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Summary{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &Metric_Summary{v} - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Metadata = append(m.Metadata, v11.KeyValue{}) - if err := m.Metadata[len(m.Metadata)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Gauge) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Gauge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Gauge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataPoints = append(m.DataPoints, &NumberDataPoint{}) - if err := m.DataPoints[len(m.DataPoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Sum) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Sum: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Sum: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataPoints = append(m.DataPoints, &NumberDataPoint{}) - if err := m.DataPoints[len(m.DataPoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) - } - m.AggregationTemporality = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AggregationTemporality |= AggregationTemporality(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsMonotonic", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsMonotonic = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Histogram) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Histogram: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Histogram: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataPoints = append(m.DataPoints, &HistogramDataPoint{}) - if err := m.DataPoints[len(m.DataPoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) - } - m.AggregationTemporality = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AggregationTemporality |= AggregationTemporality(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExponentialHistogram) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExponentialHistogram: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExponentialHistogram: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataPoints = append(m.DataPoints, &ExponentialHistogramDataPoint{}) - if err := m.DataPoints[len(m.DataPoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) - } - m.AggregationTemporality = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AggregationTemporality |= AggregationTemporality(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Summary) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Summary: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Summary: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DataPoints = append(m.DataPoints, &SummaryDataPoint{}) - if err := m.DataPoints[len(m.DataPoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NumberDataPoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: NumberDataPoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NumberDataPoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTimeUnixNano", wireType) - } - m.StartTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.StartTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field AsDouble", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = &NumberDataPoint_AsDouble{float64(math.Float64frombits(v))} - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Exemplars", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Exemplars = append(m.Exemplars, Exemplar{}) - if err := m.Exemplars[len(m.Exemplars)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field AsInt", wireType) - } - var v int64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = &NumberDataPoint_AsInt{v} - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Flags |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HistogramDataPoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HistogramDataPoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HistogramDataPoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTimeUnixNano", wireType) - } - m.StartTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.StartTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) - } - m.Count = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Count = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 5: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Sum_ = &HistogramDataPoint_Sum{float64(math.Float64frombits(v))} - case 6: - if wireType == 1 { - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.BucketCounts = append(m.BucketCounts, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - elementCount = packedLen / 8 - if elementCount != 0 && len(m.BucketCounts) == 0 { - m.BucketCounts = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.BucketCounts = append(m.BucketCounts, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field BucketCounts", wireType) - } - case 7: - if wireType == 1 { - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - v2 := float64(math.Float64frombits(v)) - m.ExplicitBounds = append(m.ExplicitBounds, v2) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - elementCount = packedLen / 8 - if elementCount != 0 && len(m.ExplicitBounds) == 0 { - m.ExplicitBounds = make([]float64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - v2 := float64(math.Float64frombits(v)) - m.ExplicitBounds = append(m.ExplicitBounds, v2) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field ExplicitBounds", wireType) - } - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Exemplars", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Exemplars = append(m.Exemplars, Exemplar{}) - if err := m.Exemplars[len(m.Exemplars)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Flags |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Min_ = &HistogramDataPoint_Min{float64(math.Float64frombits(v))} - case 12: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Max_ = &HistogramDataPoint_Max{float64(math.Float64frombits(v))} - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExponentialHistogramDataPoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ExponentialHistogramDataPoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ExponentialHistogramDataPoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTimeUnixNano", wireType) - } - m.StartTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.StartTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) - } - m.Count = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Count = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 5: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Sum_ = &ExponentialHistogramDataPoint_Sum{float64(math.Float64frombits(v))} - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Scale", wireType) - } - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - v = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31)) - m.Scale = v - case 7: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field ZeroCount", wireType) - } - m.ZeroCount = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.ZeroCount = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Positive", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Positive.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Negative", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Negative.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Flags |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Exemplars", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Exemplars = append(m.Exemplars, Exemplar{}) - if err := m.Exemplars[len(m.Exemplars)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 12: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Min_ = &ExponentialHistogramDataPoint_Min{float64(math.Float64frombits(v))} - case 13: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Max_ = &ExponentialHistogramDataPoint_Max{float64(math.Float64frombits(v))} - case 14: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field ZeroThreshold", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.ZeroThreshold = float64(math.Float64frombits(v)) - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ExponentialHistogramDataPoint_Buckets) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Buckets: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Buckets: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) - } - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - v = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31)) - m.Offset = v - case 2: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.BucketCounts = append(m.BucketCounts, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.BucketCounts) == 0 { - m.BucketCounts = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.BucketCounts = append(m.BucketCounts, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field BucketCounts", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SummaryDataPoint) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SummaryDataPoint: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SummaryDataPoint: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTimeUnixNano", wireType) - } - m.StartTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.StartTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) - } - m.Count = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.Count = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 5: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Sum = float64(math.Float64frombits(v)) - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QuantileValues", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.QuantileValues = append(m.QuantileValues, &SummaryDataPoint_ValueAtQuantile{}) - if err := m.QuantileValues[len(m.QuantileValues)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Flags |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SummaryDataPoint_ValueAtQuantile) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ValueAtQuantile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValueAtQuantile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Quantile", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Quantile = float64(math.Float64frombits(v)) - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = float64(math.Float64frombits(v)) - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Exemplar) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Exemplar: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Exemplar: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field AsDouble", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = &Exemplar_AsDouble{float64(math.Float64frombits(v))} - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SpanId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field AsInt", wireType) - } - var v int64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = int64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.Value = &Exemplar_AsInt{v} - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FilteredAttributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMetrics - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMetrics - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMetrics - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FilteredAttributes = append(m.FilteredAttributes, v11.KeyValue{}) - if err := m.FilteredAttributes[len(m.FilteredAttributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMetrics(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMetrics - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipMetrics(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMetrics - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMetrics - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMetrics - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthMetrics - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMetrics - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMetrics - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthMetrics = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMetrics = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMetrics = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/profiles/v1development/profiles.pb.go b/pdata/internal/data/protogen/profiles/v1development/profiles.pb.go deleted file mode 100644 index e1d24c4eeda..00000000000 --- a/pdata/internal/data/protogen/profiles/v1development/profiles.pb.go +++ /dev/null @@ -1,5259 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/profiles/v1development/profiles.proto - -package v1development - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - - go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" - v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Specifies the method of aggregating metric values, either DELTA (change since last report) -// or CUMULATIVE (total since a fixed start time). -type AggregationTemporality int32 - -const ( - // UNSPECIFIED is the default AggregationTemporality, it MUST not be used. - AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED AggregationTemporality = 0 - //* DELTA is an AggregationTemporality for a profiler which reports - //changes since last report time. Successive metrics contain aggregation of - //values from continuous and non-overlapping intervals. - // - //The values for a DELTA metric are based only on the time interval - //associated with one measurement cycle. There is no dependency on - //previous measurements like is the case for CUMULATIVE metrics. - // - //For example, consider a system measuring the number of requests that - //it receives and reports the sum of these requests every second as a - //DELTA metric: - // - //1. The system starts receiving at time=t_0. - //2. A request is received, the system measures 1 request. - //3. A request is received, the system measures 1 request. - //4. A request is received, the system measures 1 request. - //5. The 1 second collection cycle ends. A metric is exported for the - //number of requests received over the interval of time t_0 to - //t_0+1 with a value of 3. - //6. A request is received, the system measures 1 request. - //7. A request is received, the system measures 1 request. - //8. The 1 second collection cycle ends. A metric is exported for the - //number of requests received over the interval of time t_0+1 to - //t_0+2 with a value of 2. - AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA AggregationTemporality = 1 - //* CUMULATIVE is an AggregationTemporality for a profiler which - //reports changes since a fixed start time. This means that current values - //of a CUMULATIVE metric depend on all previous measurements since the - //start time. Because of this, the sender is required to retain this state - //in some form. If this state is lost or invalidated, the CUMULATIVE metric - //values MUST be reset and a new fixed start time following the last - //reported measurement time sent MUST be used. - // - //For example, consider a system measuring the number of requests that - //it receives and reports the sum of these requests every second as a - //CUMULATIVE metric: - // - //1. The system starts receiving at time=t_0. - //2. A request is received, the system measures 1 request. - //3. A request is received, the system measures 1 request. - //4. A request is received, the system measures 1 request. - //5. The 1 second collection cycle ends. A metric is exported for the - //number of requests received over the interval of time t_0 to - //t_0+1 with a value of 3. - //6. A request is received, the system measures 1 request. - //7. A request is received, the system measures 1 request. - //8. The 1 second collection cycle ends. A metric is exported for the - //number of requests received over the interval of time t_0 to - //t_0+2 with a value of 5. - //9. The system experiences a fault and loses state. - //10. The system recovers and resumes receiving at time=t_1. - //11. A request is received, the system measures 1 request. - //12. The 1 second collection cycle ends. A metric is exported for the - //number of requests received over the interval of time t_1 to - //t_1+1 with a value of 1. - // - //Note: Even though, when reporting changes since last report time, using - //CUMULATIVE is valid, it is not recommended. - AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE AggregationTemporality = 2 -) - -var AggregationTemporality_name = map[int32]string{ - 0: "AGGREGATION_TEMPORALITY_UNSPECIFIED", - 1: "AGGREGATION_TEMPORALITY_DELTA", - 2: "AGGREGATION_TEMPORALITY_CUMULATIVE", -} - -var AggregationTemporality_value = map[string]int32{ - "AGGREGATION_TEMPORALITY_UNSPECIFIED": 0, - "AGGREGATION_TEMPORALITY_DELTA": 1, - "AGGREGATION_TEMPORALITY_CUMULATIVE": 2, -} - -func (x AggregationTemporality) String() string { - return proto.EnumName(AggregationTemporality_name, int32(x)) -} - -func (AggregationTemporality) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{0} -} - -// ProfilesDictionary represents the profiles data shared across the -// entire message being sent. -// -// Note that all fields in this message MUST have a zero value encoded as the first element. -// This allows for _index fields pointing into the dictionary to use a 0 pointer value -// to indicate 'null' / 'not set'. Unless otherwise defined, a 'zero value' message value -// is one with all default field values, so as to minimize wire encoded size. -type ProfilesDictionary struct { - // Mappings from address ranges to the image/binary/library mapped - // into that address range referenced by locations via Location.mapping_index. - MappingTable []*Mapping `protobuf:"bytes,1,rep,name=mapping_table,json=mappingTable,proto3" json:"mapping_table,omitempty"` - // Locations referenced by samples via Stack.location_indices. - LocationTable []*Location `protobuf:"bytes,2,rep,name=location_table,json=locationTable,proto3" json:"location_table,omitempty"` - // Functions referenced by locations via Line.function_index. - FunctionTable []*Function `protobuf:"bytes,3,rep,name=function_table,json=functionTable,proto3" json:"function_table,omitempty"` - // Links referenced by samples via Sample.link_index. - LinkTable []*Link `protobuf:"bytes,4,rep,name=link_table,json=linkTable,proto3" json:"link_table,omitempty"` - // A common table for strings referenced by various messages. - // string_table[0] must always be "". - StringTable []string `protobuf:"bytes,5,rep,name=string_table,json=stringTable,proto3" json:"string_table,omitempty"` - // A common table for attributes referenced by various messages. - // It is a collection of key/value pairs. Note, global attributes - // like server name can be set using the resource API. Examples of attributes: - // - // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" - // "/http/server_latency": 300 - // "abc.com/myattribute": true - // "abc.com/score": 10.239 - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - AttributeTable []*KeyValueAndUnit `protobuf:"bytes,6,rep,name=attribute_table,json=attributeTable,proto3" json:"attribute_table,omitempty"` - // Stacks referenced by samples via Sample.stack_index. - StackTable []*Stack `protobuf:"bytes,7,rep,name=stack_table,json=stackTable,proto3" json:"stack_table,omitempty"` -} - -func (m *ProfilesDictionary) Reset() { *m = ProfilesDictionary{} } -func (m *ProfilesDictionary) String() string { return proto.CompactTextString(m) } -func (*ProfilesDictionary) ProtoMessage() {} -func (*ProfilesDictionary) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{0} -} -func (m *ProfilesDictionary) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProfilesDictionary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProfilesDictionary.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ProfilesDictionary) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProfilesDictionary.Merge(m, src) -} -func (m *ProfilesDictionary) XXX_Size() int { - return m.Size() -} -func (m *ProfilesDictionary) XXX_DiscardUnknown() { - xxx_messageInfo_ProfilesDictionary.DiscardUnknown(m) -} - -var xxx_messageInfo_ProfilesDictionary proto.InternalMessageInfo - -func (m *ProfilesDictionary) GetMappingTable() []*Mapping { - if m != nil { - return m.MappingTable - } - return nil -} - -func (m *ProfilesDictionary) GetLocationTable() []*Location { - if m != nil { - return m.LocationTable - } - return nil -} - -func (m *ProfilesDictionary) GetFunctionTable() []*Function { - if m != nil { - return m.FunctionTable - } - return nil -} - -func (m *ProfilesDictionary) GetLinkTable() []*Link { - if m != nil { - return m.LinkTable - } - return nil -} - -func (m *ProfilesDictionary) GetStringTable() []string { - if m != nil { - return m.StringTable - } - return nil -} - -func (m *ProfilesDictionary) GetAttributeTable() []*KeyValueAndUnit { - if m != nil { - return m.AttributeTable - } - return nil -} - -func (m *ProfilesDictionary) GetStackTable() []*Stack { - if m != nil { - return m.StackTable - } - return nil -} - -// ProfilesData represents the profiles data that can be stored in persistent storage, -// OR can be embedded by other protocols that transfer OTLP profiles data but do not -// implement the OTLP protocol. -// -// The main difference between this message and collector protocol is that -// in this message there will not be any "control" or "metadata" specific to -// OTLP protocol. -// -// When new fields are added into this message, the OTLP request MUST be updated -// as well. -type ProfilesData struct { - // An array of ResourceProfiles. - // For data coming from an SDK profiler, this array will typically contain one - // element. Host-level profilers will usually create one ResourceProfile per - // container, as well as one additional ResourceProfile grouping all samples - // from non-containerized processes. - // Other resource groupings are possible as well and clarified via - // Resource.attributes and semantic conventions. - // Tools that visualize profiles should prefer displaying - // resources_profiles[0].scope_profiles[0].profiles[0] by default. - ResourceProfiles []*ResourceProfiles `protobuf:"bytes,1,rep,name=resource_profiles,json=resourceProfiles,proto3" json:"resource_profiles,omitempty"` - // One instance of ProfilesDictionary - Dictionary ProfilesDictionary `protobuf:"bytes,2,opt,name=dictionary,proto3" json:"dictionary"` -} - -func (m *ProfilesData) Reset() { *m = ProfilesData{} } -func (m *ProfilesData) String() string { return proto.CompactTextString(m) } -func (*ProfilesData) ProtoMessage() {} -func (*ProfilesData) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{1} -} -func (m *ProfilesData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProfilesData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProfilesData.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ProfilesData) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProfilesData.Merge(m, src) -} -func (m *ProfilesData) XXX_Size() int { - return m.Size() -} -func (m *ProfilesData) XXX_DiscardUnknown() { - xxx_messageInfo_ProfilesData.DiscardUnknown(m) -} - -var xxx_messageInfo_ProfilesData proto.InternalMessageInfo - -func (m *ProfilesData) GetResourceProfiles() []*ResourceProfiles { - if m != nil { - return m.ResourceProfiles - } - return nil -} - -func (m *ProfilesData) GetDictionary() ProfilesDictionary { - if m != nil { - return m.Dictionary - } - return ProfilesDictionary{} -} - -// A collection of ScopeProfiles from a Resource. -type ResourceProfiles struct { - // The resource for the profiles in this message. - // If this field is not set then no resource info is known. - Resource v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource"` - // A list of ScopeProfiles that originate from a resource. - ScopeProfiles []*ScopeProfiles `protobuf:"bytes,2,rep,name=scope_profiles,json=scopeProfiles,proto3" json:"scope_profiles,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the resource data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to the data in the "resource" field. It does not apply - // to the data in the "scope_profiles" field which have their own schema_url field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ResourceProfiles) Reset() { *m = ResourceProfiles{} } -func (m *ResourceProfiles) String() string { return proto.CompactTextString(m) } -func (*ResourceProfiles) ProtoMessage() {} -func (*ResourceProfiles) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{2} -} -func (m *ResourceProfiles) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ResourceProfiles) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ResourceProfiles.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ResourceProfiles) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResourceProfiles.Merge(m, src) -} -func (m *ResourceProfiles) XXX_Size() int { - return m.Size() -} -func (m *ResourceProfiles) XXX_DiscardUnknown() { - xxx_messageInfo_ResourceProfiles.DiscardUnknown(m) -} - -var xxx_messageInfo_ResourceProfiles proto.InternalMessageInfo - -func (m *ResourceProfiles) GetResource() v1.Resource { - if m != nil { - return m.Resource - } - return v1.Resource{} -} - -func (m *ResourceProfiles) GetScopeProfiles() []*ScopeProfiles { - if m != nil { - return m.ScopeProfiles - } - return nil -} - -func (m *ResourceProfiles) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// A collection of Profiles produced by an InstrumentationScope. -type ScopeProfiles struct { - // The instrumentation scope information for the profiles in this message. - // Semantically when InstrumentationScope isn't set, it is equivalent with - // an empty instrumentation scope name (unknown). - Scope v11.InstrumentationScope `protobuf:"bytes,1,opt,name=scope,proto3" json:"scope"` - // A list of Profiles that originate from an instrumentation scope. - Profiles []*Profile `protobuf:"bytes,2,rep,name=profiles,proto3" json:"profiles,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the profile data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to all profiles in the "profiles" field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ScopeProfiles) Reset() { *m = ScopeProfiles{} } -func (m *ScopeProfiles) String() string { return proto.CompactTextString(m) } -func (*ScopeProfiles) ProtoMessage() {} -func (*ScopeProfiles) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{3} -} -func (m *ScopeProfiles) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ScopeProfiles) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ScopeProfiles.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ScopeProfiles) XXX_Merge(src proto.Message) { - xxx_messageInfo_ScopeProfiles.Merge(m, src) -} -func (m *ScopeProfiles) XXX_Size() int { - return m.Size() -} -func (m *ScopeProfiles) XXX_DiscardUnknown() { - xxx_messageInfo_ScopeProfiles.DiscardUnknown(m) -} - -var xxx_messageInfo_ScopeProfiles proto.InternalMessageInfo - -func (m *ScopeProfiles) GetScope() v11.InstrumentationScope { - if m != nil { - return m.Scope - } - return v11.InstrumentationScope{} -} - -func (m *ScopeProfiles) GetProfiles() []*Profile { - if m != nil { - return m.Profiles - } - return nil -} - -func (m *ScopeProfiles) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// Represents a complete profile, including sample types, samples, mappings to -// binaries, stacks, locations, functions, string table, and additional -// metadata. It modifies and annotates pprof Profile with OpenTelemetry -// specific fields. -// -// Note that whilst fields in this message retain the name and field id from pprof in most cases -// for ease of understanding data migration, it is not intended that pprof:Profile and -// OpenTelemetry:Profile encoding be wire compatible. -type Profile struct { - // The type and unit of all Sample.values in this profile. - // For a cpu or off-cpu profile this might be: - // ["cpu","nanoseconds"] or ["off_cpu","nanoseconds"] - // For a heap profile, this might be: - // ["allocated_objects","count"] or ["allocated_space","bytes"], - SampleType ValueType `protobuf:"bytes,1,opt,name=sample_type,json=sampleType,proto3" json:"sample_type"` - // The set of samples recorded in this profile. - Sample []*Sample `protobuf:"bytes,2,rep,name=sample,proto3" json:"sample,omitempty"` - // Time of collection (UTC) represented as nanoseconds past the epoch. - TimeUnixNano uint64 `protobuf:"fixed64,3,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // Duration of the profile, if a duration makes sense. - DurationNano uint64 `protobuf:"varint,4,opt,name=duration_nano,json=durationNano,proto3" json:"duration_nano,omitempty"` - // The kind of events between sampled occurrences. - // e.g [ "cpu","cycles" ] or [ "heap","bytes" ] - PeriodType ValueType `protobuf:"bytes,5,opt,name=period_type,json=periodType,proto3" json:"period_type"` - // The number of events between sampled occurrences. - Period int64 `protobuf:"varint,6,opt,name=period,proto3" json:"period,omitempty"` - // Free-form text associated with the profile. The text is displayed as is - // to the user by the tools that read profiles (e.g. by pprof). This field - // should not be used to store any machine-readable information, it is only - // for human-friendly content. The profile must stay functional if this field - // is cleaned. - CommentStrindices []int32 `protobuf:"varint,7,rep,packed,name=comment_strindices,json=commentStrindices,proto3" json:"comment_strindices,omitempty"` - // A globally unique identifier for a profile. The ID is a 16-byte array. An ID with - // all zeroes is considered invalid. It may be used for deduplication and signal - // correlation purposes. It is acceptable to treat two profiles with different values - // in this field as not equal, even if they represented the same object at an earlier - // time. - // This field is optional; an ID may be assigned to an ID-less profile in a later step. - ProfileId go_opentelemetry_io_collector_pdata_internal_data.ProfileID `protobuf:"bytes,8,opt,name=profile_id,json=profileId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.ProfileID" json:"profile_id"` - // dropped_attributes_count is the number of attributes that were discarded. Attributes - // can be discarded because their keys are too long or because there are too many - // attributes. If this value is 0, then no attributes were dropped. - DroppedAttributesCount uint32 `protobuf:"varint,9,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` - // Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] - OriginalPayloadFormat string `protobuf:"bytes,10,opt,name=original_payload_format,json=originalPayloadFormat,proto3" json:"original_payload_format,omitempty"` - // Original payload can be stored in this field. This can be useful for users who want to get the original payload. - // Formats such as JFR are highly extensible and can contain more information than what is defined in this spec. - // Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload. - // If the original payload is in pprof format, it SHOULD not be included in this field. - // The field is optional, however if it is present then equivalent converted data should be populated in other fields - // of this message as far as is practicable. - OriginalPayload []byte `protobuf:"bytes,11,opt,name=original_payload,json=originalPayload,proto3" json:"original_payload,omitempty"` - // References to attributes in attribute_table. [optional] - AttributeIndices []int32 `protobuf:"varint,12,rep,packed,name=attribute_indices,json=attributeIndices,proto3" json:"attribute_indices,omitempty"` -} - -func (m *Profile) Reset() { *m = Profile{} } -func (m *Profile) String() string { return proto.CompactTextString(m) } -func (*Profile) ProtoMessage() {} -func (*Profile) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{4} -} -func (m *Profile) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Profile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Profile.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Profile) XXX_Merge(src proto.Message) { - xxx_messageInfo_Profile.Merge(m, src) -} -func (m *Profile) XXX_Size() int { - return m.Size() -} -func (m *Profile) XXX_DiscardUnknown() { - xxx_messageInfo_Profile.DiscardUnknown(m) -} - -var xxx_messageInfo_Profile proto.InternalMessageInfo - -func (m *Profile) GetSampleType() ValueType { - if m != nil { - return m.SampleType - } - return ValueType{} -} - -func (m *Profile) GetSample() []*Sample { - if m != nil { - return m.Sample - } - return nil -} - -func (m *Profile) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *Profile) GetDurationNano() uint64 { - if m != nil { - return m.DurationNano - } - return 0 -} - -func (m *Profile) GetPeriodType() ValueType { - if m != nil { - return m.PeriodType - } - return ValueType{} -} - -func (m *Profile) GetPeriod() int64 { - if m != nil { - return m.Period - } - return 0 -} - -func (m *Profile) GetCommentStrindices() []int32 { - if m != nil { - return m.CommentStrindices - } - return nil -} - -func (m *Profile) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -func (m *Profile) GetOriginalPayloadFormat() string { - if m != nil { - return m.OriginalPayloadFormat - } - return "" -} - -func (m *Profile) GetOriginalPayload() []byte { - if m != nil { - return m.OriginalPayload - } - return nil -} - -func (m *Profile) GetAttributeIndices() []int32 { - if m != nil { - return m.AttributeIndices - } - return nil -} - -// A pointer from a profile Sample to a trace Span. -// Connects a profile sample to a trace span, identified by unique trace and span IDs. -type Link struct { - // A unique identifier of a trace that this linked span is part of. The ID is a - // 16-byte array. - TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` - // A unique identifier for the linked span. The ID is an 8-byte array. - SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` -} - -func (m *Link) Reset() { *m = Link{} } -func (m *Link) String() string { return proto.CompactTextString(m) } -func (*Link) ProtoMessage() {} -func (*Link) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{5} -} -func (m *Link) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Link.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Link) XXX_Merge(src proto.Message) { - xxx_messageInfo_Link.Merge(m, src) -} -func (m *Link) XXX_Size() int { - return m.Size() -} -func (m *Link) XXX_DiscardUnknown() { - xxx_messageInfo_Link.DiscardUnknown(m) -} - -var xxx_messageInfo_Link proto.InternalMessageInfo - -// ValueType describes the type and units of a value, with an optional aggregation temporality. -type ValueType struct { - TypeStrindex int32 `protobuf:"varint,1,opt,name=type_strindex,json=typeStrindex,proto3" json:"type_strindex,omitempty"` - UnitStrindex int32 `protobuf:"varint,2,opt,name=unit_strindex,json=unitStrindex,proto3" json:"unit_strindex,omitempty"` - AggregationTemporality AggregationTemporality `protobuf:"varint,3,opt,name=aggregation_temporality,json=aggregationTemporality,proto3,enum=opentelemetry.proto.profiles.v1development.AggregationTemporality" json:"aggregation_temporality,omitempty"` -} - -func (m *ValueType) Reset() { *m = ValueType{} } -func (m *ValueType) String() string { return proto.CompactTextString(m) } -func (*ValueType) ProtoMessage() {} -func (*ValueType) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{6} -} -func (m *ValueType) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ValueType) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ValueType.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ValueType) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValueType.Merge(m, src) -} -func (m *ValueType) XXX_Size() int { - return m.Size() -} -func (m *ValueType) XXX_DiscardUnknown() { - xxx_messageInfo_ValueType.DiscardUnknown(m) -} - -var xxx_messageInfo_ValueType proto.InternalMessageInfo - -func (m *ValueType) GetTypeStrindex() int32 { - if m != nil { - return m.TypeStrindex - } - return 0 -} - -func (m *ValueType) GetUnitStrindex() int32 { - if m != nil { - return m.UnitStrindex - } - return 0 -} - -func (m *ValueType) GetAggregationTemporality() AggregationTemporality { - if m != nil { - return m.AggregationTemporality - } - return AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED -} - -// Each Sample records values encountered in some program context. The program -// context is typically a stack trace, perhaps augmented with auxiliary -// information like the thread-id, some indicator of a higher level request -// being handled etc. -// -// A Sample MUST have have at least one values or timestamps_unix_nano entry. If -// both fields are populated, they MUST contain the same number of elements, and -// the elements at the same index MUST refer to the same event. -// -// Examples of different ways of representing a sample with the total value of 10: -// -// Report of a stacktrace at 10 timestamps (consumers must assume the value is 1 for each point): -// -// values: [] -// timestamps_unix_nano: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] -// -// Report of a stacktrace with an aggregated value without timestamps: -// -// values: [10] -// timestamps_unix_nano: [] -// -// Report of a stacktrace at 4 timestamps where each point records a specific value: -// -// values: [2, 2, 3, 3] -// timestamps_unix_nano: [1, 2, 3, 4] -type Sample struct { - // Reference to stack in ProfilesDictionary.stack_table. - StackIndex int32 `protobuf:"varint,1,opt,name=stack_index,json=stackIndex,proto3" json:"stack_index,omitempty"` - // The type and unit of each value is defined by Profile.sample_type. - Values []int64 `protobuf:"varint,2,rep,packed,name=values,proto3" json:"values,omitempty"` - // References to attributes in ProfilesDictionary.attribute_table. [optional] - AttributeIndices []int32 `protobuf:"varint,3,rep,packed,name=attribute_indices,json=attributeIndices,proto3" json:"attribute_indices,omitempty"` - // Reference to link in ProfilesDictionary.link_table. [optional] - // It can be unset / set to 0 if no link exists, as link_table[0] is always a 'null' default value. - LinkIndex int32 `protobuf:"varint,4,opt,name=link_index,json=linkIndex,proto3" json:"link_index,omitempty"` - // Timestamps associated with Sample represented in nanoseconds. These - // timestamps should fall within the Profile's time range. - TimestampsUnixNano []uint64 `protobuf:"fixed64,5,rep,packed,name=timestamps_unix_nano,json=timestampsUnixNano,proto3" json:"timestamps_unix_nano,omitempty"` -} - -func (m *Sample) Reset() { *m = Sample{} } -func (m *Sample) String() string { return proto.CompactTextString(m) } -func (*Sample) ProtoMessage() {} -func (*Sample) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{7} -} -func (m *Sample) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Sample) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Sample.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Sample) XXX_Merge(src proto.Message) { - xxx_messageInfo_Sample.Merge(m, src) -} -func (m *Sample) XXX_Size() int { - return m.Size() -} -func (m *Sample) XXX_DiscardUnknown() { - xxx_messageInfo_Sample.DiscardUnknown(m) -} - -var xxx_messageInfo_Sample proto.InternalMessageInfo - -func (m *Sample) GetStackIndex() int32 { - if m != nil { - return m.StackIndex - } - return 0 -} - -func (m *Sample) GetValues() []int64 { - if m != nil { - return m.Values - } - return nil -} - -func (m *Sample) GetAttributeIndices() []int32 { - if m != nil { - return m.AttributeIndices - } - return nil -} - -func (m *Sample) GetLinkIndex() int32 { - if m != nil { - return m.LinkIndex - } - return 0 -} - -func (m *Sample) GetTimestampsUnixNano() []uint64 { - if m != nil { - return m.TimestampsUnixNano - } - return nil -} - -// Describes the mapping of a binary in memory, including its address range, -// file offset, and metadata like build ID -type Mapping struct { - // Address at which the binary (or DLL) is loaded into memory. - MemoryStart uint64 `protobuf:"varint,1,opt,name=memory_start,json=memoryStart,proto3" json:"memory_start,omitempty"` - // The limit of the address range occupied by this mapping. - MemoryLimit uint64 `protobuf:"varint,2,opt,name=memory_limit,json=memoryLimit,proto3" json:"memory_limit,omitempty"` - // Offset in the binary that corresponds to the first mapped address. - FileOffset uint64 `protobuf:"varint,3,opt,name=file_offset,json=fileOffset,proto3" json:"file_offset,omitempty"` - // The object this entry is loaded from. This can be a filename on - // disk for the main binary and shared libraries, or virtual - // abstractions like "[vdso]". - FilenameStrindex int32 `protobuf:"varint,4,opt,name=filename_strindex,json=filenameStrindex,proto3" json:"filename_strindex,omitempty"` - // References to attributes in ProfilesDictionary.attribute_table. [optional] - AttributeIndices []int32 `protobuf:"varint,5,rep,packed,name=attribute_indices,json=attributeIndices,proto3" json:"attribute_indices,omitempty"` -} - -func (m *Mapping) Reset() { *m = Mapping{} } -func (m *Mapping) String() string { return proto.CompactTextString(m) } -func (*Mapping) ProtoMessage() {} -func (*Mapping) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{8} -} -func (m *Mapping) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Mapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Mapping.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Mapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_Mapping.Merge(m, src) -} -func (m *Mapping) XXX_Size() int { - return m.Size() -} -func (m *Mapping) XXX_DiscardUnknown() { - xxx_messageInfo_Mapping.DiscardUnknown(m) -} - -var xxx_messageInfo_Mapping proto.InternalMessageInfo - -func (m *Mapping) GetMemoryStart() uint64 { - if m != nil { - return m.MemoryStart - } - return 0 -} - -func (m *Mapping) GetMemoryLimit() uint64 { - if m != nil { - return m.MemoryLimit - } - return 0 -} - -func (m *Mapping) GetFileOffset() uint64 { - if m != nil { - return m.FileOffset - } - return 0 -} - -func (m *Mapping) GetFilenameStrindex() int32 { - if m != nil { - return m.FilenameStrindex - } - return 0 -} - -func (m *Mapping) GetAttributeIndices() []int32 { - if m != nil { - return m.AttributeIndices - } - return nil -} - -// A Stack represents a stack trace as a list of locations. -type Stack struct { - // References to locations in ProfilesDictionary.location_table. - // The first location is the leaf frame. - LocationIndices []int32 `protobuf:"varint,1,rep,packed,name=location_indices,json=locationIndices,proto3" json:"location_indices,omitempty"` -} - -func (m *Stack) Reset() { *m = Stack{} } -func (m *Stack) String() string { return proto.CompactTextString(m) } -func (*Stack) ProtoMessage() {} -func (*Stack) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{9} -} -func (m *Stack) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Stack) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Stack.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Stack) XXX_Merge(src proto.Message) { - xxx_messageInfo_Stack.Merge(m, src) -} -func (m *Stack) XXX_Size() int { - return m.Size() -} -func (m *Stack) XXX_DiscardUnknown() { - xxx_messageInfo_Stack.DiscardUnknown(m) -} - -var xxx_messageInfo_Stack proto.InternalMessageInfo - -func (m *Stack) GetLocationIndices() []int32 { - if m != nil { - return m.LocationIndices - } - return nil -} - -// Describes function and line table debug information. -type Location struct { - // Reference to mapping in ProfilesDictionary.mapping_table. - // It can be unset / set to 0 if the mapping is unknown or not applicable for - // this profile type, as mapping_table[0] is always a 'null' default mapping. - MappingIndex int32 `protobuf:"varint,1,opt,name=mapping_index,json=mappingIndex,proto3" json:"mapping_index,omitempty"` - // The instruction address for this location, if available. It - // should be within [Mapping.memory_start...Mapping.memory_limit] - // for the corresponding mapping. A non-leaf address may be in the - // middle of a call instruction. It is up to display tools to find - // the beginning of the instruction if necessary. - Address uint64 `protobuf:"varint,2,opt,name=address,proto3" json:"address,omitempty"` - // Multiple line indicates this location has inlined functions, - // where the last entry represents the caller into which the - // preceding entries were inlined. - // - // E.g., if memcpy() is inlined into printf: - // line[0].function_name == "memcpy" - // line[1].function_name == "printf" - Line []*Line `protobuf:"bytes,3,rep,name=line,proto3" json:"line,omitempty"` - // References to attributes in ProfilesDictionary.attribute_table. [optional] - AttributeIndices []int32 `protobuf:"varint,4,rep,packed,name=attribute_indices,json=attributeIndices,proto3" json:"attribute_indices,omitempty"` -} - -func (m *Location) Reset() { *m = Location{} } -func (m *Location) String() string { return proto.CompactTextString(m) } -func (*Location) ProtoMessage() {} -func (*Location) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{10} -} -func (m *Location) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Location) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Location.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Location) XXX_Merge(src proto.Message) { - xxx_messageInfo_Location.Merge(m, src) -} -func (m *Location) XXX_Size() int { - return m.Size() -} -func (m *Location) XXX_DiscardUnknown() { - xxx_messageInfo_Location.DiscardUnknown(m) -} - -var xxx_messageInfo_Location proto.InternalMessageInfo - -func (m *Location) GetMappingIndex() int32 { - if m != nil { - return m.MappingIndex - } - return 0 -} - -func (m *Location) GetAddress() uint64 { - if m != nil { - return m.Address - } - return 0 -} - -func (m *Location) GetLine() []*Line { - if m != nil { - return m.Line - } - return nil -} - -func (m *Location) GetAttributeIndices() []int32 { - if m != nil { - return m.AttributeIndices - } - return nil -} - -// Details a specific line in a source code, linked to a function. -type Line struct { - // Reference to function in ProfilesDictionary.function_table. - FunctionIndex int32 `protobuf:"varint,1,opt,name=function_index,json=functionIndex,proto3" json:"function_index,omitempty"` - // Line number in source code. 0 means unset. - Line int64 `protobuf:"varint,2,opt,name=line,proto3" json:"line,omitempty"` - // Column number in source code. 0 means unset. - Column int64 `protobuf:"varint,3,opt,name=column,proto3" json:"column,omitempty"` -} - -func (m *Line) Reset() { *m = Line{} } -func (m *Line) String() string { return proto.CompactTextString(m) } -func (*Line) ProtoMessage() {} -func (*Line) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{11} -} -func (m *Line) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Line) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Line.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Line) XXX_Merge(src proto.Message) { - xxx_messageInfo_Line.Merge(m, src) -} -func (m *Line) XXX_Size() int { - return m.Size() -} -func (m *Line) XXX_DiscardUnknown() { - xxx_messageInfo_Line.DiscardUnknown(m) -} - -var xxx_messageInfo_Line proto.InternalMessageInfo - -func (m *Line) GetFunctionIndex() int32 { - if m != nil { - return m.FunctionIndex - } - return 0 -} - -func (m *Line) GetLine() int64 { - if m != nil { - return m.Line - } - return 0 -} - -func (m *Line) GetColumn() int64 { - if m != nil { - return m.Column - } - return 0 -} - -// Describes a function, including its human-readable name, system name, -// source file, and starting line number in the source. -type Function struct { - // Function name. Empty string if not available. - NameStrindex int32 `protobuf:"varint,1,opt,name=name_strindex,json=nameStrindex,proto3" json:"name_strindex,omitempty"` - // Function name, as identified by the system. For instance, - // it can be a C++ mangled name. Empty string if not available. - SystemNameStrindex int32 `protobuf:"varint,2,opt,name=system_name_strindex,json=systemNameStrindex,proto3" json:"system_name_strindex,omitempty"` - // Source file containing the function. Empty string if not available. - FilenameStrindex int32 `protobuf:"varint,3,opt,name=filename_strindex,json=filenameStrindex,proto3" json:"filename_strindex,omitempty"` - // Line number in source file. 0 means unset. - StartLine int64 `protobuf:"varint,4,opt,name=start_line,json=startLine,proto3" json:"start_line,omitempty"` -} - -func (m *Function) Reset() { *m = Function{} } -func (m *Function) String() string { return proto.CompactTextString(m) } -func (*Function) ProtoMessage() {} -func (*Function) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{12} -} -func (m *Function) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Function) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Function.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Function) XXX_Merge(src proto.Message) { - xxx_messageInfo_Function.Merge(m, src) -} -func (m *Function) XXX_Size() int { - return m.Size() -} -func (m *Function) XXX_DiscardUnknown() { - xxx_messageInfo_Function.DiscardUnknown(m) -} - -var xxx_messageInfo_Function proto.InternalMessageInfo - -func (m *Function) GetNameStrindex() int32 { - if m != nil { - return m.NameStrindex - } - return 0 -} - -func (m *Function) GetSystemNameStrindex() int32 { - if m != nil { - return m.SystemNameStrindex - } - return 0 -} - -func (m *Function) GetFilenameStrindex() int32 { - if m != nil { - return m.FilenameStrindex - } - return 0 -} - -func (m *Function) GetStartLine() int64 { - if m != nil { - return m.StartLine - } - return 0 -} - -// A custom 'dictionary native' style of encoding attributes which is more convenient -// for profiles than opentelemetry.proto.common.v1.KeyValue -// Specifically, uses the string table for keys and allows optional unit information. -type KeyValueAndUnit struct { - KeyStrindex int32 `protobuf:"varint,1,opt,name=key_strindex,json=keyStrindex,proto3" json:"key_strindex,omitempty"` - Value v11.AnyValue `protobuf:"bytes,2,opt,name=value,proto3" json:"value"` - UnitStrindex int32 `protobuf:"varint,3,opt,name=unit_strindex,json=unitStrindex,proto3" json:"unit_strindex,omitempty"` -} - -func (m *KeyValueAndUnit) Reset() { *m = KeyValueAndUnit{} } -func (m *KeyValueAndUnit) String() string { return proto.CompactTextString(m) } -func (*KeyValueAndUnit) ProtoMessage() {} -func (*KeyValueAndUnit) Descriptor() ([]byte, []int) { - return fileDescriptor_ddd0cf081a2fe76f, []int{13} -} -func (m *KeyValueAndUnit) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *KeyValueAndUnit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_KeyValueAndUnit.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *KeyValueAndUnit) XXX_Merge(src proto.Message) { - xxx_messageInfo_KeyValueAndUnit.Merge(m, src) -} -func (m *KeyValueAndUnit) XXX_Size() int { - return m.Size() -} -func (m *KeyValueAndUnit) XXX_DiscardUnknown() { - xxx_messageInfo_KeyValueAndUnit.DiscardUnknown(m) -} - -var xxx_messageInfo_KeyValueAndUnit proto.InternalMessageInfo - -func (m *KeyValueAndUnit) GetKeyStrindex() int32 { - if m != nil { - return m.KeyStrindex - } - return 0 -} - -func (m *KeyValueAndUnit) GetValue() v11.AnyValue { - if m != nil { - return m.Value - } - return v11.AnyValue{} -} - -func (m *KeyValueAndUnit) GetUnitStrindex() int32 { - if m != nil { - return m.UnitStrindex - } - return 0 -} - -func init() { - proto.RegisterEnum("opentelemetry.proto.profiles.v1development.AggregationTemporality", AggregationTemporality_name, AggregationTemporality_value) - proto.RegisterType((*ProfilesDictionary)(nil), "opentelemetry.proto.profiles.v1development.ProfilesDictionary") - proto.RegisterType((*ProfilesData)(nil), "opentelemetry.proto.profiles.v1development.ProfilesData") - proto.RegisterType((*ResourceProfiles)(nil), "opentelemetry.proto.profiles.v1development.ResourceProfiles") - proto.RegisterType((*ScopeProfiles)(nil), "opentelemetry.proto.profiles.v1development.ScopeProfiles") - proto.RegisterType((*Profile)(nil), "opentelemetry.proto.profiles.v1development.Profile") - proto.RegisterType((*Link)(nil), "opentelemetry.proto.profiles.v1development.Link") - proto.RegisterType((*ValueType)(nil), "opentelemetry.proto.profiles.v1development.ValueType") - proto.RegisterType((*Sample)(nil), "opentelemetry.proto.profiles.v1development.Sample") - proto.RegisterType((*Mapping)(nil), "opentelemetry.proto.profiles.v1development.Mapping") - proto.RegisterType((*Stack)(nil), "opentelemetry.proto.profiles.v1development.Stack") - proto.RegisterType((*Location)(nil), "opentelemetry.proto.profiles.v1development.Location") - proto.RegisterType((*Line)(nil), "opentelemetry.proto.profiles.v1development.Line") - proto.RegisterType((*Function)(nil), "opentelemetry.proto.profiles.v1development.Function") - proto.RegisterType((*KeyValueAndUnit)(nil), "opentelemetry.proto.profiles.v1development.KeyValueAndUnit") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/profiles/v1development/profiles.proto", fileDescriptor_ddd0cf081a2fe76f) -} - -var fileDescriptor_ddd0cf081a2fe76f = []byte{ - // 1475 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0x5f, 0x6f, 0x13, 0xc7, - 0x16, 0xc0, 0xb3, 0xf1, 0xbf, 0xf8, 0xd8, 0x4e, 0xcc, 0x88, 0x1b, 0x2c, 0x24, 0x82, 0x31, 0xf7, - 0x5e, 0x4c, 0xae, 0x48, 0x48, 0xb8, 0xad, 0x40, 0x54, 0x55, 0x9d, 0x38, 0xa0, 0x85, 0x90, 0xa4, - 0x13, 0x07, 0x95, 0x16, 0x69, 0x3b, 0xf1, 0x4e, 0xdc, 0x55, 0x76, 0x67, 0x57, 0xbb, 0xe3, 0x08, - 0xab, 0x5f, 0xa1, 0x0f, 0xfd, 0x04, 0xfd, 0x00, 0x95, 0xfa, 0x0d, 0x2a, 0xf5, 0x15, 0xf5, 0x89, - 0xf6, 0xa1, 0x42, 0x7d, 0xa0, 0x15, 0xbc, 0xd0, 0x6f, 0x51, 0xcd, 0x9f, 0x5d, 0xff, 0x89, 0x23, - 0xba, 0x55, 0x5f, 0xac, 0x9d, 0x33, 0x67, 0x7e, 0x67, 0xce, 0x99, 0x33, 0x67, 0x8e, 0xe1, 0x8e, - 0x1f, 0x50, 0xc6, 0xa9, 0x4b, 0x3d, 0xca, 0xc3, 0xc1, 0x6a, 0x10, 0xfa, 0xdc, 0x17, 0xbf, 0x47, - 0x8e, 0x4b, 0xa3, 0xd5, 0x93, 0x35, 0x9b, 0x9e, 0x50, 0xd7, 0x0f, 0x3c, 0xca, 0x78, 0x22, 0x5e, - 0x91, 0x5a, 0x68, 0x79, 0x6c, 0xa9, 0x12, 0xae, 0x24, 0x3a, 0x63, 0x4b, 0x2f, 0x9e, 0xef, 0xf9, - 0x3d, 0x5f, 0xc1, 0xc5, 0x97, 0x52, 0xbe, 0xb8, 0x3c, 0xcd, 0x78, 0xd7, 0xf7, 0x3c, 0x9f, 0xad, - 0x9e, 0xac, 0xe9, 0x2f, 0xad, 0xbb, 0x32, 0x4d, 0x37, 0xa4, 0x91, 0xdf, 0x0f, 0xbb, 0x54, 0x68, - 0xc7, 0xdf, 0x4a, 0xbf, 0xf1, 0x4b, 0x16, 0xd0, 0x9e, 0xde, 0x4c, 0xdb, 0xe9, 0x72, 0xc7, 0x67, - 0x24, 0x1c, 0xa0, 0x4f, 0xa0, 0xe2, 0x91, 0x20, 0x70, 0x58, 0xcf, 0xe2, 0xe4, 0xd0, 0xa5, 0x35, - 0xa3, 0x9e, 0x69, 0x96, 0xd6, 0x6f, 0xad, 0xfc, 0x75, 0x67, 0x56, 0x1e, 0x29, 0x00, 0x2e, 0x6b, - 0x52, 0x47, 0x80, 0xd0, 0x67, 0x30, 0xef, 0xfa, 0x5d, 0x22, 0x0c, 0x69, 0xf4, 0xac, 0x44, 0xff, - 0x3f, 0x0d, 0x7a, 0x5b, 0x13, 0x70, 0x25, 0x66, 0x25, 0xf0, 0xa3, 0x3e, 0xeb, 0x8e, 0xc0, 0x33, - 0xe9, 0xe1, 0xf7, 0x34, 0x01, 0x57, 0x62, 0x96, 0x82, 0xef, 0x02, 0xb8, 0x0e, 0x3b, 0xd6, 0xe0, - 0xac, 0x04, 0xdf, 0x4c, 0xb5, 0x6b, 0x87, 0x1d, 0xe3, 0xa2, 0x60, 0x28, 0xe0, 0x15, 0x28, 0x47, - 0x3c, 0x1c, 0xc6, 0x38, 0x57, 0xcf, 0x34, 0x8b, 0xb8, 0xa4, 0x64, 0x4a, 0xc5, 0x86, 0x05, 0xc2, - 0x79, 0xe8, 0x1c, 0xf6, 0x39, 0xd5, 0x5a, 0x79, 0x69, 0xf8, 0x6e, 0x1a, 0xc3, 0x0f, 0xe9, 0xe0, - 0x31, 0x71, 0xfb, 0xb4, 0xc5, 0xec, 0x03, 0xe6, 0x70, 0x3c, 0x9f, 0x30, 0x95, 0x15, 0x0c, 0xa5, - 0x88, 0x93, 0x6e, 0xec, 0x5a, 0x41, 0x5a, 0x58, 0x4b, 0x63, 0x61, 0x5f, 0x2c, 0xc7, 0x20, 0x29, - 0x92, 0xd9, 0xf8, 0xcd, 0x80, 0x72, 0x92, 0x58, 0x84, 0x13, 0xe4, 0xc0, 0xb9, 0x38, 0xf7, 0xac, - 0x98, 0xa2, 0xd3, 0xea, 0x83, 0x34, 0xa6, 0xb0, 0x86, 0xc4, 0x70, 0x5c, 0x0d, 0x27, 0x24, 0xc8, - 0x06, 0xb0, 0x93, 0x5c, 0xae, 0xcd, 0xd6, 0x8d, 0x66, 0x69, 0xfd, 0xc3, 0x34, 0x36, 0x4e, 0xdf, - 0x88, 0x8d, 0xec, 0xf3, 0x57, 0x97, 0x67, 0xf0, 0x08, 0xb7, 0xf1, 0xd6, 0x80, 0xea, 0xe4, 0x66, - 0xd0, 0x43, 0x98, 0x8b, 0xb7, 0x53, 0x33, 0xa4, 0xe1, 0xeb, 0x53, 0x0d, 0x27, 0xd7, 0xf0, 0x64, - 0x2d, 0xf1, 0x48, 0xdb, 0x48, 0x00, 0xe8, 0x73, 0x98, 0x8f, 0xba, 0x7e, 0x30, 0x12, 0x2f, 0x75, - 0x57, 0xee, 0xa4, 0x3a, 0x1a, 0x41, 0x48, 0x82, 0x55, 0x89, 0x46, 0x87, 0xe8, 0x12, 0x40, 0xd4, - 0xfd, 0x82, 0x7a, 0xc4, 0xea, 0x87, 0x6e, 0x2d, 0x53, 0x37, 0x9a, 0x45, 0x5c, 0x54, 0x92, 0x83, - 0xd0, 0x7d, 0x90, 0x9f, 0x7b, 0x5b, 0xa8, 0xfe, 0x51, 0x68, 0xbc, 0x30, 0xa0, 0x32, 0xc6, 0x41, - 0xbb, 0x90, 0x93, 0x24, 0xed, 0xe4, 0xf4, 0xc2, 0xa0, 0x2b, 0xd3, 0xc9, 0xda, 0x8a, 0xc9, 0x22, - 0x1e, 0xf6, 0xc5, 0x7e, 0xe4, 0x6d, 0x95, 0x2c, 0xed, 0xae, 0xe2, 0xa0, 0x5d, 0x98, 0x9b, 0xf0, - 0xf2, 0xd6, 0xdf, 0x38, 0x31, 0x9c, 0x40, 0xde, 0xe1, 0x5a, 0xe3, 0xa7, 0x1c, 0x14, 0xf4, 0x22, - 0xf4, 0x14, 0x4a, 0x11, 0xf1, 0x02, 0x97, 0x5a, 0x7c, 0x90, 0xb8, 0xf4, 0x5e, 0x1a, 0xf3, 0xf2, - 0x7a, 0x75, 0x06, 0x89, 0x53, 0xa0, 0x78, 0x42, 0x82, 0x1e, 0x40, 0x5e, 0x8d, 0xb4, 0x5f, 0xeb, - 0xa9, 0x4e, 0x4f, 0xae, 0xc4, 0x9a, 0x80, 0xfe, 0x0d, 0xf3, 0xdc, 0xf1, 0xa8, 0xd5, 0x67, 0xce, - 0x33, 0x8b, 0x11, 0xe6, 0x4b, 0xc7, 0xf2, 0xb8, 0x2c, 0xa4, 0x07, 0xcc, 0x79, 0xb6, 0x43, 0x98, - 0x8f, 0xae, 0x42, 0xc5, 0xee, 0x87, 0xaa, 0xc6, 0x4a, 0xa5, 0x6c, 0xdd, 0x68, 0x66, 0x71, 0x39, - 0x16, 0x4a, 0xa5, 0xa7, 0x50, 0x0a, 0x68, 0xe8, 0xf8, 0xb6, 0x72, 0x3a, 0xf7, 0x0f, 0x38, 0xad, - 0x78, 0xd2, 0xe9, 0x45, 0xc8, 0xab, 0x51, 0x2d, 0x5f, 0x37, 0x9a, 0x19, 0xac, 0x47, 0xe8, 0x06, - 0x20, 0x91, 0x15, 0x94, 0x71, 0x4b, 0xd6, 0x39, 0xdb, 0xe9, 0xd2, 0x48, 0x56, 0x9c, 0x1c, 0x3e, - 0xa7, 0x67, 0xf6, 0x93, 0x09, 0x74, 0x08, 0xa0, 0x8d, 0x5b, 0x8e, 0x5d, 0x9b, 0xab, 0x1b, 0xcd, - 0xf2, 0xc6, 0xa6, 0x30, 0xf6, 0xeb, 0xab, 0xcb, 0x77, 0x7b, 0xfe, 0xc4, 0x6e, 0x1d, 0xf1, 0x2c, - 0xba, 0x2e, 0xed, 0x72, 0x3f, 0x5c, 0x0d, 0x6c, 0xc2, 0xc9, 0xaa, 0xc3, 0x38, 0x0d, 0x19, 0x71, - 0x57, 0xc5, 0x28, 0xce, 0x12, 0xb3, 0x8d, 0x8b, 0x1a, 0x6b, 0xda, 0xe8, 0x36, 0xd4, 0xec, 0xd0, - 0x0f, 0x02, 0x6a, 0x5b, 0x49, 0x5d, 0x8c, 0xac, 0xae, 0xdf, 0x67, 0xbc, 0x56, 0xac, 0x1b, 0xcd, - 0x0a, 0x5e, 0xd4, 0xf3, 0xad, 0x64, 0x7a, 0x53, 0xcc, 0xa2, 0xf7, 0xe1, 0x82, 0x1f, 0x3a, 0x3d, - 0x87, 0x11, 0xd7, 0x0a, 0xc8, 0xc0, 0xf5, 0x89, 0x6d, 0x1d, 0xf9, 0xa1, 0x47, 0x78, 0x0d, 0x64, - 0xbe, 0xfd, 0x2b, 0x9e, 0xde, 0x53, 0xb3, 0xf7, 0xe4, 0x24, 0xba, 0x0e, 0xd5, 0xc9, 0x75, 0xb5, - 0x92, 0xf0, 0x0d, 0x2f, 0x4c, 0x2c, 0x40, 0xff, 0x83, 0x73, 0xc3, 0x07, 0x20, 0x0e, 0x57, 0x59, - 0x86, 0xab, 0x9a, 0x4c, 0x98, 0x4a, 0xde, 0xf8, 0xc1, 0x80, 0xac, 0x78, 0x64, 0xd0, 0x53, 0x98, - 0xe3, 0x21, 0xe9, 0xca, 0xa0, 0x19, 0x32, 0x68, 0x2d, 0x1d, 0xb4, 0x3b, 0xe9, 0x83, 0xd6, 0x11, - 0x24, 0xb3, 0x8d, 0x0b, 0x12, 0x69, 0xda, 0xe8, 0x09, 0x14, 0xa2, 0x80, 0x30, 0x01, 0x9f, 0x95, - 0xf0, 0x8f, 0x34, 0xfc, 0x76, 0x7a, 0xf8, 0x7e, 0x40, 0x98, 0xd9, 0xc6, 0x79, 0x01, 0x34, 0xed, - 0xc6, 0xcf, 0x06, 0x14, 0x93, 0xb4, 0x12, 0x79, 0x2c, 0x72, 0x53, 0x67, 0x0a, 0x7d, 0x26, 0x7d, - 0xc9, 0xe1, 0xb2, 0x10, 0xee, 0x6b, 0x99, 0x50, 0xea, 0x33, 0x87, 0x0f, 0x95, 0x66, 0x95, 0x92, - 0x10, 0x26, 0x4a, 0x5f, 0xc2, 0x05, 0xd2, 0xeb, 0x85, 0xb4, 0xa7, 0x1b, 0x0f, 0xea, 0x05, 0x7e, - 0x48, 0x5c, 0x87, 0x0f, 0xe4, 0x05, 0x9a, 0x5f, 0xdf, 0x48, 0x93, 0xf8, 0xad, 0x21, 0xaa, 0x33, - 0x24, 0xe1, 0x45, 0x32, 0x55, 0x2e, 0x8e, 0x25, 0xaf, 0xee, 0x31, 0xba, 0x1c, 0xbf, 0xb4, 0xa3, - 0xfe, 0xa8, 0x67, 0xd3, 0x94, 0x1b, 0x5d, 0x84, 0xfc, 0x89, 0xf0, 0x5f, 0x15, 0xc1, 0x0c, 0xd6, - 0xa3, 0xe9, 0x79, 0x90, 0x99, 0x9e, 0x07, 0xa2, 0xf4, 0xc9, 0x4e, 0x45, 0x19, 0xc9, 0x4a, 0x23, - 0xb2, 0xef, 0x50, 0x36, 0x6e, 0xc2, 0x79, 0x51, 0x2e, 0x22, 0x4e, 0xbc, 0x20, 0x1a, 0x29, 0x25, - 0xa2, 0xff, 0xc8, 0x63, 0x34, 0x9c, 0x8b, 0x0b, 0x4a, 0xe3, 0x47, 0x03, 0x0a, 0xba, 0x9d, 0x13, - 0x5d, 0x8b, 0x47, 0x3d, 0x3f, 0x1c, 0x58, 0x11, 0x27, 0x21, 0x97, 0x3e, 0x64, 0x71, 0x49, 0xc9, - 0xf6, 0x85, 0x68, 0x44, 0xc5, 0x75, 0x3c, 0x87, 0xcb, 0x13, 0x49, 0x54, 0xb6, 0x85, 0x48, 0x04, - 0x42, 0xde, 0x6a, 0xff, 0xe8, 0x28, 0xa2, 0x5c, 0x1e, 0x42, 0x16, 0x83, 0x10, 0xed, 0x4a, 0x89, - 0x70, 0x58, 0x8c, 0x18, 0xf1, 0x46, 0xce, 0x5f, 0xb9, 0x52, 0x8d, 0x27, 0x92, 0xe3, 0x9d, 0x1a, - 0x9d, 0xdc, 0x19, 0xb7, 0x64, 0x1d, 0x72, 0xb2, 0x5d, 0x11, 0xd7, 0x30, 0x69, 0x45, 0xe3, 0x45, - 0x86, 0x5c, 0xb4, 0x10, 0xcb, 0xe3, 0x35, 0xdf, 0x1b, 0x30, 0x17, 0x37, 0x9d, 0x22, 0xe3, 0xe2, - 0xe6, 0x78, 0x2c, 0x2d, 0xb5, 0x50, 0x05, 0xb9, 0x06, 0x05, 0x62, 0xdb, 0x21, 0x8d, 0x22, 0xed, - 0x7e, 0x3c, 0x44, 0x6d, 0xc8, 0xba, 0x0e, 0x8b, 0x5b, 0xd3, 0xb4, 0x1d, 0x24, 0xc5, 0x72, 0xf5, - 0x74, 0x97, 0xb3, 0x67, 0xb8, 0xfc, 0x44, 0xd6, 0x05, 0x8a, 0xfe, 0x33, 0xd2, 0x1f, 0x8f, 0x6e, - 0x3d, 0xe9, 0x74, 0xd5, 0xde, 0x91, 0xde, 0xe1, 0xac, 0x2c, 0xdd, 0xca, 0xde, 0x22, 0xe4, 0xbb, - 0xbe, 0xdb, 0xf7, 0x98, 0x3c, 0xab, 0x0c, 0xd6, 0xa3, 0xc6, 0x77, 0x06, 0xcc, 0xc5, 0x1d, 0xb3, - 0x88, 0xcc, 0xf8, 0x81, 0xe9, 0xc8, 0x8c, 0x1d, 0xd6, 0x4d, 0x38, 0x1f, 0x0d, 0x22, 0x4e, 0x3d, - 0x6b, 0x5c, 0x57, 0xdd, 0x5b, 0xa4, 0xe6, 0x76, 0x26, 0x8e, 0xf7, 0x74, 0x2e, 0x64, 0xce, 0xc8, - 0x05, 0xf1, 0xee, 0x8b, 0x2c, 0xb4, 0xa4, 0x0b, 0x59, 0xb9, 0xd9, 0xa2, 0x94, 0x88, 0x10, 0x34, - 0xbe, 0x31, 0x60, 0x61, 0xa2, 0x1f, 0x16, 0xf9, 0x7a, 0x4c, 0x07, 0x93, 0xbb, 0x2e, 0x1d, 0xd3, - 0x41, 0x42, 0xdd, 0x84, 0x9c, 0xbc, 0x89, 0xba, 0x9b, 0xbc, 0xf6, 0x8e, 0x7e, 0xa7, 0xc5, 0x94, - 0x85, 0xb8, 0xc7, 0x91, 0x6b, 0x4f, 0x97, 0xaa, 0xcc, 0xe9, 0x52, 0xb5, 0xfc, 0x95, 0x01, 0x8b, - 0xd3, 0x0b, 0x0c, 0xba, 0x06, 0x57, 0x5b, 0xf7, 0xef, 0xe3, 0xad, 0xfb, 0xad, 0x8e, 0xb9, 0xbb, - 0x63, 0x75, 0xb6, 0x1e, 0xed, 0xed, 0xe2, 0xd6, 0xb6, 0xd9, 0x79, 0x62, 0x1d, 0xec, 0xec, 0xef, - 0x6d, 0x6d, 0x9a, 0xf7, 0xcc, 0xad, 0x76, 0x75, 0x06, 0x5d, 0x81, 0x4b, 0x67, 0x29, 0xb6, 0xb7, - 0xb6, 0x3b, 0xad, 0xaa, 0x81, 0xfe, 0x0b, 0x8d, 0xb3, 0x54, 0x36, 0x0f, 0x1e, 0x1d, 0x6c, 0xb7, - 0x3a, 0xe6, 0xe3, 0xad, 0xea, 0xec, 0xc6, 0x4b, 0xe3, 0xf9, 0xeb, 0x25, 0xe3, 0xc5, 0xeb, 0x25, - 0xe3, 0xf7, 0xd7, 0x4b, 0xc6, 0xd7, 0x6f, 0x96, 0x66, 0x5e, 0xbc, 0x59, 0x9a, 0x79, 0xf9, 0x66, - 0x69, 0x06, 0x6e, 0x38, 0x7e, 0x8a, 0xe4, 0xdd, 0xa8, 0xc4, 0xcd, 0xe3, 0x9e, 0xd0, 0xda, 0x33, - 0x3e, 0xfd, 0x38, 0xf5, 0x73, 0xa1, 0xfe, 0xcf, 0xf6, 0x28, 0x3b, 0xe3, 0xbf, 0xf7, 0xb7, 0xb3, - 0xcb, 0xbb, 0x01, 0x65, 0x9d, 0x04, 0x28, 0x4d, 0x25, 0xed, 0xfc, 0xca, 0xe3, 0xb5, 0xf6, 0x50, - 0xf9, 0x30, 0x2f, 0x69, 0xb7, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x93, 0x0f, 0x25, 0xda, 0xdd, - 0x0f, 0x00, 0x00, -} - -func (m *ProfilesDictionary) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProfilesDictionary) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProfilesDictionary) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StackTable) > 0 { - for iNdEx := len(m.StackTable) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StackTable[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if len(m.AttributeTable) > 0 { - for iNdEx := len(m.AttributeTable) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AttributeTable[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } - if len(m.StringTable) > 0 { - for iNdEx := len(m.StringTable) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.StringTable[iNdEx]) - copy(dAtA[i:], m.StringTable[iNdEx]) - i = encodeVarintProfiles(dAtA, i, uint64(len(m.StringTable[iNdEx]))) - i-- - dAtA[i] = 0x2a - } - } - if len(m.LinkTable) > 0 { - for iNdEx := len(m.LinkTable) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LinkTable[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.FunctionTable) > 0 { - for iNdEx := len(m.FunctionTable) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FunctionTable[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.LocationTable) > 0 { - for iNdEx := len(m.LocationTable) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LocationTable[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.MappingTable) > 0 { - for iNdEx := len(m.MappingTable) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MappingTable[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ProfilesData) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProfilesData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProfilesData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Dictionary.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.ResourceProfiles) > 0 { - for iNdEx := len(m.ResourceProfiles) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceProfiles[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ResourceProfiles) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ResourceProfiles) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ResourceProfiles) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintProfiles(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.ScopeProfiles) > 0 { - for iNdEx := len(m.ScopeProfiles) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ScopeProfiles[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Resource.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ScopeProfiles) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ScopeProfiles) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ScopeProfiles) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintProfiles(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.Profiles) > 0 { - for iNdEx := len(m.Profiles) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Profiles[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Scope.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Profile) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Profile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Profile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AttributeIndices) > 0 { - dAtA5 := make([]byte, len(m.AttributeIndices)*10) - var j4 int - for _, num1 := range m.AttributeIndices { - num := uint64(num1) - for num >= 1<<7 { - dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j4++ - } - dAtA5[j4] = uint8(num) - j4++ - } - i -= j4 - copy(dAtA[i:], dAtA5[:j4]) - i = encodeVarintProfiles(dAtA, i, uint64(j4)) - i-- - dAtA[i] = 0x62 - } - if len(m.OriginalPayload) > 0 { - i -= len(m.OriginalPayload) - copy(dAtA[i:], m.OriginalPayload) - i = encodeVarintProfiles(dAtA, i, uint64(len(m.OriginalPayload))) - i-- - dAtA[i] = 0x5a - } - if len(m.OriginalPayloadFormat) > 0 { - i -= len(m.OriginalPayloadFormat) - copy(dAtA[i:], m.OriginalPayloadFormat) - i = encodeVarintProfiles(dAtA, i, uint64(len(m.OriginalPayloadFormat))) - i-- - dAtA[i] = 0x52 - } - if m.DroppedAttributesCount != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x48 - } - { - size := m.ProfileId.Size() - i -= size - if _, err := m.ProfileId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - if len(m.CommentStrindices) > 0 { - dAtA7 := make([]byte, len(m.CommentStrindices)*10) - var j6 int - for _, num1 := range m.CommentStrindices { - num := uint64(num1) - for num >= 1<<7 { - dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j6++ - } - dAtA7[j6] = uint8(num) - j6++ - } - i -= j6 - copy(dAtA[i:], dAtA7[:j6]) - i = encodeVarintProfiles(dAtA, i, uint64(j6)) - i-- - dAtA[i] = 0x3a - } - if m.Period != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.Period)) - i-- - dAtA[i] = 0x30 - } - { - size, err := m.PeriodType.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.DurationNano != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.DurationNano)) - i-- - dAtA[i] = 0x20 - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x19 - } - if len(m.Sample) > 0 { - for iNdEx := len(m.Sample) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Sample[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.SampleType.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Link) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Link) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Link) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.SpanId.Size() - i -= size - if _, err := m.SpanId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.TraceId.Size() - i -= size - if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ValueType) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ValueType) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValueType) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AggregationTemporality != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.AggregationTemporality)) - i-- - dAtA[i] = 0x18 - } - if m.UnitStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.UnitStrindex)) - i-- - dAtA[i] = 0x10 - } - if m.TypeStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.TypeStrindex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Sample) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Sample) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Sample) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.TimestampsUnixNano) > 0 { - for iNdEx := len(m.TimestampsUnixNano) - 1; iNdEx >= 0; iNdEx-- { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimestampsUnixNano[iNdEx])) - } - i = encodeVarintProfiles(dAtA, i, uint64(len(m.TimestampsUnixNano)*8)) - i-- - dAtA[i] = 0x2a - } - if m.LinkIndex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.LinkIndex)) - i-- - dAtA[i] = 0x20 - } - if len(m.AttributeIndices) > 0 { - dAtA11 := make([]byte, len(m.AttributeIndices)*10) - var j10 int - for _, num1 := range m.AttributeIndices { - num := uint64(num1) - for num >= 1<<7 { - dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j10++ - } - dAtA11[j10] = uint8(num) - j10++ - } - i -= j10 - copy(dAtA[i:], dAtA11[:j10]) - i = encodeVarintProfiles(dAtA, i, uint64(j10)) - i-- - dAtA[i] = 0x1a - } - if len(m.Values) > 0 { - dAtA13 := make([]byte, len(m.Values)*10) - var j12 int - for _, num1 := range m.Values { - num := uint64(num1) - for num >= 1<<7 { - dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j12++ - } - dAtA13[j12] = uint8(num) - j12++ - } - i -= j12 - copy(dAtA[i:], dAtA13[:j12]) - i = encodeVarintProfiles(dAtA, i, uint64(j12)) - i-- - dAtA[i] = 0x12 - } - if m.StackIndex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.StackIndex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Mapping) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Mapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Mapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AttributeIndices) > 0 { - dAtA15 := make([]byte, len(m.AttributeIndices)*10) - var j14 int - for _, num1 := range m.AttributeIndices { - num := uint64(num1) - for num >= 1<<7 { - dAtA15[j14] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j14++ - } - dAtA15[j14] = uint8(num) - j14++ - } - i -= j14 - copy(dAtA[i:], dAtA15[:j14]) - i = encodeVarintProfiles(dAtA, i, uint64(j14)) - i-- - dAtA[i] = 0x2a - } - if m.FilenameStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.FilenameStrindex)) - i-- - dAtA[i] = 0x20 - } - if m.FileOffset != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.FileOffset)) - i-- - dAtA[i] = 0x18 - } - if m.MemoryLimit != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.MemoryLimit)) - i-- - dAtA[i] = 0x10 - } - if m.MemoryStart != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.MemoryStart)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Stack) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Stack) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Stack) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.LocationIndices) > 0 { - dAtA17 := make([]byte, len(m.LocationIndices)*10) - var j16 int - for _, num1 := range m.LocationIndices { - num := uint64(num1) - for num >= 1<<7 { - dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j16++ - } - dAtA17[j16] = uint8(num) - j16++ - } - i -= j16 - copy(dAtA[i:], dAtA17[:j16]) - i = encodeVarintProfiles(dAtA, i, uint64(j16)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Location) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Location) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Location) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AttributeIndices) > 0 { - dAtA19 := make([]byte, len(m.AttributeIndices)*10) - var j18 int - for _, num1 := range m.AttributeIndices { - num := uint64(num1) - for num >= 1<<7 { - dAtA19[j18] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j18++ - } - dAtA19[j18] = uint8(num) - j18++ - } - i -= j18 - copy(dAtA[i:], dAtA19[:j18]) - i = encodeVarintProfiles(dAtA, i, uint64(j18)) - i-- - dAtA[i] = 0x22 - } - if len(m.Line) > 0 { - for iNdEx := len(m.Line) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Line[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if m.Address != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.Address)) - i-- - dAtA[i] = 0x10 - } - if m.MappingIndex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.MappingIndex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Line) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Line) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Line) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Column != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.Column)) - i-- - dAtA[i] = 0x18 - } - if m.Line != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.Line)) - i-- - dAtA[i] = 0x10 - } - if m.FunctionIndex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.FunctionIndex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Function) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Function) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Function) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.StartLine != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.StartLine)) - i-- - dAtA[i] = 0x20 - } - if m.FilenameStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.FilenameStrindex)) - i-- - dAtA[i] = 0x18 - } - if m.SystemNameStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.SystemNameStrindex)) - i-- - dAtA[i] = 0x10 - } - if m.NameStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.NameStrindex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *KeyValueAndUnit) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KeyValueAndUnit) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *KeyValueAndUnit) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.UnitStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.UnitStrindex)) - i-- - dAtA[i] = 0x18 - } - { - size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintProfiles(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.KeyStrindex != 0 { - i = encodeVarintProfiles(dAtA, i, uint64(m.KeyStrindex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintProfiles(dAtA []byte, offset int, v uint64) int { - offset -= sovProfiles(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *ProfilesDictionary) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.MappingTable) > 0 { - for _, e := range m.MappingTable { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.LocationTable) > 0 { - for _, e := range m.LocationTable { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.FunctionTable) > 0 { - for _, e := range m.FunctionTable { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.LinkTable) > 0 { - for _, e := range m.LinkTable { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.StringTable) > 0 { - for _, s := range m.StringTable { - l = len(s) - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.AttributeTable) > 0 { - for _, e := range m.AttributeTable { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.StackTable) > 0 { - for _, e := range m.StackTable { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - return n -} - -func (m *ProfilesData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceProfiles) > 0 { - for _, e := range m.ResourceProfiles { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - l = m.Dictionary.Size() - n += 1 + l + sovProfiles(uint64(l)) - return n -} - -func (m *ResourceProfiles) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Resource.Size() - n += 1 + l + sovProfiles(uint64(l)) - if len(m.ScopeProfiles) > 0 { - for _, e := range m.ScopeProfiles { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovProfiles(uint64(l)) - } - return n -} - -func (m *ScopeProfiles) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Scope.Size() - n += 1 + l + sovProfiles(uint64(l)) - if len(m.Profiles) > 0 { - for _, e := range m.Profiles { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovProfiles(uint64(l)) - } - return n -} - -func (m *Profile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.SampleType.Size() - n += 1 + l + sovProfiles(uint64(l)) - if len(m.Sample) > 0 { - for _, e := range m.Sample { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if m.TimeUnixNano != 0 { - n += 9 - } - if m.DurationNano != 0 { - n += 1 + sovProfiles(uint64(m.DurationNano)) - } - l = m.PeriodType.Size() - n += 1 + l + sovProfiles(uint64(l)) - if m.Period != 0 { - n += 1 + sovProfiles(uint64(m.Period)) - } - if len(m.CommentStrindices) > 0 { - l = 0 - for _, e := range m.CommentStrindices { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - l = m.ProfileId.Size() - n += 1 + l + sovProfiles(uint64(l)) - if m.DroppedAttributesCount != 0 { - n += 1 + sovProfiles(uint64(m.DroppedAttributesCount)) - } - l = len(m.OriginalPayloadFormat) - if l > 0 { - n += 1 + l + sovProfiles(uint64(l)) - } - l = len(m.OriginalPayload) - if l > 0 { - n += 1 + l + sovProfiles(uint64(l)) - } - if len(m.AttributeIndices) > 0 { - l = 0 - for _, e := range m.AttributeIndices { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - return n -} - -func (m *Link) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.TraceId.Size() - n += 1 + l + sovProfiles(uint64(l)) - l = m.SpanId.Size() - n += 1 + l + sovProfiles(uint64(l)) - return n -} - -func (m *ValueType) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TypeStrindex != 0 { - n += 1 + sovProfiles(uint64(m.TypeStrindex)) - } - if m.UnitStrindex != 0 { - n += 1 + sovProfiles(uint64(m.UnitStrindex)) - } - if m.AggregationTemporality != 0 { - n += 1 + sovProfiles(uint64(m.AggregationTemporality)) - } - return n -} - -func (m *Sample) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StackIndex != 0 { - n += 1 + sovProfiles(uint64(m.StackIndex)) - } - if len(m.Values) > 0 { - l = 0 - for _, e := range m.Values { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - if len(m.AttributeIndices) > 0 { - l = 0 - for _, e := range m.AttributeIndices { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - if m.LinkIndex != 0 { - n += 1 + sovProfiles(uint64(m.LinkIndex)) - } - if len(m.TimestampsUnixNano) > 0 { - n += 1 + sovProfiles(uint64(len(m.TimestampsUnixNano)*8)) + len(m.TimestampsUnixNano)*8 - } - return n -} - -func (m *Mapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MemoryStart != 0 { - n += 1 + sovProfiles(uint64(m.MemoryStart)) - } - if m.MemoryLimit != 0 { - n += 1 + sovProfiles(uint64(m.MemoryLimit)) - } - if m.FileOffset != 0 { - n += 1 + sovProfiles(uint64(m.FileOffset)) - } - if m.FilenameStrindex != 0 { - n += 1 + sovProfiles(uint64(m.FilenameStrindex)) - } - if len(m.AttributeIndices) > 0 { - l = 0 - for _, e := range m.AttributeIndices { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - return n -} - -func (m *Stack) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.LocationIndices) > 0 { - l = 0 - for _, e := range m.LocationIndices { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - return n -} - -func (m *Location) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MappingIndex != 0 { - n += 1 + sovProfiles(uint64(m.MappingIndex)) - } - if m.Address != 0 { - n += 1 + sovProfiles(uint64(m.Address)) - } - if len(m.Line) > 0 { - for _, e := range m.Line { - l = e.Size() - n += 1 + l + sovProfiles(uint64(l)) - } - } - if len(m.AttributeIndices) > 0 { - l = 0 - for _, e := range m.AttributeIndices { - l += sovProfiles(uint64(e)) - } - n += 1 + sovProfiles(uint64(l)) + l - } - return n -} - -func (m *Line) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FunctionIndex != 0 { - n += 1 + sovProfiles(uint64(m.FunctionIndex)) - } - if m.Line != 0 { - n += 1 + sovProfiles(uint64(m.Line)) - } - if m.Column != 0 { - n += 1 + sovProfiles(uint64(m.Column)) - } - return n -} - -func (m *Function) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NameStrindex != 0 { - n += 1 + sovProfiles(uint64(m.NameStrindex)) - } - if m.SystemNameStrindex != 0 { - n += 1 + sovProfiles(uint64(m.SystemNameStrindex)) - } - if m.FilenameStrindex != 0 { - n += 1 + sovProfiles(uint64(m.FilenameStrindex)) - } - if m.StartLine != 0 { - n += 1 + sovProfiles(uint64(m.StartLine)) - } - return n -} - -func (m *KeyValueAndUnit) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.KeyStrindex != 0 { - n += 1 + sovProfiles(uint64(m.KeyStrindex)) - } - l = m.Value.Size() - n += 1 + l + sovProfiles(uint64(l)) - if m.UnitStrindex != 0 { - n += 1 + sovProfiles(uint64(m.UnitStrindex)) - } - return n -} - -func sovProfiles(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozProfiles(x uint64) (n int) { - return sovProfiles(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *ProfilesDictionary) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProfilesDictionary: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProfilesDictionary: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MappingTable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MappingTable = append(m.MappingTable, &Mapping{}) - if err := m.MappingTable[len(m.MappingTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LocationTable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LocationTable = append(m.LocationTable, &Location{}) - if err := m.LocationTable[len(m.LocationTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FunctionTable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FunctionTable = append(m.FunctionTable, &Function{}) - if err := m.FunctionTable[len(m.FunctionTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LinkTable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LinkTable = append(m.LinkTable, &Link{}) - if err := m.LinkTable[len(m.LinkTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StringTable", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StringTable = append(m.StringTable, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AttributeTable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AttributeTable = append(m.AttributeTable, &KeyValueAndUnit{}) - if err := m.AttributeTable[len(m.AttributeTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StackTable", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StackTable = append(m.StackTable, &Stack{}) - if err := m.StackTable[len(m.StackTable)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ProfilesData) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProfilesData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProfilesData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceProfiles", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceProfiles = append(m.ResourceProfiles, &ResourceProfiles{}) - if err := m.ResourceProfiles[len(m.ResourceProfiles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Dictionary", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Dictionary.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ResourceProfiles) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ResourceProfiles: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceProfiles: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeProfiles", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ScopeProfiles = append(m.ScopeProfiles, &ScopeProfiles{}) - if err := m.ScopeProfiles[len(m.ScopeProfiles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ScopeProfiles) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ScopeProfiles: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeProfiles: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Scope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Profiles", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Profiles = append(m.Profiles, &Profile{}) - if err := m.Profiles[len(m.Profiles)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Profile) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Profile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Profile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SampleType", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SampleType.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sample", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sample = append(m.Sample, &Sample{}) - if err := m.Sample[len(m.Sample)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DurationNano", wireType) - } - m.DurationNano = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DurationNano |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeriodType", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PeriodType.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) - } - m.Period = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Period |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.CommentStrindices = append(m.CommentStrindices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.CommentStrindices) == 0 { - m.CommentStrindices = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.CommentStrindices = append(m.CommentStrindices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field CommentStrindices", wireType) - } - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProfileId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ProfileId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OriginalPayloadFormat", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OriginalPayloadFormat = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OriginalPayload", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OriginalPayload = append(m.OriginalPayload[:0], dAtA[iNdEx:postIndex]...) - if m.OriginalPayload == nil { - m.OriginalPayload = []byte{} - } - iNdEx = postIndex - case 12: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.AttributeIndices) == 0 { - m.AttributeIndices = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field AttributeIndices", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Link) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Link: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Link: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SpanId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ValueType) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ValueType: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValueType: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TypeStrindex", wireType) - } - m.TypeStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TypeStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnitStrindex", wireType) - } - m.UnitStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnitStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) - } - m.AggregationTemporality = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AggregationTemporality |= AggregationTemporality(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Sample) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Sample: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Sample: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StackIndex", wireType) - } - m.StackIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StackIndex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType == 0 { - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Values = append(m.Values, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.Values) == 0 { - m.Values = make([]int64, 0, elementCount) - } - for iNdEx < postIndex { - var v int64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Values = append(m.Values, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) - } - case 3: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.AttributeIndices) == 0 { - m.AttributeIndices = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field AttributeIndices", wireType) - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LinkIndex", wireType) - } - m.LinkIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.LinkIndex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType == 1 { - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.TimestampsUnixNano = append(m.TimestampsUnixNano, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - elementCount = packedLen / 8 - if elementCount != 0 && len(m.TimestampsUnixNano) == 0 { - m.TimestampsUnixNano = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.TimestampsUnixNano = append(m.TimestampsUnixNano, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field TimestampsUnixNano", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Mapping) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Mapping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Mapping: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MemoryStart", wireType) - } - m.MemoryStart = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MemoryStart |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MemoryLimit", wireType) - } - m.MemoryLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MemoryLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FileOffset", wireType) - } - m.FileOffset = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FileOffset |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FilenameStrindex", wireType) - } - m.FilenameStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FilenameStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.AttributeIndices) == 0 { - m.AttributeIndices = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field AttributeIndices", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Stack) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Stack: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Stack: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.LocationIndices = append(m.LocationIndices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.LocationIndices) == 0 { - m.LocationIndices = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.LocationIndices = append(m.LocationIndices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field LocationIndices", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Location) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Location: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Location: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MappingIndex", wireType) - } - m.MappingIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MappingIndex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - m.Address = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Address |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Line", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Line = append(m.Line, &Line{}) - if err := m.Line[len(m.Line)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType == 0 { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.AttributeIndices) == 0 { - m.AttributeIndices = make([]int32, 0, elementCount) - } - for iNdEx < postIndex { - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AttributeIndices = append(m.AttributeIndices, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field AttributeIndices", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Line) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Line: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Line: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FunctionIndex", wireType) - } - m.FunctionIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FunctionIndex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Line", wireType) - } - m.Line = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Line |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Column", wireType) - } - m.Column = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Column |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Function) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Function: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Function: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NameStrindex", wireType) - } - m.NameStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NameStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SystemNameStrindex", wireType) - } - m.SystemNameStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SystemNameStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FilenameStrindex", wireType) - } - m.FilenameStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FilenameStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartLine", wireType) - } - m.StartLine = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartLine |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *KeyValueAndUnit) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KeyValueAndUnit: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KeyValueAndUnit: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyStrindex", wireType) - } - m.KeyStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.KeyStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthProfiles - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProfiles - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnitStrindex", wireType) - } - m.UnitStrindex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProfiles - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnitStrindex |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipProfiles(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProfiles - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipProfiles(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProfiles - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProfiles - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowProfiles - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthProfiles - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupProfiles - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthProfiles - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthProfiles = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowProfiles = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupProfiles = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/resource/v1/resource.pb.go b/pdata/internal/data/protogen/resource/v1/resource.pb.go deleted file mode 100644 index ce55b3c3496..00000000000 --- a/pdata/internal/data/protogen/resource/v1/resource.pb.go +++ /dev/null @@ -1,460 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/resource/v1/resource.proto - -package v1 - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Resource information. -type Resource struct { - // Set of attributes that describe the resource. - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v1.KeyValue `protobuf:"bytes,1,rep,name=attributes,proto3" json:"attributes"` - // dropped_attributes_count is the number of dropped attributes. If the value is 0, then - // no attributes were dropped. - DroppedAttributesCount uint32 `protobuf:"varint,2,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` - // Set of entities that participate in this Resource. - // - // Note: keys in the references MUST exist in attributes of this message. - // - // Status: [Development] - EntityRefs []*v1.EntityRef `protobuf:"bytes,3,rep,name=entity_refs,json=entityRefs,proto3" json:"entity_refs,omitempty"` -} - -func (m *Resource) Reset() { *m = Resource{} } -func (m *Resource) String() string { return proto.CompactTextString(m) } -func (*Resource) ProtoMessage() {} -func (*Resource) Descriptor() ([]byte, []int) { - return fileDescriptor_446f73eacf88f3f5, []int{0} -} -func (m *Resource) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Resource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Resource.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Resource) XXX_Merge(src proto.Message) { - xxx_messageInfo_Resource.Merge(m, src) -} -func (m *Resource) XXX_Size() int { - return m.Size() -} -func (m *Resource) XXX_DiscardUnknown() { - xxx_messageInfo_Resource.DiscardUnknown(m) -} - -var xxx_messageInfo_Resource proto.InternalMessageInfo - -func (m *Resource) GetAttributes() []v1.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *Resource) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -func (m *Resource) GetEntityRefs() []*v1.EntityRef { - if m != nil { - return m.EntityRefs - } - return nil -} - -func init() { - proto.RegisterType((*Resource)(nil), "opentelemetry.proto.resource.v1.Resource") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/resource/v1/resource.proto", fileDescriptor_446f73eacf88f3f5) -} - -var fileDescriptor_446f73eacf88f3f5 = []byte{ - // 334 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x6a, 0xfa, 0x40, - 0x10, 0xc6, 0xb3, 0xfa, 0xe7, 0x4f, 0x59, 0xf1, 0x12, 0x4a, 0x09, 0x1e, 0xa2, 0x78, 0xa9, 0xf4, - 0xb0, 0x21, 0xed, 0xa5, 0xd7, 0x5a, 0x5a, 0x28, 0xa5, 0x54, 0x42, 0xf1, 0xd0, 0x8b, 0xc4, 0x38, - 0x86, 0x40, 0xdc, 0x09, 0x9b, 0x89, 0xe0, 0x5b, 0xf4, 0x39, 0xfa, 0x02, 0x7d, 0x05, 0x8f, 0x1e, - 0x7b, 0x92, 0xa2, 0x2f, 0x52, 0xb2, 0x31, 0xa9, 0x2d, 0x82, 0xb7, 0x6f, 0xe7, 0xfb, 0xe6, 0x37, - 0xc3, 0x2c, 0x17, 0x98, 0x80, 0x24, 0x88, 0x61, 0x06, 0xa4, 0x16, 0x4e, 0xa2, 0x90, 0xd0, 0x51, - 0x90, 0x62, 0xa6, 0x02, 0x70, 0xe6, 0x6e, 0xa5, 0x85, 0xb6, 0xcc, 0xf6, 0xaf, 0x7c, 0x51, 0x14, - 0x55, 0x66, 0xee, 0xb6, 0x4e, 0x43, 0x0c, 0xb1, 0xc0, 0xe4, 0xaa, 0x48, 0xb4, 0x2e, 0x0e, 0x8d, - 0x09, 0x70, 0x36, 0x43, 0x99, 0x0f, 0x29, 0x54, 0x91, 0xed, 0xae, 0x19, 0x3f, 0xf1, 0x76, 0x44, - 0xf3, 0x89, 0x73, 0x9f, 0x48, 0x45, 0xe3, 0x8c, 0x20, 0xb5, 0x58, 0xa7, 0xde, 0x6b, 0x5c, 0x9e, - 0x8b, 0x43, 0x4b, 0xec, 0x18, 0x73, 0x57, 0x3c, 0xc2, 0x62, 0xe8, 0xc7, 0x19, 0xf4, 0xff, 0x2d, - 0xd7, 0x6d, 0xc3, 0xdb, 0x03, 0x98, 0xd7, 0xdc, 0x9a, 0x28, 0x4c, 0x12, 0x98, 0x8c, 0x7e, 0xaa, - 0xa3, 0x00, 0x33, 0x49, 0x56, 0xad, 0xc3, 0x7a, 0x4d, 0xef, 0x6c, 0xe7, 0xdf, 0x54, 0xf6, 0x6d, - 0xee, 0x9a, 0x0f, 0xbc, 0x01, 0x92, 0x22, 0x5a, 0x8c, 0x14, 0x4c, 0x53, 0xab, 0xae, 0x37, 0xe9, - 0x1d, 0xd9, 0xe4, 0x4e, 0x77, 0x78, 0x30, 0xf5, 0x38, 0x94, 0x32, 0xed, 0x7f, 0xb0, 0xe5, 0xc6, - 0x66, 0xab, 0x8d, 0xcd, 0xbe, 0x36, 0x36, 0x7b, 0xdb, 0xda, 0xc6, 0x6a, 0x6b, 0x1b, 0x9f, 0x5b, - 0xdb, 0xe0, 0xdd, 0x08, 0xc5, 0x91, 0x0b, 0xf7, 0x9b, 0xe5, 0x71, 0x06, 0xb9, 0x35, 0x60, 0xaf, - 0xf7, 0xe1, 0xdf, 0xa6, 0x28, 0x3f, 0x6e, 0x1c, 0x43, 0x40, 0xa8, 0x9c, 0x64, 0xe2, 0x93, 0xef, - 0x44, 0x92, 0x40, 0x49, 0x3f, 0x76, 0xf4, 0x4b, 0x53, 0x43, 0x90, 0xfb, 0x5f, 0xfd, 0x5e, 0x6b, - 0x3f, 0x27, 0x20, 0x5f, 0x2a, 0x8a, 0xe6, 0x8b, 0x72, 0x9a, 0x18, 0xba, 0xe3, 0xff, 0xba, 0xef, - 0xea, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x10, 0xa9, 0xec, 0x36, 0x02, 0x00, 0x00, -} - -func (m *Resource) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Resource) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Resource) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.EntityRefs) > 0 { - for iNdEx := len(m.EntityRefs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.EntityRefs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintResource(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if m.DroppedAttributesCount != 0 { - i = encodeVarintResource(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x10 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintResource(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintResource(dAtA []byte, offset int, v uint64) int { - offset -= sovResource(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Resource) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovResource(uint64(l)) - } - } - if m.DroppedAttributesCount != 0 { - n += 1 + sovResource(uint64(m.DroppedAttributesCount)) - } - if len(m.EntityRefs) > 0 { - for _, e := range m.EntityRefs { - l = e.Size() - n += 1 + l + sovResource(uint64(l)) - } - } - return n -} - -func sovResource(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozResource(x uint64) (n int) { - return sovResource(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Resource) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowResource - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Resource: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Resource: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowResource - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthResource - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthResource - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v1.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowResource - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EntityRefs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowResource - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthResource - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthResource - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EntityRefs = append(m.EntityRefs, &v1.EntityRef{}) - if err := m.EntityRefs[len(m.EntityRefs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipResource(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthResource - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipResource(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowResource - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowResource - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowResource - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthResource - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupResource - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthResource - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthResource = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowResource = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupResource = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/protogen/trace/v1/trace.pb.go b/pdata/internal/data/protogen/trace/v1/trace.pb.go deleted file mode 100644 index 6c7767be1b3..00000000000 --- a/pdata/internal/data/protogen/trace/v1/trace.pb.go +++ /dev/null @@ -1,3073 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: opentelemetry/proto/trace/v1/trace.proto - -package v1 - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - - go_opentelemetry_io_collector_pdata_internal_data "go.opentelemetry.io/collector/pdata/internal/data" - v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// SpanFlags represents constants used to interpret the -// Span.flags field, which is protobuf 'fixed32' type and is to -// be used as bit-fields. Each non-zero value defined in this enum is -// a bit-mask. To extract the bit-field, for example, use an -// expression like: -// -// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK) -// -// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. -// -// Note that Span flags were introduced in version 1.1 of the -// OpenTelemetry protocol. Older Span producers do not set this -// field, consequently consumers should not rely on the absence of a -// particular flag bit to indicate the presence of a particular feature. -type SpanFlags int32 - -const ( - // The zero value for the enum. Should not be used for comparisons. - // Instead use bitwise "and" with the appropriate mask as shown above. - SpanFlags_SPAN_FLAGS_DO_NOT_USE SpanFlags = 0 - // Bits 0-7 are used for trace flags. - SpanFlags_SPAN_FLAGS_TRACE_FLAGS_MASK SpanFlags = 255 - // Bits 8 and 9 are used to indicate that the parent span or link span is remote. - // Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known. - // Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote. - SpanFlags_SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK SpanFlags = 256 - SpanFlags_SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK SpanFlags = 512 -) - -var SpanFlags_name = map[int32]string{ - 0: "SPAN_FLAGS_DO_NOT_USE", - 255: "SPAN_FLAGS_TRACE_FLAGS_MASK", - 256: "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK", - 512: "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK", -} - -var SpanFlags_value = map[string]int32{ - "SPAN_FLAGS_DO_NOT_USE": 0, - "SPAN_FLAGS_TRACE_FLAGS_MASK": 255, - "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK": 256, - "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK": 512, -} - -func (x SpanFlags) String() string { - return proto.EnumName(SpanFlags_name, int32(x)) -} - -func (SpanFlags) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{0} -} - -// SpanKind is the type of span. Can be used to specify additional relationships between spans -// in addition to a parent/child relationship. -type Span_SpanKind int32 - -const ( - // Unspecified. Do NOT use as default. - // Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED. - Span_SPAN_KIND_UNSPECIFIED Span_SpanKind = 0 - // Indicates that the span represents an internal operation within an application, - // as opposed to an operation happening at the boundaries. Default value. - Span_SPAN_KIND_INTERNAL Span_SpanKind = 1 - // Indicates that the span covers server-side handling of an RPC or other - // remote network request. - Span_SPAN_KIND_SERVER Span_SpanKind = 2 - // Indicates that the span describes a request to some remote service. - Span_SPAN_KIND_CLIENT Span_SpanKind = 3 - // Indicates that the span describes a producer sending a message to a broker. - // Unlike CLIENT and SERVER, there is often no direct critical path latency relationship - // between producer and consumer spans. A PRODUCER span ends when the message was accepted - // by the broker while the logical processing of the message might span a much longer time. - Span_SPAN_KIND_PRODUCER Span_SpanKind = 4 - // Indicates that the span describes consumer receiving a message from a broker. - // Like the PRODUCER kind, there is often no direct critical path latency relationship - // between producer and consumer spans. - Span_SPAN_KIND_CONSUMER Span_SpanKind = 5 -) - -var Span_SpanKind_name = map[int32]string{ - 0: "SPAN_KIND_UNSPECIFIED", - 1: "SPAN_KIND_INTERNAL", - 2: "SPAN_KIND_SERVER", - 3: "SPAN_KIND_CLIENT", - 4: "SPAN_KIND_PRODUCER", - 5: "SPAN_KIND_CONSUMER", -} - -var Span_SpanKind_value = map[string]int32{ - "SPAN_KIND_UNSPECIFIED": 0, - "SPAN_KIND_INTERNAL": 1, - "SPAN_KIND_SERVER": 2, - "SPAN_KIND_CLIENT": 3, - "SPAN_KIND_PRODUCER": 4, - "SPAN_KIND_CONSUMER": 5, -} - -func (x Span_SpanKind) String() string { - return proto.EnumName(Span_SpanKind_name, int32(x)) -} - -func (Span_SpanKind) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{3, 0} -} - -// For the semantics of status codes see -// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status -type Status_StatusCode int32 - -const ( - // The default status. - Status_STATUS_CODE_UNSET Status_StatusCode = 0 - // The Span has been validated by an Application developer or Operator to - // have completed successfully. - Status_STATUS_CODE_OK Status_StatusCode = 1 - // The Span contains an error. - Status_STATUS_CODE_ERROR Status_StatusCode = 2 -) - -var Status_StatusCode_name = map[int32]string{ - 0: "STATUS_CODE_UNSET", - 1: "STATUS_CODE_OK", - 2: "STATUS_CODE_ERROR", -} - -var Status_StatusCode_value = map[string]int32{ - "STATUS_CODE_UNSET": 0, - "STATUS_CODE_OK": 1, - "STATUS_CODE_ERROR": 2, -} - -func (x Status_StatusCode) String() string { - return proto.EnumName(Status_StatusCode_name, int32(x)) -} - -func (Status_StatusCode) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{4, 0} -} - -// TracesData represents the traces data that can be stored in a persistent storage, -// OR can be embedded by other protocols that transfer OTLP traces data but do -// not implement the OTLP protocol. -// -// The main difference between this message and collector protocol is that -// in this message there will not be any "control" or "metadata" specific to -// OTLP protocol. -// -// When new fields are added into this message, the OTLP request MUST be updated -// as well. -type TracesData struct { - // An array of ResourceSpans. - // For data coming from a single resource this array will typically contain - // one element. Intermediary nodes that receive data from multiple origins - // typically batch the data before forwarding further and in that case this - // array will contain multiple elements. - ResourceSpans []*ResourceSpans `protobuf:"bytes,1,rep,name=resource_spans,json=resourceSpans,proto3" json:"resource_spans,omitempty"` -} - -func (m *TracesData) Reset() { *m = TracesData{} } -func (m *TracesData) String() string { return proto.CompactTextString(m) } -func (*TracesData) ProtoMessage() {} -func (*TracesData) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{0} -} -func (m *TracesData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TracesData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TracesData.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TracesData) XXX_Merge(src proto.Message) { - xxx_messageInfo_TracesData.Merge(m, src) -} -func (m *TracesData) XXX_Size() int { - return m.Size() -} -func (m *TracesData) XXX_DiscardUnknown() { - xxx_messageInfo_TracesData.DiscardUnknown(m) -} - -var xxx_messageInfo_TracesData proto.InternalMessageInfo - -func (m *TracesData) GetResourceSpans() []*ResourceSpans { - if m != nil { - return m.ResourceSpans - } - return nil -} - -// A collection of ScopeSpans from a Resource. -type ResourceSpans struct { - DeprecatedScopeSpans []*ScopeSpans `protobuf:"bytes,1000,rep,name=deprecated_scope_spans,json=deprecatedScopeSpans,proto3" json:"deprecated_scope_spans,omitempty"` - // The resource for the spans in this message. - // If this field is not set then no resource info is known. - Resource v1.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource"` - // A list of ScopeSpans that originate from a resource. - ScopeSpans []*ScopeSpans `protobuf:"bytes,2,rep,name=scope_spans,json=scopeSpans,proto3" json:"scope_spans,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the resource data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to the data in the "resource" field. It does not apply - // to the data in the "scope_spans" field which have their own schema_url field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ResourceSpans) Reset() { *m = ResourceSpans{} } -func (m *ResourceSpans) String() string { return proto.CompactTextString(m) } -func (*ResourceSpans) ProtoMessage() {} -func (*ResourceSpans) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{1} -} -func (m *ResourceSpans) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ResourceSpans) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ResourceSpans.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ResourceSpans) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResourceSpans.Merge(m, src) -} -func (m *ResourceSpans) XXX_Size() int { - return m.Size() -} -func (m *ResourceSpans) XXX_DiscardUnknown() { - xxx_messageInfo_ResourceSpans.DiscardUnknown(m) -} - -var xxx_messageInfo_ResourceSpans proto.InternalMessageInfo - -func (m *ResourceSpans) GetDeprecatedScopeSpans() []*ScopeSpans { - if m != nil { - return m.DeprecatedScopeSpans - } - return nil -} - -func (m *ResourceSpans) GetResource() v1.Resource { - if m != nil { - return m.Resource - } - return v1.Resource{} -} - -func (m *ResourceSpans) GetScopeSpans() []*ScopeSpans { - if m != nil { - return m.ScopeSpans - } - return nil -} - -func (m *ResourceSpans) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// A collection of Spans produced by an InstrumentationScope. -type ScopeSpans struct { - // The instrumentation scope information for the spans in this message. - // Semantically when InstrumentationScope isn't set, it is equivalent with - // an empty instrumentation scope name (unknown). - Scope v11.InstrumentationScope `protobuf:"bytes,1,opt,name=scope,proto3" json:"scope"` - // A list of Spans that originate from an instrumentation scope. - Spans []*Span `protobuf:"bytes,2,rep,name=spans,proto3" json:"spans,omitempty"` - // The Schema URL, if known. This is the identifier of the Schema that the span data - // is recorded in. Notably, the last part of the URL path is the version number of the - // schema: http[s]://server[:port]/path/. To learn more about Schema URL see - // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - // This schema_url applies to all spans and span events in the "spans" field. - SchemaUrl string `protobuf:"bytes,3,opt,name=schema_url,json=schemaUrl,proto3" json:"schema_url,omitempty"` -} - -func (m *ScopeSpans) Reset() { *m = ScopeSpans{} } -func (m *ScopeSpans) String() string { return proto.CompactTextString(m) } -func (*ScopeSpans) ProtoMessage() {} -func (*ScopeSpans) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{2} -} -func (m *ScopeSpans) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ScopeSpans) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ScopeSpans.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ScopeSpans) XXX_Merge(src proto.Message) { - xxx_messageInfo_ScopeSpans.Merge(m, src) -} -func (m *ScopeSpans) XXX_Size() int { - return m.Size() -} -func (m *ScopeSpans) XXX_DiscardUnknown() { - xxx_messageInfo_ScopeSpans.DiscardUnknown(m) -} - -var xxx_messageInfo_ScopeSpans proto.InternalMessageInfo - -func (m *ScopeSpans) GetScope() v11.InstrumentationScope { - if m != nil { - return m.Scope - } - return v11.InstrumentationScope{} -} - -func (m *ScopeSpans) GetSpans() []*Span { - if m != nil { - return m.Spans - } - return nil -} - -func (m *ScopeSpans) GetSchemaUrl() string { - if m != nil { - return m.SchemaUrl - } - return "" -} - -// A Span represents a single operation performed by a single component of the system. -// -// The next available field id is 17. -type Span struct { - // A unique identifier for a trace. All spans from the same trace share - // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR - // of length other than 16 bytes is considered invalid (empty string in OTLP/JSON - // is zero-length and thus is also invalid). - // - // This field is required. - TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` - // A unique identifier for a span within a trace, assigned when the span - // is created. The ID is an 8-byte array. An ID with all zeroes OR of length - // other than 8 bytes is considered invalid (empty string in OTLP/JSON - // is zero-length and thus is also invalid). - // - // This field is required. - SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` - // trace_state conveys information about request position in multiple distributed tracing graphs. - // It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header - // See also https://github.com/w3c/distributed-tracing for more details about this field. - TraceState string `protobuf:"bytes,3,opt,name=trace_state,json=traceState,proto3" json:"trace_state,omitempty"` - // The `span_id` of this span's parent span. If this is a root span, then this - // field must be empty. The ID is an 8-byte array. - ParentSpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,4,opt,name=parent_span_id,json=parentSpanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"parent_span_id"` - // Flags, a bit field. - // - // Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace - // Context specification. To read the 8-bit W3C trace flag, use - // `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. - // - // See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. - // - // Bits 8 and 9 represent the 3 states of whether a span's parent - // is remote. The states are (unknown, is not remote, is remote). - // To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`. - // To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`. - // - // When creating span messages, if the message is logically forwarded from another source - // with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD - // be copied as-is. If creating from a source that does not have an equivalent flags field - // (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST - // be set to zero. - // Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. - // - // [Optional]. - Flags uint32 `protobuf:"fixed32,16,opt,name=flags,proto3" json:"flags,omitempty"` - // A description of the span's operation. - // - // For example, the name can be a qualified method name or a file name - // and a line number where the operation is called. A best practice is to use - // the same display name at the same call point in an application. - // This makes it easier to correlate spans in different traces. - // - // This field is semantically required to be set to non-empty string. - // Empty value is equivalent to an unknown span name. - // - // This field is required. - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // Distinguishes between spans generated in a particular context. For example, - // two spans with the same name may be distinguished using `CLIENT` (caller) - // and `SERVER` (callee) to identify queueing latency associated with the span. - Kind Span_SpanKind `protobuf:"varint,6,opt,name=kind,proto3,enum=opentelemetry.proto.trace.v1.Span_SpanKind" json:"kind,omitempty"` - // start_time_unix_nano is the start time of the span. On the client side, this is the time - // kept by the local machine where the span execution starts. On the server side, this - // is the time when the server's application handler starts running. - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // - // This field is semantically required and it is expected that end_time >= start_time. - StartTimeUnixNano uint64 `protobuf:"fixed64,7,opt,name=start_time_unix_nano,json=startTimeUnixNano,proto3" json:"start_time_unix_nano,omitempty"` - // end_time_unix_nano is the end time of the span. On the client side, this is the time - // kept by the local machine where the span execution ends. On the server side, this - // is the time when the server application handler stops running. - // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - // - // This field is semantically required and it is expected that end_time >= start_time. - EndTimeUnixNano uint64 `protobuf:"fixed64,8,opt,name=end_time_unix_nano,json=endTimeUnixNano,proto3" json:"end_time_unix_nano,omitempty"` - // attributes is a collection of key/value pairs. Note, global attributes - // like server name can be set using the resource API. Examples of attributes: - // - // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" - // "/http/server_latency": 300 - // "example.com/myattribute": true - // "example.com/score": 10.239 - // - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,9,rep,name=attributes,proto3" json:"attributes"` - // dropped_attributes_count is the number of attributes that were discarded. Attributes - // can be discarded because their keys are too long or because there are too many - // attributes. If this value is 0, then no attributes were dropped. - DroppedAttributesCount uint32 `protobuf:"varint,10,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` - // events is a collection of Event items. - Events []*Span_Event `protobuf:"bytes,11,rep,name=events,proto3" json:"events,omitempty"` - // dropped_events_count is the number of dropped events. If the value is 0, then no - // events were dropped. - DroppedEventsCount uint32 `protobuf:"varint,12,opt,name=dropped_events_count,json=droppedEventsCount,proto3" json:"dropped_events_count,omitempty"` - // links is a collection of Links, which are references from this span to a span - // in the same or different trace. - Links []*Span_Link `protobuf:"bytes,13,rep,name=links,proto3" json:"links,omitempty"` - // dropped_links_count is the number of dropped links after the maximum size was - // enforced. If this value is 0, then no links were dropped. - DroppedLinksCount uint32 `protobuf:"varint,14,opt,name=dropped_links_count,json=droppedLinksCount,proto3" json:"dropped_links_count,omitempty"` - // An optional final status for this span. Semantically when Status isn't set, it means - // span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). - Status Status `protobuf:"bytes,15,opt,name=status,proto3" json:"status"` -} - -func (m *Span) Reset() { *m = Span{} } -func (m *Span) String() string { return proto.CompactTextString(m) } -func (*Span) ProtoMessage() {} -func (*Span) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{3} -} -func (m *Span) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Span) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Span.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Span) XXX_Merge(src proto.Message) { - xxx_messageInfo_Span.Merge(m, src) -} -func (m *Span) XXX_Size() int { - return m.Size() -} -func (m *Span) XXX_DiscardUnknown() { - xxx_messageInfo_Span.DiscardUnknown(m) -} - -var xxx_messageInfo_Span proto.InternalMessageInfo - -func (m *Span) GetTraceState() string { - if m != nil { - return m.TraceState - } - return "" -} - -func (m *Span) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -func (m *Span) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Span) GetKind() Span_SpanKind { - if m != nil { - return m.Kind - } - return Span_SPAN_KIND_UNSPECIFIED -} - -func (m *Span) GetStartTimeUnixNano() uint64 { - if m != nil { - return m.StartTimeUnixNano - } - return 0 -} - -func (m *Span) GetEndTimeUnixNano() uint64 { - if m != nil { - return m.EndTimeUnixNano - } - return 0 -} - -func (m *Span) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *Span) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -func (m *Span) GetEvents() []*Span_Event { - if m != nil { - return m.Events - } - return nil -} - -func (m *Span) GetDroppedEventsCount() uint32 { - if m != nil { - return m.DroppedEventsCount - } - return 0 -} - -func (m *Span) GetLinks() []*Span_Link { - if m != nil { - return m.Links - } - return nil -} - -func (m *Span) GetDroppedLinksCount() uint32 { - if m != nil { - return m.DroppedLinksCount - } - return 0 -} - -func (m *Span) GetStatus() Status { - if m != nil { - return m.Status - } - return Status{} -} - -// Event is a time-stamped annotation of the span, consisting of user-supplied -// text description and key-value pairs. -type Span_Event struct { - // time_unix_nano is the time the event occurred. - TimeUnixNano uint64 `protobuf:"fixed64,1,opt,name=time_unix_nano,json=timeUnixNano,proto3" json:"time_unix_nano,omitempty"` - // name of the event. - // This field is semantically required to be set to non-empty string. - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - // attributes is a collection of attribute key/value pairs on the event. - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,3,rep,name=attributes,proto3" json:"attributes"` - // dropped_attributes_count is the number of dropped attributes. If the value is 0, - // then no attributes were dropped. - DroppedAttributesCount uint32 `protobuf:"varint,4,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` -} - -func (m *Span_Event) Reset() { *m = Span_Event{} } -func (m *Span_Event) String() string { return proto.CompactTextString(m) } -func (*Span_Event) ProtoMessage() {} -func (*Span_Event) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{3, 0} -} -func (m *Span_Event) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Span_Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Span_Event.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Span_Event) XXX_Merge(src proto.Message) { - xxx_messageInfo_Span_Event.Merge(m, src) -} -func (m *Span_Event) XXX_Size() int { - return m.Size() -} -func (m *Span_Event) XXX_DiscardUnknown() { - xxx_messageInfo_Span_Event.DiscardUnknown(m) -} - -var xxx_messageInfo_Span_Event proto.InternalMessageInfo - -func (m *Span_Event) GetTimeUnixNano() uint64 { - if m != nil { - return m.TimeUnixNano - } - return 0 -} - -func (m *Span_Event) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Span_Event) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *Span_Event) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -// A pointer from the current span to another span in the same trace or in a -// different trace. For example, this can be used in batching operations, -// where a single batch handler processes multiple requests from different -// traces or when the handler receives a request from a different project. -type Span_Link struct { - // A unique identifier of a trace that this linked span is part of. The ID is a - // 16-byte array. - TraceId go_opentelemetry_io_collector_pdata_internal_data.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.TraceID" json:"trace_id"` - // A unique identifier for the linked span. The ID is an 8-byte array. - SpanId go_opentelemetry_io_collector_pdata_internal_data.SpanID `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3,customtype=go.opentelemetry.io/collector/pdata/internal/data.SpanID" json:"span_id"` - // The trace_state associated with the link. - TraceState string `protobuf:"bytes,3,opt,name=trace_state,json=traceState,proto3" json:"trace_state,omitempty"` - // attributes is a collection of attribute key/value pairs on the link. - // Attribute keys MUST be unique (it is not allowed to have more than one - // attribute with the same key). - // - // The attribute values SHOULD NOT contain empty values. - // The attribute values SHOULD NOT contain bytes values. - // The attribute values SHOULD NOT contain array values different than array of string values, bool values, int values, - // double values. - // The attribute values SHOULD NOT contain kvlist values. - // The behavior of software that receives attributes containing such values can be unpredictable. - // These restrictions can change in a minor release. - // The restrictions take origin from the OpenTelemetry specification: - // https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute. - Attributes []v11.KeyValue `protobuf:"bytes,4,rep,name=attributes,proto3" json:"attributes"` - // dropped_attributes_count is the number of dropped attributes. If the value is 0, - // then no attributes were dropped. - DroppedAttributesCount uint32 `protobuf:"varint,5,opt,name=dropped_attributes_count,json=droppedAttributesCount,proto3" json:"dropped_attributes_count,omitempty"` - // Flags, a bit field. - // - // Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace - // Context specification. To read the 8-bit W3C trace flag, use - // `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. - // - // See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions. - // - // Bits 8 and 9 represent the 3 states of whether the link is remote. - // The states are (unknown, is not remote, is remote). - // To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`. - // To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`. - // - // Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero. - // When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero. - // - // [Optional]. - Flags uint32 `protobuf:"fixed32,6,opt,name=flags,proto3" json:"flags,omitempty"` -} - -func (m *Span_Link) Reset() { *m = Span_Link{} } -func (m *Span_Link) String() string { return proto.CompactTextString(m) } -func (*Span_Link) ProtoMessage() {} -func (*Span_Link) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{3, 1} -} -func (m *Span_Link) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Span_Link) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Span_Link.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Span_Link) XXX_Merge(src proto.Message) { - xxx_messageInfo_Span_Link.Merge(m, src) -} -func (m *Span_Link) XXX_Size() int { - return m.Size() -} -func (m *Span_Link) XXX_DiscardUnknown() { - xxx_messageInfo_Span_Link.DiscardUnknown(m) -} - -var xxx_messageInfo_Span_Link proto.InternalMessageInfo - -func (m *Span_Link) GetTraceState() string { - if m != nil { - return m.TraceState - } - return "" -} - -func (m *Span_Link) GetAttributes() []v11.KeyValue { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *Span_Link) GetDroppedAttributesCount() uint32 { - if m != nil { - return m.DroppedAttributesCount - } - return 0 -} - -func (m *Span_Link) GetFlags() uint32 { - if m != nil { - return m.Flags - } - return 0 -} - -// The Status type defines a logical error model that is suitable for different -// programming environments, including REST APIs and RPC APIs. -type Status struct { - // A developer-facing human readable error message. - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - // The status code. - Code Status_StatusCode `protobuf:"varint,3,opt,name=code,proto3,enum=opentelemetry.proto.trace.v1.Status_StatusCode" json:"code,omitempty"` -} - -func (m *Status) Reset() { *m = Status{} } -func (m *Status) String() string { return proto.CompactTextString(m) } -func (*Status) ProtoMessage() {} -func (*Status) Descriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{4} -} -func (m *Status) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Status) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Status.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Status) XXX_Merge(src proto.Message) { - xxx_messageInfo_Status.Merge(m, src) -} -func (m *Status) XXX_Size() int { - return m.Size() -} -func (m *Status) XXX_DiscardUnknown() { - xxx_messageInfo_Status.DiscardUnknown(m) -} - -var xxx_messageInfo_Status proto.InternalMessageInfo - -func (m *Status) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *Status) GetCode() Status_StatusCode { - if m != nil { - return m.Code - } - return Status_STATUS_CODE_UNSET -} - -func init() { - proto.RegisterEnum("opentelemetry.proto.trace.v1.SpanFlags", SpanFlags_name, SpanFlags_value) - proto.RegisterEnum("opentelemetry.proto.trace.v1.Span_SpanKind", Span_SpanKind_name, Span_SpanKind_value) - proto.RegisterEnum("opentelemetry.proto.trace.v1.Status_StatusCode", Status_StatusCode_name, Status_StatusCode_value) - proto.RegisterType((*TracesData)(nil), "opentelemetry.proto.trace.v1.TracesData") - proto.RegisterType((*ResourceSpans)(nil), "opentelemetry.proto.trace.v1.ResourceSpans") - proto.RegisterType((*ScopeSpans)(nil), "opentelemetry.proto.trace.v1.ScopeSpans") - proto.RegisterType((*Span)(nil), "opentelemetry.proto.trace.v1.Span") - proto.RegisterType((*Span_Event)(nil), "opentelemetry.proto.trace.v1.Span.Event") - proto.RegisterType((*Span_Link)(nil), "opentelemetry.proto.trace.v1.Span.Link") - proto.RegisterType((*Status)(nil), "opentelemetry.proto.trace.v1.Status") -} - -func init() { - proto.RegisterFile("opentelemetry/proto/trace/v1/trace.proto", fileDescriptor_5c407ac9c675a601) -} - -var fileDescriptor_5c407ac9c675a601 = []byte{ - // 1112 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0x3a, 0x6b, 0x3b, 0x79, 0x49, 0xdc, 0xed, 0xe0, 0x56, 0x4b, 0x28, 0x8e, 0xb1, 0x0a, - 0x98, 0x56, 0xb2, 0x49, 0x7b, 0x29, 0x07, 0x44, 0x1d, 0x7b, 0x03, 0x8b, 0x13, 0x3b, 0x9a, 0x5d, - 0x47, 0x80, 0x90, 0x96, 0xad, 0x77, 0x6a, 0x56, 0xb1, 0x67, 0xad, 0xdd, 0x71, 0xd4, 0xde, 0xf8, - 0x13, 0xb8, 0x22, 0x71, 0x47, 0x02, 0xce, 0xdc, 0xb8, 0x57, 0x9c, 0x7a, 0x44, 0x1c, 0x2a, 0x94, - 0x5c, 0xf8, 0x2f, 0x8a, 0x66, 0x66, 0xd7, 0x5e, 0x47, 0x91, 0xd3, 0x48, 0xf4, 0xc2, 0x25, 0x99, - 0x79, 0x3f, 0xbe, 0xef, 0x7b, 0x6f, 0xde, 0x8c, 0x17, 0x6a, 0xc1, 0x84, 0x50, 0x46, 0x46, 0x64, - 0x4c, 0x58, 0xf8, 0xb4, 0x31, 0x09, 0x03, 0x16, 0x34, 0x58, 0xe8, 0x0e, 0x48, 0xe3, 0x64, 0x47, - 0x2e, 0xea, 0xc2, 0x88, 0x6e, 0x2d, 0x44, 0x4a, 0x63, 0x5d, 0x06, 0x9c, 0xec, 0x6c, 0x95, 0x86, - 0xc1, 0x30, 0x90, 0xd9, 0x7c, 0x25, 0xdd, 0x5b, 0x77, 0x2e, 0x42, 0x1f, 0x04, 0xe3, 0x71, 0x40, - 0x39, 0xbc, 0x5c, 0xc5, 0xb1, 0xf5, 0x8b, 0x62, 0x43, 0x12, 0x05, 0xd3, 0x50, 0x8a, 0x49, 0xd6, - 0x32, 0xbe, 0xfa, 0x0d, 0x80, 0xcd, 0xd9, 0xa3, 0xb6, 0xcb, 0x5c, 0x84, 0xa1, 0x98, 0xf8, 0x9d, - 0x68, 0xe2, 0xd2, 0x48, 0x57, 0x2a, 0x2b, 0xb5, 0xf5, 0x7b, 0x77, 0xeb, 0xcb, 0x64, 0xd7, 0x71, - 0x9c, 0x63, 0xf1, 0x14, 0xbc, 0x19, 0xa6, 0xb7, 0xd5, 0x9f, 0xb2, 0xb0, 0xb9, 0x10, 0x80, 0x1c, - 0xb8, 0xe9, 0x91, 0x49, 0x48, 0x06, 0x2e, 0x23, 0x9e, 0x13, 0x0d, 0x82, 0x49, 0xc2, 0xf6, 0x4f, - 0x41, 0xd0, 0xd5, 0x96, 0xd3, 0x59, 0x3c, 0x43, 0x72, 0x95, 0xe6, 0x40, 0x73, 0x2b, 0xea, 0xc0, - 0x6a, 0xa2, 0x41, 0x57, 0x2a, 0x4a, 0x6d, 0xfd, 0xde, 0x07, 0x17, 0x22, 0xce, 0x7a, 0x91, 0xaa, - 0x61, 0x57, 0x7d, 0xf6, 0x62, 0x3b, 0x83, 0x67, 0x00, 0xc8, 0x84, 0xf5, 0xb4, 0xc4, 0xec, 0x15, - 0x15, 0x42, 0x34, 0xd7, 0xf5, 0x36, 0x40, 0x34, 0xf8, 0x96, 0x8c, 0x5d, 0x67, 0x1a, 0x8e, 0xf4, - 0x95, 0x8a, 0x52, 0x5b, 0xc3, 0x6b, 0xd2, 0xd2, 0x0f, 0x47, 0xd5, 0xdf, 0x14, 0x80, 0x54, 0x15, - 0x3d, 0xc8, 0x89, 0xdc, 0xb8, 0x84, 0xfb, 0x17, 0x52, 0xc6, 0x87, 0x7f, 0xb2, 0x53, 0x37, 0x69, - 0xc4, 0xc2, 0xe9, 0x98, 0x50, 0xe6, 0x32, 0x3f, 0xa0, 0x02, 0x28, 0x2e, 0x46, 0xe2, 0xa0, 0x07, - 0x90, 0x4b, 0xd7, 0x50, 0xbd, 0xa4, 0x86, 0x89, 0x4b, 0xb1, 0x4c, 0xb8, 0x4c, 0xf8, 0xaf, 0x9b, - 0xa0, 0xf2, 0x70, 0xf4, 0x35, 0xac, 0x8a, 0x7c, 0xc7, 0xf7, 0x84, 0xea, 0x8d, 0xdd, 0x26, 0x17, - 0xf0, 0xd7, 0x8b, 0xed, 0x8f, 0x86, 0xc1, 0x39, 0x3a, 0x9f, 0xcf, 0xf0, 0x68, 0x44, 0x06, 0x2c, - 0x08, 0x1b, 0x13, 0xcf, 0x65, 0x6e, 0xc3, 0xa7, 0x8c, 0x84, 0xd4, 0x1d, 0x35, 0xf8, 0xae, 0x2e, - 0xe6, 0xd2, 0x6c, 0xe3, 0x82, 0x80, 0x34, 0x3d, 0xf4, 0x25, 0x14, 0xb8, 0x1c, 0x0e, 0x9e, 0x15, - 0xe0, 0x0f, 0x63, 0xf0, 0x07, 0x57, 0x07, 0xe7, 0x72, 0xcd, 0x36, 0xce, 0x73, 0x40, 0xd3, 0x43, - 0xdb, 0xb0, 0x2e, 0x85, 0x47, 0xcc, 0x65, 0x24, 0xae, 0x10, 0x84, 0xc9, 0xe2, 0x16, 0xf4, 0x18, - 0x8a, 0x13, 0x37, 0x24, 0x94, 0x39, 0x89, 0x04, 0xf5, 0x3f, 0x92, 0xb0, 0x21, 0x71, 0x2d, 0x29, - 0xa4, 0x04, 0xb9, 0xc7, 0x23, 0x77, 0x18, 0xe9, 0x5a, 0x45, 0xa9, 0x15, 0xb0, 0xdc, 0x20, 0x04, - 0x2a, 0x75, 0xc7, 0x44, 0xcf, 0x09, 0x5d, 0x62, 0x8d, 0x3e, 0x01, 0xf5, 0xd8, 0xa7, 0x9e, 0x9e, - 0xaf, 0x28, 0xb5, 0xe2, 0x65, 0x37, 0x94, 0xa3, 0x8b, 0x3f, 0x1d, 0x9f, 0x7a, 0x58, 0x24, 0xa2, - 0x06, 0x94, 0x22, 0xe6, 0x86, 0xcc, 0x61, 0xfe, 0x98, 0x38, 0x53, 0xea, 0x3f, 0x71, 0xa8, 0x4b, - 0x03, 0xbd, 0x50, 0x51, 0x6a, 0x79, 0x7c, 0x5d, 0xf8, 0x6c, 0x7f, 0x4c, 0xfa, 0xd4, 0x7f, 0xd2, - 0x75, 0x69, 0x80, 0xee, 0x02, 0x22, 0xd4, 0x3b, 0x1f, 0xbe, 0x2a, 0xc2, 0xaf, 0x11, 0xea, 0x2d, - 0x04, 0x1f, 0x00, 0xb8, 0x8c, 0x85, 0xfe, 0xa3, 0x29, 0x23, 0x91, 0xbe, 0x26, 0x26, 0xee, 0xfd, - 0x4b, 0x46, 0xb8, 0x43, 0x9e, 0x1e, 0xb9, 0xa3, 0x69, 0x32, 0xb6, 0x29, 0x00, 0xf4, 0x00, 0x74, - 0x2f, 0x0c, 0x26, 0x13, 0xe2, 0x39, 0x73, 0xab, 0x33, 0x08, 0xa6, 0x94, 0xe9, 0x50, 0x51, 0x6a, - 0x9b, 0xf8, 0x66, 0xec, 0x6f, 0xce, 0xdc, 0x2d, 0xee, 0x45, 0x0f, 0x21, 0x4f, 0x4e, 0x08, 0x65, - 0x91, 0xbe, 0xfe, 0x4a, 0x57, 0x97, 0x77, 0xca, 0xe0, 0x09, 0x38, 0xce, 0x43, 0x1f, 0x42, 0x29, - 0xe1, 0x96, 0x96, 0x98, 0x77, 0x43, 0xf0, 0xa2, 0xd8, 0x27, 0x72, 0x62, 0xce, 0x8f, 0x21, 0x37, - 0xf2, 0xe9, 0x71, 0xa4, 0x6f, 0x2e, 0xa9, 0x7b, 0x91, 0x72, 0xdf, 0xa7, 0xc7, 0x58, 0x66, 0xa1, - 0x3a, 0xbc, 0x91, 0x10, 0x0a, 0x43, 0xcc, 0x57, 0x14, 0x7c, 0xd7, 0x63, 0x17, 0x4f, 0x88, 0xe9, - 0x76, 0x21, 0xcf, 0xe7, 0x76, 0x1a, 0xe9, 0xd7, 0xc4, 0x53, 0x71, 0xfb, 0x12, 0x3e, 0x11, 0x1b, - 0x37, 0x39, 0xce, 0xdc, 0xfa, 0x43, 0x81, 0x9c, 0x28, 0x01, 0xdd, 0x86, 0xe2, 0xb9, 0x23, 0x56, - 0xc4, 0x11, 0x6f, 0xb0, 0xf4, 0xf9, 0x26, 0x23, 0x99, 0x4d, 0x8d, 0xe4, 0xe2, 0x99, 0xaf, 0xbc, - 0xce, 0x33, 0x57, 0x97, 0x9d, 0xf9, 0xd6, 0xcb, 0x2c, 0xa8, 0xbc, 0x3f, 0xff, 0xe3, 0x07, 0x69, - 0xb1, 0xd7, 0xea, 0xeb, 0xec, 0x75, 0x6e, 0xe9, 0xfd, 0x9a, 0xbd, 0x58, 0xf9, 0xd4, 0x8b, 0x55, - 0xfd, 0x41, 0x81, 0xd5, 0xe4, 0xbd, 0x41, 0x6f, 0xc2, 0x0d, 0xeb, 0xb0, 0xd9, 0x75, 0x3a, 0x66, - 0xb7, 0xed, 0xf4, 0xbb, 0xd6, 0xa1, 0xd1, 0x32, 0xf7, 0x4c, 0xa3, 0xad, 0x65, 0xd0, 0x4d, 0x40, - 0x73, 0x97, 0xd9, 0xb5, 0x0d, 0xdc, 0x6d, 0xee, 0x6b, 0x0a, 0x2a, 0x81, 0x36, 0xb7, 0x5b, 0x06, - 0x3e, 0x32, 0xb0, 0x96, 0x5d, 0xb4, 0xb6, 0xf6, 0x4d, 0xa3, 0x6b, 0x6b, 0x2b, 0x8b, 0x18, 0x87, - 0xb8, 0xd7, 0xee, 0xb7, 0x0c, 0xac, 0xa9, 0x8b, 0xf6, 0x56, 0xaf, 0x6b, 0xf5, 0x0f, 0x0c, 0xac, - 0xe5, 0xaa, 0xbf, 0x2b, 0x90, 0x97, 0x77, 0x00, 0xe9, 0x50, 0x18, 0x93, 0x28, 0x72, 0x87, 0xc9, - 0x20, 0x27, 0x5b, 0xd4, 0x02, 0x75, 0x10, 0x78, 0xb2, 0xf3, 0xc5, 0x7b, 0x8d, 0x57, 0xb9, 0x51, - 0xf1, 0xbf, 0x56, 0xe0, 0x11, 0x2c, 0x92, 0xab, 0x5d, 0x80, 0xb9, 0x0d, 0xdd, 0x80, 0xeb, 0x96, - 0xdd, 0xb4, 0xfb, 0x96, 0xd3, 0xea, 0xb5, 0x0d, 0xde, 0x08, 0xc3, 0xd6, 0x32, 0x08, 0x41, 0x31, - 0x6d, 0xee, 0x75, 0x34, 0xe5, 0x7c, 0xa8, 0x81, 0x71, 0x0f, 0x6b, 0xd9, 0xcf, 0xd5, 0x55, 0x45, - 0xcb, 0xde, 0xf9, 0x51, 0x81, 0x35, 0xde, 0xdb, 0x3d, 0xf1, 0xdb, 0x90, 0x34, 0x77, 0x6f, 0xbf, - 0xf9, 0xa9, 0xe5, 0xb4, 0x7b, 0x4e, 0xb7, 0x67, 0x3b, 0x7d, 0xcb, 0xd0, 0x32, 0xa8, 0x02, 0x6f, - 0xa5, 0x5c, 0x36, 0x6e, 0xb6, 0x8c, 0x78, 0x7d, 0xd0, 0xb4, 0x3a, 0xda, 0x4b, 0x05, 0xdd, 0x81, - 0x77, 0x53, 0x11, 0xad, 0x5e, 0xd7, 0x36, 0xbe, 0xb0, 0x9d, 0xcf, 0x9a, 0x96, 0x63, 0x5a, 0x0e, - 0x36, 0x0e, 0x7a, 0xb6, 0x21, 0x63, 0xbf, 0xcb, 0xa2, 0xf7, 0xe0, 0x9d, 0x0b, 0x62, 0xcf, 0xc7, - 0xa9, 0xbb, 0xbf, 0x28, 0xcf, 0x4e, 0xcb, 0xca, 0xf3, 0xd3, 0xb2, 0xf2, 0xf7, 0x69, 0x59, 0xf9, - 0xfe, 0xac, 0x9c, 0x79, 0x7e, 0x56, 0xce, 0xfc, 0x79, 0x56, 0xce, 0xc0, 0xb6, 0x1f, 0x2c, 0x6d, - 0xe4, 0xae, 0xfc, 0x18, 0x3d, 0xe4, 0xc6, 0x43, 0xe5, 0xab, 0xd6, 0x95, 0xaf, 0x91, 0xfc, 0xe0, - 0x1d, 0x12, 0x3a, 0xfb, 0xfa, 0xfe, 0x39, 0x7b, 0xab, 0x37, 0x21, 0xd4, 0x9e, 0x41, 0x08, 0x70, - 0x79, 0x97, 0xeb, 0x47, 0x3b, 0x8f, 0xf2, 0x22, 0xe3, 0xfe, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xfd, 0xbe, 0x84, 0xc3, 0xc3, 0x0b, 0x00, 0x00, -} - -func (m *TracesData) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TracesData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TracesData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ResourceSpans) > 0 { - for iNdEx := len(m.ResourceSpans) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ResourceSpans[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ResourceSpans) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ResourceSpans) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ResourceSpans) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DeprecatedScopeSpans) > 0 { - for iNdEx := len(m.DeprecatedScopeSpans) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DeprecatedScopeSpans[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3e - i-- - dAtA[i] = 0xc2 - } - } - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintTrace(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.ScopeSpans) > 0 { - for iNdEx := len(m.ScopeSpans) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ScopeSpans[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Resource.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ScopeSpans) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ScopeSpans) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ScopeSpans) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SchemaUrl) > 0 { - i -= len(m.SchemaUrl) - copy(dAtA[i:], m.SchemaUrl) - i = encodeVarintTrace(dAtA, i, uint64(len(m.SchemaUrl))) - i-- - dAtA[i] = 0x1a - } - if len(m.Spans) > 0 { - for iNdEx := len(m.Spans) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Spans[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Scope.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Span) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Span) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Span) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Flags != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Flags)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x85 - } - { - size, err := m.Status.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - if m.DroppedLinksCount != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.DroppedLinksCount)) - i-- - dAtA[i] = 0x70 - } - if len(m.Links) > 0 { - for iNdEx := len(m.Links) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Links[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - } - } - if m.DroppedEventsCount != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.DroppedEventsCount)) - i-- - dAtA[i] = 0x60 - } - if len(m.Events) > 0 { - for iNdEx := len(m.Events) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Events[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } - } - if m.DroppedAttributesCount != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x50 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - } - if m.EndTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.EndTimeUnixNano)) - i-- - dAtA[i] = 0x41 - } - if m.StartTimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.StartTimeUnixNano)) - i-- - dAtA[i] = 0x39 - } - if m.Kind != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.Kind)) - i-- - dAtA[i] = 0x30 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintTrace(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x2a - } - { - size := m.ParentSpanId.Size() - i -= size - if _, err := m.ParentSpanId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.TraceState) > 0 { - i -= len(m.TraceState) - copy(dAtA[i:], m.TraceState) - i = encodeVarintTrace(dAtA, i, uint64(len(m.TraceState))) - i-- - dAtA[i] = 0x1a - } - { - size := m.SpanId.Size() - i -= size - if _, err := m.SpanId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.TraceId.Size() - i -= size - if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Span_Event) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Span_Event) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Span_Event) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.DroppedAttributesCount != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x20 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintTrace(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x12 - } - if m.TimeUnixNano != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(m.TimeUnixNano)) - i-- - dAtA[i] = 0x9 - } - return len(dAtA) - i, nil -} - -func (m *Span_Link) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Span_Link) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Span_Link) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Flags != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Flags)) - i-- - dAtA[i] = 0x35 - } - if m.DroppedAttributesCount != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.DroppedAttributesCount)) - i-- - dAtA[i] = 0x28 - } - if len(m.Attributes) > 0 { - for iNdEx := len(m.Attributes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Attributes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.TraceState) > 0 { - i -= len(m.TraceState) - copy(dAtA[i:], m.TraceState) - i = encodeVarintTrace(dAtA, i, uint64(len(m.TraceState))) - i-- - dAtA[i] = 0x1a - } - { - size := m.SpanId.Size() - i -= size - if _, err := m.SpanId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.TraceId.Size() - i -= size - if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTrace(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Status) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Status) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Code != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x18 - } - if len(m.Message) > 0 { - i -= len(m.Message) - copy(dAtA[i:], m.Message) - i = encodeVarintTrace(dAtA, i, uint64(len(m.Message))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - -func encodeVarintTrace(dAtA []byte, offset int, v uint64) int { - offset -= sovTrace(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *TracesData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ResourceSpans) > 0 { - for _, e := range m.ResourceSpans { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - return n -} - -func (m *ResourceSpans) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Resource.Size() - n += 1 + l + sovTrace(uint64(l)) - if len(m.ScopeSpans) > 0 { - for _, e := range m.ScopeSpans { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - if len(m.DeprecatedScopeSpans) > 0 { - for _, e := range m.DeprecatedScopeSpans { - l = e.Size() - n += 2 + l + sovTrace(uint64(l)) - } - } - return n -} - -func (m *ScopeSpans) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Scope.Size() - n += 1 + l + sovTrace(uint64(l)) - if len(m.Spans) > 0 { - for _, e := range m.Spans { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - l = len(m.SchemaUrl) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - return n -} - -func (m *Span) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.TraceId.Size() - n += 1 + l + sovTrace(uint64(l)) - l = m.SpanId.Size() - n += 1 + l + sovTrace(uint64(l)) - l = len(m.TraceState) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - l = m.ParentSpanId.Size() - n += 1 + l + sovTrace(uint64(l)) - l = len(m.Name) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - if m.Kind != 0 { - n += 1 + sovTrace(uint64(m.Kind)) - } - if m.StartTimeUnixNano != 0 { - n += 9 - } - if m.EndTimeUnixNano != 0 { - n += 9 - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - if m.DroppedAttributesCount != 0 { - n += 1 + sovTrace(uint64(m.DroppedAttributesCount)) - } - if len(m.Events) > 0 { - for _, e := range m.Events { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - if m.DroppedEventsCount != 0 { - n += 1 + sovTrace(uint64(m.DroppedEventsCount)) - } - if len(m.Links) > 0 { - for _, e := range m.Links { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - if m.DroppedLinksCount != 0 { - n += 1 + sovTrace(uint64(m.DroppedLinksCount)) - } - l = m.Status.Size() - n += 1 + l + sovTrace(uint64(l)) - if m.Flags != 0 { - n += 6 - } - return n -} - -func (m *Span_Event) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TimeUnixNano != 0 { - n += 9 - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - if m.DroppedAttributesCount != 0 { - n += 1 + sovTrace(uint64(m.DroppedAttributesCount)) - } - return n -} - -func (m *Span_Link) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.TraceId.Size() - n += 1 + l + sovTrace(uint64(l)) - l = m.SpanId.Size() - n += 1 + l + sovTrace(uint64(l)) - l = len(m.TraceState) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - if len(m.Attributes) > 0 { - for _, e := range m.Attributes { - l = e.Size() - n += 1 + l + sovTrace(uint64(l)) - } - } - if m.DroppedAttributesCount != 0 { - n += 1 + sovTrace(uint64(m.DroppedAttributesCount)) - } - if m.Flags != 0 { - n += 5 - } - return n -} - -func (m *Status) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Message) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } - if m.Code != 0 { - n += 1 + sovTrace(uint64(m.Code)) - } - return n -} - -func sovTrace(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTrace(x uint64) (n int) { - return sovTrace(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *TracesData) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TracesData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TracesData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceSpans", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceSpans = append(m.ResourceSpans, &ResourceSpans{}) - if err := m.ResourceSpans[len(m.ResourceSpans)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ResourceSpans) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ResourceSpans: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResourceSpans: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeSpans", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ScopeSpans = append(m.ScopeSpans, &ScopeSpans{}) - if err := m.ScopeSpans[len(m.ScopeSpans)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 1000: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedScopeSpans", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DeprecatedScopeSpans = append(m.DeprecatedScopeSpans, &ScopeSpans{}) - if err := m.DeprecatedScopeSpans[len(m.DeprecatedScopeSpans)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ScopeSpans) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ScopeSpans: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ScopeSpans: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Scope.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Spans", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Spans = append(m.Spans, &Span{}) - if err := m.Spans[len(m.Spans)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Span) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Span: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Span: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SpanId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceState", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TraceState = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ParentSpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ParentSpanId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - m.Kind = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Kind |= Span_SpanKind(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTimeUnixNano", wireType) - } - m.StartTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.StartTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 8: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field EndTimeUnixNano", wireType) - } - m.EndTimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.EndTimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Events", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Events = append(m.Events, &Span_Event{}) - if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedEventsCount", wireType) - } - m.DroppedEventsCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedEventsCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Links", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Links = append(m.Links, &Span_Link{}) - if err := m.Links[len(m.Links)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedLinksCount", wireType) - } - m.DroppedLinksCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedLinksCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Status.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 16: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.Flags = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Span_Event) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Event: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeUnixNano", wireType) - } - m.TimeUnixNano = 0 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - m.TimeUnixNano = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Span_Link) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Link: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Link: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SpanId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceState", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TraceState = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Attributes = append(m.Attributes, v11.KeyValue{}) - if err := m.Attributes[len(m.Attributes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - m.DroppedAttributesCount = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.DroppedAttributesCount |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) - } - m.Flags = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.Flags = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Status) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Status: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Status: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTrace - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTrace - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Message = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTrace - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= Status_StatusCode(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTrace(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTrace - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTrace(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTrace - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTrace - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTrace - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTrace - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTrace - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTrace - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTrace = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTrace = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTrace = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/internal/data/spanid.go b/pdata/internal/data/spanid.go deleted file mode 100644 index 597e071ddaa..00000000000 --- a/pdata/internal/data/spanid.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package data // import "go.opentelemetry.io/collector/pdata/internal/data" - -import ( - "encoding/hex" - "errors" - - "github.com/gogo/protobuf/proto" - - "go.opentelemetry.io/collector/pdata/internal/json" -) - -const spanIDSize = 8 - -var ( - errMarshalSpanID = errors.New("marshal: invalid buffer length for SpanID") - errUnmarshalSpanID = errors.New("unmarshal: invalid SpanID length") -) - -// SpanID is a custom data type that is used for all span_id fields in OTLP -// Protobuf messages. -type SpanID [spanIDSize]byte - -var _ proto.Sizer = (*SpanID)(nil) - -// Size returns the size of the data to serialize. -func (sid SpanID) Size() int { - if sid.IsEmpty() { - return 0 - } - return spanIDSize -} - -// IsEmpty returns true if id contains at least one non-zero byte. -func (sid SpanID) IsEmpty() bool { - return sid == [spanIDSize]byte{} -} - -// MarshalTo converts trace ID into a binary representation. Called by Protobuf serialization. -func (sid SpanID) MarshalTo(data []byte) (n int, err error) { - if sid.IsEmpty() { - return 0, nil - } - - if len(data) < spanIDSize { - return 0, errMarshalSpanID - } - - return copy(data, sid[:]), nil -} - -// Unmarshal inflates this trace ID from binary representation. Called by Protobuf serialization. -func (sid *SpanID) Unmarshal(data []byte) error { - if len(data) == 0 { - *sid = [spanIDSize]byte{} - return nil - } - - if len(data) != spanIDSize { - return errUnmarshalSpanID - } - - copy(sid[:], data) - return nil -} - -// MarshalJSONStream converts SpanID into a hex string. -func (sid SpanID) MarshalJSONStream(dest *json.Stream) { - dest.WriteString(hex.EncodeToString(sid[:])) -} - -// UnmarshalJSONIter decodes SpanID from hex string. -func (sid *SpanID) UnmarshalJSONIter(iter *json.Iterator) { - *sid = [spanIDSize]byte{} - unmarshalJSON(sid[:], iter) -} diff --git a/pdata/internal/data/spanid_test.go b/pdata/internal/data/spanid_test.go deleted file mode 100644 index 20185ee08dd..00000000000 --- a/pdata/internal/data/spanid_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package data - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestSpanID(t *testing.T) { - sid := SpanID([8]byte{}) - assert.EqualValues(t, [8]byte{}, sid) - assert.Equal(t, 0, sid.Size()) - - b := [8]byte{1, 2, 3, 4, 5, 6, 7, 8} - sid = b - assert.EqualValues(t, b, sid) - assert.Equal(t, 8, sid.Size()) -} - -func TestSpanIDMarshal(t *testing.T) { - buf := make([]byte, 10) - - sid := SpanID([8]byte{}) - n, err := sid.MarshalTo(buf) - assert.Equal(t, 0, n) - require.NoError(t, err) - - sid = [8]byte{1, 2, 3, 4, 5, 6, 7, 8} - n, err = sid.MarshalTo(buf) - require.NoError(t, err) - assert.Equal(t, 8, n) - assert.Equal(t, []byte{1, 2, 3, 4, 5, 6, 7, 8}, buf[0:8]) - - _, err = sid.MarshalTo(buf[0:1]) - assert.Error(t, err) -} - -func TestSpanIDUnmarshal(t *testing.T) { - buf := []byte{0x12, 0x23, 0xAD, 0x12, 0x23, 0xAD, 0x12, 0x23} - - sid := SpanID{} - err := sid.Unmarshal(buf[0:8]) - require.NoError(t, err) - assert.EqualValues(t, [8]byte{0x12, 0x23, 0xAD, 0x12, 0x23, 0xAD, 0x12, 0x23}, sid) - - err = sid.Unmarshal(buf[0:0]) - require.NoError(t, err) - assert.EqualValues(t, [8]byte{}, sid) - - err = sid.Unmarshal(nil) - require.NoError(t, err) - assert.EqualValues(t, [8]byte{}, sid) - - err = sid.Unmarshal(buf[0:3]) - assert.Error(t, err) -} - -func TestSpanIDMarshalAndUnmarshalJSON(t *testing.T) { - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - src := SpanID([8]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}) - src.MarshalJSONStream(stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := SpanID{} - dest.UnmarshalJSONIter(iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/data/traceid.go b/pdata/internal/data/traceid.go deleted file mode 100644 index 0e7c98ac910..00000000000 --- a/pdata/internal/data/traceid.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package data // import "go.opentelemetry.io/collector/pdata/internal/data" - -import ( - "encoding/hex" - "errors" - - "github.com/gogo/protobuf/proto" - - "go.opentelemetry.io/collector/pdata/internal/json" -) - -const traceIDSize = 16 - -var ( - errMarshalTraceID = errors.New("marshal: invalid buffer length for TraceID") - errUnmarshalTraceID = errors.New("unmarshal: invalid TraceID length") -) - -// TraceID is a custom data type that is used for all trace_id fields in OTLP -// Protobuf messages. -type TraceID [traceIDSize]byte - -var _ proto.Sizer = (*TraceID)(nil) - -// Size returns the size of the data to serialize. -func (tid TraceID) Size() int { - if tid.IsEmpty() { - return 0 - } - return traceIDSize -} - -// IsEmpty returns true if id contains at leas one non-zero byte. -func (tid TraceID) IsEmpty() bool { - return tid == [traceIDSize]byte{} -} - -// MarshalTo converts trace ID into a binary representation. Called by Protobuf serialization. -func (tid TraceID) MarshalTo(data []byte) (n int, err error) { - if tid.IsEmpty() { - return 0, nil - } - - if len(data) < traceIDSize { - return 0, errMarshalTraceID - } - - return copy(data, tid[:]), nil -} - -// Unmarshal inflates this trace ID from binary representation. Called by Protobuf serialization. -func (tid *TraceID) Unmarshal(data []byte) error { - if len(data) == 0 { - *tid = [traceIDSize]byte{} - return nil - } - - if len(data) != traceIDSize { - return errUnmarshalTraceID - } - - copy(tid[:], data) - return nil -} - -// MarshalJSONStream converts TraceID into a hex string. -func (tid TraceID) MarshalJSONStream(dest *json.Stream) { - dest.WriteString(hex.EncodeToString(tid[:])) -} - -// UnmarshalJSONIter decodes TraceID from hex string. -func (tid *TraceID) UnmarshalJSONIter(iter *json.Iterator) { - *tid = [profileIDSize]byte{} - unmarshalJSON(tid[:], iter) -} diff --git a/pdata/internal/generated_enum_aggregationtemporality.go b/pdata/internal/generated_enum_aggregationtemporality.go new file mode 100644 index 00000000000..6c3a7208dbc --- /dev/null +++ b/pdata/internal/generated_enum_aggregationtemporality.go @@ -0,0 +1,29 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +const ( + AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED = AggregationTemporality(0) + AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA = AggregationTemporality(1) + AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE = AggregationTemporality(2) +) + +// AggregationTemporality defines how a metric aggregator reports aggregated values. +// It describes how those values relate to the time interval over which they are aggregated. +type AggregationTemporality int32 + +var AggregationTemporality_name = map[int32]string{ + 0: "AGGREGATION_TEMPORALITY_UNSPECIFIED", + 1: "AGGREGATION_TEMPORALITY_DELTA", + 2: "AGGREGATION_TEMPORALITY_CUMULATIVE", +} + +var AggregationTemporality_value = map[string]int32{ + "AGGREGATION_TEMPORALITY_UNSPECIFIED": 0, + "AGGREGATION_TEMPORALITY_DELTA": 1, + "AGGREGATION_TEMPORALITY_CUMULATIVE": 2, +} diff --git a/pdata/internal/generated_enum_severitynumber.go b/pdata/internal/generated_enum_severitynumber.go new file mode 100644 index 00000000000..4ad9a5b29db --- /dev/null +++ b/pdata/internal/generated_enum_severitynumber.go @@ -0,0 +1,94 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +const ( + SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED = SeverityNumber(0) + SeverityNumber_SEVERITY_NUMBER_TRACE = SeverityNumber(1) + SeverityNumber_SEVERITY_NUMBER_TRACE2 = SeverityNumber(2) + SeverityNumber_SEVERITY_NUMBER_TRACE3 = SeverityNumber(3) + SeverityNumber_SEVERITY_NUMBER_TRACE4 = SeverityNumber(4) + SeverityNumber_SEVERITY_NUMBER_DEBUG = SeverityNumber(5) + SeverityNumber_SEVERITY_NUMBER_DEBUG2 = SeverityNumber(6) + SeverityNumber_SEVERITY_NUMBER_DEBUG3 = SeverityNumber(7) + SeverityNumber_SEVERITY_NUMBER_DEBUG4 = SeverityNumber(8) + SeverityNumber_SEVERITY_NUMBER_INFO = SeverityNumber(9) + SeverityNumber_SEVERITY_NUMBER_INFO2 = SeverityNumber(10) + SeverityNumber_SEVERITY_NUMBER_INFO3 = SeverityNumber(11) + SeverityNumber_SEVERITY_NUMBER_INFO4 = SeverityNumber(12) + SeverityNumber_SEVERITY_NUMBER_WARN = SeverityNumber(13) + SeverityNumber_SEVERITY_NUMBER_WARN2 = SeverityNumber(14) + SeverityNumber_SEVERITY_NUMBER_WARN3 = SeverityNumber(15) + SeverityNumber_SEVERITY_NUMBER_WARN4 = SeverityNumber(16) + SeverityNumber_SEVERITY_NUMBER_ERROR = SeverityNumber(17) + SeverityNumber_SEVERITY_NUMBER_ERROR2 = SeverityNumber(18) + SeverityNumber_SEVERITY_NUMBER_ERROR3 = SeverityNumber(19) + SeverityNumber_SEVERITY_NUMBER_ERROR4 = SeverityNumber(20) + SeverityNumber_SEVERITY_NUMBER_FATAL = SeverityNumber(21) + SeverityNumber_SEVERITY_NUMBER_FATAL2 = SeverityNumber(22) + SeverityNumber_SEVERITY_NUMBER_FATAL3 = SeverityNumber(23) + SeverityNumber_SEVERITY_NUMBER_FATAL4 = SeverityNumber(24) +) + +// SeverityNumber represent possible values for LogRecord.SeverityNumber +type SeverityNumber int32 + +var SeverityNumber_name = map[int32]string{ + 0: "SEVERITY_NUMBER_UNSPECIFIED", + 1: "SEVERITY_NUMBER_TRACE ", + 2: "SEVERITY_NUMBER_TRACE2", + 3: "SEVERITY_NUMBER_TRACE3", + 4: "SEVERITY_NUMBER_TRACE4", + 5: "SEVERITY_NUMBER_DEBUG", + 6: "SEVERITY_NUMBER_DEBUG2", + 7: "SEVERITY_NUMBER_DEBUG3", + 8: "SEVERITY_NUMBER_DEBUG4", + 9: "SEVERITY_NUMBER_INFO", + 10: "SEVERITY_NUMBER_INFO2", + 11: "SEVERITY_NUMBER_INFO3", + 12: "SEVERITY_NUMBER_INFO4", + 13: "SEVERITY_NUMBER_WARN", + 14: "SEVERITY_NUMBER_WARN2", + 15: "SEVERITY_NUMBER_WARN3", + 16: "SEVERITY_NUMBER_WARN4", + 17: "SEVERITY_NUMBER_ERROR", + 18: "SEVERITY_NUMBER_ERROR2", + 19: "SEVERITY_NUMBER_ERROR3", + 20: "SEVERITY_NUMBER_ERROR4", + 21: "SEVERITY_NUMBER_FATAL", + 22: "SEVERITY_NUMBER_FATAL2", + 23: "SEVERITY_NUMBER_FATAL3", + 24: "SEVERITY_NUMBER_FATAL4", +} + +var SeverityNumber_value = map[string]int32{ + "SEVERITY_NUMBER_UNSPECIFIED": 0, + "SEVERITY_NUMBER_TRACE ": 1, + "SEVERITY_NUMBER_TRACE2": 2, + "SEVERITY_NUMBER_TRACE3": 3, + "SEVERITY_NUMBER_TRACE4": 4, + "SEVERITY_NUMBER_DEBUG": 5, + "SEVERITY_NUMBER_DEBUG2": 6, + "SEVERITY_NUMBER_DEBUG3": 7, + "SEVERITY_NUMBER_DEBUG4": 8, + "SEVERITY_NUMBER_INFO": 9, + "SEVERITY_NUMBER_INFO2": 10, + "SEVERITY_NUMBER_INFO3": 11, + "SEVERITY_NUMBER_INFO4": 12, + "SEVERITY_NUMBER_WARN": 13, + "SEVERITY_NUMBER_WARN2": 14, + "SEVERITY_NUMBER_WARN3": 15, + "SEVERITY_NUMBER_WARN4": 16, + "SEVERITY_NUMBER_ERROR": 17, + "SEVERITY_NUMBER_ERROR2": 18, + "SEVERITY_NUMBER_ERROR3": 19, + "SEVERITY_NUMBER_ERROR4": 20, + "SEVERITY_NUMBER_FATAL": 21, + "SEVERITY_NUMBER_FATAL2": 22, + "SEVERITY_NUMBER_FATAL3": 23, + "SEVERITY_NUMBER_FATAL4": 24, +} diff --git a/pdata/internal/generated_enum_spankind.go b/pdata/internal/generated_enum_spankind.go new file mode 100644 index 00000000000..1632aadde2a --- /dev/null +++ b/pdata/internal/generated_enum_spankind.go @@ -0,0 +1,38 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +const ( + SpanKind_SPAN_KIND_UNSPECIFIED = SpanKind(0) + SpanKind_SPAN_KIND_INTERNAL = SpanKind(1) + SpanKind_SPAN_KIND_SERVER = SpanKind(2) + SpanKind_SPAN_KIND_CLIENT = SpanKind(3) + SpanKind_SPAN_KIND_PRODUCER = SpanKind(4) + SpanKind_SPAN_KIND_CONSUMER = SpanKind(5) +) + +// SpanKind is the type of span. +// Can be used to specify additional relationships between spans in addition to a parent/child relationship. +type SpanKind int32 + +var SpanKind_name = map[int32]string{ + 0: "SPAN_KIND_UNSPECIFIED", + 1: "SPAN_KIND_INTERNAL", + 2: "SPAN_KIND_SERVER", + 3: "SPAN_KIND_CLIENT", + 4: "SPAN_KIND_PRODUCER", + 5: "SPAN_KIND_CONSUMER", +} + +var SpanKind_value = map[string]int32{ + "SPAN_KIND_UNSPECIFIED": 0, + "SPAN_KIND_INTERNAL": 1, + "SPAN_KIND_SERVER": 2, + "SPAN_KIND_CLIENT": 3, + "SPAN_KIND_PRODUCER": 4, + "SPAN_KIND_CONSUMER": 5, +} diff --git a/pdata/internal/generated_enum_statuscode.go b/pdata/internal/generated_enum_statuscode.go new file mode 100644 index 00000000000..ac5aab75934 --- /dev/null +++ b/pdata/internal/generated_enum_statuscode.go @@ -0,0 +1,29 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +const ( + StatusCode_STATUS_CODE_UNSET = StatusCode(0) + StatusCode_STATUS_CODE_OK = StatusCode(1) + StatusCode_STATUS_CODE_ERROR = StatusCode(2) +) + +// StatusCode is the status of the span, for the semantics of codes see +// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status +type StatusCode int32 + +var StatusCode_name = map[int32]string{ + 0: "STATUS_CODE_UNSET", + 1: "STATUS_CODE_OK", + 2: "STATUS_CODE_ERROR", +} + +var StatusCode_value = map[string]int32{ + "STATUS_CODE_UNSET": 0, + "STATUS_CODE_OK": 1, + "STATUS_CODE_ERROR": 2, +} diff --git a/pdata/internal/generated_proto_anyvalue.go b/pdata/internal/generated_proto_anyvalue.go new file mode 100644 index 00000000000..ddc86601cd8 --- /dev/null +++ b/pdata/internal/generated_proto_anyvalue.go @@ -0,0 +1,770 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "math" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +func (m *AnyValue) GetValue() any { + if m != nil { + return m.Value + } + return nil +} + +type AnyValue_StringValue struct { + StringValue string +} + +func (m *AnyValue) GetStringValue() string { + if v, ok := m.GetValue().(*AnyValue_StringValue); ok { + return v.StringValue + } + return "" +} + +type AnyValue_BoolValue struct { + BoolValue bool +} + +func (m *AnyValue) GetBoolValue() bool { + if v, ok := m.GetValue().(*AnyValue_BoolValue); ok { + return v.BoolValue + } + return false +} + +type AnyValue_IntValue struct { + IntValue int64 +} + +func (m *AnyValue) GetIntValue() int64 { + if v, ok := m.GetValue().(*AnyValue_IntValue); ok { + return v.IntValue + } + return int64(0) +} + +type AnyValue_DoubleValue struct { + DoubleValue float64 +} + +func (m *AnyValue) GetDoubleValue() float64 { + if v, ok := m.GetValue().(*AnyValue_DoubleValue); ok { + return v.DoubleValue + } + return float64(0) +} + +type AnyValue_ArrayValue struct { + ArrayValue *ArrayValue +} + +func (m *AnyValue) GetArrayValue() *ArrayValue { + if v, ok := m.GetValue().(*AnyValue_ArrayValue); ok { + return v.ArrayValue + } + return nil +} + +type AnyValue_KvlistValue struct { + KvlistValue *KeyValueList +} + +func (m *AnyValue) GetKvlistValue() *KeyValueList { + if v, ok := m.GetValue().(*AnyValue_KvlistValue); ok { + return v.KvlistValue + } + return nil +} + +type AnyValue_BytesValue struct { + BytesValue []byte +} + +func (m *AnyValue) GetBytesValue() []byte { + if v, ok := m.GetValue().(*AnyValue_BytesValue); ok { + return v.BytesValue + } + return nil +} + +type AnyValue struct { + Value any +} + +var ( + protoPoolAnyValue = sync.Pool{ + New: func() any { + return &AnyValue{} + }, + } + + ProtoPoolAnyValue_StringValue = sync.Pool{ + New: func() any { + return &AnyValue_StringValue{} + }, + } + + ProtoPoolAnyValue_BoolValue = sync.Pool{ + New: func() any { + return &AnyValue_BoolValue{} + }, + } + + ProtoPoolAnyValue_IntValue = sync.Pool{ + New: func() any { + return &AnyValue_IntValue{} + }, + } + + ProtoPoolAnyValue_DoubleValue = sync.Pool{ + New: func() any { + return &AnyValue_DoubleValue{} + }, + } + + ProtoPoolAnyValue_ArrayValue = sync.Pool{ + New: func() any { + return &AnyValue_ArrayValue{} + }, + } + + ProtoPoolAnyValue_KvlistValue = sync.Pool{ + New: func() any { + return &AnyValue_KvlistValue{} + }, + } + + ProtoPoolAnyValue_BytesValue = sync.Pool{ + New: func() any { + return &AnyValue_BytesValue{} + }, + } +) + +func NewAnyValue() *AnyValue { + if !UseProtoPooling.IsEnabled() { + return &AnyValue{} + } + return protoPoolAnyValue.Get().(*AnyValue) +} + +func DeleteAnyValue(orig *AnyValue, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + switch ov := orig.Value.(type) { + case *AnyValue_StringValue: + if UseProtoPooling.IsEnabled() { + ov.StringValue = "" + ProtoPoolAnyValue_StringValue.Put(ov) + } + case *AnyValue_BoolValue: + if UseProtoPooling.IsEnabled() { + ov.BoolValue = false + ProtoPoolAnyValue_BoolValue.Put(ov) + } + case *AnyValue_IntValue: + if UseProtoPooling.IsEnabled() { + ov.IntValue = int64(0) + ProtoPoolAnyValue_IntValue.Put(ov) + } + case *AnyValue_DoubleValue: + if UseProtoPooling.IsEnabled() { + ov.DoubleValue = float64(0) + ProtoPoolAnyValue_DoubleValue.Put(ov) + } + case *AnyValue_ArrayValue: + DeleteArrayValue(ov.ArrayValue, true) + ov.ArrayValue = nil + ProtoPoolAnyValue_ArrayValue.Put(ov) + case *AnyValue_KvlistValue: + DeleteKeyValueList(ov.KvlistValue, true) + ov.KvlistValue = nil + ProtoPoolAnyValue_KvlistValue.Put(ov) + case *AnyValue_BytesValue: + if UseProtoPooling.IsEnabled() { + ov.BytesValue = nil + ProtoPoolAnyValue_BytesValue.Put(ov) + } + + } + + orig.Reset() + if nullable { + protoPoolAnyValue.Put(orig) + } +} + +func CopyAnyValue(dest, src *AnyValue) *AnyValue { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewAnyValue() + } + switch t := src.Value.(type) { + case *AnyValue_StringValue: + var ov *AnyValue_StringValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_StringValue{} + } else { + ov = ProtoPoolAnyValue_StringValue.Get().(*AnyValue_StringValue) + } + ov.StringValue = t.StringValue + dest.Value = ov + case *AnyValue_BoolValue: + var ov *AnyValue_BoolValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_BoolValue{} + } else { + ov = ProtoPoolAnyValue_BoolValue.Get().(*AnyValue_BoolValue) + } + ov.BoolValue = t.BoolValue + dest.Value = ov + case *AnyValue_IntValue: + var ov *AnyValue_IntValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_IntValue{} + } else { + ov = ProtoPoolAnyValue_IntValue.Get().(*AnyValue_IntValue) + } + ov.IntValue = t.IntValue + dest.Value = ov + case *AnyValue_DoubleValue: + var ov *AnyValue_DoubleValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_DoubleValue{} + } else { + ov = ProtoPoolAnyValue_DoubleValue.Get().(*AnyValue_DoubleValue) + } + ov.DoubleValue = t.DoubleValue + dest.Value = ov + case *AnyValue_ArrayValue: + var ov *AnyValue_ArrayValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_ArrayValue{} + } else { + ov = ProtoPoolAnyValue_ArrayValue.Get().(*AnyValue_ArrayValue) + } + ov.ArrayValue = NewArrayValue() + CopyArrayValue(ov.ArrayValue, t.ArrayValue) + dest.Value = ov + + case *AnyValue_KvlistValue: + var ov *AnyValue_KvlistValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_KvlistValue{} + } else { + ov = ProtoPoolAnyValue_KvlistValue.Get().(*AnyValue_KvlistValue) + } + ov.KvlistValue = NewKeyValueList() + CopyKeyValueList(ov.KvlistValue, t.KvlistValue) + dest.Value = ov + + case *AnyValue_BytesValue: + var ov *AnyValue_BytesValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_BytesValue{} + } else { + ov = ProtoPoolAnyValue_BytesValue.Get().(*AnyValue_BytesValue) + } + ov.BytesValue = t.BytesValue + dest.Value = ov + default: + dest.Value = nil + } + + return dest +} + +func CopyAnyValueSlice(dest, src []AnyValue) []AnyValue { + var newDest []AnyValue + if cap(dest) < len(src) { + newDest = make([]AnyValue, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteAnyValue(&dest[i], false) + } + } + for i := range src { + CopyAnyValue(&newDest[i], &src[i]) + } + return newDest +} + +func CopyAnyValuePtrSlice(dest, src []*AnyValue) []*AnyValue { + var newDest []*AnyValue + if cap(dest) < len(src) { + newDest = make([]*AnyValue, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewAnyValue() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteAnyValue(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewAnyValue() + } + } + for i := range src { + CopyAnyValue(newDest[i], src[i]) + } + return newDest +} + +func (orig *AnyValue) Reset() { + *orig = AnyValue{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *AnyValue) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + switch orig := orig.Value.(type) { + case *AnyValue_StringValue: + dest.WriteObjectField("stringValue") + dest.WriteString(orig.StringValue) + case *AnyValue_BoolValue: + dest.WriteObjectField("boolValue") + dest.WriteBool(orig.BoolValue) + case *AnyValue_IntValue: + dest.WriteObjectField("intValue") + dest.WriteInt64(orig.IntValue) + case *AnyValue_DoubleValue: + dest.WriteObjectField("doubleValue") + dest.WriteFloat64(orig.DoubleValue) + case *AnyValue_ArrayValue: + if orig.ArrayValue != nil { + dest.WriteObjectField("arrayValue") + orig.ArrayValue.MarshalJSON(dest) + } + case *AnyValue_KvlistValue: + if orig.KvlistValue != nil { + dest.WriteObjectField("kvlistValue") + orig.KvlistValue.MarshalJSON(dest) + } + case *AnyValue_BytesValue: + + dest.WriteObjectField("bytesValue") + dest.WriteBytes(orig.BytesValue) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *AnyValue) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + + case "stringValue", "string_value": + { + var ov *AnyValue_StringValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_StringValue{} + } else { + ov = ProtoPoolAnyValue_StringValue.Get().(*AnyValue_StringValue) + } + ov.StringValue = iter.ReadString() + orig.Value = ov + } + + case "boolValue", "bool_value": + { + var ov *AnyValue_BoolValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_BoolValue{} + } else { + ov = ProtoPoolAnyValue_BoolValue.Get().(*AnyValue_BoolValue) + } + ov.BoolValue = iter.ReadBool() + orig.Value = ov + } + + case "intValue", "int_value": + { + var ov *AnyValue_IntValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_IntValue{} + } else { + ov = ProtoPoolAnyValue_IntValue.Get().(*AnyValue_IntValue) + } + ov.IntValue = iter.ReadInt64() + orig.Value = ov + } + + case "doubleValue", "double_value": + { + var ov *AnyValue_DoubleValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_DoubleValue{} + } else { + ov = ProtoPoolAnyValue_DoubleValue.Get().(*AnyValue_DoubleValue) + } + ov.DoubleValue = iter.ReadFloat64() + orig.Value = ov + } + + case "arrayValue", "array_value": + { + var ov *AnyValue_ArrayValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_ArrayValue{} + } else { + ov = ProtoPoolAnyValue_ArrayValue.Get().(*AnyValue_ArrayValue) + } + ov.ArrayValue = NewArrayValue() + ov.ArrayValue.UnmarshalJSON(iter) + orig.Value = ov + } + + case "kvlistValue", "kvlist_value": + { + var ov *AnyValue_KvlistValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_KvlistValue{} + } else { + ov = ProtoPoolAnyValue_KvlistValue.Get().(*AnyValue_KvlistValue) + } + ov.KvlistValue = NewKeyValueList() + ov.KvlistValue.UnmarshalJSON(iter) + orig.Value = ov + } + + case "bytesValue", "bytes_value": + { + var ov *AnyValue_BytesValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_BytesValue{} + } else { + ov = ProtoPoolAnyValue_BytesValue.Get().(*AnyValue_BytesValue) + } + ov.BytesValue = iter.ReadBytes() + orig.Value = ov + } + + default: + iter.Skip() + } + } +} + +func (orig *AnyValue) SizeProto() int { + var n int + var l int + _ = l + switch orig := orig.Value.(type) { + case nil: + _ = orig + break + case *AnyValue_StringValue: + 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 { + l = orig.ArrayValue.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *AnyValue_KvlistValue: + if orig.KvlistValue != nil { + l = orig.KvlistValue.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *AnyValue_BytesValue: + l = len(orig.BytesValue) + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *AnyValue) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + switch orig := orig.Value.(type) { + case *AnyValue_StringValue: + l = len(orig.StringValue) + pos -= l + copy(buf[pos:], orig.StringValue) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + case *AnyValue_BoolValue: + pos-- + if orig.BoolValue { + buf[pos] = 1 + } else { + buf[pos] = 0 + } + pos-- + buf[pos] = 0x10 + + case *AnyValue_IntValue: + pos = proto.EncodeVarint(buf, pos, uint64(orig.IntValue)) + pos-- + buf[pos] = 0x18 + + case *AnyValue_DoubleValue: + pos -= 8 + binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.DoubleValue)) + pos-- + buf[pos] = 0x21 + + case *AnyValue_ArrayValue: + if orig.ArrayValue != nil { + l = orig.ArrayValue.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x2a + } + case *AnyValue_KvlistValue: + if orig.KvlistValue != nil { + l = orig.KvlistValue.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x32 + } + case *AnyValue_BytesValue: + l = len(orig.BytesValue) + pos -= l + copy(buf[pos:], orig.BytesValue) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x3a + + } + return len(buf) - pos +} + +func (orig *AnyValue) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field StringValue", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *AnyValue_StringValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_StringValue{} + } else { + ov = ProtoPoolAnyValue_StringValue.Get().(*AnyValue_StringValue) + } + ov.StringValue = string(buf[startPos:pos]) + orig.Value = ov + + case 2: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field BoolValue", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + var ov *AnyValue_BoolValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_BoolValue{} + } else { + ov = ProtoPoolAnyValue_BoolValue.Get().(*AnyValue_BoolValue) + } + ov.BoolValue = num != 0 + orig.Value = ov + + case 3: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field IntValue", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + var ov *AnyValue_IntValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_IntValue{} + } else { + ov = ProtoPoolAnyValue_IntValue.Get().(*AnyValue_IntValue) + } + ov.IntValue = int64(num) + orig.Value = ov + + case 4: + if wireType != proto.WireTypeI64 { + return fmt.Errorf("proto: wrong wireType = %d for field DoubleValue", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeI64(buf, pos) + if err != nil { + return err + } + var ov *AnyValue_DoubleValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_DoubleValue{} + } else { + ov = ProtoPoolAnyValue_DoubleValue.Get().(*AnyValue_DoubleValue) + } + ov.DoubleValue = math.Float64frombits(num) + orig.Value = ov + + case 5: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ArrayValue", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *AnyValue_ArrayValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_ArrayValue{} + } else { + ov = ProtoPoolAnyValue_ArrayValue.Get().(*AnyValue_ArrayValue) + } + ov.ArrayValue = NewArrayValue() + err = ov.ArrayValue.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Value = ov + + case 6: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field KvlistValue", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *AnyValue_KvlistValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_KvlistValue{} + } else { + ov = ProtoPoolAnyValue_KvlistValue.Get().(*AnyValue_KvlistValue) + } + ov.KvlistValue = NewKeyValueList() + err = ov.KvlistValue.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Value = ov + + case 7: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field BytesValue", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *AnyValue_BytesValue + if !UseProtoPooling.IsEnabled() { + ov = &AnyValue_BytesValue{} + } else { + ov = ProtoPoolAnyValue_BytesValue.Get().(*AnyValue_BytesValue) + } + if length != 0 { + ov.BytesValue = make([]byte, length) + copy(ov.BytesValue, buf[startPos:pos]) + } + orig.Value = ov + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestAnyValue() *AnyValue { + orig := NewAnyValue() + orig.Value = &AnyValue_StringValue{StringValue: "test_stringvalue"} + return orig +} + +func GenTestAnyValuePtrSlice() []*AnyValue { + orig := make([]*AnyValue, 5) + orig[0] = NewAnyValue() + orig[1] = GenTestAnyValue() + orig[2] = NewAnyValue() + orig[3] = GenTestAnyValue() + orig[4] = NewAnyValue() + return orig +} + +func GenTestAnyValueSlice() []AnyValue { + orig := make([]AnyValue, 5) + orig[1] = *GenTestAnyValue() + orig[3] = *GenTestAnyValue() + return orig +} diff --git a/pdata/internal/generated_proto_anyvalue_test.go b/pdata/internal/generated_proto_anyvalue_test.go new file mode 100644 index 00000000000..d13a653e629 --- /dev/null +++ b/pdata/internal/generated_proto_anyvalue_test.go @@ -0,0 +1,234 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcommon "go.opentelemetry.io/proto/slim/otlp/common/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyAnyValue(t *testing.T) { + for name, src := range genTestEncodingValuesAnyValue() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewAnyValue() + CopyAnyValue(dest, src) + assert.Equal(t, src, dest) + CopyAnyValue(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyAnyValueSlice(t *testing.T) { + src := []AnyValue{} + dest := []AnyValue{} + // Test CopyTo empty + dest = CopyAnyValueSlice(dest, src) + assert.Equal(t, []AnyValue{}, dest) + + // Test CopyTo larger slice + src = GenTestAnyValueSlice() + dest = CopyAnyValueSlice(dest, src) + assert.Equal(t, GenTestAnyValueSlice(), dest) + + // Test CopyTo same size slice + dest = CopyAnyValueSlice(dest, src) + assert.Equal(t, GenTestAnyValueSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyAnyValueSlice(dest, []AnyValue{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyAnyValueSlice(dest, src) + assert.Equal(t, GenTestAnyValueSlice(), dest) +} + +func TestCopyAnyValuePtrSlice(t *testing.T) { + src := []*AnyValue{} + dest := []*AnyValue{} + // Test CopyTo empty + dest = CopyAnyValuePtrSlice(dest, src) + assert.Equal(t, []*AnyValue{}, dest) + + // Test CopyTo larger slice + src = GenTestAnyValuePtrSlice() + dest = CopyAnyValuePtrSlice(dest, src) + assert.Equal(t, GenTestAnyValuePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyAnyValuePtrSlice(dest, src) + assert.Equal(t, GenTestAnyValuePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyAnyValuePtrSlice(dest, []*AnyValue{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyAnyValuePtrSlice(dest, src) + assert.Equal(t, GenTestAnyValuePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONAnyValueUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewAnyValue() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewAnyValue(), dest) +} + +func TestMarshalAndUnmarshalJSONAnyValue(t *testing.T) { + for name, src := range genTestEncodingValuesAnyValue() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewAnyValue() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteAnyValue(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoAnyValueFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesAnyValue() { + t.Run(name, func(t *testing.T) { + dest := NewAnyValue() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoAnyValueUnknown(t *testing.T) { + dest := NewAnyValue() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewAnyValue(), dest) +} + +func TestMarshalAndUnmarshalProtoAnyValue(t *testing.T) { + for name, src := range genTestEncodingValuesAnyValue() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewAnyValue() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteAnyValue(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufAnyValue(t *testing.T) { + for name, src := range genTestEncodingValuesAnyValue() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcommon.AnyValue{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewAnyValue() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesAnyValue() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + + "StringValue/wrong_wire_type": {0xc}, + "StringValue/missing_value": {0xa}, + + "BoolValue/wrong_wire_type": {0x14}, + "BoolValue/missing_value": {0x10}, + + "IntValue/wrong_wire_type": {0x1c}, + "IntValue/missing_value": {0x18}, + + "DoubleValue/wrong_wire_type": {0x24}, + "DoubleValue/missing_value": {0x21}, + + "ArrayValue/wrong_wire_type": {0x2c}, + "ArrayValue/missing_value": {0x2a}, + + "KvlistValue/wrong_wire_type": {0x34}, + "KvlistValue/missing_value": {0x32}, + + "BytesValue/wrong_wire_type": {0x3c}, + "BytesValue/missing_value": {0x3a}, + } +} + +func genTestEncodingValuesAnyValue() map[string]*AnyValue { + return map[string]*AnyValue{ + "empty": NewAnyValue(), + "StringValue/default": {Value: &AnyValue_StringValue{StringValue: ""}}, + "StringValue/test": {Value: &AnyValue_StringValue{StringValue: "test_stringvalue"}}, + "BoolValue/default": {Value: &AnyValue_BoolValue{BoolValue: false}}, + "BoolValue/test": {Value: &AnyValue_BoolValue{BoolValue: true}}, + "IntValue/default": {Value: &AnyValue_IntValue{IntValue: int64(0)}}, + "IntValue/test": {Value: &AnyValue_IntValue{IntValue: int64(13)}}, + "DoubleValue/default": {Value: &AnyValue_DoubleValue{DoubleValue: float64(0)}}, + "DoubleValue/test": {Value: &AnyValue_DoubleValue{DoubleValue: float64(3.1415926)}}, + "ArrayValue/default": {Value: &AnyValue_ArrayValue{ArrayValue: &ArrayValue{}}}, + "ArrayValue/test": {Value: &AnyValue_ArrayValue{ArrayValue: GenTestArrayValue()}}, + "KvlistValue/default": {Value: &AnyValue_KvlistValue{KvlistValue: &KeyValueList{}}}, + "KvlistValue/test": {Value: &AnyValue_KvlistValue{KvlistValue: GenTestKeyValueList()}}, + "BytesValue/default": {Value: &AnyValue_BytesValue{BytesValue: nil}}, + "BytesValue/test": {Value: &AnyValue_BytesValue{BytesValue: []byte{1, 2, 3}}}, + } +} diff --git a/pdata/internal/generated_proto_arrayvalue.go b/pdata/internal/generated_proto_arrayvalue.go new file mode 100644 index 00000000000..a4367eac263 --- /dev/null +++ b/pdata/internal/generated_proto_arrayvalue.go @@ -0,0 +1,245 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message since oneof in AnyValue does not allow repeated fields. +type ArrayValue struct { + Values []AnyValue +} + +var ( + protoPoolArrayValue = sync.Pool{ + New: func() any { + return &ArrayValue{} + }, + } +) + +func NewArrayValue() *ArrayValue { + if !UseProtoPooling.IsEnabled() { + return &ArrayValue{} + } + return protoPoolArrayValue.Get().(*ArrayValue) +} + +func DeleteArrayValue(orig *ArrayValue, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.Values { + DeleteAnyValue(&orig.Values[i], false) + } + + orig.Reset() + if nullable { + protoPoolArrayValue.Put(orig) + } +} + +func CopyArrayValue(dest, src *ArrayValue) *ArrayValue { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewArrayValue() + } + dest.Values = CopyAnyValueSlice(dest.Values, src.Values) + + return dest +} + +func CopyArrayValueSlice(dest, src []ArrayValue) []ArrayValue { + var newDest []ArrayValue + if cap(dest) < len(src) { + newDest = make([]ArrayValue, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteArrayValue(&dest[i], false) + } + } + for i := range src { + CopyArrayValue(&newDest[i], &src[i]) + } + return newDest +} + +func CopyArrayValuePtrSlice(dest, src []*ArrayValue) []*ArrayValue { + var newDest []*ArrayValue + if cap(dest) < len(src) { + newDest = make([]*ArrayValue, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewArrayValue() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteArrayValue(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewArrayValue() + } + } + for i := range src { + CopyArrayValue(newDest[i], src[i]) + } + return newDest +} + +func (orig *ArrayValue) Reset() { + *orig = ArrayValue{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ArrayValue) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.Values) > 0 { + dest.WriteObjectField("values") + dest.WriteArrayStart() + orig.Values[0].MarshalJSON(dest) + for i := 1; i < len(orig.Values); i++ { + dest.WriteMore() + orig.Values[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ArrayValue) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "values": + for iter.ReadArray() { + orig.Values = append(orig.Values, AnyValue{}) + orig.Values[len(orig.Values)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ArrayValue) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.Values { + l = orig.Values[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ArrayValue) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.Values) - 1; i >= 0; i-- { + l = orig.Values[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *ArrayValue) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Values = append(orig.Values, AnyValue{}) + err = orig.Values[len(orig.Values)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestArrayValue() *ArrayValue { + orig := NewArrayValue() + orig.Values = []AnyValue{{}, *GenTestAnyValue()} + return orig +} + +func GenTestArrayValuePtrSlice() []*ArrayValue { + orig := make([]*ArrayValue, 5) + orig[0] = NewArrayValue() + orig[1] = GenTestArrayValue() + orig[2] = NewArrayValue() + orig[3] = GenTestArrayValue() + orig[4] = NewArrayValue() + return orig +} + +func GenTestArrayValueSlice() []ArrayValue { + orig := make([]ArrayValue, 5) + orig[1] = *GenTestArrayValue() + orig[3] = *GenTestArrayValue() + return orig +} diff --git a/pdata/internal/generated_wrapper_arrayvalue_test.go b/pdata/internal/generated_proto_arrayvalue_test.go similarity index 53% rename from pdata/internal/generated_wrapper_arrayvalue_test.go rename to pdata/internal/generated_proto_arrayvalue_test.go index ea1ab4a7a19..7b08f3e83cc 100644 --- a/pdata/internal/generated_wrapper_arrayvalue_test.go +++ b/pdata/internal/generated_proto_arrayvalue_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigArrayValue(t *testing.T) { +func TestCopyArrayValue(t *testing.T) { for name, src := range genTestEncodingValuesArrayValue() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigArrayValue(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigArrayValue() - CopyOrigArrayValue(dest, src) + dest := NewArrayValue() + CopyArrayValue(dest, src) assert.Equal(t, src, dest) - CopyOrigArrayValue(dest, dest) + CopyArrayValue(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigArrayValueUnknown(t *testing.T) { +func TestCopyArrayValueSlice(t *testing.T) { + src := []ArrayValue{} + dest := []ArrayValue{} + // Test CopyTo empty + dest = CopyArrayValueSlice(dest, src) + assert.Equal(t, []ArrayValue{}, dest) + + // Test CopyTo larger slice + src = GenTestArrayValueSlice() + dest = CopyArrayValueSlice(dest, src) + assert.Equal(t, GenTestArrayValueSlice(), dest) + + // Test CopyTo same size slice + dest = CopyArrayValueSlice(dest, src) + assert.Equal(t, GenTestArrayValueSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyArrayValueSlice(dest, []ArrayValue{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyArrayValueSlice(dest, src) + assert.Equal(t, GenTestArrayValueSlice(), dest) +} + +func TestCopyArrayValuePtrSlice(t *testing.T) { + src := []*ArrayValue{} + dest := []*ArrayValue{} + // Test CopyTo empty + dest = CopyArrayValuePtrSlice(dest, src) + assert.Equal(t, []*ArrayValue{}, dest) + + // Test CopyTo larger slice + src = GenTestArrayValuePtrSlice() + dest = CopyArrayValuePtrSlice(dest, src) + assert.Equal(t, GenTestArrayValuePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyArrayValuePtrSlice(dest, src) + assert.Equal(t, GenTestArrayValuePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyArrayValuePtrSlice(dest, []*ArrayValue{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyArrayValuePtrSlice(dest, src) + assert.Equal(t, GenTestArrayValuePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONArrayValueUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigArrayValue() - UnmarshalJSONOrigArrayValue(dest, iter) + dest := NewArrayValue() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigArrayValue(), dest) + assert.Equal(t, NewArrayValue(), dest) } -func TestMarshalAndUnmarshalJSONOrigArrayValue(t *testing.T) { +func TestMarshalAndUnmarshalJSONArrayValue(t *testing.T) { for name, src := range genTestEncodingValuesArrayValue() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigArrayValue(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigArrayValue(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigArrayValue() - UnmarshalJSONOrigArrayValue(dest, iter) + dest := NewArrayValue() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigArrayValue(dest, true) + DeleteArrayValue(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigArrayValueFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoArrayValueFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesArrayValue() { t.Run(name, func(t *testing.T) { - dest := NewOrigArrayValue() - require.Error(t, UnmarshalProtoOrigArrayValue(dest, buf)) + dest := NewArrayValue() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigArrayValueUnknown(t *testing.T) { - dest := NewOrigArrayValue() +func TestMarshalAndUnmarshalProtoArrayValueUnknown(t *testing.T) { + dest := NewArrayValue() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigArrayValue(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigArrayValue(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewArrayValue(), dest) } -func TestMarshalAndUnmarshalProtoOrigArrayValue(t *testing.T) { +func TestMarshalAndUnmarshalProtoArrayValue(t *testing.T) { for name, src := range genTestEncodingValuesArrayValue() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigArrayValue(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigArrayValue(src)) - gotSize := MarshalProtoOrigArrayValue(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigArrayValue() - require.NoError(t, UnmarshalProtoOrigArrayValue(dest, buf)) + dest := NewArrayValue() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigArrayValue(dest, true) + DeleteArrayValue(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigArrayValue(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufArrayValue(t *testing.T) { for name, src := range genTestEncodingValuesArrayValue() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigArrayValue(src)) - gotSize := MarshalProtoOrigArrayValue(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcommon.ArrayValue{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufArrayValue(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigArrayValue() - require.NoError(t, UnmarshalProtoOrigArrayValue(dest, goBuf)) + dest := NewArrayValue() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -145,9 +194,9 @@ func genTestFailingUnmarshalProtoValuesArrayValue() map[string][]byte { } } -func genTestEncodingValuesArrayValue() map[string]*otlpcommon.ArrayValue { - return map[string]*otlpcommon.ArrayValue{ - "empty": NewOrigArrayValue(), - "Values/default_and_test": {Values: []otlpcommon.AnyValue{{}, *GenTestOrigAnyValue()}}, +func genTestEncodingValuesArrayValue() map[string]*ArrayValue { + return map[string]*ArrayValue{ + "empty": NewArrayValue(), + "Values/test": {Values: []AnyValue{{}, *GenTestAnyValue()}}, } } diff --git a/pdata/internal/generated_proto_entityref.go b/pdata/internal/generated_proto_entityref.go new file mode 100644 index 00000000000..47c562e6813 --- /dev/null +++ b/pdata/internal/generated_proto_entityref.go @@ -0,0 +1,346 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type EntityRef struct { + SchemaUrl string + Type string + IdKeys []string + DescriptionKeys []string +} + +var ( + protoPoolEntityRef = sync.Pool{ + New: func() any { + return &EntityRef{} + }, + } +) + +func NewEntityRef() *EntityRef { + if !UseProtoPooling.IsEnabled() { + return &EntityRef{} + } + return protoPoolEntityRef.Get().(*EntityRef) +} + +func DeleteEntityRef(orig *EntityRef, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolEntityRef.Put(orig) + } +} + +func CopyEntityRef(dest, src *EntityRef) *EntityRef { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + 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 +} + +func CopyEntityRefSlice(dest, src []EntityRef) []EntityRef { + var newDest []EntityRef + if cap(dest) < len(src) { + newDest = make([]EntityRef, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteEntityRef(&dest[i], false) + } + } + for i := range src { + CopyEntityRef(&newDest[i], &src[i]) + } + return newDest +} + +func CopyEntityRefPtrSlice(dest, src []*EntityRef) []*EntityRef { + var newDest []*EntityRef + if cap(dest) < len(src) { + newDest = make([]*EntityRef, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewEntityRef() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteEntityRef(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewEntityRef() + } + } + for i := range src { + CopyEntityRef(newDest[i], src[i]) + } + return newDest +} + +func (orig *EntityRef) Reset() { + *orig = EntityRef{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *EntityRef) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + if orig.Type != "" { + dest.WriteObjectField("type") + dest.WriteString(orig.Type) + } + if len(orig.IdKeys) > 0 { + dest.WriteObjectField("idKeys") + dest.WriteArrayStart() + dest.WriteString(orig.IdKeys[0]) + for i := 1; i < len(orig.IdKeys); i++ { + dest.WriteMore() + dest.WriteString(orig.IdKeys[i]) + } + dest.WriteArrayEnd() + } + if len(orig.DescriptionKeys) > 0 { + dest.WriteObjectField("descriptionKeys") + dest.WriteArrayStart() + dest.WriteString(orig.DescriptionKeys[0]) + for i := 1; i < len(orig.DescriptionKeys); i++ { + dest.WriteMore() + dest.WriteString(orig.DescriptionKeys[i]) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *EntityRef) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + case "type": + orig.Type = iter.ReadString() + case "idKeys", "id_keys": + for iter.ReadArray() { + orig.IdKeys = append(orig.IdKeys, iter.ReadString()) + } + + case "descriptionKeys", "description_keys": + for iter.ReadArray() { + orig.DescriptionKeys = append(orig.DescriptionKeys, iter.ReadString()) + } + + default: + iter.Skip() + } + } +} + +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 + } + for _, s := range orig.IdKeys { + l = len(s) + n += 1 + proto.Sov(uint64(l)) + l + } + for _, s := range orig.DescriptionKeys { + l = len(s) + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *EntityRef) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = len(orig.Type) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Type) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + for i := len(orig.IdKeys) - 1; i >= 0; i-- { + l = len(orig.IdKeys[i]) + pos -= l + copy(buf[pos:], orig.IdKeys[i]) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + for i := len(orig.DescriptionKeys) - 1; i >= 0; i-- { + l = len(orig.DescriptionKeys[i]) + pos -= l + copy(buf[pos:], orig.DescriptionKeys[i]) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x22 + } + return len(buf) - pos +} + +func (orig *EntityRef) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Type = string(buf[startPos:pos]) + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field IdKeys", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.IdKeys = append(orig.IdKeys, string(buf[startPos:pos])) + + case 4: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DescriptionKeys", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DescriptionKeys = append(orig.DescriptionKeys, string(buf[startPos:pos])) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestEntityRef() *EntityRef { + orig := NewEntityRef() + orig.SchemaUrl = "test_schemaurl" + orig.Type = "test_type" + orig.IdKeys = []string{"", "test_idkeys"} + orig.DescriptionKeys = []string{"", "test_descriptionkeys"} + return orig +} + +func GenTestEntityRefPtrSlice() []*EntityRef { + orig := make([]*EntityRef, 5) + orig[0] = NewEntityRef() + orig[1] = GenTestEntityRef() + orig[2] = NewEntityRef() + orig[3] = GenTestEntityRef() + orig[4] = NewEntityRef() + return orig +} + +func GenTestEntityRefSlice() []EntityRef { + orig := make([]EntityRef, 5) + orig[1] = *GenTestEntityRef() + orig[3] = *GenTestEntityRef() + return orig +} diff --git a/pdata/internal/generated_wrapper_entityref_test.go b/pdata/internal/generated_proto_entityref_test.go similarity index 53% rename from pdata/internal/generated_wrapper_entityref_test.go rename to pdata/internal/generated_proto_entityref_test.go index 01739312216..ceddc482568 100644 --- a/pdata/internal/generated_wrapper_entityref_test.go +++ b/pdata/internal/generated_proto_entityref_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigEntityRef(t *testing.T) { +func TestCopyEntityRef(t *testing.T) { for name, src := range genTestEncodingValuesEntityRef() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigEntityRef(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigEntityRef() - CopyOrigEntityRef(dest, src) + dest := NewEntityRef() + CopyEntityRef(dest, src) assert.Equal(t, src, dest) - CopyOrigEntityRef(dest, dest) + CopyEntityRef(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigEntityRefUnknown(t *testing.T) { +func TestCopyEntityRefSlice(t *testing.T) { + src := []EntityRef{} + dest := []EntityRef{} + // Test CopyTo empty + dest = CopyEntityRefSlice(dest, src) + assert.Equal(t, []EntityRef{}, dest) + + // Test CopyTo larger slice + src = GenTestEntityRefSlice() + dest = CopyEntityRefSlice(dest, src) + assert.Equal(t, GenTestEntityRefSlice(), dest) + + // Test CopyTo same size slice + dest = CopyEntityRefSlice(dest, src) + assert.Equal(t, GenTestEntityRefSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyEntityRefSlice(dest, []EntityRef{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyEntityRefSlice(dest, src) + assert.Equal(t, GenTestEntityRefSlice(), dest) +} + +func TestCopyEntityRefPtrSlice(t *testing.T) { + src := []*EntityRef{} + dest := []*EntityRef{} + // Test CopyTo empty + dest = CopyEntityRefPtrSlice(dest, src) + assert.Equal(t, []*EntityRef{}, dest) + + // Test CopyTo larger slice + src = GenTestEntityRefPtrSlice() + dest = CopyEntityRefPtrSlice(dest, src) + assert.Equal(t, GenTestEntityRefPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyEntityRefPtrSlice(dest, src) + assert.Equal(t, GenTestEntityRefPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyEntityRefPtrSlice(dest, []*EntityRef{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyEntityRefPtrSlice(dest, src) + assert.Equal(t, GenTestEntityRefPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONEntityRefUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigEntityRef() - UnmarshalJSONOrigEntityRef(dest, iter) + dest := NewEntityRef() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigEntityRef(), dest) + assert.Equal(t, NewEntityRef(), dest) } -func TestMarshalAndUnmarshalJSONOrigEntityRef(t *testing.T) { +func TestMarshalAndUnmarshalJSONEntityRef(t *testing.T) { for name, src := range genTestEncodingValuesEntityRef() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigEntityRef(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigEntityRef(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigEntityRef() - UnmarshalJSONOrigEntityRef(dest, iter) + dest := NewEntityRef() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigEntityRef(dest, true) + DeleteEntityRef(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigEntityRefFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoEntityRefFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesEntityRef() { t.Run(name, func(t *testing.T) { - dest := NewOrigEntityRef() - require.Error(t, UnmarshalProtoOrigEntityRef(dest, buf)) + dest := NewEntityRef() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigEntityRefUnknown(t *testing.T) { - dest := NewOrigEntityRef() +func TestMarshalAndUnmarshalProtoEntityRefUnknown(t *testing.T) { + dest := NewEntityRef() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigEntityRef(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigEntityRef(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewEntityRef(), dest) } -func TestMarshalAndUnmarshalProtoOrigEntityRef(t *testing.T) { +func TestMarshalAndUnmarshalProtoEntityRef(t *testing.T) { for name, src := range genTestEncodingValuesEntityRef() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigEntityRef(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigEntityRef(src)) - gotSize := MarshalProtoOrigEntityRef(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigEntityRef() - require.NoError(t, UnmarshalProtoOrigEntityRef(dest, buf)) + dest := NewEntityRef() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigEntityRef(dest, true) + DeleteEntityRef(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigEntityRef(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufEntityRef(t *testing.T) { for name, src := range genTestEncodingValuesEntityRef() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigEntityRef(src)) - gotSize := MarshalProtoOrigEntityRef(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcommon.EntityRef{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufEntityRef(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigEntityRef() - require.NoError(t, UnmarshalProtoOrigEntityRef(dest, goBuf)) + dest := NewEntityRef() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -151,12 +200,12 @@ func genTestFailingUnmarshalProtoValuesEntityRef() map[string][]byte { } } -func genTestEncodingValuesEntityRef() map[string]*otlpcommon.EntityRef { - return map[string]*otlpcommon.EntityRef{ - "empty": NewOrigEntityRef(), - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, - "Type/test": {Type: "test_type"}, - "IdKeys/default_and_test": {IdKeys: []string{"", "test_idkeys"}}, - "DescriptionKeys/default_and_test": {DescriptionKeys: []string{"", "test_descriptionkeys"}}, +func genTestEncodingValuesEntityRef() map[string]*EntityRef { + return map[string]*EntityRef{ + "empty": NewEntityRef(), + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, + "Type/test": {Type: "test_type"}, + "IdKeys/test": {IdKeys: []string{"", "test_idkeys"}}, + "DescriptionKeys/test": {DescriptionKeys: []string{"", "test_descriptionkeys"}}, } } diff --git a/pdata/internal/generated_wrapper_exemplar.go b/pdata/internal/generated_proto_exemplar.go similarity index 50% rename from pdata/internal/generated_wrapper_exemplar.go rename to pdata/internal/generated_proto_exemplar.go index 3c3222e6db0..29223128d0d 100644 --- a/pdata/internal/generated_wrapper_exemplar.go +++ b/pdata/internal/generated_proto_exemplar.go @@ -12,41 +12,79 @@ import ( "math" "sync" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +func (m *Exemplar) GetValue() any { + if m != nil { + return m.Value + } + return nil +} + +type Exemplar_AsDouble struct { + AsDouble float64 +} + +func (m *Exemplar) GetAsDouble() float64 { + if v, ok := m.GetValue().(*Exemplar_AsDouble); ok { + return v.AsDouble + } + return float64(0) +} + +type Exemplar_AsInt struct { + AsInt int64 +} + +func (m *Exemplar) GetAsInt() int64 { + if v, ok := m.GetValue().(*Exemplar_AsInt); ok { + return v.AsInt + } + return int64(0) +} + +// Exemplar is a sample input double measurement. +// +// 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 { + FilteredAttributes []KeyValue + TimeUnixNano uint64 + Value any + TraceId TraceID + SpanId SpanID +} + var ( protoPoolExemplar = sync.Pool{ New: func() any { - return &otlpmetrics.Exemplar{} + return &Exemplar{} }, } ProtoPoolExemplar_AsDouble = sync.Pool{ New: func() any { - return &otlpmetrics.Exemplar_AsDouble{} + return &Exemplar_AsDouble{} }, } ProtoPoolExemplar_AsInt = sync.Pool{ New: func() any { - return &otlpmetrics.Exemplar_AsInt{} + return &Exemplar_AsInt{} }, } ) -func NewOrigExemplar() *otlpmetrics.Exemplar { +func NewExemplar() *Exemplar { if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.Exemplar{} + return &Exemplar{} } - return protoPoolExemplar.Get().(*otlpmetrics.Exemplar) + return protoPoolExemplar.Get().(*Exemplar) } -func DeleteOrigExemplar(orig *otlpmetrics.Exemplar, nullable bool) { +func DeleteExemplar(orig *Exemplar, nullable bool) { if orig == nil { return } @@ -57,23 +95,23 @@ func DeleteOrigExemplar(orig *otlpmetrics.Exemplar, nullable bool) { } for i := range orig.FilteredAttributes { - DeleteOrigKeyValue(&orig.FilteredAttributes[i], false) + DeleteKeyValue(&orig.FilteredAttributes[i], false) } switch ov := orig.Value.(type) { - case *otlpmetrics.Exemplar_AsDouble: + case *Exemplar_AsDouble: if UseProtoPooling.IsEnabled() { ov.AsDouble = float64(0) ProtoPoolExemplar_AsDouble.Put(ov) } - case *otlpmetrics.Exemplar_AsInt: + case *Exemplar_AsInt: if UseProtoPooling.IsEnabled() { ov.AsInt = int64(0) ProtoPoolExemplar_AsInt.Put(ov) } } - DeleteOrigSpanID(&orig.SpanId, false) - DeleteOrigTraceID(&orig.TraceId, false) + DeleteTraceID(&orig.TraceId, false) + DeleteSpanID(&orig.SpanId, false) orig.Reset() if nullable { @@ -81,57 +119,114 @@ func DeleteOrigExemplar(orig *otlpmetrics.Exemplar, nullable bool) { } } -func CopyOrigExemplar(dest, src *otlpmetrics.Exemplar) { +func CopyExemplar(dest, src *Exemplar) *Exemplar { // If copying to same object, just return. if src == dest { - return + return dest } - dest.FilteredAttributes = CopyOrigKeyValueSlice(dest.FilteredAttributes, src.FilteredAttributes) + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExemplar() + } + dest.FilteredAttributes = CopyKeyValueSlice(dest.FilteredAttributes, src.FilteredAttributes) + dest.TimeUnixNano = src.TimeUnixNano + switch t := src.Value.(type) { - case *otlpmetrics.Exemplar_AsDouble: - var ov *otlpmetrics.Exemplar_AsDouble + case *Exemplar_AsDouble: + var ov *Exemplar_AsDouble if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsDouble{} + ov = &Exemplar_AsDouble{} } else { - ov = ProtoPoolExemplar_AsDouble.Get().(*otlpmetrics.Exemplar_AsDouble) + ov = ProtoPoolExemplar_AsDouble.Get().(*Exemplar_AsDouble) } ov.AsDouble = t.AsDouble dest.Value = ov - case *otlpmetrics.Exemplar_AsInt: - var ov *otlpmetrics.Exemplar_AsInt + case *Exemplar_AsInt: + var ov *Exemplar_AsInt if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsInt{} + ov = &Exemplar_AsInt{} } else { - ov = ProtoPoolExemplar_AsInt.Get().(*otlpmetrics.Exemplar_AsInt) + ov = ProtoPoolExemplar_AsInt.Get().(*Exemplar_AsInt) } ov.AsInt = t.AsInt dest.Value = ov + default: + dest.Value = nil } - dest.SpanId = src.SpanId - dest.TraceId = src.TraceId + CopyTraceID(&dest.TraceId, &src.TraceId) + + CopySpanID(&dest.SpanId, &src.SpanId) + + return dest } -func GenTestOrigExemplar() *otlpmetrics.Exemplar { - orig := NewOrigExemplar() - orig.FilteredAttributes = GenerateOrigTestKeyValueSlice() - orig.TimeUnixNano = 1234567890 - orig.Value = &otlpmetrics.Exemplar_AsInt{AsInt: int64(13)} - orig.SpanId = data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) - orig.TraceId = data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - return orig +func CopyExemplarSlice(dest, src []Exemplar) []Exemplar { + var newDest []Exemplar + if cap(dest) < len(src) { + newDest = make([]Exemplar, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExemplar(&dest[i], false) + } + } + for i := range src { + CopyExemplar(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExemplarPtrSlice(dest, src []*Exemplar) []*Exemplar { + var newDest []*Exemplar + if cap(dest) < len(src) { + newDest = make([]*Exemplar, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExemplar() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExemplar(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExemplar() + } + } + for i := range src { + CopyExemplar(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExemplar(orig *otlpmetrics.Exemplar, dest *json.Stream) { +func (orig *Exemplar) Reset() { + *orig = Exemplar{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Exemplar) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.FilteredAttributes) > 0 { dest.WriteObjectField("filteredAttributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.FilteredAttributes[0], dest) + orig.FilteredAttributes[0].MarshalJSON(dest) for i := 1; i < len(orig.FilteredAttributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.FilteredAttributes[i], dest) + orig.FilteredAttributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -140,32 +235,32 @@ func MarshalJSONOrigExemplar(orig *otlpmetrics.Exemplar, dest *json.Stream) { dest.WriteUint64(orig.TimeUnixNano) } switch orig := orig.Value.(type) { - case *otlpmetrics.Exemplar_AsDouble: + case *Exemplar_AsDouble: dest.WriteObjectField("asDouble") dest.WriteFloat64(orig.AsDouble) - case *otlpmetrics.Exemplar_AsInt: + case *Exemplar_AsInt: dest.WriteObjectField("asInt") dest.WriteInt64(orig.AsInt) } - if orig.SpanId != data.SpanID([8]byte{}) { - dest.WriteObjectField("spanId") - MarshalJSONOrigSpanID(&orig.SpanId, dest) - } - if orig.TraceId != data.TraceID([16]byte{}) { + if !orig.TraceId.IsEmpty() { dest.WriteObjectField("traceId") - MarshalJSONOrigTraceID(&orig.TraceId, dest) + orig.TraceId.MarshalJSON(dest) + } + if !orig.SpanId.IsEmpty() { + dest.WriteObjectField("spanId") + orig.SpanId.MarshalJSON(dest) } dest.WriteObjectEnd() } -// UnmarshalJSONOrigExemplar unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExemplar(orig *otlpmetrics.Exemplar, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Exemplar) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "filteredAttributes", "filtered_attributes": for iter.ReadArray() { - orig.FilteredAttributes = append(orig.FilteredAttributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.FilteredAttributes[len(orig.FilteredAttributes)-1], iter) + orig.FilteredAttributes = append(orig.FilteredAttributes, KeyValue{}) + orig.FilteredAttributes[len(orig.FilteredAttributes)-1].UnmarshalJSON(iter) } case "timeUnixNano", "time_unix_nano": @@ -173,11 +268,11 @@ func UnmarshalJSONOrigExemplar(orig *otlpmetrics.Exemplar, iter *json.Iterator) case "asDouble", "as_double": { - var ov *otlpmetrics.Exemplar_AsDouble + var ov *Exemplar_AsDouble if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsDouble{} + ov = &Exemplar_AsDouble{} } else { - ov = ProtoPoolExemplar_AsDouble.Get().(*otlpmetrics.Exemplar_AsDouble) + ov = ProtoPoolExemplar_AsDouble.Get().(*Exemplar_AsDouble) } ov.AsDouble = iter.ReadFloat64() orig.Value = ov @@ -185,32 +280,34 @@ func UnmarshalJSONOrigExemplar(orig *otlpmetrics.Exemplar, iter *json.Iterator) case "asInt", "as_int": { - var ov *otlpmetrics.Exemplar_AsInt + var ov *Exemplar_AsInt if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsInt{} + ov = &Exemplar_AsInt{} } else { - ov = ProtoPoolExemplar_AsInt.Get().(*otlpmetrics.Exemplar_AsInt) + ov = ProtoPoolExemplar_AsInt.Get().(*Exemplar_AsInt) } ov.AsInt = iter.ReadInt64() orig.Value = ov } - case "spanId", "span_id": - UnmarshalJSONOrigSpanID(&orig.SpanId, iter) case "traceId", "trace_id": - UnmarshalJSONOrigTraceID(&orig.TraceId, iter) + + orig.TraceId.UnmarshalJSON(iter) + case "spanId", "span_id": + + orig.SpanId.UnmarshalJSON(iter) default: iter.Skip() } } } -func SizeProtoOrigExemplar(orig *otlpmetrics.Exemplar) int { +func (orig *Exemplar) SizeProto() int { var n int var l int _ = l for i := range orig.FilteredAttributes { - l = SizeProtoOrigKeyValue(&orig.FilteredAttributes[i]) + l = orig.FilteredAttributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.TimeUnixNano != 0 { @@ -220,24 +317,24 @@ func SizeProtoOrigExemplar(orig *otlpmetrics.Exemplar) int { case nil: _ = orig break - case *otlpmetrics.Exemplar_AsDouble: + case *Exemplar_AsDouble: n += 9 - case *otlpmetrics.Exemplar_AsInt: + case *Exemplar_AsInt: n += 9 } - l = SizeProtoOrigSpanID(&orig.SpanId) + l = orig.TraceId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - l = SizeProtoOrigTraceID(&orig.TraceId) + l = orig.SpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l return n } -func MarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) int { +func (orig *Exemplar) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.FilteredAttributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.FilteredAttributes[i], buf[:pos]) + l = orig.FilteredAttributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -250,36 +347,35 @@ func MarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) int { buf[pos] = 0x11 } switch orig := orig.Value.(type) { - case *otlpmetrics.Exemplar_AsDouble: + case *Exemplar_AsDouble: pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.AsDouble)) pos-- buf[pos] = 0x19 - case *otlpmetrics.Exemplar_AsInt: + case *Exemplar_AsInt: pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.AsInt)) pos-- buf[pos] = 0x31 } - - l = MarshalProtoOrigSpanID(&orig.SpanId, buf[:pos]) + l = orig.TraceId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- - buf[pos] = 0x22 + buf[pos] = 0x2a - l = MarshalProtoOrigTraceID(&orig.TraceId, buf[:pos]) + l = orig.SpanId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- - buf[pos] = 0x2a + buf[pos] = 0x22 return len(buf) - pos } -func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { +func (orig *Exemplar) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -304,8 +400,8 @@ func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { return err } startPos := pos - length - orig.FilteredAttributes = append(orig.FilteredAttributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.FilteredAttributes[len(orig.FilteredAttributes)-1], buf[startPos:pos]) + orig.FilteredAttributes = append(orig.FilteredAttributes, KeyValue{}) + err = orig.FilteredAttributes[len(orig.FilteredAttributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -331,11 +427,11 @@ func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { if err != nil { return err } - var ov *otlpmetrics.Exemplar_AsDouble + var ov *Exemplar_AsDouble if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsDouble{} + ov = &Exemplar_AsDouble{} } else { - ov = ProtoPoolExemplar_AsDouble.Get().(*otlpmetrics.Exemplar_AsDouble) + ov = ProtoPoolExemplar_AsDouble.Get().(*Exemplar_AsDouble) } ov.AsDouble = math.Float64frombits(num) orig.Value = ov @@ -349,18 +445,18 @@ func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { if err != nil { return err } - var ov *otlpmetrics.Exemplar_AsInt + var ov *Exemplar_AsInt if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsInt{} + ov = &Exemplar_AsInt{} } else { - ov = ProtoPoolExemplar_AsInt.Get().(*otlpmetrics.Exemplar_AsInt) + ov = ProtoPoolExemplar_AsInt.Get().(*Exemplar_AsInt) } ov.AsInt = int64(num) orig.Value = ov - case 4: + case 5: if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) } var length int length, pos, err = proto.ConsumeLen(buf, pos) @@ -369,14 +465,14 @@ func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigSpanID(&orig.SpanId, buf[startPos:pos]) + err = orig.TraceId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } - case 5: + case 4: if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) } var length int length, pos, err = proto.ConsumeLen(buf, pos) @@ -385,7 +481,7 @@ func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigTraceID(&orig.TraceId, buf[startPos:pos]) + err = orig.SpanId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -398,3 +494,30 @@ func UnmarshalProtoOrigExemplar(orig *otlpmetrics.Exemplar, buf []byte) error { } return nil } + +func GenTestExemplar() *Exemplar { + orig := NewExemplar() + orig.FilteredAttributes = []KeyValue{{}, *GenTestKeyValue()} + orig.TimeUnixNano = uint64(13) + orig.Value = &Exemplar_AsDouble{AsDouble: float64(3.1415926)} + orig.TraceId = *GenTestTraceID() + orig.SpanId = *GenTestSpanID() + return orig +} + +func GenTestExemplarPtrSlice() []*Exemplar { + orig := make([]*Exemplar, 5) + orig[0] = NewExemplar() + orig[1] = GenTestExemplar() + orig[2] = NewExemplar() + orig[3] = GenTestExemplar() + orig[4] = NewExemplar() + return orig +} + +func GenTestExemplarSlice() []Exemplar { + orig := make([]Exemplar, 5) + orig[1] = *GenTestExemplar() + orig[3] = *GenTestExemplar() + return orig +} diff --git a/pdata/internal/generated_wrapper_exemplar_test.go b/pdata/internal/generated_proto_exemplar_test.go similarity index 52% rename from pdata/internal/generated_wrapper_exemplar_test.go rename to pdata/internal/generated_proto_exemplar_test.go index d1c33cef2ec..bd50bfa99e3 100644 --- a/pdata/internal/generated_wrapper_exemplar_test.go +++ b/pdata/internal/generated_proto_exemplar_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigExemplar(t *testing.T) { +func TestCopyExemplar(t *testing.T) { for name, src := range genTestEncodingValuesExemplar() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigExemplar(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigExemplar() - CopyOrigExemplar(dest, src) + dest := NewExemplar() + CopyExemplar(dest, src) assert.Equal(t, src, dest) - CopyOrigExemplar(dest, dest) + CopyExemplar(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigExemplarUnknown(t *testing.T) { +func TestCopyExemplarSlice(t *testing.T) { + src := []Exemplar{} + dest := []Exemplar{} + // Test CopyTo empty + dest = CopyExemplarSlice(dest, src) + assert.Equal(t, []Exemplar{}, dest) + + // Test CopyTo larger slice + src = GenTestExemplarSlice() + dest = CopyExemplarSlice(dest, src) + assert.Equal(t, GenTestExemplarSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExemplarSlice(dest, src) + assert.Equal(t, GenTestExemplarSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExemplarSlice(dest, []Exemplar{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExemplarSlice(dest, src) + assert.Equal(t, GenTestExemplarSlice(), dest) +} + +func TestCopyExemplarPtrSlice(t *testing.T) { + src := []*Exemplar{} + dest := []*Exemplar{} + // Test CopyTo empty + dest = CopyExemplarPtrSlice(dest, src) + assert.Equal(t, []*Exemplar{}, dest) + + // Test CopyTo larger slice + src = GenTestExemplarPtrSlice() + dest = CopyExemplarPtrSlice(dest, src) + assert.Equal(t, GenTestExemplarPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExemplarPtrSlice(dest, src) + assert.Equal(t, GenTestExemplarPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExemplarPtrSlice(dest, []*Exemplar{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExemplarPtrSlice(dest, src) + assert.Equal(t, GenTestExemplarPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExemplarUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigExemplar() - UnmarshalJSONOrigExemplar(dest, iter) + dest := NewExemplar() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExemplar(), dest) + assert.Equal(t, NewExemplar(), dest) } -func TestMarshalAndUnmarshalJSONOrigExemplar(t *testing.T) { +func TestMarshalAndUnmarshalJSONExemplar(t *testing.T) { for name, src := range genTestEncodingValuesExemplar() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigExemplar(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigExemplar(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigExemplar() - UnmarshalJSONOrigExemplar(dest, iter) + dest := NewExemplar() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigExemplar(dest, true) + DeleteExemplar(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigExemplarFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoExemplarFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesExemplar() { t.Run(name, func(t *testing.T) { - dest := NewOrigExemplar() - require.Error(t, UnmarshalProtoOrigExemplar(dest, buf)) + dest := NewExemplar() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigExemplarUnknown(t *testing.T) { - dest := NewOrigExemplar() +func TestMarshalAndUnmarshalProtoExemplarUnknown(t *testing.T) { + dest := NewExemplar() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExemplar(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExemplar(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExemplar(), dest) } -func TestMarshalAndUnmarshalProtoOrigExemplar(t *testing.T) { +func TestMarshalAndUnmarshalProtoExemplar(t *testing.T) { for name, src := range genTestEncodingValuesExemplar() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigExemplar(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigExemplar(src)) - gotSize := MarshalProtoOrigExemplar(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigExemplar() - require.NoError(t, UnmarshalProtoOrigExemplar(dest, buf)) + dest := NewExemplar() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigExemplar(dest, true) + DeleteExemplar(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigExemplar(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufExemplar(t *testing.T) { for name, src := range genTestEncodingValuesExemplar() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExemplar(src)) - gotSize := MarshalProtoOrigExemplar(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.Exemplar{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufExemplar(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigExemplar() - require.NoError(t, UnmarshalProtoOrigExemplar(dest, goBuf)) + dest := NewExemplar() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -151,23 +199,23 @@ func genTestFailingUnmarshalProtoValuesExemplar() map[string][]byte { "AsInt/wrong_wire_type": {0x34}, "AsInt/missing_value": {0x31}, - "SpanId/wrong_wire_type": {0x24}, - "SpanId/missing_value": {0x22}, "TraceId/wrong_wire_type": {0x2c}, "TraceId/missing_value": {0x2a}, + "SpanId/wrong_wire_type": {0x24}, + "SpanId/missing_value": {0x22}, } } -func genTestEncodingValuesExemplar() map[string]*otlpmetrics.Exemplar { - return map[string]*otlpmetrics.Exemplar{ - "empty": NewOrigExemplar(), - "FilteredAttributes/default_and_test": {FilteredAttributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, - "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, - "AsDouble/default": {Value: &otlpmetrics.Exemplar_AsDouble{AsDouble: float64(0)}}, - "AsDouble/test": {Value: &otlpmetrics.Exemplar_AsDouble{AsDouble: float64(3.1415926)}}, - "AsInt/default": {Value: &otlpmetrics.Exemplar_AsInt{AsInt: int64(0)}}, - "AsInt/test": {Value: &otlpmetrics.Exemplar_AsInt{AsInt: int64(13)}}, - "SpanId/test": {SpanId: *GenTestOrigSpanID()}, - "TraceId/test": {TraceId: *GenTestOrigTraceID()}, +func genTestEncodingValuesExemplar() map[string]*Exemplar { + return map[string]*Exemplar{ + "empty": NewExemplar(), + "FilteredAttributes/test": {FilteredAttributes: []KeyValue{{}, *GenTestKeyValue()}}, + "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, + "AsDouble/default": {Value: &Exemplar_AsDouble{AsDouble: float64(0)}}, + "AsDouble/test": {Value: &Exemplar_AsDouble{AsDouble: float64(3.1415926)}}, + "AsInt/default": {Value: &Exemplar_AsInt{AsInt: int64(0)}}, + "AsInt/test": {Value: &Exemplar_AsInt{AsInt: int64(13)}}, + "TraceId/test": {TraceId: *GenTestTraceID()}, + "SpanId/test": {SpanId: *GenTestSpanID()}, } } diff --git a/pdata/internal/generated_proto_exponentialhistogram.go b/pdata/internal/generated_proto_exponentialhistogram.go new file mode 100644 index 00000000000..926816346a9 --- /dev/null +++ b/pdata/internal/generated_proto_exponentialhistogram.go @@ -0,0 +1,277 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExponentialHistogram represents the type of a metric that is calculated by aggregating +// as a ExponentialHistogram of all reported double measurements over a time interval. +type ExponentialHistogram struct { + DataPoints []*ExponentialHistogramDataPoint + AggregationTemporality AggregationTemporality +} + +var ( + protoPoolExponentialHistogram = sync.Pool{ + New: func() any { + return &ExponentialHistogram{} + }, + } +) + +func NewExponentialHistogram() *ExponentialHistogram { + if !UseProtoPooling.IsEnabled() { + return &ExponentialHistogram{} + } + return protoPoolExponentialHistogram.Get().(*ExponentialHistogram) +} + +func DeleteExponentialHistogram(orig *ExponentialHistogram, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.DataPoints { + DeleteExponentialHistogramDataPoint(orig.DataPoints[i], true) + } + + orig.Reset() + if nullable { + protoPoolExponentialHistogram.Put(orig) + } +} + +func CopyExponentialHistogram(dest, src *ExponentialHistogram) *ExponentialHistogram { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExponentialHistogram() + } + dest.DataPoints = CopyExponentialHistogramDataPointPtrSlice(dest.DataPoints, src.DataPoints) + + dest.AggregationTemporality = src.AggregationTemporality + + return dest +} + +func CopyExponentialHistogramSlice(dest, src []ExponentialHistogram) []ExponentialHistogram { + var newDest []ExponentialHistogram + if cap(dest) < len(src) { + newDest = make([]ExponentialHistogram, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExponentialHistogram(&dest[i], false) + } + } + for i := range src { + CopyExponentialHistogram(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExponentialHistogramPtrSlice(dest, src []*ExponentialHistogram) []*ExponentialHistogram { + var newDest []*ExponentialHistogram + if cap(dest) < len(src) { + newDest = make([]*ExponentialHistogram, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExponentialHistogram() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExponentialHistogram(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExponentialHistogram() + } + } + for i := range src { + CopyExponentialHistogram(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExponentialHistogram) Reset() { + *orig = ExponentialHistogram{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExponentialHistogram) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.DataPoints) > 0 { + dest.WriteObjectField("dataPoints") + dest.WriteArrayStart() + orig.DataPoints[0].MarshalJSON(dest) + for i := 1; i < len(orig.DataPoints); i++ { + dest.WriteMore() + orig.DataPoints[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + + if int32(orig.AggregationTemporality) != 0 { + dest.WriteObjectField("aggregationTemporality") + dest.WriteInt32(int32(orig.AggregationTemporality)) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExponentialHistogram) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "dataPoints", "data_points": + for iter.ReadArray() { + orig.DataPoints = append(orig.DataPoints, NewExponentialHistogramDataPoint()) + orig.DataPoints[len(orig.DataPoints)-1].UnmarshalJSON(iter) + } + + case "aggregationTemporality", "aggregation_temporality": + orig.AggregationTemporality = AggregationTemporality(iter.ReadEnumValue(AggregationTemporality_value)) + default: + iter.Skip() + } + } +} + +func (orig *ExponentialHistogram) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.DataPoints { + l = orig.DataPoints[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + if orig.AggregationTemporality != 0 { + n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) + } + return n +} + +func (orig *ExponentialHistogram) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.DataPoints) - 1; i >= 0; i-- { + l = orig.DataPoints[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + if orig.AggregationTemporality != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) + pos-- + buf[pos] = 0x10 + } + return len(buf) - pos +} + +func (orig *ExponentialHistogram) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DataPoints = append(orig.DataPoints, NewExponentialHistogramDataPoint()) + err = orig.DataPoints[len(orig.DataPoints)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.AggregationTemporality = AggregationTemporality(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExponentialHistogram() *ExponentialHistogram { + orig := NewExponentialHistogram() + orig.DataPoints = []*ExponentialHistogramDataPoint{{}, GenTestExponentialHistogramDataPoint()} + orig.AggregationTemporality = AggregationTemporality(13) + return orig +} + +func GenTestExponentialHistogramPtrSlice() []*ExponentialHistogram { + orig := make([]*ExponentialHistogram, 5) + orig[0] = NewExponentialHistogram() + orig[1] = GenTestExponentialHistogram() + orig[2] = NewExponentialHistogram() + orig[3] = GenTestExponentialHistogram() + orig[4] = NewExponentialHistogram() + return orig +} + +func GenTestExponentialHistogramSlice() []ExponentialHistogram { + orig := make([]ExponentialHistogram, 5) + orig[1] = *GenTestExponentialHistogram() + orig[3] = *GenTestExponentialHistogram() + return orig +} diff --git a/pdata/internal/generated_proto_exponentialhistogram_test.go b/pdata/internal/generated_proto_exponentialhistogram_test.go new file mode 100644 index 00000000000..9a153b76830 --- /dev/null +++ b/pdata/internal/generated_proto_exponentialhistogram_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExponentialHistogram(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogram() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExponentialHistogram() + CopyExponentialHistogram(dest, src) + assert.Equal(t, src, dest) + CopyExponentialHistogram(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExponentialHistogramSlice(t *testing.T) { + src := []ExponentialHistogram{} + dest := []ExponentialHistogram{} + // Test CopyTo empty + dest = CopyExponentialHistogramSlice(dest, src) + assert.Equal(t, []ExponentialHistogram{}, dest) + + // Test CopyTo larger slice + src = GenTestExponentialHistogramSlice() + dest = CopyExponentialHistogramSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExponentialHistogramSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExponentialHistogramSlice(dest, []ExponentialHistogram{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExponentialHistogramSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramSlice(), dest) +} + +func TestCopyExponentialHistogramPtrSlice(t *testing.T) { + src := []*ExponentialHistogram{} + dest := []*ExponentialHistogram{} + // Test CopyTo empty + dest = CopyExponentialHistogramPtrSlice(dest, src) + assert.Equal(t, []*ExponentialHistogram{}, dest) + + // Test CopyTo larger slice + src = GenTestExponentialHistogramPtrSlice() + dest = CopyExponentialHistogramPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExponentialHistogramPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExponentialHistogramPtrSlice(dest, []*ExponentialHistogram{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExponentialHistogramPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExponentialHistogramUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExponentialHistogram() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExponentialHistogram(), dest) +} + +func TestMarshalAndUnmarshalJSONExponentialHistogram(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogram() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExponentialHistogram() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExponentialHistogram(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExponentialHistogram() { + t.Run(name, func(t *testing.T) { + dest := NewExponentialHistogram() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramUnknown(t *testing.T) { + dest := NewExponentialHistogram() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExponentialHistogram(), dest) +} + +func TestMarshalAndUnmarshalProtoExponentialHistogram(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogram() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExponentialHistogram() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExponentialHistogram(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExponentialHistogram(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogram() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpmetrics.ExponentialHistogram{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExponentialHistogram() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExponentialHistogram() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "DataPoints/wrong_wire_type": {0xc}, + "DataPoints/missing_value": {0xa}, + "AggregationTemporality/wrong_wire_type": {0x14}, + "AggregationTemporality/missing_value": {0x10}, + } +} + +func genTestEncodingValuesExponentialHistogram() map[string]*ExponentialHistogram { + return map[string]*ExponentialHistogram{ + "empty": NewExponentialHistogram(), + "DataPoints/test": {DataPoints: []*ExponentialHistogramDataPoint{{}, GenTestExponentialHistogramDataPoint()}}, + "AggregationTemporality/test": {AggregationTemporality: AggregationTemporality(13)}, + } +} diff --git a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint.go b/pdata/internal/generated_proto_exponentialhistogramdatapoint.go similarity index 52% rename from pdata/internal/generated_wrapper_exponentialhistogramdatapoint.go rename to pdata/internal/generated_proto_exponentialhistogramdatapoint.go index 29bc0011c91..d16c0120ebd 100644 --- a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint.go +++ b/pdata/internal/generated_proto_exponentialhistogramdatapoint.go @@ -12,45 +12,118 @@ import ( "math" "sync" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "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 { + Attributes []KeyValue + StartTimeUnixNano uint64 + TimeUnixNano uint64 + Count uint64 + Sum_ any + Scale int32 + ZeroCount uint64 + Positive ExponentialHistogramDataPointBuckets + Negative ExponentialHistogramDataPointBuckets + Flags uint32 + Exemplars []Exemplar + Min_ any + Max_ any + ZeroThreshold float64 +} + var ( protoPoolExponentialHistogramDataPoint = sync.Pool{ New: func() any { - return &otlpmetrics.ExponentialHistogramDataPoint{} + return &ExponentialHistogramDataPoint{} }, } ProtoPoolExponentialHistogramDataPoint_Sum = sync.Pool{ New: func() any { - return &otlpmetrics.ExponentialHistogramDataPoint_Sum{} + return &ExponentialHistogramDataPoint_Sum{} }, } ProtoPoolExponentialHistogramDataPoint_Min = sync.Pool{ New: func() any { - return &otlpmetrics.ExponentialHistogramDataPoint_Min{} + return &ExponentialHistogramDataPoint_Min{} }, } ProtoPoolExponentialHistogramDataPoint_Max = sync.Pool{ New: func() any { - return &otlpmetrics.ExponentialHistogramDataPoint_Max{} + return &ExponentialHistogramDataPoint_Max{} }, } ) -func NewOrigExponentialHistogramDataPoint() *otlpmetrics.ExponentialHistogramDataPoint { +func NewExponentialHistogramDataPoint() *ExponentialHistogramDataPoint { if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.ExponentialHistogramDataPoint{} + return &ExponentialHistogramDataPoint{} } - return protoPoolExponentialHistogramDataPoint.Get().(*otlpmetrics.ExponentialHistogramDataPoint) + return protoPoolExponentialHistogramDataPoint.Get().(*ExponentialHistogramDataPoint) } -func DeleteOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint, nullable bool) { +func DeleteExponentialHistogramDataPoint(orig *ExponentialHistogramDataPoint, nullable bool) { if orig == nil { return } @@ -61,23 +134,23 @@ func DeleteOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistog } for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } switch ov := orig.Sum_.(type) { - case *otlpmetrics.ExponentialHistogramDataPoint_Sum: + case *ExponentialHistogramDataPoint_Sum: if UseProtoPooling.IsEnabled() { ov.Sum = float64(0) ProtoPoolExponentialHistogramDataPoint_Sum.Put(ov) } } - DeleteOrigExponentialHistogramDataPoint_Buckets(&orig.Positive, false) - DeleteOrigExponentialHistogramDataPoint_Buckets(&orig.Negative, false) + DeleteExponentialHistogramDataPointBuckets(&orig.Positive, false) + DeleteExponentialHistogramDataPointBuckets(&orig.Negative, false) for i := range orig.Exemplars { - DeleteOrigExemplar(&orig.Exemplars[i], false) + DeleteExemplar(&orig.Exemplars[i], false) } switch ov := orig.Min_.(type) { - case *otlpmetrics.ExponentialHistogramDataPoint_Min: + case *ExponentialHistogramDataPoint_Min: if UseProtoPooling.IsEnabled() { ov.Min = float64(0) ProtoPoolExponentialHistogramDataPoint_Min.Put(ov) @@ -85,7 +158,7 @@ func DeleteOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistog } switch ov := orig.Max_.(type) { - case *otlpmetrics.ExponentialHistogramDataPoint_Max: + case *ExponentialHistogramDataPoint_Max: if UseProtoPooling.IsEnabled() { ov.Max = float64(0) ProtoPoolExponentialHistogramDataPoint_Max.Put(ov) @@ -99,83 +172,148 @@ func DeleteOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistog } } -func CopyOrigExponentialHistogramDataPoint(dest, src *otlpmetrics.ExponentialHistogramDataPoint) { +func CopyExponentialHistogramDataPoint(dest, src *ExponentialHistogramDataPoint) *ExponentialHistogramDataPoint { // If copying to same object, just return. if src == dest { - return + return dest } - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExponentialHistogramDataPoint() + } + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + dest.StartTimeUnixNano = src.StartTimeUnixNano + dest.TimeUnixNano = src.TimeUnixNano + dest.Count = src.Count - if srcSum, ok := src.Sum_.(*otlpmetrics.ExponentialHistogramDataPoint_Sum); ok { - destSum, ok := dest.Sum_.(*otlpmetrics.ExponentialHistogramDataPoint_Sum) - if !ok { - destSum = &otlpmetrics.ExponentialHistogramDataPoint_Sum{} - dest.Sum_ = destSum + + 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) } - destSum.Sum = srcSum.Sum - } else { + ov.Sum = t.Sum + dest.Sum_ = ov + default: dest.Sum_ = nil } + dest.Scale = src.Scale + dest.ZeroCount = src.ZeroCount - CopyOrigExponentialHistogramDataPoint_Buckets(&dest.Positive, &src.Positive) - CopyOrigExponentialHistogramDataPoint_Buckets(&dest.Negative, &src.Negative) + + CopyExponentialHistogramDataPointBuckets(&dest.Positive, &src.Positive) + + CopyExponentialHistogramDataPointBuckets(&dest.Negative, &src.Negative) + dest.Flags = src.Flags - dest.Exemplars = CopyOrigExemplarSlice(dest.Exemplars, src.Exemplars) - if srcMin, ok := src.Min_.(*otlpmetrics.ExponentialHistogramDataPoint_Min); ok { - destMin, ok := dest.Min_.(*otlpmetrics.ExponentialHistogramDataPoint_Min) - if !ok { - destMin = &otlpmetrics.ExponentialHistogramDataPoint_Min{} - dest.Min_ = destMin + + 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) } - destMin.Min = srcMin.Min - } else { + ov.Min = t.Min + dest.Min_ = ov + default: dest.Min_ = nil } - if srcMax, ok := src.Max_.(*otlpmetrics.ExponentialHistogramDataPoint_Max); ok { - destMax, ok := dest.Max_.(*otlpmetrics.ExponentialHistogramDataPoint_Max) - if !ok { - destMax = &otlpmetrics.ExponentialHistogramDataPoint_Max{} - dest.Max_ = destMax + + 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) } - destMax.Max = srcMax.Max - } else { + ov.Max = t.Max + dest.Max_ = ov + default: dest.Max_ = nil } + dest.ZeroThreshold = src.ZeroThreshold + + return dest } -func GenTestOrigExponentialHistogramDataPoint() *otlpmetrics.ExponentialHistogramDataPoint { - orig := NewOrigExponentialHistogramDataPoint() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.StartTimeUnixNano = 1234567890 - orig.TimeUnixNano = 1234567890 - orig.Count = uint64(13) - orig.Sum_ = &otlpmetrics.ExponentialHistogramDataPoint_Sum{Sum: float64(3.1415926)} - orig.Scale = int32(13) - orig.ZeroCount = uint64(13) - orig.Positive = *GenTestOrigExponentialHistogramDataPoint_Buckets() - orig.Negative = *GenTestOrigExponentialHistogramDataPoint_Buckets() - orig.Flags = 1 - orig.Exemplars = GenerateOrigTestExemplarSlice() - orig.Min_ = &otlpmetrics.ExponentialHistogramDataPoint_Min{Min: float64(3.1415926)} - orig.Max_ = &otlpmetrics.ExponentialHistogramDataPoint_Max{Max: float64(3.1415926)} - orig.ZeroThreshold = float64(3.1415926) - return orig +func CopyExponentialHistogramDataPointSlice(dest, src []ExponentialHistogramDataPoint) []ExponentialHistogramDataPoint { + var newDest []ExponentialHistogramDataPoint + if cap(dest) < len(src) { + newDest = make([]ExponentialHistogramDataPoint, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExponentialHistogramDataPoint(&dest[i], false) + } + } + for i := range src { + CopyExponentialHistogramDataPoint(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint, dest *json.Stream) { +func CopyExponentialHistogramDataPointPtrSlice(dest, src []*ExponentialHistogramDataPoint) []*ExponentialHistogramDataPoint { + var newDest []*ExponentialHistogramDataPoint + if cap(dest) < len(src) { + newDest = make([]*ExponentialHistogramDataPoint, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExponentialHistogramDataPoint() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExponentialHistogramDataPoint(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExponentialHistogramDataPoint() + } + } + for i := range src { + CopyExponentialHistogramDataPoint(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExponentialHistogramDataPoint) Reset() { + *orig = ExponentialHistogramDataPoint{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExponentialHistogramDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -191,7 +329,7 @@ func MarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialH dest.WriteObjectField("count") dest.WriteUint64(orig.Count) } - if orig, ok := orig.Sum_.(*otlpmetrics.ExponentialHistogramDataPoint_Sum); ok { + if orig, ok := orig.Sum_.(*ExponentialHistogramDataPoint_Sum); ok { dest.WriteObjectField("sum") dest.WriteFloat64(orig.Sum) } @@ -204,9 +342,9 @@ func MarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialH dest.WriteUint64(orig.ZeroCount) } dest.WriteObjectField("positive") - MarshalJSONOrigExponentialHistogramDataPoint_Buckets(&orig.Positive, dest) + orig.Positive.MarshalJSON(dest) dest.WriteObjectField("negative") - MarshalJSONOrigExponentialHistogramDataPoint_Buckets(&orig.Negative, dest) + orig.Negative.MarshalJSON(dest) if orig.Flags != uint32(0) { dest.WriteObjectField("flags") dest.WriteUint32(orig.Flags) @@ -214,18 +352,18 @@ func MarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialH if len(orig.Exemplars) > 0 { dest.WriteObjectField("exemplars") dest.WriteArrayStart() - MarshalJSONOrigExemplar(&orig.Exemplars[0], dest) + orig.Exemplars[0].MarshalJSON(dest) for i := 1; i < len(orig.Exemplars); i++ { dest.WriteMore() - MarshalJSONOrigExemplar(&orig.Exemplars[i], dest) + orig.Exemplars[i].MarshalJSON(dest) } dest.WriteArrayEnd() } - if orig, ok := orig.Min_.(*otlpmetrics.ExponentialHistogramDataPoint_Min); ok { + if orig, ok := orig.Min_.(*ExponentialHistogramDataPoint_Min); ok { dest.WriteObjectField("min") dest.WriteFloat64(orig.Min) } - if orig, ok := orig.Max_.(*otlpmetrics.ExponentialHistogramDataPoint_Max); ok { + if orig, ok := orig.Max_.(*ExponentialHistogramDataPoint_Max); ok { dest.WriteObjectField("max") dest.WriteFloat64(orig.Max) } @@ -236,14 +374,14 @@ func MarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialH dest.WriteObjectEnd() } -// UnmarshalJSONOrigExponentialHistogramDataPoint unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExponentialHistogramDataPoint) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "startTimeUnixNano", "start_time_unix_nano": @@ -254,11 +392,11 @@ func UnmarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponentia orig.Count = iter.ReadUint64() case "sum": { - var ov *otlpmetrics.ExponentialHistogramDataPoint_Sum + var ov *ExponentialHistogramDataPoint_Sum if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.ExponentialHistogramDataPoint_Sum{} + ov = &ExponentialHistogramDataPoint_Sum{} } else { - ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Sum) + ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*ExponentialHistogramDataPoint_Sum) } ov.Sum = iter.ReadFloat64() orig.Sum_ = ov @@ -269,24 +407,26 @@ func UnmarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponentia case "zeroCount", "zero_count": orig.ZeroCount = iter.ReadUint64() case "positive": - UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(&orig.Positive, iter) + + orig.Positive.UnmarshalJSON(iter) case "negative": - UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(&orig.Negative, iter) + + orig.Negative.UnmarshalJSON(iter) case "flags": orig.Flags = iter.ReadUint32() case "exemplars": for iter.ReadArray() { - orig.Exemplars = append(orig.Exemplars, otlpmetrics.Exemplar{}) - UnmarshalJSONOrigExemplar(&orig.Exemplars[len(orig.Exemplars)-1], iter) + orig.Exemplars = append(orig.Exemplars, Exemplar{}) + orig.Exemplars[len(orig.Exemplars)-1].UnmarshalJSON(iter) } case "min": { - var ov *otlpmetrics.ExponentialHistogramDataPoint_Min + var ov *ExponentialHistogramDataPoint_Min if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.ExponentialHistogramDataPoint_Min{} + ov = &ExponentialHistogramDataPoint_Min{} } else { - ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Min) + ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*ExponentialHistogramDataPoint_Min) } ov.Min = iter.ReadFloat64() orig.Min_ = ov @@ -294,11 +434,11 @@ func UnmarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponentia case "max": { - var ov *otlpmetrics.ExponentialHistogramDataPoint_Max + var ov *ExponentialHistogramDataPoint_Max if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.ExponentialHistogramDataPoint_Max{} + ov = &ExponentialHistogramDataPoint_Max{} } else { - ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Max) + ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*ExponentialHistogramDataPoint_Max) } ov.Max = iter.ReadFloat64() orig.Max_ = ov @@ -312,12 +452,12 @@ func UnmarshalJSONOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponentia } } -func SizeProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint) int { +func (orig *ExponentialHistogramDataPoint) SizeProto() int { var n int var l int _ = l for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.StartTimeUnixNano != 0 { @@ -329,7 +469,7 @@ func SizeProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHis if orig.Count != 0 { n += 9 } - if orig, ok := orig.Sum_.(*otlpmetrics.ExponentialHistogramDataPoint_Sum); ok { + if orig, ok := orig.Sum_.(*ExponentialHistogramDataPoint_Sum); ok { _ = orig n += 9 } @@ -339,22 +479,22 @@ func SizeProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHis if orig.ZeroCount != 0 { n += 9 } - l = SizeProtoOrigExponentialHistogramDataPoint_Buckets(&orig.Positive) + l = orig.Positive.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - l = SizeProtoOrigExponentialHistogramDataPoint_Buckets(&orig.Negative) + l = orig.Negative.SizeProto() n += 1 + proto.Sov(uint64(l)) + l if orig.Flags != 0 { n += 1 + proto.Sov(uint64(orig.Flags)) } for i := range orig.Exemplars { - l = SizeProtoOrigExemplar(&orig.Exemplars[i]) + l = orig.Exemplars[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } - if orig, ok := orig.Min_.(*otlpmetrics.ExponentialHistogramDataPoint_Min); ok { + if orig, ok := orig.Min_.(*ExponentialHistogramDataPoint_Min); ok { _ = orig n += 9 } - if orig, ok := orig.Max_.(*otlpmetrics.ExponentialHistogramDataPoint_Max); ok { + if orig, ok := orig.Max_.(*ExponentialHistogramDataPoint_Max); ok { _ = orig n += 9 } @@ -364,12 +504,12 @@ func SizeProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHis return n } -func MarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint, buf []byte) int { +func (orig *ExponentialHistogramDataPoint) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -393,7 +533,7 @@ func MarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponential pos-- buf[pos] = 0x21 } - if orig, ok := orig.Sum_.(*otlpmetrics.ExponentialHistogramDataPoint_Sum); ok { + if orig, ok := orig.Sum_.(*ExponentialHistogramDataPoint_Sum); ok { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Sum)) pos-- @@ -410,14 +550,13 @@ func MarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponential pos-- buf[pos] = 0x39 } - - l = MarshalProtoOrigExponentialHistogramDataPoint_Buckets(&orig.Positive, buf[:pos]) + l = orig.Positive.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x42 - l = MarshalProtoOrigExponentialHistogramDataPoint_Buckets(&orig.Negative, buf[:pos]) + l = orig.Negative.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -429,19 +568,19 @@ func MarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponential buf[pos] = 0x50 } for i := len(orig.Exemplars) - 1; i >= 0; i-- { - l = MarshalProtoOrigExemplar(&orig.Exemplars[i], buf[:pos]) + l = orig.Exemplars[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x5a } - if orig, ok := orig.Min_.(*otlpmetrics.ExponentialHistogramDataPoint_Min); ok { + if orig, ok := orig.Min_.(*ExponentialHistogramDataPoint_Min); ok { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Min)) pos-- buf[pos] = 0x61 } - if orig, ok := orig.Max_.(*otlpmetrics.ExponentialHistogramDataPoint_Max); ok { + if orig, ok := orig.Max_.(*ExponentialHistogramDataPoint_Max); ok { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Max)) pos-- @@ -456,7 +595,7 @@ func MarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponential return len(buf) - pos } -func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint, buf []byte) error { +func (orig *ExponentialHistogramDataPoint) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -481,8 +620,8 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -532,11 +671,11 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti if err != nil { return err } - var ov *otlpmetrics.ExponentialHistogramDataPoint_Sum + var ov *ExponentialHistogramDataPoint_Sum if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.ExponentialHistogramDataPoint_Sum{} + ov = &ExponentialHistogramDataPoint_Sum{} } else { - ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Sum) + ov = ProtoPoolExponentialHistogramDataPoint_Sum.Get().(*ExponentialHistogramDataPoint_Sum) } ov.Sum = math.Float64frombits(num) orig.Sum_ = ov @@ -576,7 +715,7 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti } startPos := pos - length - err = UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(&orig.Positive, buf[startPos:pos]) + err = orig.Positive.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -592,7 +731,7 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti } startPos := pos - length - err = UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(&orig.Negative, buf[startPos:pos]) + err = orig.Negative.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -619,8 +758,8 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti return err } startPos := pos - length - orig.Exemplars = append(orig.Exemplars, otlpmetrics.Exemplar{}) - err = UnmarshalProtoOrigExemplar(&orig.Exemplars[len(orig.Exemplars)-1], buf[startPos:pos]) + orig.Exemplars = append(orig.Exemplars, Exemplar{}) + err = orig.Exemplars[len(orig.Exemplars)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -634,11 +773,11 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti if err != nil { return err } - var ov *otlpmetrics.ExponentialHistogramDataPoint_Min + var ov *ExponentialHistogramDataPoint_Min if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.ExponentialHistogramDataPoint_Min{} + ov = &ExponentialHistogramDataPoint_Min{} } else { - ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Min) + ov = ProtoPoolExponentialHistogramDataPoint_Min.Get().(*ExponentialHistogramDataPoint_Min) } ov.Min = math.Float64frombits(num) orig.Min_ = ov @@ -652,11 +791,11 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti if err != nil { return err } - var ov *otlpmetrics.ExponentialHistogramDataPoint_Max + var ov *ExponentialHistogramDataPoint_Max if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.ExponentialHistogramDataPoint_Max{} + ov = &ExponentialHistogramDataPoint_Max{} } else { - ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Max) + ov = ProtoPoolExponentialHistogramDataPoint_Max.Get().(*ExponentialHistogramDataPoint_Max) } ov.Max = math.Float64frombits(num) orig.Max_ = ov @@ -681,3 +820,39 @@ func UnmarshalProtoOrigExponentialHistogramDataPoint(orig *otlpmetrics.Exponenti } return nil } + +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.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.ZeroThreshold = float64(3.1415926) + return orig +} + +func GenTestExponentialHistogramDataPointPtrSlice() []*ExponentialHistogramDataPoint { + orig := make([]*ExponentialHistogramDataPoint, 5) + orig[0] = NewExponentialHistogramDataPoint() + orig[1] = GenTestExponentialHistogramDataPoint() + orig[2] = NewExponentialHistogramDataPoint() + orig[3] = GenTestExponentialHistogramDataPoint() + orig[4] = NewExponentialHistogramDataPoint() + return orig +} + +func GenTestExponentialHistogramDataPointSlice() []ExponentialHistogramDataPoint { + orig := make([]ExponentialHistogramDataPoint, 5) + orig[1] = *GenTestExponentialHistogramDataPoint() + orig[3] = *GenTestExponentialHistogramDataPoint() + return orig +} diff --git a/pdata/internal/generated_proto_exponentialhistogramdatapoint_test.go b/pdata/internal/generated_proto_exponentialhistogramdatapoint_test.go new file mode 100644 index 00000000000..b9e6436ff10 --- /dev/null +++ b/pdata/internal/generated_proto_exponentialhistogramdatapoint_test.go @@ -0,0 +1,241 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExponentialHistogramDataPoint(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExponentialHistogramDataPoint() + CopyExponentialHistogramDataPoint(dest, src) + assert.Equal(t, src, dest) + CopyExponentialHistogramDataPoint(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExponentialHistogramDataPointSlice(t *testing.T) { + src := []ExponentialHistogramDataPoint{} + dest := []ExponentialHistogramDataPoint{} + // Test CopyTo empty + dest = CopyExponentialHistogramDataPointSlice(dest, src) + assert.Equal(t, []ExponentialHistogramDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestExponentialHistogramDataPointSlice() + dest = CopyExponentialHistogramDataPointSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExponentialHistogramDataPointSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExponentialHistogramDataPointSlice(dest, []ExponentialHistogramDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExponentialHistogramDataPointSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointSlice(), dest) +} + +func TestCopyExponentialHistogramDataPointPtrSlice(t *testing.T) { + src := []*ExponentialHistogramDataPoint{} + dest := []*ExponentialHistogramDataPoint{} + // Test CopyTo empty + dest = CopyExponentialHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, []*ExponentialHistogramDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestExponentialHistogramDataPointPtrSlice() + dest = CopyExponentialHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExponentialHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExponentialHistogramDataPointPtrSlice(dest, []*ExponentialHistogramDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExponentialHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExponentialHistogramDataPointUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExponentialHistogramDataPoint() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExponentialHistogramDataPoint(), dest) +} + +func TestMarshalAndUnmarshalJSONExponentialHistogramDataPoint(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExponentialHistogramDataPoint() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExponentialHistogramDataPoint(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramDataPointFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExponentialHistogramDataPoint() { + t.Run(name, func(t *testing.T) { + dest := NewExponentialHistogramDataPoint() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramDataPointUnknown(t *testing.T) { + dest := NewExponentialHistogramDataPoint() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExponentialHistogramDataPoint(), dest) +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramDataPoint(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExponentialHistogramDataPoint() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExponentialHistogramDataPoint(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExponentialHistogramDataPoint(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpmetrics.ExponentialHistogramDataPoint{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExponentialHistogramDataPoint() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExponentialHistogramDataPoint() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Attributes/wrong_wire_type": {0xc}, + "Attributes/missing_value": {0xa}, + "StartTimeUnixNano/wrong_wire_type": {0x14}, + "StartTimeUnixNano/missing_value": {0x11}, + "TimeUnixNano/wrong_wire_type": {0x1c}, + "TimeUnixNano/missing_value": {0x19}, + "Count/wrong_wire_type": {0x24}, + "Count/missing_value": {0x21}, + "Sum/wrong_wire_type": {0x2c}, + "Sum/missing_value": {0x29}, + "Scale/wrong_wire_type": {0x34}, + "Scale/missing_value": {0x30}, + "ZeroCount/wrong_wire_type": {0x3c}, + "ZeroCount/missing_value": {0x39}, + "Positive/wrong_wire_type": {0x44}, + "Positive/missing_value": {0x42}, + "Negative/wrong_wire_type": {0x4c}, + "Negative/missing_value": {0x4a}, + "Flags/wrong_wire_type": {0x54}, + "Flags/missing_value": {0x50}, + "Exemplars/wrong_wire_type": {0x5c}, + "Exemplars/missing_value": {0x5a}, + "Min/wrong_wire_type": {0x64}, + "Min/missing_value": {0x61}, + "Max/wrong_wire_type": {0x6c}, + "Max/missing_value": {0x69}, + "ZeroThreshold/wrong_wire_type": {0x74}, + "ZeroThreshold/missing_value": {0x71}, + } +} + +func genTestEncodingValuesExponentialHistogramDataPoint() map[string]*ExponentialHistogramDataPoint { + return map[string]*ExponentialHistogramDataPoint{ + "empty": NewExponentialHistogramDataPoint(), + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, + "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, + "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, + "Count/test": {Count: uint64(13)}, "Sum/default": {Sum_: &ExponentialHistogramDataPoint_Sum{Sum: float64(0)}}, + "Sum/test": {Sum_: &ExponentialHistogramDataPoint_Sum{Sum: float64(3.1415926)}}, + "Scale/test": {Scale: int32(13)}, + "ZeroCount/test": {ZeroCount: uint64(13)}, + "Positive/test": {Positive: *GenTestExponentialHistogramDataPointBuckets()}, + "Negative/test": {Negative: *GenTestExponentialHistogramDataPointBuckets()}, + "Flags/test": {Flags: uint32(13)}, + "Exemplars/test": {Exemplars: []Exemplar{{}, *GenTestExemplar()}}, "Min/default": {Min_: &ExponentialHistogramDataPoint_Min{Min: float64(0)}}, + "Min/test": {Min_: &ExponentialHistogramDataPoint_Min{Min: float64(3.1415926)}}, "Max/default": {Max_: &ExponentialHistogramDataPoint_Max{Max: float64(0)}}, + "Max/test": {Max_: &ExponentialHistogramDataPoint_Max{Max: float64(3.1415926)}}, + "ZeroThreshold/test": {ZeroThreshold: float64(3.1415926)}, + } +} diff --git a/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go b/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go new file mode 100644 index 00000000000..459dfe0c38b --- /dev/null +++ b/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets.go @@ -0,0 +1,290 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExponentialHistogramDataPointBuckets are a set of bucket counts, encoded in a contiguous array of counts. +type ExponentialHistogramDataPointBuckets struct { + Offset int32 + BucketCounts []uint64 +} + +var ( + protoPoolExponentialHistogramDataPointBuckets = sync.Pool{ + New: func() any { + return &ExponentialHistogramDataPointBuckets{} + }, + } +) + +func NewExponentialHistogramDataPointBuckets() *ExponentialHistogramDataPointBuckets { + if !UseProtoPooling.IsEnabled() { + return &ExponentialHistogramDataPointBuckets{} + } + return protoPoolExponentialHistogramDataPointBuckets.Get().(*ExponentialHistogramDataPointBuckets) +} + +func DeleteExponentialHistogramDataPointBuckets(orig *ExponentialHistogramDataPointBuckets, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolExponentialHistogramDataPointBuckets.Put(orig) + } +} + +func CopyExponentialHistogramDataPointBuckets(dest, src *ExponentialHistogramDataPointBuckets) *ExponentialHistogramDataPointBuckets { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExponentialHistogramDataPointBuckets() + } + dest.Offset = src.Offset + + dest.BucketCounts = append(dest.BucketCounts[:0], src.BucketCounts...) + + return dest +} + +func CopyExponentialHistogramDataPointBucketsSlice(dest, src []ExponentialHistogramDataPointBuckets) []ExponentialHistogramDataPointBuckets { + var newDest []ExponentialHistogramDataPointBuckets + if cap(dest) < len(src) { + newDest = make([]ExponentialHistogramDataPointBuckets, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExponentialHistogramDataPointBuckets(&dest[i], false) + } + } + for i := range src { + CopyExponentialHistogramDataPointBuckets(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExponentialHistogramDataPointBucketsPtrSlice(dest, src []*ExponentialHistogramDataPointBuckets) []*ExponentialHistogramDataPointBuckets { + var newDest []*ExponentialHistogramDataPointBuckets + if cap(dest) < len(src) { + newDest = make([]*ExponentialHistogramDataPointBuckets, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExponentialHistogramDataPointBuckets() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExponentialHistogramDataPointBuckets(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExponentialHistogramDataPointBuckets() + } + } + for i := range src { + CopyExponentialHistogramDataPointBuckets(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExponentialHistogramDataPointBuckets) Reset() { + *orig = ExponentialHistogramDataPointBuckets{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExponentialHistogramDataPointBuckets) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Offset != int32(0) { + dest.WriteObjectField("offset") + dest.WriteInt32(orig.Offset) + } + if len(orig.BucketCounts) > 0 { + dest.WriteObjectField("bucketCounts") + dest.WriteArrayStart() + dest.WriteUint64(orig.BucketCounts[0]) + for i := 1; i < len(orig.BucketCounts); i++ { + dest.WriteMore() + dest.WriteUint64(orig.BucketCounts[i]) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExponentialHistogramDataPointBuckets) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "offset": + orig.Offset = iter.ReadInt32() + case "bucketCounts", "bucket_counts": + for iter.ReadArray() { + orig.BucketCounts = append(orig.BucketCounts, iter.ReadUint64()) + } + + default: + iter.Skip() + } + } +} + +func (orig *ExponentialHistogramDataPointBuckets) SizeProto() int { + var n int + var l int + _ = l + if orig.Offset != 0 { + n += 1 + proto.Soz(uint64(orig.Offset)) + } + if len(orig.BucketCounts) > 0 { + l = 0 + for _, e := range orig.BucketCounts { + l += proto.Sov(uint64(e)) + } + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExponentialHistogramDataPointBuckets) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.Offset != 0 { + pos = proto.EncodeVarint(buf, pos, uint64((uint32(orig.Offset)<<1)^uint32(orig.Offset>>31))) + pos-- + buf[pos] = 0x8 + } + l = len(orig.BucketCounts) + if l > 0 { + endPos := pos + for i := l - 1; i >= 0; i-- { + pos = proto.EncodeVarint(buf, pos, uint64(orig.BucketCounts[i])) + } + pos = proto.EncodeVarint(buf, pos, uint64(endPos-pos)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *ExponentialHistogramDataPointBuckets) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.Offset = int32(uint32(num>>1) ^ uint32(int32((num&1)<<31)>>31)) + case 2: + switch wireType { + case proto.WireTypeLen: + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var num uint64 + for startPos < pos { + num, startPos, err = proto.ConsumeVarint(buf[:pos], startPos) + if err != nil { + return err + } + orig.BucketCounts = append(orig.BucketCounts, uint64(num)) + } + if startPos != pos { + return fmt.Errorf("proto: invalid field len = %d for field BucketCounts", pos-startPos) + } + case proto.WireTypeVarint: + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + orig.BucketCounts = append(orig.BucketCounts, uint64(num)) + default: + return fmt.Errorf("proto: wrong wireType = %d for field BucketCounts", wireType) + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExponentialHistogramDataPointBuckets() *ExponentialHistogramDataPointBuckets { + orig := NewExponentialHistogramDataPointBuckets() + orig.Offset = int32(13) + orig.BucketCounts = []uint64{uint64(0), uint64(13)} + return orig +} + +func GenTestExponentialHistogramDataPointBucketsPtrSlice() []*ExponentialHistogramDataPointBuckets { + orig := make([]*ExponentialHistogramDataPointBuckets, 5) + orig[0] = NewExponentialHistogramDataPointBuckets() + orig[1] = GenTestExponentialHistogramDataPointBuckets() + orig[2] = NewExponentialHistogramDataPointBuckets() + orig[3] = GenTestExponentialHistogramDataPointBuckets() + orig[4] = NewExponentialHistogramDataPointBuckets() + return orig +} + +func GenTestExponentialHistogramDataPointBucketsSlice() []ExponentialHistogramDataPointBuckets { + orig := make([]ExponentialHistogramDataPointBuckets, 5) + orig[1] = *GenTestExponentialHistogramDataPointBuckets() + orig[3] = *GenTestExponentialHistogramDataPointBuckets() + return orig +} diff --git a/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets_test.go b/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets_test.go new file mode 100644 index 00000000000..dd89b4812d0 --- /dev/null +++ b/pdata/internal/generated_proto_exponentialhistogramdatapointbuckets_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExponentialHistogramDataPointBuckets(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPointBuckets() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExponentialHistogramDataPointBuckets() + CopyExponentialHistogramDataPointBuckets(dest, src) + assert.Equal(t, src, dest) + CopyExponentialHistogramDataPointBuckets(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExponentialHistogramDataPointBucketsSlice(t *testing.T) { + src := []ExponentialHistogramDataPointBuckets{} + dest := []ExponentialHistogramDataPointBuckets{} + // Test CopyTo empty + dest = CopyExponentialHistogramDataPointBucketsSlice(dest, src) + assert.Equal(t, []ExponentialHistogramDataPointBuckets{}, dest) + + // Test CopyTo larger slice + src = GenTestExponentialHistogramDataPointBucketsSlice() + dest = CopyExponentialHistogramDataPointBucketsSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointBucketsSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExponentialHistogramDataPointBucketsSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointBucketsSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExponentialHistogramDataPointBucketsSlice(dest, []ExponentialHistogramDataPointBuckets{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExponentialHistogramDataPointBucketsSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointBucketsSlice(), dest) +} + +func TestCopyExponentialHistogramDataPointBucketsPtrSlice(t *testing.T) { + src := []*ExponentialHistogramDataPointBuckets{} + dest := []*ExponentialHistogramDataPointBuckets{} + // Test CopyTo empty + dest = CopyExponentialHistogramDataPointBucketsPtrSlice(dest, src) + assert.Equal(t, []*ExponentialHistogramDataPointBuckets{}, dest) + + // Test CopyTo larger slice + src = GenTestExponentialHistogramDataPointBucketsPtrSlice() + dest = CopyExponentialHistogramDataPointBucketsPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointBucketsPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExponentialHistogramDataPointBucketsPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointBucketsPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExponentialHistogramDataPointBucketsPtrSlice(dest, []*ExponentialHistogramDataPointBuckets{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExponentialHistogramDataPointBucketsPtrSlice(dest, src) + assert.Equal(t, GenTestExponentialHistogramDataPointBucketsPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExponentialHistogramDataPointBucketsUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExponentialHistogramDataPointBuckets() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExponentialHistogramDataPointBuckets(), dest) +} + +func TestMarshalAndUnmarshalJSONExponentialHistogramDataPointBuckets(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPointBuckets() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExponentialHistogramDataPointBuckets() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExponentialHistogramDataPointBuckets(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramDataPointBucketsFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExponentialHistogramDataPointBuckets() { + t.Run(name, func(t *testing.T) { + dest := NewExponentialHistogramDataPointBuckets() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramDataPointBucketsUnknown(t *testing.T) { + dest := NewExponentialHistogramDataPointBuckets() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExponentialHistogramDataPointBuckets(), dest) +} + +func TestMarshalAndUnmarshalProtoExponentialHistogramDataPointBuckets(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPointBuckets() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExponentialHistogramDataPointBuckets() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExponentialHistogramDataPointBuckets(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExponentialHistogramDataPointBuckets(t *testing.T) { + for name, src := range genTestEncodingValuesExponentialHistogramDataPointBuckets() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpmetrics.ExponentialHistogramDataPoint_Buckets{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExponentialHistogramDataPointBuckets() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExponentialHistogramDataPointBuckets() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Offset/wrong_wire_type": {0xc}, + "Offset/missing_value": {0x8}, + "BucketCounts/wrong_wire_type": {0x14}, + "BucketCounts/missing_value": {0x12}, + } +} + +func genTestEncodingValuesExponentialHistogramDataPointBuckets() map[string]*ExponentialHistogramDataPointBuckets { + return map[string]*ExponentialHistogramDataPointBuckets{ + "empty": NewExponentialHistogramDataPointBuckets(), + "Offset/test": {Offset: int32(13)}, + "BucketCounts/test": {BucketCounts: []uint64{uint64(0), uint64(13)}}, + } +} diff --git a/pdata/internal/generated_proto_exportlogspartialsuccess.go b/pdata/internal/generated_proto_exportlogspartialsuccess.go new file mode 100644 index 00000000000..f93525d3455 --- /dev/null +++ b/pdata/internal/generated_proto_exportlogspartialsuccess.go @@ -0,0 +1,258 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportPartialSuccess represents the details of a partially successful export request. +type ExportLogsPartialSuccess struct { + RejectedLogRecords int64 + ErrorMessage string +} + +var ( + protoPoolExportLogsPartialSuccess = sync.Pool{ + New: func() any { + return &ExportLogsPartialSuccess{} + }, + } +) + +func NewExportLogsPartialSuccess() *ExportLogsPartialSuccess { + if !UseProtoPooling.IsEnabled() { + return &ExportLogsPartialSuccess{} + } + return protoPoolExportLogsPartialSuccess.Get().(*ExportLogsPartialSuccess) +} + +func DeleteExportLogsPartialSuccess(orig *ExportLogsPartialSuccess, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolExportLogsPartialSuccess.Put(orig) + } +} + +func CopyExportLogsPartialSuccess(dest, src *ExportLogsPartialSuccess) *ExportLogsPartialSuccess { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportLogsPartialSuccess() + } + dest.RejectedLogRecords = src.RejectedLogRecords + + dest.ErrorMessage = src.ErrorMessage + + return dest +} + +func CopyExportLogsPartialSuccessSlice(dest, src []ExportLogsPartialSuccess) []ExportLogsPartialSuccess { + var newDest []ExportLogsPartialSuccess + if cap(dest) < len(src) { + newDest = make([]ExportLogsPartialSuccess, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportLogsPartialSuccess(&dest[i], false) + } + } + for i := range src { + CopyExportLogsPartialSuccess(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportLogsPartialSuccessPtrSlice(dest, src []*ExportLogsPartialSuccess) []*ExportLogsPartialSuccess { + var newDest []*ExportLogsPartialSuccess + if cap(dest) < len(src) { + newDest = make([]*ExportLogsPartialSuccess, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportLogsPartialSuccess() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportLogsPartialSuccess(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportLogsPartialSuccess() + } + } + for i := range src { + CopyExportLogsPartialSuccess(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportLogsPartialSuccess) Reset() { + *orig = ExportLogsPartialSuccess{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportLogsPartialSuccess) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RejectedLogRecords != int64(0) { + dest.WriteObjectField("rejectedLogRecords") + dest.WriteInt64(orig.RejectedLogRecords) + } + if orig.ErrorMessage != "" { + dest.WriteObjectField("errorMessage") + dest.WriteString(orig.ErrorMessage) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportLogsPartialSuccess) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "rejectedLogRecords", "rejected_log_records": + orig.RejectedLogRecords = iter.ReadInt64() + case "errorMessage", "error_message": + orig.ErrorMessage = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ExportLogsPartialSuccess) SizeProto() int { + var n int + var l int + _ = l + if orig.RejectedLogRecords != 0 { + n += 1 + proto.Sov(uint64(orig.RejectedLogRecords)) + } + l = len(orig.ErrorMessage) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportLogsPartialSuccess) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RejectedLogRecords != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedLogRecords)) + pos-- + buf[pos] = 0x8 + } + l = len(orig.ErrorMessage) + if l > 0 { + pos -= l + copy(buf[pos:], orig.ErrorMessage) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *ExportLogsPartialSuccess) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field RejectedLogRecords", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.RejectedLogRecords = int64(num) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ErrorMessage = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportLogsPartialSuccess() *ExportLogsPartialSuccess { + orig := NewExportLogsPartialSuccess() + orig.RejectedLogRecords = int64(13) + orig.ErrorMessage = "test_errormessage" + return orig +} + +func GenTestExportLogsPartialSuccessPtrSlice() []*ExportLogsPartialSuccess { + orig := make([]*ExportLogsPartialSuccess, 5) + orig[0] = NewExportLogsPartialSuccess() + orig[1] = GenTestExportLogsPartialSuccess() + orig[2] = NewExportLogsPartialSuccess() + orig[3] = GenTestExportLogsPartialSuccess() + orig[4] = NewExportLogsPartialSuccess() + return orig +} + +func GenTestExportLogsPartialSuccessSlice() []ExportLogsPartialSuccess { + orig := make([]ExportLogsPartialSuccess, 5) + orig[1] = *GenTestExportLogsPartialSuccess() + orig[3] = *GenTestExportLogsPartialSuccess() + return orig +} diff --git a/pdata/internal/generated_wrapper_exportlogspartialsuccess_test.go b/pdata/internal/generated_proto_exportlogspartialsuccess_test.go similarity index 51% rename from pdata/internal/generated_wrapper_exportlogspartialsuccess_test.go rename to pdata/internal/generated_proto_exportlogspartialsuccess_test.go index 6b991eb0cac..f98e8494ab9 100644 --- a/pdata/internal/generated_wrapper_exportlogspartialsuccess_test.go +++ b/pdata/internal/generated_proto_exportlogspartialsuccess_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigExportLogsPartialSuccess(t *testing.T) { +func TestCopyExportLogsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportLogsPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigExportLogsPartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigExportLogsPartialSuccess() - CopyOrigExportLogsPartialSuccess(dest, src) + dest := NewExportLogsPartialSuccess() + CopyExportLogsPartialSuccess(dest, src) assert.Equal(t, src, dest) - CopyOrigExportLogsPartialSuccess(dest, dest) + CopyExportLogsPartialSuccess(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigExportLogsPartialSuccessUnknown(t *testing.T) { +func TestCopyExportLogsPartialSuccessSlice(t *testing.T) { + src := []ExportLogsPartialSuccess{} + dest := []ExportLogsPartialSuccess{} + // Test CopyTo empty + dest = CopyExportLogsPartialSuccessSlice(dest, src) + assert.Equal(t, []ExportLogsPartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportLogsPartialSuccessSlice() + dest = CopyExportLogsPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportLogsPartialSuccessSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportLogsPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportLogsPartialSuccessSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportLogsPartialSuccessSlice(dest, []ExportLogsPartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportLogsPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportLogsPartialSuccessSlice(), dest) +} + +func TestCopyExportLogsPartialSuccessPtrSlice(t *testing.T) { + src := []*ExportLogsPartialSuccess{} + dest := []*ExportLogsPartialSuccess{} + // Test CopyTo empty + dest = CopyExportLogsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, []*ExportLogsPartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportLogsPartialSuccessPtrSlice() + dest = CopyExportLogsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsPartialSuccessPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportLogsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsPartialSuccessPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportLogsPartialSuccessPtrSlice(dest, []*ExportLogsPartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportLogsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsPartialSuccessPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportLogsPartialSuccessUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigExportLogsPartialSuccess() - UnmarshalJSONOrigExportLogsPartialSuccess(dest, iter) + dest := NewExportLogsPartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportLogsPartialSuccess(), dest) + assert.Equal(t, NewExportLogsPartialSuccess(), dest) } -func TestMarshalAndUnmarshalJSONOrigExportLogsPartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalJSONExportLogsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportLogsPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigExportLogsPartialSuccess(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigExportLogsPartialSuccess(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigExportLogsPartialSuccess() - UnmarshalJSONOrigExportLogsPartialSuccess(dest, iter) + dest := NewExportLogsPartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigExportLogsPartialSuccess(dest, true) + DeleteExportLogsPartialSuccess(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigExportLogsPartialSuccessFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportLogsPartialSuccessFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesExportLogsPartialSuccess() { t.Run(name, func(t *testing.T) { - dest := NewOrigExportLogsPartialSuccess() - require.Error(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, buf)) + dest := NewExportLogsPartialSuccess() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigExportLogsPartialSuccessUnknown(t *testing.T) { - dest := NewOrigExportLogsPartialSuccess() +func TestMarshalAndUnmarshalProtoExportLogsPartialSuccessUnknown(t *testing.T) { + dest := NewExportLogsPartialSuccess() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportLogsPartialSuccess(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportLogsPartialSuccess(), dest) } -func TestMarshalAndUnmarshalProtoOrigExportLogsPartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportLogsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportLogsPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigExportLogsPartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigExportLogsPartialSuccess(src)) - gotSize := MarshalProtoOrigExportLogsPartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigExportLogsPartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, buf)) + dest := NewExportLogsPartialSuccess() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigExportLogsPartialSuccess(dest, true) + DeleteExportLogsPartialSuccess(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigExportLogsPartialSuccess(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufExportLogsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportLogsPartialSuccess() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportLogsPartialSuccess(src)) - gotSize := MarshalProtoOrigExportLogsPartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcollectorlogs.ExportLogsPartialSuccess{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufExportLogsPartialSuccess(t *testing. goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigExportLogsPartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportLogsPartialSuccess(dest, goBuf)) + dest := NewExportLogsPartialSuccess() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,9 +196,9 @@ func genTestFailingUnmarshalProtoValuesExportLogsPartialSuccess() map[string][]b } } -func genTestEncodingValuesExportLogsPartialSuccess() map[string]*otlpcollectorlogs.ExportLogsPartialSuccess { - return map[string]*otlpcollectorlogs.ExportLogsPartialSuccess{ - "empty": NewOrigExportLogsPartialSuccess(), +func genTestEncodingValuesExportLogsPartialSuccess() map[string]*ExportLogsPartialSuccess { + return map[string]*ExportLogsPartialSuccess{ + "empty": NewExportLogsPartialSuccess(), "RejectedLogRecords/test": {RejectedLogRecords: int64(13)}, "ErrorMessage/test": {ErrorMessage: "test_errormessage"}, } diff --git a/pdata/internal/generated_proto_exportlogsservicerequest.go b/pdata/internal/generated_proto_exportlogsservicerequest.go new file mode 100644 index 00000000000..1c849ec22db --- /dev/null +++ b/pdata/internal/generated_proto_exportlogsservicerequest.go @@ -0,0 +1,246 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Logs is the top-level struct that is propagated through the logs pipeline. +// Use NewLogs to create new instance, zero-initialized instance is not valid for use. +type ExportLogsServiceRequest struct { + ResourceLogs []*ResourceLogs +} + +var ( + protoPoolExportLogsServiceRequest = sync.Pool{ + New: func() any { + return &ExportLogsServiceRequest{} + }, + } +) + +func NewExportLogsServiceRequest() *ExportLogsServiceRequest { + if !UseProtoPooling.IsEnabled() { + return &ExportLogsServiceRequest{} + } + return protoPoolExportLogsServiceRequest.Get().(*ExportLogsServiceRequest) +} + +func DeleteExportLogsServiceRequest(orig *ExportLogsServiceRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceLogs { + DeleteResourceLogs(orig.ResourceLogs[i], true) + } + + orig.Reset() + if nullable { + protoPoolExportLogsServiceRequest.Put(orig) + } +} + +func CopyExportLogsServiceRequest(dest, src *ExportLogsServiceRequest) *ExportLogsServiceRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportLogsServiceRequest() + } + dest.ResourceLogs = CopyResourceLogsPtrSlice(dest.ResourceLogs, src.ResourceLogs) + + return dest +} + +func CopyExportLogsServiceRequestSlice(dest, src []ExportLogsServiceRequest) []ExportLogsServiceRequest { + var newDest []ExportLogsServiceRequest + if cap(dest) < len(src) { + newDest = make([]ExportLogsServiceRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportLogsServiceRequest(&dest[i], false) + } + } + for i := range src { + CopyExportLogsServiceRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportLogsServiceRequestPtrSlice(dest, src []*ExportLogsServiceRequest) []*ExportLogsServiceRequest { + var newDest []*ExportLogsServiceRequest + if cap(dest) < len(src) { + newDest = make([]*ExportLogsServiceRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportLogsServiceRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportLogsServiceRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportLogsServiceRequest() + } + } + for i := range src { + CopyExportLogsServiceRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportLogsServiceRequest) Reset() { + *orig = ExportLogsServiceRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportLogsServiceRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceLogs) > 0 { + dest.WriteObjectField("resourceLogs") + dest.WriteArrayStart() + orig.ResourceLogs[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceLogs); i++ { + dest.WriteMore() + orig.ResourceLogs[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportLogsServiceRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceLogs", "resource_logs": + for iter.ReadArray() { + orig.ResourceLogs = append(orig.ResourceLogs, NewResourceLogs()) + orig.ResourceLogs[len(orig.ResourceLogs)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ExportLogsServiceRequest) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceLogs { + l = orig.ResourceLogs[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportLogsServiceRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceLogs) - 1; i >= 0; i-- { + l = orig.ResourceLogs[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *ExportLogsServiceRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceLogs = append(orig.ResourceLogs, NewResourceLogs()) + err = orig.ResourceLogs[len(orig.ResourceLogs)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportLogsServiceRequest() *ExportLogsServiceRequest { + orig := NewExportLogsServiceRequest() + orig.ResourceLogs = []*ResourceLogs{{}, GenTestResourceLogs()} + return orig +} + +func GenTestExportLogsServiceRequestPtrSlice() []*ExportLogsServiceRequest { + orig := make([]*ExportLogsServiceRequest, 5) + orig[0] = NewExportLogsServiceRequest() + orig[1] = GenTestExportLogsServiceRequest() + orig[2] = NewExportLogsServiceRequest() + orig[3] = GenTestExportLogsServiceRequest() + orig[4] = NewExportLogsServiceRequest() + return orig +} + +func GenTestExportLogsServiceRequestSlice() []ExportLogsServiceRequest { + orig := make([]ExportLogsServiceRequest, 5) + orig[1] = *GenTestExportLogsServiceRequest() + orig[3] = *GenTestExportLogsServiceRequest() + return orig +} diff --git a/pdata/internal/generated_proto_exportlogsservicerequest_test.go b/pdata/internal/generated_proto_exportlogsservicerequest_test.go new file mode 100644 index 00000000000..4ac445918f9 --- /dev/null +++ b/pdata/internal/generated_proto_exportlogsservicerequest_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectorlogs "go.opentelemetry.io/proto/slim/otlp/collector/logs/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportLogsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportLogsServiceRequest() + CopyExportLogsServiceRequest(dest, src) + assert.Equal(t, src, dest) + CopyExportLogsServiceRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportLogsServiceRequestSlice(t *testing.T) { + src := []ExportLogsServiceRequest{} + dest := []ExportLogsServiceRequest{} + // Test CopyTo empty + dest = CopyExportLogsServiceRequestSlice(dest, src) + assert.Equal(t, []ExportLogsServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportLogsServiceRequestSlice() + dest = CopyExportLogsServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportLogsServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportLogsServiceRequestSlice(dest, []ExportLogsServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportLogsServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceRequestSlice(), dest) +} + +func TestCopyExportLogsServiceRequestPtrSlice(t *testing.T) { + src := []*ExportLogsServiceRequest{} + dest := []*ExportLogsServiceRequest{} + // Test CopyTo empty + dest = CopyExportLogsServiceRequestPtrSlice(dest, src) + assert.Equal(t, []*ExportLogsServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportLogsServiceRequestPtrSlice() + dest = CopyExportLogsServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportLogsServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportLogsServiceRequestPtrSlice(dest, []*ExportLogsServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportLogsServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportLogsServiceRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportLogsServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportLogsServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONExportLogsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportLogsServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportLogsServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportLogsServiceRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportLogsServiceRequest() { + t.Run(name, func(t *testing.T) { + dest := NewExportLogsServiceRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportLogsServiceRequestUnknown(t *testing.T) { + dest := NewExportLogsServiceRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportLogsServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoExportLogsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportLogsServiceRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportLogsServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportLogsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectorlogs.ExportLogsServiceRequest{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportLogsServiceRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportLogsServiceRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceLogs/wrong_wire_type": {0xc}, + "ResourceLogs/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportLogsServiceRequest() map[string]*ExportLogsServiceRequest { + return map[string]*ExportLogsServiceRequest{ + "empty": NewExportLogsServiceRequest(), + "ResourceLogs/test": {ResourceLogs: []*ResourceLogs{{}, GenTestResourceLogs()}}, + } +} diff --git a/pdata/internal/generated_proto_exportlogsserviceresponse.go b/pdata/internal/generated_proto_exportlogsserviceresponse.go new file mode 100644 index 00000000000..7b78c73604d --- /dev/null +++ b/pdata/internal/generated_proto_exportlogsserviceresponse.go @@ -0,0 +1,229 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportResponse represents the response for gRPC/HTTP client/server. +type ExportLogsServiceResponse struct { + PartialSuccess ExportLogsPartialSuccess +} + +var ( + protoPoolExportLogsServiceResponse = sync.Pool{ + New: func() any { + return &ExportLogsServiceResponse{} + }, + } +) + +func NewExportLogsServiceResponse() *ExportLogsServiceResponse { + if !UseProtoPooling.IsEnabled() { + return &ExportLogsServiceResponse{} + } + return protoPoolExportLogsServiceResponse.Get().(*ExportLogsServiceResponse) +} + +func DeleteExportLogsServiceResponse(orig *ExportLogsServiceResponse, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteExportLogsPartialSuccess(&orig.PartialSuccess, false) + + orig.Reset() + if nullable { + protoPoolExportLogsServiceResponse.Put(orig) + } +} + +func CopyExportLogsServiceResponse(dest, src *ExportLogsServiceResponse) *ExportLogsServiceResponse { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportLogsServiceResponse() + } + CopyExportLogsPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) + + return dest +} + +func CopyExportLogsServiceResponseSlice(dest, src []ExportLogsServiceResponse) []ExportLogsServiceResponse { + var newDest []ExportLogsServiceResponse + if cap(dest) < len(src) { + newDest = make([]ExportLogsServiceResponse, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportLogsServiceResponse(&dest[i], false) + } + } + for i := range src { + CopyExportLogsServiceResponse(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportLogsServiceResponsePtrSlice(dest, src []*ExportLogsServiceResponse) []*ExportLogsServiceResponse { + var newDest []*ExportLogsServiceResponse + if cap(dest) < len(src) { + newDest = make([]*ExportLogsServiceResponse, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportLogsServiceResponse() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportLogsServiceResponse(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportLogsServiceResponse() + } + } + for i := range src { + CopyExportLogsServiceResponse(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportLogsServiceResponse) Reset() { + *orig = ExportLogsServiceResponse{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportLogsServiceResponse) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("partialSuccess") + orig.PartialSuccess.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportLogsServiceResponse) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "partialSuccess", "partial_success": + + orig.PartialSuccess.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *ExportLogsServiceResponse) SizeProto() int { + var n int + var l int + _ = l + l = orig.PartialSuccess.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *ExportLogsServiceResponse) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.PartialSuccess.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + return len(buf) - pos +} + +func (orig *ExportLogsServiceResponse) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.PartialSuccess.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportLogsServiceResponse() *ExportLogsServiceResponse { + orig := NewExportLogsServiceResponse() + orig.PartialSuccess = *GenTestExportLogsPartialSuccess() + return orig +} + +func GenTestExportLogsServiceResponsePtrSlice() []*ExportLogsServiceResponse { + orig := make([]*ExportLogsServiceResponse, 5) + orig[0] = NewExportLogsServiceResponse() + orig[1] = GenTestExportLogsServiceResponse() + orig[2] = NewExportLogsServiceResponse() + orig[3] = GenTestExportLogsServiceResponse() + orig[4] = NewExportLogsServiceResponse() + return orig +} + +func GenTestExportLogsServiceResponseSlice() []ExportLogsServiceResponse { + orig := make([]ExportLogsServiceResponse, 5) + orig[1] = *GenTestExportLogsServiceResponse() + orig[3] = *GenTestExportLogsServiceResponse() + return orig +} diff --git a/pdata/internal/generated_proto_exportlogsserviceresponse_test.go b/pdata/internal/generated_proto_exportlogsserviceresponse_test.go new file mode 100644 index 00000000000..adbf08b787f --- /dev/null +++ b/pdata/internal/generated_proto_exportlogsserviceresponse_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectorlogs "go.opentelemetry.io/proto/slim/otlp/collector/logs/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportLogsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportLogsServiceResponse() + CopyExportLogsServiceResponse(dest, src) + assert.Equal(t, src, dest) + CopyExportLogsServiceResponse(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportLogsServiceResponseSlice(t *testing.T) { + src := []ExportLogsServiceResponse{} + dest := []ExportLogsServiceResponse{} + // Test CopyTo empty + dest = CopyExportLogsServiceResponseSlice(dest, src) + assert.Equal(t, []ExportLogsServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportLogsServiceResponseSlice() + dest = CopyExportLogsServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceResponseSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportLogsServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceResponseSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportLogsServiceResponseSlice(dest, []ExportLogsServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportLogsServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceResponseSlice(), dest) +} + +func TestCopyExportLogsServiceResponsePtrSlice(t *testing.T) { + src := []*ExportLogsServiceResponse{} + dest := []*ExportLogsServiceResponse{} + // Test CopyTo empty + dest = CopyExportLogsServiceResponsePtrSlice(dest, src) + assert.Equal(t, []*ExportLogsServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportLogsServiceResponsePtrSlice() + dest = CopyExportLogsServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceResponsePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportLogsServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceResponsePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportLogsServiceResponsePtrSlice(dest, []*ExportLogsServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportLogsServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportLogsServiceResponsePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportLogsServiceResponseUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportLogsServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportLogsServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalJSONExportLogsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportLogsServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportLogsServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportLogsServiceResponseFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportLogsServiceResponse() { + t.Run(name, func(t *testing.T) { + dest := NewExportLogsServiceResponse() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportLogsServiceResponseUnknown(t *testing.T) { + dest := NewExportLogsServiceResponse() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportLogsServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalProtoExportLogsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportLogsServiceResponse() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportLogsServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportLogsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportLogsServiceResponse() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectorlogs.ExportLogsServiceResponse{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportLogsServiceResponse() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportLogsServiceResponse() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "PartialSuccess/wrong_wire_type": {0xc}, + "PartialSuccess/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportLogsServiceResponse() map[string]*ExportLogsServiceResponse { + return map[string]*ExportLogsServiceResponse{ + "empty": NewExportLogsServiceResponse(), + "PartialSuccess/test": {PartialSuccess: *GenTestExportLogsPartialSuccess()}, + } +} diff --git a/pdata/internal/generated_proto_exportmetricspartialsuccess.go b/pdata/internal/generated_proto_exportmetricspartialsuccess.go new file mode 100644 index 00000000000..ff18f954c52 --- /dev/null +++ b/pdata/internal/generated_proto_exportmetricspartialsuccess.go @@ -0,0 +1,258 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportPartialSuccess represents the details of a partially successful export request. +type ExportMetricsPartialSuccess struct { + RejectedDataPoints int64 + ErrorMessage string +} + +var ( + protoPoolExportMetricsPartialSuccess = sync.Pool{ + New: func() any { + return &ExportMetricsPartialSuccess{} + }, + } +) + +func NewExportMetricsPartialSuccess() *ExportMetricsPartialSuccess { + if !UseProtoPooling.IsEnabled() { + return &ExportMetricsPartialSuccess{} + } + return protoPoolExportMetricsPartialSuccess.Get().(*ExportMetricsPartialSuccess) +} + +func DeleteExportMetricsPartialSuccess(orig *ExportMetricsPartialSuccess, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolExportMetricsPartialSuccess.Put(orig) + } +} + +func CopyExportMetricsPartialSuccess(dest, src *ExportMetricsPartialSuccess) *ExportMetricsPartialSuccess { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportMetricsPartialSuccess() + } + dest.RejectedDataPoints = src.RejectedDataPoints + + dest.ErrorMessage = src.ErrorMessage + + return dest +} + +func CopyExportMetricsPartialSuccessSlice(dest, src []ExportMetricsPartialSuccess) []ExportMetricsPartialSuccess { + var newDest []ExportMetricsPartialSuccess + if cap(dest) < len(src) { + newDest = make([]ExportMetricsPartialSuccess, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportMetricsPartialSuccess(&dest[i], false) + } + } + for i := range src { + CopyExportMetricsPartialSuccess(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportMetricsPartialSuccessPtrSlice(dest, src []*ExportMetricsPartialSuccess) []*ExportMetricsPartialSuccess { + var newDest []*ExportMetricsPartialSuccess + if cap(dest) < len(src) { + newDest = make([]*ExportMetricsPartialSuccess, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportMetricsPartialSuccess() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportMetricsPartialSuccess(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportMetricsPartialSuccess() + } + } + for i := range src { + CopyExportMetricsPartialSuccess(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportMetricsPartialSuccess) Reset() { + *orig = ExportMetricsPartialSuccess{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportMetricsPartialSuccess) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RejectedDataPoints != int64(0) { + dest.WriteObjectField("rejectedDataPoints") + dest.WriteInt64(orig.RejectedDataPoints) + } + if orig.ErrorMessage != "" { + dest.WriteObjectField("errorMessage") + dest.WriteString(orig.ErrorMessage) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportMetricsPartialSuccess) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "rejectedDataPoints", "rejected_data_points": + orig.RejectedDataPoints = iter.ReadInt64() + case "errorMessage", "error_message": + orig.ErrorMessage = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ExportMetricsPartialSuccess) SizeProto() int { + var n int + var l int + _ = l + if orig.RejectedDataPoints != 0 { + n += 1 + proto.Sov(uint64(orig.RejectedDataPoints)) + } + l = len(orig.ErrorMessage) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportMetricsPartialSuccess) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RejectedDataPoints != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedDataPoints)) + pos-- + buf[pos] = 0x8 + } + l = len(orig.ErrorMessage) + if l > 0 { + pos -= l + copy(buf[pos:], orig.ErrorMessage) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *ExportMetricsPartialSuccess) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field RejectedDataPoints", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.RejectedDataPoints = int64(num) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ErrorMessage = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportMetricsPartialSuccess() *ExportMetricsPartialSuccess { + orig := NewExportMetricsPartialSuccess() + orig.RejectedDataPoints = int64(13) + orig.ErrorMessage = "test_errormessage" + return orig +} + +func GenTestExportMetricsPartialSuccessPtrSlice() []*ExportMetricsPartialSuccess { + orig := make([]*ExportMetricsPartialSuccess, 5) + orig[0] = NewExportMetricsPartialSuccess() + orig[1] = GenTestExportMetricsPartialSuccess() + orig[2] = NewExportMetricsPartialSuccess() + orig[3] = GenTestExportMetricsPartialSuccess() + orig[4] = NewExportMetricsPartialSuccess() + return orig +} + +func GenTestExportMetricsPartialSuccessSlice() []ExportMetricsPartialSuccess { + orig := make([]ExportMetricsPartialSuccess, 5) + orig[1] = *GenTestExportMetricsPartialSuccess() + orig[3] = *GenTestExportMetricsPartialSuccess() + return orig +} diff --git a/pdata/internal/generated_wrapper_exportmetricspartialsuccess_test.go b/pdata/internal/generated_proto_exportmetricspartialsuccess_test.go similarity index 50% rename from pdata/internal/generated_wrapper_exportmetricspartialsuccess_test.go rename to pdata/internal/generated_proto_exportmetricspartialsuccess_test.go index 11f3ea5545a..5b35a6469cb 100644 --- a/pdata/internal/generated_wrapper_exportmetricspartialsuccess_test.go +++ b/pdata/internal/generated_proto_exportmetricspartialsuccess_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigExportMetricsPartialSuccess(t *testing.T) { +func TestCopyExportMetricsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportMetricsPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigExportMetricsPartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigExportMetricsPartialSuccess() - CopyOrigExportMetricsPartialSuccess(dest, src) + dest := NewExportMetricsPartialSuccess() + CopyExportMetricsPartialSuccess(dest, src) assert.Equal(t, src, dest) - CopyOrigExportMetricsPartialSuccess(dest, dest) + CopyExportMetricsPartialSuccess(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigExportMetricsPartialSuccessUnknown(t *testing.T) { +func TestCopyExportMetricsPartialSuccessSlice(t *testing.T) { + src := []ExportMetricsPartialSuccess{} + dest := []ExportMetricsPartialSuccess{} + // Test CopyTo empty + dest = CopyExportMetricsPartialSuccessSlice(dest, src) + assert.Equal(t, []ExportMetricsPartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportMetricsPartialSuccessSlice() + dest = CopyExportMetricsPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportMetricsPartialSuccessSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportMetricsPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportMetricsPartialSuccessSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportMetricsPartialSuccessSlice(dest, []ExportMetricsPartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportMetricsPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportMetricsPartialSuccessSlice(), dest) +} + +func TestCopyExportMetricsPartialSuccessPtrSlice(t *testing.T) { + src := []*ExportMetricsPartialSuccess{} + dest := []*ExportMetricsPartialSuccess{} + // Test CopyTo empty + dest = CopyExportMetricsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, []*ExportMetricsPartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportMetricsPartialSuccessPtrSlice() + dest = CopyExportMetricsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsPartialSuccessPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportMetricsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsPartialSuccessPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportMetricsPartialSuccessPtrSlice(dest, []*ExportMetricsPartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportMetricsPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsPartialSuccessPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportMetricsPartialSuccessUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigExportMetricsPartialSuccess() - UnmarshalJSONOrigExportMetricsPartialSuccess(dest, iter) + dest := NewExportMetricsPartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportMetricsPartialSuccess(), dest) + assert.Equal(t, NewExportMetricsPartialSuccess(), dest) } -func TestMarshalAndUnmarshalJSONOrigExportMetricsPartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalJSONExportMetricsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportMetricsPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigExportMetricsPartialSuccess(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigExportMetricsPartialSuccess(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigExportMetricsPartialSuccess() - UnmarshalJSONOrigExportMetricsPartialSuccess(dest, iter) + dest := NewExportMetricsPartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigExportMetricsPartialSuccess(dest, true) + DeleteExportMetricsPartialSuccess(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigExportMetricsPartialSuccessFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportMetricsPartialSuccessFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesExportMetricsPartialSuccess() { t.Run(name, func(t *testing.T) { - dest := NewOrigExportMetricsPartialSuccess() - require.Error(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, buf)) + dest := NewExportMetricsPartialSuccess() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigExportMetricsPartialSuccessUnknown(t *testing.T) { - dest := NewOrigExportMetricsPartialSuccess() +func TestMarshalAndUnmarshalProtoExportMetricsPartialSuccessUnknown(t *testing.T) { + dest := NewExportMetricsPartialSuccess() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportMetricsPartialSuccess(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportMetricsPartialSuccess(), dest) } -func TestMarshalAndUnmarshalProtoOrigExportMetricsPartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportMetricsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportMetricsPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigExportMetricsPartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigExportMetricsPartialSuccess(src)) - gotSize := MarshalProtoOrigExportMetricsPartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigExportMetricsPartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, buf)) + dest := NewExportMetricsPartialSuccess() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigExportMetricsPartialSuccess(dest, true) + DeleteExportMetricsPartialSuccess(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigExportMetricsPartialSuccess(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufExportMetricsPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportMetricsPartialSuccess() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportMetricsPartialSuccess(src)) - gotSize := MarshalProtoOrigExportMetricsPartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcollectormetrics.ExportMetricsPartialSuccess{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufExportMetricsPartialSuccess(t *testi goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigExportMetricsPartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportMetricsPartialSuccess(dest, goBuf)) + dest := NewExportMetricsPartialSuccess() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,9 +196,9 @@ func genTestFailingUnmarshalProtoValuesExportMetricsPartialSuccess() map[string] } } -func genTestEncodingValuesExportMetricsPartialSuccess() map[string]*otlpcollectormetrics.ExportMetricsPartialSuccess { - return map[string]*otlpcollectormetrics.ExportMetricsPartialSuccess{ - "empty": NewOrigExportMetricsPartialSuccess(), +func genTestEncodingValuesExportMetricsPartialSuccess() map[string]*ExportMetricsPartialSuccess { + return map[string]*ExportMetricsPartialSuccess{ + "empty": NewExportMetricsPartialSuccess(), "RejectedDataPoints/test": {RejectedDataPoints: int64(13)}, "ErrorMessage/test": {ErrorMessage: "test_errormessage"}, } diff --git a/pdata/internal/generated_proto_exportmetricsservicerequest.go b/pdata/internal/generated_proto_exportmetricsservicerequest.go new file mode 100644 index 00000000000..f4a4a0fa7b2 --- /dev/null +++ b/pdata/internal/generated_proto_exportmetricsservicerequest.go @@ -0,0 +1,246 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Metrics is the top-level struct that is propagated through the metrics pipeline. +// Use NewMetrics to create new instance, zero-initialized instance is not valid for use. +type ExportMetricsServiceRequest struct { + ResourceMetrics []*ResourceMetrics +} + +var ( + protoPoolExportMetricsServiceRequest = sync.Pool{ + New: func() any { + return &ExportMetricsServiceRequest{} + }, + } +) + +func NewExportMetricsServiceRequest() *ExportMetricsServiceRequest { + if !UseProtoPooling.IsEnabled() { + return &ExportMetricsServiceRequest{} + } + return protoPoolExportMetricsServiceRequest.Get().(*ExportMetricsServiceRequest) +} + +func DeleteExportMetricsServiceRequest(orig *ExportMetricsServiceRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceMetrics { + DeleteResourceMetrics(orig.ResourceMetrics[i], true) + } + + orig.Reset() + if nullable { + protoPoolExportMetricsServiceRequest.Put(orig) + } +} + +func CopyExportMetricsServiceRequest(dest, src *ExportMetricsServiceRequest) *ExportMetricsServiceRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportMetricsServiceRequest() + } + dest.ResourceMetrics = CopyResourceMetricsPtrSlice(dest.ResourceMetrics, src.ResourceMetrics) + + return dest +} + +func CopyExportMetricsServiceRequestSlice(dest, src []ExportMetricsServiceRequest) []ExportMetricsServiceRequest { + var newDest []ExportMetricsServiceRequest + if cap(dest) < len(src) { + newDest = make([]ExportMetricsServiceRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportMetricsServiceRequest(&dest[i], false) + } + } + for i := range src { + CopyExportMetricsServiceRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportMetricsServiceRequestPtrSlice(dest, src []*ExportMetricsServiceRequest) []*ExportMetricsServiceRequest { + var newDest []*ExportMetricsServiceRequest + if cap(dest) < len(src) { + newDest = make([]*ExportMetricsServiceRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportMetricsServiceRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportMetricsServiceRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportMetricsServiceRequest() + } + } + for i := range src { + CopyExportMetricsServiceRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportMetricsServiceRequest) Reset() { + *orig = ExportMetricsServiceRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportMetricsServiceRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceMetrics) > 0 { + dest.WriteObjectField("resourceMetrics") + dest.WriteArrayStart() + orig.ResourceMetrics[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceMetrics); i++ { + dest.WriteMore() + orig.ResourceMetrics[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportMetricsServiceRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceMetrics", "resource_metrics": + for iter.ReadArray() { + orig.ResourceMetrics = append(orig.ResourceMetrics, NewResourceMetrics()) + orig.ResourceMetrics[len(orig.ResourceMetrics)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ExportMetricsServiceRequest) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceMetrics { + l = orig.ResourceMetrics[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportMetricsServiceRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceMetrics) - 1; i >= 0; i-- { + l = orig.ResourceMetrics[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *ExportMetricsServiceRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceMetrics", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceMetrics = append(orig.ResourceMetrics, NewResourceMetrics()) + err = orig.ResourceMetrics[len(orig.ResourceMetrics)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportMetricsServiceRequest() *ExportMetricsServiceRequest { + orig := NewExportMetricsServiceRequest() + orig.ResourceMetrics = []*ResourceMetrics{{}, GenTestResourceMetrics()} + return orig +} + +func GenTestExportMetricsServiceRequestPtrSlice() []*ExportMetricsServiceRequest { + orig := make([]*ExportMetricsServiceRequest, 5) + orig[0] = NewExportMetricsServiceRequest() + orig[1] = GenTestExportMetricsServiceRequest() + orig[2] = NewExportMetricsServiceRequest() + orig[3] = GenTestExportMetricsServiceRequest() + orig[4] = NewExportMetricsServiceRequest() + return orig +} + +func GenTestExportMetricsServiceRequestSlice() []ExportMetricsServiceRequest { + orig := make([]ExportMetricsServiceRequest, 5) + orig[1] = *GenTestExportMetricsServiceRequest() + orig[3] = *GenTestExportMetricsServiceRequest() + return orig +} diff --git a/pdata/internal/generated_proto_exportmetricsservicerequest_test.go b/pdata/internal/generated_proto_exportmetricsservicerequest_test.go new file mode 100644 index 00000000000..2582295c331 --- /dev/null +++ b/pdata/internal/generated_proto_exportmetricsservicerequest_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectormetrics "go.opentelemetry.io/proto/slim/otlp/collector/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportMetricsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportMetricsServiceRequest() + CopyExportMetricsServiceRequest(dest, src) + assert.Equal(t, src, dest) + CopyExportMetricsServiceRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportMetricsServiceRequestSlice(t *testing.T) { + src := []ExportMetricsServiceRequest{} + dest := []ExportMetricsServiceRequest{} + // Test CopyTo empty + dest = CopyExportMetricsServiceRequestSlice(dest, src) + assert.Equal(t, []ExportMetricsServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportMetricsServiceRequestSlice() + dest = CopyExportMetricsServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportMetricsServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportMetricsServiceRequestSlice(dest, []ExportMetricsServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportMetricsServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceRequestSlice(), dest) +} + +func TestCopyExportMetricsServiceRequestPtrSlice(t *testing.T) { + src := []*ExportMetricsServiceRequest{} + dest := []*ExportMetricsServiceRequest{} + // Test CopyTo empty + dest = CopyExportMetricsServiceRequestPtrSlice(dest, src) + assert.Equal(t, []*ExportMetricsServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportMetricsServiceRequestPtrSlice() + dest = CopyExportMetricsServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportMetricsServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportMetricsServiceRequestPtrSlice(dest, []*ExportMetricsServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportMetricsServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportMetricsServiceRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportMetricsServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportMetricsServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONExportMetricsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportMetricsServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportMetricsServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportMetricsServiceRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportMetricsServiceRequest() { + t.Run(name, func(t *testing.T) { + dest := NewExportMetricsServiceRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportMetricsServiceRequestUnknown(t *testing.T) { + dest := NewExportMetricsServiceRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportMetricsServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoExportMetricsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportMetricsServiceRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportMetricsServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportMetricsServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectormetrics.ExportMetricsServiceRequest{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportMetricsServiceRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportMetricsServiceRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceMetrics/wrong_wire_type": {0xc}, + "ResourceMetrics/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportMetricsServiceRequest() map[string]*ExportMetricsServiceRequest { + return map[string]*ExportMetricsServiceRequest{ + "empty": NewExportMetricsServiceRequest(), + "ResourceMetrics/test": {ResourceMetrics: []*ResourceMetrics{{}, GenTestResourceMetrics()}}, + } +} diff --git a/pdata/internal/generated_proto_exportmetricsserviceresponse.go b/pdata/internal/generated_proto_exportmetricsserviceresponse.go new file mode 100644 index 00000000000..19e69384ed6 --- /dev/null +++ b/pdata/internal/generated_proto_exportmetricsserviceresponse.go @@ -0,0 +1,229 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportResponse represents the response for gRPC/HTTP client/server. +type ExportMetricsServiceResponse struct { + PartialSuccess ExportMetricsPartialSuccess +} + +var ( + protoPoolExportMetricsServiceResponse = sync.Pool{ + New: func() any { + return &ExportMetricsServiceResponse{} + }, + } +) + +func NewExportMetricsServiceResponse() *ExportMetricsServiceResponse { + if !UseProtoPooling.IsEnabled() { + return &ExportMetricsServiceResponse{} + } + return protoPoolExportMetricsServiceResponse.Get().(*ExportMetricsServiceResponse) +} + +func DeleteExportMetricsServiceResponse(orig *ExportMetricsServiceResponse, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteExportMetricsPartialSuccess(&orig.PartialSuccess, false) + + orig.Reset() + if nullable { + protoPoolExportMetricsServiceResponse.Put(orig) + } +} + +func CopyExportMetricsServiceResponse(dest, src *ExportMetricsServiceResponse) *ExportMetricsServiceResponse { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportMetricsServiceResponse() + } + CopyExportMetricsPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) + + return dest +} + +func CopyExportMetricsServiceResponseSlice(dest, src []ExportMetricsServiceResponse) []ExportMetricsServiceResponse { + var newDest []ExportMetricsServiceResponse + if cap(dest) < len(src) { + newDest = make([]ExportMetricsServiceResponse, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportMetricsServiceResponse(&dest[i], false) + } + } + for i := range src { + CopyExportMetricsServiceResponse(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportMetricsServiceResponsePtrSlice(dest, src []*ExportMetricsServiceResponse) []*ExportMetricsServiceResponse { + var newDest []*ExportMetricsServiceResponse + if cap(dest) < len(src) { + newDest = make([]*ExportMetricsServiceResponse, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportMetricsServiceResponse() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportMetricsServiceResponse(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportMetricsServiceResponse() + } + } + for i := range src { + CopyExportMetricsServiceResponse(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportMetricsServiceResponse) Reset() { + *orig = ExportMetricsServiceResponse{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportMetricsServiceResponse) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("partialSuccess") + orig.PartialSuccess.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportMetricsServiceResponse) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "partialSuccess", "partial_success": + + orig.PartialSuccess.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *ExportMetricsServiceResponse) SizeProto() int { + var n int + var l int + _ = l + l = orig.PartialSuccess.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *ExportMetricsServiceResponse) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.PartialSuccess.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + return len(buf) - pos +} + +func (orig *ExportMetricsServiceResponse) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.PartialSuccess.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportMetricsServiceResponse() *ExportMetricsServiceResponse { + orig := NewExportMetricsServiceResponse() + orig.PartialSuccess = *GenTestExportMetricsPartialSuccess() + return orig +} + +func GenTestExportMetricsServiceResponsePtrSlice() []*ExportMetricsServiceResponse { + orig := make([]*ExportMetricsServiceResponse, 5) + orig[0] = NewExportMetricsServiceResponse() + orig[1] = GenTestExportMetricsServiceResponse() + orig[2] = NewExportMetricsServiceResponse() + orig[3] = GenTestExportMetricsServiceResponse() + orig[4] = NewExportMetricsServiceResponse() + return orig +} + +func GenTestExportMetricsServiceResponseSlice() []ExportMetricsServiceResponse { + orig := make([]ExportMetricsServiceResponse, 5) + orig[1] = *GenTestExportMetricsServiceResponse() + orig[3] = *GenTestExportMetricsServiceResponse() + return orig +} diff --git a/pdata/internal/generated_proto_exportmetricsserviceresponse_test.go b/pdata/internal/generated_proto_exportmetricsserviceresponse_test.go new file mode 100644 index 00000000000..c6ec0a30876 --- /dev/null +++ b/pdata/internal/generated_proto_exportmetricsserviceresponse_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectormetrics "go.opentelemetry.io/proto/slim/otlp/collector/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportMetricsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportMetricsServiceResponse() + CopyExportMetricsServiceResponse(dest, src) + assert.Equal(t, src, dest) + CopyExportMetricsServiceResponse(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportMetricsServiceResponseSlice(t *testing.T) { + src := []ExportMetricsServiceResponse{} + dest := []ExportMetricsServiceResponse{} + // Test CopyTo empty + dest = CopyExportMetricsServiceResponseSlice(dest, src) + assert.Equal(t, []ExportMetricsServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportMetricsServiceResponseSlice() + dest = CopyExportMetricsServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceResponseSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportMetricsServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceResponseSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportMetricsServiceResponseSlice(dest, []ExportMetricsServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportMetricsServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceResponseSlice(), dest) +} + +func TestCopyExportMetricsServiceResponsePtrSlice(t *testing.T) { + src := []*ExportMetricsServiceResponse{} + dest := []*ExportMetricsServiceResponse{} + // Test CopyTo empty + dest = CopyExportMetricsServiceResponsePtrSlice(dest, src) + assert.Equal(t, []*ExportMetricsServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportMetricsServiceResponsePtrSlice() + dest = CopyExportMetricsServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceResponsePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportMetricsServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceResponsePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportMetricsServiceResponsePtrSlice(dest, []*ExportMetricsServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportMetricsServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportMetricsServiceResponsePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportMetricsServiceResponseUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportMetricsServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportMetricsServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalJSONExportMetricsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportMetricsServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportMetricsServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportMetricsServiceResponseFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportMetricsServiceResponse() { + t.Run(name, func(t *testing.T) { + dest := NewExportMetricsServiceResponse() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportMetricsServiceResponseUnknown(t *testing.T) { + dest := NewExportMetricsServiceResponse() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportMetricsServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalProtoExportMetricsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportMetricsServiceResponse() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportMetricsServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportMetricsServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectormetrics.ExportMetricsServiceResponse{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportMetricsServiceResponse() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportMetricsServiceResponse() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "PartialSuccess/wrong_wire_type": {0xc}, + "PartialSuccess/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportMetricsServiceResponse() map[string]*ExportMetricsServiceResponse { + return map[string]*ExportMetricsServiceResponse{ + "empty": NewExportMetricsServiceResponse(), + "PartialSuccess/test": {PartialSuccess: *GenTestExportMetricsPartialSuccess()}, + } +} diff --git a/pdata/internal/generated_proto_exportprofilespartialsuccess.go b/pdata/internal/generated_proto_exportprofilespartialsuccess.go new file mode 100644 index 00000000000..03a20a62483 --- /dev/null +++ b/pdata/internal/generated_proto_exportprofilespartialsuccess.go @@ -0,0 +1,258 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportPartialSuccess represents the details of a partially successful export request. +type ExportProfilesPartialSuccess struct { + RejectedProfiles int64 + ErrorMessage string +} + +var ( + protoPoolExportProfilesPartialSuccess = sync.Pool{ + New: func() any { + return &ExportProfilesPartialSuccess{} + }, + } +) + +func NewExportProfilesPartialSuccess() *ExportProfilesPartialSuccess { + if !UseProtoPooling.IsEnabled() { + return &ExportProfilesPartialSuccess{} + } + return protoPoolExportProfilesPartialSuccess.Get().(*ExportProfilesPartialSuccess) +} + +func DeleteExportProfilesPartialSuccess(orig *ExportProfilesPartialSuccess, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolExportProfilesPartialSuccess.Put(orig) + } +} + +func CopyExportProfilesPartialSuccess(dest, src *ExportProfilesPartialSuccess) *ExportProfilesPartialSuccess { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportProfilesPartialSuccess() + } + dest.RejectedProfiles = src.RejectedProfiles + + dest.ErrorMessage = src.ErrorMessage + + return dest +} + +func CopyExportProfilesPartialSuccessSlice(dest, src []ExportProfilesPartialSuccess) []ExportProfilesPartialSuccess { + var newDest []ExportProfilesPartialSuccess + if cap(dest) < len(src) { + newDest = make([]ExportProfilesPartialSuccess, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportProfilesPartialSuccess(&dest[i], false) + } + } + for i := range src { + CopyExportProfilesPartialSuccess(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportProfilesPartialSuccessPtrSlice(dest, src []*ExportProfilesPartialSuccess) []*ExportProfilesPartialSuccess { + var newDest []*ExportProfilesPartialSuccess + if cap(dest) < len(src) { + newDest = make([]*ExportProfilesPartialSuccess, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportProfilesPartialSuccess() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportProfilesPartialSuccess(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportProfilesPartialSuccess() + } + } + for i := range src { + CopyExportProfilesPartialSuccess(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportProfilesPartialSuccess) Reset() { + *orig = ExportProfilesPartialSuccess{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportProfilesPartialSuccess) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RejectedProfiles != int64(0) { + dest.WriteObjectField("rejectedProfiles") + dest.WriteInt64(orig.RejectedProfiles) + } + if orig.ErrorMessage != "" { + dest.WriteObjectField("errorMessage") + dest.WriteString(orig.ErrorMessage) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportProfilesPartialSuccess) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "rejectedProfiles", "rejected_profiles": + orig.RejectedProfiles = iter.ReadInt64() + case "errorMessage", "error_message": + orig.ErrorMessage = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ExportProfilesPartialSuccess) SizeProto() int { + var n int + var l int + _ = l + if orig.RejectedProfiles != 0 { + n += 1 + proto.Sov(uint64(orig.RejectedProfiles)) + } + l = len(orig.ErrorMessage) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportProfilesPartialSuccess) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RejectedProfiles != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedProfiles)) + pos-- + buf[pos] = 0x8 + } + l = len(orig.ErrorMessage) + if l > 0 { + pos -= l + copy(buf[pos:], orig.ErrorMessage) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *ExportProfilesPartialSuccess) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field RejectedProfiles", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.RejectedProfiles = int64(num) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ErrorMessage = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportProfilesPartialSuccess() *ExportProfilesPartialSuccess { + orig := NewExportProfilesPartialSuccess() + orig.RejectedProfiles = int64(13) + orig.ErrorMessage = "test_errormessage" + return orig +} + +func GenTestExportProfilesPartialSuccessPtrSlice() []*ExportProfilesPartialSuccess { + orig := make([]*ExportProfilesPartialSuccess, 5) + orig[0] = NewExportProfilesPartialSuccess() + orig[1] = GenTestExportProfilesPartialSuccess() + orig[2] = NewExportProfilesPartialSuccess() + orig[3] = GenTestExportProfilesPartialSuccess() + orig[4] = NewExportProfilesPartialSuccess() + return orig +} + +func GenTestExportProfilesPartialSuccessSlice() []ExportProfilesPartialSuccess { + orig := make([]ExportProfilesPartialSuccess, 5) + orig[1] = *GenTestExportProfilesPartialSuccess() + orig[3] = *GenTestExportProfilesPartialSuccess() + return orig +} diff --git a/pdata/internal/generated_wrapper_exportprofilespartialsuccess_test.go b/pdata/internal/generated_proto_exportprofilespartialsuccess_test.go similarity index 50% rename from pdata/internal/generated_wrapper_exportprofilespartialsuccess_test.go rename to pdata/internal/generated_proto_exportprofilespartialsuccess_test.go index a8e3ae025bb..c5b95413d58 100644 --- a/pdata/internal/generated_wrapper_exportprofilespartialsuccess_test.go +++ b/pdata/internal/generated_proto_exportprofilespartialsuccess_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigExportProfilesPartialSuccess(t *testing.T) { +func TestCopyExportProfilesPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportProfilesPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigExportProfilesPartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigExportProfilesPartialSuccess() - CopyOrigExportProfilesPartialSuccess(dest, src) + dest := NewExportProfilesPartialSuccess() + CopyExportProfilesPartialSuccess(dest, src) assert.Equal(t, src, dest) - CopyOrigExportProfilesPartialSuccess(dest, dest) + CopyExportProfilesPartialSuccess(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigExportProfilesPartialSuccessUnknown(t *testing.T) { +func TestCopyExportProfilesPartialSuccessSlice(t *testing.T) { + src := []ExportProfilesPartialSuccess{} + dest := []ExportProfilesPartialSuccess{} + // Test CopyTo empty + dest = CopyExportProfilesPartialSuccessSlice(dest, src) + assert.Equal(t, []ExportProfilesPartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportProfilesPartialSuccessSlice() + dest = CopyExportProfilesPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportProfilesPartialSuccessSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportProfilesPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportProfilesPartialSuccessSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportProfilesPartialSuccessSlice(dest, []ExportProfilesPartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportProfilesPartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportProfilesPartialSuccessSlice(), dest) +} + +func TestCopyExportProfilesPartialSuccessPtrSlice(t *testing.T) { + src := []*ExportProfilesPartialSuccess{} + dest := []*ExportProfilesPartialSuccess{} + // Test CopyTo empty + dest = CopyExportProfilesPartialSuccessPtrSlice(dest, src) + assert.Equal(t, []*ExportProfilesPartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportProfilesPartialSuccessPtrSlice() + dest = CopyExportProfilesPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesPartialSuccessPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportProfilesPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesPartialSuccessPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportProfilesPartialSuccessPtrSlice(dest, []*ExportProfilesPartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportProfilesPartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesPartialSuccessPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportProfilesPartialSuccessUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigExportProfilesPartialSuccess() - UnmarshalJSONOrigExportProfilesPartialSuccess(dest, iter) + dest := NewExportProfilesPartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportProfilesPartialSuccess(), dest) + assert.Equal(t, NewExportProfilesPartialSuccess(), dest) } -func TestMarshalAndUnmarshalJSONOrigExportProfilesPartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalJSONExportProfilesPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportProfilesPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigExportProfilesPartialSuccess(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigExportProfilesPartialSuccess(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigExportProfilesPartialSuccess() - UnmarshalJSONOrigExportProfilesPartialSuccess(dest, iter) + dest := NewExportProfilesPartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigExportProfilesPartialSuccess(dest, true) + DeleteExportProfilesPartialSuccess(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigExportProfilesPartialSuccessFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportProfilesPartialSuccessFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesExportProfilesPartialSuccess() { t.Run(name, func(t *testing.T) { - dest := NewOrigExportProfilesPartialSuccess() - require.Error(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, buf)) + dest := NewExportProfilesPartialSuccess() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigExportProfilesPartialSuccessUnknown(t *testing.T) { - dest := NewOrigExportProfilesPartialSuccess() +func TestMarshalAndUnmarshalProtoExportProfilesPartialSuccessUnknown(t *testing.T) { + dest := NewExportProfilesPartialSuccess() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportProfilesPartialSuccess(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportProfilesPartialSuccess(), dest) } -func TestMarshalAndUnmarshalProtoOrigExportProfilesPartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportProfilesPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportProfilesPartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigExportProfilesPartialSuccess(t *testing.T) require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigExportProfilesPartialSuccess(src)) - gotSize := MarshalProtoOrigExportProfilesPartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigExportProfilesPartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, buf)) + dest := NewExportProfilesPartialSuccess() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigExportProfilesPartialSuccess(dest, true) + DeleteExportProfilesPartialSuccess(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigExportProfilesPartialSuccess(t *testing.T) func TestMarshalAndUnmarshalProtoViaProtobufExportProfilesPartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportProfilesPartialSuccess() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportProfilesPartialSuccess(src)) - gotSize := MarshalProtoOrigExportProfilesPartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcollectorprofiles.ExportProfilesPartialSuccess{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufExportProfilesPartialSuccess(t *test goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigExportProfilesPartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportProfilesPartialSuccess(dest, goBuf)) + dest := NewExportProfilesPartialSuccess() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,9 +196,9 @@ func genTestFailingUnmarshalProtoValuesExportProfilesPartialSuccess() map[string } } -func genTestEncodingValuesExportProfilesPartialSuccess() map[string]*otlpcollectorprofiles.ExportProfilesPartialSuccess { - return map[string]*otlpcollectorprofiles.ExportProfilesPartialSuccess{ - "empty": NewOrigExportProfilesPartialSuccess(), +func genTestEncodingValuesExportProfilesPartialSuccess() map[string]*ExportProfilesPartialSuccess { + return map[string]*ExportProfilesPartialSuccess{ + "empty": NewExportProfilesPartialSuccess(), "RejectedProfiles/test": {RejectedProfiles: int64(13)}, "ErrorMessage/test": {ErrorMessage: "test_errormessage"}, } diff --git a/pdata/internal/generated_proto_exportprofilesservicerequest.go b/pdata/internal/generated_proto_exportprofilesservicerequest.go new file mode 100644 index 00000000000..5906ce52093 --- /dev/null +++ b/pdata/internal/generated_proto_exportprofilesservicerequest.go @@ -0,0 +1,280 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Profiles is the top-level struct that is propagated through the profiles pipeline. +// Use NewProfiles to create new instance, zero-initialized instance is not valid for use. +type ExportProfilesServiceRequest struct { + ResourceProfiles []*ResourceProfiles + Dictionary ProfilesDictionary +} + +var ( + protoPoolExportProfilesServiceRequest = sync.Pool{ + New: func() any { + return &ExportProfilesServiceRequest{} + }, + } +) + +func NewExportProfilesServiceRequest() *ExportProfilesServiceRequest { + if !UseProtoPooling.IsEnabled() { + return &ExportProfilesServiceRequest{} + } + return protoPoolExportProfilesServiceRequest.Get().(*ExportProfilesServiceRequest) +} + +func DeleteExportProfilesServiceRequest(orig *ExportProfilesServiceRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceProfiles { + DeleteResourceProfiles(orig.ResourceProfiles[i], true) + } + DeleteProfilesDictionary(&orig.Dictionary, false) + + orig.Reset() + if nullable { + protoPoolExportProfilesServiceRequest.Put(orig) + } +} + +func CopyExportProfilesServiceRequest(dest, src *ExportProfilesServiceRequest) *ExportProfilesServiceRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportProfilesServiceRequest() + } + dest.ResourceProfiles = CopyResourceProfilesPtrSlice(dest.ResourceProfiles, src.ResourceProfiles) + + CopyProfilesDictionary(&dest.Dictionary, &src.Dictionary) + + return dest +} + +func CopyExportProfilesServiceRequestSlice(dest, src []ExportProfilesServiceRequest) []ExportProfilesServiceRequest { + var newDest []ExportProfilesServiceRequest + if cap(dest) < len(src) { + newDest = make([]ExportProfilesServiceRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportProfilesServiceRequest(&dest[i], false) + } + } + for i := range src { + CopyExportProfilesServiceRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportProfilesServiceRequestPtrSlice(dest, src []*ExportProfilesServiceRequest) []*ExportProfilesServiceRequest { + var newDest []*ExportProfilesServiceRequest + if cap(dest) < len(src) { + newDest = make([]*ExportProfilesServiceRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportProfilesServiceRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportProfilesServiceRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportProfilesServiceRequest() + } + } + for i := range src { + CopyExportProfilesServiceRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportProfilesServiceRequest) Reset() { + *orig = ExportProfilesServiceRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportProfilesServiceRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceProfiles) > 0 { + dest.WriteObjectField("resourceProfiles") + dest.WriteArrayStart() + orig.ResourceProfiles[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceProfiles); i++ { + dest.WriteMore() + orig.ResourceProfiles[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectField("dictionary") + orig.Dictionary.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportProfilesServiceRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceProfiles", "resource_profiles": + for iter.ReadArray() { + orig.ResourceProfiles = append(orig.ResourceProfiles, NewResourceProfiles()) + orig.ResourceProfiles[len(orig.ResourceProfiles)-1].UnmarshalJSON(iter) + } + + case "dictionary": + + orig.Dictionary.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *ExportProfilesServiceRequest) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceProfiles { + l = orig.ResourceProfiles[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + l = orig.Dictionary.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *ExportProfilesServiceRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceProfiles) - 1; i >= 0; i-- { + l = orig.ResourceProfiles[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = orig.Dictionary.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + + return len(buf) - pos +} + +func (orig *ExportProfilesServiceRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceProfiles", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceProfiles = append(orig.ResourceProfiles, NewResourceProfiles()) + err = orig.ResourceProfiles[len(orig.ResourceProfiles)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Dictionary", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Dictionary.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportProfilesServiceRequest() *ExportProfilesServiceRequest { + orig := NewExportProfilesServiceRequest() + orig.ResourceProfiles = []*ResourceProfiles{{}, GenTestResourceProfiles()} + orig.Dictionary = *GenTestProfilesDictionary() + return orig +} + +func GenTestExportProfilesServiceRequestPtrSlice() []*ExportProfilesServiceRequest { + orig := make([]*ExportProfilesServiceRequest, 5) + orig[0] = NewExportProfilesServiceRequest() + orig[1] = GenTestExportProfilesServiceRequest() + orig[2] = NewExportProfilesServiceRequest() + orig[3] = GenTestExportProfilesServiceRequest() + orig[4] = NewExportProfilesServiceRequest() + return orig +} + +func GenTestExportProfilesServiceRequestSlice() []ExportProfilesServiceRequest { + orig := make([]ExportProfilesServiceRequest, 5) + orig[1] = *GenTestExportProfilesServiceRequest() + orig[3] = *GenTestExportProfilesServiceRequest() + return orig +} diff --git a/pdata/internal/generated_proto_exportprofilesservicerequest_test.go b/pdata/internal/generated_proto_exportprofilesservicerequest_test.go new file mode 100644 index 00000000000..18b73da8407 --- /dev/null +++ b/pdata/internal/generated_proto_exportprofilesservicerequest_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectorprofiles "go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportProfilesServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportProfilesServiceRequest() + CopyExportProfilesServiceRequest(dest, src) + assert.Equal(t, src, dest) + CopyExportProfilesServiceRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportProfilesServiceRequestSlice(t *testing.T) { + src := []ExportProfilesServiceRequest{} + dest := []ExportProfilesServiceRequest{} + // Test CopyTo empty + dest = CopyExportProfilesServiceRequestSlice(dest, src) + assert.Equal(t, []ExportProfilesServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportProfilesServiceRequestSlice() + dest = CopyExportProfilesServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportProfilesServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportProfilesServiceRequestSlice(dest, []ExportProfilesServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportProfilesServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceRequestSlice(), dest) +} + +func TestCopyExportProfilesServiceRequestPtrSlice(t *testing.T) { + src := []*ExportProfilesServiceRequest{} + dest := []*ExportProfilesServiceRequest{} + // Test CopyTo empty + dest = CopyExportProfilesServiceRequestPtrSlice(dest, src) + assert.Equal(t, []*ExportProfilesServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportProfilesServiceRequestPtrSlice() + dest = CopyExportProfilesServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportProfilesServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportProfilesServiceRequestPtrSlice(dest, []*ExportProfilesServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportProfilesServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportProfilesServiceRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportProfilesServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportProfilesServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONExportProfilesServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportProfilesServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportProfilesServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportProfilesServiceRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportProfilesServiceRequest() { + t.Run(name, func(t *testing.T) { + dest := NewExportProfilesServiceRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportProfilesServiceRequestUnknown(t *testing.T) { + dest := NewExportProfilesServiceRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportProfilesServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoExportProfilesServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportProfilesServiceRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportProfilesServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportProfilesServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectorprofiles.ExportProfilesServiceRequest{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportProfilesServiceRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportProfilesServiceRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceProfiles/wrong_wire_type": {0xc}, + "ResourceProfiles/missing_value": {0xa}, + "Dictionary/wrong_wire_type": {0x14}, + "Dictionary/missing_value": {0x12}, + } +} + +func genTestEncodingValuesExportProfilesServiceRequest() map[string]*ExportProfilesServiceRequest { + return map[string]*ExportProfilesServiceRequest{ + "empty": NewExportProfilesServiceRequest(), + "ResourceProfiles/test": {ResourceProfiles: []*ResourceProfiles{{}, GenTestResourceProfiles()}}, + "Dictionary/test": {Dictionary: *GenTestProfilesDictionary()}, + } +} diff --git a/pdata/internal/generated_proto_exportprofilesserviceresponse.go b/pdata/internal/generated_proto_exportprofilesserviceresponse.go new file mode 100644 index 00000000000..0153c060994 --- /dev/null +++ b/pdata/internal/generated_proto_exportprofilesserviceresponse.go @@ -0,0 +1,229 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportResponse represents the response for gRPC/HTTP client/server. +type ExportProfilesServiceResponse struct { + PartialSuccess ExportProfilesPartialSuccess +} + +var ( + protoPoolExportProfilesServiceResponse = sync.Pool{ + New: func() any { + return &ExportProfilesServiceResponse{} + }, + } +) + +func NewExportProfilesServiceResponse() *ExportProfilesServiceResponse { + if !UseProtoPooling.IsEnabled() { + return &ExportProfilesServiceResponse{} + } + return protoPoolExportProfilesServiceResponse.Get().(*ExportProfilesServiceResponse) +} + +func DeleteExportProfilesServiceResponse(orig *ExportProfilesServiceResponse, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteExportProfilesPartialSuccess(&orig.PartialSuccess, false) + + orig.Reset() + if nullable { + protoPoolExportProfilesServiceResponse.Put(orig) + } +} + +func CopyExportProfilesServiceResponse(dest, src *ExportProfilesServiceResponse) *ExportProfilesServiceResponse { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportProfilesServiceResponse() + } + CopyExportProfilesPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) + + return dest +} + +func CopyExportProfilesServiceResponseSlice(dest, src []ExportProfilesServiceResponse) []ExportProfilesServiceResponse { + var newDest []ExportProfilesServiceResponse + if cap(dest) < len(src) { + newDest = make([]ExportProfilesServiceResponse, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportProfilesServiceResponse(&dest[i], false) + } + } + for i := range src { + CopyExportProfilesServiceResponse(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportProfilesServiceResponsePtrSlice(dest, src []*ExportProfilesServiceResponse) []*ExportProfilesServiceResponse { + var newDest []*ExportProfilesServiceResponse + if cap(dest) < len(src) { + newDest = make([]*ExportProfilesServiceResponse, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportProfilesServiceResponse() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportProfilesServiceResponse(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportProfilesServiceResponse() + } + } + for i := range src { + CopyExportProfilesServiceResponse(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportProfilesServiceResponse) Reset() { + *orig = ExportProfilesServiceResponse{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportProfilesServiceResponse) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("partialSuccess") + orig.PartialSuccess.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportProfilesServiceResponse) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "partialSuccess", "partial_success": + + orig.PartialSuccess.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *ExportProfilesServiceResponse) SizeProto() int { + var n int + var l int + _ = l + l = orig.PartialSuccess.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *ExportProfilesServiceResponse) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.PartialSuccess.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + return len(buf) - pos +} + +func (orig *ExportProfilesServiceResponse) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.PartialSuccess.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportProfilesServiceResponse() *ExportProfilesServiceResponse { + orig := NewExportProfilesServiceResponse() + orig.PartialSuccess = *GenTestExportProfilesPartialSuccess() + return orig +} + +func GenTestExportProfilesServiceResponsePtrSlice() []*ExportProfilesServiceResponse { + orig := make([]*ExportProfilesServiceResponse, 5) + orig[0] = NewExportProfilesServiceResponse() + orig[1] = GenTestExportProfilesServiceResponse() + orig[2] = NewExportProfilesServiceResponse() + orig[3] = GenTestExportProfilesServiceResponse() + orig[4] = NewExportProfilesServiceResponse() + return orig +} + +func GenTestExportProfilesServiceResponseSlice() []ExportProfilesServiceResponse { + orig := make([]ExportProfilesServiceResponse, 5) + orig[1] = *GenTestExportProfilesServiceResponse() + orig[3] = *GenTestExportProfilesServiceResponse() + return orig +} diff --git a/pdata/internal/generated_proto_exportprofilesserviceresponse_test.go b/pdata/internal/generated_proto_exportprofilesserviceresponse_test.go new file mode 100644 index 00000000000..c2b901d0fd9 --- /dev/null +++ b/pdata/internal/generated_proto_exportprofilesserviceresponse_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectorprofiles "go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportProfilesServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportProfilesServiceResponse() + CopyExportProfilesServiceResponse(dest, src) + assert.Equal(t, src, dest) + CopyExportProfilesServiceResponse(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportProfilesServiceResponseSlice(t *testing.T) { + src := []ExportProfilesServiceResponse{} + dest := []ExportProfilesServiceResponse{} + // Test CopyTo empty + dest = CopyExportProfilesServiceResponseSlice(dest, src) + assert.Equal(t, []ExportProfilesServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportProfilesServiceResponseSlice() + dest = CopyExportProfilesServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceResponseSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportProfilesServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceResponseSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportProfilesServiceResponseSlice(dest, []ExportProfilesServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportProfilesServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceResponseSlice(), dest) +} + +func TestCopyExportProfilesServiceResponsePtrSlice(t *testing.T) { + src := []*ExportProfilesServiceResponse{} + dest := []*ExportProfilesServiceResponse{} + // Test CopyTo empty + dest = CopyExportProfilesServiceResponsePtrSlice(dest, src) + assert.Equal(t, []*ExportProfilesServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportProfilesServiceResponsePtrSlice() + dest = CopyExportProfilesServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceResponsePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportProfilesServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceResponsePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportProfilesServiceResponsePtrSlice(dest, []*ExportProfilesServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportProfilesServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportProfilesServiceResponsePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportProfilesServiceResponseUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportProfilesServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportProfilesServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalJSONExportProfilesServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportProfilesServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportProfilesServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportProfilesServiceResponseFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportProfilesServiceResponse() { + t.Run(name, func(t *testing.T) { + dest := NewExportProfilesServiceResponse() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportProfilesServiceResponseUnknown(t *testing.T) { + dest := NewExportProfilesServiceResponse() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportProfilesServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalProtoExportProfilesServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportProfilesServiceResponse() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportProfilesServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportProfilesServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectorprofiles.ExportProfilesServiceResponse{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportProfilesServiceResponse() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportProfilesServiceResponse() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "PartialSuccess/wrong_wire_type": {0xc}, + "PartialSuccess/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportProfilesServiceResponse() map[string]*ExportProfilesServiceResponse { + return map[string]*ExportProfilesServiceResponse{ + "empty": NewExportProfilesServiceResponse(), + "PartialSuccess/test": {PartialSuccess: *GenTestExportProfilesPartialSuccess()}, + } +} diff --git a/pdata/internal/generated_proto_exporttracepartialsuccess.go b/pdata/internal/generated_proto_exporttracepartialsuccess.go new file mode 100644 index 00000000000..df8025572b4 --- /dev/null +++ b/pdata/internal/generated_proto_exporttracepartialsuccess.go @@ -0,0 +1,258 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportPartialSuccess represents the details of a partially successful export request. +type ExportTracePartialSuccess struct { + RejectedSpans int64 + ErrorMessage string +} + +var ( + protoPoolExportTracePartialSuccess = sync.Pool{ + New: func() any { + return &ExportTracePartialSuccess{} + }, + } +) + +func NewExportTracePartialSuccess() *ExportTracePartialSuccess { + if !UseProtoPooling.IsEnabled() { + return &ExportTracePartialSuccess{} + } + return protoPoolExportTracePartialSuccess.Get().(*ExportTracePartialSuccess) +} + +func DeleteExportTracePartialSuccess(orig *ExportTracePartialSuccess, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolExportTracePartialSuccess.Put(orig) + } +} + +func CopyExportTracePartialSuccess(dest, src *ExportTracePartialSuccess) *ExportTracePartialSuccess { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportTracePartialSuccess() + } + dest.RejectedSpans = src.RejectedSpans + + dest.ErrorMessage = src.ErrorMessage + + return dest +} + +func CopyExportTracePartialSuccessSlice(dest, src []ExportTracePartialSuccess) []ExportTracePartialSuccess { + var newDest []ExportTracePartialSuccess + if cap(dest) < len(src) { + newDest = make([]ExportTracePartialSuccess, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportTracePartialSuccess(&dest[i], false) + } + } + for i := range src { + CopyExportTracePartialSuccess(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportTracePartialSuccessPtrSlice(dest, src []*ExportTracePartialSuccess) []*ExportTracePartialSuccess { + var newDest []*ExportTracePartialSuccess + if cap(dest) < len(src) { + newDest = make([]*ExportTracePartialSuccess, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportTracePartialSuccess() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportTracePartialSuccess(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportTracePartialSuccess() + } + } + for i := range src { + CopyExportTracePartialSuccess(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportTracePartialSuccess) Reset() { + *orig = ExportTracePartialSuccess{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportTracePartialSuccess) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RejectedSpans != int64(0) { + dest.WriteObjectField("rejectedSpans") + dest.WriteInt64(orig.RejectedSpans) + } + if orig.ErrorMessage != "" { + dest.WriteObjectField("errorMessage") + dest.WriteString(orig.ErrorMessage) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportTracePartialSuccess) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "rejectedSpans", "rejected_spans": + orig.RejectedSpans = iter.ReadInt64() + case "errorMessage", "error_message": + orig.ErrorMessage = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ExportTracePartialSuccess) SizeProto() int { + var n int + var l int + _ = l + if orig.RejectedSpans != 0 { + n += 1 + proto.Sov(uint64(orig.RejectedSpans)) + } + l = len(orig.ErrorMessage) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportTracePartialSuccess) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RejectedSpans != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedSpans)) + pos-- + buf[pos] = 0x8 + } + l = len(orig.ErrorMessage) + if l > 0 { + pos -= l + copy(buf[pos:], orig.ErrorMessage) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *ExportTracePartialSuccess) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field RejectedSpans", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.RejectedSpans = int64(num) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ErrorMessage = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportTracePartialSuccess() *ExportTracePartialSuccess { + orig := NewExportTracePartialSuccess() + orig.RejectedSpans = int64(13) + orig.ErrorMessage = "test_errormessage" + return orig +} + +func GenTestExportTracePartialSuccessPtrSlice() []*ExportTracePartialSuccess { + orig := make([]*ExportTracePartialSuccess, 5) + orig[0] = NewExportTracePartialSuccess() + orig[1] = GenTestExportTracePartialSuccess() + orig[2] = NewExportTracePartialSuccess() + orig[3] = GenTestExportTracePartialSuccess() + orig[4] = NewExportTracePartialSuccess() + return orig +} + +func GenTestExportTracePartialSuccessSlice() []ExportTracePartialSuccess { + orig := make([]ExportTracePartialSuccess, 5) + orig[1] = *GenTestExportTracePartialSuccess() + orig[3] = *GenTestExportTracePartialSuccess() + return orig +} diff --git a/pdata/internal/generated_wrapper_exporttracepartialsuccess_test.go b/pdata/internal/generated_proto_exporttracepartialsuccess_test.go similarity index 51% rename from pdata/internal/generated_wrapper_exporttracepartialsuccess_test.go rename to pdata/internal/generated_proto_exporttracepartialsuccess_test.go index 6aa9b873c04..7331cc17a10 100644 --- a/pdata/internal/generated_wrapper_exporttracepartialsuccess_test.go +++ b/pdata/internal/generated_proto_exporttracepartialsuccess_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigExportTracePartialSuccess(t *testing.T) { +func TestCopyExportTracePartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportTracePartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigExportTracePartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigExportTracePartialSuccess() - CopyOrigExportTracePartialSuccess(dest, src) + dest := NewExportTracePartialSuccess() + CopyExportTracePartialSuccess(dest, src) assert.Equal(t, src, dest) - CopyOrigExportTracePartialSuccess(dest, dest) + CopyExportTracePartialSuccess(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigExportTracePartialSuccessUnknown(t *testing.T) { +func TestCopyExportTracePartialSuccessSlice(t *testing.T) { + src := []ExportTracePartialSuccess{} + dest := []ExportTracePartialSuccess{} + // Test CopyTo empty + dest = CopyExportTracePartialSuccessSlice(dest, src) + assert.Equal(t, []ExportTracePartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportTracePartialSuccessSlice() + dest = CopyExportTracePartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportTracePartialSuccessSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportTracePartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportTracePartialSuccessSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportTracePartialSuccessSlice(dest, []ExportTracePartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportTracePartialSuccessSlice(dest, src) + assert.Equal(t, GenTestExportTracePartialSuccessSlice(), dest) +} + +func TestCopyExportTracePartialSuccessPtrSlice(t *testing.T) { + src := []*ExportTracePartialSuccess{} + dest := []*ExportTracePartialSuccess{} + // Test CopyTo empty + dest = CopyExportTracePartialSuccessPtrSlice(dest, src) + assert.Equal(t, []*ExportTracePartialSuccess{}, dest) + + // Test CopyTo larger slice + src = GenTestExportTracePartialSuccessPtrSlice() + dest = CopyExportTracePartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportTracePartialSuccessPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportTracePartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportTracePartialSuccessPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportTracePartialSuccessPtrSlice(dest, []*ExportTracePartialSuccess{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportTracePartialSuccessPtrSlice(dest, src) + assert.Equal(t, GenTestExportTracePartialSuccessPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportTracePartialSuccessUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigExportTracePartialSuccess() - UnmarshalJSONOrigExportTracePartialSuccess(dest, iter) + dest := NewExportTracePartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportTracePartialSuccess(), dest) + assert.Equal(t, NewExportTracePartialSuccess(), dest) } -func TestMarshalAndUnmarshalJSONOrigExportTracePartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalJSONExportTracePartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportTracePartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigExportTracePartialSuccess(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigExportTracePartialSuccess(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigExportTracePartialSuccess() - UnmarshalJSONOrigExportTracePartialSuccess(dest, iter) + dest := NewExportTracePartialSuccess() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigExportTracePartialSuccess(dest, true) + DeleteExportTracePartialSuccess(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigExportTracePartialSuccessFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportTracePartialSuccessFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesExportTracePartialSuccess() { t.Run(name, func(t *testing.T) { - dest := NewOrigExportTracePartialSuccess() - require.Error(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, buf)) + dest := NewExportTracePartialSuccess() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigExportTracePartialSuccessUnknown(t *testing.T) { - dest := NewOrigExportTracePartialSuccess() +func TestMarshalAndUnmarshalProtoExportTracePartialSuccessUnknown(t *testing.T) { + dest := NewExportTracePartialSuccess() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportTracePartialSuccess(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportTracePartialSuccess(), dest) } -func TestMarshalAndUnmarshalProtoOrigExportTracePartialSuccess(t *testing.T) { +func TestMarshalAndUnmarshalProtoExportTracePartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportTracePartialSuccess() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigExportTracePartialSuccess(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigExportTracePartialSuccess(src)) - gotSize := MarshalProtoOrigExportTracePartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigExportTracePartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, buf)) + dest := NewExportTracePartialSuccess() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigExportTracePartialSuccess(dest, true) + DeleteExportTracePartialSuccess(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigExportTracePartialSuccess(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufExportTracePartialSuccess(t *testing.T) { for name, src := range genTestEncodingValuesExportTracePartialSuccess() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportTracePartialSuccess(src)) - gotSize := MarshalProtoOrigExportTracePartialSuccess(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcollectortrace.ExportTracePartialSuccess{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufExportTracePartialSuccess(t *testing goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigExportTracePartialSuccess() - require.NoError(t, UnmarshalProtoOrigExportTracePartialSuccess(dest, goBuf)) + dest := NewExportTracePartialSuccess() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,9 +196,9 @@ func genTestFailingUnmarshalProtoValuesExportTracePartialSuccess() map[string][] } } -func genTestEncodingValuesExportTracePartialSuccess() map[string]*otlpcollectortrace.ExportTracePartialSuccess { - return map[string]*otlpcollectortrace.ExportTracePartialSuccess{ - "empty": NewOrigExportTracePartialSuccess(), +func genTestEncodingValuesExportTracePartialSuccess() map[string]*ExportTracePartialSuccess { + return map[string]*ExportTracePartialSuccess{ + "empty": NewExportTracePartialSuccess(), "RejectedSpans/test": {RejectedSpans: int64(13)}, "ErrorMessage/test": {ErrorMessage: "test_errormessage"}, } diff --git a/pdata/internal/generated_proto_exporttraceservicerequest.go b/pdata/internal/generated_proto_exporttraceservicerequest.go new file mode 100644 index 00000000000..e64316f8f3c --- /dev/null +++ b/pdata/internal/generated_proto_exporttraceservicerequest.go @@ -0,0 +1,246 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Traces is the top-level struct that is propagated through the traces pipeline. +// Use NewTraces to create new instance, zero-initialized instance is not valid for use. +type ExportTraceServiceRequest struct { + ResourceSpans []*ResourceSpans +} + +var ( + protoPoolExportTraceServiceRequest = sync.Pool{ + New: func() any { + return &ExportTraceServiceRequest{} + }, + } +) + +func NewExportTraceServiceRequest() *ExportTraceServiceRequest { + if !UseProtoPooling.IsEnabled() { + return &ExportTraceServiceRequest{} + } + return protoPoolExportTraceServiceRequest.Get().(*ExportTraceServiceRequest) +} + +func DeleteExportTraceServiceRequest(orig *ExportTraceServiceRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceSpans { + DeleteResourceSpans(orig.ResourceSpans[i], true) + } + + orig.Reset() + if nullable { + protoPoolExportTraceServiceRequest.Put(orig) + } +} + +func CopyExportTraceServiceRequest(dest, src *ExportTraceServiceRequest) *ExportTraceServiceRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportTraceServiceRequest() + } + dest.ResourceSpans = CopyResourceSpansPtrSlice(dest.ResourceSpans, src.ResourceSpans) + + return dest +} + +func CopyExportTraceServiceRequestSlice(dest, src []ExportTraceServiceRequest) []ExportTraceServiceRequest { + var newDest []ExportTraceServiceRequest + if cap(dest) < len(src) { + newDest = make([]ExportTraceServiceRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportTraceServiceRequest(&dest[i], false) + } + } + for i := range src { + CopyExportTraceServiceRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportTraceServiceRequestPtrSlice(dest, src []*ExportTraceServiceRequest) []*ExportTraceServiceRequest { + var newDest []*ExportTraceServiceRequest + if cap(dest) < len(src) { + newDest = make([]*ExportTraceServiceRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportTraceServiceRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportTraceServiceRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportTraceServiceRequest() + } + } + for i := range src { + CopyExportTraceServiceRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportTraceServiceRequest) Reset() { + *orig = ExportTraceServiceRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportTraceServiceRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceSpans) > 0 { + dest.WriteObjectField("resourceSpans") + dest.WriteArrayStart() + orig.ResourceSpans[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceSpans); i++ { + dest.WriteMore() + orig.ResourceSpans[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportTraceServiceRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceSpans", "resource_spans": + for iter.ReadArray() { + orig.ResourceSpans = append(orig.ResourceSpans, NewResourceSpans()) + orig.ResourceSpans[len(orig.ResourceSpans)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ExportTraceServiceRequest) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceSpans { + l = orig.ResourceSpans[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ExportTraceServiceRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceSpans) - 1; i >= 0; i-- { + l = orig.ResourceSpans[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *ExportTraceServiceRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceSpans", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceSpans = append(orig.ResourceSpans, NewResourceSpans()) + err = orig.ResourceSpans[len(orig.ResourceSpans)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportTraceServiceRequest() *ExportTraceServiceRequest { + orig := NewExportTraceServiceRequest() + orig.ResourceSpans = []*ResourceSpans{{}, GenTestResourceSpans()} + return orig +} + +func GenTestExportTraceServiceRequestPtrSlice() []*ExportTraceServiceRequest { + orig := make([]*ExportTraceServiceRequest, 5) + orig[0] = NewExportTraceServiceRequest() + orig[1] = GenTestExportTraceServiceRequest() + orig[2] = NewExportTraceServiceRequest() + orig[3] = GenTestExportTraceServiceRequest() + orig[4] = NewExportTraceServiceRequest() + return orig +} + +func GenTestExportTraceServiceRequestSlice() []ExportTraceServiceRequest { + orig := make([]ExportTraceServiceRequest, 5) + orig[1] = *GenTestExportTraceServiceRequest() + orig[3] = *GenTestExportTraceServiceRequest() + return orig +} diff --git a/pdata/internal/generated_proto_exporttraceservicerequest_test.go b/pdata/internal/generated_proto_exporttraceservicerequest_test.go new file mode 100644 index 00000000000..4dbf90c0838 --- /dev/null +++ b/pdata/internal/generated_proto_exporttraceservicerequest_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectortrace "go.opentelemetry.io/proto/slim/otlp/collector/trace/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportTraceServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportTraceServiceRequest() + CopyExportTraceServiceRequest(dest, src) + assert.Equal(t, src, dest) + CopyExportTraceServiceRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportTraceServiceRequestSlice(t *testing.T) { + src := []ExportTraceServiceRequest{} + dest := []ExportTraceServiceRequest{} + // Test CopyTo empty + dest = CopyExportTraceServiceRequestSlice(dest, src) + assert.Equal(t, []ExportTraceServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportTraceServiceRequestSlice() + dest = CopyExportTraceServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportTraceServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportTraceServiceRequestSlice(dest, []ExportTraceServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportTraceServiceRequestSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceRequestSlice(), dest) +} + +func TestCopyExportTraceServiceRequestPtrSlice(t *testing.T) { + src := []*ExportTraceServiceRequest{} + dest := []*ExportTraceServiceRequest{} + // Test CopyTo empty + dest = CopyExportTraceServiceRequestPtrSlice(dest, src) + assert.Equal(t, []*ExportTraceServiceRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestExportTraceServiceRequestPtrSlice() + dest = CopyExportTraceServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportTraceServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportTraceServiceRequestPtrSlice(dest, []*ExportTraceServiceRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportTraceServiceRequestPtrSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportTraceServiceRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportTraceServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportTraceServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONExportTraceServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportTraceServiceRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportTraceServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportTraceServiceRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportTraceServiceRequest() { + t.Run(name, func(t *testing.T) { + dest := NewExportTraceServiceRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportTraceServiceRequestUnknown(t *testing.T) { + dest := NewExportTraceServiceRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportTraceServiceRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoExportTraceServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportTraceServiceRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportTraceServiceRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportTraceServiceRequest(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectortrace.ExportTraceServiceRequest{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportTraceServiceRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportTraceServiceRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceSpans/wrong_wire_type": {0xc}, + "ResourceSpans/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportTraceServiceRequest() map[string]*ExportTraceServiceRequest { + return map[string]*ExportTraceServiceRequest{ + "empty": NewExportTraceServiceRequest(), + "ResourceSpans/test": {ResourceSpans: []*ResourceSpans{{}, GenTestResourceSpans()}}, + } +} diff --git a/pdata/internal/generated_proto_exporttraceserviceresponse.go b/pdata/internal/generated_proto_exporttraceserviceresponse.go new file mode 100644 index 00000000000..86be1a0fdaf --- /dev/null +++ b/pdata/internal/generated_proto_exporttraceserviceresponse.go @@ -0,0 +1,229 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ExportResponse represents the response for gRPC/HTTP client/server. +type ExportTraceServiceResponse struct { + PartialSuccess ExportTracePartialSuccess +} + +var ( + protoPoolExportTraceServiceResponse = sync.Pool{ + New: func() any { + return &ExportTraceServiceResponse{} + }, + } +) + +func NewExportTraceServiceResponse() *ExportTraceServiceResponse { + if !UseProtoPooling.IsEnabled() { + return &ExportTraceServiceResponse{} + } + return protoPoolExportTraceServiceResponse.Get().(*ExportTraceServiceResponse) +} + +func DeleteExportTraceServiceResponse(orig *ExportTraceServiceResponse, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteExportTracePartialSuccess(&orig.PartialSuccess, false) + + orig.Reset() + if nullable { + protoPoolExportTraceServiceResponse.Put(orig) + } +} + +func CopyExportTraceServiceResponse(dest, src *ExportTraceServiceResponse) *ExportTraceServiceResponse { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewExportTraceServiceResponse() + } + CopyExportTracePartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) + + return dest +} + +func CopyExportTraceServiceResponseSlice(dest, src []ExportTraceServiceResponse) []ExportTraceServiceResponse { + var newDest []ExportTraceServiceResponse + if cap(dest) < len(src) { + newDest = make([]ExportTraceServiceResponse, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportTraceServiceResponse(&dest[i], false) + } + } + for i := range src { + CopyExportTraceServiceResponse(&newDest[i], &src[i]) + } + return newDest +} + +func CopyExportTraceServiceResponsePtrSlice(dest, src []*ExportTraceServiceResponse) []*ExportTraceServiceResponse { + var newDest []*ExportTraceServiceResponse + if cap(dest) < len(src) { + newDest = make([]*ExportTraceServiceResponse, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportTraceServiceResponse() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteExportTraceServiceResponse(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewExportTraceServiceResponse() + } + } + for i := range src { + CopyExportTraceServiceResponse(newDest[i], src[i]) + } + return newDest +} + +func (orig *ExportTraceServiceResponse) Reset() { + *orig = ExportTraceServiceResponse{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ExportTraceServiceResponse) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("partialSuccess") + orig.PartialSuccess.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ExportTraceServiceResponse) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "partialSuccess", "partial_success": + + orig.PartialSuccess.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *ExportTraceServiceResponse) SizeProto() int { + var n int + var l int + _ = l + l = orig.PartialSuccess.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *ExportTraceServiceResponse) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.PartialSuccess.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + return len(buf) - pos +} + +func (orig *ExportTraceServiceResponse) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.PartialSuccess.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestExportTraceServiceResponse() *ExportTraceServiceResponse { + orig := NewExportTraceServiceResponse() + orig.PartialSuccess = *GenTestExportTracePartialSuccess() + return orig +} + +func GenTestExportTraceServiceResponsePtrSlice() []*ExportTraceServiceResponse { + orig := make([]*ExportTraceServiceResponse, 5) + orig[0] = NewExportTraceServiceResponse() + orig[1] = GenTestExportTraceServiceResponse() + orig[2] = NewExportTraceServiceResponse() + orig[3] = GenTestExportTraceServiceResponse() + orig[4] = NewExportTraceServiceResponse() + return orig +} + +func GenTestExportTraceServiceResponseSlice() []ExportTraceServiceResponse { + orig := make([]ExportTraceServiceResponse, 5) + orig[1] = *GenTestExportTraceServiceResponse() + orig[3] = *GenTestExportTraceServiceResponse() + return orig +} diff --git a/pdata/internal/generated_proto_exporttraceserviceresponse_test.go b/pdata/internal/generated_proto_exporttraceserviceresponse_test.go new file mode 100644 index 00000000000..74ae7b4f3ed --- /dev/null +++ b/pdata/internal/generated_proto_exporttraceserviceresponse_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpcollectortrace "go.opentelemetry.io/proto/slim/otlp/collector/trace/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyExportTraceServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewExportTraceServiceResponse() + CopyExportTraceServiceResponse(dest, src) + assert.Equal(t, src, dest) + CopyExportTraceServiceResponse(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyExportTraceServiceResponseSlice(t *testing.T) { + src := []ExportTraceServiceResponse{} + dest := []ExportTraceServiceResponse{} + // Test CopyTo empty + dest = CopyExportTraceServiceResponseSlice(dest, src) + assert.Equal(t, []ExportTraceServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportTraceServiceResponseSlice() + dest = CopyExportTraceServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceResponseSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportTraceServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceResponseSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportTraceServiceResponseSlice(dest, []ExportTraceServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportTraceServiceResponseSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceResponseSlice(), dest) +} + +func TestCopyExportTraceServiceResponsePtrSlice(t *testing.T) { + src := []*ExportTraceServiceResponse{} + dest := []*ExportTraceServiceResponse{} + // Test CopyTo empty + dest = CopyExportTraceServiceResponsePtrSlice(dest, src) + assert.Equal(t, []*ExportTraceServiceResponse{}, dest) + + // Test CopyTo larger slice + src = GenTestExportTraceServiceResponsePtrSlice() + dest = CopyExportTraceServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceResponsePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyExportTraceServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceResponsePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyExportTraceServiceResponsePtrSlice(dest, []*ExportTraceServiceResponse{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyExportTraceServiceResponsePtrSlice(dest, src) + assert.Equal(t, GenTestExportTraceServiceResponsePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONExportTraceServiceResponseUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewExportTraceServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewExportTraceServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalJSONExportTraceServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewExportTraceServiceResponse() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteExportTraceServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoExportTraceServiceResponseFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesExportTraceServiceResponse() { + t.Run(name, func(t *testing.T) { + dest := NewExportTraceServiceResponse() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoExportTraceServiceResponseUnknown(t *testing.T) { + dest := NewExportTraceServiceResponse() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewExportTraceServiceResponse(), dest) +} + +func TestMarshalAndUnmarshalProtoExportTraceServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceResponse() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewExportTraceServiceResponse() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteExportTraceServiceResponse(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufExportTraceServiceResponse(t *testing.T) { + for name, src := range genTestEncodingValuesExportTraceServiceResponse() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpcollectortrace.ExportTraceServiceResponse{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewExportTraceServiceResponse() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesExportTraceServiceResponse() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "PartialSuccess/wrong_wire_type": {0xc}, + "PartialSuccess/missing_value": {0xa}, + } +} + +func genTestEncodingValuesExportTraceServiceResponse() map[string]*ExportTraceServiceResponse { + return map[string]*ExportTraceServiceResponse{ + "empty": NewExportTraceServiceResponse(), + "PartialSuccess/test": {PartialSuccess: *GenTestExportTracePartialSuccess()}, + } +} diff --git a/pdata/internal/generated_wrapper_function.go b/pdata/internal/generated_proto_function.go similarity index 60% rename from pdata/internal/generated_wrapper_function.go rename to pdata/internal/generated_proto_function.go index 2999e35c2d2..4e822539092 100644 --- a/pdata/internal/generated_wrapper_function.go +++ b/pdata/internal/generated_proto_function.go @@ -10,27 +10,34 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Function describes a function, including its human-readable name, system name, source file, and starting line number in the source. +type Function struct { + NameStrindex int32 + SystemNameStrindex int32 + FilenameStrindex int32 + StartLine int64 +} + var ( protoPoolFunction = sync.Pool{ New: func() any { - return &otlpprofiles.Function{} + return &Function{} }, } ) -func NewOrigFunction() *otlpprofiles.Function { +func NewFunction() *Function { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Function{} + return &Function{} } - return protoPoolFunction.Get().(*otlpprofiles.Function) + return protoPoolFunction.Get().(*Function) } -func DeleteOrigFunction(orig *otlpprofiles.Function, nullable bool) { +func DeleteFunction(orig *Function, nullable bool) { if orig == nil { return } @@ -46,28 +53,84 @@ func DeleteOrigFunction(orig *otlpprofiles.Function, nullable bool) { } } -func CopyOrigFunction(dest, src *otlpprofiles.Function) { +func CopyFunction(dest, src *Function) *Function { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewFunction() } dest.NameStrindex = src.NameStrindex + dest.SystemNameStrindex = src.SystemNameStrindex + dest.FilenameStrindex = src.FilenameStrindex + dest.StartLine = src.StartLine + + return dest } -func GenTestOrigFunction() *otlpprofiles.Function { - orig := NewOrigFunction() - orig.NameStrindex = int32(13) - orig.SystemNameStrindex = int32(13) - orig.FilenameStrindex = int32(13) - orig.StartLine = int64(13) - return orig +func CopyFunctionSlice(dest, src []Function) []Function { + var newDest []Function + if cap(dest) < len(src) { + newDest = make([]Function, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteFunction(&dest[i], false) + } + } + for i := range src { + CopyFunction(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigFunction(orig *otlpprofiles.Function, dest *json.Stream) { +func CopyFunctionPtrSlice(dest, src []*Function) []*Function { + var newDest []*Function + if cap(dest) < len(src) { + newDest = make([]*Function, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewFunction() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteFunction(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewFunction() + } + } + for i := range src { + CopyFunction(newDest[i], src[i]) + } + return newDest +} + +func (orig *Function) Reset() { + *orig = Function{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Function) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.NameStrindex != int32(0) { dest.WriteObjectField("nameStrindex") @@ -88,8 +151,8 @@ func MarshalJSONOrigFunction(orig *otlpprofiles.Function, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigFunction unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigFunction(orig *otlpprofiles.Function, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Function) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "nameStrindex", "name_strindex": @@ -106,7 +169,7 @@ func UnmarshalJSONOrigFunction(orig *otlpprofiles.Function, iter *json.Iterator) } } -func SizeProtoOrigFunction(orig *otlpprofiles.Function) int { +func (orig *Function) SizeProto() int { var n int var l int _ = l @@ -125,7 +188,7 @@ func SizeProtoOrigFunction(orig *otlpprofiles.Function) int { return n } -func MarshalProtoOrigFunction(orig *otlpprofiles.Function, buf []byte) int { +func (orig *Function) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -152,7 +215,7 @@ func MarshalProtoOrigFunction(orig *otlpprofiles.Function, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigFunction(orig *otlpprofiles.Function, buf []byte) error { +func (orig *Function) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -223,3 +286,29 @@ func UnmarshalProtoOrigFunction(orig *otlpprofiles.Function, buf []byte) error { } return nil } + +func GenTestFunction() *Function { + orig := NewFunction() + orig.NameStrindex = int32(13) + orig.SystemNameStrindex = int32(13) + orig.FilenameStrindex = int32(13) + orig.StartLine = int64(13) + return orig +} + +func GenTestFunctionPtrSlice() []*Function { + orig := make([]*Function, 5) + orig[0] = NewFunction() + orig[1] = GenTestFunction() + orig[2] = NewFunction() + orig[3] = GenTestFunction() + orig[4] = NewFunction() + return orig +} + +func GenTestFunctionSlice() []Function { + orig := make([]Function, 5) + orig[1] = *GenTestFunction() + orig[3] = *GenTestFunction() + return orig +} diff --git a/pdata/internal/generated_wrapper_function_test.go b/pdata/internal/generated_proto_function_test.go similarity index 58% rename from pdata/internal/generated_wrapper_function_test.go rename to pdata/internal/generated_proto_function_test.go index b4806abd4b4..3947ba9dd64 100644 --- a/pdata/internal/generated_wrapper_function_test.go +++ b/pdata/internal/generated_proto_function_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigFunction(t *testing.T) { +func TestCopyFunction(t *testing.T) { for name, src := range genTestEncodingValuesFunction() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigFunction(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigFunction() - CopyOrigFunction(dest, src) + dest := NewFunction() + CopyFunction(dest, src) assert.Equal(t, src, dest) - CopyOrigFunction(dest, dest) + CopyFunction(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigFunctionUnknown(t *testing.T) { +func TestCopyFunctionSlice(t *testing.T) { + src := []Function{} + dest := []Function{} + // Test CopyTo empty + dest = CopyFunctionSlice(dest, src) + assert.Equal(t, []Function{}, dest) + + // Test CopyTo larger slice + src = GenTestFunctionSlice() + dest = CopyFunctionSlice(dest, src) + assert.Equal(t, GenTestFunctionSlice(), dest) + + // Test CopyTo same size slice + dest = CopyFunctionSlice(dest, src) + assert.Equal(t, GenTestFunctionSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyFunctionSlice(dest, []Function{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyFunctionSlice(dest, src) + assert.Equal(t, GenTestFunctionSlice(), dest) +} + +func TestCopyFunctionPtrSlice(t *testing.T) { + src := []*Function{} + dest := []*Function{} + // Test CopyTo empty + dest = CopyFunctionPtrSlice(dest, src) + assert.Equal(t, []*Function{}, dest) + + // Test CopyTo larger slice + src = GenTestFunctionPtrSlice() + dest = CopyFunctionPtrSlice(dest, src) + assert.Equal(t, GenTestFunctionPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyFunctionPtrSlice(dest, src) + assert.Equal(t, GenTestFunctionPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyFunctionPtrSlice(dest, []*Function{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyFunctionPtrSlice(dest, src) + assert.Equal(t, GenTestFunctionPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONFunctionUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigFunction() - UnmarshalJSONOrigFunction(dest, iter) + dest := NewFunction() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigFunction(), dest) + assert.Equal(t, NewFunction(), dest) } -func TestMarshalAndUnmarshalJSONOrigFunction(t *testing.T) { +func TestMarshalAndUnmarshalJSONFunction(t *testing.T) { for name, src := range genTestEncodingValuesFunction() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigFunction(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigFunction(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigFunction() - UnmarshalJSONOrigFunction(dest, iter) + dest := NewFunction() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigFunction(dest, true) + DeleteFunction(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigFunctionFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoFunctionFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesFunction() { t.Run(name, func(t *testing.T) { - dest := NewOrigFunction() - require.Error(t, UnmarshalProtoOrigFunction(dest, buf)) + dest := NewFunction() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigFunctionUnknown(t *testing.T) { - dest := NewOrigFunction() +func TestMarshalAndUnmarshalProtoFunctionUnknown(t *testing.T) { + dest := NewFunction() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigFunction(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigFunction(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewFunction(), dest) } -func TestMarshalAndUnmarshalProtoOrigFunction(t *testing.T) { +func TestMarshalAndUnmarshalProtoFunction(t *testing.T) { for name, src := range genTestEncodingValuesFunction() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigFunction(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigFunction(src)) - gotSize := MarshalProtoOrigFunction(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigFunction() - require.NoError(t, UnmarshalProtoOrigFunction(dest, buf)) + dest := NewFunction() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigFunction(dest, true) + DeleteFunction(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigFunction(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufFunction(t *testing.T) { for name, src := range genTestEncodingValuesFunction() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigFunction(src)) - gotSize := MarshalProtoOrigFunction(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Function{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufFunction(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigFunction() - require.NoError(t, UnmarshalProtoOrigFunction(dest, goBuf)) + dest := NewFunction() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -151,9 +200,9 @@ func genTestFailingUnmarshalProtoValuesFunction() map[string][]byte { } } -func genTestEncodingValuesFunction() map[string]*otlpprofiles.Function { - return map[string]*otlpprofiles.Function{ - "empty": NewOrigFunction(), +func genTestEncodingValuesFunction() map[string]*Function { + return map[string]*Function{ + "empty": NewFunction(), "NameStrindex/test": {NameStrindex: int32(13)}, "SystemNameStrindex/test": {SystemNameStrindex: int32(13)}, "FilenameStrindex/test": {FilenameStrindex: int32(13)}, diff --git a/pdata/internal/generated_proto_gauge.go b/pdata/internal/generated_proto_gauge.go new file mode 100644 index 00000000000..e39eb2e7958 --- /dev/null +++ b/pdata/internal/generated_proto_gauge.go @@ -0,0 +1,245 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Gauge represents the type of a numeric metric that always exports the "current value" for every data point. +type Gauge struct { + DataPoints []*NumberDataPoint +} + +var ( + protoPoolGauge = sync.Pool{ + New: func() any { + return &Gauge{} + }, + } +) + +func NewGauge() *Gauge { + if !UseProtoPooling.IsEnabled() { + return &Gauge{} + } + return protoPoolGauge.Get().(*Gauge) +} + +func DeleteGauge(orig *Gauge, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.DataPoints { + DeleteNumberDataPoint(orig.DataPoints[i], true) + } + + orig.Reset() + if nullable { + protoPoolGauge.Put(orig) + } +} + +func CopyGauge(dest, src *Gauge) *Gauge { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewGauge() + } + dest.DataPoints = CopyNumberDataPointPtrSlice(dest.DataPoints, src.DataPoints) + + return dest +} + +func CopyGaugeSlice(dest, src []Gauge) []Gauge { + var newDest []Gauge + if cap(dest) < len(src) { + newDest = make([]Gauge, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteGauge(&dest[i], false) + } + } + for i := range src { + CopyGauge(&newDest[i], &src[i]) + } + return newDest +} + +func CopyGaugePtrSlice(dest, src []*Gauge) []*Gauge { + var newDest []*Gauge + if cap(dest) < len(src) { + newDest = make([]*Gauge, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewGauge() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteGauge(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewGauge() + } + } + for i := range src { + CopyGauge(newDest[i], src[i]) + } + return newDest +} + +func (orig *Gauge) Reset() { + *orig = Gauge{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Gauge) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.DataPoints) > 0 { + dest.WriteObjectField("dataPoints") + dest.WriteArrayStart() + orig.DataPoints[0].MarshalJSON(dest) + for i := 1; i < len(orig.DataPoints); i++ { + dest.WriteMore() + orig.DataPoints[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Gauge) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "dataPoints", "data_points": + for iter.ReadArray() { + orig.DataPoints = append(orig.DataPoints, NewNumberDataPoint()) + orig.DataPoints[len(orig.DataPoints)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *Gauge) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.DataPoints { + l = orig.DataPoints[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *Gauge) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.DataPoints) - 1; i >= 0; i-- { + l = orig.DataPoints[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *Gauge) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DataPoints = append(orig.DataPoints, NewNumberDataPoint()) + err = orig.DataPoints[len(orig.DataPoints)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestGauge() *Gauge { + orig := NewGauge() + orig.DataPoints = []*NumberDataPoint{{}, GenTestNumberDataPoint()} + return orig +} + +func GenTestGaugePtrSlice() []*Gauge { + orig := make([]*Gauge, 5) + orig[0] = NewGauge() + orig[1] = GenTestGauge() + orig[2] = NewGauge() + orig[3] = GenTestGauge() + orig[4] = NewGauge() + return orig +} + +func GenTestGaugeSlice() []Gauge { + orig := make([]Gauge, 5) + orig[1] = *GenTestGauge() + orig[3] = *GenTestGauge() + return orig +} diff --git a/pdata/internal/generated_wrapper_gauge_test.go b/pdata/internal/generated_proto_gauge_test.go similarity index 55% rename from pdata/internal/generated_wrapper_gauge_test.go rename to pdata/internal/generated_proto_gauge_test.go index 1d9028ced7d..09f593e78df 100644 --- a/pdata/internal/generated_wrapper_gauge_test.go +++ b/pdata/internal/generated_proto_gauge_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigGauge(t *testing.T) { +func TestCopyGauge(t *testing.T) { for name, src := range genTestEncodingValuesGauge() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigGauge(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigGauge() - CopyOrigGauge(dest, src) + dest := NewGauge() + CopyGauge(dest, src) assert.Equal(t, src, dest) - CopyOrigGauge(dest, dest) + CopyGauge(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigGaugeUnknown(t *testing.T) { +func TestCopyGaugeSlice(t *testing.T) { + src := []Gauge{} + dest := []Gauge{} + // Test CopyTo empty + dest = CopyGaugeSlice(dest, src) + assert.Equal(t, []Gauge{}, dest) + + // Test CopyTo larger slice + src = GenTestGaugeSlice() + dest = CopyGaugeSlice(dest, src) + assert.Equal(t, GenTestGaugeSlice(), dest) + + // Test CopyTo same size slice + dest = CopyGaugeSlice(dest, src) + assert.Equal(t, GenTestGaugeSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyGaugeSlice(dest, []Gauge{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyGaugeSlice(dest, src) + assert.Equal(t, GenTestGaugeSlice(), dest) +} + +func TestCopyGaugePtrSlice(t *testing.T) { + src := []*Gauge{} + dest := []*Gauge{} + // Test CopyTo empty + dest = CopyGaugePtrSlice(dest, src) + assert.Equal(t, []*Gauge{}, dest) + + // Test CopyTo larger slice + src = GenTestGaugePtrSlice() + dest = CopyGaugePtrSlice(dest, src) + assert.Equal(t, GenTestGaugePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyGaugePtrSlice(dest, src) + assert.Equal(t, GenTestGaugePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyGaugePtrSlice(dest, []*Gauge{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyGaugePtrSlice(dest, src) + assert.Equal(t, GenTestGaugePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONGaugeUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigGauge() - UnmarshalJSONOrigGauge(dest, iter) + dest := NewGauge() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigGauge(), dest) + assert.Equal(t, NewGauge(), dest) } -func TestMarshalAndUnmarshalJSONOrigGauge(t *testing.T) { +func TestMarshalAndUnmarshalJSONGauge(t *testing.T) { for name, src := range genTestEncodingValuesGauge() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigGauge(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigGauge(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigGauge() - UnmarshalJSONOrigGauge(dest, iter) + dest := NewGauge() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigGauge(dest, true) + DeleteGauge(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigGaugeFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoGaugeFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesGauge() { t.Run(name, func(t *testing.T) { - dest := NewOrigGauge() - require.Error(t, UnmarshalProtoOrigGauge(dest, buf)) + dest := NewGauge() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigGaugeUnknown(t *testing.T) { - dest := NewOrigGauge() +func TestMarshalAndUnmarshalProtoGaugeUnknown(t *testing.T) { + dest := NewGauge() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigGauge(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigGauge(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewGauge(), dest) } -func TestMarshalAndUnmarshalProtoOrigGauge(t *testing.T) { +func TestMarshalAndUnmarshalProtoGauge(t *testing.T) { for name, src := range genTestEncodingValuesGauge() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigGauge(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigGauge(src)) - gotSize := MarshalProtoOrigGauge(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigGauge() - require.NoError(t, UnmarshalProtoOrigGauge(dest, buf)) + dest := NewGauge() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigGauge(dest, true) + DeleteGauge(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigGauge(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufGauge(t *testing.T) { for name, src := range genTestEncodingValuesGauge() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigGauge(src)) - gotSize := MarshalProtoOrigGauge(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.Gauge{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufGauge(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigGauge() - require.NoError(t, UnmarshalProtoOrigGauge(dest, goBuf)) + dest := NewGauge() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -145,9 +194,9 @@ func genTestFailingUnmarshalProtoValuesGauge() map[string][]byte { } } -func genTestEncodingValuesGauge() map[string]*otlpmetrics.Gauge { - return map[string]*otlpmetrics.Gauge{ - "empty": NewOrigGauge(), - "DataPoints/default_and_test": {DataPoints: []*otlpmetrics.NumberDataPoint{{}, GenTestOrigNumberDataPoint()}}, +func genTestEncodingValuesGauge() map[string]*Gauge { + return map[string]*Gauge{ + "empty": NewGauge(), + "DataPoints/test": {DataPoints: []*NumberDataPoint{{}, GenTestNumberDataPoint()}}, } } diff --git a/pdata/internal/generated_proto_histogram.go b/pdata/internal/generated_proto_histogram.go new file mode 100644 index 00000000000..b35b328f913 --- /dev/null +++ b/pdata/internal/generated_proto_histogram.go @@ -0,0 +1,276 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Histogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported measurements over a time interval. +type Histogram struct { + DataPoints []*HistogramDataPoint + AggregationTemporality AggregationTemporality +} + +var ( + protoPoolHistogram = sync.Pool{ + New: func() any { + return &Histogram{} + }, + } +) + +func NewHistogram() *Histogram { + if !UseProtoPooling.IsEnabled() { + return &Histogram{} + } + return protoPoolHistogram.Get().(*Histogram) +} + +func DeleteHistogram(orig *Histogram, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.DataPoints { + DeleteHistogramDataPoint(orig.DataPoints[i], true) + } + + orig.Reset() + if nullable { + protoPoolHistogram.Put(orig) + } +} + +func CopyHistogram(dest, src *Histogram) *Histogram { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewHistogram() + } + dest.DataPoints = CopyHistogramDataPointPtrSlice(dest.DataPoints, src.DataPoints) + + dest.AggregationTemporality = src.AggregationTemporality + + return dest +} + +func CopyHistogramSlice(dest, src []Histogram) []Histogram { + var newDest []Histogram + if cap(dest) < len(src) { + newDest = make([]Histogram, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteHistogram(&dest[i], false) + } + } + for i := range src { + CopyHistogram(&newDest[i], &src[i]) + } + return newDest +} + +func CopyHistogramPtrSlice(dest, src []*Histogram) []*Histogram { + var newDest []*Histogram + if cap(dest) < len(src) { + newDest = make([]*Histogram, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewHistogram() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteHistogram(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewHistogram() + } + } + for i := range src { + CopyHistogram(newDest[i], src[i]) + } + return newDest +} + +func (orig *Histogram) Reset() { + *orig = Histogram{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Histogram) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.DataPoints) > 0 { + dest.WriteObjectField("dataPoints") + dest.WriteArrayStart() + orig.DataPoints[0].MarshalJSON(dest) + for i := 1; i < len(orig.DataPoints); i++ { + dest.WriteMore() + orig.DataPoints[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + + if int32(orig.AggregationTemporality) != 0 { + dest.WriteObjectField("aggregationTemporality") + dest.WriteInt32(int32(orig.AggregationTemporality)) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Histogram) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "dataPoints", "data_points": + for iter.ReadArray() { + orig.DataPoints = append(orig.DataPoints, NewHistogramDataPoint()) + orig.DataPoints[len(orig.DataPoints)-1].UnmarshalJSON(iter) + } + + case "aggregationTemporality", "aggregation_temporality": + orig.AggregationTemporality = AggregationTemporality(iter.ReadEnumValue(AggregationTemporality_value)) + default: + iter.Skip() + } + } +} + +func (orig *Histogram) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.DataPoints { + l = orig.DataPoints[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + if orig.AggregationTemporality != 0 { + n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) + } + return n +} + +func (orig *Histogram) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.DataPoints) - 1; i >= 0; i-- { + l = orig.DataPoints[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + if orig.AggregationTemporality != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) + pos-- + buf[pos] = 0x10 + } + return len(buf) - pos +} + +func (orig *Histogram) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DataPoints = append(orig.DataPoints, NewHistogramDataPoint()) + err = orig.DataPoints[len(orig.DataPoints)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.AggregationTemporality = AggregationTemporality(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestHistogram() *Histogram { + orig := NewHistogram() + orig.DataPoints = []*HistogramDataPoint{{}, GenTestHistogramDataPoint()} + orig.AggregationTemporality = AggregationTemporality(13) + return orig +} + +func GenTestHistogramPtrSlice() []*Histogram { + orig := make([]*Histogram, 5) + orig[0] = NewHistogram() + orig[1] = GenTestHistogram() + orig[2] = NewHistogram() + orig[3] = GenTestHistogram() + orig[4] = NewHistogram() + return orig +} + +func GenTestHistogramSlice() []Histogram { + orig := make([]Histogram, 5) + orig[1] = *GenTestHistogram() + orig[3] = *GenTestHistogram() + return orig +} diff --git a/pdata/internal/generated_wrapper_histogram_test.go b/pdata/internal/generated_proto_histogram_test.go similarity index 53% rename from pdata/internal/generated_wrapper_histogram_test.go rename to pdata/internal/generated_proto_histogram_test.go index 191e02ee7d4..92704eed114 100644 --- a/pdata/internal/generated_wrapper_histogram_test.go +++ b/pdata/internal/generated_proto_histogram_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigHistogram(t *testing.T) { +func TestCopyHistogram(t *testing.T) { for name, src := range genTestEncodingValuesHistogram() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigHistogram(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigHistogram() - CopyOrigHistogram(dest, src) + dest := NewHistogram() + CopyHistogram(dest, src) assert.Equal(t, src, dest) - CopyOrigHistogram(dest, dest) + CopyHistogram(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigHistogramUnknown(t *testing.T) { +func TestCopyHistogramSlice(t *testing.T) { + src := []Histogram{} + dest := []Histogram{} + // Test CopyTo empty + dest = CopyHistogramSlice(dest, src) + assert.Equal(t, []Histogram{}, dest) + + // Test CopyTo larger slice + src = GenTestHistogramSlice() + dest = CopyHistogramSlice(dest, src) + assert.Equal(t, GenTestHistogramSlice(), dest) + + // Test CopyTo same size slice + dest = CopyHistogramSlice(dest, src) + assert.Equal(t, GenTestHistogramSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyHistogramSlice(dest, []Histogram{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyHistogramSlice(dest, src) + assert.Equal(t, GenTestHistogramSlice(), dest) +} + +func TestCopyHistogramPtrSlice(t *testing.T) { + src := []*Histogram{} + dest := []*Histogram{} + // Test CopyTo empty + dest = CopyHistogramPtrSlice(dest, src) + assert.Equal(t, []*Histogram{}, dest) + + // Test CopyTo larger slice + src = GenTestHistogramPtrSlice() + dest = CopyHistogramPtrSlice(dest, src) + assert.Equal(t, GenTestHistogramPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyHistogramPtrSlice(dest, src) + assert.Equal(t, GenTestHistogramPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyHistogramPtrSlice(dest, []*Histogram{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyHistogramPtrSlice(dest, src) + assert.Equal(t, GenTestHistogramPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONHistogramUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigHistogram() - UnmarshalJSONOrigHistogram(dest, iter) + dest := NewHistogram() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigHistogram(), dest) + assert.Equal(t, NewHistogram(), dest) } -func TestMarshalAndUnmarshalJSONOrigHistogram(t *testing.T) { +func TestMarshalAndUnmarshalJSONHistogram(t *testing.T) { for name, src := range genTestEncodingValuesHistogram() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigHistogram(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigHistogram(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigHistogram() - UnmarshalJSONOrigHistogram(dest, iter) + dest := NewHistogram() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigHistogram(dest, true) + DeleteHistogram(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigHistogramFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoHistogramFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesHistogram() { t.Run(name, func(t *testing.T) { - dest := NewOrigHistogram() - require.Error(t, UnmarshalProtoOrigHistogram(dest, buf)) + dest := NewHistogram() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigHistogramUnknown(t *testing.T) { - dest := NewOrigHistogram() +func TestMarshalAndUnmarshalProtoHistogramUnknown(t *testing.T) { + dest := NewHistogram() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigHistogram(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigHistogram(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewHistogram(), dest) } -func TestMarshalAndUnmarshalProtoOrigHistogram(t *testing.T) { +func TestMarshalAndUnmarshalProtoHistogram(t *testing.T) { for name, src := range genTestEncodingValuesHistogram() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigHistogram(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigHistogram(src)) - gotSize := MarshalProtoOrigHistogram(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigHistogram() - require.NoError(t, UnmarshalProtoOrigHistogram(dest, buf)) + dest := NewHistogram() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigHistogram(dest, true) + DeleteHistogram(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigHistogram(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufHistogram(t *testing.T) { for name, src := range genTestEncodingValuesHistogram() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigHistogram(src)) - gotSize := MarshalProtoOrigHistogram(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.Histogram{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufHistogram(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigHistogram() - require.NoError(t, UnmarshalProtoOrigHistogram(dest, goBuf)) + dest := NewHistogram() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,10 +196,10 @@ func genTestFailingUnmarshalProtoValuesHistogram() map[string][]byte { } } -func genTestEncodingValuesHistogram() map[string]*otlpmetrics.Histogram { - return map[string]*otlpmetrics.Histogram{ - "empty": NewOrigHistogram(), - "DataPoints/default_and_test": {DataPoints: []*otlpmetrics.HistogramDataPoint{{}, GenTestOrigHistogramDataPoint()}}, - "AggregationTemporality/test": {AggregationTemporality: otlpmetrics.AggregationTemporality(13)}, +func genTestEncodingValuesHistogram() map[string]*Histogram { + return map[string]*Histogram{ + "empty": NewHistogram(), + "DataPoints/test": {DataPoints: []*HistogramDataPoint{{}, GenTestHistogramDataPoint()}}, + "AggregationTemporality/test": {AggregationTemporality: AggregationTemporality(13)}, } } diff --git a/pdata/internal/generated_wrapper_histogramdatapoint.go b/pdata/internal/generated_proto_histogramdatapoint.go similarity index 57% rename from pdata/internal/generated_wrapper_histogramdatapoint.go rename to pdata/internal/generated_proto_histogramdatapoint.go index baffb2e190d..42953b3f91d 100644 --- a/pdata/internal/generated_wrapper_histogramdatapoint.go +++ b/pdata/internal/generated_proto_histogramdatapoint.go @@ -12,45 +12,112 @@ import ( "math" "sync" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "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 + Flags uint32 + Min_ any + Max_ any +} + var ( protoPoolHistogramDataPoint = sync.Pool{ New: func() any { - return &otlpmetrics.HistogramDataPoint{} + return &HistogramDataPoint{} }, } ProtoPoolHistogramDataPoint_Sum = sync.Pool{ New: func() any { - return &otlpmetrics.HistogramDataPoint_Sum{} + return &HistogramDataPoint_Sum{} }, } ProtoPoolHistogramDataPoint_Min = sync.Pool{ New: func() any { - return &otlpmetrics.HistogramDataPoint_Min{} + return &HistogramDataPoint_Min{} }, } ProtoPoolHistogramDataPoint_Max = sync.Pool{ New: func() any { - return &otlpmetrics.HistogramDataPoint_Max{} + return &HistogramDataPoint_Max{} }, } ) -func NewOrigHistogramDataPoint() *otlpmetrics.HistogramDataPoint { +func NewHistogramDataPoint() *HistogramDataPoint { if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.HistogramDataPoint{} + return &HistogramDataPoint{} } - return protoPoolHistogramDataPoint.Get().(*otlpmetrics.HistogramDataPoint) + return protoPoolHistogramDataPoint.Get().(*HistogramDataPoint) } -func DeleteOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, nullable bool) { +func DeleteHistogramDataPoint(orig *HistogramDataPoint, nullable bool) { if orig == nil { return } @@ -61,10 +128,10 @@ func DeleteOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, nullable } for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } switch ov := orig.Sum_.(type) { - case *otlpmetrics.HistogramDataPoint_Sum: + case *HistogramDataPoint_Sum: if UseProtoPooling.IsEnabled() { ov.Sum = float64(0) ProtoPoolHistogramDataPoint_Sum.Put(ov) @@ -72,10 +139,10 @@ func DeleteOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, nullable } for i := range orig.Exemplars { - DeleteOrigExemplar(&orig.Exemplars[i], false) + DeleteExemplar(&orig.Exemplars[i], false) } switch ov := orig.Min_.(type) { - case *otlpmetrics.HistogramDataPoint_Min: + case *HistogramDataPoint_Min: if UseProtoPooling.IsEnabled() { ov.Min = float64(0) ProtoPoolHistogramDataPoint_Min.Put(ov) @@ -83,7 +150,7 @@ func DeleteOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, nullable } switch ov := orig.Max_.(type) { - case *otlpmetrics.HistogramDataPoint_Max: + case *HistogramDataPoint_Max: if UseProtoPooling.IsEnabled() { ov.Max = float64(0) ProtoPoolHistogramDataPoint_Max.Put(ov) @@ -97,77 +164,140 @@ func DeleteOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, nullable } } -func CopyOrigHistogramDataPoint(dest, src *otlpmetrics.HistogramDataPoint) { +func CopyHistogramDataPoint(dest, src *HistogramDataPoint) *HistogramDataPoint { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil } - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + if dest == nil { + dest = NewHistogramDataPoint() + } + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + dest.StartTimeUnixNano = src.StartTimeUnixNano + dest.TimeUnixNano = src.TimeUnixNano + dest.Count = src.Count - if srcSum, ok := src.Sum_.(*otlpmetrics.HistogramDataPoint_Sum); ok { - destSum, ok := dest.Sum_.(*otlpmetrics.HistogramDataPoint_Sum) - if !ok { - destSum = &otlpmetrics.HistogramDataPoint_Sum{} - dest.Sum_ = destSum + + 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) } - destSum.Sum = srcSum.Sum - } else { + ov.Sum = t.Sum + dest.Sum_ = ov + default: dest.Sum_ = nil } - dest.BucketCounts = CopyOrigUint64Slice(dest.BucketCounts, src.BucketCounts) - dest.ExplicitBounds = CopyOrigFloat64Slice(dest.ExplicitBounds, src.ExplicitBounds) - dest.Exemplars = CopyOrigExemplarSlice(dest.Exemplars, src.Exemplars) + + 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 srcMin, ok := src.Min_.(*otlpmetrics.HistogramDataPoint_Min); ok { - destMin, ok := dest.Min_.(*otlpmetrics.HistogramDataPoint_Min) - if !ok { - destMin = &otlpmetrics.HistogramDataPoint_Min{} - dest.Min_ = destMin + + 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) } - destMin.Min = srcMin.Min - } else { + ov.Min = t.Min + dest.Min_ = ov + default: dest.Min_ = nil } - if srcMax, ok := src.Max_.(*otlpmetrics.HistogramDataPoint_Max); ok { - destMax, ok := dest.Max_.(*otlpmetrics.HistogramDataPoint_Max) - if !ok { - destMax = &otlpmetrics.HistogramDataPoint_Max{} - dest.Max_ = destMax + + 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) } - destMax.Max = srcMax.Max - } else { + ov.Max = t.Max + dest.Max_ = ov + default: dest.Max_ = nil } + + return dest } -func GenTestOrigHistogramDataPoint() *otlpmetrics.HistogramDataPoint { - orig := NewOrigHistogramDataPoint() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.StartTimeUnixNano = 1234567890 - orig.TimeUnixNano = 1234567890 - orig.Count = uint64(13) - orig.Sum_ = &otlpmetrics.HistogramDataPoint_Sum{Sum: float64(3.1415926)} - orig.BucketCounts = GenerateOrigTestUint64Slice() - orig.ExplicitBounds = GenerateOrigTestFloat64Slice() - orig.Exemplars = GenerateOrigTestExemplarSlice() - orig.Flags = 1 - orig.Min_ = &otlpmetrics.HistogramDataPoint_Min{Min: float64(3.1415926)} - orig.Max_ = &otlpmetrics.HistogramDataPoint_Max{Max: float64(3.1415926)} - return orig +func CopyHistogramDataPointSlice(dest, src []HistogramDataPoint) []HistogramDataPoint { + var newDest []HistogramDataPoint + if cap(dest) < len(src) { + newDest = make([]HistogramDataPoint, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteHistogramDataPoint(&dest[i], false) + } + } + for i := range src { + CopyHistogramDataPoint(&newDest[i], &src[i]) + } + return newDest +} + +func CopyHistogramDataPointPtrSlice(dest, src []*HistogramDataPoint) []*HistogramDataPoint { + var newDest []*HistogramDataPoint + if cap(dest) < len(src) { + newDest = make([]*HistogramDataPoint, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewHistogramDataPoint() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteHistogramDataPoint(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewHistogramDataPoint() + } + } + for i := range src { + CopyHistogramDataPoint(newDest[i], src[i]) + } + return newDest +} + +func (orig *HistogramDataPoint) Reset() { + *orig = HistogramDataPoint{} } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, dest *json.Stream) { +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *HistogramDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -183,7 +313,7 @@ func MarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, des dest.WriteObjectField("count") dest.WriteUint64(orig.Count) } - if orig, ok := orig.Sum_.(*otlpmetrics.HistogramDataPoint_Sum); ok { + if orig, ok := orig.Sum_.(*HistogramDataPoint_Sum); ok { dest.WriteObjectField("sum") dest.WriteFloat64(orig.Sum) } @@ -210,10 +340,10 @@ func MarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, des if len(orig.Exemplars) > 0 { dest.WriteObjectField("exemplars") dest.WriteArrayStart() - MarshalJSONOrigExemplar(&orig.Exemplars[0], dest) + orig.Exemplars[0].MarshalJSON(dest) for i := 1; i < len(orig.Exemplars); i++ { dest.WriteMore() - MarshalJSONOrigExemplar(&orig.Exemplars[i], dest) + orig.Exemplars[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -221,25 +351,25 @@ func MarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, des dest.WriteObjectField("flags") dest.WriteUint32(orig.Flags) } - if orig, ok := orig.Min_.(*otlpmetrics.HistogramDataPoint_Min); ok { + if orig, ok := orig.Min_.(*HistogramDataPoint_Min); ok { dest.WriteObjectField("min") dest.WriteFloat64(orig.Min) } - if orig, ok := orig.Max_.(*otlpmetrics.HistogramDataPoint_Max); ok { + if orig, ok := orig.Max_.(*HistogramDataPoint_Max); ok { dest.WriteObjectField("max") dest.WriteFloat64(orig.Max) } dest.WriteObjectEnd() } -// UnmarshalJSONOrigHistogramDataPoint unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *HistogramDataPoint) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "startTimeUnixNano", "start_time_unix_nano": @@ -250,11 +380,11 @@ func UnmarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, i orig.Count = iter.ReadUint64() case "sum": { - var ov *otlpmetrics.HistogramDataPoint_Sum + var ov *HistogramDataPoint_Sum if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.HistogramDataPoint_Sum{} + ov = &HistogramDataPoint_Sum{} } else { - ov = ProtoPoolHistogramDataPoint_Sum.Get().(*otlpmetrics.HistogramDataPoint_Sum) + ov = ProtoPoolHistogramDataPoint_Sum.Get().(*HistogramDataPoint_Sum) } ov.Sum = iter.ReadFloat64() orig.Sum_ = ov @@ -272,19 +402,19 @@ func UnmarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, i case "exemplars": for iter.ReadArray() { - orig.Exemplars = append(orig.Exemplars, otlpmetrics.Exemplar{}) - UnmarshalJSONOrigExemplar(&orig.Exemplars[len(orig.Exemplars)-1], iter) + orig.Exemplars = append(orig.Exemplars, Exemplar{}) + orig.Exemplars[len(orig.Exemplars)-1].UnmarshalJSON(iter) } case "flags": orig.Flags = iter.ReadUint32() case "min": { - var ov *otlpmetrics.HistogramDataPoint_Min + var ov *HistogramDataPoint_Min if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.HistogramDataPoint_Min{} + ov = &HistogramDataPoint_Min{} } else { - ov = ProtoPoolHistogramDataPoint_Min.Get().(*otlpmetrics.HistogramDataPoint_Min) + ov = ProtoPoolHistogramDataPoint_Min.Get().(*HistogramDataPoint_Min) } ov.Min = iter.ReadFloat64() orig.Min_ = ov @@ -292,11 +422,11 @@ func UnmarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, i case "max": { - var ov *otlpmetrics.HistogramDataPoint_Max + var ov *HistogramDataPoint_Max if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.HistogramDataPoint_Max{} + ov = &HistogramDataPoint_Max{} } else { - ov = ProtoPoolHistogramDataPoint_Max.Get().(*otlpmetrics.HistogramDataPoint_Max) + ov = ProtoPoolHistogramDataPoint_Max.Get().(*HistogramDataPoint_Max) } ov.Max = iter.ReadFloat64() orig.Max_ = ov @@ -308,12 +438,12 @@ func UnmarshalJSONOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, i } } -func SizeProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint) int { +func (orig *HistogramDataPoint) SizeProto() int { var n int var l int _ = l for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.StartTimeUnixNano != 0 { @@ -325,7 +455,7 @@ func SizeProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint) int { if orig.Count != 0 { n += 9 } - if orig, ok := orig.Sum_.(*otlpmetrics.HistogramDataPoint_Sum); ok { + if orig, ok := orig.Sum_.(*HistogramDataPoint_Sum); ok { _ = orig n += 9 } @@ -340,29 +470,29 @@ func SizeProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint) int { n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.Exemplars { - l = SizeProtoOrigExemplar(&orig.Exemplars[i]) + l = orig.Exemplars[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.Flags != 0 { n += 1 + proto.Sov(uint64(orig.Flags)) } - if orig, ok := orig.Min_.(*otlpmetrics.HistogramDataPoint_Min); ok { + if orig, ok := orig.Min_.(*HistogramDataPoint_Min); ok { _ = orig n += 9 } - if orig, ok := orig.Max_.(*otlpmetrics.HistogramDataPoint_Max); ok { + if orig, ok := orig.Max_.(*HistogramDataPoint_Max); ok { _ = orig n += 9 } return n } -func MarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, buf []byte) int { +func (orig *HistogramDataPoint) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -386,7 +516,7 @@ func MarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, bu pos-- buf[pos] = 0x21 } - if orig, ok := orig.Sum_.(*otlpmetrics.HistogramDataPoint_Sum); ok { + if orig, ok := orig.Sum_.(*HistogramDataPoint_Sum); ok { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Sum)) pos-- @@ -413,7 +543,7 @@ func MarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, bu buf[pos] = 0x3a } for i := len(orig.Exemplars) - 1; i >= 0; i-- { - l = MarshalProtoOrigExemplar(&orig.Exemplars[i], buf[:pos]) + l = orig.Exemplars[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -424,13 +554,13 @@ func MarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, bu pos-- buf[pos] = 0x50 } - if orig, ok := orig.Min_.(*otlpmetrics.HistogramDataPoint_Min); ok { + if orig, ok := orig.Min_.(*HistogramDataPoint_Min); ok { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Min)) pos-- buf[pos] = 0x59 } - if orig, ok := orig.Max_.(*otlpmetrics.HistogramDataPoint_Max); ok { + if orig, ok := orig.Max_.(*HistogramDataPoint_Max); ok { pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Max)) pos-- @@ -439,7 +569,7 @@ func MarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, bu return len(buf) - pos } -func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, buf []byte) error { +func (orig *HistogramDataPoint) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -464,8 +594,8 @@ func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -515,11 +645,11 @@ func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, if err != nil { return err } - var ov *otlpmetrics.HistogramDataPoint_Sum + var ov *HistogramDataPoint_Sum if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.HistogramDataPoint_Sum{} + ov = &HistogramDataPoint_Sum{} } else { - ov = ProtoPoolHistogramDataPoint_Sum.Get().(*otlpmetrics.HistogramDataPoint_Sum) + ov = ProtoPoolHistogramDataPoint_Sum.Get().(*HistogramDataPoint_Sum) } ov.Sum = math.Float64frombits(num) orig.Sum_ = ov @@ -598,8 +728,8 @@ func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, return err } startPos := pos - length - orig.Exemplars = append(orig.Exemplars, otlpmetrics.Exemplar{}) - err = UnmarshalProtoOrigExemplar(&orig.Exemplars[len(orig.Exemplars)-1], buf[startPos:pos]) + orig.Exemplars = append(orig.Exemplars, Exemplar{}) + err = orig.Exemplars[len(orig.Exemplars)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -625,11 +755,11 @@ func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, if err != nil { return err } - var ov *otlpmetrics.HistogramDataPoint_Min + var ov *HistogramDataPoint_Min if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.HistogramDataPoint_Min{} + ov = &HistogramDataPoint_Min{} } else { - ov = ProtoPoolHistogramDataPoint_Min.Get().(*otlpmetrics.HistogramDataPoint_Min) + ov = ProtoPoolHistogramDataPoint_Min.Get().(*HistogramDataPoint_Min) } ov.Min = math.Float64frombits(num) orig.Min_ = ov @@ -643,11 +773,11 @@ func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, if err != nil { return err } - var ov *otlpmetrics.HistogramDataPoint_Max + var ov *HistogramDataPoint_Max if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.HistogramDataPoint_Max{} + ov = &HistogramDataPoint_Max{} } else { - ov = ProtoPoolHistogramDataPoint_Max.Get().(*otlpmetrics.HistogramDataPoint_Max) + ov = ProtoPoolHistogramDataPoint_Max.Get().(*HistogramDataPoint_Max) } ov.Max = math.Float64frombits(num) orig.Max_ = ov @@ -660,3 +790,36 @@ func UnmarshalProtoOrigHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, } return nil } + +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.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)} + return orig +} + +func GenTestHistogramDataPointPtrSlice() []*HistogramDataPoint { + orig := make([]*HistogramDataPoint, 5) + orig[0] = NewHistogramDataPoint() + orig[1] = GenTestHistogramDataPoint() + orig[2] = NewHistogramDataPoint() + orig[3] = GenTestHistogramDataPoint() + orig[4] = NewHistogramDataPoint() + return orig +} + +func GenTestHistogramDataPointSlice() []HistogramDataPoint { + orig := make([]HistogramDataPoint, 5) + orig[1] = *GenTestHistogramDataPoint() + orig[3] = *GenTestHistogramDataPoint() + return orig +} diff --git a/pdata/internal/generated_wrapper_histogramdatapoint_test.go b/pdata/internal/generated_proto_histogramdatapoint_test.go similarity index 50% rename from pdata/internal/generated_wrapper_histogramdatapoint_test.go rename to pdata/internal/generated_proto_histogramdatapoint_test.go index 4dbdf5211bb..9f4d54db8df 100644 --- a/pdata/internal/generated_wrapper_histogramdatapoint_test.go +++ b/pdata/internal/generated_proto_histogramdatapoint_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigHistogramDataPoint(t *testing.T) { +func TestCopyHistogramDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesHistogramDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigHistogramDataPoint(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigHistogramDataPoint() - CopyOrigHistogramDataPoint(dest, src) + dest := NewHistogramDataPoint() + CopyHistogramDataPoint(dest, src) assert.Equal(t, src, dest) - CopyOrigHistogramDataPoint(dest, dest) + CopyHistogramDataPoint(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigHistogramDataPointUnknown(t *testing.T) { +func TestCopyHistogramDataPointSlice(t *testing.T) { + src := []HistogramDataPoint{} + dest := []HistogramDataPoint{} + // Test CopyTo empty + dest = CopyHistogramDataPointSlice(dest, src) + assert.Equal(t, []HistogramDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestHistogramDataPointSlice() + dest = CopyHistogramDataPointSlice(dest, src) + assert.Equal(t, GenTestHistogramDataPointSlice(), dest) + + // Test CopyTo same size slice + dest = CopyHistogramDataPointSlice(dest, src) + assert.Equal(t, GenTestHistogramDataPointSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyHistogramDataPointSlice(dest, []HistogramDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyHistogramDataPointSlice(dest, src) + assert.Equal(t, GenTestHistogramDataPointSlice(), dest) +} + +func TestCopyHistogramDataPointPtrSlice(t *testing.T) { + src := []*HistogramDataPoint{} + dest := []*HistogramDataPoint{} + // Test CopyTo empty + dest = CopyHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, []*HistogramDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestHistogramDataPointPtrSlice() + dest = CopyHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestHistogramDataPointPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestHistogramDataPointPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyHistogramDataPointPtrSlice(dest, []*HistogramDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyHistogramDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestHistogramDataPointPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONHistogramDataPointUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigHistogramDataPoint() - UnmarshalJSONOrigHistogramDataPoint(dest, iter) + dest := NewHistogramDataPoint() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigHistogramDataPoint(), dest) + assert.Equal(t, NewHistogramDataPoint(), dest) } -func TestMarshalAndUnmarshalJSONOrigHistogramDataPoint(t *testing.T) { +func TestMarshalAndUnmarshalJSONHistogramDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesHistogramDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigHistogramDataPoint(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigHistogramDataPoint(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigHistogramDataPoint() - UnmarshalJSONOrigHistogramDataPoint(dest, iter) + dest := NewHistogramDataPoint() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigHistogramDataPoint(dest, true) + DeleteHistogramDataPoint(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigHistogramDataPointFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoHistogramDataPointFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesHistogramDataPoint() { t.Run(name, func(t *testing.T) { - dest := NewOrigHistogramDataPoint() - require.Error(t, UnmarshalProtoOrigHistogramDataPoint(dest, buf)) + dest := NewHistogramDataPoint() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigHistogramDataPointUnknown(t *testing.T) { - dest := NewOrigHistogramDataPoint() +func TestMarshalAndUnmarshalProtoHistogramDataPointUnknown(t *testing.T) { + dest := NewHistogramDataPoint() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigHistogramDataPoint(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigHistogramDataPoint(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewHistogramDataPoint(), dest) } -func TestMarshalAndUnmarshalProtoOrigHistogramDataPoint(t *testing.T) { +func TestMarshalAndUnmarshalProtoHistogramDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesHistogramDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigHistogramDataPoint(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigHistogramDataPoint(src)) - gotSize := MarshalProtoOrigHistogramDataPoint(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigHistogramDataPoint() - require.NoError(t, UnmarshalProtoOrigHistogramDataPoint(dest, buf)) + dest := NewHistogramDataPoint() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigHistogramDataPoint(dest, true) + DeleteHistogramDataPoint(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigHistogramDataPoint(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufHistogramDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesHistogramDataPoint() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigHistogramDataPoint(src)) - gotSize := MarshalProtoOrigHistogramDataPoint(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.HistogramDataPoint{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufHistogramDataPoint(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigHistogramDataPoint() - require.NoError(t, UnmarshalProtoOrigHistogramDataPoint(dest, goBuf)) + dest := NewHistogramDataPoint() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -166,19 +214,19 @@ func genTestFailingUnmarshalProtoValuesHistogramDataPoint() map[string][]byte { } } -func genTestEncodingValuesHistogramDataPoint() map[string]*otlpmetrics.HistogramDataPoint { - return map[string]*otlpmetrics.HistogramDataPoint{ - "empty": NewOrigHistogramDataPoint(), - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, - "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, - "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, - "Count/test": {Count: uint64(13)}, "Sum/default": {Sum_: &otlpmetrics.HistogramDataPoint_Sum{Sum: float64(0)}}, - "Sum/test": {Sum_: &otlpmetrics.HistogramDataPoint_Sum{Sum: float64(3.1415926)}}, - "BucketCounts/default_and_test": {BucketCounts: []uint64{uint64(0), uint64(13)}}, - "ExplicitBounds/default_and_test": {ExplicitBounds: []float64{float64(0), float64(3.1415926)}}, - "Exemplars/default_and_test": {Exemplars: []otlpmetrics.Exemplar{{}, *GenTestOrigExemplar()}}, - "Flags/test": {Flags: uint32(13)}, "Min/default": {Min_: &otlpmetrics.HistogramDataPoint_Min{Min: float64(0)}}, - "Min/test": {Min_: &otlpmetrics.HistogramDataPoint_Min{Min: float64(3.1415926)}}, "Max/default": {Max_: &otlpmetrics.HistogramDataPoint_Max{Max: float64(0)}}, - "Max/test": {Max_: &otlpmetrics.HistogramDataPoint_Max{Max: float64(3.1415926)}}, +func genTestEncodingValuesHistogramDataPoint() map[string]*HistogramDataPoint { + return map[string]*HistogramDataPoint{ + "empty": NewHistogramDataPoint(), + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, + "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, + "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, + "Count/test": {Count: uint64(13)}, "Sum/default": {Sum_: &HistogramDataPoint_Sum{Sum: float64(0)}}, + "Sum/test": {Sum_: &HistogramDataPoint_Sum{Sum: float64(3.1415926)}}, + "BucketCounts/test": {BucketCounts: []uint64{uint64(0), uint64(13)}}, + "ExplicitBounds/test": {ExplicitBounds: []float64{float64(0), float64(3.1415926)}}, + "Exemplars/test": {Exemplars: []Exemplar{{}, *GenTestExemplar()}}, + "Flags/test": {Flags: uint32(13)}, "Min/default": {Min_: &HistogramDataPoint_Min{Min: float64(0)}}, + "Min/test": {Min_: &HistogramDataPoint_Min{Min: float64(3.1415926)}}, "Max/default": {Max_: &HistogramDataPoint_Max{Max: float64(0)}}, + "Max/test": {Max_: &HistogramDataPoint_Max{Max: float64(3.1415926)}}, } } diff --git a/pdata/internal/generated_proto_instrumentationscope.go b/pdata/internal/generated_proto_instrumentationscope.go new file mode 100644 index 00000000000..1e64085e946 --- /dev/null +++ b/pdata/internal/generated_proto_instrumentationscope.go @@ -0,0 +1,343 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// InstrumentationScope is a message representing the instrumentation scope information. +type InstrumentationScope struct { + Name string + Version string + Attributes []KeyValue + DroppedAttributesCount uint32 +} + +var ( + protoPoolInstrumentationScope = sync.Pool{ + New: func() any { + return &InstrumentationScope{} + }, + } +) + +func NewInstrumentationScope() *InstrumentationScope { + if !UseProtoPooling.IsEnabled() { + return &InstrumentationScope{} + } + return protoPoolInstrumentationScope.Get().(*InstrumentationScope) +} + +func DeleteInstrumentationScope(orig *InstrumentationScope, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.Attributes { + DeleteKeyValue(&orig.Attributes[i], false) + } + + orig.Reset() + if nullable { + protoPoolInstrumentationScope.Put(orig) + } +} + +func CopyInstrumentationScope(dest, src *InstrumentationScope) *InstrumentationScope { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewInstrumentationScope() + } + dest.Name = src.Name + + dest.Version = src.Version + + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + + dest.DroppedAttributesCount = src.DroppedAttributesCount + + return dest +} + +func CopyInstrumentationScopeSlice(dest, src []InstrumentationScope) []InstrumentationScope { + var newDest []InstrumentationScope + if cap(dest) < len(src) { + newDest = make([]InstrumentationScope, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteInstrumentationScope(&dest[i], false) + } + } + for i := range src { + CopyInstrumentationScope(&newDest[i], &src[i]) + } + return newDest +} + +func CopyInstrumentationScopePtrSlice(dest, src []*InstrumentationScope) []*InstrumentationScope { + var newDest []*InstrumentationScope + if cap(dest) < len(src) { + newDest = make([]*InstrumentationScope, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewInstrumentationScope() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteInstrumentationScope(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewInstrumentationScope() + } + } + for i := range src { + CopyInstrumentationScope(newDest[i], src[i]) + } + return newDest +} + +func (orig *InstrumentationScope) Reset() { + *orig = InstrumentationScope{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *InstrumentationScope) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Name != "" { + dest.WriteObjectField("name") + dest.WriteString(orig.Name) + } + if orig.Version != "" { + dest.WriteObjectField("version") + dest.WriteString(orig.Version) + } + if len(orig.Attributes) > 0 { + dest.WriteObjectField("attributes") + dest.WriteArrayStart() + orig.Attributes[0].MarshalJSON(dest) + for i := 1; i < len(orig.Attributes); i++ { + dest.WriteMore() + orig.Attributes[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.DroppedAttributesCount != uint32(0) { + dest.WriteObjectField("droppedAttributesCount") + dest.WriteUint32(orig.DroppedAttributesCount) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *InstrumentationScope) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "name": + orig.Name = iter.ReadString() + case "version": + orig.Version = iter.ReadString() + case "attributes": + for iter.ReadArray() { + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) + } + + case "droppedAttributesCount", "dropped_attributes_count": + orig.DroppedAttributesCount = iter.ReadUint32() + default: + iter.Skip() + } + } +} + +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 + } + for i := range orig.Attributes { + l = orig.Attributes[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + if orig.DroppedAttributesCount != 0 { + n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) + } + return n +} + +func (orig *InstrumentationScope) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.Name) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Name) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = len(orig.Version) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Version) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + for i := len(orig.Attributes) - 1; i >= 0; i-- { + l = orig.Attributes[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + if orig.DroppedAttributesCount != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) + pos-- + buf[pos] = 0x20 + } + return len(buf) - pos +} + +func (orig *InstrumentationScope) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Name = string(buf[startPos:pos]) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Version = string(buf[startPos:pos]) + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 4: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.DroppedAttributesCount = uint32(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestInstrumentationScope() *InstrumentationScope { + orig := NewInstrumentationScope() + orig.Name = "test_name" + orig.Version = "test_version" + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.DroppedAttributesCount = uint32(13) + return orig +} + +func GenTestInstrumentationScopePtrSlice() []*InstrumentationScope { + orig := make([]*InstrumentationScope, 5) + orig[0] = NewInstrumentationScope() + orig[1] = GenTestInstrumentationScope() + orig[2] = NewInstrumentationScope() + orig[3] = GenTestInstrumentationScope() + orig[4] = NewInstrumentationScope() + return orig +} + +func GenTestInstrumentationScopeSlice() []InstrumentationScope { + orig := make([]InstrumentationScope, 5) + orig[1] = *GenTestInstrumentationScope() + orig[3] = *GenTestInstrumentationScope() + return orig +} diff --git a/pdata/internal/generated_wrapper_instrumentationscope_test.go b/pdata/internal/generated_proto_instrumentationscope_test.go similarity index 53% rename from pdata/internal/generated_wrapper_instrumentationscope_test.go rename to pdata/internal/generated_proto_instrumentationscope_test.go index 4878f47ea62..2af0077e970 100644 --- a/pdata/internal/generated_wrapper_instrumentationscope_test.go +++ b/pdata/internal/generated_proto_instrumentationscope_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigInstrumentationScope(t *testing.T) { +func TestCopyInstrumentationScope(t *testing.T) { for name, src := range genTestEncodingValuesInstrumentationScope() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigInstrumentationScope(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigInstrumentationScope() - CopyOrigInstrumentationScope(dest, src) + dest := NewInstrumentationScope() + CopyInstrumentationScope(dest, src) assert.Equal(t, src, dest) - CopyOrigInstrumentationScope(dest, dest) + CopyInstrumentationScope(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigInstrumentationScopeUnknown(t *testing.T) { +func TestCopyInstrumentationScopeSlice(t *testing.T) { + src := []InstrumentationScope{} + dest := []InstrumentationScope{} + // Test CopyTo empty + dest = CopyInstrumentationScopeSlice(dest, src) + assert.Equal(t, []InstrumentationScope{}, dest) + + // Test CopyTo larger slice + src = GenTestInstrumentationScopeSlice() + dest = CopyInstrumentationScopeSlice(dest, src) + assert.Equal(t, GenTestInstrumentationScopeSlice(), dest) + + // Test CopyTo same size slice + dest = CopyInstrumentationScopeSlice(dest, src) + assert.Equal(t, GenTestInstrumentationScopeSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyInstrumentationScopeSlice(dest, []InstrumentationScope{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyInstrumentationScopeSlice(dest, src) + assert.Equal(t, GenTestInstrumentationScopeSlice(), dest) +} + +func TestCopyInstrumentationScopePtrSlice(t *testing.T) { + src := []*InstrumentationScope{} + dest := []*InstrumentationScope{} + // Test CopyTo empty + dest = CopyInstrumentationScopePtrSlice(dest, src) + assert.Equal(t, []*InstrumentationScope{}, dest) + + // Test CopyTo larger slice + src = GenTestInstrumentationScopePtrSlice() + dest = CopyInstrumentationScopePtrSlice(dest, src) + assert.Equal(t, GenTestInstrumentationScopePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyInstrumentationScopePtrSlice(dest, src) + assert.Equal(t, GenTestInstrumentationScopePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyInstrumentationScopePtrSlice(dest, []*InstrumentationScope{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyInstrumentationScopePtrSlice(dest, src) + assert.Equal(t, GenTestInstrumentationScopePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONInstrumentationScopeUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigInstrumentationScope() - UnmarshalJSONOrigInstrumentationScope(dest, iter) + dest := NewInstrumentationScope() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigInstrumentationScope(), dest) + assert.Equal(t, NewInstrumentationScope(), dest) } -func TestMarshalAndUnmarshalJSONOrigInstrumentationScope(t *testing.T) { +func TestMarshalAndUnmarshalJSONInstrumentationScope(t *testing.T) { for name, src := range genTestEncodingValuesInstrumentationScope() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigInstrumentationScope(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigInstrumentationScope(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigInstrumentationScope() - UnmarshalJSONOrigInstrumentationScope(dest, iter) + dest := NewInstrumentationScope() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigInstrumentationScope(dest, true) + DeleteInstrumentationScope(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigInstrumentationScopeFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoInstrumentationScopeFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesInstrumentationScope() { t.Run(name, func(t *testing.T) { - dest := NewOrigInstrumentationScope() - require.Error(t, UnmarshalProtoOrigInstrumentationScope(dest, buf)) + dest := NewInstrumentationScope() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigInstrumentationScopeUnknown(t *testing.T) { - dest := NewOrigInstrumentationScope() +func TestMarshalAndUnmarshalProtoInstrumentationScopeUnknown(t *testing.T) { + dest := NewInstrumentationScope() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigInstrumentationScope(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigInstrumentationScope(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewInstrumentationScope(), dest) } -func TestMarshalAndUnmarshalProtoOrigInstrumentationScope(t *testing.T) { +func TestMarshalAndUnmarshalProtoInstrumentationScope(t *testing.T) { for name, src := range genTestEncodingValuesInstrumentationScope() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigInstrumentationScope(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigInstrumentationScope(src)) - gotSize := MarshalProtoOrigInstrumentationScope(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigInstrumentationScope() - require.NoError(t, UnmarshalProtoOrigInstrumentationScope(dest, buf)) + dest := NewInstrumentationScope() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigInstrumentationScope(dest, true) + DeleteInstrumentationScope(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigInstrumentationScope(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufInstrumentationScope(t *testing.T) { for name, src := range genTestEncodingValuesInstrumentationScope() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigInstrumentationScope(src)) - gotSize := MarshalProtoOrigInstrumentationScope(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcommon.InstrumentationScope{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufInstrumentationScope(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigInstrumentationScope() - require.NoError(t, UnmarshalProtoOrigInstrumentationScope(dest, goBuf)) + dest := NewInstrumentationScope() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -151,12 +200,12 @@ func genTestFailingUnmarshalProtoValuesInstrumentationScope() map[string][]byte } } -func genTestEncodingValuesInstrumentationScope() map[string]*otlpcommon.InstrumentationScope { - return map[string]*otlpcommon.InstrumentationScope{ - "empty": NewOrigInstrumentationScope(), +func genTestEncodingValuesInstrumentationScope() map[string]*InstrumentationScope { + return map[string]*InstrumentationScope{ + "empty": NewInstrumentationScope(), "Name/test": {Name: "test_name"}, "Version/test": {Version: "test_version"}, - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, } } diff --git a/pdata/internal/generated_proto_ipaddr.go b/pdata/internal/generated_proto_ipaddr.go new file mode 100644 index 00000000000..2cd6029a63a --- /dev/null +++ b/pdata/internal/generated_proto_ipaddr.go @@ -0,0 +1,265 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type IPAddr struct { + IP []byte + Zone string +} + +var ( + protoPoolIPAddr = sync.Pool{ + New: func() any { + return &IPAddr{} + }, + } +) + +func NewIPAddr() *IPAddr { + if !UseProtoPooling.IsEnabled() { + return &IPAddr{} + } + return protoPoolIPAddr.Get().(*IPAddr) +} + +func DeleteIPAddr(orig *IPAddr, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolIPAddr.Put(orig) + } +} + +func CopyIPAddr(dest, src *IPAddr) *IPAddr { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewIPAddr() + } + dest.IP = src.IP + + dest.Zone = src.Zone + + return dest +} + +func CopyIPAddrSlice(dest, src []IPAddr) []IPAddr { + var newDest []IPAddr + if cap(dest) < len(src) { + newDest = make([]IPAddr, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteIPAddr(&dest[i], false) + } + } + for i := range src { + CopyIPAddr(&newDest[i], &src[i]) + } + return newDest +} + +func CopyIPAddrPtrSlice(dest, src []*IPAddr) []*IPAddr { + var newDest []*IPAddr + if cap(dest) < len(src) { + newDest = make([]*IPAddr, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewIPAddr() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteIPAddr(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewIPAddr() + } + } + for i := range src { + CopyIPAddr(newDest[i], src[i]) + } + return newDest +} + +func (orig *IPAddr) Reset() { + *orig = IPAddr{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *IPAddr) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + + if len(orig.IP) > 0 { + dest.WriteObjectField("iP") + dest.WriteBytes(orig.IP) + } + if orig.Zone != "" { + dest.WriteObjectField("zone") + dest.WriteString(orig.Zone) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *IPAddr) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "iP": + orig.IP = iter.ReadBytes() + case "zone": + orig.Zone = iter.ReadString() + default: + iter.Skip() + } + } +} + +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 + } + return n +} + +func (orig *IPAddr) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.IP) + if l > 0 { + pos -= l + copy(buf[pos:], orig.IP) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = len(orig.Zone) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Zone) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *IPAddr) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + if length != 0 { + orig.IP = make([]byte, length) + copy(orig.IP, buf[startPos:pos]) + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Zone", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Zone = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestIPAddr() *IPAddr { + orig := NewIPAddr() + orig.IP = []byte{1, 2, 3} + orig.Zone = "test_zone" + return orig +} + +func GenTestIPAddrPtrSlice() []*IPAddr { + orig := make([]*IPAddr, 5) + orig[0] = NewIPAddr() + orig[1] = GenTestIPAddr() + orig[2] = NewIPAddr() + orig[3] = GenTestIPAddr() + orig[4] = NewIPAddr() + return orig +} + +func GenTestIPAddrSlice() []IPAddr { + orig := make([]IPAddr, 5) + orig[1] = *GenTestIPAddr() + orig[3] = *GenTestIPAddr() + return orig +} diff --git a/pdata/internal/generated_proto_ipaddr_test.go b/pdata/internal/generated_proto_ipaddr_test.go new file mode 100644 index 00000000000..aa982246e4b --- /dev/null +++ b/pdata/internal/generated_proto_ipaddr_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyIPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesIPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewIPAddr() + CopyIPAddr(dest, src) + assert.Equal(t, src, dest) + CopyIPAddr(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyIPAddrSlice(t *testing.T) { + src := []IPAddr{} + dest := []IPAddr{} + // Test CopyTo empty + dest = CopyIPAddrSlice(dest, src) + assert.Equal(t, []IPAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestIPAddrSlice() + dest = CopyIPAddrSlice(dest, src) + assert.Equal(t, GenTestIPAddrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyIPAddrSlice(dest, src) + assert.Equal(t, GenTestIPAddrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyIPAddrSlice(dest, []IPAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyIPAddrSlice(dest, src) + assert.Equal(t, GenTestIPAddrSlice(), dest) +} + +func TestCopyIPAddrPtrSlice(t *testing.T) { + src := []*IPAddr{} + dest := []*IPAddr{} + // Test CopyTo empty + dest = CopyIPAddrPtrSlice(dest, src) + assert.Equal(t, []*IPAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestIPAddrPtrSlice() + dest = CopyIPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestIPAddrPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyIPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestIPAddrPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyIPAddrPtrSlice(dest, []*IPAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyIPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestIPAddrPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONIPAddrUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewIPAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewIPAddr(), dest) +} + +func TestMarshalAndUnmarshalJSONIPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesIPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewIPAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteIPAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoIPAddrFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesIPAddr() { + t.Run(name, func(t *testing.T) { + dest := NewIPAddr() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoIPAddrUnknown(t *testing.T) { + dest := NewIPAddr() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewIPAddr(), dest) +} + +func TestMarshalAndUnmarshalProtoIPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesIPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewIPAddr() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteIPAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufIPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesIPAddr() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewIPAddr() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesIPAddr() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "IP/wrong_wire_type": {0xc}, + "IP/missing_value": {0xa}, + "Zone/wrong_wire_type": {0x14}, + "Zone/missing_value": {0x12}, + } +} + +func genTestEncodingValuesIPAddr() map[string]*IPAddr { + return map[string]*IPAddr{ + "empty": NewIPAddr(), + "IP/test": {IP: []byte{1, 2, 3}}, + "Zone/test": {Zone: "test_zone"}, + } +} diff --git a/pdata/internal/generated_proto_keyvalue.go b/pdata/internal/generated_proto_keyvalue.go new file mode 100644 index 00000000000..3208776fb65 --- /dev/null +++ b/pdata/internal/generated_proto_keyvalue.go @@ -0,0 +1,262 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type KeyValue struct { + Key string + Value AnyValue +} + +var ( + protoPoolKeyValue = sync.Pool{ + New: func() any { + return &KeyValue{} + }, + } +) + +func NewKeyValue() *KeyValue { + if !UseProtoPooling.IsEnabled() { + return &KeyValue{} + } + return protoPoolKeyValue.Get().(*KeyValue) +} + +func DeleteKeyValue(orig *KeyValue, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteAnyValue(&orig.Value, false) + + orig.Reset() + if nullable { + protoPoolKeyValue.Put(orig) + } +} + +func CopyKeyValue(dest, src *KeyValue) *KeyValue { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewKeyValue() + } + dest.Key = src.Key + + CopyAnyValue(&dest.Value, &src.Value) + + return dest +} + +func CopyKeyValueSlice(dest, src []KeyValue) []KeyValue { + var newDest []KeyValue + if cap(dest) < len(src) { + newDest = make([]KeyValue, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteKeyValue(&dest[i], false) + } + } + for i := range src { + CopyKeyValue(&newDest[i], &src[i]) + } + return newDest +} + +func CopyKeyValuePtrSlice(dest, src []*KeyValue) []*KeyValue { + var newDest []*KeyValue + if cap(dest) < len(src) { + newDest = make([]*KeyValue, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewKeyValue() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteKeyValue(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewKeyValue() + } + } + for i := range src { + CopyKeyValue(newDest[i], src[i]) + } + return newDest +} + +func (orig *KeyValue) Reset() { + *orig = KeyValue{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *KeyValue) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Key != "" { + dest.WriteObjectField("key") + dest.WriteString(orig.Key) + } + dest.WriteObjectField("value") + orig.Value.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *KeyValue) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "key": + orig.Key = iter.ReadString() + case "value": + + orig.Value.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +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 + } + l = orig.Value.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *KeyValue) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.Key) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Key) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = orig.Value.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + + return len(buf) - pos +} + +func (orig *KeyValue) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Key = string(buf[startPos:pos]) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Value.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestKeyValue() *KeyValue { + orig := NewKeyValue() + orig.Key = "test_key" + orig.Value = *GenTestAnyValue() + return orig +} + +func GenTestKeyValuePtrSlice() []*KeyValue { + orig := make([]*KeyValue, 5) + orig[0] = NewKeyValue() + orig[1] = GenTestKeyValue() + orig[2] = NewKeyValue() + orig[3] = GenTestKeyValue() + orig[4] = NewKeyValue() + return orig +} + +func GenTestKeyValueSlice() []KeyValue { + orig := make([]KeyValue, 5) + orig[1] = *GenTestKeyValue() + orig[3] = *GenTestKeyValue() + return orig +} diff --git a/pdata/internal/generated_wrapper_keyvalue_test.go b/pdata/internal/generated_proto_keyvalue_test.go similarity index 54% rename from pdata/internal/generated_wrapper_keyvalue_test.go rename to pdata/internal/generated_proto_keyvalue_test.go index f0114870444..b8c21046f73 100644 --- a/pdata/internal/generated_wrapper_keyvalue_test.go +++ b/pdata/internal/generated_proto_keyvalue_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigKeyValue(t *testing.T) { +func TestCopyKeyValue(t *testing.T) { for name, src := range genTestEncodingValuesKeyValue() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigKeyValue(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigKeyValue() - CopyOrigKeyValue(dest, src) + dest := NewKeyValue() + CopyKeyValue(dest, src) assert.Equal(t, src, dest) - CopyOrigKeyValue(dest, dest) + CopyKeyValue(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigKeyValueUnknown(t *testing.T) { +func TestCopyKeyValueSlice(t *testing.T) { + src := []KeyValue{} + dest := []KeyValue{} + // Test CopyTo empty + dest = CopyKeyValueSlice(dest, src) + assert.Equal(t, []KeyValue{}, dest) + + // Test CopyTo larger slice + src = GenTestKeyValueSlice() + dest = CopyKeyValueSlice(dest, src) + assert.Equal(t, GenTestKeyValueSlice(), dest) + + // Test CopyTo same size slice + dest = CopyKeyValueSlice(dest, src) + assert.Equal(t, GenTestKeyValueSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyKeyValueSlice(dest, []KeyValue{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyKeyValueSlice(dest, src) + assert.Equal(t, GenTestKeyValueSlice(), dest) +} + +func TestCopyKeyValuePtrSlice(t *testing.T) { + src := []*KeyValue{} + dest := []*KeyValue{} + // Test CopyTo empty + dest = CopyKeyValuePtrSlice(dest, src) + assert.Equal(t, []*KeyValue{}, dest) + + // Test CopyTo larger slice + src = GenTestKeyValuePtrSlice() + dest = CopyKeyValuePtrSlice(dest, src) + assert.Equal(t, GenTestKeyValuePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyKeyValuePtrSlice(dest, src) + assert.Equal(t, GenTestKeyValuePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyKeyValuePtrSlice(dest, []*KeyValue{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyKeyValuePtrSlice(dest, src) + assert.Equal(t, GenTestKeyValuePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONKeyValueUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigKeyValue() - UnmarshalJSONOrigKeyValue(dest, iter) + dest := NewKeyValue() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigKeyValue(), dest) + assert.Equal(t, NewKeyValue(), dest) } -func TestMarshalAndUnmarshalJSONOrigKeyValue(t *testing.T) { +func TestMarshalAndUnmarshalJSONKeyValue(t *testing.T) { for name, src := range genTestEncodingValuesKeyValue() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigKeyValue(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigKeyValue(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigKeyValue() - UnmarshalJSONOrigKeyValue(dest, iter) + dest := NewKeyValue() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigKeyValue(dest, true) + DeleteKeyValue(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigKeyValueFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoKeyValueFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesKeyValue() { t.Run(name, func(t *testing.T) { - dest := NewOrigKeyValue() - require.Error(t, UnmarshalProtoOrigKeyValue(dest, buf)) + dest := NewKeyValue() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigKeyValueUnknown(t *testing.T) { - dest := NewOrigKeyValue() +func TestMarshalAndUnmarshalProtoKeyValueUnknown(t *testing.T) { + dest := NewKeyValue() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigKeyValue(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigKeyValue(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewKeyValue(), dest) } -func TestMarshalAndUnmarshalProtoOrigKeyValue(t *testing.T) { +func TestMarshalAndUnmarshalProtoKeyValue(t *testing.T) { for name, src := range genTestEncodingValuesKeyValue() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigKeyValue(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigKeyValue(src)) - gotSize := MarshalProtoOrigKeyValue(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigKeyValue() - require.NoError(t, UnmarshalProtoOrigKeyValue(dest, buf)) + dest := NewKeyValue() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigKeyValue(dest, true) + DeleteKeyValue(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigKeyValue(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufKeyValue(t *testing.T) { for name, src := range genTestEncodingValuesKeyValue() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigKeyValue(src)) - gotSize := MarshalProtoOrigKeyValue(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcommon.KeyValue{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufKeyValue(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigKeyValue() - require.NoError(t, UnmarshalProtoOrigKeyValue(dest, goBuf)) + dest := NewKeyValue() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,10 +196,10 @@ func genTestFailingUnmarshalProtoValuesKeyValue() map[string][]byte { } } -func genTestEncodingValuesKeyValue() map[string]*otlpcommon.KeyValue { - return map[string]*otlpcommon.KeyValue{ - "empty": NewOrigKeyValue(), +func genTestEncodingValuesKeyValue() map[string]*KeyValue { + return map[string]*KeyValue{ + "empty": NewKeyValue(), "Key/test": {Key: "test_key"}, - "Value/test": {Value: *GenTestOrigAnyValue()}, + "Value/test": {Value: *GenTestAnyValue()}, } } diff --git a/pdata/internal/generated_proto_keyvalueandunit.go b/pdata/internal/generated_proto_keyvalueandunit.go new file mode 100644 index 00000000000..14c2e763d97 --- /dev/null +++ b/pdata/internal/generated_proto_keyvalueandunit.go @@ -0,0 +1,291 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// KeyValueAndUnit represents a custom 'dictionary native' +// style of encoding attributes which is more convenient +// for profiles than opentelemetry.proto.common.v1.KeyValue. +type KeyValueAndUnit struct { + KeyStrindex int32 + Value AnyValue + UnitStrindex int32 +} + +var ( + protoPoolKeyValueAndUnit = sync.Pool{ + New: func() any { + return &KeyValueAndUnit{} + }, + } +) + +func NewKeyValueAndUnit() *KeyValueAndUnit { + if !UseProtoPooling.IsEnabled() { + return &KeyValueAndUnit{} + } + return protoPoolKeyValueAndUnit.Get().(*KeyValueAndUnit) +} + +func DeleteKeyValueAndUnit(orig *KeyValueAndUnit, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteAnyValue(&orig.Value, false) + + orig.Reset() + if nullable { + protoPoolKeyValueAndUnit.Put(orig) + } +} + +func CopyKeyValueAndUnit(dest, src *KeyValueAndUnit) *KeyValueAndUnit { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewKeyValueAndUnit() + } + dest.KeyStrindex = src.KeyStrindex + + CopyAnyValue(&dest.Value, &src.Value) + + dest.UnitStrindex = src.UnitStrindex + + return dest +} + +func CopyKeyValueAndUnitSlice(dest, src []KeyValueAndUnit) []KeyValueAndUnit { + var newDest []KeyValueAndUnit + if cap(dest) < len(src) { + newDest = make([]KeyValueAndUnit, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteKeyValueAndUnit(&dest[i], false) + } + } + for i := range src { + CopyKeyValueAndUnit(&newDest[i], &src[i]) + } + return newDest +} + +func CopyKeyValueAndUnitPtrSlice(dest, src []*KeyValueAndUnit) []*KeyValueAndUnit { + var newDest []*KeyValueAndUnit + if cap(dest) < len(src) { + newDest = make([]*KeyValueAndUnit, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewKeyValueAndUnit() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteKeyValueAndUnit(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewKeyValueAndUnit() + } + } + for i := range src { + CopyKeyValueAndUnit(newDest[i], src[i]) + } + return newDest +} + +func (orig *KeyValueAndUnit) Reset() { + *orig = KeyValueAndUnit{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *KeyValueAndUnit) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.KeyStrindex != int32(0) { + dest.WriteObjectField("keyStrindex") + dest.WriteInt32(orig.KeyStrindex) + } + dest.WriteObjectField("value") + orig.Value.MarshalJSON(dest) + if orig.UnitStrindex != int32(0) { + dest.WriteObjectField("unitStrindex") + dest.WriteInt32(orig.UnitStrindex) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *KeyValueAndUnit) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "keyStrindex", "key_strindex": + orig.KeyStrindex = iter.ReadInt32() + case "value": + + orig.Value.UnmarshalJSON(iter) + case "unitStrindex", "unit_strindex": + orig.UnitStrindex = iter.ReadInt32() + default: + iter.Skip() + } + } +} + +func (orig *KeyValueAndUnit) SizeProto() int { + var n int + var l int + _ = l + if orig.KeyStrindex != 0 { + n += 1 + proto.Sov(uint64(orig.KeyStrindex)) + } + l = orig.Value.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + if orig.UnitStrindex != 0 { + n += 1 + proto.Sov(uint64(orig.UnitStrindex)) + } + return n +} + +func (orig *KeyValueAndUnit) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.KeyStrindex != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.KeyStrindex)) + pos-- + buf[pos] = 0x8 + } + l = orig.Value.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + + if orig.UnitStrindex != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.UnitStrindex)) + pos-- + buf[pos] = 0x18 + } + return len(buf) - pos +} + +func (orig *KeyValueAndUnit) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field KeyStrindex", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.KeyStrindex = int32(num) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Value.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field UnitStrindex", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.UnitStrindex = int32(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestKeyValueAndUnit() *KeyValueAndUnit { + orig := NewKeyValueAndUnit() + orig.KeyStrindex = int32(13) + orig.Value = *GenTestAnyValue() + orig.UnitStrindex = int32(13) + return orig +} + +func GenTestKeyValueAndUnitPtrSlice() []*KeyValueAndUnit { + orig := make([]*KeyValueAndUnit, 5) + orig[0] = NewKeyValueAndUnit() + orig[1] = GenTestKeyValueAndUnit() + orig[2] = NewKeyValueAndUnit() + orig[3] = GenTestKeyValueAndUnit() + orig[4] = NewKeyValueAndUnit() + return orig +} + +func GenTestKeyValueAndUnitSlice() []KeyValueAndUnit { + orig := make([]KeyValueAndUnit, 5) + orig[1] = *GenTestKeyValueAndUnit() + orig[3] = *GenTestKeyValueAndUnit() + return orig +} diff --git a/pdata/internal/generated_wrapper_keyvalueandunit_test.go b/pdata/internal/generated_proto_keyvalueandunit_test.go similarity index 53% rename from pdata/internal/generated_wrapper_keyvalueandunit_test.go rename to pdata/internal/generated_proto_keyvalueandunit_test.go index 866e3ab6622..50f28595a2b 100644 --- a/pdata/internal/generated_wrapper_keyvalueandunit_test.go +++ b/pdata/internal/generated_proto_keyvalueandunit_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigKeyValueAndUnit(t *testing.T) { +func TestCopyKeyValueAndUnit(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueAndUnit() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigKeyValueAndUnit(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigKeyValueAndUnit() - CopyOrigKeyValueAndUnit(dest, src) + dest := NewKeyValueAndUnit() + CopyKeyValueAndUnit(dest, src) assert.Equal(t, src, dest) - CopyOrigKeyValueAndUnit(dest, dest) + CopyKeyValueAndUnit(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigKeyValueAndUnitUnknown(t *testing.T) { +func TestCopyKeyValueAndUnitSlice(t *testing.T) { + src := []KeyValueAndUnit{} + dest := []KeyValueAndUnit{} + // Test CopyTo empty + dest = CopyKeyValueAndUnitSlice(dest, src) + assert.Equal(t, []KeyValueAndUnit{}, dest) + + // Test CopyTo larger slice + src = GenTestKeyValueAndUnitSlice() + dest = CopyKeyValueAndUnitSlice(dest, src) + assert.Equal(t, GenTestKeyValueAndUnitSlice(), dest) + + // Test CopyTo same size slice + dest = CopyKeyValueAndUnitSlice(dest, src) + assert.Equal(t, GenTestKeyValueAndUnitSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyKeyValueAndUnitSlice(dest, []KeyValueAndUnit{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyKeyValueAndUnitSlice(dest, src) + assert.Equal(t, GenTestKeyValueAndUnitSlice(), dest) +} + +func TestCopyKeyValueAndUnitPtrSlice(t *testing.T) { + src := []*KeyValueAndUnit{} + dest := []*KeyValueAndUnit{} + // Test CopyTo empty + dest = CopyKeyValueAndUnitPtrSlice(dest, src) + assert.Equal(t, []*KeyValueAndUnit{}, dest) + + // Test CopyTo larger slice + src = GenTestKeyValueAndUnitPtrSlice() + dest = CopyKeyValueAndUnitPtrSlice(dest, src) + assert.Equal(t, GenTestKeyValueAndUnitPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyKeyValueAndUnitPtrSlice(dest, src) + assert.Equal(t, GenTestKeyValueAndUnitPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyKeyValueAndUnitPtrSlice(dest, []*KeyValueAndUnit{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyKeyValueAndUnitPtrSlice(dest, src) + assert.Equal(t, GenTestKeyValueAndUnitPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONKeyValueAndUnitUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigKeyValueAndUnit() - UnmarshalJSONOrigKeyValueAndUnit(dest, iter) + dest := NewKeyValueAndUnit() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigKeyValueAndUnit(), dest) + assert.Equal(t, NewKeyValueAndUnit(), dest) } -func TestMarshalAndUnmarshalJSONOrigKeyValueAndUnit(t *testing.T) { +func TestMarshalAndUnmarshalJSONKeyValueAndUnit(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueAndUnit() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigKeyValueAndUnit(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigKeyValueAndUnit(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigKeyValueAndUnit() - UnmarshalJSONOrigKeyValueAndUnit(dest, iter) + dest := NewKeyValueAndUnit() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigKeyValueAndUnit(dest, true) + DeleteKeyValueAndUnit(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigKeyValueAndUnitFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoKeyValueAndUnitFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesKeyValueAndUnit() { t.Run(name, func(t *testing.T) { - dest := NewOrigKeyValueAndUnit() - require.Error(t, UnmarshalProtoOrigKeyValueAndUnit(dest, buf)) + dest := NewKeyValueAndUnit() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigKeyValueAndUnitUnknown(t *testing.T) { - dest := NewOrigKeyValueAndUnit() +func TestMarshalAndUnmarshalProtoKeyValueAndUnitUnknown(t *testing.T) { + dest := NewKeyValueAndUnit() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigKeyValueAndUnit(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigKeyValueAndUnit(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewKeyValueAndUnit(), dest) } -func TestMarshalAndUnmarshalProtoOrigKeyValueAndUnit(t *testing.T) { +func TestMarshalAndUnmarshalProtoKeyValueAndUnit(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueAndUnit() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigKeyValueAndUnit(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigKeyValueAndUnit(src)) - gotSize := MarshalProtoOrigKeyValueAndUnit(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigKeyValueAndUnit() - require.NoError(t, UnmarshalProtoOrigKeyValueAndUnit(dest, buf)) + dest := NewKeyValueAndUnit() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigKeyValueAndUnit(dest, true) + DeleteKeyValueAndUnit(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigKeyValueAndUnit(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufKeyValueAndUnit(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueAndUnit() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigKeyValueAndUnit(src)) - gotSize := MarshalProtoOrigKeyValueAndUnit(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.KeyValueAndUnit{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufKeyValueAndUnit(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigKeyValueAndUnit() - require.NoError(t, UnmarshalProtoOrigKeyValueAndUnit(dest, goBuf)) + dest := NewKeyValueAndUnit() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesKeyValueAndUnit() map[string][]byte { } } -func genTestEncodingValuesKeyValueAndUnit() map[string]*otlpprofiles.KeyValueAndUnit { - return map[string]*otlpprofiles.KeyValueAndUnit{ - "empty": NewOrigKeyValueAndUnit(), +func genTestEncodingValuesKeyValueAndUnit() map[string]*KeyValueAndUnit { + return map[string]*KeyValueAndUnit{ + "empty": NewKeyValueAndUnit(), "KeyStrindex/test": {KeyStrindex: int32(13)}, - "Value/test": {Value: *GenTestOrigAnyValue()}, + "Value/test": {Value: *GenTestAnyValue()}, "UnitStrindex/test": {UnitStrindex: int32(13)}, } } diff --git a/pdata/internal/generated_proto_keyvaluelist.go b/pdata/internal/generated_proto_keyvaluelist.go new file mode 100644 index 00000000000..1cb1fef73c8 --- /dev/null +++ b/pdata/internal/generated_proto_keyvaluelist.go @@ -0,0 +1,245 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message since oneof in AnyValue does not allow repeated fields. +type KeyValueList struct { + Values []KeyValue +} + +var ( + protoPoolKeyValueList = sync.Pool{ + New: func() any { + return &KeyValueList{} + }, + } +) + +func NewKeyValueList() *KeyValueList { + if !UseProtoPooling.IsEnabled() { + return &KeyValueList{} + } + return protoPoolKeyValueList.Get().(*KeyValueList) +} + +func DeleteKeyValueList(orig *KeyValueList, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.Values { + DeleteKeyValue(&orig.Values[i], false) + } + + orig.Reset() + if nullable { + protoPoolKeyValueList.Put(orig) + } +} + +func CopyKeyValueList(dest, src *KeyValueList) *KeyValueList { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewKeyValueList() + } + dest.Values = CopyKeyValueSlice(dest.Values, src.Values) + + return dest +} + +func CopyKeyValueListSlice(dest, src []KeyValueList) []KeyValueList { + var newDest []KeyValueList + if cap(dest) < len(src) { + newDest = make([]KeyValueList, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteKeyValueList(&dest[i], false) + } + } + for i := range src { + CopyKeyValueList(&newDest[i], &src[i]) + } + return newDest +} + +func CopyKeyValueListPtrSlice(dest, src []*KeyValueList) []*KeyValueList { + var newDest []*KeyValueList + if cap(dest) < len(src) { + newDest = make([]*KeyValueList, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewKeyValueList() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteKeyValueList(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewKeyValueList() + } + } + for i := range src { + CopyKeyValueList(newDest[i], src[i]) + } + return newDest +} + +func (orig *KeyValueList) Reset() { + *orig = KeyValueList{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *KeyValueList) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.Values) > 0 { + dest.WriteObjectField("values") + dest.WriteArrayStart() + orig.Values[0].MarshalJSON(dest) + for i := 1; i < len(orig.Values); i++ { + dest.WriteMore() + orig.Values[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *KeyValueList) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "values": + for iter.ReadArray() { + orig.Values = append(orig.Values, KeyValue{}) + orig.Values[len(orig.Values)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *KeyValueList) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.Values { + l = orig.Values[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *KeyValueList) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.Values) - 1; i >= 0; i-- { + l = orig.Values[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *KeyValueList) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Values = append(orig.Values, KeyValue{}) + err = orig.Values[len(orig.Values)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestKeyValueList() *KeyValueList { + orig := NewKeyValueList() + orig.Values = []KeyValue{{}, *GenTestKeyValue()} + return orig +} + +func GenTestKeyValueListPtrSlice() []*KeyValueList { + orig := make([]*KeyValueList, 5) + orig[0] = NewKeyValueList() + orig[1] = GenTestKeyValueList() + orig[2] = NewKeyValueList() + orig[3] = GenTestKeyValueList() + orig[4] = NewKeyValueList() + return orig +} + +func GenTestKeyValueListSlice() []KeyValueList { + orig := make([]KeyValueList, 5) + orig[1] = *GenTestKeyValueList() + orig[3] = *GenTestKeyValueList() + return orig +} diff --git a/pdata/internal/generated_wrapper_keyvaluelist_test.go b/pdata/internal/generated_proto_keyvaluelist_test.go similarity index 52% rename from pdata/internal/generated_wrapper_keyvaluelist_test.go rename to pdata/internal/generated_proto_keyvaluelist_test.go index 2615bb9a669..eee0761ab6d 100644 --- a/pdata/internal/generated_wrapper_keyvaluelist_test.go +++ b/pdata/internal/generated_proto_keyvaluelist_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigKeyValueList(t *testing.T) { +func TestCopyKeyValueList(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueList() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigKeyValueList(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigKeyValueList() - CopyOrigKeyValueList(dest, src) + dest := NewKeyValueList() + CopyKeyValueList(dest, src) assert.Equal(t, src, dest) - CopyOrigKeyValueList(dest, dest) + CopyKeyValueList(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigKeyValueListUnknown(t *testing.T) { +func TestCopyKeyValueListSlice(t *testing.T) { + src := []KeyValueList{} + dest := []KeyValueList{} + // Test CopyTo empty + dest = CopyKeyValueListSlice(dest, src) + assert.Equal(t, []KeyValueList{}, dest) + + // Test CopyTo larger slice + src = GenTestKeyValueListSlice() + dest = CopyKeyValueListSlice(dest, src) + assert.Equal(t, GenTestKeyValueListSlice(), dest) + + // Test CopyTo same size slice + dest = CopyKeyValueListSlice(dest, src) + assert.Equal(t, GenTestKeyValueListSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyKeyValueListSlice(dest, []KeyValueList{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyKeyValueListSlice(dest, src) + assert.Equal(t, GenTestKeyValueListSlice(), dest) +} + +func TestCopyKeyValueListPtrSlice(t *testing.T) { + src := []*KeyValueList{} + dest := []*KeyValueList{} + // Test CopyTo empty + dest = CopyKeyValueListPtrSlice(dest, src) + assert.Equal(t, []*KeyValueList{}, dest) + + // Test CopyTo larger slice + src = GenTestKeyValueListPtrSlice() + dest = CopyKeyValueListPtrSlice(dest, src) + assert.Equal(t, GenTestKeyValueListPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyKeyValueListPtrSlice(dest, src) + assert.Equal(t, GenTestKeyValueListPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyKeyValueListPtrSlice(dest, []*KeyValueList{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyKeyValueListPtrSlice(dest, src) + assert.Equal(t, GenTestKeyValueListPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONKeyValueListUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigKeyValueList() - UnmarshalJSONOrigKeyValueList(dest, iter) + dest := NewKeyValueList() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigKeyValueList(), dest) + assert.Equal(t, NewKeyValueList(), dest) } -func TestMarshalAndUnmarshalJSONOrigKeyValueList(t *testing.T) { +func TestMarshalAndUnmarshalJSONKeyValueList(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueList() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigKeyValueList(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigKeyValueList(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigKeyValueList() - UnmarshalJSONOrigKeyValueList(dest, iter) + dest := NewKeyValueList() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigKeyValueList(dest, true) + DeleteKeyValueList(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigKeyValueListFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoKeyValueListFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesKeyValueList() { t.Run(name, func(t *testing.T) { - dest := NewOrigKeyValueList() - require.Error(t, UnmarshalProtoOrigKeyValueList(dest, buf)) + dest := NewKeyValueList() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigKeyValueListUnknown(t *testing.T) { - dest := NewOrigKeyValueList() +func TestMarshalAndUnmarshalProtoKeyValueListUnknown(t *testing.T) { + dest := NewKeyValueList() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigKeyValueList(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigKeyValueList(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewKeyValueList(), dest) } -func TestMarshalAndUnmarshalProtoOrigKeyValueList(t *testing.T) { +func TestMarshalAndUnmarshalProtoKeyValueList(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueList() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigKeyValueList(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigKeyValueList(src)) - gotSize := MarshalProtoOrigKeyValueList(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigKeyValueList() - require.NoError(t, UnmarshalProtoOrigKeyValueList(dest, buf)) + dest := NewKeyValueList() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigKeyValueList(dest, true) + DeleteKeyValueList(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigKeyValueList(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufKeyValueList(t *testing.T) { for name, src := range genTestEncodingValuesKeyValueList() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigKeyValueList(src)) - gotSize := MarshalProtoOrigKeyValueList(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpcommon.KeyValueList{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufKeyValueList(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigKeyValueList() - require.NoError(t, UnmarshalProtoOrigKeyValueList(dest, goBuf)) + dest := NewKeyValueList() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -145,9 +194,9 @@ func genTestFailingUnmarshalProtoValuesKeyValueList() map[string][]byte { } } -func genTestEncodingValuesKeyValueList() map[string]*otlpcommon.KeyValueList { - return map[string]*otlpcommon.KeyValueList{ - "empty": NewOrigKeyValueList(), - "Values/default_and_test": {Values: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, +func genTestEncodingValuesKeyValueList() map[string]*KeyValueList { + return map[string]*KeyValueList{ + "empty": NewKeyValueList(), + "Values/test": {Values: []KeyValue{{}, *GenTestKeyValue()}}, } } diff --git a/pdata/internal/generated_wrapper_line.go b/pdata/internal/generated_proto_line.go similarity index 56% rename from pdata/internal/generated_wrapper_line.go rename to pdata/internal/generated_proto_line.go index 4b455cfb17d..f9cde7b965a 100644 --- a/pdata/internal/generated_wrapper_line.go +++ b/pdata/internal/generated_proto_line.go @@ -10,27 +10,33 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Line details a specific line in a source code, linked to a function. +type Line struct { + FunctionIndex int32 + Line int64 + Column int64 +} + var ( protoPoolLine = sync.Pool{ New: func() any { - return &otlpprofiles.Line{} + return &Line{} }, } ) -func NewOrigLine() *otlpprofiles.Line { +func NewLine() *Line { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Line{} + return &Line{} } - return protoPoolLine.Get().(*otlpprofiles.Line) + return protoPoolLine.Get().(*Line) } -func DeleteOrigLine(orig *otlpprofiles.Line, nullable bool) { +func DeleteLine(orig *Line, nullable bool) { if orig == nil { return } @@ -46,26 +52,82 @@ func DeleteOrigLine(orig *otlpprofiles.Line, nullable bool) { } } -func CopyOrigLine(dest, src *otlpprofiles.Line) { +func CopyLine(dest, src *Line) *Line { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewLine() } dest.FunctionIndex = src.FunctionIndex + dest.Line = src.Line + dest.Column = src.Column + + return dest } -func GenTestOrigLine() *otlpprofiles.Line { - orig := NewOrigLine() - orig.FunctionIndex = int32(13) - orig.Line = int64(13) - orig.Column = int64(13) - return orig +func CopyLineSlice(dest, src []Line) []Line { + var newDest []Line + if cap(dest) < len(src) { + newDest = make([]Line, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLine(&dest[i], false) + } + } + for i := range src { + CopyLine(&newDest[i], &src[i]) + } + return newDest +} + +func CopyLinePtrSlice(dest, src []*Line) []*Line { + var newDest []*Line + if cap(dest) < len(src) { + newDest = make([]*Line, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLine() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLine(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLine() + } + } + for i := range src { + CopyLine(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigLine(orig *otlpprofiles.Line, dest *json.Stream) { +func (orig *Line) Reset() { + *orig = Line{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Line) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.FunctionIndex != int32(0) { dest.WriteObjectField("functionIndex") @@ -82,8 +144,8 @@ func MarshalJSONOrigLine(orig *otlpprofiles.Line, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigLine unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigLine(orig *otlpprofiles.Line, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Line) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "functionIndex", "function_index": @@ -98,7 +160,7 @@ func UnmarshalJSONOrigLine(orig *otlpprofiles.Line, iter *json.Iterator) { } } -func SizeProtoOrigLine(orig *otlpprofiles.Line) int { +func (orig *Line) SizeProto() int { var n int var l int _ = l @@ -114,7 +176,7 @@ func SizeProtoOrigLine(orig *otlpprofiles.Line) int { return n } -func MarshalProtoOrigLine(orig *otlpprofiles.Line, buf []byte) int { +func (orig *Line) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -136,7 +198,7 @@ func MarshalProtoOrigLine(orig *otlpprofiles.Line, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigLine(orig *otlpprofiles.Line, buf []byte) error { +func (orig *Line) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -195,3 +257,28 @@ func UnmarshalProtoOrigLine(orig *otlpprofiles.Line, buf []byte) error { } return nil } + +func GenTestLine() *Line { + orig := NewLine() + orig.FunctionIndex = int32(13) + orig.Line = int64(13) + orig.Column = int64(13) + return orig +} + +func GenTestLinePtrSlice() []*Line { + orig := make([]*Line, 5) + orig[0] = NewLine() + orig[1] = GenTestLine() + orig[2] = NewLine() + orig[3] = GenTestLine() + orig[4] = NewLine() + return orig +} + +func GenTestLineSlice() []Line { + orig := make([]Line, 5) + orig[1] = *GenTestLine() + orig[3] = *GenTestLine() + return orig +} diff --git a/pdata/internal/generated_wrapper_line_test.go b/pdata/internal/generated_proto_line_test.go similarity index 58% rename from pdata/internal/generated_wrapper_line_test.go rename to pdata/internal/generated_proto_line_test.go index 279863c4ba9..afdae244d2a 100644 --- a/pdata/internal/generated_wrapper_line_test.go +++ b/pdata/internal/generated_proto_line_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigLine(t *testing.T) { +func TestCopyLine(t *testing.T) { for name, src := range genTestEncodingValuesLine() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigLine(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigLine() - CopyOrigLine(dest, src) + dest := NewLine() + CopyLine(dest, src) assert.Equal(t, src, dest) - CopyOrigLine(dest, dest) + CopyLine(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigLineUnknown(t *testing.T) { +func TestCopyLineSlice(t *testing.T) { + src := []Line{} + dest := []Line{} + // Test CopyTo empty + dest = CopyLineSlice(dest, src) + assert.Equal(t, []Line{}, dest) + + // Test CopyTo larger slice + src = GenTestLineSlice() + dest = CopyLineSlice(dest, src) + assert.Equal(t, GenTestLineSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLineSlice(dest, src) + assert.Equal(t, GenTestLineSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLineSlice(dest, []Line{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLineSlice(dest, src) + assert.Equal(t, GenTestLineSlice(), dest) +} + +func TestCopyLinePtrSlice(t *testing.T) { + src := []*Line{} + dest := []*Line{} + // Test CopyTo empty + dest = CopyLinePtrSlice(dest, src) + assert.Equal(t, []*Line{}, dest) + + // Test CopyTo larger slice + src = GenTestLinePtrSlice() + dest = CopyLinePtrSlice(dest, src) + assert.Equal(t, GenTestLinePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLinePtrSlice(dest, src) + assert.Equal(t, GenTestLinePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLinePtrSlice(dest, []*Line{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLinePtrSlice(dest, src) + assert.Equal(t, GenTestLinePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONLineUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigLine() - UnmarshalJSONOrigLine(dest, iter) + dest := NewLine() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigLine(), dest) + assert.Equal(t, NewLine(), dest) } -func TestMarshalAndUnmarshalJSONOrigLine(t *testing.T) { +func TestMarshalAndUnmarshalJSONLine(t *testing.T) { for name, src := range genTestEncodingValuesLine() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigLine(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigLine(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigLine() - UnmarshalJSONOrigLine(dest, iter) + dest := NewLine() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigLine(dest, true) + DeleteLine(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigLineFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoLineFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesLine() { t.Run(name, func(t *testing.T) { - dest := NewOrigLine() - require.Error(t, UnmarshalProtoOrigLine(dest, buf)) + dest := NewLine() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigLineUnknown(t *testing.T) { - dest := NewOrigLine() +func TestMarshalAndUnmarshalProtoLineUnknown(t *testing.T) { + dest := NewLine() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigLine(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigLine(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewLine(), dest) } -func TestMarshalAndUnmarshalProtoOrigLine(t *testing.T) { +func TestMarshalAndUnmarshalProtoLine(t *testing.T) { for name, src := range genTestEncodingValuesLine() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigLine(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigLine(src)) - gotSize := MarshalProtoOrigLine(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigLine() - require.NoError(t, UnmarshalProtoOrigLine(dest, buf)) + dest := NewLine() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigLine(dest, true) + DeleteLine(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigLine(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufLine(t *testing.T) { for name, src := range genTestEncodingValuesLine() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigLine(src)) - gotSize := MarshalProtoOrigLine(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Line{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufLine(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigLine() - require.NoError(t, UnmarshalProtoOrigLine(dest, goBuf)) + dest := NewLine() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,9 +198,9 @@ func genTestFailingUnmarshalProtoValuesLine() map[string][]byte { } } -func genTestEncodingValuesLine() map[string]*otlpprofiles.Line { - return map[string]*otlpprofiles.Line{ - "empty": NewOrigLine(), +func genTestEncodingValuesLine() map[string]*Line { + return map[string]*Line{ + "empty": NewLine(), "FunctionIndex/test": {FunctionIndex: int32(13)}, "Line/test": {Line: int64(13)}, "Column/test": {Column: int64(13)}, diff --git a/pdata/internal/generated_proto_link.go b/pdata/internal/generated_proto_link.go new file mode 100644 index 00000000000..26962ad2712 --- /dev/null +++ b/pdata/internal/generated_proto_link.go @@ -0,0 +1,267 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Link represents a pointer from a profile Sample to a trace Span. +type Link struct { + TraceId TraceID + SpanId SpanID +} + +var ( + protoPoolLink = sync.Pool{ + New: func() any { + return &Link{} + }, + } +) + +func NewLink() *Link { + if !UseProtoPooling.IsEnabled() { + return &Link{} + } + return protoPoolLink.Get().(*Link) +} + +func DeleteLink(orig *Link, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteTraceID(&orig.TraceId, false) + DeleteSpanID(&orig.SpanId, false) + + orig.Reset() + if nullable { + protoPoolLink.Put(orig) + } +} + +func CopyLink(dest, src *Link) *Link { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewLink() + } + CopyTraceID(&dest.TraceId, &src.TraceId) + + CopySpanID(&dest.SpanId, &src.SpanId) + + return dest +} + +func CopyLinkSlice(dest, src []Link) []Link { + var newDest []Link + if cap(dest) < len(src) { + newDest = make([]Link, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLink(&dest[i], false) + } + } + for i := range src { + CopyLink(&newDest[i], &src[i]) + } + return newDest +} + +func CopyLinkPtrSlice(dest, src []*Link) []*Link { + var newDest []*Link + if cap(dest) < len(src) { + newDest = make([]*Link, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLink() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLink(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLink() + } + } + for i := range src { + CopyLink(newDest[i], src[i]) + } + return newDest +} + +func (orig *Link) Reset() { + *orig = Link{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Link) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if !orig.TraceId.IsEmpty() { + dest.WriteObjectField("traceId") + orig.TraceId.MarshalJSON(dest) + } + if !orig.SpanId.IsEmpty() { + dest.WriteObjectField("spanId") + orig.SpanId.MarshalJSON(dest) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Link) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "traceId", "trace_id": + + orig.TraceId.UnmarshalJSON(iter) + case "spanId", "span_id": + + orig.SpanId.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *Link) SizeProto() int { + var n int + var l int + _ = l + l = orig.TraceId.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + l = orig.SpanId.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *Link) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.TraceId.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + l = orig.SpanId.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + + return len(buf) - pos +} + +func (orig *Link) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.TraceId.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.SpanId.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestLink() *Link { + orig := NewLink() + orig.TraceId = *GenTestTraceID() + orig.SpanId = *GenTestSpanID() + return orig +} + +func GenTestLinkPtrSlice() []*Link { + orig := make([]*Link, 5) + orig[0] = NewLink() + orig[1] = GenTestLink() + orig[2] = NewLink() + orig[3] = GenTestLink() + orig[4] = NewLink() + return orig +} + +func GenTestLinkSlice() []Link { + orig := make([]Link, 5) + orig[1] = *GenTestLink() + orig[3] = *GenTestLink() + return orig +} diff --git a/pdata/internal/generated_wrapper_link_test.go b/pdata/internal/generated_proto_link_test.go similarity index 55% rename from pdata/internal/generated_wrapper_link_test.go rename to pdata/internal/generated_proto_link_test.go index c4db1ba88c7..5887e4d1226 100644 --- a/pdata/internal/generated_wrapper_link_test.go +++ b/pdata/internal/generated_proto_link_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigLink(t *testing.T) { +func TestCopyLink(t *testing.T) { for name, src := range genTestEncodingValuesLink() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigLink(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigLink() - CopyOrigLink(dest, src) + dest := NewLink() + CopyLink(dest, src) assert.Equal(t, src, dest) - CopyOrigLink(dest, dest) + CopyLink(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigLinkUnknown(t *testing.T) { +func TestCopyLinkSlice(t *testing.T) { + src := []Link{} + dest := []Link{} + // Test CopyTo empty + dest = CopyLinkSlice(dest, src) + assert.Equal(t, []Link{}, dest) + + // Test CopyTo larger slice + src = GenTestLinkSlice() + dest = CopyLinkSlice(dest, src) + assert.Equal(t, GenTestLinkSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLinkSlice(dest, src) + assert.Equal(t, GenTestLinkSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLinkSlice(dest, []Link{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLinkSlice(dest, src) + assert.Equal(t, GenTestLinkSlice(), dest) +} + +func TestCopyLinkPtrSlice(t *testing.T) { + src := []*Link{} + dest := []*Link{} + // Test CopyTo empty + dest = CopyLinkPtrSlice(dest, src) + assert.Equal(t, []*Link{}, dest) + + // Test CopyTo larger slice + src = GenTestLinkPtrSlice() + dest = CopyLinkPtrSlice(dest, src) + assert.Equal(t, GenTestLinkPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLinkPtrSlice(dest, src) + assert.Equal(t, GenTestLinkPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLinkPtrSlice(dest, []*Link{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLinkPtrSlice(dest, src) + assert.Equal(t, GenTestLinkPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONLinkUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigLink() - UnmarshalJSONOrigLink(dest, iter) + dest := NewLink() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigLink(), dest) + assert.Equal(t, NewLink(), dest) } -func TestMarshalAndUnmarshalJSONOrigLink(t *testing.T) { +func TestMarshalAndUnmarshalJSONLink(t *testing.T) { for name, src := range genTestEncodingValuesLink() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigLink(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigLink(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigLink() - UnmarshalJSONOrigLink(dest, iter) + dest := NewLink() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigLink(dest, true) + DeleteLink(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigLinkFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoLinkFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesLink() { t.Run(name, func(t *testing.T) { - dest := NewOrigLink() - require.Error(t, UnmarshalProtoOrigLink(dest, buf)) + dest := NewLink() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigLinkUnknown(t *testing.T) { - dest := NewOrigLink() +func TestMarshalAndUnmarshalProtoLinkUnknown(t *testing.T) { + dest := NewLink() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigLink(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigLink(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewLink(), dest) } -func TestMarshalAndUnmarshalProtoOrigLink(t *testing.T) { +func TestMarshalAndUnmarshalProtoLink(t *testing.T) { for name, src := range genTestEncodingValuesLink() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigLink(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigLink(src)) - gotSize := MarshalProtoOrigLink(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigLink() - require.NoError(t, UnmarshalProtoOrigLink(dest, buf)) + dest := NewLink() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigLink(dest, true) + DeleteLink(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigLink(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufLink(t *testing.T) { for name, src := range genTestEncodingValuesLink() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigLink(src)) - gotSize := MarshalProtoOrigLink(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Link{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufLink(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigLink() - require.NoError(t, UnmarshalProtoOrigLink(dest, goBuf)) + dest := NewLink() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,10 +196,10 @@ func genTestFailingUnmarshalProtoValuesLink() map[string][]byte { } } -func genTestEncodingValuesLink() map[string]*otlpprofiles.Link { - return map[string]*otlpprofiles.Link{ - "empty": NewOrigLink(), - "TraceId/test": {TraceId: *GenTestOrigTraceID()}, - "SpanId/test": {SpanId: *GenTestOrigSpanID()}, +func genTestEncodingValuesLink() map[string]*Link { + return map[string]*Link{ + "empty": NewLink(), + "TraceId/test": {TraceId: *GenTestTraceID()}, + "SpanId/test": {SpanId: *GenTestSpanID()}, } } diff --git a/pdata/internal/generated_wrapper_location.go b/pdata/internal/generated_proto_location.go similarity index 60% rename from pdata/internal/generated_wrapper_location.go rename to pdata/internal/generated_proto_location.go index f36da20a6e2..7b16e381ff5 100644 --- a/pdata/internal/generated_wrapper_location.go +++ b/pdata/internal/generated_proto_location.go @@ -10,27 +10,34 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Location describes function and line table debug information. +type Location struct { + MappingIndex int32 + Address uint64 + Line []*Line + AttributeIndices []int32 +} + var ( protoPoolLocation = sync.Pool{ New: func() any { - return &otlpprofiles.Location{} + return &Location{} }, } ) -func NewOrigLocation() *otlpprofiles.Location { +func NewLocation() *Location { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Location{} + return &Location{} } - return protoPoolLocation.Get().(*otlpprofiles.Location) + return protoPoolLocation.Get().(*Location) } -func DeleteOrigLocation(orig *otlpprofiles.Location, nullable bool) { +func DeleteLocation(orig *Location, nullable bool) { if orig == nil { return } @@ -41,7 +48,7 @@ func DeleteOrigLocation(orig *otlpprofiles.Location, nullable bool) { } for i := range orig.Line { - DeleteOrigLine(orig.Line[i], true) + DeleteLine(orig.Line[i], true) } orig.Reset() @@ -50,28 +57,84 @@ func DeleteOrigLocation(orig *otlpprofiles.Location, nullable bool) { } } -func CopyOrigLocation(dest, src *otlpprofiles.Location) { +func CopyLocation(dest, src *Location) *Location { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewLocation() } dest.MappingIndex = src.MappingIndex + dest.Address = src.Address - dest.Line = CopyOrigLineSlice(dest.Line, src.Line) - dest.AttributeIndices = CopyOrigInt32Slice(dest.AttributeIndices, src.AttributeIndices) + + dest.Line = CopyLinePtrSlice(dest.Line, src.Line) + + dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) + + return dest } -func GenTestOrigLocation() *otlpprofiles.Location { - orig := NewOrigLocation() - orig.MappingIndex = int32(13) - orig.Address = uint64(13) - orig.Line = GenerateOrigTestLineSlice() - orig.AttributeIndices = GenerateOrigTestInt32Slice() - return orig +func CopyLocationSlice(dest, src []Location) []Location { + var newDest []Location + if cap(dest) < len(src) { + newDest = make([]Location, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLocation(&dest[i], false) + } + } + for i := range src { + CopyLocation(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigLocation(orig *otlpprofiles.Location, dest *json.Stream) { +func CopyLocationPtrSlice(dest, src []*Location) []*Location { + var newDest []*Location + if cap(dest) < len(src) { + newDest = make([]*Location, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLocation() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLocation(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLocation() + } + } + for i := range src { + CopyLocation(newDest[i], src[i]) + } + return newDest +} + +func (orig *Location) Reset() { + *orig = Location{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Location) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.MappingIndex != int32(0) { dest.WriteObjectField("mappingIndex") @@ -84,10 +147,10 @@ func MarshalJSONOrigLocation(orig *otlpprofiles.Location, dest *json.Stream) { if len(orig.Line) > 0 { dest.WriteObjectField("line") dest.WriteArrayStart() - MarshalJSONOrigLine(orig.Line[0], dest) + orig.Line[0].MarshalJSON(dest) for i := 1; i < len(orig.Line); i++ { dest.WriteMore() - MarshalJSONOrigLine(orig.Line[i], dest) + orig.Line[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -104,8 +167,8 @@ func MarshalJSONOrigLocation(orig *otlpprofiles.Location, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigLocation unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigLocation(orig *otlpprofiles.Location, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Location) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "mappingIndex", "mapping_index": @@ -114,8 +177,8 @@ func UnmarshalJSONOrigLocation(orig *otlpprofiles.Location, iter *json.Iterator) orig.Address = iter.ReadUint64() case "line": for iter.ReadArray() { - orig.Line = append(orig.Line, NewOrigLine()) - UnmarshalJSONOrigLine(orig.Line[len(orig.Line)-1], iter) + orig.Line = append(orig.Line, NewLine()) + orig.Line[len(orig.Line)-1].UnmarshalJSON(iter) } case "attributeIndices", "attribute_indices": @@ -129,7 +192,7 @@ func UnmarshalJSONOrigLocation(orig *otlpprofiles.Location, iter *json.Iterator) } } -func SizeProtoOrigLocation(orig *otlpprofiles.Location) int { +func (orig *Location) SizeProto() int { var n int var l int _ = l @@ -140,7 +203,7 @@ func SizeProtoOrigLocation(orig *otlpprofiles.Location) int { n += 1 + proto.Sov(uint64(orig.Address)) } for i := range orig.Line { - l = SizeProtoOrigLine(orig.Line[i]) + l = orig.Line[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if len(orig.AttributeIndices) > 0 { @@ -153,7 +216,7 @@ func SizeProtoOrigLocation(orig *otlpprofiles.Location) int { return n } -func MarshalProtoOrigLocation(orig *otlpprofiles.Location, buf []byte) int { +func (orig *Location) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -168,7 +231,7 @@ func MarshalProtoOrigLocation(orig *otlpprofiles.Location, buf []byte) int { buf[pos] = 0x10 } for i := len(orig.Line) - 1; i >= 0; i-- { - l = MarshalProtoOrigLine(orig.Line[i], buf[:pos]) + l = orig.Line[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -187,7 +250,7 @@ func MarshalProtoOrigLocation(orig *otlpprofiles.Location, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigLocation(orig *otlpprofiles.Location, buf []byte) error { +func (orig *Location) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -236,8 +299,8 @@ func UnmarshalProtoOrigLocation(orig *otlpprofiles.Location, buf []byte) error { return err } startPos := pos - length - orig.Line = append(orig.Line, NewOrigLine()) - err = UnmarshalProtoOrigLine(orig.Line[len(orig.Line)-1], buf[startPos:pos]) + orig.Line = append(orig.Line, NewLine()) + err = orig.Line[len(orig.Line)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -280,3 +343,29 @@ func UnmarshalProtoOrigLocation(orig *otlpprofiles.Location, buf []byte) error { } return nil } + +func GenTestLocation() *Location { + orig := NewLocation() + orig.MappingIndex = int32(13) + orig.Address = uint64(13) + orig.Line = []*Line{{}, GenTestLine()} + orig.AttributeIndices = []int32{int32(0), int32(13)} + return orig +} + +func GenTestLocationPtrSlice() []*Location { + orig := make([]*Location, 5) + orig[0] = NewLocation() + orig[1] = GenTestLocation() + orig[2] = NewLocation() + orig[3] = GenTestLocation() + orig[4] = NewLocation() + return orig +} + +func GenTestLocationSlice() []Location { + orig := make([]Location, 5) + orig[1] = *GenTestLocation() + orig[3] = *GenTestLocation() + return orig +} diff --git a/pdata/internal/generated_wrapper_location_test.go b/pdata/internal/generated_proto_location_test.go similarity index 54% rename from pdata/internal/generated_wrapper_location_test.go rename to pdata/internal/generated_proto_location_test.go index 445b9fbe6dd..e76a8df0551 100644 --- a/pdata/internal/generated_wrapper_location_test.go +++ b/pdata/internal/generated_proto_location_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigLocation(t *testing.T) { +func TestCopyLocation(t *testing.T) { for name, src := range genTestEncodingValuesLocation() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigLocation(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigLocation() - CopyOrigLocation(dest, src) + dest := NewLocation() + CopyLocation(dest, src) assert.Equal(t, src, dest) - CopyOrigLocation(dest, dest) + CopyLocation(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigLocationUnknown(t *testing.T) { +func TestCopyLocationSlice(t *testing.T) { + src := []Location{} + dest := []Location{} + // Test CopyTo empty + dest = CopyLocationSlice(dest, src) + assert.Equal(t, []Location{}, dest) + + // Test CopyTo larger slice + src = GenTestLocationSlice() + dest = CopyLocationSlice(dest, src) + assert.Equal(t, GenTestLocationSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLocationSlice(dest, src) + assert.Equal(t, GenTestLocationSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLocationSlice(dest, []Location{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLocationSlice(dest, src) + assert.Equal(t, GenTestLocationSlice(), dest) +} + +func TestCopyLocationPtrSlice(t *testing.T) { + src := []*Location{} + dest := []*Location{} + // Test CopyTo empty + dest = CopyLocationPtrSlice(dest, src) + assert.Equal(t, []*Location{}, dest) + + // Test CopyTo larger slice + src = GenTestLocationPtrSlice() + dest = CopyLocationPtrSlice(dest, src) + assert.Equal(t, GenTestLocationPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLocationPtrSlice(dest, src) + assert.Equal(t, GenTestLocationPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLocationPtrSlice(dest, []*Location{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLocationPtrSlice(dest, src) + assert.Equal(t, GenTestLocationPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONLocationUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigLocation() - UnmarshalJSONOrigLocation(dest, iter) + dest := NewLocation() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigLocation(), dest) + assert.Equal(t, NewLocation(), dest) } -func TestMarshalAndUnmarshalJSONOrigLocation(t *testing.T) { +func TestMarshalAndUnmarshalJSONLocation(t *testing.T) { for name, src := range genTestEncodingValuesLocation() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigLocation(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigLocation(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigLocation() - UnmarshalJSONOrigLocation(dest, iter) + dest := NewLocation() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigLocation(dest, true) + DeleteLocation(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigLocationFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoLocationFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesLocation() { t.Run(name, func(t *testing.T) { - dest := NewOrigLocation() - require.Error(t, UnmarshalProtoOrigLocation(dest, buf)) + dest := NewLocation() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigLocationUnknown(t *testing.T) { - dest := NewOrigLocation() +func TestMarshalAndUnmarshalProtoLocationUnknown(t *testing.T) { + dest := NewLocation() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigLocation(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigLocation(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewLocation(), dest) } -func TestMarshalAndUnmarshalProtoOrigLocation(t *testing.T) { +func TestMarshalAndUnmarshalProtoLocation(t *testing.T) { for name, src := range genTestEncodingValuesLocation() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigLocation(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigLocation(src)) - gotSize := MarshalProtoOrigLocation(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigLocation() - require.NoError(t, UnmarshalProtoOrigLocation(dest, buf)) + dest := NewLocation() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigLocation(dest, true) + DeleteLocation(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigLocation(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufLocation(t *testing.T) { for name, src := range genTestEncodingValuesLocation() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigLocation(src)) - gotSize := MarshalProtoOrigLocation(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Location{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufLocation(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigLocation() - require.NoError(t, UnmarshalProtoOrigLocation(dest, goBuf)) + dest := NewLocation() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -151,12 +200,12 @@ func genTestFailingUnmarshalProtoValuesLocation() map[string][]byte { } } -func genTestEncodingValuesLocation() map[string]*otlpprofiles.Location { - return map[string]*otlpprofiles.Location{ - "empty": NewOrigLocation(), - "MappingIndex/test": {MappingIndex: int32(13)}, - "Address/test": {Address: uint64(13)}, - "Line/default_and_test": {Line: []*otlpprofiles.Line{{}, GenTestOrigLine()}}, - "AttributeIndices/default_and_test": {AttributeIndices: []int32{int32(0), int32(13)}}, +func genTestEncodingValuesLocation() map[string]*Location { + return map[string]*Location{ + "empty": NewLocation(), + "MappingIndex/test": {MappingIndex: int32(13)}, + "Address/test": {Address: uint64(13)}, + "Line/test": {Line: []*Line{{}, GenTestLine()}}, + "AttributeIndices/test": {AttributeIndices: []int32{int32(0), int32(13)}}, } } diff --git a/pdata/internal/generated_wrapper_logrecord.go b/pdata/internal/generated_proto_logrecord.go similarity index 64% rename from pdata/internal/generated_wrapper_logrecord.go rename to pdata/internal/generated_proto_logrecord.go index a43fdb38bfd..8ef100c1347 100644 --- a/pdata/internal/generated_wrapper_logrecord.go +++ b/pdata/internal/generated_proto_logrecord.go @@ -11,29 +11,42 @@ import ( "fmt" "sync" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// LogRecord are experimental implementation of OpenTelemetry Log Data Model. + +type LogRecord struct { + TimeUnixNano uint64 + ObservedTimeUnixNano uint64 + SeverityNumber SeverityNumber + SeverityText string + Body AnyValue + Attributes []KeyValue + DroppedAttributesCount uint32 + Flags uint32 + TraceId TraceID + SpanId SpanID + EventName string +} + var ( protoPoolLogRecord = sync.Pool{ New: func() any { - return &otlplogs.LogRecord{} + return &LogRecord{} }, } ) -func NewOrigLogRecord() *otlplogs.LogRecord { +func NewLogRecord() *LogRecord { if !UseProtoPooling.IsEnabled() { - return &otlplogs.LogRecord{} + return &LogRecord{} } - return protoPoolLogRecord.Get().(*otlplogs.LogRecord) + return protoPoolLogRecord.Get().(*LogRecord) } -func DeleteOrigLogRecord(orig *otlplogs.LogRecord, nullable bool) { +func DeleteLogRecord(orig *LogRecord, nullable bool) { if orig == nil { return } @@ -43,12 +56,12 @@ func DeleteOrigLogRecord(orig *otlplogs.LogRecord, nullable bool) { return } - DeleteOrigAnyValue(&orig.Body, false) + DeleteAnyValue(&orig.Body, false) for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } - DeleteOrigTraceID(&orig.TraceId, false) - DeleteOrigSpanID(&orig.SpanId, false) + DeleteTraceID(&orig.TraceId, false) + DeleteSpanID(&orig.SpanId, false) orig.Reset() if nullable { @@ -56,42 +69,98 @@ func DeleteOrigLogRecord(orig *otlplogs.LogRecord, nullable bool) { } } -func CopyOrigLogRecord(dest, src *otlplogs.LogRecord) { +func CopyLogRecord(dest, src *LogRecord) *LogRecord { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewLogRecord() } dest.TimeUnixNano = src.TimeUnixNano + dest.ObservedTimeUnixNano = src.ObservedTimeUnixNano + dest.SeverityNumber = src.SeverityNumber + dest.SeverityText = src.SeverityText - CopyOrigAnyValue(&dest.Body, &src.Body) - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + CopyAnyValue(&dest.Body, &src.Body) + + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + dest.DroppedAttributesCount = src.DroppedAttributesCount + dest.Flags = src.Flags - dest.TraceId = src.TraceId - dest.SpanId = src.SpanId + + CopyTraceID(&dest.TraceId, &src.TraceId) + + CopySpanID(&dest.SpanId, &src.SpanId) + dest.EventName = src.EventName + + return dest } -func GenTestOrigLogRecord() *otlplogs.LogRecord { - orig := NewOrigLogRecord() - orig.TimeUnixNano = 1234567890 - orig.ObservedTimeUnixNano = 1234567890 - orig.SeverityNumber = otlplogs.SeverityNumber(5) - orig.SeverityText = "test_severitytext" - orig.Body = *GenTestOrigAnyValue() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.DroppedAttributesCount = uint32(13) - orig.Flags = 1 - orig.TraceId = data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - orig.SpanId = data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) - orig.EventName = "test_eventname" - return orig +func CopyLogRecordSlice(dest, src []LogRecord) []LogRecord { + var newDest []LogRecord + if cap(dest) < len(src) { + newDest = make([]LogRecord, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLogRecord(&dest[i], false) + } + } + for i := range src { + CopyLogRecord(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, dest *json.Stream) { +func CopyLogRecordPtrSlice(dest, src []*LogRecord) []*LogRecord { + var newDest []*LogRecord + if cap(dest) < len(src) { + newDest = make([]*LogRecord, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLogRecord() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLogRecord(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLogRecord() + } + } + for i := range src { + CopyLogRecord(newDest[i], src[i]) + } + return newDest +} + +func (orig *LogRecord) Reset() { + *orig = LogRecord{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *LogRecord) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.TimeUnixNano != uint64(0) { dest.WriteObjectField("timeUnixNano") @@ -111,14 +180,14 @@ func MarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, dest *json.Stream) { dest.WriteString(orig.SeverityText) } dest.WriteObjectField("body") - MarshalJSONOrigAnyValue(&orig.Body, dest) + orig.Body.MarshalJSON(dest) if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -130,13 +199,13 @@ func MarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, dest *json.Stream) { dest.WriteObjectField("flags") dest.WriteUint32(orig.Flags) } - if orig.TraceId != data.TraceID([16]byte{}) { + if !orig.TraceId.IsEmpty() { dest.WriteObjectField("traceId") - MarshalJSONOrigTraceID(&orig.TraceId, dest) + orig.TraceId.MarshalJSON(dest) } - if orig.SpanId != data.SpanID([8]byte{}) { + if !orig.SpanId.IsEmpty() { dest.WriteObjectField("spanId") - MarshalJSONOrigSpanID(&orig.SpanId, dest) + orig.SpanId.MarshalJSON(dest) } if orig.EventName != "" { dest.WriteObjectField("eventName") @@ -145,8 +214,8 @@ func MarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigLogRecord unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *LogRecord) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "timeUnixNano", "time_unix_nano": @@ -154,15 +223,16 @@ func UnmarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, iter *json.Iterator) { case "observedTimeUnixNano", "observed_time_unix_nano": orig.ObservedTimeUnixNano = iter.ReadUint64() case "severityNumber", "severity_number": - orig.SeverityNumber = otlplogs.SeverityNumber(iter.ReadEnumValue(otlplogs.SeverityNumber_value)) + orig.SeverityNumber = SeverityNumber(iter.ReadEnumValue(SeverityNumber_value)) case "severityText", "severity_text": orig.SeverityText = iter.ReadString() case "body": - UnmarshalJSONOrigAnyValue(&orig.Body, iter) + + orig.Body.UnmarshalJSON(iter) case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "droppedAttributesCount", "dropped_attributes_count": @@ -170,9 +240,11 @@ func UnmarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, iter *json.Iterator) { case "flags": orig.Flags = iter.ReadUint32() case "traceId", "trace_id": - UnmarshalJSONOrigTraceID(&orig.TraceId, iter) + + orig.TraceId.UnmarshalJSON(iter) case "spanId", "span_id": - UnmarshalJSONOrigSpanID(&orig.SpanId, iter) + + orig.SpanId.UnmarshalJSON(iter) case "eventName", "event_name": orig.EventName = iter.ReadString() default: @@ -181,7 +253,7 @@ func UnmarshalJSONOrigLogRecord(orig *otlplogs.LogRecord, iter *json.Iterator) { } } -func SizeProtoOrigLogRecord(orig *otlplogs.LogRecord) int { +func (orig *LogRecord) SizeProto() int { var n int var l int _ = l @@ -198,10 +270,10 @@ func SizeProtoOrigLogRecord(orig *otlplogs.LogRecord) int { if l > 0 { n += 1 + proto.Sov(uint64(l)) + l } - l = SizeProtoOrigAnyValue(&orig.Body) + l = orig.Body.SizeProto() n += 1 + proto.Sov(uint64(l)) + l for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.DroppedAttributesCount != 0 { @@ -210,9 +282,9 @@ func SizeProtoOrigLogRecord(orig *otlplogs.LogRecord) int { if orig.Flags != 0 { n += 5 } - l = SizeProtoOrigTraceID(&orig.TraceId) + l = orig.TraceId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - l = SizeProtoOrigSpanID(&orig.SpanId) + l = orig.SpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l l = len(orig.EventName) if l > 0 { @@ -221,7 +293,7 @@ func SizeProtoOrigLogRecord(orig *otlplogs.LogRecord) int { return n } -func MarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) int { +func (orig *LogRecord) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -250,15 +322,14 @@ func MarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) int { pos-- buf[pos] = 0x1a } - - l = MarshalProtoOrigAnyValue(&orig.Body, buf[:pos]) + l = orig.Body.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x2a for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -275,14 +346,13 @@ func MarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) int { pos-- buf[pos] = 0x45 } - - l = MarshalProtoOrigTraceID(&orig.TraceId, buf[:pos]) + l = orig.TraceId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x4a - l = MarshalProtoOrigSpanID(&orig.SpanId, buf[:pos]) + l = orig.SpanId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -299,7 +369,7 @@ func MarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { +func (orig *LogRecord) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -348,7 +418,7 @@ func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { return err } - orig.SeverityNumber = otlplogs.SeverityNumber(num) + orig.SeverityNumber = SeverityNumber(num) case 3: if wireType != proto.WireTypeLen { @@ -373,7 +443,7 @@ func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigAnyValue(&orig.Body, buf[startPos:pos]) + err = orig.Body.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -388,8 +458,8 @@ func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -429,7 +499,7 @@ func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigTraceID(&orig.TraceId, buf[startPos:pos]) + err = orig.TraceId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -445,7 +515,7 @@ func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigSpanID(&orig.SpanId, buf[startPos:pos]) + err = orig.SpanId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -470,3 +540,36 @@ func UnmarshalProtoOrigLogRecord(orig *otlplogs.LogRecord, buf []byte) error { } return nil } + +func GenTestLogRecord() *LogRecord { + orig := NewLogRecord() + orig.TimeUnixNano = uint64(13) + orig.ObservedTimeUnixNano = uint64(13) + orig.SeverityNumber = SeverityNumber(13) + orig.SeverityText = "test_severitytext" + orig.Body = *GenTestAnyValue() + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.DroppedAttributesCount = uint32(13) + orig.Flags = uint32(13) + orig.TraceId = *GenTestTraceID() + orig.SpanId = *GenTestSpanID() + orig.EventName = "test_eventname" + return orig +} + +func GenTestLogRecordPtrSlice() []*LogRecord { + orig := make([]*LogRecord, 5) + orig[0] = NewLogRecord() + orig[1] = GenTestLogRecord() + orig[2] = NewLogRecord() + orig[3] = GenTestLogRecord() + orig[4] = NewLogRecord() + return orig +} + +func GenTestLogRecordSlice() []LogRecord { + orig := make([]LogRecord, 5) + orig[1] = *GenTestLogRecord() + orig[3] = *GenTestLogRecord() + return orig +} diff --git a/pdata/internal/generated_wrapper_logrecord_test.go b/pdata/internal/generated_proto_logrecord_test.go similarity index 60% rename from pdata/internal/generated_wrapper_logrecord_test.go rename to pdata/internal/generated_proto_logrecord_test.go index 026ee050903..6f2df992731 100644 --- a/pdata/internal/generated_wrapper_logrecord_test.go +++ b/pdata/internal/generated_proto_logrecord_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigLogRecord(t *testing.T) { +func TestCopyLogRecord(t *testing.T) { for name, src := range genTestEncodingValuesLogRecord() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigLogRecord(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigLogRecord() - CopyOrigLogRecord(dest, src) + dest := NewLogRecord() + CopyLogRecord(dest, src) assert.Equal(t, src, dest) - CopyOrigLogRecord(dest, dest) + CopyLogRecord(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigLogRecordUnknown(t *testing.T) { +func TestCopyLogRecordSlice(t *testing.T) { + src := []LogRecord{} + dest := []LogRecord{} + // Test CopyTo empty + dest = CopyLogRecordSlice(dest, src) + assert.Equal(t, []LogRecord{}, dest) + + // Test CopyTo larger slice + src = GenTestLogRecordSlice() + dest = CopyLogRecordSlice(dest, src) + assert.Equal(t, GenTestLogRecordSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLogRecordSlice(dest, src) + assert.Equal(t, GenTestLogRecordSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLogRecordSlice(dest, []LogRecord{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLogRecordSlice(dest, src) + assert.Equal(t, GenTestLogRecordSlice(), dest) +} + +func TestCopyLogRecordPtrSlice(t *testing.T) { + src := []*LogRecord{} + dest := []*LogRecord{} + // Test CopyTo empty + dest = CopyLogRecordPtrSlice(dest, src) + assert.Equal(t, []*LogRecord{}, dest) + + // Test CopyTo larger slice + src = GenTestLogRecordPtrSlice() + dest = CopyLogRecordPtrSlice(dest, src) + assert.Equal(t, GenTestLogRecordPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLogRecordPtrSlice(dest, src) + assert.Equal(t, GenTestLogRecordPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLogRecordPtrSlice(dest, []*LogRecord{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLogRecordPtrSlice(dest, src) + assert.Equal(t, GenTestLogRecordPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONLogRecordUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigLogRecord() - UnmarshalJSONOrigLogRecord(dest, iter) + dest := NewLogRecord() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigLogRecord(), dest) + assert.Equal(t, NewLogRecord(), dest) } -func TestMarshalAndUnmarshalJSONOrigLogRecord(t *testing.T) { +func TestMarshalAndUnmarshalJSONLogRecord(t *testing.T) { for name, src := range genTestEncodingValuesLogRecord() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigLogRecord(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigLogRecord(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigLogRecord() - UnmarshalJSONOrigLogRecord(dest, iter) + dest := NewLogRecord() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigLogRecord(dest, true) + DeleteLogRecord(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigLogRecordFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoLogRecordFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesLogRecord() { t.Run(name, func(t *testing.T) { - dest := NewOrigLogRecord() - require.Error(t, UnmarshalProtoOrigLogRecord(dest, buf)) + dest := NewLogRecord() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigLogRecordUnknown(t *testing.T) { - dest := NewOrigLogRecord() +func TestMarshalAndUnmarshalProtoLogRecordUnknown(t *testing.T) { + dest := NewLogRecord() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigLogRecord(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigLogRecord(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewLogRecord(), dest) } -func TestMarshalAndUnmarshalProtoOrigLogRecord(t *testing.T) { +func TestMarshalAndUnmarshalProtoLogRecord(t *testing.T) { for name, src := range genTestEncodingValuesLogRecord() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigLogRecord(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigLogRecord(src)) - gotSize := MarshalProtoOrigLogRecord(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigLogRecord() - require.NoError(t, UnmarshalProtoOrigLogRecord(dest, buf)) + dest := NewLogRecord() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigLogRecord(dest, true) + DeleteLogRecord(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigLogRecord(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufLogRecord(t *testing.T) { for name, src := range genTestEncodingValuesLogRecord() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigLogRecord(src)) - gotSize := MarshalProtoOrigLogRecord(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlplogs.LogRecord{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufLogRecord(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigLogRecord() - require.NoError(t, UnmarshalProtoOrigLogRecord(dest, goBuf)) + dest := NewLogRecord() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -166,19 +214,19 @@ func genTestFailingUnmarshalProtoValuesLogRecord() map[string][]byte { } } -func genTestEncodingValuesLogRecord() map[string]*otlplogs.LogRecord { - return map[string]*otlplogs.LogRecord{ - "empty": NewOrigLogRecord(), +func genTestEncodingValuesLogRecord() map[string]*LogRecord { + return map[string]*LogRecord{ + "empty": NewLogRecord(), "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, "ObservedTimeUnixNano/test": {ObservedTimeUnixNano: uint64(13)}, - "SeverityNumber/test": {SeverityNumber: otlplogs.SeverityNumber(13)}, + "SeverityNumber/test": {SeverityNumber: SeverityNumber(13)}, "SeverityText/test": {SeverityText: "test_severitytext"}, - "Body/test": {Body: *GenTestOrigAnyValue()}, - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, + "Body/test": {Body: *GenTestAnyValue()}, + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, "Flags/test": {Flags: uint32(13)}, - "TraceId/test": {TraceId: *GenTestOrigTraceID()}, - "SpanId/test": {SpanId: *GenTestOrigSpanID()}, + "TraceId/test": {TraceId: *GenTestTraceID()}, + "SpanId/test": {SpanId: *GenTestSpanID()}, "EventName/test": {EventName: "test_eventname"}, } } diff --git a/pdata/internal/generated_proto_logsdata.go b/pdata/internal/generated_proto_logsdata.go new file mode 100644 index 00000000000..8b7cf668f93 --- /dev/null +++ b/pdata/internal/generated_proto_logsdata.go @@ -0,0 +1,247 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// LogsData represents the logs data that can be stored in a persistent storage, +// OR can be embedded by other protocols that transfer OTLP logs data but do not +// implement the OTLP protocol. +type LogsData struct { + ResourceLogs []*ResourceLogs +} + +var ( + protoPoolLogsData = sync.Pool{ + New: func() any { + return &LogsData{} + }, + } +) + +func NewLogsData() *LogsData { + if !UseProtoPooling.IsEnabled() { + return &LogsData{} + } + return protoPoolLogsData.Get().(*LogsData) +} + +func DeleteLogsData(orig *LogsData, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceLogs { + DeleteResourceLogs(orig.ResourceLogs[i], true) + } + + orig.Reset() + if nullable { + protoPoolLogsData.Put(orig) + } +} + +func CopyLogsData(dest, src *LogsData) *LogsData { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewLogsData() + } + dest.ResourceLogs = CopyResourceLogsPtrSlice(dest.ResourceLogs, src.ResourceLogs) + + return dest +} + +func CopyLogsDataSlice(dest, src []LogsData) []LogsData { + var newDest []LogsData + if cap(dest) < len(src) { + newDest = make([]LogsData, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLogsData(&dest[i], false) + } + } + for i := range src { + CopyLogsData(&newDest[i], &src[i]) + } + return newDest +} + +func CopyLogsDataPtrSlice(dest, src []*LogsData) []*LogsData { + var newDest []*LogsData + if cap(dest) < len(src) { + newDest = make([]*LogsData, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLogsData() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLogsData(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLogsData() + } + } + for i := range src { + CopyLogsData(newDest[i], src[i]) + } + return newDest +} + +func (orig *LogsData) Reset() { + *orig = LogsData{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *LogsData) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceLogs) > 0 { + dest.WriteObjectField("resourceLogs") + dest.WriteArrayStart() + orig.ResourceLogs[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceLogs); i++ { + dest.WriteMore() + orig.ResourceLogs[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *LogsData) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceLogs", "resource_logs": + for iter.ReadArray() { + orig.ResourceLogs = append(orig.ResourceLogs, NewResourceLogs()) + orig.ResourceLogs[len(orig.ResourceLogs)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *LogsData) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceLogs { + l = orig.ResourceLogs[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *LogsData) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceLogs) - 1; i >= 0; i-- { + l = orig.ResourceLogs[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *LogsData) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceLogs = append(orig.ResourceLogs, NewResourceLogs()) + err = orig.ResourceLogs[len(orig.ResourceLogs)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestLogsData() *LogsData { + orig := NewLogsData() + orig.ResourceLogs = []*ResourceLogs{{}, GenTestResourceLogs()} + return orig +} + +func GenTestLogsDataPtrSlice() []*LogsData { + orig := make([]*LogsData, 5) + orig[0] = NewLogsData() + orig[1] = GenTestLogsData() + orig[2] = NewLogsData() + orig[3] = GenTestLogsData() + orig[4] = NewLogsData() + return orig +} + +func GenTestLogsDataSlice() []LogsData { + orig := make([]LogsData, 5) + orig[1] = *GenTestLogsData() + orig[3] = *GenTestLogsData() + return orig +} diff --git a/pdata/internal/generated_proto_logsdata_test.go b/pdata/internal/generated_proto_logsdata_test.go new file mode 100644 index 00000000000..871778d1c78 --- /dev/null +++ b/pdata/internal/generated_proto_logsdata_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlplogs "go.opentelemetry.io/proto/slim/otlp/logs/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyLogsData(t *testing.T) { + for name, src := range genTestEncodingValuesLogsData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewLogsData() + CopyLogsData(dest, src) + assert.Equal(t, src, dest) + CopyLogsData(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyLogsDataSlice(t *testing.T) { + src := []LogsData{} + dest := []LogsData{} + // Test CopyTo empty + dest = CopyLogsDataSlice(dest, src) + assert.Equal(t, []LogsData{}, dest) + + // Test CopyTo larger slice + src = GenTestLogsDataSlice() + dest = CopyLogsDataSlice(dest, src) + assert.Equal(t, GenTestLogsDataSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLogsDataSlice(dest, src) + assert.Equal(t, GenTestLogsDataSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLogsDataSlice(dest, []LogsData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLogsDataSlice(dest, src) + assert.Equal(t, GenTestLogsDataSlice(), dest) +} + +func TestCopyLogsDataPtrSlice(t *testing.T) { + src := []*LogsData{} + dest := []*LogsData{} + // Test CopyTo empty + dest = CopyLogsDataPtrSlice(dest, src) + assert.Equal(t, []*LogsData{}, dest) + + // Test CopyTo larger slice + src = GenTestLogsDataPtrSlice() + dest = CopyLogsDataPtrSlice(dest, src) + assert.Equal(t, GenTestLogsDataPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLogsDataPtrSlice(dest, src) + assert.Equal(t, GenTestLogsDataPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLogsDataPtrSlice(dest, []*LogsData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLogsDataPtrSlice(dest, src) + assert.Equal(t, GenTestLogsDataPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONLogsDataUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewLogsData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewLogsData(), dest) +} + +func TestMarshalAndUnmarshalJSONLogsData(t *testing.T) { + for name, src := range genTestEncodingValuesLogsData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewLogsData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteLogsData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoLogsDataFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesLogsData() { + t.Run(name, func(t *testing.T) { + dest := NewLogsData() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoLogsDataUnknown(t *testing.T) { + dest := NewLogsData() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewLogsData(), dest) +} + +func TestMarshalAndUnmarshalProtoLogsData(t *testing.T) { + for name, src := range genTestEncodingValuesLogsData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewLogsData() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteLogsData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufLogsData(t *testing.T) { + for name, src := range genTestEncodingValuesLogsData() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlplogs.LogsData{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewLogsData() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesLogsData() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceLogs/wrong_wire_type": {0xc}, + "ResourceLogs/missing_value": {0xa}, + } +} + +func genTestEncodingValuesLogsData() map[string]*LogsData { + return map[string]*LogsData{ + "empty": NewLogsData(), + "ResourceLogs/test": {ResourceLogs: []*ResourceLogs{{}, GenTestResourceLogs()}}, + } +} diff --git a/pdata/internal/generated_proto_logsrequest.go b/pdata/internal/generated_proto_logsrequest.go new file mode 100644 index 00000000000..60bae8a7894 --- /dev/null +++ b/pdata/internal/generated_proto_logsrequest.go @@ -0,0 +1,300 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type LogsRequest struct { + RequestContext *RequestContext + LogsData LogsData + FormatVersion uint32 +} + +var ( + protoPoolLogsRequest = sync.Pool{ + New: func() any { + return &LogsRequest{} + }, + } +) + +func NewLogsRequest() *LogsRequest { + if !UseProtoPooling.IsEnabled() { + return &LogsRequest{} + } + return protoPoolLogsRequest.Get().(*LogsRequest) +} + +func DeleteLogsRequest(orig *LogsRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteRequestContext(orig.RequestContext, true) + DeleteLogsData(&orig.LogsData, false) + + orig.Reset() + if nullable { + protoPoolLogsRequest.Put(orig) + } +} + +func CopyLogsRequest(dest, src *LogsRequest) *LogsRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewLogsRequest() + } + dest.RequestContext = CopyRequestContext(dest.RequestContext, src.RequestContext) + + CopyLogsData(&dest.LogsData, &src.LogsData) + + dest.FormatVersion = src.FormatVersion + + return dest +} + +func CopyLogsRequestSlice(dest, src []LogsRequest) []LogsRequest { + var newDest []LogsRequest + if cap(dest) < len(src) { + newDest = make([]LogsRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLogsRequest(&dest[i], false) + } + } + for i := range src { + CopyLogsRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyLogsRequestPtrSlice(dest, src []*LogsRequest) []*LogsRequest { + var newDest []*LogsRequest + if cap(dest) < len(src) { + newDest = make([]*LogsRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLogsRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteLogsRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewLogsRequest() + } + } + for i := range src { + CopyLogsRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *LogsRequest) Reset() { + *orig = LogsRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *LogsRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RequestContext != nil { + dest.WriteObjectField("requestContext") + orig.RequestContext.MarshalJSON(dest) + } + dest.WriteObjectField("logsData") + orig.LogsData.MarshalJSON(dest) + if orig.FormatVersion != uint32(0) { + dest.WriteObjectField("formatVersion") + dest.WriteUint32(orig.FormatVersion) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *LogsRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "requestContext", "request_context": + orig.RequestContext = NewRequestContext() + orig.RequestContext.UnmarshalJSON(iter) + case "logsData", "logs_data": + + orig.LogsData.UnmarshalJSON(iter) + case "formatVersion", "format_version": + orig.FormatVersion = iter.ReadUint32() + default: + iter.Skip() + } + } +} + +func (orig *LogsRequest) SizeProto() int { + var n int + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + l = orig.LogsData.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + if orig.FormatVersion != 0 { + n += 5 + } + return n +} + +func (orig *LogsRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = orig.LogsData.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + + if orig.FormatVersion != 0 { + pos -= 4 + binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) + pos-- + buf[pos] = 0xd + } + return len(buf) - pos +} + +func (orig *LogsRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + orig.RequestContext = NewRequestContext() + err = orig.RequestContext.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field LogsData", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.LogsData.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 1: + if wireType != proto.WireTypeI32 { + return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) + } + var num uint32 + num, pos, err = proto.ConsumeI32(buf, pos) + if err != nil { + return err + } + + orig.FormatVersion = uint32(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestLogsRequest() *LogsRequest { + orig := NewLogsRequest() + orig.RequestContext = GenTestRequestContext() + orig.LogsData = *GenTestLogsData() + orig.FormatVersion = uint32(13) + return orig +} + +func GenTestLogsRequestPtrSlice() []*LogsRequest { + orig := make([]*LogsRequest, 5) + orig[0] = NewLogsRequest() + orig[1] = GenTestLogsRequest() + orig[2] = NewLogsRequest() + orig[3] = GenTestLogsRequest() + orig[4] = NewLogsRequest() + return orig +} + +func GenTestLogsRequestSlice() []LogsRequest { + orig := make([]LogsRequest, 5) + orig[1] = *GenTestLogsRequest() + orig[3] = *GenTestLogsRequest() + return orig +} diff --git a/pdata/internal/generated_proto_logsrequest_test.go b/pdata/internal/generated_proto_logsrequest_test.go new file mode 100644 index 00000000000..439c3380833 --- /dev/null +++ b/pdata/internal/generated_proto_logsrequest_test.go @@ -0,0 +1,208 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyLogsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesLogsRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewLogsRequest() + CopyLogsRequest(dest, src) + assert.Equal(t, src, dest) + CopyLogsRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyLogsRequestSlice(t *testing.T) { + src := []LogsRequest{} + dest := []LogsRequest{} + // Test CopyTo empty + dest = CopyLogsRequestSlice(dest, src) + assert.Equal(t, []LogsRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestLogsRequestSlice() + dest = CopyLogsRequestSlice(dest, src) + assert.Equal(t, GenTestLogsRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLogsRequestSlice(dest, src) + assert.Equal(t, GenTestLogsRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLogsRequestSlice(dest, []LogsRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLogsRequestSlice(dest, src) + assert.Equal(t, GenTestLogsRequestSlice(), dest) +} + +func TestCopyLogsRequestPtrSlice(t *testing.T) { + src := []*LogsRequest{} + dest := []*LogsRequest{} + // Test CopyTo empty + dest = CopyLogsRequestPtrSlice(dest, src) + assert.Equal(t, []*LogsRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestLogsRequestPtrSlice() + dest = CopyLogsRequestPtrSlice(dest, src) + assert.Equal(t, GenTestLogsRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyLogsRequestPtrSlice(dest, src) + assert.Equal(t, GenTestLogsRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyLogsRequestPtrSlice(dest, []*LogsRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyLogsRequestPtrSlice(dest, src) + assert.Equal(t, GenTestLogsRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONLogsRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewLogsRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewLogsRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONLogsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesLogsRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewLogsRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteLogsRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoLogsRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesLogsRequest() { + t.Run(name, func(t *testing.T) { + dest := NewLogsRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoLogsRequestUnknown(t *testing.T) { + dest := NewLogsRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewLogsRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoLogsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesLogsRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewLogsRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteLogsRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufLogsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesLogsRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewLogsRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesLogsRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "RequestContext/wrong_wire_type": {0x14}, + "RequestContext/missing_value": {0x12}, + "LogsData/wrong_wire_type": {0x1c}, + "LogsData/missing_value": {0x1a}, + "FormatVersion/wrong_wire_type": {0xc}, + "FormatVersion/missing_value": {0xd}, + } +} + +func genTestEncodingValuesLogsRequest() map[string]*LogsRequest { + return map[string]*LogsRequest{ + "empty": NewLogsRequest(), + "RequestContext/test": {RequestContext: GenTestRequestContext()}, + "LogsData/test": {LogsData: *GenTestLogsData()}, + "FormatVersion/test": {FormatVersion: uint32(13)}, + } +} diff --git a/pdata/internal/generated_wrapper_mapping.go b/pdata/internal/generated_proto_mapping.go similarity index 67% rename from pdata/internal/generated_wrapper_mapping.go rename to pdata/internal/generated_proto_mapping.go index b9220b05637..41b74624725 100644 --- a/pdata/internal/generated_wrapper_mapping.go +++ b/pdata/internal/generated_proto_mapping.go @@ -10,27 +10,35 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Mapping describes the mapping of a binary in memory, including its address range, file offset, and metadata like build ID +type Mapping struct { + MemoryStart uint64 + MemoryLimit uint64 + FileOffset uint64 + FilenameStrindex int32 + AttributeIndices []int32 +} + var ( protoPoolMapping = sync.Pool{ New: func() any { - return &otlpprofiles.Mapping{} + return &Mapping{} }, } ) -func NewOrigMapping() *otlpprofiles.Mapping { +func NewMapping() *Mapping { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Mapping{} + return &Mapping{} } - return protoPoolMapping.Get().(*otlpprofiles.Mapping) + return protoPoolMapping.Get().(*Mapping) } -func DeleteOrigMapping(orig *otlpprofiles.Mapping, nullable bool) { +func DeleteMapping(orig *Mapping, nullable bool) { if orig == nil { return } @@ -46,30 +54,86 @@ func DeleteOrigMapping(orig *otlpprofiles.Mapping, nullable bool) { } } -func CopyOrigMapping(dest, src *otlpprofiles.Mapping) { +func CopyMapping(dest, src *Mapping) *Mapping { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewMapping() } dest.MemoryStart = src.MemoryStart + dest.MemoryLimit = src.MemoryLimit + dest.FileOffset = src.FileOffset + dest.FilenameStrindex = src.FilenameStrindex - dest.AttributeIndices = CopyOrigInt32Slice(dest.AttributeIndices, src.AttributeIndices) + + dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) + + return dest } -func GenTestOrigMapping() *otlpprofiles.Mapping { - orig := NewOrigMapping() - orig.MemoryStart = uint64(13) - orig.MemoryLimit = uint64(13) - orig.FileOffset = uint64(13) - orig.FilenameStrindex = int32(13) - orig.AttributeIndices = GenerateOrigTestInt32Slice() - return orig +func CopyMappingSlice(dest, src []Mapping) []Mapping { + var newDest []Mapping + if cap(dest) < len(src) { + newDest = make([]Mapping, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMapping(&dest[i], false) + } + } + for i := range src { + CopyMapping(&newDest[i], &src[i]) + } + return newDest +} + +func CopyMappingPtrSlice(dest, src []*Mapping) []*Mapping { + var newDest []*Mapping + if cap(dest) < len(src) { + newDest = make([]*Mapping, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMapping() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMapping(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMapping() + } + } + for i := range src { + CopyMapping(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigMapping(orig *otlpprofiles.Mapping, dest *json.Stream) { +func (orig *Mapping) Reset() { + *orig = Mapping{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Mapping) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.MemoryStart != uint64(0) { dest.WriteObjectField("memoryStart") @@ -100,8 +164,8 @@ func MarshalJSONOrigMapping(orig *otlpprofiles.Mapping, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigMapping unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigMapping(orig *otlpprofiles.Mapping, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Mapping) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "memoryStart", "memory_start": @@ -123,7 +187,7 @@ func UnmarshalJSONOrigMapping(orig *otlpprofiles.Mapping, iter *json.Iterator) { } } -func SizeProtoOrigMapping(orig *otlpprofiles.Mapping) int { +func (orig *Mapping) SizeProto() int { var n int var l int _ = l @@ -149,7 +213,7 @@ func SizeProtoOrigMapping(orig *otlpprofiles.Mapping) int { return n } -func MarshalProtoOrigMapping(orig *otlpprofiles.Mapping, buf []byte) int { +func (orig *Mapping) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -186,7 +250,7 @@ func MarshalProtoOrigMapping(orig *otlpprofiles.Mapping, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigMapping(orig *otlpprofiles.Mapping, buf []byte) error { +func (orig *Mapping) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -287,3 +351,30 @@ func UnmarshalProtoOrigMapping(orig *otlpprofiles.Mapping, buf []byte) error { } return nil } + +func GenTestMapping() *Mapping { + orig := NewMapping() + orig.MemoryStart = uint64(13) + orig.MemoryLimit = uint64(13) + orig.FileOffset = uint64(13) + orig.FilenameStrindex = int32(13) + orig.AttributeIndices = []int32{int32(0), int32(13)} + return orig +} + +func GenTestMappingPtrSlice() []*Mapping { + orig := make([]*Mapping, 5) + orig[0] = NewMapping() + orig[1] = GenTestMapping() + orig[2] = NewMapping() + orig[3] = GenTestMapping() + orig[4] = NewMapping() + return orig +} + +func GenTestMappingSlice() []Mapping { + orig := make([]Mapping, 5) + orig[1] = *GenTestMapping() + orig[3] = *GenTestMapping() + return orig +} diff --git a/pdata/internal/generated_wrapper_mapping_test.go b/pdata/internal/generated_proto_mapping_test.go similarity index 55% rename from pdata/internal/generated_wrapper_mapping_test.go rename to pdata/internal/generated_proto_mapping_test.go index 3a960dc93a4..a539f0b74cf 100644 --- a/pdata/internal/generated_wrapper_mapping_test.go +++ b/pdata/internal/generated_proto_mapping_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigMapping(t *testing.T) { +func TestCopyMapping(t *testing.T) { for name, src := range genTestEncodingValuesMapping() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigMapping(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigMapping() - CopyOrigMapping(dest, src) + dest := NewMapping() + CopyMapping(dest, src) assert.Equal(t, src, dest) - CopyOrigMapping(dest, dest) + CopyMapping(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigMappingUnknown(t *testing.T) { +func TestCopyMappingSlice(t *testing.T) { + src := []Mapping{} + dest := []Mapping{} + // Test CopyTo empty + dest = CopyMappingSlice(dest, src) + assert.Equal(t, []Mapping{}, dest) + + // Test CopyTo larger slice + src = GenTestMappingSlice() + dest = CopyMappingSlice(dest, src) + assert.Equal(t, GenTestMappingSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMappingSlice(dest, src) + assert.Equal(t, GenTestMappingSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMappingSlice(dest, []Mapping{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMappingSlice(dest, src) + assert.Equal(t, GenTestMappingSlice(), dest) +} + +func TestCopyMappingPtrSlice(t *testing.T) { + src := []*Mapping{} + dest := []*Mapping{} + // Test CopyTo empty + dest = CopyMappingPtrSlice(dest, src) + assert.Equal(t, []*Mapping{}, dest) + + // Test CopyTo larger slice + src = GenTestMappingPtrSlice() + dest = CopyMappingPtrSlice(dest, src) + assert.Equal(t, GenTestMappingPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMappingPtrSlice(dest, src) + assert.Equal(t, GenTestMappingPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMappingPtrSlice(dest, []*Mapping{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMappingPtrSlice(dest, src) + assert.Equal(t, GenTestMappingPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONMappingUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigMapping() - UnmarshalJSONOrigMapping(dest, iter) + dest := NewMapping() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigMapping(), dest) + assert.Equal(t, NewMapping(), dest) } -func TestMarshalAndUnmarshalJSONOrigMapping(t *testing.T) { +func TestMarshalAndUnmarshalJSONMapping(t *testing.T) { for name, src := range genTestEncodingValuesMapping() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigMapping(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigMapping(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigMapping() - UnmarshalJSONOrigMapping(dest, iter) + dest := NewMapping() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigMapping(dest, true) + DeleteMapping(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigMappingFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoMappingFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesMapping() { t.Run(name, func(t *testing.T) { - dest := NewOrigMapping() - require.Error(t, UnmarshalProtoOrigMapping(dest, buf)) + dest := NewMapping() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigMappingUnknown(t *testing.T) { - dest := NewOrigMapping() +func TestMarshalAndUnmarshalProtoMappingUnknown(t *testing.T) { + dest := NewMapping() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigMapping(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigMapping(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewMapping(), dest) } -func TestMarshalAndUnmarshalProtoOrigMapping(t *testing.T) { +func TestMarshalAndUnmarshalProtoMapping(t *testing.T) { for name, src := range genTestEncodingValuesMapping() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigMapping(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigMapping(src)) - gotSize := MarshalProtoOrigMapping(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigMapping() - require.NoError(t, UnmarshalProtoOrigMapping(dest, buf)) + dest := NewMapping() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigMapping(dest, true) + DeleteMapping(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigMapping(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufMapping(t *testing.T) { for name, src := range genTestEncodingValuesMapping() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigMapping(src)) - gotSize := MarshalProtoOrigMapping(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Mapping{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufMapping(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigMapping() - require.NoError(t, UnmarshalProtoOrigMapping(dest, goBuf)) + dest := NewMapping() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -153,13 +202,13 @@ func genTestFailingUnmarshalProtoValuesMapping() map[string][]byte { } } -func genTestEncodingValuesMapping() map[string]*otlpprofiles.Mapping { - return map[string]*otlpprofiles.Mapping{ - "empty": NewOrigMapping(), - "MemoryStart/test": {MemoryStart: uint64(13)}, - "MemoryLimit/test": {MemoryLimit: uint64(13)}, - "FileOffset/test": {FileOffset: uint64(13)}, - "FilenameStrindex/test": {FilenameStrindex: int32(13)}, - "AttributeIndices/default_and_test": {AttributeIndices: []int32{int32(0), int32(13)}}, +func genTestEncodingValuesMapping() map[string]*Mapping { + return map[string]*Mapping{ + "empty": NewMapping(), + "MemoryStart/test": {MemoryStart: uint64(13)}, + "MemoryLimit/test": {MemoryLimit: uint64(13)}, + "FileOffset/test": {FileOffset: uint64(13)}, + "FilenameStrindex/test": {FilenameStrindex: int32(13)}, + "AttributeIndices/test": {AttributeIndices: []int32{int32(0), int32(13)}}, } } diff --git a/pdata/internal/generated_proto_metric.go b/pdata/internal/generated_proto_metric.go new file mode 100644 index 00000000000..b7f85b27a03 --- /dev/null +++ b/pdata/internal/generated_proto_metric.go @@ -0,0 +1,804 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +func (m *Metric) GetData() any { + if m != nil { + return m.Data + } + return nil +} + +type Metric_Gauge struct { + Gauge *Gauge +} + +func (m *Metric) GetGauge() *Gauge { + if v, ok := m.GetData().(*Metric_Gauge); ok { + return v.Gauge + } + return nil +} + +type Metric_Sum struct { + Sum *Sum +} + +func (m *Metric) GetSum() *Sum { + if v, ok := m.GetData().(*Metric_Sum); ok { + return v.Sum + } + return nil +} + +type Metric_Histogram struct { + Histogram *Histogram +} + +func (m *Metric) GetHistogram() *Histogram { + if v, ok := m.GetData().(*Metric_Histogram); ok { + return v.Histogram + } + return nil +} + +type Metric_ExponentialHistogram struct { + ExponentialHistogram *ExponentialHistogram +} + +func (m *Metric) GetExponentialHistogram() *ExponentialHistogram { + if v, ok := m.GetData().(*Metric_ExponentialHistogram); ok { + return v.ExponentialHistogram + } + return nil +} + +type Metric_Summary struct { + Summary *Summary +} + +func (m *Metric) GetSummary() *Summary { + if v, ok := m.GetData().(*Metric_Summary); ok { + return v.Summary + } + return nil +} + +// Metric represents one metric as a collection of datapoints. +// See Metric definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/metrics/v1/metrics.proto +type Metric struct { + Name string + Description string + Unit string + Data any + Metadata []KeyValue +} + +var ( + protoPoolMetric = sync.Pool{ + New: func() any { + return &Metric{} + }, + } + + ProtoPoolMetric_Gauge = sync.Pool{ + New: func() any { + return &Metric_Gauge{} + }, + } + + ProtoPoolMetric_Sum = sync.Pool{ + New: func() any { + return &Metric_Sum{} + }, + } + + ProtoPoolMetric_Histogram = sync.Pool{ + New: func() any { + return &Metric_Histogram{} + }, + } + + ProtoPoolMetric_ExponentialHistogram = sync.Pool{ + New: func() any { + return &Metric_ExponentialHistogram{} + }, + } + + ProtoPoolMetric_Summary = sync.Pool{ + New: func() any { + return &Metric_Summary{} + }, + } +) + +func NewMetric() *Metric { + if !UseProtoPooling.IsEnabled() { + return &Metric{} + } + return protoPoolMetric.Get().(*Metric) +} + +func DeleteMetric(orig *Metric, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + switch ov := orig.Data.(type) { + case *Metric_Gauge: + DeleteGauge(ov.Gauge, true) + ov.Gauge = nil + ProtoPoolMetric_Gauge.Put(ov) + case *Metric_Sum: + DeleteSum(ov.Sum, true) + ov.Sum = nil + ProtoPoolMetric_Sum.Put(ov) + case *Metric_Histogram: + DeleteHistogram(ov.Histogram, true) + ov.Histogram = nil + ProtoPoolMetric_Histogram.Put(ov) + case *Metric_ExponentialHistogram: + DeleteExponentialHistogram(ov.ExponentialHistogram, true) + ov.ExponentialHistogram = nil + ProtoPoolMetric_ExponentialHistogram.Put(ov) + case *Metric_Summary: + 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) + } +} + +func CopyMetric(dest, src *Metric) *Metric { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + 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 + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Gauge{} + } else { + ov = ProtoPoolMetric_Gauge.Get().(*Metric_Gauge) + } + ov.Gauge = NewGauge() + CopyGauge(ov.Gauge, t.Gauge) + dest.Data = ov + + case *Metric_Sum: + var ov *Metric_Sum + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Sum{} + } else { + ov = ProtoPoolMetric_Sum.Get().(*Metric_Sum) + } + ov.Sum = NewSum() + CopySum(ov.Sum, t.Sum) + dest.Data = ov + + case *Metric_Histogram: + var ov *Metric_Histogram + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Histogram{} + } else { + ov = ProtoPoolMetric_Histogram.Get().(*Metric_Histogram) + } + ov.Histogram = NewHistogram() + CopyHistogram(ov.Histogram, t.Histogram) + dest.Data = ov + + case *Metric_ExponentialHistogram: + var ov *Metric_ExponentialHistogram + if !UseProtoPooling.IsEnabled() { + ov = &Metric_ExponentialHistogram{} + } else { + ov = ProtoPoolMetric_ExponentialHistogram.Get().(*Metric_ExponentialHistogram) + } + ov.ExponentialHistogram = NewExponentialHistogram() + CopyExponentialHistogram(ov.ExponentialHistogram, t.ExponentialHistogram) + dest.Data = ov + + case *Metric_Summary: + var ov *Metric_Summary + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Summary{} + } else { + ov = ProtoPoolMetric_Summary.Get().(*Metric_Summary) + } + ov.Summary = NewSummary() + CopySummary(ov.Summary, t.Summary) + dest.Data = ov + + default: + dest.Data = nil + } + dest.Metadata = CopyKeyValueSlice(dest.Metadata, src.Metadata) + + return dest +} + +func CopyMetricSlice(dest, src []Metric) []Metric { + var newDest []Metric + if cap(dest) < len(src) { + newDest = make([]Metric, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMetric(&dest[i], false) + } + } + for i := range src { + CopyMetric(&newDest[i], &src[i]) + } + return newDest +} + +func CopyMetricPtrSlice(dest, src []*Metric) []*Metric { + var newDest []*Metric + if cap(dest) < len(src) { + newDest = make([]*Metric, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMetric() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMetric(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMetric() + } + } + for i := range src { + CopyMetric(newDest[i], src[i]) + } + return newDest +} + +func (orig *Metric) Reset() { + *orig = Metric{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Metric) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Name != "" { + dest.WriteObjectField("name") + dest.WriteString(orig.Name) + } + if orig.Description != "" { + dest.WriteObjectField("description") + dest.WriteString(orig.Description) + } + if orig.Unit != "" { + dest.WriteObjectField("unit") + dest.WriteString(orig.Unit) + } + switch orig := orig.Data.(type) { + case *Metric_Gauge: + if orig.Gauge != nil { + dest.WriteObjectField("gauge") + orig.Gauge.MarshalJSON(dest) + } + case *Metric_Sum: + if orig.Sum != nil { + dest.WriteObjectField("sum") + orig.Sum.MarshalJSON(dest) + } + case *Metric_Histogram: + if orig.Histogram != nil { + dest.WriteObjectField("histogram") + orig.Histogram.MarshalJSON(dest) + } + case *Metric_ExponentialHistogram: + if orig.ExponentialHistogram != nil { + dest.WriteObjectField("exponentialHistogram") + orig.ExponentialHistogram.MarshalJSON(dest) + } + case *Metric_Summary: + if orig.Summary != nil { + dest.WriteObjectField("summary") + orig.Summary.MarshalJSON(dest) + } + } + if len(orig.Metadata) > 0 { + dest.WriteObjectField("metadata") + dest.WriteArrayStart() + orig.Metadata[0].MarshalJSON(dest) + for i := 1; i < len(orig.Metadata); i++ { + dest.WriteMore() + orig.Metadata[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Metric) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "name": + orig.Name = iter.ReadString() + case "description": + orig.Description = iter.ReadString() + case "unit": + orig.Unit = iter.ReadString() + + case "gauge": + { + var ov *Metric_Gauge + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Gauge{} + } else { + ov = ProtoPoolMetric_Gauge.Get().(*Metric_Gauge) + } + ov.Gauge = NewGauge() + ov.Gauge.UnmarshalJSON(iter) + orig.Data = ov + } + + case "sum": + { + var ov *Metric_Sum + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Sum{} + } else { + ov = ProtoPoolMetric_Sum.Get().(*Metric_Sum) + } + ov.Sum = NewSum() + ov.Sum.UnmarshalJSON(iter) + orig.Data = ov + } + + case "histogram": + { + var ov *Metric_Histogram + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Histogram{} + } else { + ov = ProtoPoolMetric_Histogram.Get().(*Metric_Histogram) + } + ov.Histogram = NewHistogram() + ov.Histogram.UnmarshalJSON(iter) + orig.Data = ov + } + + case "exponentialHistogram", "exponential_histogram": + { + var ov *Metric_ExponentialHistogram + if !UseProtoPooling.IsEnabled() { + ov = &Metric_ExponentialHistogram{} + } else { + ov = ProtoPoolMetric_ExponentialHistogram.Get().(*Metric_ExponentialHistogram) + } + ov.ExponentialHistogram = NewExponentialHistogram() + ov.ExponentialHistogram.UnmarshalJSON(iter) + orig.Data = ov + } + + case "summary": + { + var ov *Metric_Summary + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Summary{} + } else { + ov = ProtoPoolMetric_Summary.Get().(*Metric_Summary) + } + ov.Summary = NewSummary() + ov.Summary.UnmarshalJSON(iter) + orig.Data = ov + } + + case "metadata": + for iter.ReadArray() { + orig.Metadata = append(orig.Metadata, KeyValue{}) + orig.Metadata[len(orig.Metadata)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +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 + } + switch orig := orig.Data.(type) { + case nil: + _ = orig + break + case *Metric_Gauge: + if orig.Gauge != nil { + l = orig.Gauge.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *Metric_Sum: + if orig.Sum != nil { + l = orig.Sum.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *Metric_Histogram: + if orig.Histogram != nil { + l = orig.Histogram.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *Metric_ExponentialHistogram: + if orig.ExponentialHistogram != nil { + l = orig.ExponentialHistogram.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *Metric_Summary: + if orig.Summary != nil { + l = orig.Summary.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + } + for i := range orig.Metadata { + l = orig.Metadata[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *Metric) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.Name) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Name) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = len(orig.Description) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Description) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.Unit) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Unit) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + switch orig := orig.Data.(type) { + case *Metric_Gauge: + if orig.Gauge != nil { + l = orig.Gauge.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x2a + } + case *Metric_Sum: + if orig.Sum != nil { + l = orig.Sum.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x3a + } + case *Metric_Histogram: + if orig.Histogram != nil { + l = orig.Histogram.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x4a + } + case *Metric_ExponentialHistogram: + if orig.ExponentialHistogram != nil { + l = orig.ExponentialHistogram.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x52 + } + case *Metric_Summary: + if orig.Summary != nil { + l = orig.Summary.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x5a + } + } + for i := len(orig.Metadata) - 1; i >= 0; i-- { + l = orig.Metadata[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x62 + } + return len(buf) - pos +} + +func (orig *Metric) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Name = string(buf[startPos:pos]) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Description = string(buf[startPos:pos]) + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Unit", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Unit = string(buf[startPos:pos]) + + case 5: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Gauge", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *Metric_Gauge + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Gauge{} + } else { + ov = ProtoPoolMetric_Gauge.Get().(*Metric_Gauge) + } + ov.Gauge = NewGauge() + err = ov.Gauge.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Data = ov + + case 7: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *Metric_Sum + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Sum{} + } else { + ov = ProtoPoolMetric_Sum.Get().(*Metric_Sum) + } + ov.Sum = NewSum() + err = ov.Sum.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Data = ov + + case 9: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Histogram", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *Metric_Histogram + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Histogram{} + } else { + ov = ProtoPoolMetric_Histogram.Get().(*Metric_Histogram) + } + ov.Histogram = NewHistogram() + err = ov.Histogram.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Data = ov + + case 10: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ExponentialHistogram", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *Metric_ExponentialHistogram + if !UseProtoPooling.IsEnabled() { + ov = &Metric_ExponentialHistogram{} + } else { + ov = ProtoPoolMetric_ExponentialHistogram.Get().(*Metric_ExponentialHistogram) + } + ov.ExponentialHistogram = NewExponentialHistogram() + err = ov.ExponentialHistogram.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Data = ov + + case 11: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Summary", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *Metric_Summary + if !UseProtoPooling.IsEnabled() { + ov = &Metric_Summary{} + } else { + ov = ProtoPoolMetric_Summary.Get().(*Metric_Summary) + } + ov.Summary = NewSummary() + err = ov.Summary.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.Data = ov + + case 12: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Metadata = append(orig.Metadata, KeyValue{}) + err = orig.Metadata[len(orig.Metadata)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestMetric() *Metric { + orig := NewMetric() + orig.Name = "test_name" + orig.Description = "test_description" + orig.Unit = "test_unit" + orig.Data = &Metric_Gauge{Gauge: GenTestGauge()} + orig.Metadata = []KeyValue{{}, *GenTestKeyValue()} + return orig +} + +func GenTestMetricPtrSlice() []*Metric { + orig := make([]*Metric, 5) + orig[0] = NewMetric() + orig[1] = GenTestMetric() + orig[2] = NewMetric() + orig[3] = GenTestMetric() + orig[4] = NewMetric() + return orig +} + +func GenTestMetricSlice() []Metric { + orig := make([]Metric, 5) + orig[1] = *GenTestMetric() + orig[3] = *GenTestMetric() + return orig +} diff --git a/pdata/internal/generated_wrapper_metric_test.go b/pdata/internal/generated_proto_metric_test.go similarity index 53% rename from pdata/internal/generated_wrapper_metric_test.go rename to pdata/internal/generated_proto_metric_test.go index 52664d2c038..e538a3c9885 100644 --- a/pdata/internal/generated_wrapper_metric_test.go +++ b/pdata/internal/generated_proto_metric_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigMetric(t *testing.T) { +func TestCopyMetric(t *testing.T) { for name, src := range genTestEncodingValuesMetric() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigMetric(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigMetric() - CopyOrigMetric(dest, src) + dest := NewMetric() + CopyMetric(dest, src) assert.Equal(t, src, dest) - CopyOrigMetric(dest, dest) + CopyMetric(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigMetricUnknown(t *testing.T) { +func TestCopyMetricSlice(t *testing.T) { + src := []Metric{} + dest := []Metric{} + // Test CopyTo empty + dest = CopyMetricSlice(dest, src) + assert.Equal(t, []Metric{}, dest) + + // Test CopyTo larger slice + src = GenTestMetricSlice() + dest = CopyMetricSlice(dest, src) + assert.Equal(t, GenTestMetricSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMetricSlice(dest, src) + assert.Equal(t, GenTestMetricSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMetricSlice(dest, []Metric{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMetricSlice(dest, src) + assert.Equal(t, GenTestMetricSlice(), dest) +} + +func TestCopyMetricPtrSlice(t *testing.T) { + src := []*Metric{} + dest := []*Metric{} + // Test CopyTo empty + dest = CopyMetricPtrSlice(dest, src) + assert.Equal(t, []*Metric{}, dest) + + // Test CopyTo larger slice + src = GenTestMetricPtrSlice() + dest = CopyMetricPtrSlice(dest, src) + assert.Equal(t, GenTestMetricPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMetricPtrSlice(dest, src) + assert.Equal(t, GenTestMetricPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMetricPtrSlice(dest, []*Metric{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMetricPtrSlice(dest, src) + assert.Equal(t, GenTestMetricPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONMetricUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigMetric() - UnmarshalJSONOrigMetric(dest, iter) + dest := NewMetric() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigMetric(), dest) + assert.Equal(t, NewMetric(), dest) } -func TestMarshalAndUnmarshalJSONOrigMetric(t *testing.T) { +func TestMarshalAndUnmarshalJSONMetric(t *testing.T) { for name, src := range genTestEncodingValuesMetric() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigMetric(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigMetric(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigMetric() - UnmarshalJSONOrigMetric(dest, iter) + dest := NewMetric() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigMetric(dest, true) + DeleteMetric(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigMetricFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoMetricFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesMetric() { t.Run(name, func(t *testing.T) { - dest := NewOrigMetric() - require.Error(t, UnmarshalProtoOrigMetric(dest, buf)) + dest := NewMetric() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigMetricUnknown(t *testing.T) { - dest := NewOrigMetric() +func TestMarshalAndUnmarshalProtoMetricUnknown(t *testing.T) { + dest := NewMetric() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigMetric(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigMetric(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewMetric(), dest) } -func TestMarshalAndUnmarshalProtoOrigMetric(t *testing.T) { +func TestMarshalAndUnmarshalProtoMetric(t *testing.T) { for name, src := range genTestEncodingValuesMetric() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigMetric(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigMetric(src)) - gotSize := MarshalProtoOrigMetric(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigMetric() - require.NoError(t, UnmarshalProtoOrigMetric(dest, buf)) + dest := NewMetric() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigMetric(dest, true) + DeleteMetric(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigMetric(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufMetric(t *testing.T) { for name, src := range genTestEncodingValuesMetric() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigMetric(src)) - gotSize := MarshalProtoOrigMetric(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.Metric{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufMetric(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigMetric() - require.NoError(t, UnmarshalProtoOrigMetric(dest, goBuf)) + dest := NewMetric() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -167,22 +215,22 @@ func genTestFailingUnmarshalProtoValuesMetric() map[string][]byte { } } -func genTestEncodingValuesMetric() map[string]*otlpmetrics.Metric { - return map[string]*otlpmetrics.Metric{ - "empty": NewOrigMetric(), +func genTestEncodingValuesMetric() map[string]*Metric { + return map[string]*Metric{ + "empty": NewMetric(), "Name/test": {Name: "test_name"}, "Description/test": {Description: "test_description"}, "Unit/test": {Unit: "test_unit"}, - "Gauge/default": {Data: &otlpmetrics.Metric_Gauge{Gauge: &otlpmetrics.Gauge{}}}, - "Gauge/test": {Data: &otlpmetrics.Metric_Gauge{Gauge: GenTestOrigGauge()}}, - "Sum/default": {Data: &otlpmetrics.Metric_Sum{Sum: &otlpmetrics.Sum{}}}, - "Sum/test": {Data: &otlpmetrics.Metric_Sum{Sum: GenTestOrigSum()}}, - "Histogram/default": {Data: &otlpmetrics.Metric_Histogram{Histogram: &otlpmetrics.Histogram{}}}, - "Histogram/test": {Data: &otlpmetrics.Metric_Histogram{Histogram: GenTestOrigHistogram()}}, - "ExponentialHistogram/default": {Data: &otlpmetrics.Metric_ExponentialHistogram{ExponentialHistogram: &otlpmetrics.ExponentialHistogram{}}}, - "ExponentialHistogram/test": {Data: &otlpmetrics.Metric_ExponentialHistogram{ExponentialHistogram: GenTestOrigExponentialHistogram()}}, - "Summary/default": {Data: &otlpmetrics.Metric_Summary{Summary: &otlpmetrics.Summary{}}}, - "Summary/test": {Data: &otlpmetrics.Metric_Summary{Summary: GenTestOrigSummary()}}, - "Metadata/default_and_test": {Metadata: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, + "Gauge/default": {Data: &Metric_Gauge{Gauge: &Gauge{}}}, + "Gauge/test": {Data: &Metric_Gauge{Gauge: GenTestGauge()}}, + "Sum/default": {Data: &Metric_Sum{Sum: &Sum{}}}, + "Sum/test": {Data: &Metric_Sum{Sum: GenTestSum()}}, + "Histogram/default": {Data: &Metric_Histogram{Histogram: &Histogram{}}}, + "Histogram/test": {Data: &Metric_Histogram{Histogram: GenTestHistogram()}}, + "ExponentialHistogram/default": {Data: &Metric_ExponentialHistogram{ExponentialHistogram: &ExponentialHistogram{}}}, + "ExponentialHistogram/test": {Data: &Metric_ExponentialHistogram{ExponentialHistogram: GenTestExponentialHistogram()}}, + "Summary/default": {Data: &Metric_Summary{Summary: &Summary{}}}, + "Summary/test": {Data: &Metric_Summary{Summary: GenTestSummary()}}, + "Metadata/test": {Metadata: []KeyValue{{}, *GenTestKeyValue()}}, } } diff --git a/pdata/internal/generated_proto_metricsdata.go b/pdata/internal/generated_proto_metricsdata.go new file mode 100644 index 00000000000..ad560d67b4b --- /dev/null +++ b/pdata/internal/generated_proto_metricsdata.go @@ -0,0 +1,247 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// MetricsData represents the metrics data that can be stored in a persistent storage, +// OR can be embedded by other protocols that transfer OTLP metrics data but do not +// implement the OTLP protocol.. +type MetricsData struct { + ResourceMetrics []*ResourceMetrics +} + +var ( + protoPoolMetricsData = sync.Pool{ + New: func() any { + return &MetricsData{} + }, + } +) + +func NewMetricsData() *MetricsData { + if !UseProtoPooling.IsEnabled() { + return &MetricsData{} + } + return protoPoolMetricsData.Get().(*MetricsData) +} + +func DeleteMetricsData(orig *MetricsData, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceMetrics { + DeleteResourceMetrics(orig.ResourceMetrics[i], true) + } + + orig.Reset() + if nullable { + protoPoolMetricsData.Put(orig) + } +} + +func CopyMetricsData(dest, src *MetricsData) *MetricsData { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewMetricsData() + } + dest.ResourceMetrics = CopyResourceMetricsPtrSlice(dest.ResourceMetrics, src.ResourceMetrics) + + return dest +} + +func CopyMetricsDataSlice(dest, src []MetricsData) []MetricsData { + var newDest []MetricsData + if cap(dest) < len(src) { + newDest = make([]MetricsData, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMetricsData(&dest[i], false) + } + } + for i := range src { + CopyMetricsData(&newDest[i], &src[i]) + } + return newDest +} + +func CopyMetricsDataPtrSlice(dest, src []*MetricsData) []*MetricsData { + var newDest []*MetricsData + if cap(dest) < len(src) { + newDest = make([]*MetricsData, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMetricsData() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMetricsData(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMetricsData() + } + } + for i := range src { + CopyMetricsData(newDest[i], src[i]) + } + return newDest +} + +func (orig *MetricsData) Reset() { + *orig = MetricsData{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *MetricsData) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceMetrics) > 0 { + dest.WriteObjectField("resourceMetrics") + dest.WriteArrayStart() + orig.ResourceMetrics[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceMetrics); i++ { + dest.WriteMore() + orig.ResourceMetrics[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *MetricsData) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceMetrics", "resource_metrics": + for iter.ReadArray() { + orig.ResourceMetrics = append(orig.ResourceMetrics, NewResourceMetrics()) + orig.ResourceMetrics[len(orig.ResourceMetrics)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *MetricsData) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceMetrics { + l = orig.ResourceMetrics[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *MetricsData) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceMetrics) - 1; i >= 0; i-- { + l = orig.ResourceMetrics[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *MetricsData) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceMetrics", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceMetrics = append(orig.ResourceMetrics, NewResourceMetrics()) + err = orig.ResourceMetrics[len(orig.ResourceMetrics)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestMetricsData() *MetricsData { + orig := NewMetricsData() + orig.ResourceMetrics = []*ResourceMetrics{{}, GenTestResourceMetrics()} + return orig +} + +func GenTestMetricsDataPtrSlice() []*MetricsData { + orig := make([]*MetricsData, 5) + orig[0] = NewMetricsData() + orig[1] = GenTestMetricsData() + orig[2] = NewMetricsData() + orig[3] = GenTestMetricsData() + orig[4] = NewMetricsData() + return orig +} + +func GenTestMetricsDataSlice() []MetricsData { + orig := make([]MetricsData, 5) + orig[1] = *GenTestMetricsData() + orig[3] = *GenTestMetricsData() + return orig +} diff --git a/pdata/internal/generated_proto_metricsdata_test.go b/pdata/internal/generated_proto_metricsdata_test.go new file mode 100644 index 00000000000..4d310ba85c3 --- /dev/null +++ b/pdata/internal/generated_proto_metricsdata_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyMetricsData(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewMetricsData() + CopyMetricsData(dest, src) + assert.Equal(t, src, dest) + CopyMetricsData(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyMetricsDataSlice(t *testing.T) { + src := []MetricsData{} + dest := []MetricsData{} + // Test CopyTo empty + dest = CopyMetricsDataSlice(dest, src) + assert.Equal(t, []MetricsData{}, dest) + + // Test CopyTo larger slice + src = GenTestMetricsDataSlice() + dest = CopyMetricsDataSlice(dest, src) + assert.Equal(t, GenTestMetricsDataSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMetricsDataSlice(dest, src) + assert.Equal(t, GenTestMetricsDataSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMetricsDataSlice(dest, []MetricsData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMetricsDataSlice(dest, src) + assert.Equal(t, GenTestMetricsDataSlice(), dest) +} + +func TestCopyMetricsDataPtrSlice(t *testing.T) { + src := []*MetricsData{} + dest := []*MetricsData{} + // Test CopyTo empty + dest = CopyMetricsDataPtrSlice(dest, src) + assert.Equal(t, []*MetricsData{}, dest) + + // Test CopyTo larger slice + src = GenTestMetricsDataPtrSlice() + dest = CopyMetricsDataPtrSlice(dest, src) + assert.Equal(t, GenTestMetricsDataPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMetricsDataPtrSlice(dest, src) + assert.Equal(t, GenTestMetricsDataPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMetricsDataPtrSlice(dest, []*MetricsData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMetricsDataPtrSlice(dest, src) + assert.Equal(t, GenTestMetricsDataPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONMetricsDataUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewMetricsData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewMetricsData(), dest) +} + +func TestMarshalAndUnmarshalJSONMetricsData(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewMetricsData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteMetricsData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoMetricsDataFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesMetricsData() { + t.Run(name, func(t *testing.T) { + dest := NewMetricsData() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoMetricsDataUnknown(t *testing.T) { + dest := NewMetricsData() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewMetricsData(), dest) +} + +func TestMarshalAndUnmarshalProtoMetricsData(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewMetricsData() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteMetricsData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufMetricsData(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsData() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpmetrics.MetricsData{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewMetricsData() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesMetricsData() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceMetrics/wrong_wire_type": {0xc}, + "ResourceMetrics/missing_value": {0xa}, + } +} + +func genTestEncodingValuesMetricsData() map[string]*MetricsData { + return map[string]*MetricsData{ + "empty": NewMetricsData(), + "ResourceMetrics/test": {ResourceMetrics: []*ResourceMetrics{{}, GenTestResourceMetrics()}}, + } +} diff --git a/pdata/internal/generated_proto_metricsrequest.go b/pdata/internal/generated_proto_metricsrequest.go new file mode 100644 index 00000000000..e4cb0b38f17 --- /dev/null +++ b/pdata/internal/generated_proto_metricsrequest.go @@ -0,0 +1,300 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type MetricsRequest struct { + RequestContext *RequestContext + MetricsData MetricsData + FormatVersion uint32 +} + +var ( + protoPoolMetricsRequest = sync.Pool{ + New: func() any { + return &MetricsRequest{} + }, + } +) + +func NewMetricsRequest() *MetricsRequest { + if !UseProtoPooling.IsEnabled() { + return &MetricsRequest{} + } + return protoPoolMetricsRequest.Get().(*MetricsRequest) +} + +func DeleteMetricsRequest(orig *MetricsRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteRequestContext(orig.RequestContext, true) + DeleteMetricsData(&orig.MetricsData, false) + + orig.Reset() + if nullable { + protoPoolMetricsRequest.Put(orig) + } +} + +func CopyMetricsRequest(dest, src *MetricsRequest) *MetricsRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewMetricsRequest() + } + dest.RequestContext = CopyRequestContext(dest.RequestContext, src.RequestContext) + + CopyMetricsData(&dest.MetricsData, &src.MetricsData) + + dest.FormatVersion = src.FormatVersion + + return dest +} + +func CopyMetricsRequestSlice(dest, src []MetricsRequest) []MetricsRequest { + var newDest []MetricsRequest + if cap(dest) < len(src) { + newDest = make([]MetricsRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMetricsRequest(&dest[i], false) + } + } + for i := range src { + CopyMetricsRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyMetricsRequestPtrSlice(dest, src []*MetricsRequest) []*MetricsRequest { + var newDest []*MetricsRequest + if cap(dest) < len(src) { + newDest = make([]*MetricsRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMetricsRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteMetricsRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewMetricsRequest() + } + } + for i := range src { + CopyMetricsRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *MetricsRequest) Reset() { + *orig = MetricsRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *MetricsRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RequestContext != nil { + dest.WriteObjectField("requestContext") + orig.RequestContext.MarshalJSON(dest) + } + dest.WriteObjectField("metricsData") + orig.MetricsData.MarshalJSON(dest) + if orig.FormatVersion != uint32(0) { + dest.WriteObjectField("formatVersion") + dest.WriteUint32(orig.FormatVersion) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *MetricsRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "requestContext", "request_context": + orig.RequestContext = NewRequestContext() + orig.RequestContext.UnmarshalJSON(iter) + case "metricsData", "metrics_data": + + orig.MetricsData.UnmarshalJSON(iter) + case "formatVersion", "format_version": + orig.FormatVersion = iter.ReadUint32() + default: + iter.Skip() + } + } +} + +func (orig *MetricsRequest) SizeProto() int { + var n int + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + l = orig.MetricsData.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + if orig.FormatVersion != 0 { + n += 5 + } + return n +} + +func (orig *MetricsRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = orig.MetricsData.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + + if orig.FormatVersion != 0 { + pos -= 4 + binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) + pos-- + buf[pos] = 0xd + } + return len(buf) - pos +} + +func (orig *MetricsRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + orig.RequestContext = NewRequestContext() + err = orig.RequestContext.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field MetricsData", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.MetricsData.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 1: + if wireType != proto.WireTypeI32 { + return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) + } + var num uint32 + num, pos, err = proto.ConsumeI32(buf, pos) + if err != nil { + return err + } + + orig.FormatVersion = uint32(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestMetricsRequest() *MetricsRequest { + orig := NewMetricsRequest() + orig.RequestContext = GenTestRequestContext() + orig.MetricsData = *GenTestMetricsData() + orig.FormatVersion = uint32(13) + return orig +} + +func GenTestMetricsRequestPtrSlice() []*MetricsRequest { + orig := make([]*MetricsRequest, 5) + orig[0] = NewMetricsRequest() + orig[1] = GenTestMetricsRequest() + orig[2] = NewMetricsRequest() + orig[3] = GenTestMetricsRequest() + orig[4] = NewMetricsRequest() + return orig +} + +func GenTestMetricsRequestSlice() []MetricsRequest { + orig := make([]MetricsRequest, 5) + orig[1] = *GenTestMetricsRequest() + orig[3] = *GenTestMetricsRequest() + return orig +} diff --git a/pdata/internal/generated_proto_metricsrequest_test.go b/pdata/internal/generated_proto_metricsrequest_test.go new file mode 100644 index 00000000000..82dca21a103 --- /dev/null +++ b/pdata/internal/generated_proto_metricsrequest_test.go @@ -0,0 +1,208 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyMetricsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewMetricsRequest() + CopyMetricsRequest(dest, src) + assert.Equal(t, src, dest) + CopyMetricsRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyMetricsRequestSlice(t *testing.T) { + src := []MetricsRequest{} + dest := []MetricsRequest{} + // Test CopyTo empty + dest = CopyMetricsRequestSlice(dest, src) + assert.Equal(t, []MetricsRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestMetricsRequestSlice() + dest = CopyMetricsRequestSlice(dest, src) + assert.Equal(t, GenTestMetricsRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMetricsRequestSlice(dest, src) + assert.Equal(t, GenTestMetricsRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMetricsRequestSlice(dest, []MetricsRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMetricsRequestSlice(dest, src) + assert.Equal(t, GenTestMetricsRequestSlice(), dest) +} + +func TestCopyMetricsRequestPtrSlice(t *testing.T) { + src := []*MetricsRequest{} + dest := []*MetricsRequest{} + // Test CopyTo empty + dest = CopyMetricsRequestPtrSlice(dest, src) + assert.Equal(t, []*MetricsRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestMetricsRequestPtrSlice() + dest = CopyMetricsRequestPtrSlice(dest, src) + assert.Equal(t, GenTestMetricsRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyMetricsRequestPtrSlice(dest, src) + assert.Equal(t, GenTestMetricsRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyMetricsRequestPtrSlice(dest, []*MetricsRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyMetricsRequestPtrSlice(dest, src) + assert.Equal(t, GenTestMetricsRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONMetricsRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewMetricsRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewMetricsRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONMetricsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewMetricsRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteMetricsRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoMetricsRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesMetricsRequest() { + t.Run(name, func(t *testing.T) { + dest := NewMetricsRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoMetricsRequestUnknown(t *testing.T) { + dest := NewMetricsRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewMetricsRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoMetricsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewMetricsRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteMetricsRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufMetricsRequest(t *testing.T) { + for name, src := range genTestEncodingValuesMetricsRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewMetricsRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesMetricsRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "RequestContext/wrong_wire_type": {0x14}, + "RequestContext/missing_value": {0x12}, + "MetricsData/wrong_wire_type": {0x1c}, + "MetricsData/missing_value": {0x1a}, + "FormatVersion/wrong_wire_type": {0xc}, + "FormatVersion/missing_value": {0xd}, + } +} + +func genTestEncodingValuesMetricsRequest() map[string]*MetricsRequest { + return map[string]*MetricsRequest{ + "empty": NewMetricsRequest(), + "RequestContext/test": {RequestContext: GenTestRequestContext()}, + "MetricsData/test": {MetricsData: *GenTestMetricsData()}, + "FormatVersion/test": {FormatVersion: uint32(13)}, + } +} diff --git a/pdata/internal/generated_wrapper_numberdatapoint.go b/pdata/internal/generated_proto_numberdatapoint.go similarity index 52% rename from pdata/internal/generated_wrapper_numberdatapoint.go rename to pdata/internal/generated_proto_numberdatapoint.go index 348b0b73f4e..4b86a7f3a1b 100644 --- a/pdata/internal/generated_wrapper_numberdatapoint.go +++ b/pdata/internal/generated_proto_numberdatapoint.go @@ -12,40 +12,77 @@ import ( "math" "sync" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +func (m *NumberDataPoint) GetValue() any { + if m != nil { + return m.Value + } + return nil +} + +type NumberDataPoint_AsDouble struct { + AsDouble float64 +} + +func (m *NumberDataPoint) GetAsDouble() float64 { + if v, ok := m.GetValue().(*NumberDataPoint_AsDouble); ok { + return v.AsDouble + } + return float64(0) +} + +type NumberDataPoint_AsInt struct { + AsInt int64 +} + +func (m *NumberDataPoint) GetAsInt() int64 { + if v, ok := m.GetValue().(*NumberDataPoint_AsInt); ok { + return v.AsInt + } + return int64(0) +} + +// NumberDataPoint is a single data point in a timeseries that describes the time-varying value of a number metric. +type NumberDataPoint struct { + Attributes []KeyValue + StartTimeUnixNano uint64 + TimeUnixNano uint64 + Value any + Exemplars []Exemplar + Flags uint32 +} + var ( protoPoolNumberDataPoint = sync.Pool{ New: func() any { - return &otlpmetrics.NumberDataPoint{} + return &NumberDataPoint{} }, } ProtoPoolNumberDataPoint_AsDouble = sync.Pool{ New: func() any { - return &otlpmetrics.NumberDataPoint_AsDouble{} + return &NumberDataPoint_AsDouble{} }, } ProtoPoolNumberDataPoint_AsInt = sync.Pool{ New: func() any { - return &otlpmetrics.NumberDataPoint_AsInt{} + return &NumberDataPoint_AsInt{} }, } ) -func NewOrigNumberDataPoint() *otlpmetrics.NumberDataPoint { +func NewNumberDataPoint() *NumberDataPoint { if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.NumberDataPoint{} + return &NumberDataPoint{} } - return protoPoolNumberDataPoint.Get().(*otlpmetrics.NumberDataPoint) + return protoPoolNumberDataPoint.Get().(*NumberDataPoint) } -func DeleteOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, nullable bool) { +func DeleteNumberDataPoint(orig *NumberDataPoint, nullable bool) { if orig == nil { return } @@ -56,15 +93,15 @@ func DeleteOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, nullable bool) } for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } switch ov := orig.Value.(type) { - case *otlpmetrics.NumberDataPoint_AsDouble: + case *NumberDataPoint_AsDouble: if UseProtoPooling.IsEnabled() { ov.AsDouble = float64(0) ProtoPoolNumberDataPoint_AsDouble.Put(ov) } - case *otlpmetrics.NumberDataPoint_AsInt: + case *NumberDataPoint_AsInt: if UseProtoPooling.IsEnabled() { ov.AsInt = int64(0) ProtoPoolNumberDataPoint_AsInt.Put(ov) @@ -72,7 +109,7 @@ func DeleteOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, nullable bool) } for i := range orig.Exemplars { - DeleteOrigExemplar(&orig.Exemplars[i], false) + DeleteExemplar(&orig.Exemplars[i], false) } orig.Reset() @@ -81,59 +118,116 @@ func DeleteOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, nullable bool) } } -func CopyOrigNumberDataPoint(dest, src *otlpmetrics.NumberDataPoint) { +func CopyNumberDataPoint(dest, src *NumberDataPoint) *NumberDataPoint { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewNumberDataPoint() } - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + dest.StartTimeUnixNano = src.StartTimeUnixNano + dest.TimeUnixNano = src.TimeUnixNano + switch t := src.Value.(type) { - case *otlpmetrics.NumberDataPoint_AsDouble: - var ov *otlpmetrics.NumberDataPoint_AsDouble + case *NumberDataPoint_AsDouble: + var ov *NumberDataPoint_AsDouble if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsDouble{} + ov = &NumberDataPoint_AsDouble{} } else { - ov = ProtoPoolNumberDataPoint_AsDouble.Get().(*otlpmetrics.NumberDataPoint_AsDouble) + ov = ProtoPoolNumberDataPoint_AsDouble.Get().(*NumberDataPoint_AsDouble) } ov.AsDouble = t.AsDouble dest.Value = ov - case *otlpmetrics.NumberDataPoint_AsInt: - var ov *otlpmetrics.NumberDataPoint_AsInt + case *NumberDataPoint_AsInt: + var ov *NumberDataPoint_AsInt if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsInt{} + ov = &NumberDataPoint_AsInt{} } else { - ov = ProtoPoolNumberDataPoint_AsInt.Get().(*otlpmetrics.NumberDataPoint_AsInt) + ov = ProtoPoolNumberDataPoint_AsInt.Get().(*NumberDataPoint_AsInt) } ov.AsInt = t.AsInt dest.Value = ov + default: + dest.Value = nil } - dest.Exemplars = CopyOrigExemplarSlice(dest.Exemplars, src.Exemplars) + dest.Exemplars = CopyExemplarSlice(dest.Exemplars, src.Exemplars) + dest.Flags = src.Flags + + return dest } -func GenTestOrigNumberDataPoint() *otlpmetrics.NumberDataPoint { - orig := NewOrigNumberDataPoint() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.StartTimeUnixNano = 1234567890 - orig.TimeUnixNano = 1234567890 - orig.Value = &otlpmetrics.NumberDataPoint_AsDouble{AsDouble: float64(3.1415926)} - orig.Exemplars = GenerateOrigTestExemplarSlice() - orig.Flags = 1 - return orig +func CopyNumberDataPointSlice(dest, src []NumberDataPoint) []NumberDataPoint { + var newDest []NumberDataPoint + if cap(dest) < len(src) { + newDest = make([]NumberDataPoint, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteNumberDataPoint(&dest[i], false) + } + } + for i := range src { + CopyNumberDataPoint(&newDest[i], &src[i]) + } + return newDest +} + +func CopyNumberDataPointPtrSlice(dest, src []*NumberDataPoint) []*NumberDataPoint { + var newDest []*NumberDataPoint + if cap(dest) < len(src) { + newDest = make([]*NumberDataPoint, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewNumberDataPoint() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteNumberDataPoint(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewNumberDataPoint() + } + } + for i := range src { + CopyNumberDataPoint(newDest[i], src[i]) + } + return newDest +} + +func (orig *NumberDataPoint) Reset() { + *orig = NumberDataPoint{} } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, dest *json.Stream) { +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *NumberDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -146,20 +240,20 @@ func MarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, dest *jso dest.WriteUint64(orig.TimeUnixNano) } switch orig := orig.Value.(type) { - case *otlpmetrics.NumberDataPoint_AsDouble: + case *NumberDataPoint_AsDouble: dest.WriteObjectField("asDouble") dest.WriteFloat64(orig.AsDouble) - case *otlpmetrics.NumberDataPoint_AsInt: + case *NumberDataPoint_AsInt: dest.WriteObjectField("asInt") dest.WriteInt64(orig.AsInt) } if len(orig.Exemplars) > 0 { dest.WriteObjectField("exemplars") dest.WriteArrayStart() - MarshalJSONOrigExemplar(&orig.Exemplars[0], dest) + orig.Exemplars[0].MarshalJSON(dest) for i := 1; i < len(orig.Exemplars); i++ { dest.WriteMore() - MarshalJSONOrigExemplar(&orig.Exemplars[i], dest) + orig.Exemplars[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -170,14 +264,14 @@ func MarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, dest *jso dest.WriteObjectEnd() } -// UnmarshalJSONOrigNumberDataPoint unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *NumberDataPoint) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "startTimeUnixNano", "start_time_unix_nano": @@ -187,11 +281,11 @@ func UnmarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, iter *j case "asDouble", "as_double": { - var ov *otlpmetrics.NumberDataPoint_AsDouble + var ov *NumberDataPoint_AsDouble if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsDouble{} + ov = &NumberDataPoint_AsDouble{} } else { - ov = ProtoPoolNumberDataPoint_AsDouble.Get().(*otlpmetrics.NumberDataPoint_AsDouble) + ov = ProtoPoolNumberDataPoint_AsDouble.Get().(*NumberDataPoint_AsDouble) } ov.AsDouble = iter.ReadFloat64() orig.Value = ov @@ -199,11 +293,11 @@ func UnmarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, iter *j case "asInt", "as_int": { - var ov *otlpmetrics.NumberDataPoint_AsInt + var ov *NumberDataPoint_AsInt if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsInt{} + ov = &NumberDataPoint_AsInt{} } else { - ov = ProtoPoolNumberDataPoint_AsInt.Get().(*otlpmetrics.NumberDataPoint_AsInt) + ov = ProtoPoolNumberDataPoint_AsInt.Get().(*NumberDataPoint_AsInt) } ov.AsInt = iter.ReadInt64() orig.Value = ov @@ -211,8 +305,8 @@ func UnmarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, iter *j case "exemplars": for iter.ReadArray() { - orig.Exemplars = append(orig.Exemplars, otlpmetrics.Exemplar{}) - UnmarshalJSONOrigExemplar(&orig.Exemplars[len(orig.Exemplars)-1], iter) + orig.Exemplars = append(orig.Exemplars, Exemplar{}) + orig.Exemplars[len(orig.Exemplars)-1].UnmarshalJSON(iter) } case "flags": @@ -223,12 +317,12 @@ func UnmarshalJSONOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, iter *j } } -func SizeProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint) int { +func (orig *NumberDataPoint) SizeProto() int { var n int var l int _ = l for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.StartTimeUnixNano != 0 { @@ -241,13 +335,13 @@ func SizeProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint) int { case nil: _ = orig break - case *otlpmetrics.NumberDataPoint_AsDouble: + case *NumberDataPoint_AsDouble: n += 9 - case *otlpmetrics.NumberDataPoint_AsInt: + case *NumberDataPoint_AsInt: n += 9 } for i := range orig.Exemplars { - l = SizeProtoOrigExemplar(&orig.Exemplars[i]) + l = orig.Exemplars[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.Flags != 0 { @@ -256,12 +350,12 @@ func SizeProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint) int { return n } -func MarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf []byte) int { +func (orig *NumberDataPoint) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -280,13 +374,13 @@ func MarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf []by buf[pos] = 0x19 } switch orig := orig.Value.(type) { - case *otlpmetrics.NumberDataPoint_AsDouble: + case *NumberDataPoint_AsDouble: pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.AsDouble)) pos-- buf[pos] = 0x21 - case *otlpmetrics.NumberDataPoint_AsInt: + case *NumberDataPoint_AsInt: pos -= 8 binary.LittleEndian.PutUint64(buf[pos:], uint64(orig.AsInt)) pos-- @@ -294,7 +388,7 @@ func MarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf []by } for i := len(orig.Exemplars) - 1; i >= 0; i-- { - l = MarshalProtoOrigExemplar(&orig.Exemplars[i], buf[:pos]) + l = orig.Exemplars[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -308,7 +402,7 @@ func MarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf []by return len(buf) - pos } -func UnmarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf []byte) error { +func (orig *NumberDataPoint) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -333,8 +427,8 @@ func UnmarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf [] return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -372,11 +466,11 @@ func UnmarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf [] if err != nil { return err } - var ov *otlpmetrics.NumberDataPoint_AsDouble + var ov *NumberDataPoint_AsDouble if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsDouble{} + ov = &NumberDataPoint_AsDouble{} } else { - ov = ProtoPoolNumberDataPoint_AsDouble.Get().(*otlpmetrics.NumberDataPoint_AsDouble) + ov = ProtoPoolNumberDataPoint_AsDouble.Get().(*NumberDataPoint_AsDouble) } ov.AsDouble = math.Float64frombits(num) orig.Value = ov @@ -390,11 +484,11 @@ func UnmarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf [] if err != nil { return err } - var ov *otlpmetrics.NumberDataPoint_AsInt + var ov *NumberDataPoint_AsInt if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsInt{} + ov = &NumberDataPoint_AsInt{} } else { - ov = ProtoPoolNumberDataPoint_AsInt.Get().(*otlpmetrics.NumberDataPoint_AsInt) + ov = ProtoPoolNumberDataPoint_AsInt.Get().(*NumberDataPoint_AsInt) } ov.AsInt = int64(num) orig.Value = ov @@ -409,8 +503,8 @@ func UnmarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf [] return err } startPos := pos - length - orig.Exemplars = append(orig.Exemplars, otlpmetrics.Exemplar{}) - err = UnmarshalProtoOrigExemplar(&orig.Exemplars[len(orig.Exemplars)-1], buf[startPos:pos]) + orig.Exemplars = append(orig.Exemplars, Exemplar{}) + err = orig.Exemplars[len(orig.Exemplars)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -435,3 +529,31 @@ func UnmarshalProtoOrigNumberDataPoint(orig *otlpmetrics.NumberDataPoint, buf [] } return nil } + +func GenTestNumberDataPoint() *NumberDataPoint { + orig := NewNumberDataPoint() + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.StartTimeUnixNano = uint64(13) + orig.TimeUnixNano = uint64(13) + orig.Value = &NumberDataPoint_AsDouble{AsDouble: float64(3.1415926)} + orig.Exemplars = []Exemplar{{}, *GenTestExemplar()} + orig.Flags = uint32(13) + return orig +} + +func GenTestNumberDataPointPtrSlice() []*NumberDataPoint { + orig := make([]*NumberDataPoint, 5) + orig[0] = NewNumberDataPoint() + orig[1] = GenTestNumberDataPoint() + orig[2] = NewNumberDataPoint() + orig[3] = GenTestNumberDataPoint() + orig[4] = NewNumberDataPoint() + return orig +} + +func GenTestNumberDataPointSlice() []NumberDataPoint { + orig := make([]NumberDataPoint, 5) + orig[1] = *GenTestNumberDataPoint() + orig[3] = *GenTestNumberDataPoint() + return orig +} diff --git a/pdata/internal/generated_wrapper_numberdatapoint_test.go b/pdata/internal/generated_proto_numberdatapoint_test.go similarity index 50% rename from pdata/internal/generated_wrapper_numberdatapoint_test.go rename to pdata/internal/generated_proto_numberdatapoint_test.go index 2759d4826a8..5c94d8fca72 100644 --- a/pdata/internal/generated_wrapper_numberdatapoint_test.go +++ b/pdata/internal/generated_proto_numberdatapoint_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigNumberDataPoint(t *testing.T) { +func TestCopyNumberDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesNumberDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigNumberDataPoint(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigNumberDataPoint() - CopyOrigNumberDataPoint(dest, src) + dest := NewNumberDataPoint() + CopyNumberDataPoint(dest, src) assert.Equal(t, src, dest) - CopyOrigNumberDataPoint(dest, dest) + CopyNumberDataPoint(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigNumberDataPointUnknown(t *testing.T) { +func TestCopyNumberDataPointSlice(t *testing.T) { + src := []NumberDataPoint{} + dest := []NumberDataPoint{} + // Test CopyTo empty + dest = CopyNumberDataPointSlice(dest, src) + assert.Equal(t, []NumberDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestNumberDataPointSlice() + dest = CopyNumberDataPointSlice(dest, src) + assert.Equal(t, GenTestNumberDataPointSlice(), dest) + + // Test CopyTo same size slice + dest = CopyNumberDataPointSlice(dest, src) + assert.Equal(t, GenTestNumberDataPointSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyNumberDataPointSlice(dest, []NumberDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyNumberDataPointSlice(dest, src) + assert.Equal(t, GenTestNumberDataPointSlice(), dest) +} + +func TestCopyNumberDataPointPtrSlice(t *testing.T) { + src := []*NumberDataPoint{} + dest := []*NumberDataPoint{} + // Test CopyTo empty + dest = CopyNumberDataPointPtrSlice(dest, src) + assert.Equal(t, []*NumberDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestNumberDataPointPtrSlice() + dest = CopyNumberDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestNumberDataPointPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyNumberDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestNumberDataPointPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyNumberDataPointPtrSlice(dest, []*NumberDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyNumberDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestNumberDataPointPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONNumberDataPointUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigNumberDataPoint() - UnmarshalJSONOrigNumberDataPoint(dest, iter) + dest := NewNumberDataPoint() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigNumberDataPoint(), dest) + assert.Equal(t, NewNumberDataPoint(), dest) } -func TestMarshalAndUnmarshalJSONOrigNumberDataPoint(t *testing.T) { +func TestMarshalAndUnmarshalJSONNumberDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesNumberDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigNumberDataPoint(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigNumberDataPoint(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigNumberDataPoint() - UnmarshalJSONOrigNumberDataPoint(dest, iter) + dest := NewNumberDataPoint() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigNumberDataPoint(dest, true) + DeleteNumberDataPoint(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigNumberDataPointFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoNumberDataPointFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesNumberDataPoint() { t.Run(name, func(t *testing.T) { - dest := NewOrigNumberDataPoint() - require.Error(t, UnmarshalProtoOrigNumberDataPoint(dest, buf)) + dest := NewNumberDataPoint() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigNumberDataPointUnknown(t *testing.T) { - dest := NewOrigNumberDataPoint() +func TestMarshalAndUnmarshalProtoNumberDataPointUnknown(t *testing.T) { + dest := NewNumberDataPoint() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigNumberDataPoint(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigNumberDataPoint(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewNumberDataPoint(), dest) } -func TestMarshalAndUnmarshalProtoOrigNumberDataPoint(t *testing.T) { +func TestMarshalAndUnmarshalProtoNumberDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesNumberDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigNumberDataPoint(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigNumberDataPoint(src)) - gotSize := MarshalProtoOrigNumberDataPoint(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigNumberDataPoint() - require.NoError(t, UnmarshalProtoOrigNumberDataPoint(dest, buf)) + dest := NewNumberDataPoint() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigNumberDataPoint(dest, true) + DeleteNumberDataPoint(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigNumberDataPoint(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufNumberDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesNumberDataPoint() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigNumberDataPoint(src)) - gotSize := MarshalProtoOrigNumberDataPoint(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.NumberDataPoint{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufNumberDataPoint(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigNumberDataPoint() - require.NoError(t, UnmarshalProtoOrigNumberDataPoint(dest, goBuf)) + dest := NewNumberDataPoint() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -160,17 +208,17 @@ func genTestFailingUnmarshalProtoValuesNumberDataPoint() map[string][]byte { } } -func genTestEncodingValuesNumberDataPoint() map[string]*otlpmetrics.NumberDataPoint { - return map[string]*otlpmetrics.NumberDataPoint{ - "empty": NewOrigNumberDataPoint(), - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, - "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, - "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, - "AsDouble/default": {Value: &otlpmetrics.NumberDataPoint_AsDouble{AsDouble: float64(0)}}, - "AsDouble/test": {Value: &otlpmetrics.NumberDataPoint_AsDouble{AsDouble: float64(3.1415926)}}, - "AsInt/default": {Value: &otlpmetrics.NumberDataPoint_AsInt{AsInt: int64(0)}}, - "AsInt/test": {Value: &otlpmetrics.NumberDataPoint_AsInt{AsInt: int64(13)}}, - "Exemplars/default_and_test": {Exemplars: []otlpmetrics.Exemplar{{}, *GenTestOrigExemplar()}}, - "Flags/test": {Flags: uint32(13)}, +func genTestEncodingValuesNumberDataPoint() map[string]*NumberDataPoint { + return map[string]*NumberDataPoint{ + "empty": NewNumberDataPoint(), + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, + "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, + "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, + "AsDouble/default": {Value: &NumberDataPoint_AsDouble{AsDouble: float64(0)}}, + "AsDouble/test": {Value: &NumberDataPoint_AsDouble{AsDouble: float64(3.1415926)}}, + "AsInt/default": {Value: &NumberDataPoint_AsInt{AsInt: int64(0)}}, + "AsInt/test": {Value: &NumberDataPoint_AsInt{AsInt: int64(13)}}, + "Exemplars/test": {Exemplars: []Exemplar{{}, *GenTestExemplar()}}, + "Flags/test": {Flags: uint32(13)}, } } diff --git a/pdata/internal/generated_wrapper_profile.go b/pdata/internal/generated_proto_profile.go similarity index 70% rename from pdata/internal/generated_wrapper_profile.go rename to pdata/internal/generated_proto_profile.go index c3b3994a7eb..eb1e0b9f922 100644 --- a/pdata/internal/generated_wrapper_profile.go +++ b/pdata/internal/generated_proto_profile.go @@ -11,28 +11,43 @@ import ( "fmt" "sync" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Profile are an implementation of the pprofextended data model. + +type Profile struct { + SampleType ValueType + Sample []*Sample + TimeUnixNano uint64 + DurationNano uint64 + PeriodType ValueType + Period int64 + CommentStrindices []int32 + ProfileId ProfileID + DroppedAttributesCount uint32 + OriginalPayloadFormat string + OriginalPayload []byte + AttributeIndices []int32 +} + var ( protoPoolProfile = sync.Pool{ New: func() any { - return &otlpprofiles.Profile{} + return &Profile{} }, } ) -func NewOrigProfile() *otlpprofiles.Profile { +func NewProfile() *Profile { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Profile{} + return &Profile{} } - return protoPoolProfile.Get().(*otlpprofiles.Profile) + return protoPoolProfile.Get().(*Profile) } -func DeleteOrigProfile(orig *otlpprofiles.Profile, nullable bool) { +func DeleteProfile(orig *Profile, nullable bool) { if orig == nil { return } @@ -42,12 +57,12 @@ func DeleteOrigProfile(orig *otlpprofiles.Profile, nullable bool) { return } - DeleteOrigValueType(&orig.SampleType, false) + DeleteValueType(&orig.SampleType, false) for i := range orig.Sample { - DeleteOrigSample(orig.Sample[i], true) + DeleteSample(orig.Sample[i], true) } - DeleteOrigValueType(&orig.PeriodType, false) - DeleteOrigProfileID(&orig.ProfileId, false) + DeleteValueType(&orig.PeriodType, false) + DeleteProfileID(&orig.ProfileId, false) orig.Reset() if nullable { @@ -55,54 +70,109 @@ func DeleteOrigProfile(orig *otlpprofiles.Profile, nullable bool) { } } -func CopyOrigProfile(dest, src *otlpprofiles.Profile) { +func CopyProfile(dest, src *Profile) *Profile { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewProfile() } - CopyOrigValueType(&dest.SampleType, &src.SampleType) - dest.Sample = CopyOrigSampleSlice(dest.Sample, src.Sample) + CopyValueType(&dest.SampleType, &src.SampleType) + + dest.Sample = CopySamplePtrSlice(dest.Sample, src.Sample) + dest.TimeUnixNano = src.TimeUnixNano + dest.DurationNano = src.DurationNano - CopyOrigValueType(&dest.PeriodType, &src.PeriodType) + + CopyValueType(&dest.PeriodType, &src.PeriodType) + dest.Period = src.Period - dest.CommentStrindices = CopyOrigInt32Slice(dest.CommentStrindices, src.CommentStrindices) - dest.ProfileId = src.ProfileId + + dest.CommentStrindices = append(dest.CommentStrindices[:0], src.CommentStrindices...) + CopyProfileID(&dest.ProfileId, &src.ProfileId) + dest.DroppedAttributesCount = src.DroppedAttributesCount + dest.OriginalPayloadFormat = src.OriginalPayloadFormat - dest.OriginalPayload = CopyOrigByteSlice(dest.OriginalPayload, src.OriginalPayload) - dest.AttributeIndices = CopyOrigInt32Slice(dest.AttributeIndices, src.AttributeIndices) + + dest.OriginalPayload = src.OriginalPayload + + dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) + + return dest } -func GenTestOrigProfile() *otlpprofiles.Profile { - orig := NewOrigProfile() - orig.SampleType = *GenTestOrigValueType() - orig.Sample = GenerateOrigTestSampleSlice() - orig.TimeUnixNano = 1234567890 - orig.DurationNano = 1234567890 - orig.PeriodType = *GenTestOrigValueType() - orig.Period = int64(13) - orig.CommentStrindices = GenerateOrigTestInt32Slice() - orig.ProfileId = data.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - orig.DroppedAttributesCount = uint32(13) - orig.OriginalPayloadFormat = "test_originalpayloadformat" - orig.OriginalPayload = GenerateOrigTestByteSlice() - orig.AttributeIndices = GenerateOrigTestInt32Slice() - return orig +func CopyProfileSlice(dest, src []Profile) []Profile { + var newDest []Profile + if cap(dest) < len(src) { + newDest = make([]Profile, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfile(&dest[i], false) + } + } + for i := range src { + CopyProfile(&newDest[i], &src[i]) + } + return newDest +} + +func CopyProfilePtrSlice(dest, src []*Profile) []*Profile { + var newDest []*Profile + if cap(dest) < len(src) { + newDest = make([]*Profile, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfile() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfile(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfile() + } + } + for i := range src { + CopyProfile(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigProfile(orig *otlpprofiles.Profile, dest *json.Stream) { +func (orig *Profile) Reset() { + *orig = Profile{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Profile) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() dest.WriteObjectField("sampleType") - MarshalJSONOrigValueType(&orig.SampleType, dest) + orig.SampleType.MarshalJSON(dest) if len(orig.Sample) > 0 { dest.WriteObjectField("sample") dest.WriteArrayStart() - MarshalJSONOrigSample(orig.Sample[0], dest) + orig.Sample[0].MarshalJSON(dest) for i := 1; i < len(orig.Sample); i++ { dest.WriteMore() - MarshalJSONOrigSample(orig.Sample[i], dest) + orig.Sample[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -115,7 +185,7 @@ func MarshalJSONOrigProfile(orig *otlpprofiles.Profile, dest *json.Stream) { dest.WriteUint64(orig.DurationNano) } dest.WriteObjectField("periodType") - MarshalJSONOrigValueType(&orig.PeriodType, dest) + orig.PeriodType.MarshalJSON(dest) if orig.Period != int64(0) { dest.WriteObjectField("period") dest.WriteInt64(orig.Period) @@ -130,9 +200,9 @@ func MarshalJSONOrigProfile(orig *otlpprofiles.Profile, dest *json.Stream) { } dest.WriteArrayEnd() } - if orig.ProfileId != data.ProfileID([16]byte{}) { + if !orig.ProfileId.IsEmpty() { dest.WriteObjectField("profileId") - MarshalJSONOrigProfileID(&orig.ProfileId, dest) + orig.ProfileId.MarshalJSON(dest) } if orig.DroppedAttributesCount != uint32(0) { dest.WriteObjectField("droppedAttributesCount") @@ -160,16 +230,17 @@ func MarshalJSONOrigProfile(orig *otlpprofiles.Profile, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigProfile unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigProfile(orig *otlpprofiles.Profile, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Profile) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "sampleType", "sample_type": - UnmarshalJSONOrigValueType(&orig.SampleType, iter) + + orig.SampleType.UnmarshalJSON(iter) case "sample": for iter.ReadArray() { - orig.Sample = append(orig.Sample, NewOrigSample()) - UnmarshalJSONOrigSample(orig.Sample[len(orig.Sample)-1], iter) + orig.Sample = append(orig.Sample, NewSample()) + orig.Sample[len(orig.Sample)-1].UnmarshalJSON(iter) } case "timeUnixNano", "time_unix_nano": @@ -177,7 +248,8 @@ func UnmarshalJSONOrigProfile(orig *otlpprofiles.Profile, iter *json.Iterator) { case "durationNano", "duration_nano": orig.DurationNano = iter.ReadUint64() case "periodType", "period_type": - UnmarshalJSONOrigValueType(&orig.PeriodType, iter) + + orig.PeriodType.UnmarshalJSON(iter) case "period": orig.Period = iter.ReadInt64() case "commentStrindices", "comment_strindices": @@ -186,7 +258,8 @@ func UnmarshalJSONOrigProfile(orig *otlpprofiles.Profile, iter *json.Iterator) { } case "profileId", "profile_id": - UnmarshalJSONOrigProfileID(&orig.ProfileId, iter) + + orig.ProfileId.UnmarshalJSON(iter) case "droppedAttributesCount", "dropped_attributes_count": orig.DroppedAttributesCount = iter.ReadUint32() case "originalPayloadFormat", "original_payload_format": @@ -204,14 +277,14 @@ func UnmarshalJSONOrigProfile(orig *otlpprofiles.Profile, iter *json.Iterator) { } } -func SizeProtoOrigProfile(orig *otlpprofiles.Profile) int { +func (orig *Profile) SizeProto() int { var n int var l int _ = l - l = SizeProtoOrigValueType(&orig.SampleType) + l = orig.SampleType.SizeProto() n += 1 + proto.Sov(uint64(l)) + l for i := range orig.Sample { - l = SizeProtoOrigSample(orig.Sample[i]) + l = orig.Sample[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.TimeUnixNano != 0 { @@ -220,7 +293,7 @@ func SizeProtoOrigProfile(orig *otlpprofiles.Profile) int { if orig.DurationNano != 0 { n += 1 + proto.Sov(uint64(orig.DurationNano)) } - l = SizeProtoOrigValueType(&orig.PeriodType) + l = orig.PeriodType.SizeProto() n += 1 + proto.Sov(uint64(l)) + l if orig.Period != 0 { n += 1 + proto.Sov(uint64(orig.Period)) @@ -232,7 +305,7 @@ func SizeProtoOrigProfile(orig *otlpprofiles.Profile) int { } n += 1 + proto.Sov(uint64(l)) + l } - l = SizeProtoOrigProfileID(&orig.ProfileId) + l = orig.ProfileId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l if orig.DroppedAttributesCount != 0 { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) @@ -255,19 +328,18 @@ func SizeProtoOrigProfile(orig *otlpprofiles.Profile) int { return n } -func MarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) int { +func (orig *Profile) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - - l = MarshalProtoOrigValueType(&orig.SampleType, buf[:pos]) + l = orig.SampleType.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0xa for i := len(orig.Sample) - 1; i >= 0; i-- { - l = MarshalProtoOrigSample(orig.Sample[i], buf[:pos]) + l = orig.Sample[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -284,8 +356,7 @@ func MarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) int { pos-- buf[pos] = 0x20 } - - l = MarshalProtoOrigValueType(&orig.PeriodType, buf[:pos]) + l = orig.PeriodType.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -306,8 +377,7 @@ func MarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) int { pos-- buf[pos] = 0x3a } - - l = MarshalProtoOrigProfileID(&orig.ProfileId, buf[:pos]) + l = orig.ProfileId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -347,7 +417,7 @@ func MarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) error { +func (orig *Profile) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -373,7 +443,7 @@ func UnmarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigValueType(&orig.SampleType, buf[startPos:pos]) + err = orig.SampleType.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -388,8 +458,8 @@ func UnmarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) error { return err } startPos := pos - length - orig.Sample = append(orig.Sample, NewOrigSample()) - err = UnmarshalProtoOrigSample(orig.Sample[len(orig.Sample)-1], buf[startPos:pos]) + orig.Sample = append(orig.Sample, NewSample()) + err = orig.Sample[len(orig.Sample)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -429,7 +499,7 @@ func UnmarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigValueType(&orig.PeriodType, buf[startPos:pos]) + err = orig.PeriodType.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -487,7 +557,7 @@ func UnmarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigProfileID(&orig.ProfileId, buf[startPos:pos]) + err = orig.ProfileId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -569,3 +639,37 @@ func UnmarshalProtoOrigProfile(orig *otlpprofiles.Profile, buf []byte) error { } return nil } + +func GenTestProfile() *Profile { + orig := NewProfile() + orig.SampleType = *GenTestValueType() + orig.Sample = []*Sample{{}, GenTestSample()} + orig.TimeUnixNano = uint64(13) + orig.DurationNano = uint64(13) + orig.PeriodType = *GenTestValueType() + orig.Period = int64(13) + orig.CommentStrindices = []int32{int32(0), int32(13)} + orig.ProfileId = *GenTestProfileID() + orig.DroppedAttributesCount = uint32(13) + orig.OriginalPayloadFormat = "test_originalpayloadformat" + orig.OriginalPayload = []byte{1, 2, 3} + orig.AttributeIndices = []int32{int32(0), int32(13)} + return orig +} + +func GenTestProfilePtrSlice() []*Profile { + orig := make([]*Profile, 5) + orig[0] = NewProfile() + orig[1] = GenTestProfile() + orig[2] = NewProfile() + orig[3] = GenTestProfile() + orig[4] = NewProfile() + return orig +} + +func GenTestProfileSlice() []Profile { + orig := make([]Profile, 5) + orig[1] = *GenTestProfile() + orig[3] = *GenTestProfile() + return orig +} diff --git a/pdata/internal/generated_wrapper_profile_test.go b/pdata/internal/generated_proto_profile_test.go similarity index 55% rename from pdata/internal/generated_wrapper_profile_test.go rename to pdata/internal/generated_proto_profile_test.go index dcc0940d8c3..872f0823c9c 100644 --- a/pdata/internal/generated_wrapper_profile_test.go +++ b/pdata/internal/generated_proto_profile_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigProfile(t *testing.T) { +func TestCopyProfile(t *testing.T) { for name, src := range genTestEncodingValuesProfile() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigProfile(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigProfile() - CopyOrigProfile(dest, src) + dest := NewProfile() + CopyProfile(dest, src) assert.Equal(t, src, dest) - CopyOrigProfile(dest, dest) + CopyProfile(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigProfileUnknown(t *testing.T) { +func TestCopyProfileSlice(t *testing.T) { + src := []Profile{} + dest := []Profile{} + // Test CopyTo empty + dest = CopyProfileSlice(dest, src) + assert.Equal(t, []Profile{}, dest) + + // Test CopyTo larger slice + src = GenTestProfileSlice() + dest = CopyProfileSlice(dest, src) + assert.Equal(t, GenTestProfileSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfileSlice(dest, src) + assert.Equal(t, GenTestProfileSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfileSlice(dest, []Profile{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfileSlice(dest, src) + assert.Equal(t, GenTestProfileSlice(), dest) +} + +func TestCopyProfilePtrSlice(t *testing.T) { + src := []*Profile{} + dest := []*Profile{} + // Test CopyTo empty + dest = CopyProfilePtrSlice(dest, src) + assert.Equal(t, []*Profile{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilePtrSlice() + dest = CopyProfilePtrSlice(dest, src) + assert.Equal(t, GenTestProfilePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilePtrSlice(dest, src) + assert.Equal(t, GenTestProfilePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilePtrSlice(dest, []*Profile{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilePtrSlice(dest, src) + assert.Equal(t, GenTestProfilePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONProfileUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigProfile() - UnmarshalJSONOrigProfile(dest, iter) + dest := NewProfile() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigProfile(), dest) + assert.Equal(t, NewProfile(), dest) } -func TestMarshalAndUnmarshalJSONOrigProfile(t *testing.T) { +func TestMarshalAndUnmarshalJSONProfile(t *testing.T) { for name, src := range genTestEncodingValuesProfile() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigProfile(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigProfile(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigProfile() - UnmarshalJSONOrigProfile(dest, iter) + dest := NewProfile() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigProfile(dest, true) + DeleteProfile(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigProfileFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoProfileFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesProfile() { t.Run(name, func(t *testing.T) { - dest := NewOrigProfile() - require.Error(t, UnmarshalProtoOrigProfile(dest, buf)) + dest := NewProfile() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigProfileUnknown(t *testing.T) { - dest := NewOrigProfile() +func TestMarshalAndUnmarshalProtoProfileUnknown(t *testing.T) { + dest := NewProfile() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigProfile(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigProfile(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewProfile(), dest) } -func TestMarshalAndUnmarshalProtoOrigProfile(t *testing.T) { +func TestMarshalAndUnmarshalProtoProfile(t *testing.T) { for name, src := range genTestEncodingValuesProfile() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigProfile(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigProfile(src)) - gotSize := MarshalProtoOrigProfile(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigProfile() - require.NoError(t, UnmarshalProtoOrigProfile(dest, buf)) + dest := NewProfile() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigProfile(dest, true) + DeleteProfile(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigProfile(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufProfile(t *testing.T) { for name, src := range genTestEncodingValuesProfile() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigProfile(src)) - gotSize := MarshalProtoOrigProfile(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Profile{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufProfile(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigProfile() - require.NoError(t, UnmarshalProtoOrigProfile(dest, goBuf)) + dest := NewProfile() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -167,20 +216,20 @@ func genTestFailingUnmarshalProtoValuesProfile() map[string][]byte { } } -func genTestEncodingValuesProfile() map[string]*otlpprofiles.Profile { - return map[string]*otlpprofiles.Profile{ - "empty": NewOrigProfile(), - "SampleType/test": {SampleType: *GenTestOrigValueType()}, - "Sample/default_and_test": {Sample: []*otlpprofiles.Sample{{}, GenTestOrigSample()}}, - "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, - "DurationNano/test": {DurationNano: uint64(13)}, - "PeriodType/test": {PeriodType: *GenTestOrigValueType()}, - "Period/test": {Period: int64(13)}, - "CommentStrindices/default_and_test": {CommentStrindices: []int32{int32(0), int32(13)}}, - "ProfileId/test": {ProfileId: *GenTestOrigProfileID()}, - "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, - "OriginalPayloadFormat/test": {OriginalPayloadFormat: "test_originalpayloadformat"}, - "OriginalPayload/test": {OriginalPayload: []byte{1, 2, 3}}, - "AttributeIndices/default_and_test": {AttributeIndices: []int32{int32(0), int32(13)}}, +func genTestEncodingValuesProfile() map[string]*Profile { + return map[string]*Profile{ + "empty": NewProfile(), + "SampleType/test": {SampleType: *GenTestValueType()}, + "Sample/test": {Sample: []*Sample{{}, GenTestSample()}}, + "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, + "DurationNano/test": {DurationNano: uint64(13)}, + "PeriodType/test": {PeriodType: *GenTestValueType()}, + "Period/test": {Period: int64(13)}, + "CommentStrindices/test": {CommentStrindices: []int32{int32(0), int32(13)}}, + "ProfileId/test": {ProfileId: *GenTestProfileID()}, + "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, + "OriginalPayloadFormat/test": {OriginalPayloadFormat: "test_originalpayloadformat"}, + "OriginalPayload/test": {OriginalPayload: []byte{1, 2, 3}}, + "AttributeIndices/test": {AttributeIndices: []int32{int32(0), int32(13)}}, } } diff --git a/pdata/internal/generated_proto_profilesdata.go b/pdata/internal/generated_proto_profilesdata.go new file mode 100644 index 00000000000..f3d1c1a16d9 --- /dev/null +++ b/pdata/internal/generated_proto_profilesdata.go @@ -0,0 +1,281 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ProfilesData represents the profiles data that can be stored in persistent storage, +// OR can be embedded by other protocols that transfer OTLP profiles data but do not +// implement the OTLP protocol. +type ProfilesData struct { + ResourceProfiles []*ResourceProfiles + Dictionary ProfilesDictionary +} + +var ( + protoPoolProfilesData = sync.Pool{ + New: func() any { + return &ProfilesData{} + }, + } +) + +func NewProfilesData() *ProfilesData { + if !UseProtoPooling.IsEnabled() { + return &ProfilesData{} + } + return protoPoolProfilesData.Get().(*ProfilesData) +} + +func DeleteProfilesData(orig *ProfilesData, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceProfiles { + DeleteResourceProfiles(orig.ResourceProfiles[i], true) + } + DeleteProfilesDictionary(&orig.Dictionary, false) + + orig.Reset() + if nullable { + protoPoolProfilesData.Put(orig) + } +} + +func CopyProfilesData(dest, src *ProfilesData) *ProfilesData { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewProfilesData() + } + dest.ResourceProfiles = CopyResourceProfilesPtrSlice(dest.ResourceProfiles, src.ResourceProfiles) + + CopyProfilesDictionary(&dest.Dictionary, &src.Dictionary) + + return dest +} + +func CopyProfilesDataSlice(dest, src []ProfilesData) []ProfilesData { + var newDest []ProfilesData + if cap(dest) < len(src) { + newDest = make([]ProfilesData, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfilesData(&dest[i], false) + } + } + for i := range src { + CopyProfilesData(&newDest[i], &src[i]) + } + return newDest +} + +func CopyProfilesDataPtrSlice(dest, src []*ProfilesData) []*ProfilesData { + var newDest []*ProfilesData + if cap(dest) < len(src) { + newDest = make([]*ProfilesData, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfilesData() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfilesData(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfilesData() + } + } + for i := range src { + CopyProfilesData(newDest[i], src[i]) + } + return newDest +} + +func (orig *ProfilesData) Reset() { + *orig = ProfilesData{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ProfilesData) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceProfiles) > 0 { + dest.WriteObjectField("resourceProfiles") + dest.WriteArrayStart() + orig.ResourceProfiles[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceProfiles); i++ { + dest.WriteMore() + orig.ResourceProfiles[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectField("dictionary") + orig.Dictionary.MarshalJSON(dest) + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ProfilesData) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceProfiles", "resource_profiles": + for iter.ReadArray() { + orig.ResourceProfiles = append(orig.ResourceProfiles, NewResourceProfiles()) + orig.ResourceProfiles[len(orig.ResourceProfiles)-1].UnmarshalJSON(iter) + } + + case "dictionary": + + orig.Dictionary.UnmarshalJSON(iter) + default: + iter.Skip() + } + } +} + +func (orig *ProfilesData) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceProfiles { + l = orig.ResourceProfiles[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + l = orig.Dictionary.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + return n +} + +func (orig *ProfilesData) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceProfiles) - 1; i >= 0; i-- { + l = orig.ResourceProfiles[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = orig.Dictionary.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + + return len(buf) - pos +} + +func (orig *ProfilesData) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceProfiles", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceProfiles = append(orig.ResourceProfiles, NewResourceProfiles()) + err = orig.ResourceProfiles[len(orig.ResourceProfiles)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Dictionary", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Dictionary.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestProfilesData() *ProfilesData { + orig := NewProfilesData() + orig.ResourceProfiles = []*ResourceProfiles{{}, GenTestResourceProfiles()} + orig.Dictionary = *GenTestProfilesDictionary() + return orig +} + +func GenTestProfilesDataPtrSlice() []*ProfilesData { + orig := make([]*ProfilesData, 5) + orig[0] = NewProfilesData() + orig[1] = GenTestProfilesData() + orig[2] = NewProfilesData() + orig[3] = GenTestProfilesData() + orig[4] = NewProfilesData() + return orig +} + +func GenTestProfilesDataSlice() []ProfilesData { + orig := make([]ProfilesData, 5) + orig[1] = *GenTestProfilesData() + orig[3] = *GenTestProfilesData() + return orig +} diff --git a/pdata/internal/generated_proto_profilesdata_test.go b/pdata/internal/generated_proto_profilesdata_test.go new file mode 100644 index 00000000000..99901d13b5f --- /dev/null +++ b/pdata/internal/generated_proto_profilesdata_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpprofiles "go.opentelemetry.io/proto/slim/otlp/profiles/v1development" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyProfilesData(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewProfilesData() + CopyProfilesData(dest, src) + assert.Equal(t, src, dest) + CopyProfilesData(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyProfilesDataSlice(t *testing.T) { + src := []ProfilesData{} + dest := []ProfilesData{} + // Test CopyTo empty + dest = CopyProfilesDataSlice(dest, src) + assert.Equal(t, []ProfilesData{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilesDataSlice() + dest = CopyProfilesDataSlice(dest, src) + assert.Equal(t, GenTestProfilesDataSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilesDataSlice(dest, src) + assert.Equal(t, GenTestProfilesDataSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilesDataSlice(dest, []ProfilesData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilesDataSlice(dest, src) + assert.Equal(t, GenTestProfilesDataSlice(), dest) +} + +func TestCopyProfilesDataPtrSlice(t *testing.T) { + src := []*ProfilesData{} + dest := []*ProfilesData{} + // Test CopyTo empty + dest = CopyProfilesDataPtrSlice(dest, src) + assert.Equal(t, []*ProfilesData{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilesDataPtrSlice() + dest = CopyProfilesDataPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesDataPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilesDataPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesDataPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilesDataPtrSlice(dest, []*ProfilesData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilesDataPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesDataPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONProfilesDataUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewProfilesData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewProfilesData(), dest) +} + +func TestMarshalAndUnmarshalJSONProfilesData(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewProfilesData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteProfilesData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoProfilesDataFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesProfilesData() { + t.Run(name, func(t *testing.T) { + dest := NewProfilesData() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoProfilesDataUnknown(t *testing.T) { + dest := NewProfilesData() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewProfilesData(), dest) +} + +func TestMarshalAndUnmarshalProtoProfilesData(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewProfilesData() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteProfilesData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufProfilesData(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesData() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpprofiles.ProfilesData{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewProfilesData() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesProfilesData() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceProfiles/wrong_wire_type": {0xc}, + "ResourceProfiles/missing_value": {0xa}, + "Dictionary/wrong_wire_type": {0x14}, + "Dictionary/missing_value": {0x12}, + } +} + +func genTestEncodingValuesProfilesData() map[string]*ProfilesData { + return map[string]*ProfilesData{ + "empty": NewProfilesData(), + "ResourceProfiles/test": {ResourceProfiles: []*ResourceProfiles{{}, GenTestResourceProfiles()}}, + "Dictionary/test": {Dictionary: *GenTestProfilesDictionary()}, + } +} diff --git a/pdata/internal/generated_wrapper_profilesdictionary.go b/pdata/internal/generated_proto_profilesdictionary.go similarity index 50% rename from pdata/internal/generated_wrapper_profilesdictionary.go rename to pdata/internal/generated_proto_profilesdictionary.go index 671414494b2..af6168e1174 100644 --- a/pdata/internal/generated_wrapper_profilesdictionary.go +++ b/pdata/internal/generated_proto_profilesdictionary.go @@ -10,27 +10,37 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// ProfilesDictionary is the reference table containing all data shared by profiles across the message being sent. +type ProfilesDictionary struct { + MappingTable []*Mapping + LocationTable []*Location + FunctionTable []*Function + LinkTable []*Link + StringTable []string + AttributeTable []*KeyValueAndUnit + StackTable []*Stack +} + var ( protoPoolProfilesDictionary = sync.Pool{ New: func() any { - return &otlpprofiles.ProfilesDictionary{} + return &ProfilesDictionary{} }, } ) -func NewOrigProfilesDictionary() *otlpprofiles.ProfilesDictionary { +func NewProfilesDictionary() *ProfilesDictionary { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.ProfilesDictionary{} + return &ProfilesDictionary{} } - return protoPoolProfilesDictionary.Get().(*otlpprofiles.ProfilesDictionary) + return protoPoolProfilesDictionary.Get().(*ProfilesDictionary) } -func DeleteOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, nullable bool) { +func DeleteProfilesDictionary(orig *ProfilesDictionary, nullable bool) { if orig == nil { return } @@ -41,22 +51,22 @@ func DeleteOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, nullabl } for i := range orig.MappingTable { - DeleteOrigMapping(orig.MappingTable[i], true) + DeleteMapping(orig.MappingTable[i], true) } for i := range orig.LocationTable { - DeleteOrigLocation(orig.LocationTable[i], true) + DeleteLocation(orig.LocationTable[i], true) } for i := range orig.FunctionTable { - DeleteOrigFunction(orig.FunctionTable[i], true) + DeleteFunction(orig.FunctionTable[i], true) } for i := range orig.LinkTable { - DeleteOrigLink(orig.LinkTable[i], true) + DeleteLink(orig.LinkTable[i], true) } for i := range orig.AttributeTable { - DeleteOrigKeyValueAndUnit(orig.AttributeTable[i], true) + DeleteKeyValueAndUnit(orig.AttributeTable[i], true) } for i := range orig.StackTable { - DeleteOrigStack(orig.StackTable[i], true) + DeleteStack(orig.StackTable[i], true) } orig.Reset() @@ -65,72 +75,127 @@ func DeleteOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, nullabl } } -func CopyOrigProfilesDictionary(dest, src *otlpprofiles.ProfilesDictionary) { +func CopyProfilesDictionary(dest, src *ProfilesDictionary) *ProfilesDictionary { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil } - dest.MappingTable = CopyOrigMappingSlice(dest.MappingTable, src.MappingTable) - dest.LocationTable = CopyOrigLocationSlice(dest.LocationTable, src.LocationTable) - dest.FunctionTable = CopyOrigFunctionSlice(dest.FunctionTable, src.FunctionTable) - dest.LinkTable = CopyOrigLinkSlice(dest.LinkTable, src.LinkTable) - dest.StringTable = CopyOrigStringSlice(dest.StringTable, src.StringTable) - dest.AttributeTable = CopyOrigKeyValueAndUnitSlice(dest.AttributeTable, src.AttributeTable) - dest.StackTable = CopyOrigStackSlice(dest.StackTable, src.StackTable) + + if dest == nil { + dest = NewProfilesDictionary() + } + dest.MappingTable = CopyMappingPtrSlice(dest.MappingTable, src.MappingTable) + + dest.LocationTable = CopyLocationPtrSlice(dest.LocationTable, src.LocationTable) + + dest.FunctionTable = CopyFunctionPtrSlice(dest.FunctionTable, src.FunctionTable) + + 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) + + return dest } -func GenTestOrigProfilesDictionary() *otlpprofiles.ProfilesDictionary { - orig := NewOrigProfilesDictionary() - orig.MappingTable = GenerateOrigTestMappingSlice() - orig.LocationTable = GenerateOrigTestLocationSlice() - orig.FunctionTable = GenerateOrigTestFunctionSlice() - orig.LinkTable = GenerateOrigTestLinkSlice() - orig.StringTable = GenerateOrigTestStringSlice() - orig.AttributeTable = GenerateOrigTestKeyValueAndUnitSlice() - orig.StackTable = GenerateOrigTestStackSlice() - return orig +func CopyProfilesDictionarySlice(dest, src []ProfilesDictionary) []ProfilesDictionary { + var newDest []ProfilesDictionary + if cap(dest) < len(src) { + newDest = make([]ProfilesDictionary, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfilesDictionary(&dest[i], false) + } + } + for i := range src { + CopyProfilesDictionary(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, dest *json.Stream) { +func CopyProfilesDictionaryPtrSlice(dest, src []*ProfilesDictionary) []*ProfilesDictionary { + var newDest []*ProfilesDictionary + if cap(dest) < len(src) { + newDest = make([]*ProfilesDictionary, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfilesDictionary() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfilesDictionary(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfilesDictionary() + } + } + for i := range src { + CopyProfilesDictionary(newDest[i], src[i]) + } + return newDest +} + +func (orig *ProfilesDictionary) Reset() { + *orig = ProfilesDictionary{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ProfilesDictionary) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.MappingTable) > 0 { dest.WriteObjectField("mappingTable") dest.WriteArrayStart() - MarshalJSONOrigMapping(orig.MappingTable[0], dest) + orig.MappingTable[0].MarshalJSON(dest) for i := 1; i < len(orig.MappingTable); i++ { dest.WriteMore() - MarshalJSONOrigMapping(orig.MappingTable[i], dest) + orig.MappingTable[i].MarshalJSON(dest) } dest.WriteArrayEnd() } if len(orig.LocationTable) > 0 { dest.WriteObjectField("locationTable") dest.WriteArrayStart() - MarshalJSONOrigLocation(orig.LocationTable[0], dest) + orig.LocationTable[0].MarshalJSON(dest) for i := 1; i < len(orig.LocationTable); i++ { dest.WriteMore() - MarshalJSONOrigLocation(orig.LocationTable[i], dest) + orig.LocationTable[i].MarshalJSON(dest) } dest.WriteArrayEnd() } if len(orig.FunctionTable) > 0 { dest.WriteObjectField("functionTable") dest.WriteArrayStart() - MarshalJSONOrigFunction(orig.FunctionTable[0], dest) + orig.FunctionTable[0].MarshalJSON(dest) for i := 1; i < len(orig.FunctionTable); i++ { dest.WriteMore() - MarshalJSONOrigFunction(orig.FunctionTable[i], dest) + orig.FunctionTable[i].MarshalJSON(dest) } dest.WriteArrayEnd() } if len(orig.LinkTable) > 0 { dest.WriteObjectField("linkTable") dest.WriteArrayStart() - MarshalJSONOrigLink(orig.LinkTable[0], dest) + orig.LinkTable[0].MarshalJSON(dest) for i := 1; i < len(orig.LinkTable); i++ { dest.WriteMore() - MarshalJSONOrigLink(orig.LinkTable[i], dest) + orig.LinkTable[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -147,52 +212,52 @@ func MarshalJSONOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, de if len(orig.AttributeTable) > 0 { dest.WriteObjectField("attributeTable") dest.WriteArrayStart() - MarshalJSONOrigKeyValueAndUnit(orig.AttributeTable[0], dest) + orig.AttributeTable[0].MarshalJSON(dest) for i := 1; i < len(orig.AttributeTable); i++ { dest.WriteMore() - MarshalJSONOrigKeyValueAndUnit(orig.AttributeTable[i], dest) + orig.AttributeTable[i].MarshalJSON(dest) } dest.WriteArrayEnd() } if len(orig.StackTable) > 0 { dest.WriteObjectField("stackTable") dest.WriteArrayStart() - MarshalJSONOrigStack(orig.StackTable[0], dest) + orig.StackTable[0].MarshalJSON(dest) for i := 1; i < len(orig.StackTable); i++ { dest.WriteMore() - MarshalJSONOrigStack(orig.StackTable[i], dest) + orig.StackTable[i].MarshalJSON(dest) } dest.WriteArrayEnd() } dest.WriteObjectEnd() } -// UnmarshalJSONOrigProfilesDictionary unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ProfilesDictionary) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "mappingTable", "mapping_table": for iter.ReadArray() { - orig.MappingTable = append(orig.MappingTable, NewOrigMapping()) - UnmarshalJSONOrigMapping(orig.MappingTable[len(orig.MappingTable)-1], iter) + orig.MappingTable = append(orig.MappingTable, NewMapping()) + orig.MappingTable[len(orig.MappingTable)-1].UnmarshalJSON(iter) } case "locationTable", "location_table": for iter.ReadArray() { - orig.LocationTable = append(orig.LocationTable, NewOrigLocation()) - UnmarshalJSONOrigLocation(orig.LocationTable[len(orig.LocationTable)-1], iter) + orig.LocationTable = append(orig.LocationTable, NewLocation()) + orig.LocationTable[len(orig.LocationTable)-1].UnmarshalJSON(iter) } case "functionTable", "function_table": for iter.ReadArray() { - orig.FunctionTable = append(orig.FunctionTable, NewOrigFunction()) - UnmarshalJSONOrigFunction(orig.FunctionTable[len(orig.FunctionTable)-1], iter) + orig.FunctionTable = append(orig.FunctionTable, NewFunction()) + orig.FunctionTable[len(orig.FunctionTable)-1].UnmarshalJSON(iter) } case "linkTable", "link_table": for iter.ReadArray() { - orig.LinkTable = append(orig.LinkTable, NewOrigLink()) - UnmarshalJSONOrigLink(orig.LinkTable[len(orig.LinkTable)-1], iter) + orig.LinkTable = append(orig.LinkTable, NewLink()) + orig.LinkTable[len(orig.LinkTable)-1].UnmarshalJSON(iter) } case "stringTable", "string_table": @@ -202,14 +267,14 @@ func UnmarshalJSONOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, case "attributeTable", "attribute_table": for iter.ReadArray() { - orig.AttributeTable = append(orig.AttributeTable, NewOrigKeyValueAndUnit()) - UnmarshalJSONOrigKeyValueAndUnit(orig.AttributeTable[len(orig.AttributeTable)-1], iter) + orig.AttributeTable = append(orig.AttributeTable, NewKeyValueAndUnit()) + orig.AttributeTable[len(orig.AttributeTable)-1].UnmarshalJSON(iter) } case "stackTable", "stack_table": for iter.ReadArray() { - orig.StackTable = append(orig.StackTable, NewOrigStack()) - UnmarshalJSONOrigStack(orig.StackTable[len(orig.StackTable)-1], iter) + orig.StackTable = append(orig.StackTable, NewStack()) + orig.StackTable[len(orig.StackTable)-1].UnmarshalJSON(iter) } default: @@ -218,24 +283,24 @@ func UnmarshalJSONOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, } } -func SizeProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary) int { +func (orig *ProfilesDictionary) SizeProto() int { var n int var l int _ = l for i := range orig.MappingTable { - l = SizeProtoOrigMapping(orig.MappingTable[i]) + l = orig.MappingTable[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.LocationTable { - l = SizeProtoOrigLocation(orig.LocationTable[i]) + l = orig.LocationTable[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.FunctionTable { - l = SizeProtoOrigFunction(orig.FunctionTable[i]) + l = orig.FunctionTable[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.LinkTable { - l = SizeProtoOrigLink(orig.LinkTable[i]) + l = orig.LinkTable[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } for _, s := range orig.StringTable { @@ -243,43 +308,43 @@ func SizeProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary) int n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.AttributeTable { - l = SizeProtoOrigKeyValueAndUnit(orig.AttributeTable[i]) + l = orig.AttributeTable[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.StackTable { - l = SizeProtoOrigStack(orig.StackTable[i]) + l = orig.StackTable[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } return n } -func MarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, buf []byte) int { +func (orig *ProfilesDictionary) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.MappingTable) - 1; i >= 0; i-- { - l = MarshalProtoOrigMapping(orig.MappingTable[i], buf[:pos]) + l = orig.MappingTable[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0xa } for i := len(orig.LocationTable) - 1; i >= 0; i-- { - l = MarshalProtoOrigLocation(orig.LocationTable[i], buf[:pos]) + l = orig.LocationTable[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x12 } for i := len(orig.FunctionTable) - 1; i >= 0; i-- { - l = MarshalProtoOrigFunction(orig.FunctionTable[i], buf[:pos]) + l = orig.FunctionTable[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x1a } for i := len(orig.LinkTable) - 1; i >= 0; i-- { - l = MarshalProtoOrigLink(orig.LinkTable[i], buf[:pos]) + l = orig.LinkTable[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -294,14 +359,14 @@ func MarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, b buf[pos] = 0x2a } for i := len(orig.AttributeTable) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValueAndUnit(orig.AttributeTable[i], buf[:pos]) + l = orig.AttributeTable[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0x32 } for i := len(orig.StackTable) - 1; i >= 0; i-- { - l = MarshalProtoOrigStack(orig.StackTable[i], buf[:pos]) + l = orig.StackTable[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -310,7 +375,7 @@ func MarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, b return len(buf) - pos } -func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, buf []byte) error { +func (orig *ProfilesDictionary) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -335,8 +400,8 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, return err } startPos := pos - length - orig.MappingTable = append(orig.MappingTable, NewOrigMapping()) - err = UnmarshalProtoOrigMapping(orig.MappingTable[len(orig.MappingTable)-1], buf[startPos:pos]) + orig.MappingTable = append(orig.MappingTable, NewMapping()) + err = orig.MappingTable[len(orig.MappingTable)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -351,8 +416,8 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, return err } startPos := pos - length - orig.LocationTable = append(orig.LocationTable, NewOrigLocation()) - err = UnmarshalProtoOrigLocation(orig.LocationTable[len(orig.LocationTable)-1], buf[startPos:pos]) + orig.LocationTable = append(orig.LocationTable, NewLocation()) + err = orig.LocationTable[len(orig.LocationTable)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -367,8 +432,8 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, return err } startPos := pos - length - orig.FunctionTable = append(orig.FunctionTable, NewOrigFunction()) - err = UnmarshalProtoOrigFunction(orig.FunctionTable[len(orig.FunctionTable)-1], buf[startPos:pos]) + orig.FunctionTable = append(orig.FunctionTable, NewFunction()) + err = orig.FunctionTable[len(orig.FunctionTable)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -383,8 +448,8 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, return err } startPos := pos - length - orig.LinkTable = append(orig.LinkTable, NewOrigLink()) - err = UnmarshalProtoOrigLink(orig.LinkTable[len(orig.LinkTable)-1], buf[startPos:pos]) + orig.LinkTable = append(orig.LinkTable, NewLink()) + err = orig.LinkTable[len(orig.LinkTable)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -411,8 +476,8 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, return err } startPos := pos - length - orig.AttributeTable = append(orig.AttributeTable, NewOrigKeyValueAndUnit()) - err = UnmarshalProtoOrigKeyValueAndUnit(orig.AttributeTable[len(orig.AttributeTable)-1], buf[startPos:pos]) + orig.AttributeTable = append(orig.AttributeTable, NewKeyValueAndUnit()) + err = orig.AttributeTable[len(orig.AttributeTable)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -427,8 +492,8 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, return err } startPos := pos - length - orig.StackTable = append(orig.StackTable, NewOrigStack()) - err = UnmarshalProtoOrigStack(orig.StackTable[len(orig.StackTable)-1], buf[startPos:pos]) + orig.StackTable = append(orig.StackTable, NewStack()) + err = orig.StackTable[len(orig.StackTable)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -441,3 +506,32 @@ func UnmarshalProtoOrigProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, } return nil } + +func GenTestProfilesDictionary() *ProfilesDictionary { + orig := NewProfilesDictionary() + orig.MappingTable = []*Mapping{{}, GenTestMapping()} + orig.LocationTable = []*Location{{}, GenTestLocation()} + orig.FunctionTable = []*Function{{}, GenTestFunction()} + orig.LinkTable = []*Link{{}, GenTestLink()} + orig.StringTable = []string{"", "test_stringtable"} + orig.AttributeTable = []*KeyValueAndUnit{{}, GenTestKeyValueAndUnit()} + orig.StackTable = []*Stack{{}, GenTestStack()} + return orig +} + +func GenTestProfilesDictionaryPtrSlice() []*ProfilesDictionary { + orig := make([]*ProfilesDictionary, 5) + orig[0] = NewProfilesDictionary() + orig[1] = GenTestProfilesDictionary() + orig[2] = NewProfilesDictionary() + orig[3] = GenTestProfilesDictionary() + orig[4] = NewProfilesDictionary() + return orig +} + +func GenTestProfilesDictionarySlice() []ProfilesDictionary { + orig := make([]ProfilesDictionary, 5) + orig[1] = *GenTestProfilesDictionary() + orig[3] = *GenTestProfilesDictionary() + return orig +} diff --git a/pdata/internal/generated_wrapper_profilesdictionary_test.go b/pdata/internal/generated_proto_profilesdictionary_test.go similarity index 50% rename from pdata/internal/generated_wrapper_profilesdictionary_test.go rename to pdata/internal/generated_proto_profilesdictionary_test.go index 662756e173a..8408878a0e8 100644 --- a/pdata/internal/generated_wrapper_profilesdictionary_test.go +++ b/pdata/internal/generated_proto_profilesdictionary_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigProfilesDictionary(t *testing.T) { +func TestCopyProfilesDictionary(t *testing.T) { for name, src := range genTestEncodingValuesProfilesDictionary() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigProfilesDictionary(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigProfilesDictionary() - CopyOrigProfilesDictionary(dest, src) + dest := NewProfilesDictionary() + CopyProfilesDictionary(dest, src) assert.Equal(t, src, dest) - CopyOrigProfilesDictionary(dest, dest) + CopyProfilesDictionary(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigProfilesDictionaryUnknown(t *testing.T) { +func TestCopyProfilesDictionarySlice(t *testing.T) { + src := []ProfilesDictionary{} + dest := []ProfilesDictionary{} + // Test CopyTo empty + dest = CopyProfilesDictionarySlice(dest, src) + assert.Equal(t, []ProfilesDictionary{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilesDictionarySlice() + dest = CopyProfilesDictionarySlice(dest, src) + assert.Equal(t, GenTestProfilesDictionarySlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilesDictionarySlice(dest, src) + assert.Equal(t, GenTestProfilesDictionarySlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilesDictionarySlice(dest, []ProfilesDictionary{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilesDictionarySlice(dest, src) + assert.Equal(t, GenTestProfilesDictionarySlice(), dest) +} + +func TestCopyProfilesDictionaryPtrSlice(t *testing.T) { + src := []*ProfilesDictionary{} + dest := []*ProfilesDictionary{} + // Test CopyTo empty + dest = CopyProfilesDictionaryPtrSlice(dest, src) + assert.Equal(t, []*ProfilesDictionary{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilesDictionaryPtrSlice() + dest = CopyProfilesDictionaryPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesDictionaryPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilesDictionaryPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesDictionaryPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilesDictionaryPtrSlice(dest, []*ProfilesDictionary{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilesDictionaryPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesDictionaryPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONProfilesDictionaryUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigProfilesDictionary() - UnmarshalJSONOrigProfilesDictionary(dest, iter) + dest := NewProfilesDictionary() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigProfilesDictionary(), dest) + assert.Equal(t, NewProfilesDictionary(), dest) } -func TestMarshalAndUnmarshalJSONOrigProfilesDictionary(t *testing.T) { +func TestMarshalAndUnmarshalJSONProfilesDictionary(t *testing.T) { for name, src := range genTestEncodingValuesProfilesDictionary() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigProfilesDictionary(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigProfilesDictionary(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigProfilesDictionary() - UnmarshalJSONOrigProfilesDictionary(dest, iter) + dest := NewProfilesDictionary() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigProfilesDictionary(dest, true) + DeleteProfilesDictionary(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigProfilesDictionaryFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoProfilesDictionaryFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesProfilesDictionary() { t.Run(name, func(t *testing.T) { - dest := NewOrigProfilesDictionary() - require.Error(t, UnmarshalProtoOrigProfilesDictionary(dest, buf)) + dest := NewProfilesDictionary() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigProfilesDictionaryUnknown(t *testing.T) { - dest := NewOrigProfilesDictionary() +func TestMarshalAndUnmarshalProtoProfilesDictionaryUnknown(t *testing.T) { + dest := NewProfilesDictionary() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigProfilesDictionary(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigProfilesDictionary(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewProfilesDictionary(), dest) } -func TestMarshalAndUnmarshalProtoOrigProfilesDictionary(t *testing.T) { +func TestMarshalAndUnmarshalProtoProfilesDictionary(t *testing.T) { for name, src := range genTestEncodingValuesProfilesDictionary() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigProfilesDictionary(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigProfilesDictionary(src)) - gotSize := MarshalProtoOrigProfilesDictionary(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigProfilesDictionary() - require.NoError(t, UnmarshalProtoOrigProfilesDictionary(dest, buf)) + dest := NewProfilesDictionary() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigProfilesDictionary(dest, true) + DeleteProfilesDictionary(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigProfilesDictionary(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufProfilesDictionary(t *testing.T) { for name, src := range genTestEncodingValuesProfilesDictionary() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigProfilesDictionary(src)) - gotSize := MarshalProtoOrigProfilesDictionary(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.ProfilesDictionary{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufProfilesDictionary(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigProfilesDictionary() - require.NoError(t, UnmarshalProtoOrigProfilesDictionary(dest, goBuf)) + dest := NewProfilesDictionary() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -157,15 +206,15 @@ func genTestFailingUnmarshalProtoValuesProfilesDictionary() map[string][]byte { } } -func genTestEncodingValuesProfilesDictionary() map[string]*otlpprofiles.ProfilesDictionary { - return map[string]*otlpprofiles.ProfilesDictionary{ - "empty": NewOrigProfilesDictionary(), - "MappingTable/default_and_test": {MappingTable: []*otlpprofiles.Mapping{{}, GenTestOrigMapping()}}, - "LocationTable/default_and_test": {LocationTable: []*otlpprofiles.Location{{}, GenTestOrigLocation()}}, - "FunctionTable/default_and_test": {FunctionTable: []*otlpprofiles.Function{{}, GenTestOrigFunction()}}, - "LinkTable/default_and_test": {LinkTable: []*otlpprofiles.Link{{}, GenTestOrigLink()}}, - "StringTable/default_and_test": {StringTable: []string{"", "test_stringtable"}}, - "AttributeTable/default_and_test": {AttributeTable: []*otlpprofiles.KeyValueAndUnit{{}, GenTestOrigKeyValueAndUnit()}}, - "StackTable/default_and_test": {StackTable: []*otlpprofiles.Stack{{}, GenTestOrigStack()}}, +func genTestEncodingValuesProfilesDictionary() map[string]*ProfilesDictionary { + return map[string]*ProfilesDictionary{ + "empty": NewProfilesDictionary(), + "MappingTable/test": {MappingTable: []*Mapping{{}, GenTestMapping()}}, + "LocationTable/test": {LocationTable: []*Location{{}, GenTestLocation()}}, + "FunctionTable/test": {FunctionTable: []*Function{{}, GenTestFunction()}}, + "LinkTable/test": {LinkTable: []*Link{{}, GenTestLink()}}, + "StringTable/test": {StringTable: []string{"", "test_stringtable"}}, + "AttributeTable/test": {AttributeTable: []*KeyValueAndUnit{{}, GenTestKeyValueAndUnit()}}, + "StackTable/test": {StackTable: []*Stack{{}, GenTestStack()}}, } } diff --git a/pdata/internal/generated_proto_profilesrequest.go b/pdata/internal/generated_proto_profilesrequest.go new file mode 100644 index 00000000000..287b9ee4d5b --- /dev/null +++ b/pdata/internal/generated_proto_profilesrequest.go @@ -0,0 +1,300 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type ProfilesRequest struct { + RequestContext *RequestContext + ProfilesData ProfilesData + FormatVersion uint32 +} + +var ( + protoPoolProfilesRequest = sync.Pool{ + New: func() any { + return &ProfilesRequest{} + }, + } +) + +func NewProfilesRequest() *ProfilesRequest { + if !UseProtoPooling.IsEnabled() { + return &ProfilesRequest{} + } + return protoPoolProfilesRequest.Get().(*ProfilesRequest) +} + +func DeleteProfilesRequest(orig *ProfilesRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteRequestContext(orig.RequestContext, true) + DeleteProfilesData(&orig.ProfilesData, false) + + orig.Reset() + if nullable { + protoPoolProfilesRequest.Put(orig) + } +} + +func CopyProfilesRequest(dest, src *ProfilesRequest) *ProfilesRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewProfilesRequest() + } + dest.RequestContext = CopyRequestContext(dest.RequestContext, src.RequestContext) + + CopyProfilesData(&dest.ProfilesData, &src.ProfilesData) + + dest.FormatVersion = src.FormatVersion + + return dest +} + +func CopyProfilesRequestSlice(dest, src []ProfilesRequest) []ProfilesRequest { + var newDest []ProfilesRequest + if cap(dest) < len(src) { + newDest = make([]ProfilesRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfilesRequest(&dest[i], false) + } + } + for i := range src { + CopyProfilesRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyProfilesRequestPtrSlice(dest, src []*ProfilesRequest) []*ProfilesRequest { + var newDest []*ProfilesRequest + if cap(dest) < len(src) { + newDest = make([]*ProfilesRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfilesRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteProfilesRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewProfilesRequest() + } + } + for i := range src { + CopyProfilesRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *ProfilesRequest) Reset() { + *orig = ProfilesRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ProfilesRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RequestContext != nil { + dest.WriteObjectField("requestContext") + orig.RequestContext.MarshalJSON(dest) + } + dest.WriteObjectField("profilesData") + orig.ProfilesData.MarshalJSON(dest) + if orig.FormatVersion != uint32(0) { + dest.WriteObjectField("formatVersion") + dest.WriteUint32(orig.FormatVersion) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ProfilesRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "requestContext", "request_context": + orig.RequestContext = NewRequestContext() + orig.RequestContext.UnmarshalJSON(iter) + case "profilesData", "profiles_data": + + orig.ProfilesData.UnmarshalJSON(iter) + case "formatVersion", "format_version": + orig.FormatVersion = iter.ReadUint32() + default: + iter.Skip() + } + } +} + +func (orig *ProfilesRequest) SizeProto() int { + var n int + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + l = orig.ProfilesData.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + if orig.FormatVersion != 0 { + n += 5 + } + return n +} + +func (orig *ProfilesRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = orig.ProfilesData.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + + if orig.FormatVersion != 0 { + pos -= 4 + binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) + pos-- + buf[pos] = 0xd + } + return len(buf) - pos +} + +func (orig *ProfilesRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + orig.RequestContext = NewRequestContext() + err = orig.RequestContext.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ProfilesData", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.ProfilesData.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 1: + if wireType != proto.WireTypeI32 { + return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) + } + var num uint32 + num, pos, err = proto.ConsumeI32(buf, pos) + if err != nil { + return err + } + + orig.FormatVersion = uint32(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestProfilesRequest() *ProfilesRequest { + orig := NewProfilesRequest() + orig.RequestContext = GenTestRequestContext() + orig.ProfilesData = *GenTestProfilesData() + orig.FormatVersion = uint32(13) + return orig +} + +func GenTestProfilesRequestPtrSlice() []*ProfilesRequest { + orig := make([]*ProfilesRequest, 5) + orig[0] = NewProfilesRequest() + orig[1] = GenTestProfilesRequest() + orig[2] = NewProfilesRequest() + orig[3] = GenTestProfilesRequest() + orig[4] = NewProfilesRequest() + return orig +} + +func GenTestProfilesRequestSlice() []ProfilesRequest { + orig := make([]ProfilesRequest, 5) + orig[1] = *GenTestProfilesRequest() + orig[3] = *GenTestProfilesRequest() + return orig +} diff --git a/pdata/internal/generated_proto_profilesrequest_test.go b/pdata/internal/generated_proto_profilesrequest_test.go new file mode 100644 index 00000000000..719688643e5 --- /dev/null +++ b/pdata/internal/generated_proto_profilesrequest_test.go @@ -0,0 +1,208 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyProfilesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewProfilesRequest() + CopyProfilesRequest(dest, src) + assert.Equal(t, src, dest) + CopyProfilesRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyProfilesRequestSlice(t *testing.T) { + src := []ProfilesRequest{} + dest := []ProfilesRequest{} + // Test CopyTo empty + dest = CopyProfilesRequestSlice(dest, src) + assert.Equal(t, []ProfilesRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilesRequestSlice() + dest = CopyProfilesRequestSlice(dest, src) + assert.Equal(t, GenTestProfilesRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilesRequestSlice(dest, src) + assert.Equal(t, GenTestProfilesRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilesRequestSlice(dest, []ProfilesRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilesRequestSlice(dest, src) + assert.Equal(t, GenTestProfilesRequestSlice(), dest) +} + +func TestCopyProfilesRequestPtrSlice(t *testing.T) { + src := []*ProfilesRequest{} + dest := []*ProfilesRequest{} + // Test CopyTo empty + dest = CopyProfilesRequestPtrSlice(dest, src) + assert.Equal(t, []*ProfilesRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestProfilesRequestPtrSlice() + dest = CopyProfilesRequestPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyProfilesRequestPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyProfilesRequestPtrSlice(dest, []*ProfilesRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyProfilesRequestPtrSlice(dest, src) + assert.Equal(t, GenTestProfilesRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONProfilesRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewProfilesRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewProfilesRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONProfilesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewProfilesRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteProfilesRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoProfilesRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesProfilesRequest() { + t.Run(name, func(t *testing.T) { + dest := NewProfilesRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoProfilesRequestUnknown(t *testing.T) { + dest := NewProfilesRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewProfilesRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoProfilesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewProfilesRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteProfilesRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufProfilesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesProfilesRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewProfilesRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesProfilesRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "RequestContext/wrong_wire_type": {0x14}, + "RequestContext/missing_value": {0x12}, + "ProfilesData/wrong_wire_type": {0x1c}, + "ProfilesData/missing_value": {0x1a}, + "FormatVersion/wrong_wire_type": {0xc}, + "FormatVersion/missing_value": {0xd}, + } +} + +func genTestEncodingValuesProfilesRequest() map[string]*ProfilesRequest { + return map[string]*ProfilesRequest{ + "empty": NewProfilesRequest(), + "RequestContext/test": {RequestContext: GenTestRequestContext()}, + "ProfilesData/test": {ProfilesData: *GenTestProfilesData()}, + "FormatVersion/test": {FormatVersion: uint32(13)}, + } +} diff --git a/pdata/internal/generated_proto_requestcontext.go b/pdata/internal/generated_proto_requestcontext.go new file mode 100644 index 00000000000..4921ea97f09 --- /dev/null +++ b/pdata/internal/generated_proto_requestcontext.go @@ -0,0 +1,654 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +func (m *RequestContext) GetClientAddress() any { + if m != nil { + return m.ClientAddress + } + return nil +} + +type RequestContext_IP struct { + IP *IPAddr +} + +func (m *RequestContext) GetIP() *IPAddr { + if v, ok := m.GetClientAddress().(*RequestContext_IP); ok { + return v.IP + } + return nil +} + +type RequestContext_TCP struct { + TCP *TCPAddr +} + +func (m *RequestContext) GetTCP() *TCPAddr { + if v, ok := m.GetClientAddress().(*RequestContext_TCP); ok { + return v.TCP + } + return nil +} + +type RequestContext_UDP struct { + UDP *UDPAddr +} + +func (m *RequestContext) GetUDP() *UDPAddr { + if v, ok := m.GetClientAddress().(*RequestContext_UDP); ok { + return v.UDP + } + return nil +} + +type RequestContext_Unix struct { + Unix *UnixAddr +} + +func (m *RequestContext) GetUnix() *UnixAddr { + if v, ok := m.GetClientAddress().(*RequestContext_Unix); ok { + return v.Unix + } + return nil +} + +type RequestContext struct { + SpanContext *SpanContext + ClientMetadata []KeyValue + ClientAddress any +} + +var ( + protoPoolRequestContext = sync.Pool{ + New: func() any { + return &RequestContext{} + }, + } + + ProtoPoolRequestContext_IP = sync.Pool{ + New: func() any { + return &RequestContext_IP{} + }, + } + + ProtoPoolRequestContext_TCP = sync.Pool{ + New: func() any { + return &RequestContext_TCP{} + }, + } + + ProtoPoolRequestContext_UDP = sync.Pool{ + New: func() any { + return &RequestContext_UDP{} + }, + } + + ProtoPoolRequestContext_Unix = sync.Pool{ + New: func() any { + return &RequestContext_Unix{} + }, + } +) + +func NewRequestContext() *RequestContext { + if !UseProtoPooling.IsEnabled() { + return &RequestContext{} + } + return protoPoolRequestContext.Get().(*RequestContext) +} + +func DeleteRequestContext(orig *RequestContext, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteSpanContext(orig.SpanContext, true) + for i := range orig.ClientMetadata { + DeleteKeyValue(&orig.ClientMetadata[i], false) + } + switch ov := orig.ClientAddress.(type) { + case *RequestContext_IP: + DeleteIPAddr(ov.IP, true) + ov.IP = nil + ProtoPoolRequestContext_IP.Put(ov) + case *RequestContext_TCP: + DeleteTCPAddr(ov.TCP, true) + ov.TCP = nil + ProtoPoolRequestContext_TCP.Put(ov) + case *RequestContext_UDP: + DeleteUDPAddr(ov.UDP, true) + ov.UDP = nil + ProtoPoolRequestContext_UDP.Put(ov) + case *RequestContext_Unix: + DeleteUnixAddr(ov.Unix, true) + ov.Unix = nil + ProtoPoolRequestContext_Unix.Put(ov) + + } + + orig.Reset() + if nullable { + protoPoolRequestContext.Put(orig) + } +} + +func CopyRequestContext(dest, src *RequestContext) *RequestContext { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewRequestContext() + } + dest.SpanContext = CopySpanContext(dest.SpanContext, src.SpanContext) + + dest.ClientMetadata = CopyKeyValueSlice(dest.ClientMetadata, src.ClientMetadata) + + switch t := src.ClientAddress.(type) { + case *RequestContext_IP: + var ov *RequestContext_IP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_IP{} + } else { + ov = ProtoPoolRequestContext_IP.Get().(*RequestContext_IP) + } + ov.IP = NewIPAddr() + CopyIPAddr(ov.IP, t.IP) + dest.ClientAddress = ov + + case *RequestContext_TCP: + var ov *RequestContext_TCP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_TCP{} + } else { + ov = ProtoPoolRequestContext_TCP.Get().(*RequestContext_TCP) + } + ov.TCP = NewTCPAddr() + CopyTCPAddr(ov.TCP, t.TCP) + dest.ClientAddress = ov + + case *RequestContext_UDP: + var ov *RequestContext_UDP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_UDP{} + } else { + ov = ProtoPoolRequestContext_UDP.Get().(*RequestContext_UDP) + } + ov.UDP = NewUDPAddr() + CopyUDPAddr(ov.UDP, t.UDP) + dest.ClientAddress = ov + + case *RequestContext_Unix: + var ov *RequestContext_Unix + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_Unix{} + } else { + ov = ProtoPoolRequestContext_Unix.Get().(*RequestContext_Unix) + } + ov.Unix = NewUnixAddr() + CopyUnixAddr(ov.Unix, t.Unix) + dest.ClientAddress = ov + + default: + dest.ClientAddress = nil + } + + return dest +} + +func CopyRequestContextSlice(dest, src []RequestContext) []RequestContext { + var newDest []RequestContext + if cap(dest) < len(src) { + newDest = make([]RequestContext, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteRequestContext(&dest[i], false) + } + } + for i := range src { + CopyRequestContext(&newDest[i], &src[i]) + } + return newDest +} + +func CopyRequestContextPtrSlice(dest, src []*RequestContext) []*RequestContext { + var newDest []*RequestContext + if cap(dest) < len(src) { + newDest = make([]*RequestContext, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewRequestContext() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteRequestContext(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewRequestContext() + } + } + for i := range src { + CopyRequestContext(newDest[i], src[i]) + } + return newDest +} + +func (orig *RequestContext) Reset() { + *orig = RequestContext{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *RequestContext) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.SpanContext != nil { + dest.WriteObjectField("spanContext") + orig.SpanContext.MarshalJSON(dest) + } + if len(orig.ClientMetadata) > 0 { + dest.WriteObjectField("clientMetadata") + dest.WriteArrayStart() + orig.ClientMetadata[0].MarshalJSON(dest) + for i := 1; i < len(orig.ClientMetadata); i++ { + dest.WriteMore() + orig.ClientMetadata[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + switch orig := orig.ClientAddress.(type) { + case *RequestContext_IP: + if orig.IP != nil { + dest.WriteObjectField("iP") + orig.IP.MarshalJSON(dest) + } + case *RequestContext_TCP: + if orig.TCP != nil { + dest.WriteObjectField("tCP") + orig.TCP.MarshalJSON(dest) + } + case *RequestContext_UDP: + if orig.UDP != nil { + dest.WriteObjectField("uDP") + orig.UDP.MarshalJSON(dest) + } + case *RequestContext_Unix: + if orig.Unix != nil { + dest.WriteObjectField("unix") + orig.Unix.MarshalJSON(dest) + } + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *RequestContext) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "spanContext", "span_context": + orig.SpanContext = NewSpanContext() + orig.SpanContext.UnmarshalJSON(iter) + case "clientMetadata", "client_metadata": + for iter.ReadArray() { + orig.ClientMetadata = append(orig.ClientMetadata, KeyValue{}) + orig.ClientMetadata[len(orig.ClientMetadata)-1].UnmarshalJSON(iter) + } + + case "iP": + { + var ov *RequestContext_IP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_IP{} + } else { + ov = ProtoPoolRequestContext_IP.Get().(*RequestContext_IP) + } + ov.IP = NewIPAddr() + ov.IP.UnmarshalJSON(iter) + orig.ClientAddress = ov + } + + case "tCP": + { + var ov *RequestContext_TCP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_TCP{} + } else { + ov = ProtoPoolRequestContext_TCP.Get().(*RequestContext_TCP) + } + ov.TCP = NewTCPAddr() + ov.TCP.UnmarshalJSON(iter) + orig.ClientAddress = ov + } + + case "uDP": + { + var ov *RequestContext_UDP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_UDP{} + } else { + ov = ProtoPoolRequestContext_UDP.Get().(*RequestContext_UDP) + } + ov.UDP = NewUDPAddr() + ov.UDP.UnmarshalJSON(iter) + orig.ClientAddress = ov + } + + case "unix": + { + var ov *RequestContext_Unix + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_Unix{} + } else { + ov = ProtoPoolRequestContext_Unix.Get().(*RequestContext_Unix) + } + ov.Unix = NewUnixAddr() + ov.Unix.UnmarshalJSON(iter) + orig.ClientAddress = ov + } + + default: + iter.Skip() + } + } +} + +func (orig *RequestContext) SizeProto() int { + var n int + var l int + _ = l + if orig.SpanContext != nil { + l = orig.SpanContext.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + for i := range orig.ClientMetadata { + l = orig.ClientMetadata[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + switch orig := orig.ClientAddress.(type) { + case nil: + _ = orig + break + case *RequestContext_IP: + if orig.IP != nil { + l = orig.IP.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *RequestContext_TCP: + if orig.TCP != nil { + l = orig.TCP.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *RequestContext_UDP: + if orig.UDP != nil { + l = orig.UDP.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + case *RequestContext_Unix: + if orig.Unix != nil { + l = orig.Unix.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + } + return n +} + +func (orig *RequestContext) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.SpanContext != nil { + l = orig.SpanContext.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + for i := len(orig.ClientMetadata) - 1; i >= 0; i-- { + l = orig.ClientMetadata[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + switch orig := orig.ClientAddress.(type) { + case *RequestContext_IP: + if orig.IP != nil { + l = orig.IP.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + case *RequestContext_TCP: + if orig.TCP != nil { + l = orig.TCP.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x22 + } + case *RequestContext_UDP: + if orig.UDP != nil { + l = orig.UDP.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x2a + } + case *RequestContext_Unix: + if orig.Unix != nil { + l = orig.Unix.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x32 + } + } + return len(buf) - pos +} + +func (orig *RequestContext) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SpanContext", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + orig.SpanContext = NewSpanContext() + err = orig.SpanContext.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ClientMetadata", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ClientMetadata = append(orig.ClientMetadata, KeyValue{}) + err = orig.ClientMetadata[len(orig.ClientMetadata)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *RequestContext_IP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_IP{} + } else { + ov = ProtoPoolRequestContext_IP.Get().(*RequestContext_IP) + } + ov.IP = NewIPAddr() + err = ov.IP.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.ClientAddress = ov + + case 4: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field TCP", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *RequestContext_TCP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_TCP{} + } else { + ov = ProtoPoolRequestContext_TCP.Get().(*RequestContext_TCP) + } + ov.TCP = NewTCPAddr() + err = ov.TCP.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.ClientAddress = ov + + case 5: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field UDP", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *RequestContext_UDP + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_UDP{} + } else { + ov = ProtoPoolRequestContext_UDP.Get().(*RequestContext_UDP) + } + ov.UDP = NewUDPAddr() + err = ov.UDP.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.ClientAddress = ov + + case 6: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Unix", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + var ov *RequestContext_Unix + if !UseProtoPooling.IsEnabled() { + ov = &RequestContext_Unix{} + } else { + ov = ProtoPoolRequestContext_Unix.Get().(*RequestContext_Unix) + } + ov.Unix = NewUnixAddr() + err = ov.Unix.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + orig.ClientAddress = ov + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestRequestContext() *RequestContext { + orig := NewRequestContext() + orig.SpanContext = GenTestSpanContext() + orig.ClientMetadata = []KeyValue{{}, *GenTestKeyValue()} + orig.ClientAddress = &RequestContext_IP{IP: GenTestIPAddr()} + return orig +} + +func GenTestRequestContextPtrSlice() []*RequestContext { + orig := make([]*RequestContext, 5) + orig[0] = NewRequestContext() + orig[1] = GenTestRequestContext() + orig[2] = NewRequestContext() + orig[3] = GenTestRequestContext() + orig[4] = NewRequestContext() + return orig +} + +func GenTestRequestContextSlice() []RequestContext { + orig := make([]RequestContext, 5) + orig[1] = *GenTestRequestContext() + orig[3] = *GenTestRequestContext() + return orig +} diff --git a/pdata/internal/generated_proto_requestcontext_test.go b/pdata/internal/generated_proto_requestcontext_test.go new file mode 100644 index 00000000000..dd85497a1a3 --- /dev/null +++ b/pdata/internal/generated_proto_requestcontext_test.go @@ -0,0 +1,225 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyRequestContext(t *testing.T) { + for name, src := range genTestEncodingValuesRequestContext() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewRequestContext() + CopyRequestContext(dest, src) + assert.Equal(t, src, dest) + CopyRequestContext(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyRequestContextSlice(t *testing.T) { + src := []RequestContext{} + dest := []RequestContext{} + // Test CopyTo empty + dest = CopyRequestContextSlice(dest, src) + assert.Equal(t, []RequestContext{}, dest) + + // Test CopyTo larger slice + src = GenTestRequestContextSlice() + dest = CopyRequestContextSlice(dest, src) + assert.Equal(t, GenTestRequestContextSlice(), dest) + + // Test CopyTo same size slice + dest = CopyRequestContextSlice(dest, src) + assert.Equal(t, GenTestRequestContextSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyRequestContextSlice(dest, []RequestContext{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyRequestContextSlice(dest, src) + assert.Equal(t, GenTestRequestContextSlice(), dest) +} + +func TestCopyRequestContextPtrSlice(t *testing.T) { + src := []*RequestContext{} + dest := []*RequestContext{} + // Test CopyTo empty + dest = CopyRequestContextPtrSlice(dest, src) + assert.Equal(t, []*RequestContext{}, dest) + + // Test CopyTo larger slice + src = GenTestRequestContextPtrSlice() + dest = CopyRequestContextPtrSlice(dest, src) + assert.Equal(t, GenTestRequestContextPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyRequestContextPtrSlice(dest, src) + assert.Equal(t, GenTestRequestContextPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyRequestContextPtrSlice(dest, []*RequestContext{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyRequestContextPtrSlice(dest, src) + assert.Equal(t, GenTestRequestContextPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONRequestContextUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewRequestContext() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewRequestContext(), dest) +} + +func TestMarshalAndUnmarshalJSONRequestContext(t *testing.T) { + for name, src := range genTestEncodingValuesRequestContext() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewRequestContext() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteRequestContext(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoRequestContextFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesRequestContext() { + t.Run(name, func(t *testing.T) { + dest := NewRequestContext() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoRequestContextUnknown(t *testing.T) { + dest := NewRequestContext() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewRequestContext(), dest) +} + +func TestMarshalAndUnmarshalProtoRequestContext(t *testing.T) { + for name, src := range genTestEncodingValuesRequestContext() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewRequestContext() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteRequestContext(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufRequestContext(t *testing.T) { + for name, src := range genTestEncodingValuesRequestContext() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewRequestContext() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesRequestContext() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "SpanContext/wrong_wire_type": {0xc}, + "SpanContext/missing_value": {0xa}, + "ClientMetadata/wrong_wire_type": {0x14}, + "ClientMetadata/missing_value": {0x12}, + + "IP/wrong_wire_type": {0x1c}, + "IP/missing_value": {0x1a}, + + "TCP/wrong_wire_type": {0x24}, + "TCP/missing_value": {0x22}, + + "UDP/wrong_wire_type": {0x2c}, + "UDP/missing_value": {0x2a}, + + "Unix/wrong_wire_type": {0x34}, + "Unix/missing_value": {0x32}, + } +} + +func genTestEncodingValuesRequestContext() map[string]*RequestContext { + return map[string]*RequestContext{ + "empty": NewRequestContext(), + "SpanContext/test": {SpanContext: GenTestSpanContext()}, + "ClientMetadata/test": {ClientMetadata: []KeyValue{{}, *GenTestKeyValue()}}, + "IP/default": {ClientAddress: &RequestContext_IP{IP: &IPAddr{}}}, + "IP/test": {ClientAddress: &RequestContext_IP{IP: GenTestIPAddr()}}, + "TCP/default": {ClientAddress: &RequestContext_TCP{TCP: &TCPAddr{}}}, + "TCP/test": {ClientAddress: &RequestContext_TCP{TCP: GenTestTCPAddr()}}, + "UDP/default": {ClientAddress: &RequestContext_UDP{UDP: &UDPAddr{}}}, + "UDP/test": {ClientAddress: &RequestContext_UDP{UDP: GenTestUDPAddr()}}, + "Unix/default": {ClientAddress: &RequestContext_Unix{Unix: &UnixAddr{}}}, + "Unix/test": {ClientAddress: &RequestContext_Unix{Unix: GenTestUnixAddr()}}, + } +} diff --git a/pdata/internal/generated_proto_resource.go b/pdata/internal/generated_proto_resource.go new file mode 100644 index 00000000000..7bef0ffcb96 --- /dev/null +++ b/pdata/internal/generated_proto_resource.go @@ -0,0 +1,325 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Resource is a message representing the resource information. +type Resource struct { + Attributes []KeyValue + DroppedAttributesCount uint32 + EntityRefs []*EntityRef +} + +var ( + protoPoolResource = sync.Pool{ + New: func() any { + return &Resource{} + }, + } +) + +func NewResource() *Resource { + if !UseProtoPooling.IsEnabled() { + return &Resource{} + } + return protoPoolResource.Get().(*Resource) +} + +func DeleteResource(orig *Resource, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + 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) + } +} + +func CopyResource(dest, src *Resource) *Resource { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewResource() + } + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + + dest.DroppedAttributesCount = src.DroppedAttributesCount + + dest.EntityRefs = CopyEntityRefPtrSlice(dest.EntityRefs, src.EntityRefs) + + return dest +} + +func CopyResourceSlice(dest, src []Resource) []Resource { + var newDest []Resource + if cap(dest) < len(src) { + newDest = make([]Resource, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResource(&dest[i], false) + } + } + for i := range src { + CopyResource(&newDest[i], &src[i]) + } + return newDest +} + +func CopyResourcePtrSlice(dest, src []*Resource) []*Resource { + var newDest []*Resource + if cap(dest) < len(src) { + newDest = make([]*Resource, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResource() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResource(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResource() + } + } + for i := range src { + CopyResource(newDest[i], src[i]) + } + return newDest +} + +func (orig *Resource) Reset() { + *orig = Resource{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Resource) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.Attributes) > 0 { + dest.WriteObjectField("attributes") + dest.WriteArrayStart() + orig.Attributes[0].MarshalJSON(dest) + for i := 1; i < len(orig.Attributes); i++ { + dest.WriteMore() + orig.Attributes[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.DroppedAttributesCount != uint32(0) { + dest.WriteObjectField("droppedAttributesCount") + dest.WriteUint32(orig.DroppedAttributesCount) + } + if len(orig.EntityRefs) > 0 { + dest.WriteObjectField("entityRefs") + dest.WriteArrayStart() + orig.EntityRefs[0].MarshalJSON(dest) + for i := 1; i < len(orig.EntityRefs); i++ { + dest.WriteMore() + orig.EntityRefs[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Resource) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "attributes": + for iter.ReadArray() { + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) + } + + case "droppedAttributesCount", "dropped_attributes_count": + orig.DroppedAttributesCount = iter.ReadUint32() + case "entityRefs", "entity_refs": + for iter.ReadArray() { + orig.EntityRefs = append(orig.EntityRefs, NewEntityRef()) + orig.EntityRefs[len(orig.EntityRefs)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *Resource) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.Attributes { + l = orig.Attributes[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + if orig.DroppedAttributesCount != 0 { + n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) + } + for i := range orig.EntityRefs { + l = orig.EntityRefs[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *Resource) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.Attributes) - 1; i >= 0; i-- { + l = orig.Attributes[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + if orig.DroppedAttributesCount != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) + pos-- + buf[pos] = 0x10 + } + for i := len(orig.EntityRefs) - 1; i >= 0; i-- { + l = orig.EntityRefs[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *Resource) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.DroppedAttributesCount = uint32(num) + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field EntityRefs", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.EntityRefs = append(orig.EntityRefs, NewEntityRef()) + err = orig.EntityRefs[len(orig.EntityRefs)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestResource() *Resource { + orig := NewResource() + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.DroppedAttributesCount = uint32(13) + orig.EntityRefs = []*EntityRef{{}, GenTestEntityRef()} + return orig +} + +func GenTestResourcePtrSlice() []*Resource { + orig := make([]*Resource, 5) + orig[0] = NewResource() + orig[1] = GenTestResource() + orig[2] = NewResource() + orig[3] = GenTestResource() + orig[4] = NewResource() + return orig +} + +func GenTestResourceSlice() []Resource { + orig := make([]Resource, 5) + orig[1] = *GenTestResource() + orig[3] = *GenTestResource() + return orig +} diff --git a/pdata/internal/generated_wrapper_resource_test.go b/pdata/internal/generated_proto_resource_test.go similarity index 55% rename from pdata/internal/generated_wrapper_resource_test.go rename to pdata/internal/generated_proto_resource_test.go index f1979f65a33..d88729c6da1 100644 --- a/pdata/internal/generated_wrapper_resource_test.go +++ b/pdata/internal/generated_proto_resource_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigResource(t *testing.T) { +func TestCopyResource(t *testing.T) { for name, src := range genTestEncodingValuesResource() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigResource(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigResource() - CopyOrigResource(dest, src) + dest := NewResource() + CopyResource(dest, src) assert.Equal(t, src, dest) - CopyOrigResource(dest, dest) + CopyResource(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigResourceUnknown(t *testing.T) { +func TestCopyResourceSlice(t *testing.T) { + src := []Resource{} + dest := []Resource{} + // Test CopyTo empty + dest = CopyResourceSlice(dest, src) + assert.Equal(t, []Resource{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceSlice() + dest = CopyResourceSlice(dest, src) + assert.Equal(t, GenTestResourceSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceSlice(dest, src) + assert.Equal(t, GenTestResourceSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceSlice(dest, []Resource{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceSlice(dest, src) + assert.Equal(t, GenTestResourceSlice(), dest) +} + +func TestCopyResourcePtrSlice(t *testing.T) { + src := []*Resource{} + dest := []*Resource{} + // Test CopyTo empty + dest = CopyResourcePtrSlice(dest, src) + assert.Equal(t, []*Resource{}, dest) + + // Test CopyTo larger slice + src = GenTestResourcePtrSlice() + dest = CopyResourcePtrSlice(dest, src) + assert.Equal(t, GenTestResourcePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourcePtrSlice(dest, src) + assert.Equal(t, GenTestResourcePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourcePtrSlice(dest, []*Resource{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourcePtrSlice(dest, src) + assert.Equal(t, GenTestResourcePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigResource() - UnmarshalJSONOrigResource(dest, iter) + dest := NewResource() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigResource(), dest) + assert.Equal(t, NewResource(), dest) } -func TestMarshalAndUnmarshalJSONOrigResource(t *testing.T) { +func TestMarshalAndUnmarshalJSONResource(t *testing.T) { for name, src := range genTestEncodingValuesResource() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigResource(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigResource(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigResource() - UnmarshalJSONOrigResource(dest, iter) + dest := NewResource() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigResource(dest, true) + DeleteResource(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigResourceFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoResourceFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesResource() { t.Run(name, func(t *testing.T) { - dest := NewOrigResource() - require.Error(t, UnmarshalProtoOrigResource(dest, buf)) + dest := NewResource() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigResourceUnknown(t *testing.T) { - dest := NewOrigResource() +func TestMarshalAndUnmarshalProtoResourceUnknown(t *testing.T) { + dest := NewResource() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigResource(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigResource(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewResource(), dest) } -func TestMarshalAndUnmarshalProtoOrigResource(t *testing.T) { +func TestMarshalAndUnmarshalProtoResource(t *testing.T) { for name, src := range genTestEncodingValuesResource() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigResource(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigResource(src)) - gotSize := MarshalProtoOrigResource(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigResource() - require.NoError(t, UnmarshalProtoOrigResource(dest, buf)) + dest := NewResource() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigResource(dest, true) + DeleteResource(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigResource(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufResource(t *testing.T) { for name, src := range genTestEncodingValuesResource() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigResource(src)) - gotSize := MarshalProtoOrigResource(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpresource.Resource{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufResource(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigResource() - require.NoError(t, UnmarshalProtoOrigResource(dest, goBuf)) + dest := NewResource() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -150,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesResource() map[string][]byte { } } -func genTestEncodingValuesResource() map[string]*otlpresource.Resource { - return map[string]*otlpresource.Resource{ - "empty": NewOrigResource(), - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, +func genTestEncodingValuesResource() map[string]*Resource { + return map[string]*Resource{ + "empty": NewResource(), + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, - "EntityRefs/default_and_test": {EntityRefs: []*otlpcommon.EntityRef{{}, GenTestOrigEntityRef()}}, + "EntityRefs/test": {EntityRefs: []*EntityRef{{}, GenTestEntityRef()}}, } } diff --git a/pdata/internal/generated_proto_resourcelogs.go b/pdata/internal/generated_proto_resourcelogs.go new file mode 100644 index 00000000000..57c32e3c17b --- /dev/null +++ b/pdata/internal/generated_proto_resourcelogs.go @@ -0,0 +1,365 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ResourceLogs is a collection of logs from a Resource. +type ResourceLogs struct { + Resource Resource + ScopeLogs []*ScopeLogs + SchemaUrl string + DeprecatedScopeLogs []*ScopeLogs +} + +var ( + protoPoolResourceLogs = sync.Pool{ + New: func() any { + return &ResourceLogs{} + }, + } +) + +func NewResourceLogs() *ResourceLogs { + if !UseProtoPooling.IsEnabled() { + return &ResourceLogs{} + } + return protoPoolResourceLogs.Get().(*ResourceLogs) +} + +func DeleteResourceLogs(orig *ResourceLogs, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + 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) + } +} + +func CopyResourceLogs(dest, src *ResourceLogs) *ResourceLogs { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewResourceLogs() + } + CopyResource(&dest.Resource, &src.Resource) + + dest.ScopeLogs = CopyScopeLogsPtrSlice(dest.ScopeLogs, src.ScopeLogs) + + dest.SchemaUrl = src.SchemaUrl + + dest.DeprecatedScopeLogs = CopyScopeLogsPtrSlice(dest.DeprecatedScopeLogs, src.DeprecatedScopeLogs) + + return dest +} + +func CopyResourceLogsSlice(dest, src []ResourceLogs) []ResourceLogs { + var newDest []ResourceLogs + if cap(dest) < len(src) { + newDest = make([]ResourceLogs, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceLogs(&dest[i], false) + } + } + for i := range src { + CopyResourceLogs(&newDest[i], &src[i]) + } + return newDest +} + +func CopyResourceLogsPtrSlice(dest, src []*ResourceLogs) []*ResourceLogs { + var newDest []*ResourceLogs + if cap(dest) < len(src) { + newDest = make([]*ResourceLogs, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceLogs() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceLogs(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceLogs() + } + } + for i := range src { + CopyResourceLogs(newDest[i], src[i]) + } + return newDest +} + +func (orig *ResourceLogs) Reset() { + *orig = ResourceLogs{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ResourceLogs) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("resource") + orig.Resource.MarshalJSON(dest) + if len(orig.ScopeLogs) > 0 { + dest.WriteObjectField("scopeLogs") + dest.WriteArrayStart() + orig.ScopeLogs[0].MarshalJSON(dest) + for i := 1; i < len(orig.ScopeLogs); i++ { + dest.WriteMore() + orig.ScopeLogs[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + if len(orig.DeprecatedScopeLogs) > 0 { + dest.WriteObjectField("deprecatedScopeLogs") + dest.WriteArrayStart() + orig.DeprecatedScopeLogs[0].MarshalJSON(dest) + for i := 1; i < len(orig.DeprecatedScopeLogs); i++ { + dest.WriteMore() + orig.DeprecatedScopeLogs[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ResourceLogs) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resource": + + orig.Resource.UnmarshalJSON(iter) + case "scopeLogs", "scope_logs": + for iter.ReadArray() { + orig.ScopeLogs = append(orig.ScopeLogs, NewScopeLogs()) + orig.ScopeLogs[len(orig.ScopeLogs)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + case "deprecatedScopeLogs", "deprecated_scope_logs": + for iter.ReadArray() { + orig.DeprecatedScopeLogs = append(orig.DeprecatedScopeLogs, NewScopeLogs()) + orig.DeprecatedScopeLogs[len(orig.DeprecatedScopeLogs)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ResourceLogs) SizeProto() int { + var n int + var l int + _ = l + l = orig.Resource.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.ScopeLogs { + 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 + } + for i := range orig.DeprecatedScopeLogs { + l = orig.DeprecatedScopeLogs[i].SizeProto() + n += 2 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ResourceLogs) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Resource.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.ScopeLogs) - 1; i >= 0; i-- { + l = orig.ScopeLogs[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + for i := len(orig.DeprecatedScopeLogs) - 1; i >= 0; i-- { + l = orig.DeprecatedScopeLogs[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x3e + pos-- + buf[pos] = 0xc2 + } + return len(buf) - pos +} + +func (orig *ResourceLogs) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Resource.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ScopeLogs", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ScopeLogs = append(orig.ScopeLogs, NewScopeLogs()) + err = orig.ScopeLogs[len(orig.ScopeLogs)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + + case 1000: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedScopeLogs", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DeprecatedScopeLogs = append(orig.DeprecatedScopeLogs, NewScopeLogs()) + err = orig.DeprecatedScopeLogs[len(orig.DeprecatedScopeLogs)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestResourceLogs() *ResourceLogs { + orig := NewResourceLogs() + orig.Resource = *GenTestResource() + orig.ScopeLogs = []*ScopeLogs{{}, GenTestScopeLogs()} + orig.SchemaUrl = "test_schemaurl" + orig.DeprecatedScopeLogs = []*ScopeLogs{{}, GenTestScopeLogs()} + return orig +} + +func GenTestResourceLogsPtrSlice() []*ResourceLogs { + orig := make([]*ResourceLogs, 5) + orig[0] = NewResourceLogs() + orig[1] = GenTestResourceLogs() + orig[2] = NewResourceLogs() + orig[3] = GenTestResourceLogs() + orig[4] = NewResourceLogs() + return orig +} + +func GenTestResourceLogsSlice() []ResourceLogs { + orig := make([]ResourceLogs, 5) + orig[1] = *GenTestResourceLogs() + orig[3] = *GenTestResourceLogs() + return orig +} diff --git a/pdata/internal/generated_proto_resourcelogs_test.go b/pdata/internal/generated_proto_resourcelogs_test.go new file mode 100644 index 00000000000..e0ebd849bf1 --- /dev/null +++ b/pdata/internal/generated_proto_resourcelogs_test.go @@ -0,0 +1,211 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlplogs "go.opentelemetry.io/proto/slim/otlp/logs/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyResourceLogs(t *testing.T) { + for name, src := range genTestEncodingValuesResourceLogs() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewResourceLogs() + CopyResourceLogs(dest, src) + assert.Equal(t, src, dest) + CopyResourceLogs(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyResourceLogsSlice(t *testing.T) { + src := []ResourceLogs{} + dest := []ResourceLogs{} + // Test CopyTo empty + dest = CopyResourceLogsSlice(dest, src) + assert.Equal(t, []ResourceLogs{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceLogsSlice() + dest = CopyResourceLogsSlice(dest, src) + assert.Equal(t, GenTestResourceLogsSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceLogsSlice(dest, src) + assert.Equal(t, GenTestResourceLogsSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceLogsSlice(dest, []ResourceLogs{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceLogsSlice(dest, src) + assert.Equal(t, GenTestResourceLogsSlice(), dest) +} + +func TestCopyResourceLogsPtrSlice(t *testing.T) { + src := []*ResourceLogs{} + dest := []*ResourceLogs{} + // Test CopyTo empty + dest = CopyResourceLogsPtrSlice(dest, src) + assert.Equal(t, []*ResourceLogs{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceLogsPtrSlice() + dest = CopyResourceLogsPtrSlice(dest, src) + assert.Equal(t, GenTestResourceLogsPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceLogsPtrSlice(dest, src) + assert.Equal(t, GenTestResourceLogsPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceLogsPtrSlice(dest, []*ResourceLogs{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceLogsPtrSlice(dest, src) + assert.Equal(t, GenTestResourceLogsPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceLogsUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewResourceLogs() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewResourceLogs(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceLogs(t *testing.T) { + for name, src := range genTestEncodingValuesResourceLogs() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewResourceLogs() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteResourceLogs(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoResourceLogsFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesResourceLogs() { + t.Run(name, func(t *testing.T) { + dest := NewResourceLogs() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoResourceLogsUnknown(t *testing.T) { + dest := NewResourceLogs() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewResourceLogs(), dest) +} + +func TestMarshalAndUnmarshalProtoResourceLogs(t *testing.T) { + for name, src := range genTestEncodingValuesResourceLogs() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewResourceLogs() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteResourceLogs(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufResourceLogs(t *testing.T) { + for name, src := range genTestEncodingValuesResourceLogs() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlplogs.ResourceLogs{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewResourceLogs() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesResourceLogs() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Resource/wrong_wire_type": {0xc}, + "Resource/missing_value": {0xa}, + "ScopeLogs/wrong_wire_type": {0x14}, + "ScopeLogs/missing_value": {0x12}, + "SchemaUrl/wrong_wire_type": {0x1c}, + "SchemaUrl/missing_value": {0x1a}, + "DeprecatedScopeLogs/wrong_wire_type": {0xc4, 0x3e}, + "DeprecatedScopeLogs/missing_value": {0xc2, 0x3e}, + } +} + +func genTestEncodingValuesResourceLogs() map[string]*ResourceLogs { + return map[string]*ResourceLogs{ + "empty": NewResourceLogs(), + "Resource/test": {Resource: *GenTestResource()}, + "ScopeLogs/test": {ScopeLogs: []*ScopeLogs{{}, GenTestScopeLogs()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, + "DeprecatedScopeLogs/test": {DeprecatedScopeLogs: []*ScopeLogs{{}, GenTestScopeLogs()}}, + } +} diff --git a/pdata/internal/generated_proto_resourcemetrics.go b/pdata/internal/generated_proto_resourcemetrics.go new file mode 100644 index 00000000000..a260fe62e4d --- /dev/null +++ b/pdata/internal/generated_proto_resourcemetrics.go @@ -0,0 +1,365 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ResourceMetrics is a collection of metrics from a Resource. +type ResourceMetrics struct { + Resource Resource + ScopeMetrics []*ScopeMetrics + SchemaUrl string + DeprecatedScopeMetrics []*ScopeMetrics +} + +var ( + protoPoolResourceMetrics = sync.Pool{ + New: func() any { + return &ResourceMetrics{} + }, + } +) + +func NewResourceMetrics() *ResourceMetrics { + if !UseProtoPooling.IsEnabled() { + return &ResourceMetrics{} + } + return protoPoolResourceMetrics.Get().(*ResourceMetrics) +} + +func DeleteResourceMetrics(orig *ResourceMetrics, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + 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) + } +} + +func CopyResourceMetrics(dest, src *ResourceMetrics) *ResourceMetrics { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewResourceMetrics() + } + CopyResource(&dest.Resource, &src.Resource) + + dest.ScopeMetrics = CopyScopeMetricsPtrSlice(dest.ScopeMetrics, src.ScopeMetrics) + + dest.SchemaUrl = src.SchemaUrl + + dest.DeprecatedScopeMetrics = CopyScopeMetricsPtrSlice(dest.DeprecatedScopeMetrics, src.DeprecatedScopeMetrics) + + return dest +} + +func CopyResourceMetricsSlice(dest, src []ResourceMetrics) []ResourceMetrics { + var newDest []ResourceMetrics + if cap(dest) < len(src) { + newDest = make([]ResourceMetrics, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceMetrics(&dest[i], false) + } + } + for i := range src { + CopyResourceMetrics(&newDest[i], &src[i]) + } + return newDest +} + +func CopyResourceMetricsPtrSlice(dest, src []*ResourceMetrics) []*ResourceMetrics { + var newDest []*ResourceMetrics + if cap(dest) < len(src) { + newDest = make([]*ResourceMetrics, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceMetrics() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceMetrics(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceMetrics() + } + } + for i := range src { + CopyResourceMetrics(newDest[i], src[i]) + } + return newDest +} + +func (orig *ResourceMetrics) Reset() { + *orig = ResourceMetrics{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ResourceMetrics) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("resource") + orig.Resource.MarshalJSON(dest) + if len(orig.ScopeMetrics) > 0 { + dest.WriteObjectField("scopeMetrics") + dest.WriteArrayStart() + orig.ScopeMetrics[0].MarshalJSON(dest) + for i := 1; i < len(orig.ScopeMetrics); i++ { + dest.WriteMore() + orig.ScopeMetrics[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + if len(orig.DeprecatedScopeMetrics) > 0 { + dest.WriteObjectField("deprecatedScopeMetrics") + dest.WriteArrayStart() + orig.DeprecatedScopeMetrics[0].MarshalJSON(dest) + for i := 1; i < len(orig.DeprecatedScopeMetrics); i++ { + dest.WriteMore() + orig.DeprecatedScopeMetrics[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ResourceMetrics) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resource": + + orig.Resource.UnmarshalJSON(iter) + case "scopeMetrics", "scope_metrics": + for iter.ReadArray() { + orig.ScopeMetrics = append(orig.ScopeMetrics, NewScopeMetrics()) + orig.ScopeMetrics[len(orig.ScopeMetrics)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + case "deprecatedScopeMetrics", "deprecated_scope_metrics": + for iter.ReadArray() { + orig.DeprecatedScopeMetrics = append(orig.DeprecatedScopeMetrics, NewScopeMetrics()) + orig.DeprecatedScopeMetrics[len(orig.DeprecatedScopeMetrics)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ResourceMetrics) SizeProto() int { + var n int + var l int + _ = l + l = orig.Resource.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.ScopeMetrics { + 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 + } + for i := range orig.DeprecatedScopeMetrics { + l = orig.DeprecatedScopeMetrics[i].SizeProto() + n += 2 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ResourceMetrics) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Resource.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.ScopeMetrics) - 1; i >= 0; i-- { + l = orig.ScopeMetrics[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + for i := len(orig.DeprecatedScopeMetrics) - 1; i >= 0; i-- { + l = orig.DeprecatedScopeMetrics[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x3e + pos-- + buf[pos] = 0xc2 + } + return len(buf) - pos +} + +func (orig *ResourceMetrics) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Resource.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ScopeMetrics", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ScopeMetrics = append(orig.ScopeMetrics, NewScopeMetrics()) + err = orig.ScopeMetrics[len(orig.ScopeMetrics)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + + case 1000: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedScopeMetrics", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DeprecatedScopeMetrics = append(orig.DeprecatedScopeMetrics, NewScopeMetrics()) + err = orig.DeprecatedScopeMetrics[len(orig.DeprecatedScopeMetrics)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestResourceMetrics() *ResourceMetrics { + orig := NewResourceMetrics() + orig.Resource = *GenTestResource() + orig.ScopeMetrics = []*ScopeMetrics{{}, GenTestScopeMetrics()} + orig.SchemaUrl = "test_schemaurl" + orig.DeprecatedScopeMetrics = []*ScopeMetrics{{}, GenTestScopeMetrics()} + return orig +} + +func GenTestResourceMetricsPtrSlice() []*ResourceMetrics { + orig := make([]*ResourceMetrics, 5) + orig[0] = NewResourceMetrics() + orig[1] = GenTestResourceMetrics() + orig[2] = NewResourceMetrics() + orig[3] = GenTestResourceMetrics() + orig[4] = NewResourceMetrics() + return orig +} + +func GenTestResourceMetricsSlice() []ResourceMetrics { + orig := make([]ResourceMetrics, 5) + orig[1] = *GenTestResourceMetrics() + orig[3] = *GenTestResourceMetrics() + return orig +} diff --git a/pdata/internal/generated_proto_resourcemetrics_test.go b/pdata/internal/generated_proto_resourcemetrics_test.go new file mode 100644 index 00000000000..b02f703b345 --- /dev/null +++ b/pdata/internal/generated_proto_resourcemetrics_test.go @@ -0,0 +1,211 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyResourceMetrics(t *testing.T) { + for name, src := range genTestEncodingValuesResourceMetrics() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewResourceMetrics() + CopyResourceMetrics(dest, src) + assert.Equal(t, src, dest) + CopyResourceMetrics(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyResourceMetricsSlice(t *testing.T) { + src := []ResourceMetrics{} + dest := []ResourceMetrics{} + // Test CopyTo empty + dest = CopyResourceMetricsSlice(dest, src) + assert.Equal(t, []ResourceMetrics{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceMetricsSlice() + dest = CopyResourceMetricsSlice(dest, src) + assert.Equal(t, GenTestResourceMetricsSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceMetricsSlice(dest, src) + assert.Equal(t, GenTestResourceMetricsSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceMetricsSlice(dest, []ResourceMetrics{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceMetricsSlice(dest, src) + assert.Equal(t, GenTestResourceMetricsSlice(), dest) +} + +func TestCopyResourceMetricsPtrSlice(t *testing.T) { + src := []*ResourceMetrics{} + dest := []*ResourceMetrics{} + // Test CopyTo empty + dest = CopyResourceMetricsPtrSlice(dest, src) + assert.Equal(t, []*ResourceMetrics{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceMetricsPtrSlice() + dest = CopyResourceMetricsPtrSlice(dest, src) + assert.Equal(t, GenTestResourceMetricsPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceMetricsPtrSlice(dest, src) + assert.Equal(t, GenTestResourceMetricsPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceMetricsPtrSlice(dest, []*ResourceMetrics{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceMetricsPtrSlice(dest, src) + assert.Equal(t, GenTestResourceMetricsPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceMetricsUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewResourceMetrics() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewResourceMetrics(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceMetrics(t *testing.T) { + for name, src := range genTestEncodingValuesResourceMetrics() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewResourceMetrics() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteResourceMetrics(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoResourceMetricsFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesResourceMetrics() { + t.Run(name, func(t *testing.T) { + dest := NewResourceMetrics() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoResourceMetricsUnknown(t *testing.T) { + dest := NewResourceMetrics() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewResourceMetrics(), dest) +} + +func TestMarshalAndUnmarshalProtoResourceMetrics(t *testing.T) { + for name, src := range genTestEncodingValuesResourceMetrics() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewResourceMetrics() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteResourceMetrics(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufResourceMetrics(t *testing.T) { + for name, src := range genTestEncodingValuesResourceMetrics() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpmetrics.ResourceMetrics{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewResourceMetrics() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesResourceMetrics() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Resource/wrong_wire_type": {0xc}, + "Resource/missing_value": {0xa}, + "ScopeMetrics/wrong_wire_type": {0x14}, + "ScopeMetrics/missing_value": {0x12}, + "SchemaUrl/wrong_wire_type": {0x1c}, + "SchemaUrl/missing_value": {0x1a}, + "DeprecatedScopeMetrics/wrong_wire_type": {0xc4, 0x3e}, + "DeprecatedScopeMetrics/missing_value": {0xc2, 0x3e}, + } +} + +func genTestEncodingValuesResourceMetrics() map[string]*ResourceMetrics { + return map[string]*ResourceMetrics{ + "empty": NewResourceMetrics(), + "Resource/test": {Resource: *GenTestResource()}, + "ScopeMetrics/test": {ScopeMetrics: []*ScopeMetrics{{}, GenTestScopeMetrics()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, + "DeprecatedScopeMetrics/test": {DeprecatedScopeMetrics: []*ScopeMetrics{{}, GenTestScopeMetrics()}}, + } +} diff --git a/pdata/internal/generated_proto_resourceprofiles.go b/pdata/internal/generated_proto_resourceprofiles.go new file mode 100644 index 00000000000..69522c24d84 --- /dev/null +++ b/pdata/internal/generated_proto_resourceprofiles.go @@ -0,0 +1,313 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ResourceProfiles is a collection of profiles from a Resource. +type ResourceProfiles struct { + Resource Resource + ScopeProfiles []*ScopeProfiles + SchemaUrl string +} + +var ( + protoPoolResourceProfiles = sync.Pool{ + New: func() any { + return &ResourceProfiles{} + }, + } +) + +func NewResourceProfiles() *ResourceProfiles { + if !UseProtoPooling.IsEnabled() { + return &ResourceProfiles{} + } + return protoPoolResourceProfiles.Get().(*ResourceProfiles) +} + +func DeleteResourceProfiles(orig *ResourceProfiles, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteResource(&orig.Resource, false) + for i := range orig.ScopeProfiles { + DeleteScopeProfiles(orig.ScopeProfiles[i], true) + } + + orig.Reset() + if nullable { + protoPoolResourceProfiles.Put(orig) + } +} + +func CopyResourceProfiles(dest, src *ResourceProfiles) *ResourceProfiles { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewResourceProfiles() + } + CopyResource(&dest.Resource, &src.Resource) + + dest.ScopeProfiles = CopyScopeProfilesPtrSlice(dest.ScopeProfiles, src.ScopeProfiles) + + dest.SchemaUrl = src.SchemaUrl + + return dest +} + +func CopyResourceProfilesSlice(dest, src []ResourceProfiles) []ResourceProfiles { + var newDest []ResourceProfiles + if cap(dest) < len(src) { + newDest = make([]ResourceProfiles, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceProfiles(&dest[i], false) + } + } + for i := range src { + CopyResourceProfiles(&newDest[i], &src[i]) + } + return newDest +} + +func CopyResourceProfilesPtrSlice(dest, src []*ResourceProfiles) []*ResourceProfiles { + var newDest []*ResourceProfiles + if cap(dest) < len(src) { + newDest = make([]*ResourceProfiles, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceProfiles() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceProfiles(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceProfiles() + } + } + for i := range src { + CopyResourceProfiles(newDest[i], src[i]) + } + return newDest +} + +func (orig *ResourceProfiles) Reset() { + *orig = ResourceProfiles{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ResourceProfiles) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("resource") + orig.Resource.MarshalJSON(dest) + if len(orig.ScopeProfiles) > 0 { + dest.WriteObjectField("scopeProfiles") + dest.WriteArrayStart() + orig.ScopeProfiles[0].MarshalJSON(dest) + for i := 1; i < len(orig.ScopeProfiles); i++ { + dest.WriteMore() + orig.ScopeProfiles[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ResourceProfiles) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resource": + + orig.Resource.UnmarshalJSON(iter) + case "scopeProfiles", "scope_profiles": + for iter.ReadArray() { + orig.ScopeProfiles = append(orig.ScopeProfiles, NewScopeProfiles()) + orig.ScopeProfiles[len(orig.ScopeProfiles)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ResourceProfiles) SizeProto() int { + var n int + var l int + _ = l + l = orig.Resource.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.ScopeProfiles { + 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 + } + return n +} + +func (orig *ResourceProfiles) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Resource.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.ScopeProfiles) - 1; i >= 0; i-- { + l = orig.ScopeProfiles[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *ResourceProfiles) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Resource.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ScopeProfiles", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ScopeProfiles = append(orig.ScopeProfiles, NewScopeProfiles()) + err = orig.ScopeProfiles[len(orig.ScopeProfiles)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestResourceProfiles() *ResourceProfiles { + orig := NewResourceProfiles() + orig.Resource = *GenTestResource() + orig.ScopeProfiles = []*ScopeProfiles{{}, GenTestScopeProfiles()} + orig.SchemaUrl = "test_schemaurl" + return orig +} + +func GenTestResourceProfilesPtrSlice() []*ResourceProfiles { + orig := make([]*ResourceProfiles, 5) + orig[0] = NewResourceProfiles() + orig[1] = GenTestResourceProfiles() + orig[2] = NewResourceProfiles() + orig[3] = GenTestResourceProfiles() + orig[4] = NewResourceProfiles() + return orig +} + +func GenTestResourceProfilesSlice() []ResourceProfiles { + orig := make([]ResourceProfiles, 5) + orig[1] = *GenTestResourceProfiles() + orig[3] = *GenTestResourceProfiles() + return orig +} diff --git a/pdata/internal/generated_wrapper_resourceprofiles_test.go b/pdata/internal/generated_proto_resourceprofiles_test.go similarity index 51% rename from pdata/internal/generated_wrapper_resourceprofiles_test.go rename to pdata/internal/generated_proto_resourceprofiles_test.go index 45911b5986d..49edca21ce5 100644 --- a/pdata/internal/generated_wrapper_resourceprofiles_test.go +++ b/pdata/internal/generated_proto_resourceprofiles_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigResourceProfiles(t *testing.T) { +func TestCopyResourceProfiles(t *testing.T) { for name, src := range genTestEncodingValuesResourceProfiles() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigResourceProfiles(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigResourceProfiles() - CopyOrigResourceProfiles(dest, src) + dest := NewResourceProfiles() + CopyResourceProfiles(dest, src) assert.Equal(t, src, dest) - CopyOrigResourceProfiles(dest, dest) + CopyResourceProfiles(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigResourceProfilesUnknown(t *testing.T) { +func TestCopyResourceProfilesSlice(t *testing.T) { + src := []ResourceProfiles{} + dest := []ResourceProfiles{} + // Test CopyTo empty + dest = CopyResourceProfilesSlice(dest, src) + assert.Equal(t, []ResourceProfiles{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceProfilesSlice() + dest = CopyResourceProfilesSlice(dest, src) + assert.Equal(t, GenTestResourceProfilesSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceProfilesSlice(dest, src) + assert.Equal(t, GenTestResourceProfilesSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceProfilesSlice(dest, []ResourceProfiles{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceProfilesSlice(dest, src) + assert.Equal(t, GenTestResourceProfilesSlice(), dest) +} + +func TestCopyResourceProfilesPtrSlice(t *testing.T) { + src := []*ResourceProfiles{} + dest := []*ResourceProfiles{} + // Test CopyTo empty + dest = CopyResourceProfilesPtrSlice(dest, src) + assert.Equal(t, []*ResourceProfiles{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceProfilesPtrSlice() + dest = CopyResourceProfilesPtrSlice(dest, src) + assert.Equal(t, GenTestResourceProfilesPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceProfilesPtrSlice(dest, src) + assert.Equal(t, GenTestResourceProfilesPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceProfilesPtrSlice(dest, []*ResourceProfiles{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceProfilesPtrSlice(dest, src) + assert.Equal(t, GenTestResourceProfilesPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceProfilesUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigResourceProfiles() - UnmarshalJSONOrigResourceProfiles(dest, iter) + dest := NewResourceProfiles() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigResourceProfiles(), dest) + assert.Equal(t, NewResourceProfiles(), dest) } -func TestMarshalAndUnmarshalJSONOrigResourceProfiles(t *testing.T) { +func TestMarshalAndUnmarshalJSONResourceProfiles(t *testing.T) { for name, src := range genTestEncodingValuesResourceProfiles() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigResourceProfiles(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigResourceProfiles(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigResourceProfiles() - UnmarshalJSONOrigResourceProfiles(dest, iter) + dest := NewResourceProfiles() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigResourceProfiles(dest, true) + DeleteResourceProfiles(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigResourceProfilesFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoResourceProfilesFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesResourceProfiles() { t.Run(name, func(t *testing.T) { - dest := NewOrigResourceProfiles() - require.Error(t, UnmarshalProtoOrigResourceProfiles(dest, buf)) + dest := NewResourceProfiles() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigResourceProfilesUnknown(t *testing.T) { - dest := NewOrigResourceProfiles() +func TestMarshalAndUnmarshalProtoResourceProfilesUnknown(t *testing.T) { + dest := NewResourceProfiles() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigResourceProfiles(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigResourceProfiles(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewResourceProfiles(), dest) } -func TestMarshalAndUnmarshalProtoOrigResourceProfiles(t *testing.T) { +func TestMarshalAndUnmarshalProtoResourceProfiles(t *testing.T) { for name, src := range genTestEncodingValuesResourceProfiles() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigResourceProfiles(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigResourceProfiles(src)) - gotSize := MarshalProtoOrigResourceProfiles(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigResourceProfiles() - require.NoError(t, UnmarshalProtoOrigResourceProfiles(dest, buf)) + dest := NewResourceProfiles() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigResourceProfiles(dest, true) + DeleteResourceProfiles(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigResourceProfiles(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufResourceProfiles(t *testing.T) { for name, src := range genTestEncodingValuesResourceProfiles() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigResourceProfiles(src)) - gotSize := MarshalProtoOrigResourceProfiles(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.ResourceProfiles{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufResourceProfiles(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigResourceProfiles() - require.NoError(t, UnmarshalProtoOrigResourceProfiles(dest, goBuf)) + dest := NewResourceProfiles() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesResourceProfiles() map[string][]byte { } } -func genTestEncodingValuesResourceProfiles() map[string]*otlpprofiles.ResourceProfiles { - return map[string]*otlpprofiles.ResourceProfiles{ - "empty": NewOrigResourceProfiles(), - "Resource/test": {Resource: *GenTestOrigResource()}, - "ScopeProfiles/default_and_test": {ScopeProfiles: []*otlpprofiles.ScopeProfiles{{}, GenTestOrigScopeProfiles()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, +func genTestEncodingValuesResourceProfiles() map[string]*ResourceProfiles { + return map[string]*ResourceProfiles{ + "empty": NewResourceProfiles(), + "Resource/test": {Resource: *GenTestResource()}, + "ScopeProfiles/test": {ScopeProfiles: []*ScopeProfiles{{}, GenTestScopeProfiles()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, } } diff --git a/pdata/internal/generated_proto_resourcespans.go b/pdata/internal/generated_proto_resourcespans.go new file mode 100644 index 00000000000..bd70dedb80e --- /dev/null +++ b/pdata/internal/generated_proto_resourcespans.go @@ -0,0 +1,365 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ResourceSpans is a collection of spans from a Resource. +type ResourceSpans struct { + Resource Resource + ScopeSpans []*ScopeSpans + SchemaUrl string + DeprecatedScopeSpans []*ScopeSpans +} + +var ( + protoPoolResourceSpans = sync.Pool{ + New: func() any { + return &ResourceSpans{} + }, + } +) + +func NewResourceSpans() *ResourceSpans { + if !UseProtoPooling.IsEnabled() { + return &ResourceSpans{} + } + return protoPoolResourceSpans.Get().(*ResourceSpans) +} + +func DeleteResourceSpans(orig *ResourceSpans, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + 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) + } +} + +func CopyResourceSpans(dest, src *ResourceSpans) *ResourceSpans { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewResourceSpans() + } + CopyResource(&dest.Resource, &src.Resource) + + dest.ScopeSpans = CopyScopeSpansPtrSlice(dest.ScopeSpans, src.ScopeSpans) + + dest.SchemaUrl = src.SchemaUrl + + dest.DeprecatedScopeSpans = CopyScopeSpansPtrSlice(dest.DeprecatedScopeSpans, src.DeprecatedScopeSpans) + + return dest +} + +func CopyResourceSpansSlice(dest, src []ResourceSpans) []ResourceSpans { + var newDest []ResourceSpans + if cap(dest) < len(src) { + newDest = make([]ResourceSpans, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceSpans(&dest[i], false) + } + } + for i := range src { + CopyResourceSpans(&newDest[i], &src[i]) + } + return newDest +} + +func CopyResourceSpansPtrSlice(dest, src []*ResourceSpans) []*ResourceSpans { + var newDest []*ResourceSpans + if cap(dest) < len(src) { + newDest = make([]*ResourceSpans, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceSpans() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteResourceSpans(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewResourceSpans() + } + } + for i := range src { + CopyResourceSpans(newDest[i], src[i]) + } + return newDest +} + +func (orig *ResourceSpans) Reset() { + *orig = ResourceSpans{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ResourceSpans) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("resource") + orig.Resource.MarshalJSON(dest) + if len(orig.ScopeSpans) > 0 { + dest.WriteObjectField("scopeSpans") + dest.WriteArrayStart() + orig.ScopeSpans[0].MarshalJSON(dest) + for i := 1; i < len(orig.ScopeSpans); i++ { + dest.WriteMore() + orig.ScopeSpans[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + if len(orig.DeprecatedScopeSpans) > 0 { + dest.WriteObjectField("deprecatedScopeSpans") + dest.WriteArrayStart() + orig.DeprecatedScopeSpans[0].MarshalJSON(dest) + for i := 1; i < len(orig.DeprecatedScopeSpans); i++ { + dest.WriteMore() + orig.DeprecatedScopeSpans[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ResourceSpans) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resource": + + orig.Resource.UnmarshalJSON(iter) + case "scopeSpans", "scope_spans": + for iter.ReadArray() { + orig.ScopeSpans = append(orig.ScopeSpans, NewScopeSpans()) + orig.ScopeSpans[len(orig.ScopeSpans)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + case "deprecatedScopeSpans", "deprecated_scope_spans": + for iter.ReadArray() { + orig.DeprecatedScopeSpans = append(orig.DeprecatedScopeSpans, NewScopeSpans()) + orig.DeprecatedScopeSpans[len(orig.DeprecatedScopeSpans)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *ResourceSpans) SizeProto() int { + var n int + var l int + _ = l + l = orig.Resource.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.ScopeSpans { + 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 + } + for i := range orig.DeprecatedScopeSpans { + l = orig.DeprecatedScopeSpans[i].SizeProto() + n += 2 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *ResourceSpans) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Resource.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.ScopeSpans) - 1; i >= 0; i-- { + l = orig.ScopeSpans[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + for i := len(orig.DeprecatedScopeSpans) - 1; i >= 0; i-- { + l = orig.DeprecatedScopeSpans[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x3e + pos-- + buf[pos] = 0xc2 + } + return len(buf) - pos +} + +func (orig *ResourceSpans) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Resource.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ScopeSpans", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ScopeSpans = append(orig.ScopeSpans, NewScopeSpans()) + err = orig.ScopeSpans[len(orig.ScopeSpans)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + + case 1000: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedScopeSpans", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DeprecatedScopeSpans = append(orig.DeprecatedScopeSpans, NewScopeSpans()) + err = orig.DeprecatedScopeSpans[len(orig.DeprecatedScopeSpans)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestResourceSpans() *ResourceSpans { + orig := NewResourceSpans() + orig.Resource = *GenTestResource() + orig.ScopeSpans = []*ScopeSpans{{}, GenTestScopeSpans()} + orig.SchemaUrl = "test_schemaurl" + orig.DeprecatedScopeSpans = []*ScopeSpans{{}, GenTestScopeSpans()} + return orig +} + +func GenTestResourceSpansPtrSlice() []*ResourceSpans { + orig := make([]*ResourceSpans, 5) + orig[0] = NewResourceSpans() + orig[1] = GenTestResourceSpans() + orig[2] = NewResourceSpans() + orig[3] = GenTestResourceSpans() + orig[4] = NewResourceSpans() + return orig +} + +func GenTestResourceSpansSlice() []ResourceSpans { + orig := make([]ResourceSpans, 5) + orig[1] = *GenTestResourceSpans() + orig[3] = *GenTestResourceSpans() + return orig +} diff --git a/pdata/internal/generated_proto_resourcespans_test.go b/pdata/internal/generated_proto_resourcespans_test.go new file mode 100644 index 00000000000..f0ea9531fd8 --- /dev/null +++ b/pdata/internal/generated_proto_resourcespans_test.go @@ -0,0 +1,211 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlptrace "go.opentelemetry.io/proto/slim/otlp/trace/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyResourceSpans(t *testing.T) { + for name, src := range genTestEncodingValuesResourceSpans() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewResourceSpans() + CopyResourceSpans(dest, src) + assert.Equal(t, src, dest) + CopyResourceSpans(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyResourceSpansSlice(t *testing.T) { + src := []ResourceSpans{} + dest := []ResourceSpans{} + // Test CopyTo empty + dest = CopyResourceSpansSlice(dest, src) + assert.Equal(t, []ResourceSpans{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceSpansSlice() + dest = CopyResourceSpansSlice(dest, src) + assert.Equal(t, GenTestResourceSpansSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceSpansSlice(dest, src) + assert.Equal(t, GenTestResourceSpansSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceSpansSlice(dest, []ResourceSpans{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceSpansSlice(dest, src) + assert.Equal(t, GenTestResourceSpansSlice(), dest) +} + +func TestCopyResourceSpansPtrSlice(t *testing.T) { + src := []*ResourceSpans{} + dest := []*ResourceSpans{} + // Test CopyTo empty + dest = CopyResourceSpansPtrSlice(dest, src) + assert.Equal(t, []*ResourceSpans{}, dest) + + // Test CopyTo larger slice + src = GenTestResourceSpansPtrSlice() + dest = CopyResourceSpansPtrSlice(dest, src) + assert.Equal(t, GenTestResourceSpansPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyResourceSpansPtrSlice(dest, src) + assert.Equal(t, GenTestResourceSpansPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyResourceSpansPtrSlice(dest, []*ResourceSpans{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyResourceSpansPtrSlice(dest, src) + assert.Equal(t, GenTestResourceSpansPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceSpansUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewResourceSpans() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewResourceSpans(), dest) +} + +func TestMarshalAndUnmarshalJSONResourceSpans(t *testing.T) { + for name, src := range genTestEncodingValuesResourceSpans() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewResourceSpans() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteResourceSpans(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoResourceSpansFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesResourceSpans() { + t.Run(name, func(t *testing.T) { + dest := NewResourceSpans() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoResourceSpansUnknown(t *testing.T) { + dest := NewResourceSpans() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewResourceSpans(), dest) +} + +func TestMarshalAndUnmarshalProtoResourceSpans(t *testing.T) { + for name, src := range genTestEncodingValuesResourceSpans() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewResourceSpans() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteResourceSpans(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufResourceSpans(t *testing.T) { + for name, src := range genTestEncodingValuesResourceSpans() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlptrace.ResourceSpans{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewResourceSpans() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesResourceSpans() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Resource/wrong_wire_type": {0xc}, + "Resource/missing_value": {0xa}, + "ScopeSpans/wrong_wire_type": {0x14}, + "ScopeSpans/missing_value": {0x12}, + "SchemaUrl/wrong_wire_type": {0x1c}, + "SchemaUrl/missing_value": {0x1a}, + "DeprecatedScopeSpans/wrong_wire_type": {0xc4, 0x3e}, + "DeprecatedScopeSpans/missing_value": {0xc2, 0x3e}, + } +} + +func genTestEncodingValuesResourceSpans() map[string]*ResourceSpans { + return map[string]*ResourceSpans{ + "empty": NewResourceSpans(), + "Resource/test": {Resource: *GenTestResource()}, + "ScopeSpans/test": {ScopeSpans: []*ScopeSpans{{}, GenTestScopeSpans()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, + "DeprecatedScopeSpans/test": {DeprecatedScopeSpans: []*ScopeSpans{{}, GenTestScopeSpans()}}, + } +} diff --git a/pdata/internal/generated_wrapper_sample.go b/pdata/internal/generated_proto_sample.go similarity index 71% rename from pdata/internal/generated_wrapper_sample.go rename to pdata/internal/generated_proto_sample.go index 902b55aed89..df89e9b63e1 100644 --- a/pdata/internal/generated_wrapper_sample.go +++ b/pdata/internal/generated_proto_sample.go @@ -11,27 +11,35 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Sample represents each record value encountered within a profiled program. +type Sample struct { + StackIndex int32 + Values []int64 + AttributeIndices []int32 + LinkIndex int32 + TimestampsUnixNano []uint64 +} + var ( protoPoolSample = sync.Pool{ New: func() any { - return &otlpprofiles.Sample{} + return &Sample{} }, } ) -func NewOrigSample() *otlpprofiles.Sample { +func NewSample() *Sample { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Sample{} + return &Sample{} } - return protoPoolSample.Get().(*otlpprofiles.Sample) + return protoPoolSample.Get().(*Sample) } -func DeleteOrigSample(orig *otlpprofiles.Sample, nullable bool) { +func DeleteSample(orig *Sample, nullable bool) { if orig == nil { return } @@ -47,30 +55,84 @@ func DeleteOrigSample(orig *otlpprofiles.Sample, nullable bool) { } } -func CopyOrigSample(dest, src *otlpprofiles.Sample) { +func CopySample(dest, src *Sample) *Sample { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSample() } dest.StackIndex = src.StackIndex - dest.Values = CopyOrigInt64Slice(dest.Values, src.Values) - dest.AttributeIndices = CopyOrigInt32Slice(dest.AttributeIndices, src.AttributeIndices) + + dest.Values = append(dest.Values[:0], src.Values...) + dest.AttributeIndices = append(dest.AttributeIndices[:0], src.AttributeIndices...) dest.LinkIndex = src.LinkIndex - dest.TimestampsUnixNano = CopyOrigUint64Slice(dest.TimestampsUnixNano, src.TimestampsUnixNano) + + dest.TimestampsUnixNano = append(dest.TimestampsUnixNano[:0], src.TimestampsUnixNano...) + + return dest } -func GenTestOrigSample() *otlpprofiles.Sample { - orig := NewOrigSample() - orig.StackIndex = int32(13) - orig.Values = GenerateOrigTestInt64Slice() - orig.AttributeIndices = GenerateOrigTestInt32Slice() - orig.LinkIndex = int32(13) - orig.TimestampsUnixNano = GenerateOrigTestUint64Slice() - return orig +func CopySampleSlice(dest, src []Sample) []Sample { + var newDest []Sample + if cap(dest) < len(src) { + newDest = make([]Sample, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSample(&dest[i], false) + } + } + for i := range src { + CopySample(&newDest[i], &src[i]) + } + return newDest +} + +func CopySamplePtrSlice(dest, src []*Sample) []*Sample { + var newDest []*Sample + if cap(dest) < len(src) { + newDest = make([]*Sample, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSample() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSample(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSample() + } + } + for i := range src { + CopySample(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSample(orig *otlpprofiles.Sample, dest *json.Stream) { +func (orig *Sample) Reset() { + *orig = Sample{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Sample) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.StackIndex != int32(0) { dest.WriteObjectField("stackIndex") @@ -113,8 +175,8 @@ func MarshalJSONOrigSample(orig *otlpprofiles.Sample, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigSample unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSample(orig *otlpprofiles.Sample, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Sample) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "stackIndex", "stack_index": @@ -142,7 +204,7 @@ func UnmarshalJSONOrigSample(orig *otlpprofiles.Sample, iter *json.Iterator) { } } -func SizeProtoOrigSample(orig *otlpprofiles.Sample) int { +func (orig *Sample) SizeProto() int { var n int var l int _ = l @@ -174,7 +236,7 @@ func SizeProtoOrigSample(orig *otlpprofiles.Sample) int { return n } -func MarshalProtoOrigSample(orig *otlpprofiles.Sample, buf []byte) int { +func (orig *Sample) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -221,7 +283,7 @@ func MarshalProtoOrigSample(orig *otlpprofiles.Sample, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigSample(orig *otlpprofiles.Sample, buf []byte) error { +func (orig *Sample) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -360,3 +422,30 @@ func UnmarshalProtoOrigSample(orig *otlpprofiles.Sample, buf []byte) error { } return nil } + +func GenTestSample() *Sample { + orig := NewSample() + orig.StackIndex = int32(13) + orig.Values = []int64{int64(0), int64(13)} + orig.AttributeIndices = []int32{int32(0), int32(13)} + orig.LinkIndex = int32(13) + orig.TimestampsUnixNano = []uint64{uint64(0), uint64(13)} + return orig +} + +func GenTestSamplePtrSlice() []*Sample { + orig := make([]*Sample, 5) + orig[0] = NewSample() + orig[1] = GenTestSample() + orig[2] = NewSample() + orig[3] = GenTestSample() + orig[4] = NewSample() + return orig +} + +func GenTestSampleSlice() []Sample { + orig := make([]Sample, 5) + orig[1] = *GenTestSample() + orig[3] = *GenTestSample() + return orig +} diff --git a/pdata/internal/generated_wrapper_sample_test.go b/pdata/internal/generated_proto_sample_test.go similarity index 55% rename from pdata/internal/generated_wrapper_sample_test.go rename to pdata/internal/generated_proto_sample_test.go index 7e014732b0f..4893212c10c 100644 --- a/pdata/internal/generated_wrapper_sample_test.go +++ b/pdata/internal/generated_proto_sample_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSample(t *testing.T) { +func TestCopySample(t *testing.T) { for name, src := range genTestEncodingValuesSample() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigSample(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSample() - CopyOrigSample(dest, src) + dest := NewSample() + CopySample(dest, src) assert.Equal(t, src, dest) - CopyOrigSample(dest, dest) + CopySample(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSampleUnknown(t *testing.T) { +func TestCopySampleSlice(t *testing.T) { + src := []Sample{} + dest := []Sample{} + // Test CopyTo empty + dest = CopySampleSlice(dest, src) + assert.Equal(t, []Sample{}, dest) + + // Test CopyTo larger slice + src = GenTestSampleSlice() + dest = CopySampleSlice(dest, src) + assert.Equal(t, GenTestSampleSlice(), dest) + + // Test CopyTo same size slice + dest = CopySampleSlice(dest, src) + assert.Equal(t, GenTestSampleSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySampleSlice(dest, []Sample{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySampleSlice(dest, src) + assert.Equal(t, GenTestSampleSlice(), dest) +} + +func TestCopySamplePtrSlice(t *testing.T) { + src := []*Sample{} + dest := []*Sample{} + // Test CopyTo empty + dest = CopySamplePtrSlice(dest, src) + assert.Equal(t, []*Sample{}, dest) + + // Test CopyTo larger slice + src = GenTestSamplePtrSlice() + dest = CopySamplePtrSlice(dest, src) + assert.Equal(t, GenTestSamplePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySamplePtrSlice(dest, src) + assert.Equal(t, GenTestSamplePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySamplePtrSlice(dest, []*Sample{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySamplePtrSlice(dest, src) + assert.Equal(t, GenTestSamplePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSampleUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSample() - UnmarshalJSONOrigSample(dest, iter) + dest := NewSample() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSample(), dest) + assert.Equal(t, NewSample(), dest) } -func TestMarshalAndUnmarshalJSONOrigSample(t *testing.T) { +func TestMarshalAndUnmarshalJSONSample(t *testing.T) { for name, src := range genTestEncodingValuesSample() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigSample(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSample(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSample() - UnmarshalJSONOrigSample(dest, iter) + dest := NewSample() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSample(dest, true) + DeleteSample(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSampleFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoSampleFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesSample() { t.Run(name, func(t *testing.T) { - dest := NewOrigSample() - require.Error(t, UnmarshalProtoOrigSample(dest, buf)) + dest := NewSample() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSampleUnknown(t *testing.T) { - dest := NewOrigSample() +func TestMarshalAndUnmarshalProtoSampleUnknown(t *testing.T) { + dest := NewSample() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSample(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSample(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSample(), dest) } -func TestMarshalAndUnmarshalProtoOrigSample(t *testing.T) { +func TestMarshalAndUnmarshalProtoSample(t *testing.T) { for name, src := range genTestEncodingValuesSample() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigSample(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSample(src)) - gotSize := MarshalProtoOrigSample(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSample() - require.NoError(t, UnmarshalProtoOrigSample(dest, buf)) + dest := NewSample() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSample(dest, true) + DeleteSample(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigSample(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufSample(t *testing.T) { for name, src := range genTestEncodingValuesSample() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSample(src)) - gotSize := MarshalProtoOrigSample(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Sample{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufSample(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSample() - require.NoError(t, UnmarshalProtoOrigSample(dest, goBuf)) + dest := NewSample() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -153,13 +202,13 @@ func genTestFailingUnmarshalProtoValuesSample() map[string][]byte { } } -func genTestEncodingValuesSample() map[string]*otlpprofiles.Sample { - return map[string]*otlpprofiles.Sample{ - "empty": NewOrigSample(), - "StackIndex/test": {StackIndex: int32(13)}, - "Values/default_and_test": {Values: []int64{int64(0), int64(13)}}, - "AttributeIndices/default_and_test": {AttributeIndices: []int32{int32(0), int32(13)}}, - "LinkIndex/test": {LinkIndex: int32(13)}, - "TimestampsUnixNano/default_and_test": {TimestampsUnixNano: []uint64{uint64(0), uint64(13)}}, +func genTestEncodingValuesSample() map[string]*Sample { + return map[string]*Sample{ + "empty": NewSample(), + "StackIndex/test": {StackIndex: int32(13)}, + "Values/test": {Values: []int64{int64(0), int64(13)}}, + "AttributeIndices/test": {AttributeIndices: []int32{int32(0), int32(13)}}, + "LinkIndex/test": {LinkIndex: int32(13)}, + "TimestampsUnixNano/test": {TimestampsUnixNano: []uint64{uint64(0), uint64(13)}}, } } diff --git a/pdata/internal/generated_proto_scopelogs.go b/pdata/internal/generated_proto_scopelogs.go new file mode 100644 index 00000000000..8f303264c73 --- /dev/null +++ b/pdata/internal/generated_proto_scopelogs.go @@ -0,0 +1,313 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ScopeLogs is a collection of logs from a LibraryInstrumentation. +type ScopeLogs struct { + Scope InstrumentationScope + LogRecords []*LogRecord + SchemaUrl string +} + +var ( + protoPoolScopeLogs = sync.Pool{ + New: func() any { + return &ScopeLogs{} + }, + } +) + +func NewScopeLogs() *ScopeLogs { + if !UseProtoPooling.IsEnabled() { + return &ScopeLogs{} + } + return protoPoolScopeLogs.Get().(*ScopeLogs) +} + +func DeleteScopeLogs(orig *ScopeLogs, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteInstrumentationScope(&orig.Scope, false) + for i := range orig.LogRecords { + DeleteLogRecord(orig.LogRecords[i], true) + } + + orig.Reset() + if nullable { + protoPoolScopeLogs.Put(orig) + } +} + +func CopyScopeLogs(dest, src *ScopeLogs) *ScopeLogs { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewScopeLogs() + } + CopyInstrumentationScope(&dest.Scope, &src.Scope) + + dest.LogRecords = CopyLogRecordPtrSlice(dest.LogRecords, src.LogRecords) + + dest.SchemaUrl = src.SchemaUrl + + return dest +} + +func CopyScopeLogsSlice(dest, src []ScopeLogs) []ScopeLogs { + var newDest []ScopeLogs + if cap(dest) < len(src) { + newDest = make([]ScopeLogs, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeLogs(&dest[i], false) + } + } + for i := range src { + CopyScopeLogs(&newDest[i], &src[i]) + } + return newDest +} + +func CopyScopeLogsPtrSlice(dest, src []*ScopeLogs) []*ScopeLogs { + var newDest []*ScopeLogs + if cap(dest) < len(src) { + newDest = make([]*ScopeLogs, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeLogs() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeLogs(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeLogs() + } + } + for i := range src { + CopyScopeLogs(newDest[i], src[i]) + } + return newDest +} + +func (orig *ScopeLogs) Reset() { + *orig = ScopeLogs{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ScopeLogs) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("scope") + orig.Scope.MarshalJSON(dest) + if len(orig.LogRecords) > 0 { + dest.WriteObjectField("logRecords") + dest.WriteArrayStart() + orig.LogRecords[0].MarshalJSON(dest) + for i := 1; i < len(orig.LogRecords); i++ { + dest.WriteMore() + orig.LogRecords[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ScopeLogs) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "scope": + + orig.Scope.UnmarshalJSON(iter) + case "logRecords", "log_records": + for iter.ReadArray() { + orig.LogRecords = append(orig.LogRecords, NewLogRecord()) + orig.LogRecords[len(orig.LogRecords)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ScopeLogs) SizeProto() int { + var n int + var l int + _ = l + l = orig.Scope.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.LogRecords { + 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 + } + return n +} + +func (orig *ScopeLogs) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Scope.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.LogRecords) - 1; i >= 0; i-- { + l = orig.LogRecords[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *ScopeLogs) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Scope.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field LogRecords", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.LogRecords = append(orig.LogRecords, NewLogRecord()) + err = orig.LogRecords[len(orig.LogRecords)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestScopeLogs() *ScopeLogs { + orig := NewScopeLogs() + orig.Scope = *GenTestInstrumentationScope() + orig.LogRecords = []*LogRecord{{}, GenTestLogRecord()} + orig.SchemaUrl = "test_schemaurl" + return orig +} + +func GenTestScopeLogsPtrSlice() []*ScopeLogs { + orig := make([]*ScopeLogs, 5) + orig[0] = NewScopeLogs() + orig[1] = GenTestScopeLogs() + orig[2] = NewScopeLogs() + orig[3] = GenTestScopeLogs() + orig[4] = NewScopeLogs() + return orig +} + +func GenTestScopeLogsSlice() []ScopeLogs { + orig := make([]ScopeLogs, 5) + orig[1] = *GenTestScopeLogs() + orig[3] = *GenTestScopeLogs() + return orig +} diff --git a/pdata/internal/generated_wrapper_scopelogs_test.go b/pdata/internal/generated_proto_scopelogs_test.go similarity index 53% rename from pdata/internal/generated_wrapper_scopelogs_test.go rename to pdata/internal/generated_proto_scopelogs_test.go index 77610d6fb6b..b9ce60c6bef 100644 --- a/pdata/internal/generated_wrapper_scopelogs_test.go +++ b/pdata/internal/generated_proto_scopelogs_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigScopeLogs(t *testing.T) { +func TestCopyScopeLogs(t *testing.T) { for name, src := range genTestEncodingValuesScopeLogs() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigScopeLogs(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigScopeLogs() - CopyOrigScopeLogs(dest, src) + dest := NewScopeLogs() + CopyScopeLogs(dest, src) assert.Equal(t, src, dest) - CopyOrigScopeLogs(dest, dest) + CopyScopeLogs(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigScopeLogsUnknown(t *testing.T) { +func TestCopyScopeLogsSlice(t *testing.T) { + src := []ScopeLogs{} + dest := []ScopeLogs{} + // Test CopyTo empty + dest = CopyScopeLogsSlice(dest, src) + assert.Equal(t, []ScopeLogs{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeLogsSlice() + dest = CopyScopeLogsSlice(dest, src) + assert.Equal(t, GenTestScopeLogsSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeLogsSlice(dest, src) + assert.Equal(t, GenTestScopeLogsSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeLogsSlice(dest, []ScopeLogs{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeLogsSlice(dest, src) + assert.Equal(t, GenTestScopeLogsSlice(), dest) +} + +func TestCopyScopeLogsPtrSlice(t *testing.T) { + src := []*ScopeLogs{} + dest := []*ScopeLogs{} + // Test CopyTo empty + dest = CopyScopeLogsPtrSlice(dest, src) + assert.Equal(t, []*ScopeLogs{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeLogsPtrSlice() + dest = CopyScopeLogsPtrSlice(dest, src) + assert.Equal(t, GenTestScopeLogsPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeLogsPtrSlice(dest, src) + assert.Equal(t, GenTestScopeLogsPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeLogsPtrSlice(dest, []*ScopeLogs{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeLogsPtrSlice(dest, src) + assert.Equal(t, GenTestScopeLogsPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONScopeLogsUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigScopeLogs() - UnmarshalJSONOrigScopeLogs(dest, iter) + dest := NewScopeLogs() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigScopeLogs(), dest) + assert.Equal(t, NewScopeLogs(), dest) } -func TestMarshalAndUnmarshalJSONOrigScopeLogs(t *testing.T) { +func TestMarshalAndUnmarshalJSONScopeLogs(t *testing.T) { for name, src := range genTestEncodingValuesScopeLogs() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigScopeLogs(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigScopeLogs(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigScopeLogs() - UnmarshalJSONOrigScopeLogs(dest, iter) + dest := NewScopeLogs() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigScopeLogs(dest, true) + DeleteScopeLogs(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigScopeLogsFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeLogsFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesScopeLogs() { t.Run(name, func(t *testing.T) { - dest := NewOrigScopeLogs() - require.Error(t, UnmarshalProtoOrigScopeLogs(dest, buf)) + dest := NewScopeLogs() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigScopeLogsUnknown(t *testing.T) { - dest := NewOrigScopeLogs() +func TestMarshalAndUnmarshalProtoScopeLogsUnknown(t *testing.T) { + dest := NewScopeLogs() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigScopeLogs(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigScopeLogs(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewScopeLogs(), dest) } -func TestMarshalAndUnmarshalProtoOrigScopeLogs(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeLogs(t *testing.T) { for name, src := range genTestEncodingValuesScopeLogs() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigScopeLogs(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigScopeLogs(src)) - gotSize := MarshalProtoOrigScopeLogs(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigScopeLogs() - require.NoError(t, UnmarshalProtoOrigScopeLogs(dest, buf)) + dest := NewScopeLogs() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigScopeLogs(dest, true) + DeleteScopeLogs(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigScopeLogs(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufScopeLogs(t *testing.T) { for name, src := range genTestEncodingValuesScopeLogs() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigScopeLogs(src)) - gotSize := MarshalProtoOrigScopeLogs(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlplogs.ScopeLogs{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufScopeLogs(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigScopeLogs() - require.NoError(t, UnmarshalProtoOrigScopeLogs(dest, goBuf)) + dest := NewScopeLogs() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesScopeLogs() map[string][]byte { } } -func genTestEncodingValuesScopeLogs() map[string]*otlplogs.ScopeLogs { - return map[string]*otlplogs.ScopeLogs{ - "empty": NewOrigScopeLogs(), - "Scope/test": {Scope: *GenTestOrigInstrumentationScope()}, - "LogRecords/default_and_test": {LogRecords: []*otlplogs.LogRecord{{}, GenTestOrigLogRecord()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, +func genTestEncodingValuesScopeLogs() map[string]*ScopeLogs { + return map[string]*ScopeLogs{ + "empty": NewScopeLogs(), + "Scope/test": {Scope: *GenTestInstrumentationScope()}, + "LogRecords/test": {LogRecords: []*LogRecord{{}, GenTestLogRecord()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, } } diff --git a/pdata/internal/generated_proto_scopemetrics.go b/pdata/internal/generated_proto_scopemetrics.go new file mode 100644 index 00000000000..fc521a4017c --- /dev/null +++ b/pdata/internal/generated_proto_scopemetrics.go @@ -0,0 +1,313 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ScopeMetrics is a collection of metrics from a LibraryInstrumentation. +type ScopeMetrics struct { + Scope InstrumentationScope + Metrics []*Metric + SchemaUrl string +} + +var ( + protoPoolScopeMetrics = sync.Pool{ + New: func() any { + return &ScopeMetrics{} + }, + } +) + +func NewScopeMetrics() *ScopeMetrics { + if !UseProtoPooling.IsEnabled() { + return &ScopeMetrics{} + } + return protoPoolScopeMetrics.Get().(*ScopeMetrics) +} + +func DeleteScopeMetrics(orig *ScopeMetrics, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteInstrumentationScope(&orig.Scope, false) + for i := range orig.Metrics { + DeleteMetric(orig.Metrics[i], true) + } + + orig.Reset() + if nullable { + protoPoolScopeMetrics.Put(orig) + } +} + +func CopyScopeMetrics(dest, src *ScopeMetrics) *ScopeMetrics { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewScopeMetrics() + } + CopyInstrumentationScope(&dest.Scope, &src.Scope) + + dest.Metrics = CopyMetricPtrSlice(dest.Metrics, src.Metrics) + + dest.SchemaUrl = src.SchemaUrl + + return dest +} + +func CopyScopeMetricsSlice(dest, src []ScopeMetrics) []ScopeMetrics { + var newDest []ScopeMetrics + if cap(dest) < len(src) { + newDest = make([]ScopeMetrics, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeMetrics(&dest[i], false) + } + } + for i := range src { + CopyScopeMetrics(&newDest[i], &src[i]) + } + return newDest +} + +func CopyScopeMetricsPtrSlice(dest, src []*ScopeMetrics) []*ScopeMetrics { + var newDest []*ScopeMetrics + if cap(dest) < len(src) { + newDest = make([]*ScopeMetrics, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeMetrics() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeMetrics(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeMetrics() + } + } + for i := range src { + CopyScopeMetrics(newDest[i], src[i]) + } + return newDest +} + +func (orig *ScopeMetrics) Reset() { + *orig = ScopeMetrics{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ScopeMetrics) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("scope") + orig.Scope.MarshalJSON(dest) + if len(orig.Metrics) > 0 { + dest.WriteObjectField("metrics") + dest.WriteArrayStart() + orig.Metrics[0].MarshalJSON(dest) + for i := 1; i < len(orig.Metrics); i++ { + dest.WriteMore() + orig.Metrics[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ScopeMetrics) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "scope": + + orig.Scope.UnmarshalJSON(iter) + case "metrics": + for iter.ReadArray() { + orig.Metrics = append(orig.Metrics, NewMetric()) + orig.Metrics[len(orig.Metrics)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ScopeMetrics) SizeProto() int { + var n int + var l int + _ = l + l = orig.Scope.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.Metrics { + 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 + } + return n +} + +func (orig *ScopeMetrics) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Scope.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.Metrics) - 1; i >= 0; i-- { + l = orig.Metrics[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *ScopeMetrics) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Scope.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Metrics = append(orig.Metrics, NewMetric()) + err = orig.Metrics[len(orig.Metrics)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestScopeMetrics() *ScopeMetrics { + orig := NewScopeMetrics() + orig.Scope = *GenTestInstrumentationScope() + orig.Metrics = []*Metric{{}, GenTestMetric()} + orig.SchemaUrl = "test_schemaurl" + return orig +} + +func GenTestScopeMetricsPtrSlice() []*ScopeMetrics { + orig := make([]*ScopeMetrics, 5) + orig[0] = NewScopeMetrics() + orig[1] = GenTestScopeMetrics() + orig[2] = NewScopeMetrics() + orig[3] = GenTestScopeMetrics() + orig[4] = NewScopeMetrics() + return orig +} + +func GenTestScopeMetricsSlice() []ScopeMetrics { + orig := make([]ScopeMetrics, 5) + orig[1] = *GenTestScopeMetrics() + orig[3] = *GenTestScopeMetrics() + return orig +} diff --git a/pdata/internal/generated_wrapper_scopemetrics_test.go b/pdata/internal/generated_proto_scopemetrics_test.go similarity index 52% rename from pdata/internal/generated_wrapper_scopemetrics_test.go rename to pdata/internal/generated_proto_scopemetrics_test.go index c48f3c49fd6..b00c5a6f280 100644 --- a/pdata/internal/generated_wrapper_scopemetrics_test.go +++ b/pdata/internal/generated_proto_scopemetrics_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigScopeMetrics(t *testing.T) { +func TestCopyScopeMetrics(t *testing.T) { for name, src := range genTestEncodingValuesScopeMetrics() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigScopeMetrics(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigScopeMetrics() - CopyOrigScopeMetrics(dest, src) + dest := NewScopeMetrics() + CopyScopeMetrics(dest, src) assert.Equal(t, src, dest) - CopyOrigScopeMetrics(dest, dest) + CopyScopeMetrics(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigScopeMetricsUnknown(t *testing.T) { +func TestCopyScopeMetricsSlice(t *testing.T) { + src := []ScopeMetrics{} + dest := []ScopeMetrics{} + // Test CopyTo empty + dest = CopyScopeMetricsSlice(dest, src) + assert.Equal(t, []ScopeMetrics{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeMetricsSlice() + dest = CopyScopeMetricsSlice(dest, src) + assert.Equal(t, GenTestScopeMetricsSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeMetricsSlice(dest, src) + assert.Equal(t, GenTestScopeMetricsSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeMetricsSlice(dest, []ScopeMetrics{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeMetricsSlice(dest, src) + assert.Equal(t, GenTestScopeMetricsSlice(), dest) +} + +func TestCopyScopeMetricsPtrSlice(t *testing.T) { + src := []*ScopeMetrics{} + dest := []*ScopeMetrics{} + // Test CopyTo empty + dest = CopyScopeMetricsPtrSlice(dest, src) + assert.Equal(t, []*ScopeMetrics{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeMetricsPtrSlice() + dest = CopyScopeMetricsPtrSlice(dest, src) + assert.Equal(t, GenTestScopeMetricsPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeMetricsPtrSlice(dest, src) + assert.Equal(t, GenTestScopeMetricsPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeMetricsPtrSlice(dest, []*ScopeMetrics{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeMetricsPtrSlice(dest, src) + assert.Equal(t, GenTestScopeMetricsPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONScopeMetricsUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigScopeMetrics() - UnmarshalJSONOrigScopeMetrics(dest, iter) + dest := NewScopeMetrics() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigScopeMetrics(), dest) + assert.Equal(t, NewScopeMetrics(), dest) } -func TestMarshalAndUnmarshalJSONOrigScopeMetrics(t *testing.T) { +func TestMarshalAndUnmarshalJSONScopeMetrics(t *testing.T) { for name, src := range genTestEncodingValuesScopeMetrics() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigScopeMetrics(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigScopeMetrics(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigScopeMetrics() - UnmarshalJSONOrigScopeMetrics(dest, iter) + dest := NewScopeMetrics() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigScopeMetrics(dest, true) + DeleteScopeMetrics(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigScopeMetricsFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeMetricsFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesScopeMetrics() { t.Run(name, func(t *testing.T) { - dest := NewOrigScopeMetrics() - require.Error(t, UnmarshalProtoOrigScopeMetrics(dest, buf)) + dest := NewScopeMetrics() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigScopeMetricsUnknown(t *testing.T) { - dest := NewOrigScopeMetrics() +func TestMarshalAndUnmarshalProtoScopeMetricsUnknown(t *testing.T) { + dest := NewScopeMetrics() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigScopeMetrics(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigScopeMetrics(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewScopeMetrics(), dest) } -func TestMarshalAndUnmarshalProtoOrigScopeMetrics(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeMetrics(t *testing.T) { for name, src := range genTestEncodingValuesScopeMetrics() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigScopeMetrics(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigScopeMetrics(src)) - gotSize := MarshalProtoOrigScopeMetrics(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigScopeMetrics() - require.NoError(t, UnmarshalProtoOrigScopeMetrics(dest, buf)) + dest := NewScopeMetrics() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigScopeMetrics(dest, true) + DeleteScopeMetrics(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigScopeMetrics(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufScopeMetrics(t *testing.T) { for name, src := range genTestEncodingValuesScopeMetrics() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigScopeMetrics(src)) - gotSize := MarshalProtoOrigScopeMetrics(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.ScopeMetrics{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufScopeMetrics(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigScopeMetrics() - require.NoError(t, UnmarshalProtoOrigScopeMetrics(dest, goBuf)) + dest := NewScopeMetrics() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesScopeMetrics() map[string][]byte { } } -func genTestEncodingValuesScopeMetrics() map[string]*otlpmetrics.ScopeMetrics { - return map[string]*otlpmetrics.ScopeMetrics{ - "empty": NewOrigScopeMetrics(), - "Scope/test": {Scope: *GenTestOrigInstrumentationScope()}, - "Metrics/default_and_test": {Metrics: []*otlpmetrics.Metric{{}, GenTestOrigMetric()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, +func genTestEncodingValuesScopeMetrics() map[string]*ScopeMetrics { + return map[string]*ScopeMetrics{ + "empty": NewScopeMetrics(), + "Scope/test": {Scope: *GenTestInstrumentationScope()}, + "Metrics/test": {Metrics: []*Metric{{}, GenTestMetric()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, } } diff --git a/pdata/internal/generated_proto_scopeprofiles.go b/pdata/internal/generated_proto_scopeprofiles.go new file mode 100644 index 00000000000..c17284b1bbd --- /dev/null +++ b/pdata/internal/generated_proto_scopeprofiles.go @@ -0,0 +1,313 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ScopeProfiles is a collection of profiles from a LibraryInstrumentation. +type ScopeProfiles struct { + Scope InstrumentationScope + Profiles []*Profile + SchemaUrl string +} + +var ( + protoPoolScopeProfiles = sync.Pool{ + New: func() any { + return &ScopeProfiles{} + }, + } +) + +func NewScopeProfiles() *ScopeProfiles { + if !UseProtoPooling.IsEnabled() { + return &ScopeProfiles{} + } + return protoPoolScopeProfiles.Get().(*ScopeProfiles) +} + +func DeleteScopeProfiles(orig *ScopeProfiles, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteInstrumentationScope(&orig.Scope, false) + for i := range orig.Profiles { + DeleteProfile(orig.Profiles[i], true) + } + + orig.Reset() + if nullable { + protoPoolScopeProfiles.Put(orig) + } +} + +func CopyScopeProfiles(dest, src *ScopeProfiles) *ScopeProfiles { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewScopeProfiles() + } + CopyInstrumentationScope(&dest.Scope, &src.Scope) + + dest.Profiles = CopyProfilePtrSlice(dest.Profiles, src.Profiles) + + dest.SchemaUrl = src.SchemaUrl + + return dest +} + +func CopyScopeProfilesSlice(dest, src []ScopeProfiles) []ScopeProfiles { + var newDest []ScopeProfiles + if cap(dest) < len(src) { + newDest = make([]ScopeProfiles, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeProfiles(&dest[i], false) + } + } + for i := range src { + CopyScopeProfiles(&newDest[i], &src[i]) + } + return newDest +} + +func CopyScopeProfilesPtrSlice(dest, src []*ScopeProfiles) []*ScopeProfiles { + var newDest []*ScopeProfiles + if cap(dest) < len(src) { + newDest = make([]*ScopeProfiles, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeProfiles() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeProfiles(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeProfiles() + } + } + for i := range src { + CopyScopeProfiles(newDest[i], src[i]) + } + return newDest +} + +func (orig *ScopeProfiles) Reset() { + *orig = ScopeProfiles{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ScopeProfiles) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("scope") + orig.Scope.MarshalJSON(dest) + if len(orig.Profiles) > 0 { + dest.WriteObjectField("profiles") + dest.WriteArrayStart() + orig.Profiles[0].MarshalJSON(dest) + for i := 1; i < len(orig.Profiles); i++ { + dest.WriteMore() + orig.Profiles[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ScopeProfiles) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "scope": + + orig.Scope.UnmarshalJSON(iter) + case "profiles": + for iter.ReadArray() { + orig.Profiles = append(orig.Profiles, NewProfile()) + orig.Profiles[len(orig.Profiles)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ScopeProfiles) SizeProto() int { + var n int + var l int + _ = l + l = orig.Scope.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.Profiles { + 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 + } + return n +} + +func (orig *ScopeProfiles) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Scope.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.Profiles) - 1; i >= 0; i-- { + l = orig.Profiles[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *ScopeProfiles) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Scope.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Profiles", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Profiles = append(orig.Profiles, NewProfile()) + err = orig.Profiles[len(orig.Profiles)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestScopeProfiles() *ScopeProfiles { + orig := NewScopeProfiles() + orig.Scope = *GenTestInstrumentationScope() + orig.Profiles = []*Profile{{}, GenTestProfile()} + orig.SchemaUrl = "test_schemaurl" + return orig +} + +func GenTestScopeProfilesPtrSlice() []*ScopeProfiles { + orig := make([]*ScopeProfiles, 5) + orig[0] = NewScopeProfiles() + orig[1] = GenTestScopeProfiles() + orig[2] = NewScopeProfiles() + orig[3] = GenTestScopeProfiles() + orig[4] = NewScopeProfiles() + return orig +} + +func GenTestScopeProfilesSlice() []ScopeProfiles { + orig := make([]ScopeProfiles, 5) + orig[1] = *GenTestScopeProfiles() + orig[3] = *GenTestScopeProfiles() + return orig +} diff --git a/pdata/internal/generated_wrapper_scopeprofiles_test.go b/pdata/internal/generated_proto_scopeprofiles_test.go similarity index 52% rename from pdata/internal/generated_wrapper_scopeprofiles_test.go rename to pdata/internal/generated_proto_scopeprofiles_test.go index 9bfcc496e2e..7818bdd63b1 100644 --- a/pdata/internal/generated_wrapper_scopeprofiles_test.go +++ b/pdata/internal/generated_proto_scopeprofiles_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigScopeProfiles(t *testing.T) { +func TestCopyScopeProfiles(t *testing.T) { for name, src := range genTestEncodingValuesScopeProfiles() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigScopeProfiles(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigScopeProfiles() - CopyOrigScopeProfiles(dest, src) + dest := NewScopeProfiles() + CopyScopeProfiles(dest, src) assert.Equal(t, src, dest) - CopyOrigScopeProfiles(dest, dest) + CopyScopeProfiles(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigScopeProfilesUnknown(t *testing.T) { +func TestCopyScopeProfilesSlice(t *testing.T) { + src := []ScopeProfiles{} + dest := []ScopeProfiles{} + // Test CopyTo empty + dest = CopyScopeProfilesSlice(dest, src) + assert.Equal(t, []ScopeProfiles{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeProfilesSlice() + dest = CopyScopeProfilesSlice(dest, src) + assert.Equal(t, GenTestScopeProfilesSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeProfilesSlice(dest, src) + assert.Equal(t, GenTestScopeProfilesSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeProfilesSlice(dest, []ScopeProfiles{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeProfilesSlice(dest, src) + assert.Equal(t, GenTestScopeProfilesSlice(), dest) +} + +func TestCopyScopeProfilesPtrSlice(t *testing.T) { + src := []*ScopeProfiles{} + dest := []*ScopeProfiles{} + // Test CopyTo empty + dest = CopyScopeProfilesPtrSlice(dest, src) + assert.Equal(t, []*ScopeProfiles{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeProfilesPtrSlice() + dest = CopyScopeProfilesPtrSlice(dest, src) + assert.Equal(t, GenTestScopeProfilesPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeProfilesPtrSlice(dest, src) + assert.Equal(t, GenTestScopeProfilesPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeProfilesPtrSlice(dest, []*ScopeProfiles{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeProfilesPtrSlice(dest, src) + assert.Equal(t, GenTestScopeProfilesPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONScopeProfilesUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigScopeProfiles() - UnmarshalJSONOrigScopeProfiles(dest, iter) + dest := NewScopeProfiles() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigScopeProfiles(), dest) + assert.Equal(t, NewScopeProfiles(), dest) } -func TestMarshalAndUnmarshalJSONOrigScopeProfiles(t *testing.T) { +func TestMarshalAndUnmarshalJSONScopeProfiles(t *testing.T) { for name, src := range genTestEncodingValuesScopeProfiles() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigScopeProfiles(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigScopeProfiles(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigScopeProfiles() - UnmarshalJSONOrigScopeProfiles(dest, iter) + dest := NewScopeProfiles() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigScopeProfiles(dest, true) + DeleteScopeProfiles(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigScopeProfilesFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeProfilesFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesScopeProfiles() { t.Run(name, func(t *testing.T) { - dest := NewOrigScopeProfiles() - require.Error(t, UnmarshalProtoOrigScopeProfiles(dest, buf)) + dest := NewScopeProfiles() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigScopeProfilesUnknown(t *testing.T) { - dest := NewOrigScopeProfiles() +func TestMarshalAndUnmarshalProtoScopeProfilesUnknown(t *testing.T) { + dest := NewScopeProfiles() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigScopeProfiles(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigScopeProfiles(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewScopeProfiles(), dest) } -func TestMarshalAndUnmarshalProtoOrigScopeProfiles(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeProfiles(t *testing.T) { for name, src := range genTestEncodingValuesScopeProfiles() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigScopeProfiles(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigScopeProfiles(src)) - gotSize := MarshalProtoOrigScopeProfiles(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigScopeProfiles() - require.NoError(t, UnmarshalProtoOrigScopeProfiles(dest, buf)) + dest := NewScopeProfiles() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigScopeProfiles(dest, true) + DeleteScopeProfiles(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigScopeProfiles(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufScopeProfiles(t *testing.T) { for name, src := range genTestEncodingValuesScopeProfiles() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigScopeProfiles(src)) - gotSize := MarshalProtoOrigScopeProfiles(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.ScopeProfiles{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufScopeProfiles(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigScopeProfiles() - require.NoError(t, UnmarshalProtoOrigScopeProfiles(dest, goBuf)) + dest := NewScopeProfiles() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesScopeProfiles() map[string][]byte { } } -func genTestEncodingValuesScopeProfiles() map[string]*otlpprofiles.ScopeProfiles { - return map[string]*otlpprofiles.ScopeProfiles{ - "empty": NewOrigScopeProfiles(), - "Scope/test": {Scope: *GenTestOrigInstrumentationScope()}, - "Profiles/default_and_test": {Profiles: []*otlpprofiles.Profile{{}, GenTestOrigProfile()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, +func genTestEncodingValuesScopeProfiles() map[string]*ScopeProfiles { + return map[string]*ScopeProfiles{ + "empty": NewScopeProfiles(), + "Scope/test": {Scope: *GenTestInstrumentationScope()}, + "Profiles/test": {Profiles: []*Profile{{}, GenTestProfile()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, } } diff --git a/pdata/internal/generated_proto_scopespans.go b/pdata/internal/generated_proto_scopespans.go new file mode 100644 index 00000000000..a02a1c71557 --- /dev/null +++ b/pdata/internal/generated_proto_scopespans.go @@ -0,0 +1,313 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// ScopeSpans is a collection of spans from a LibraryInstrumentation. +type ScopeSpans struct { + Scope InstrumentationScope + Spans []*Span + SchemaUrl string +} + +var ( + protoPoolScopeSpans = sync.Pool{ + New: func() any { + return &ScopeSpans{} + }, + } +) + +func NewScopeSpans() *ScopeSpans { + if !UseProtoPooling.IsEnabled() { + return &ScopeSpans{} + } + return protoPoolScopeSpans.Get().(*ScopeSpans) +} + +func DeleteScopeSpans(orig *ScopeSpans, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteInstrumentationScope(&orig.Scope, false) + for i := range orig.Spans { + DeleteSpan(orig.Spans[i], true) + } + + orig.Reset() + if nullable { + protoPoolScopeSpans.Put(orig) + } +} + +func CopyScopeSpans(dest, src *ScopeSpans) *ScopeSpans { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewScopeSpans() + } + CopyInstrumentationScope(&dest.Scope, &src.Scope) + + dest.Spans = CopySpanPtrSlice(dest.Spans, src.Spans) + + dest.SchemaUrl = src.SchemaUrl + + return dest +} + +func CopyScopeSpansSlice(dest, src []ScopeSpans) []ScopeSpans { + var newDest []ScopeSpans + if cap(dest) < len(src) { + newDest = make([]ScopeSpans, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeSpans(&dest[i], false) + } + } + for i := range src { + CopyScopeSpans(&newDest[i], &src[i]) + } + return newDest +} + +func CopyScopeSpansPtrSlice(dest, src []*ScopeSpans) []*ScopeSpans { + var newDest []*ScopeSpans + if cap(dest) < len(src) { + newDest = make([]*ScopeSpans, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeSpans() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteScopeSpans(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewScopeSpans() + } + } + for i := range src { + CopyScopeSpans(newDest[i], src[i]) + } + return newDest +} + +func (orig *ScopeSpans) Reset() { + *orig = ScopeSpans{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ScopeSpans) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + dest.WriteObjectField("scope") + orig.Scope.MarshalJSON(dest) + if len(orig.Spans) > 0 { + dest.WriteObjectField("spans") + dest.WriteArrayStart() + orig.Spans[0].MarshalJSON(dest) + for i := 1; i < len(orig.Spans); i++ { + dest.WriteMore() + orig.Spans[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + if orig.SchemaUrl != "" { + dest.WriteObjectField("schemaUrl") + dest.WriteString(orig.SchemaUrl) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ScopeSpans) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "scope": + + orig.Scope.UnmarshalJSON(iter) + case "spans": + for iter.ReadArray() { + orig.Spans = append(orig.Spans, NewSpan()) + orig.Spans[len(orig.Spans)-1].UnmarshalJSON(iter) + } + + case "schemaUrl", "schema_url": + orig.SchemaUrl = iter.ReadString() + default: + iter.Skip() + } + } +} + +func (orig *ScopeSpans) SizeProto() int { + var n int + var l int + _ = l + l = orig.Scope.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + for i := range orig.Spans { + 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 + } + return n +} + +func (orig *ScopeSpans) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.Scope.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + for i := len(orig.Spans) - 1; i >= 0; i-- { + l = orig.Spans[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = len(orig.SchemaUrl) + if l > 0 { + pos -= l + copy(buf[pos:], orig.SchemaUrl) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *ScopeSpans) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.Scope.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Spans", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Spans = append(orig.Spans, NewSpan()) + err = orig.Spans[len(orig.Spans)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.SchemaUrl = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestScopeSpans() *ScopeSpans { + orig := NewScopeSpans() + orig.Scope = *GenTestInstrumentationScope() + orig.Spans = []*Span{{}, GenTestSpan()} + orig.SchemaUrl = "test_schemaurl" + return orig +} + +func GenTestScopeSpansPtrSlice() []*ScopeSpans { + orig := make([]*ScopeSpans, 5) + orig[0] = NewScopeSpans() + orig[1] = GenTestScopeSpans() + orig[2] = NewScopeSpans() + orig[3] = GenTestScopeSpans() + orig[4] = NewScopeSpans() + return orig +} + +func GenTestScopeSpansSlice() []ScopeSpans { + orig := make([]ScopeSpans, 5) + orig[1] = *GenTestScopeSpans() + orig[3] = *GenTestScopeSpans() + return orig +} diff --git a/pdata/internal/generated_wrapper_scopespans_test.go b/pdata/internal/generated_proto_scopespans_test.go similarity index 53% rename from pdata/internal/generated_wrapper_scopespans_test.go rename to pdata/internal/generated_proto_scopespans_test.go index 7d34d872fdb..6c84ceaf964 100644 --- a/pdata/internal/generated_wrapper_scopespans_test.go +++ b/pdata/internal/generated_proto_scopespans_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigScopeSpans(t *testing.T) { +func TestCopyScopeSpans(t *testing.T) { for name, src := range genTestEncodingValuesScopeSpans() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigScopeSpans(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigScopeSpans() - CopyOrigScopeSpans(dest, src) + dest := NewScopeSpans() + CopyScopeSpans(dest, src) assert.Equal(t, src, dest) - CopyOrigScopeSpans(dest, dest) + CopyScopeSpans(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigScopeSpansUnknown(t *testing.T) { +func TestCopyScopeSpansSlice(t *testing.T) { + src := []ScopeSpans{} + dest := []ScopeSpans{} + // Test CopyTo empty + dest = CopyScopeSpansSlice(dest, src) + assert.Equal(t, []ScopeSpans{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeSpansSlice() + dest = CopyScopeSpansSlice(dest, src) + assert.Equal(t, GenTestScopeSpansSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeSpansSlice(dest, src) + assert.Equal(t, GenTestScopeSpansSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeSpansSlice(dest, []ScopeSpans{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeSpansSlice(dest, src) + assert.Equal(t, GenTestScopeSpansSlice(), dest) +} + +func TestCopyScopeSpansPtrSlice(t *testing.T) { + src := []*ScopeSpans{} + dest := []*ScopeSpans{} + // Test CopyTo empty + dest = CopyScopeSpansPtrSlice(dest, src) + assert.Equal(t, []*ScopeSpans{}, dest) + + // Test CopyTo larger slice + src = GenTestScopeSpansPtrSlice() + dest = CopyScopeSpansPtrSlice(dest, src) + assert.Equal(t, GenTestScopeSpansPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyScopeSpansPtrSlice(dest, src) + assert.Equal(t, GenTestScopeSpansPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyScopeSpansPtrSlice(dest, []*ScopeSpans{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyScopeSpansPtrSlice(dest, src) + assert.Equal(t, GenTestScopeSpansPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONScopeSpansUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigScopeSpans() - UnmarshalJSONOrigScopeSpans(dest, iter) + dest := NewScopeSpans() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigScopeSpans(), dest) + assert.Equal(t, NewScopeSpans(), dest) } -func TestMarshalAndUnmarshalJSONOrigScopeSpans(t *testing.T) { +func TestMarshalAndUnmarshalJSONScopeSpans(t *testing.T) { for name, src := range genTestEncodingValuesScopeSpans() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigScopeSpans(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigScopeSpans(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigScopeSpans() - UnmarshalJSONOrigScopeSpans(dest, iter) + dest := NewScopeSpans() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigScopeSpans(dest, true) + DeleteScopeSpans(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigScopeSpansFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeSpansFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesScopeSpans() { t.Run(name, func(t *testing.T) { - dest := NewOrigScopeSpans() - require.Error(t, UnmarshalProtoOrigScopeSpans(dest, buf)) + dest := NewScopeSpans() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigScopeSpansUnknown(t *testing.T) { - dest := NewOrigScopeSpans() +func TestMarshalAndUnmarshalProtoScopeSpansUnknown(t *testing.T) { + dest := NewScopeSpans() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigScopeSpans(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigScopeSpans(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewScopeSpans(), dest) } -func TestMarshalAndUnmarshalProtoOrigScopeSpans(t *testing.T) { +func TestMarshalAndUnmarshalProtoScopeSpans(t *testing.T) { for name, src := range genTestEncodingValuesScopeSpans() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigScopeSpans(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigScopeSpans(src)) - gotSize := MarshalProtoOrigScopeSpans(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigScopeSpans() - require.NoError(t, UnmarshalProtoOrigScopeSpans(dest, buf)) + dest := NewScopeSpans() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigScopeSpans(dest, true) + DeleteScopeSpans(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigScopeSpans(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufScopeSpans(t *testing.T) { for name, src := range genTestEncodingValuesScopeSpans() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigScopeSpans(src)) - gotSize := MarshalProtoOrigScopeSpans(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlptrace.ScopeSpans{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufScopeSpans(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigScopeSpans() - require.NoError(t, UnmarshalProtoOrigScopeSpans(dest, goBuf)) + dest := NewScopeSpans() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesScopeSpans() map[string][]byte { } } -func genTestEncodingValuesScopeSpans() map[string]*otlptrace.ScopeSpans { - return map[string]*otlptrace.ScopeSpans{ - "empty": NewOrigScopeSpans(), - "Scope/test": {Scope: *GenTestOrigInstrumentationScope()}, - "Spans/default_and_test": {Spans: []*otlptrace.Span{{}, GenTestOrigSpan()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, +func genTestEncodingValuesScopeSpans() map[string]*ScopeSpans { + return map[string]*ScopeSpans{ + "empty": NewScopeSpans(), + "Scope/test": {Scope: *GenTestInstrumentationScope()}, + "Spans/test": {Spans: []*Span{{}, GenTestSpan()}}, + "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, } } diff --git a/pdata/internal/generated_wrapper_span.go b/pdata/internal/generated_proto_span.go similarity index 65% rename from pdata/internal/generated_wrapper_span.go rename to pdata/internal/generated_proto_span.go index d53678b0b2e..7d0ef5a6042 100644 --- a/pdata/internal/generated_wrapper_span.go +++ b/pdata/internal/generated_proto_span.go @@ -11,29 +11,47 @@ import ( "fmt" "sync" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// 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 + StartTimeUnixNano uint64 + EndTimeUnixNano uint64 + Attributes []KeyValue + DroppedAttributesCount uint32 + Events []*SpanEvent + DroppedEventsCount uint32 + Links []*SpanLink + DroppedLinksCount uint32 + Status Status +} + var ( protoPoolSpan = sync.Pool{ New: func() any { - return &otlptrace.Span{} + return &Span{} }, } ) -func NewOrigSpan() *otlptrace.Span { +func NewSpan() *Span { if !UseProtoPooling.IsEnabled() { - return &otlptrace.Span{} + return &Span{} } - return protoPoolSpan.Get().(*otlptrace.Span) + return protoPoolSpan.Get().(*Span) } -func DeleteOrigSpan(orig *otlptrace.Span, nullable bool) { +func DeleteSpan(orig *Span, nullable bool) { if orig == nil { return } @@ -43,19 +61,19 @@ func DeleteOrigSpan(orig *otlptrace.Span, nullable bool) { return } - DeleteOrigTraceID(&orig.TraceId, false) - DeleteOrigSpanID(&orig.SpanId, false) - DeleteOrigSpanID(&orig.ParentSpanId, false) + DeleteTraceID(&orig.TraceId, false) + DeleteSpanID(&orig.SpanId, false) + DeleteSpanID(&orig.ParentSpanId, false) for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } for i := range orig.Events { - DeleteOrigSpan_Event(orig.Events[i], true) + DeleteSpanEvent(orig.Events[i], true) } for i := range orig.Links { - DeleteOrigSpan_Link(orig.Links[i], true) + DeleteSpanLink(orig.Links[i], true) } - DeleteOrigStatus(&orig.Status, false) + DeleteStatus(&orig.Status, false) orig.Reset() if nullable { @@ -63,68 +81,124 @@ func DeleteOrigSpan(orig *otlptrace.Span, nullable bool) { } } -func CopyOrigSpan(dest, src *otlptrace.Span) { +func CopySpan(dest, src *Span) *Span { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSpan() } - dest.TraceId = src.TraceId - dest.SpanId = src.SpanId - CopyOrigTraceState(&dest.TraceState, &src.TraceState) - dest.ParentSpanId = src.ParentSpanId + CopyTraceID(&dest.TraceId, &src.TraceId) + + 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 = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.Events = CopyOrigSpan_EventSlice(dest.Events, src.Events) + + dest.Events = CopySpanEventPtrSlice(dest.Events, src.Events) + dest.DroppedEventsCount = src.DroppedEventsCount - dest.Links = CopyOrigSpan_LinkSlice(dest.Links, src.Links) + + dest.Links = CopySpanLinkPtrSlice(dest.Links, src.Links) + dest.DroppedLinksCount = src.DroppedLinksCount - CopyOrigStatus(&dest.Status, &src.Status) + + CopyStatus(&dest.Status, &src.Status) + + return dest } -func GenTestOrigSpan() *otlptrace.Span { - orig := NewOrigSpan() - orig.TraceId = data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - orig.SpanId = data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) - orig.TraceState = *GenTestOrigTraceState() - orig.ParentSpanId = data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) - orig.Flags = uint32(13) - orig.Name = "test_name" - orig.Kind = otlptrace.Span_SpanKind(3) - orig.StartTimeUnixNano = 1234567890 - orig.EndTimeUnixNano = 1234567890 - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.DroppedAttributesCount = uint32(13) - orig.Events = GenerateOrigTestSpan_EventSlice() - orig.DroppedEventsCount = uint32(13) - orig.Links = GenerateOrigTestSpan_LinkSlice() - orig.DroppedLinksCount = uint32(13) - orig.Status = *GenTestOrigStatus() - return orig +func CopySpanSlice(dest, src []Span) []Span { + var newDest []Span + if cap(dest) < len(src) { + newDest = make([]Span, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpan(&dest[i], false) + } + } + for i := range src { + CopySpan(&newDest[i], &src[i]) + } + return newDest +} + +func CopySpanPtrSlice(dest, src []*Span) []*Span { + var newDest []*Span + if cap(dest) < len(src) { + newDest = make([]*Span, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpan() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpan(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpan() + } + } + for i := range src { + CopySpan(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSpan(orig *otlptrace.Span, dest *json.Stream) { +func (orig *Span) Reset() { + *orig = Span{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Span) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() - if orig.TraceId != data.TraceID([16]byte{}) { + if !orig.TraceId.IsEmpty() { dest.WriteObjectField("traceId") - MarshalJSONOrigTraceID(&orig.TraceId, dest) + orig.TraceId.MarshalJSON(dest) } - if orig.SpanId != data.SpanID([8]byte{}) { + if !orig.SpanId.IsEmpty() { dest.WriteObjectField("spanId") - MarshalJSONOrigSpanID(&orig.SpanId, dest) + orig.SpanId.MarshalJSON(dest) } if orig.TraceState != "" { dest.WriteObjectField("traceState") dest.WriteString(orig.TraceState) } - if orig.ParentSpanId != data.SpanID([8]byte{}) { + if !orig.ParentSpanId.IsEmpty() { dest.WriteObjectField("parentSpanId") - MarshalJSONOrigSpanID(&orig.ParentSpanId, dest) + orig.ParentSpanId.MarshalJSON(dest) } if orig.Flags != uint32(0) { dest.WriteObjectField("flags") @@ -150,10 +224,10 @@ func MarshalJSONOrigSpan(orig *otlptrace.Span, dest *json.Stream) { if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -164,10 +238,10 @@ func MarshalJSONOrigSpan(orig *otlptrace.Span, dest *json.Stream) { if len(orig.Events) > 0 { dest.WriteObjectField("events") dest.WriteArrayStart() - MarshalJSONOrigSpan_Event(orig.Events[0], dest) + orig.Events[0].MarshalJSON(dest) for i := 1; i < len(orig.Events); i++ { dest.WriteMore() - MarshalJSONOrigSpan_Event(orig.Events[i], dest) + orig.Events[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -178,10 +252,10 @@ func MarshalJSONOrigSpan(orig *otlptrace.Span, dest *json.Stream) { if len(orig.Links) > 0 { dest.WriteObjectField("links") dest.WriteArrayStart() - MarshalJSONOrigSpan_Link(orig.Links[0], dest) + orig.Links[0].MarshalJSON(dest) for i := 1; i < len(orig.Links); i++ { dest.WriteMore() - MarshalJSONOrigSpan_Link(orig.Links[i], dest) + orig.Links[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -190,77 +264,81 @@ func MarshalJSONOrigSpan(orig *otlptrace.Span, dest *json.Stream) { dest.WriteUint32(orig.DroppedLinksCount) } dest.WriteObjectField("status") - MarshalJSONOrigStatus(&orig.Status, dest) + orig.Status.MarshalJSON(dest) dest.WriteObjectEnd() } -// UnmarshalJSONOrigSpan unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSpan(orig *otlptrace.Span, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Span) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "traceId", "trace_id": - UnmarshalJSONOrigTraceID(&orig.TraceId, iter) + + orig.TraceId.UnmarshalJSON(iter) case "spanId", "span_id": - UnmarshalJSONOrigSpanID(&orig.SpanId, iter) + + orig.SpanId.UnmarshalJSON(iter) case "traceState", "trace_state": orig.TraceState = iter.ReadString() case "parentSpanId", "parent_span_id": - UnmarshalJSONOrigSpanID(&orig.ParentSpanId, iter) + + orig.ParentSpanId.UnmarshalJSON(iter) case "flags": orig.Flags = iter.ReadUint32() case "name": orig.Name = iter.ReadString() case "kind": - orig.Kind = otlptrace.Span_SpanKind(iter.ReadEnumValue(otlptrace.Span_SpanKind_value)) + orig.Kind = SpanKind(iter.ReadEnumValue(SpanKind_value)) case "startTimeUnixNano", "start_time_unix_nano": orig.StartTimeUnixNano = iter.ReadUint64() case "endTimeUnixNano", "end_time_unix_nano": orig.EndTimeUnixNano = iter.ReadUint64() case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "droppedAttributesCount", "dropped_attributes_count": orig.DroppedAttributesCount = iter.ReadUint32() case "events": for iter.ReadArray() { - orig.Events = append(orig.Events, NewOrigSpan_Event()) - UnmarshalJSONOrigSpan_Event(orig.Events[len(orig.Events)-1], iter) + orig.Events = append(orig.Events, NewSpanEvent()) + orig.Events[len(orig.Events)-1].UnmarshalJSON(iter) } case "droppedEventsCount", "dropped_events_count": orig.DroppedEventsCount = iter.ReadUint32() case "links": for iter.ReadArray() { - orig.Links = append(orig.Links, NewOrigSpan_Link()) - UnmarshalJSONOrigSpan_Link(orig.Links[len(orig.Links)-1], iter) + orig.Links = append(orig.Links, NewSpanLink()) + orig.Links[len(orig.Links)-1].UnmarshalJSON(iter) } case "droppedLinksCount", "dropped_links_count": orig.DroppedLinksCount = iter.ReadUint32() case "status": - UnmarshalJSONOrigStatus(&orig.Status, iter) + + orig.Status.UnmarshalJSON(iter) default: iter.Skip() } } } -func SizeProtoOrigSpan(orig *otlptrace.Span) int { +func (orig *Span) SizeProto() int { var n int var l int _ = l - l = SizeProtoOrigTraceID(&orig.TraceId) + l = orig.TraceId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - l = SizeProtoOrigSpanID(&orig.SpanId) + 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 = SizeProtoOrigSpanID(&orig.ParentSpanId) + l = orig.ParentSpanId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l if orig.Flags != 0 { n += 6 @@ -279,43 +357,42 @@ func SizeProtoOrigSpan(orig *otlptrace.Span) int { n += 9 } for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.DroppedAttributesCount != 0 { n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) } for i := range orig.Events { - l = SizeProtoOrigSpan_Event(orig.Events[i]) + l = orig.Events[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.DroppedEventsCount != 0 { n += 1 + proto.Sov(uint64(orig.DroppedEventsCount)) } for i := range orig.Links { - l = SizeProtoOrigSpan_Link(orig.Links[i]) + l = orig.Links[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.DroppedLinksCount != 0 { n += 1 + proto.Sov(uint64(orig.DroppedLinksCount)) } - l = SizeProtoOrigStatus(&orig.Status) + l = orig.Status.SizeProto() n += 1 + proto.Sov(uint64(l)) + l return n } -func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { +func (orig *Span) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - - l = MarshalProtoOrigTraceID(&orig.TraceId, buf[:pos]) + l = orig.TraceId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0xa - l = MarshalProtoOrigSpanID(&orig.SpanId, buf[:pos]) + l = orig.SpanId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -329,8 +406,7 @@ func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { pos-- buf[pos] = 0x1a } - - l = MarshalProtoOrigSpanID(&orig.ParentSpanId, buf[:pos]) + l = orig.ParentSpanId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -370,7 +446,7 @@ func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { buf[pos] = 0x41 } for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -382,7 +458,7 @@ func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { buf[pos] = 0x50 } for i := len(orig.Events) - 1; i >= 0; i-- { - l = MarshalProtoOrigSpan_Event(orig.Events[i], buf[:pos]) + l = orig.Events[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -394,7 +470,7 @@ func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { buf[pos] = 0x60 } for i := len(orig.Links) - 1; i >= 0; i-- { - l = MarshalProtoOrigSpan_Link(orig.Links[i], buf[:pos]) + l = orig.Links[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -405,8 +481,7 @@ func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { pos-- buf[pos] = 0x70 } - - l = MarshalProtoOrigStatus(&orig.Status, buf[:pos]) + l = orig.Status.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -415,7 +490,7 @@ func MarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { +func (orig *Span) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -441,7 +516,7 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigTraceID(&orig.TraceId, buf[startPos:pos]) + err = orig.TraceId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -457,7 +532,7 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigSpanID(&orig.SpanId, buf[startPos:pos]) + err = orig.SpanId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -485,7 +560,7 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigSpanID(&orig.ParentSpanId, buf[startPos:pos]) + err = orig.ParentSpanId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -524,7 +599,7 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { return err } - orig.Kind = otlptrace.Span_SpanKind(num) + orig.Kind = SpanKind(num) case 7: if wireType != proto.WireTypeI64 { @@ -560,8 +635,8 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -588,8 +663,8 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { return err } startPos := pos - length - orig.Events = append(orig.Events, NewOrigSpan_Event()) - err = UnmarshalProtoOrigSpan_Event(orig.Events[len(orig.Events)-1], buf[startPos:pos]) + orig.Events = append(orig.Events, NewSpanEvent()) + err = orig.Events[len(orig.Events)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -616,8 +691,8 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { return err } startPos := pos - length - orig.Links = append(orig.Links, NewOrigSpan_Link()) - err = UnmarshalProtoOrigSpan_Link(orig.Links[len(orig.Links)-1], buf[startPos:pos]) + orig.Links = append(orig.Links, NewSpanLink()) + err = orig.Links[len(orig.Links)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -645,7 +720,7 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigStatus(&orig.Status, buf[startPos:pos]) + err = orig.Status.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -658,3 +733,41 @@ func UnmarshalProtoOrigSpan(orig *otlptrace.Span, buf []byte) error { } return nil } + +func GenTestSpan() *Span { + orig := NewSpan() + orig.TraceId = *GenTestTraceID() + orig.SpanId = *GenTestSpanID() + orig.TraceState = "test_tracestate" + orig.ParentSpanId = *GenTestSpanID() + orig.Flags = uint32(13) + orig.Name = "test_name" + orig.Kind = SpanKind(13) + orig.StartTimeUnixNano = uint64(13) + orig.EndTimeUnixNano = uint64(13) + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.DroppedAttributesCount = uint32(13) + orig.Events = []*SpanEvent{{}, GenTestSpanEvent()} + orig.DroppedEventsCount = uint32(13) + orig.Links = []*SpanLink{{}, GenTestSpanLink()} + orig.DroppedLinksCount = uint32(13) + orig.Status = *GenTestStatus() + return orig +} + +func GenTestSpanPtrSlice() []*Span { + orig := make([]*Span, 5) + orig[0] = NewSpan() + orig[1] = GenTestSpan() + orig[2] = NewSpan() + orig[3] = GenTestSpan() + orig[4] = NewSpan() + return orig +} + +func GenTestSpanSlice() []Span { + orig := make([]Span, 5) + orig[1] = *GenTestSpan() + orig[3] = *GenTestSpan() + return orig +} diff --git a/pdata/internal/generated_wrapper_span_test.go b/pdata/internal/generated_proto_span_test.go similarity index 63% rename from pdata/internal/generated_wrapper_span_test.go rename to pdata/internal/generated_proto_span_test.go index 97dd7e97d14..07667ac9006 100644 --- a/pdata/internal/generated_wrapper_span_test.go +++ b/pdata/internal/generated_proto_span_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSpan(t *testing.T) { +func TestCopySpan(t *testing.T) { for name, src := range genTestEncodingValuesSpan() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigSpan(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSpan() - CopyOrigSpan(dest, src) + dest := NewSpan() + CopySpan(dest, src) assert.Equal(t, src, dest) - CopyOrigSpan(dest, dest) + CopySpan(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSpanUnknown(t *testing.T) { +func TestCopySpanSlice(t *testing.T) { + src := []Span{} + dest := []Span{} + // Test CopyTo empty + dest = CopySpanSlice(dest, src) + assert.Equal(t, []Span{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanSlice() + dest = CopySpanSlice(dest, src) + assert.Equal(t, GenTestSpanSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanSlice(dest, src) + assert.Equal(t, GenTestSpanSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanSlice(dest, []Span{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanSlice(dest, src) + assert.Equal(t, GenTestSpanSlice(), dest) +} + +func TestCopySpanPtrSlice(t *testing.T) { + src := []*Span{} + dest := []*Span{} + // Test CopyTo empty + dest = CopySpanPtrSlice(dest, src) + assert.Equal(t, []*Span{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanPtrSlice() + dest = CopySpanPtrSlice(dest, src) + assert.Equal(t, GenTestSpanPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanPtrSlice(dest, src) + assert.Equal(t, GenTestSpanPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanPtrSlice(dest, []*Span{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanPtrSlice(dest, src) + assert.Equal(t, GenTestSpanPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSpanUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSpan() - UnmarshalJSONOrigSpan(dest, iter) + dest := NewSpan() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSpan(), dest) + assert.Equal(t, NewSpan(), dest) } -func TestMarshalAndUnmarshalJSONOrigSpan(t *testing.T) { +func TestMarshalAndUnmarshalJSONSpan(t *testing.T) { for name, src := range genTestEncodingValuesSpan() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigSpan(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSpan(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSpan() - UnmarshalJSONOrigSpan(dest, iter) + dest := NewSpan() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSpan(dest, true) + DeleteSpan(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSpanFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoSpanFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesSpan() { t.Run(name, func(t *testing.T) { - dest := NewOrigSpan() - require.Error(t, UnmarshalProtoOrigSpan(dest, buf)) + dest := NewSpan() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSpanUnknown(t *testing.T) { - dest := NewOrigSpan() +func TestMarshalAndUnmarshalProtoSpanUnknown(t *testing.T) { + dest := NewSpan() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSpan(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSpan(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSpan(), dest) } -func TestMarshalAndUnmarshalProtoOrigSpan(t *testing.T) { +func TestMarshalAndUnmarshalProtoSpan(t *testing.T) { for name, src := range genTestEncodingValuesSpan() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigSpan(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSpan(src)) - gotSize := MarshalProtoOrigSpan(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSpan() - require.NoError(t, UnmarshalProtoOrigSpan(dest, buf)) + dest := NewSpan() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSpan(dest, true) + DeleteSpan(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigSpan(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufSpan(t *testing.T) { for name, src := range genTestEncodingValuesSpan() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSpan(src)) - gotSize := MarshalProtoOrigSpan(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlptrace.Span{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufSpan(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSpan() - require.NoError(t, UnmarshalProtoOrigSpan(dest, goBuf)) + dest := NewSpan() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -176,24 +224,24 @@ func genTestFailingUnmarshalProtoValuesSpan() map[string][]byte { } } -func genTestEncodingValuesSpan() map[string]*otlptrace.Span { - return map[string]*otlptrace.Span{ - "empty": NewOrigSpan(), - "TraceId/test": {TraceId: *GenTestOrigTraceID()}, - "SpanId/test": {SpanId: *GenTestOrigSpanID()}, +func genTestEncodingValuesSpan() map[string]*Span { + return map[string]*Span{ + "empty": NewSpan(), + "TraceId/test": {TraceId: *GenTestTraceID()}, + "SpanId/test": {SpanId: *GenTestSpanID()}, "TraceState/test": {TraceState: "test_tracestate"}, - "ParentSpanId/test": {ParentSpanId: *GenTestOrigSpanID()}, + "ParentSpanId/test": {ParentSpanId: *GenTestSpanID()}, "Flags/test": {Flags: uint32(13)}, "Name/test": {Name: "test_name"}, - "Kind/test": {Kind: otlptrace.Span_SpanKind(13)}, + "Kind/test": {Kind: SpanKind(13)}, "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, "EndTimeUnixNano/test": {EndTimeUnixNano: uint64(13)}, - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, - "Events/default_and_test": {Events: []*otlptrace.Span_Event{{}, GenTestOrigSpan_Event()}}, + "Events/test": {Events: []*SpanEvent{{}, GenTestSpanEvent()}}, "DroppedEventsCount/test": {DroppedEventsCount: uint32(13)}, - "Links/default_and_test": {Links: []*otlptrace.Span_Link{{}, GenTestOrigSpan_Link()}}, + "Links/test": {Links: []*SpanLink{{}, GenTestSpanLink()}}, "DroppedLinksCount/test": {DroppedLinksCount: uint32(13)}, - "Status/test": {Status: *GenTestOrigStatus()}, + "Status/test": {Status: *GenTestStatus()}, } } diff --git a/pdata/internal/generated_proto_spancontext.go b/pdata/internal/generated_proto_spancontext.go new file mode 100644 index 00000000000..7d78787004d --- /dev/null +++ b/pdata/internal/generated_proto_spancontext.go @@ -0,0 +1,367 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type SpanContext struct { + TraceID TraceID + SpanID SpanID + TraceFlags uint32 + TraceState string + Remote bool +} + +var ( + protoPoolSpanContext = sync.Pool{ + New: func() any { + return &SpanContext{} + }, + } +) + +func NewSpanContext() *SpanContext { + if !UseProtoPooling.IsEnabled() { + return &SpanContext{} + } + return protoPoolSpanContext.Get().(*SpanContext) +} + +func DeleteSpanContext(orig *SpanContext, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteTraceID(&orig.TraceID, false) + DeleteSpanID(&orig.SpanID, false) + + orig.Reset() + if nullable { + protoPoolSpanContext.Put(orig) + } +} + +func CopySpanContext(dest, src *SpanContext) *SpanContext { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSpanContext() + } + CopyTraceID(&dest.TraceID, &src.TraceID) + + CopySpanID(&dest.SpanID, &src.SpanID) + + dest.TraceFlags = src.TraceFlags + + dest.TraceState = src.TraceState + + dest.Remote = src.Remote + + return dest +} + +func CopySpanContextSlice(dest, src []SpanContext) []SpanContext { + var newDest []SpanContext + if cap(dest) < len(src) { + newDest = make([]SpanContext, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpanContext(&dest[i], false) + } + } + for i := range src { + CopySpanContext(&newDest[i], &src[i]) + } + return newDest +} + +func CopySpanContextPtrSlice(dest, src []*SpanContext) []*SpanContext { + var newDest []*SpanContext + if cap(dest) < len(src) { + newDest = make([]*SpanContext, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpanContext() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpanContext(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpanContext() + } + } + for i := range src { + CopySpanContext(newDest[i], src[i]) + } + return newDest +} + +func (orig *SpanContext) Reset() { + *orig = SpanContext{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *SpanContext) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if !orig.TraceID.IsEmpty() { + dest.WriteObjectField("traceID") + orig.TraceID.MarshalJSON(dest) + } + if !orig.SpanID.IsEmpty() { + dest.WriteObjectField("spanID") + orig.SpanID.MarshalJSON(dest) + } + if orig.TraceFlags != uint32(0) { + dest.WriteObjectField("traceFlags") + dest.WriteUint32(orig.TraceFlags) + } + if orig.TraceState != "" { + dest.WriteObjectField("traceState") + dest.WriteString(orig.TraceState) + } + if orig.Remote != false { + dest.WriteObjectField("remote") + dest.WriteBool(orig.Remote) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *SpanContext) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "traceID", "trace_id": + + orig.TraceID.UnmarshalJSON(iter) + case "spanID", "span_id": + + orig.SpanID.UnmarshalJSON(iter) + case "traceFlags", "trace_flags": + orig.TraceFlags = iter.ReadUint32() + case "traceState", "trace_state": + orig.TraceState = iter.ReadString() + case "remote": + orig.Remote = iter.ReadBool() + default: + iter.Skip() + } + } +} + +func (orig *SpanContext) SizeProto() int { + var n int + var l int + _ = l + l = orig.TraceID.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + l = orig.SpanID.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + if orig.TraceFlags != 0 { + n += 5 + } + l = len(orig.TraceState) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + if orig.Remote { + n += 2 + } + return n +} + +func (orig *SpanContext) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = orig.TraceID.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + + l = orig.SpanID.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + + if orig.TraceFlags != 0 { + pos -= 4 + binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.TraceFlags)) + pos-- + buf[pos] = 0x1d + } + l = len(orig.TraceState) + if l > 0 { + pos -= l + copy(buf[pos:], orig.TraceState) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x22 + } + if orig.Remote { + pos-- + if orig.Remote { + buf[pos] = 1 + } else { + buf[pos] = 0 + } + pos-- + buf[pos] = 0x28 + } + return len(buf) - pos +} + +func (orig *SpanContext) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field TraceID", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.TraceID.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field SpanID", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.SpanID.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeI32 { + return fmt.Errorf("proto: wrong wireType = %d for field TraceFlags", wireType) + } + var num uint32 + num, pos, err = proto.ConsumeI32(buf, pos) + if err != nil { + return err + } + + orig.TraceFlags = uint32(num) + + case 4: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field TraceState", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.TraceState = string(buf[startPos:pos]) + + case 5: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field Remote", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.Remote = num != 0 + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestSpanContext() *SpanContext { + orig := NewSpanContext() + orig.TraceID = *GenTestTraceID() + orig.SpanID = *GenTestSpanID() + orig.TraceFlags = uint32(13) + orig.TraceState = "test_tracestate" + orig.Remote = true + return orig +} + +func GenTestSpanContextPtrSlice() []*SpanContext { + orig := make([]*SpanContext, 5) + orig[0] = NewSpanContext() + orig[1] = GenTestSpanContext() + orig[2] = NewSpanContext() + orig[3] = GenTestSpanContext() + orig[4] = NewSpanContext() + return orig +} + +func GenTestSpanContextSlice() []SpanContext { + orig := make([]SpanContext, 5) + orig[1] = *GenTestSpanContext() + orig[3] = *GenTestSpanContext() + return orig +} diff --git a/pdata/internal/generated_proto_spancontext_test.go b/pdata/internal/generated_proto_spancontext_test.go new file mode 100644 index 00000000000..47b79925f7d --- /dev/null +++ b/pdata/internal/generated_proto_spancontext_test.go @@ -0,0 +1,214 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopySpanContext(t *testing.T) { + for name, src := range genTestEncodingValuesSpanContext() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewSpanContext() + CopySpanContext(dest, src) + assert.Equal(t, src, dest) + CopySpanContext(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopySpanContextSlice(t *testing.T) { + src := []SpanContext{} + dest := []SpanContext{} + // Test CopyTo empty + dest = CopySpanContextSlice(dest, src) + assert.Equal(t, []SpanContext{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanContextSlice() + dest = CopySpanContextSlice(dest, src) + assert.Equal(t, GenTestSpanContextSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanContextSlice(dest, src) + assert.Equal(t, GenTestSpanContextSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanContextSlice(dest, []SpanContext{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanContextSlice(dest, src) + assert.Equal(t, GenTestSpanContextSlice(), dest) +} + +func TestCopySpanContextPtrSlice(t *testing.T) { + src := []*SpanContext{} + dest := []*SpanContext{} + // Test CopyTo empty + dest = CopySpanContextPtrSlice(dest, src) + assert.Equal(t, []*SpanContext{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanContextPtrSlice() + dest = CopySpanContextPtrSlice(dest, src) + assert.Equal(t, GenTestSpanContextPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanContextPtrSlice(dest, src) + assert.Equal(t, GenTestSpanContextPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanContextPtrSlice(dest, []*SpanContext{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanContextPtrSlice(dest, src) + assert.Equal(t, GenTestSpanContextPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSpanContextUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewSpanContext() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewSpanContext(), dest) +} + +func TestMarshalAndUnmarshalJSONSpanContext(t *testing.T) { + for name, src := range genTestEncodingValuesSpanContext() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewSpanContext() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteSpanContext(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoSpanContextFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesSpanContext() { + t.Run(name, func(t *testing.T) { + dest := NewSpanContext() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoSpanContextUnknown(t *testing.T) { + dest := NewSpanContext() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSpanContext(), dest) +} + +func TestMarshalAndUnmarshalProtoSpanContext(t *testing.T) { + for name, src := range genTestEncodingValuesSpanContext() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewSpanContext() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteSpanContext(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufSpanContext(t *testing.T) { + for name, src := range genTestEncodingValuesSpanContext() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewSpanContext() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesSpanContext() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "TraceID/wrong_wire_type": {0xc}, + "TraceID/missing_value": {0xa}, + "SpanID/wrong_wire_type": {0x14}, + "SpanID/missing_value": {0x12}, + "TraceFlags/wrong_wire_type": {0x1c}, + "TraceFlags/missing_value": {0x1d}, + "TraceState/wrong_wire_type": {0x24}, + "TraceState/missing_value": {0x22}, + "Remote/wrong_wire_type": {0x2c}, + "Remote/missing_value": {0x28}, + } +} + +func genTestEncodingValuesSpanContext() map[string]*SpanContext { + return map[string]*SpanContext{ + "empty": NewSpanContext(), + "TraceID/test": {TraceID: *GenTestTraceID()}, + "SpanID/test": {SpanID: *GenTestSpanID()}, + "TraceFlags/test": {TraceFlags: uint32(13)}, + "TraceState/test": {TraceState: "test_tracestate"}, + "Remote/test": {Remote: true}, + } +} diff --git a/pdata/internal/generated_wrapper_span_event.go b/pdata/internal/generated_proto_spanevent.go similarity index 54% rename from pdata/internal/generated_wrapper_span_event.go rename to pdata/internal/generated_proto_spanevent.go index 8931b6267cc..14c0fe1627c 100644 --- a/pdata/internal/generated_wrapper_span_event.go +++ b/pdata/internal/generated_proto_spanevent.go @@ -11,28 +11,35 @@ import ( "fmt" "sync" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// 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 + DroppedAttributesCount uint32 +} + var ( - protoPoolSpan_Event = sync.Pool{ + protoPoolSpanEvent = sync.Pool{ New: func() any { - return &otlptrace.Span_Event{} + return &SpanEvent{} }, } ) -func NewOrigSpan_Event() *otlptrace.Span_Event { +func NewSpanEvent() *SpanEvent { if !UseProtoPooling.IsEnabled() { - return &otlptrace.Span_Event{} + return &SpanEvent{} } - return protoPoolSpan_Event.Get().(*otlptrace.Span_Event) + return protoPoolSpanEvent.Get().(*SpanEvent) } -func DeleteOrigSpan_Event(orig *otlptrace.Span_Event, nullable bool) { +func DeleteSpanEvent(orig *SpanEvent, nullable bool) { if orig == nil { return } @@ -43,37 +50,93 @@ func DeleteOrigSpan_Event(orig *otlptrace.Span_Event, nullable bool) { } for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } orig.Reset() if nullable { - protoPoolSpan_Event.Put(orig) + protoPoolSpanEvent.Put(orig) } } -func CopyOrigSpan_Event(dest, src *otlptrace.Span_Event) { +func CopySpanEvent(dest, src *SpanEvent) *SpanEvent { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSpanEvent() } dest.TimeUnixNano = src.TimeUnixNano + dest.Name = src.Name - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + dest.Attributes = CopyKeyValueSlice(dest.Attributes, src.Attributes) + dest.DroppedAttributesCount = src.DroppedAttributesCount + + return dest } -func GenTestOrigSpan_Event() *otlptrace.Span_Event { - orig := NewOrigSpan_Event() - orig.TimeUnixNano = 1234567890 - orig.Name = "test_name" - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.DroppedAttributesCount = uint32(13) - return orig +func CopySpanEventSlice(dest, src []SpanEvent) []SpanEvent { + var newDest []SpanEvent + if cap(dest) < len(src) { + newDest = make([]SpanEvent, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpanEvent(&dest[i], false) + } + } + for i := range src { + CopySpanEvent(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSpan_Event(orig *otlptrace.Span_Event, dest *json.Stream) { +func CopySpanEventPtrSlice(dest, src []*SpanEvent) []*SpanEvent { + var newDest []*SpanEvent + if cap(dest) < len(src) { + newDest = make([]*SpanEvent, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpanEvent() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpanEvent(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpanEvent() + } + } + for i := range src { + CopySpanEvent(newDest[i], src[i]) + } + return newDest +} + +func (orig *SpanEvent) Reset() { + *orig = SpanEvent{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *SpanEvent) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.TimeUnixNano != uint64(0) { dest.WriteObjectField("timeUnixNano") @@ -86,10 +149,10 @@ func MarshalJSONOrigSpan_Event(orig *otlptrace.Span_Event, dest *json.Stream) { if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -100,8 +163,8 @@ func MarshalJSONOrigSpan_Event(orig *otlptrace.Span_Event, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigSpanEvent unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSpan_Event(orig *otlptrace.Span_Event, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *SpanEvent) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "timeUnixNano", "time_unix_nano": @@ -110,8 +173,8 @@ func UnmarshalJSONOrigSpan_Event(orig *otlptrace.Span_Event, iter *json.Iterator orig.Name = iter.ReadString() case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "droppedAttributesCount", "dropped_attributes_count": @@ -122,7 +185,7 @@ func UnmarshalJSONOrigSpan_Event(orig *otlptrace.Span_Event, iter *json.Iterator } } -func SizeProtoOrigSpan_Event(orig *otlptrace.Span_Event) int { +func (orig *SpanEvent) SizeProto() int { var n int var l int _ = l @@ -134,7 +197,7 @@ func SizeProtoOrigSpan_Event(orig *otlptrace.Span_Event) int { n += 1 + proto.Sov(uint64(l)) + l } for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.DroppedAttributesCount != 0 { @@ -143,7 +206,7 @@ func SizeProtoOrigSpan_Event(orig *otlptrace.Span_Event) int { return n } -func MarshalProtoOrigSpan_Event(orig *otlptrace.Span_Event, buf []byte) int { +func (orig *SpanEvent) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -162,7 +225,7 @@ func MarshalProtoOrigSpan_Event(orig *otlptrace.Span_Event, buf []byte) int { buf[pos] = 0x12 } for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -176,7 +239,7 @@ func MarshalProtoOrigSpan_Event(orig *otlptrace.Span_Event, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigSpan_Event(orig *otlptrace.Span_Event, buf []byte) error { +func (orig *SpanEvent) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -225,8 +288,8 @@ func UnmarshalProtoOrigSpan_Event(orig *otlptrace.Span_Event, buf []byte) error return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -251,3 +314,29 @@ func UnmarshalProtoOrigSpan_Event(orig *otlptrace.Span_Event, buf []byte) error } return nil } + +func GenTestSpanEvent() *SpanEvent { + orig := NewSpanEvent() + orig.TimeUnixNano = uint64(13) + orig.Name = "test_name" + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.DroppedAttributesCount = uint32(13) + return orig +} + +func GenTestSpanEventPtrSlice() []*SpanEvent { + orig := make([]*SpanEvent, 5) + orig[0] = NewSpanEvent() + orig[1] = GenTestSpanEvent() + orig[2] = NewSpanEvent() + orig[3] = GenTestSpanEvent() + orig[4] = NewSpanEvent() + return orig +} + +func GenTestSpanEventSlice() []SpanEvent { + orig := make([]SpanEvent, 5) + orig[1] = *GenTestSpanEvent() + orig[3] = *GenTestSpanEvent() + return orig +} diff --git a/pdata/internal/generated_wrapper_span_event_test.go b/pdata/internal/generated_proto_spanevent_test.go similarity index 50% rename from pdata/internal/generated_wrapper_span_event_test.go rename to pdata/internal/generated_proto_spanevent_test.go index 280c7bf99ec..5b2e24feb83 100644 --- a/pdata/internal/generated_wrapper_span_event_test.go +++ b/pdata/internal/generated_proto_spanevent_test.go @@ -16,13 +16,11 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSpan_Event(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Event() { +func TestCopySpanEvent(t *testing.T) { + for name, src := range genTestEncodingValuesSpanEvent() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { prevPooling := UseProtoPooling.IsEnabled() @@ -31,27 +29,77 @@ func TestCopyOrigSpan_Event(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSpan_Event() - CopyOrigSpan_Event(dest, src) + dest := NewSpanEvent() + CopySpanEvent(dest, src) assert.Equal(t, src, dest) - CopyOrigSpan_Event(dest, dest) + CopySpanEvent(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSpan_EventUnknown(t *testing.T) { +func TestCopySpanEventSlice(t *testing.T) { + src := []SpanEvent{} + dest := []SpanEvent{} + // Test CopyTo empty + dest = CopySpanEventSlice(dest, src) + assert.Equal(t, []SpanEvent{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanEventSlice() + dest = CopySpanEventSlice(dest, src) + assert.Equal(t, GenTestSpanEventSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanEventSlice(dest, src) + assert.Equal(t, GenTestSpanEventSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanEventSlice(dest, []SpanEvent{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanEventSlice(dest, src) + assert.Equal(t, GenTestSpanEventSlice(), dest) +} + +func TestCopySpanEventPtrSlice(t *testing.T) { + src := []*SpanEvent{} + dest := []*SpanEvent{} + // Test CopyTo empty + dest = CopySpanEventPtrSlice(dest, src) + assert.Equal(t, []*SpanEvent{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanEventPtrSlice() + dest = CopySpanEventPtrSlice(dest, src) + assert.Equal(t, GenTestSpanEventPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanEventPtrSlice(dest, src) + assert.Equal(t, GenTestSpanEventPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanEventPtrSlice(dest, []*SpanEvent{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanEventPtrSlice(dest, src) + assert.Equal(t, GenTestSpanEventPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSpanEventUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSpan_Event() - UnmarshalJSONOrigSpan_Event(dest, iter) + dest := NewSpanEvent() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSpan_Event(), dest) + assert.Equal(t, NewSpanEvent(), dest) } -func TestMarshalAndUnmarshalJSONOrigSpan_Event(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Event() { +func TestMarshalAndUnmarshalJSONSpanEvent(t *testing.T) { + for name, src := range genTestEncodingValuesSpanEvent() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { prevPooling := UseProtoPooling.IsEnabled() @@ -62,40 +110,40 @@ func TestMarshalAndUnmarshalJSONOrigSpan_Event(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSpan_Event(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSpan_Event() - UnmarshalJSONOrigSpan_Event(dest, iter) + dest := NewSpanEvent() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSpan_Event(dest, true) + DeleteSpanEvent(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSpan_EventFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesSpan_Event() { +func TestMarshalAndUnmarshalProtoSpanEventFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesSpanEvent() { t.Run(name, func(t *testing.T) { - dest := NewOrigSpan_Event() - require.Error(t, UnmarshalProtoOrigSpan_Event(dest, buf)) + dest := NewSpanEvent() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSpan_EventUnknown(t *testing.T) { - dest := NewOrigSpan_Event() +func TestMarshalAndUnmarshalProtoSpanEventUnknown(t *testing.T) { + dest := NewSpanEvent() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSpan_Event(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSpan_Event(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSpanEvent(), dest) } -func TestMarshalAndUnmarshalProtoOrigSpan_Event(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Event() { +func TestMarshalAndUnmarshalProtoSpanEvent(t *testing.T) { + for name, src := range genTestEncodingValuesSpanEvent() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { prevPooling := UseProtoPooling.IsEnabled() @@ -104,25 +152,25 @@ func TestMarshalAndUnmarshalProtoOrigSpan_Event(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSpan_Event(src)) - gotSize := MarshalProtoOrigSpan_Event(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSpan_Event() - require.NoError(t, UnmarshalProtoOrigSpan_Event(dest, buf)) + dest := NewSpanEvent() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSpan_Event(dest, true) + DeleteSpanEvent(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoViaProtobufSpan_Event(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Event() { +func TestMarshalAndUnmarshalProtoViaProtobufSpanEvent(t *testing.T) { + for name, src := range genTestEncodingValuesSpanEvent() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSpan_Event(src)) - gotSize := MarshalProtoOrigSpan_Event(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlptrace.Span_Event{} @@ -131,14 +179,14 @@ func TestMarshalAndUnmarshalProtoViaProtobufSpan_Event(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSpan_Event() - require.NoError(t, UnmarshalProtoOrigSpan_Event(dest, goBuf)) + dest := NewSpanEvent() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } } -func genTestFailingUnmarshalProtoValuesSpan_Event() map[string][]byte { +func genTestFailingUnmarshalProtoValuesSpanEvent() map[string][]byte { return map[string][]byte{ "invalid_field": {0x02}, "TimeUnixNano/wrong_wire_type": {0xc}, @@ -152,12 +200,12 @@ func genTestFailingUnmarshalProtoValuesSpan_Event() map[string][]byte { } } -func genTestEncodingValuesSpan_Event() map[string]*otlptrace.Span_Event { - return map[string]*otlptrace.Span_Event{ - "empty": NewOrigSpan_Event(), +func genTestEncodingValuesSpanEvent() map[string]*SpanEvent { + return map[string]*SpanEvent{ + "empty": NewSpanEvent(), "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, "Name/test": {Name: "test_name"}, - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, } } diff --git a/pdata/internal/generated_wrapper_span_link.go b/pdata/internal/generated_proto_spanlink.go similarity index 54% rename from pdata/internal/generated_wrapper_span_link.go rename to pdata/internal/generated_proto_spanlink.go index 0adb3bf260d..07c42640bcf 100644 --- a/pdata/internal/generated_wrapper_span_link.go +++ b/pdata/internal/generated_proto_spanlink.go @@ -11,29 +11,38 @@ import ( "fmt" "sync" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// SpanLink is a pointer from the current span to another span in the same trace or in a +// 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 +} + var ( - protoPoolSpan_Link = sync.Pool{ + protoPoolSpanLink = sync.Pool{ New: func() any { - return &otlptrace.Span_Link{} + return &SpanLink{} }, } ) -func NewOrigSpan_Link() *otlptrace.Span_Link { +func NewSpanLink() *SpanLink { if !UseProtoPooling.IsEnabled() { - return &otlptrace.Span_Link{} + return &SpanLink{} } - return protoPoolSpan_Link.Get().(*otlptrace.Span_Link) + return protoPoolSpanLink.Get().(*SpanLink) } -func DeleteOrigSpan_Link(orig *otlptrace.Span_Link, nullable bool) { +func DeleteSpanLink(orig *SpanLink, nullable bool) { if orig == nil { return } @@ -43,52 +52,108 @@ func DeleteOrigSpan_Link(orig *otlptrace.Span_Link, nullable bool) { return } - DeleteOrigTraceID(&orig.TraceId, false) - DeleteOrigSpanID(&orig.SpanId, false) + DeleteTraceID(&orig.TraceId, false) + DeleteSpanID(&orig.SpanId, false) for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } orig.Reset() if nullable { - protoPoolSpan_Link.Put(orig) + protoPoolSpanLink.Put(orig) } } -func CopyOrigSpan_Link(dest, src *otlptrace.Span_Link) { +func CopySpanLink(dest, src *SpanLink) *SpanLink { // If copying to same object, just return. if src == dest { - return + return dest } - dest.TraceId = src.TraceId - dest.SpanId = src.SpanId - CopyOrigTraceState(&dest.TraceState, &src.TraceState) - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSpanLink() + } + CopyTraceID(&dest.TraceId, &src.TraceId) + + 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 } -func GenTestOrigSpan_Link() *otlptrace.Span_Link { - orig := NewOrigSpan_Link() - orig.TraceId = data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - orig.SpanId = data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) - orig.TraceState = *GenTestOrigTraceState() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.DroppedAttributesCount = uint32(13) - orig.Flags = uint32(13) - return orig +func CopySpanLinkSlice(dest, src []SpanLink) []SpanLink { + var newDest []SpanLink + if cap(dest) < len(src) { + newDest = make([]SpanLink, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpanLink(&dest[i], false) + } + } + for i := range src { + CopySpanLink(&newDest[i], &src[i]) + } + return newDest +} + +func CopySpanLinkPtrSlice(dest, src []*SpanLink) []*SpanLink { + var newDest []*SpanLink + if cap(dest) < len(src) { + newDest = make([]*SpanLink, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpanLink() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSpanLink(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSpanLink() + } + } + for i := range src { + CopySpanLink(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSpan_Link(orig *otlptrace.Span_Link, dest *json.Stream) { +func (orig *SpanLink) Reset() { + *orig = SpanLink{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *SpanLink) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() - if orig.TraceId != data.TraceID([16]byte{}) { + if !orig.TraceId.IsEmpty() { dest.WriteObjectField("traceId") - MarshalJSONOrigTraceID(&orig.TraceId, dest) + orig.TraceId.MarshalJSON(dest) } - if orig.SpanId != data.SpanID([8]byte{}) { + if !orig.SpanId.IsEmpty() { dest.WriteObjectField("spanId") - MarshalJSONOrigSpanID(&orig.SpanId, dest) + orig.SpanId.MarshalJSON(dest) } if orig.TraceState != "" { dest.WriteObjectField("traceState") @@ -97,10 +162,10 @@ func MarshalJSONOrigSpan_Link(orig *otlptrace.Span_Link, dest *json.Stream) { if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -115,20 +180,22 @@ func MarshalJSONOrigSpan_Link(orig *otlptrace.Span_Link, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigSpanLink unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSpan_Link(orig *otlptrace.Span_Link, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *SpanLink) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "traceId", "trace_id": - UnmarshalJSONOrigTraceID(&orig.TraceId, iter) + + orig.TraceId.UnmarshalJSON(iter) case "spanId", "span_id": - UnmarshalJSONOrigSpanID(&orig.SpanId, iter) + + orig.SpanId.UnmarshalJSON(iter) case "traceState", "trace_state": orig.TraceState = iter.ReadString() case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "droppedAttributesCount", "dropped_attributes_count": @@ -141,20 +208,20 @@ func UnmarshalJSONOrigSpan_Link(orig *otlptrace.Span_Link, iter *json.Iterator) } } -func SizeProtoOrigSpan_Link(orig *otlptrace.Span_Link) int { +func (orig *SpanLink) SizeProto() int { var n int var l int _ = l - l = SizeProtoOrigTraceID(&orig.TraceId) + l = orig.TraceId.SizeProto() n += 1 + proto.Sov(uint64(l)) + l - l = SizeProtoOrigSpanID(&orig.SpanId) + 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 } for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.DroppedAttributesCount != 0 { @@ -166,18 +233,17 @@ func SizeProtoOrigSpan_Link(orig *otlptrace.Span_Link) int { return n } -func MarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) int { +func (orig *SpanLink) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l - - l = MarshalProtoOrigTraceID(&orig.TraceId, buf[:pos]) + l = orig.TraceId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- buf[pos] = 0xa - l = MarshalProtoOrigSpanID(&orig.SpanId, buf[:pos]) + l = orig.SpanId.MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -192,7 +258,7 @@ func MarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) int { buf[pos] = 0x1a } for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -212,7 +278,7 @@ func MarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) error { +func (orig *SpanLink) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -238,7 +304,7 @@ func UnmarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigTraceID(&orig.TraceId, buf[startPos:pos]) + err = orig.TraceId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -254,7 +320,7 @@ func UnmarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) error { } startPos := pos - length - err = UnmarshalProtoOrigSpanID(&orig.SpanId, buf[startPos:pos]) + err = orig.SpanId.UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -281,8 +347,8 @@ func UnmarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) error { return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -319,3 +385,31 @@ func UnmarshalProtoOrigSpan_Link(orig *otlptrace.Span_Link, buf []byte) error { } return nil } + +func GenTestSpanLink() *SpanLink { + orig := NewSpanLink() + orig.TraceId = *GenTestTraceID() + orig.SpanId = *GenTestSpanID() + orig.TraceState = "test_tracestate" + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.DroppedAttributesCount = uint32(13) + orig.Flags = uint32(13) + return orig +} + +func GenTestSpanLinkPtrSlice() []*SpanLink { + orig := make([]*SpanLink, 5) + orig[0] = NewSpanLink() + orig[1] = GenTestSpanLink() + orig[2] = NewSpanLink() + orig[3] = GenTestSpanLink() + orig[4] = NewSpanLink() + return orig +} + +func GenTestSpanLinkSlice() []SpanLink { + orig := make([]SpanLink, 5) + orig[1] = *GenTestSpanLink() + orig[3] = *GenTestSpanLink() + return orig +} diff --git a/pdata/internal/generated_wrapper_span_link_test.go b/pdata/internal/generated_proto_spanlink_test.go similarity index 51% rename from pdata/internal/generated_wrapper_span_link_test.go rename to pdata/internal/generated_proto_spanlink_test.go index 2bdf715d218..60ca028819c 100644 --- a/pdata/internal/generated_wrapper_span_link_test.go +++ b/pdata/internal/generated_proto_spanlink_test.go @@ -16,13 +16,11 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSpan_Link(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Link() { +func TestCopySpanLink(t *testing.T) { + for name, src := range genTestEncodingValuesSpanLink() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { prevPooling := UseProtoPooling.IsEnabled() @@ -31,27 +29,77 @@ func TestCopyOrigSpan_Link(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSpan_Link() - CopyOrigSpan_Link(dest, src) + dest := NewSpanLink() + CopySpanLink(dest, src) assert.Equal(t, src, dest) - CopyOrigSpan_Link(dest, dest) + CopySpanLink(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSpan_LinkUnknown(t *testing.T) { +func TestCopySpanLinkSlice(t *testing.T) { + src := []SpanLink{} + dest := []SpanLink{} + // Test CopyTo empty + dest = CopySpanLinkSlice(dest, src) + assert.Equal(t, []SpanLink{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanLinkSlice() + dest = CopySpanLinkSlice(dest, src) + assert.Equal(t, GenTestSpanLinkSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanLinkSlice(dest, src) + assert.Equal(t, GenTestSpanLinkSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanLinkSlice(dest, []SpanLink{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanLinkSlice(dest, src) + assert.Equal(t, GenTestSpanLinkSlice(), dest) +} + +func TestCopySpanLinkPtrSlice(t *testing.T) { + src := []*SpanLink{} + dest := []*SpanLink{} + // Test CopyTo empty + dest = CopySpanLinkPtrSlice(dest, src) + assert.Equal(t, []*SpanLink{}, dest) + + // Test CopyTo larger slice + src = GenTestSpanLinkPtrSlice() + dest = CopySpanLinkPtrSlice(dest, src) + assert.Equal(t, GenTestSpanLinkPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySpanLinkPtrSlice(dest, src) + assert.Equal(t, GenTestSpanLinkPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySpanLinkPtrSlice(dest, []*SpanLink{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySpanLinkPtrSlice(dest, src) + assert.Equal(t, GenTestSpanLinkPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSpanLinkUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSpan_Link() - UnmarshalJSONOrigSpan_Link(dest, iter) + dest := NewSpanLink() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSpan_Link(), dest) + assert.Equal(t, NewSpanLink(), dest) } -func TestMarshalAndUnmarshalJSONOrigSpan_Link(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Link() { +func TestMarshalAndUnmarshalJSONSpanLink(t *testing.T) { + for name, src := range genTestEncodingValuesSpanLink() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { prevPooling := UseProtoPooling.IsEnabled() @@ -62,40 +110,40 @@ func TestMarshalAndUnmarshalJSONOrigSpan_Link(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSpan_Link(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSpan_Link() - UnmarshalJSONOrigSpan_Link(dest, iter) + dest := NewSpanLink() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSpan_Link(dest, true) + DeleteSpanLink(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSpan_LinkFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesSpan_Link() { +func TestMarshalAndUnmarshalProtoSpanLinkFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesSpanLink() { t.Run(name, func(t *testing.T) { - dest := NewOrigSpan_Link() - require.Error(t, UnmarshalProtoOrigSpan_Link(dest, buf)) + dest := NewSpanLink() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSpan_LinkUnknown(t *testing.T) { - dest := NewOrigSpan_Link() +func TestMarshalAndUnmarshalProtoSpanLinkUnknown(t *testing.T) { + dest := NewSpanLink() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSpan_Link(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSpan_Link(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSpanLink(), dest) } -func TestMarshalAndUnmarshalProtoOrigSpan_Link(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Link() { +func TestMarshalAndUnmarshalProtoSpanLink(t *testing.T) { + for name, src := range genTestEncodingValuesSpanLink() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { prevPooling := UseProtoPooling.IsEnabled() @@ -104,25 +152,25 @@ func TestMarshalAndUnmarshalProtoOrigSpan_Link(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSpan_Link(src)) - gotSize := MarshalProtoOrigSpan_Link(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSpan_Link() - require.NoError(t, UnmarshalProtoOrigSpan_Link(dest, buf)) + dest := NewSpanLink() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSpan_Link(dest, true) + DeleteSpanLink(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoViaProtobufSpan_Link(t *testing.T) { - for name, src := range genTestEncodingValuesSpan_Link() { +func TestMarshalAndUnmarshalProtoViaProtobufSpanLink(t *testing.T) { + for name, src := range genTestEncodingValuesSpanLink() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSpan_Link(src)) - gotSize := MarshalProtoOrigSpan_Link(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlptrace.Span_Link{} @@ -131,14 +179,14 @@ func TestMarshalAndUnmarshalProtoViaProtobufSpan_Link(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSpan_Link() - require.NoError(t, UnmarshalProtoOrigSpan_Link(dest, goBuf)) + dest := NewSpanLink() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } } -func genTestFailingUnmarshalProtoValuesSpan_Link() map[string][]byte { +func genTestFailingUnmarshalProtoValuesSpanLink() map[string][]byte { return map[string][]byte{ "invalid_field": {0x02}, "TraceId/wrong_wire_type": {0xc}, @@ -156,13 +204,13 @@ func genTestFailingUnmarshalProtoValuesSpan_Link() map[string][]byte { } } -func genTestEncodingValuesSpan_Link() map[string]*otlptrace.Span_Link { - return map[string]*otlptrace.Span_Link{ - "empty": NewOrigSpan_Link(), - "TraceId/test": {TraceId: *GenTestOrigTraceID()}, - "SpanId/test": {SpanId: *GenTestOrigSpanID()}, +func genTestEncodingValuesSpanLink() map[string]*SpanLink { + return map[string]*SpanLink{ + "empty": NewSpanLink(), + "TraceId/test": {TraceId: *GenTestTraceID()}, + "SpanId/test": {SpanId: *GenTestSpanID()}, "TraceState/test": {TraceState: "test_tracestate"}, - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, "DroppedAttributesCount/test": {DroppedAttributesCount: uint32(13)}, "Flags/test": {Flags: uint32(13)}, } diff --git a/pdata/internal/generated_wrapper_stack.go b/pdata/internal/generated_proto_stack.go similarity index 53% rename from pdata/internal/generated_wrapper_stack.go rename to pdata/internal/generated_proto_stack.go index 6b230b30c6f..a97599bfc65 100644 --- a/pdata/internal/generated_wrapper_stack.go +++ b/pdata/internal/generated_proto_stack.go @@ -10,27 +10,32 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Stack represents a stack trace as a list of locations. + +type Stack struct { + LocationIndices []int32 +} + var ( protoPoolStack = sync.Pool{ New: func() any { - return &otlpprofiles.Stack{} + return &Stack{} }, } ) -func NewOrigStack() *otlpprofiles.Stack { +func NewStack() *Stack { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Stack{} + return &Stack{} } - return protoPoolStack.Get().(*otlpprofiles.Stack) + return protoPoolStack.Get().(*Stack) } -func DeleteOrigStack(orig *otlpprofiles.Stack, nullable bool) { +func DeleteStack(orig *Stack, nullable bool) { if orig == nil { return } @@ -46,22 +51,78 @@ func DeleteOrigStack(orig *otlpprofiles.Stack, nullable bool) { } } -func CopyOrigStack(dest, src *otlpprofiles.Stack) { +func CopyStack(dest, src *Stack) *Stack { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewStack() } - dest.LocationIndices = CopyOrigInt32Slice(dest.LocationIndices, src.LocationIndices) + dest.LocationIndices = append(dest.LocationIndices[:0], src.LocationIndices...) + + return dest } -func GenTestOrigStack() *otlpprofiles.Stack { - orig := NewOrigStack() - orig.LocationIndices = GenerateOrigTestInt32Slice() - return orig +func CopyStackSlice(dest, src []Stack) []Stack { + var newDest []Stack + if cap(dest) < len(src) { + newDest = make([]Stack, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteStack(&dest[i], false) + } + } + for i := range src { + CopyStack(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigStack(orig *otlpprofiles.Stack, dest *json.Stream) { +func CopyStackPtrSlice(dest, src []*Stack) []*Stack { + var newDest []*Stack + if cap(dest) < len(src) { + newDest = make([]*Stack, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewStack() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteStack(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewStack() + } + } + for i := range src { + CopyStack(newDest[i], src[i]) + } + return newDest +} + +func (orig *Stack) Reset() { + *orig = Stack{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Stack) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.LocationIndices) > 0 { dest.WriteObjectField("locationIndices") @@ -76,8 +137,8 @@ func MarshalJSONOrigStack(orig *otlpprofiles.Stack, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigStack unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigStack(orig *otlpprofiles.Stack, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Stack) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "locationIndices", "location_indices": @@ -91,7 +152,7 @@ func UnmarshalJSONOrigStack(orig *otlpprofiles.Stack, iter *json.Iterator) { } } -func SizeProtoOrigStack(orig *otlpprofiles.Stack) int { +func (orig *Stack) SizeProto() int { var n int var l int _ = l @@ -105,7 +166,7 @@ func SizeProtoOrigStack(orig *otlpprofiles.Stack) int { return n } -func MarshalProtoOrigStack(orig *otlpprofiles.Stack, buf []byte) int { +func (orig *Stack) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -122,7 +183,7 @@ func MarshalProtoOrigStack(orig *otlpprofiles.Stack, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigStack(orig *otlpprofiles.Stack, buf []byte) error { +func (orig *Stack) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -175,3 +236,26 @@ func UnmarshalProtoOrigStack(orig *otlpprofiles.Stack, buf []byte) error { } return nil } + +func GenTestStack() *Stack { + orig := NewStack() + orig.LocationIndices = []int32{int32(0), int32(13)} + return orig +} + +func GenTestStackPtrSlice() []*Stack { + orig := make([]*Stack, 5) + orig[0] = NewStack() + orig[1] = GenTestStack() + orig[2] = NewStack() + orig[3] = GenTestStack() + orig[4] = NewStack() + return orig +} + +func GenTestStackSlice() []Stack { + orig := make([]Stack, 5) + orig[1] = *GenTestStack() + orig[3] = *GenTestStack() + return orig +} diff --git a/pdata/internal/generated_wrapper_stack_test.go b/pdata/internal/generated_proto_stack_test.go similarity index 55% rename from pdata/internal/generated_wrapper_stack_test.go rename to pdata/internal/generated_proto_stack_test.go index 2493e0b0c54..ab99ba7b017 100644 --- a/pdata/internal/generated_wrapper_stack_test.go +++ b/pdata/internal/generated_proto_stack_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigStack(t *testing.T) { +func TestCopyStack(t *testing.T) { for name, src := range genTestEncodingValuesStack() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigStack(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigStack() - CopyOrigStack(dest, src) + dest := NewStack() + CopyStack(dest, src) assert.Equal(t, src, dest) - CopyOrigStack(dest, dest) + CopyStack(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigStackUnknown(t *testing.T) { +func TestCopyStackSlice(t *testing.T) { + src := []Stack{} + dest := []Stack{} + // Test CopyTo empty + dest = CopyStackSlice(dest, src) + assert.Equal(t, []Stack{}, dest) + + // Test CopyTo larger slice + src = GenTestStackSlice() + dest = CopyStackSlice(dest, src) + assert.Equal(t, GenTestStackSlice(), dest) + + // Test CopyTo same size slice + dest = CopyStackSlice(dest, src) + assert.Equal(t, GenTestStackSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyStackSlice(dest, []Stack{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyStackSlice(dest, src) + assert.Equal(t, GenTestStackSlice(), dest) +} + +func TestCopyStackPtrSlice(t *testing.T) { + src := []*Stack{} + dest := []*Stack{} + // Test CopyTo empty + dest = CopyStackPtrSlice(dest, src) + assert.Equal(t, []*Stack{}, dest) + + // Test CopyTo larger slice + src = GenTestStackPtrSlice() + dest = CopyStackPtrSlice(dest, src) + assert.Equal(t, GenTestStackPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyStackPtrSlice(dest, src) + assert.Equal(t, GenTestStackPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyStackPtrSlice(dest, []*Stack{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyStackPtrSlice(dest, src) + assert.Equal(t, GenTestStackPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONStackUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigStack() - UnmarshalJSONOrigStack(dest, iter) + dest := NewStack() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigStack(), dest) + assert.Equal(t, NewStack(), dest) } -func TestMarshalAndUnmarshalJSONOrigStack(t *testing.T) { +func TestMarshalAndUnmarshalJSONStack(t *testing.T) { for name, src := range genTestEncodingValuesStack() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigStack(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigStack(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigStack() - UnmarshalJSONOrigStack(dest, iter) + dest := NewStack() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigStack(dest, true) + DeleteStack(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigStackFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoStackFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesStack() { t.Run(name, func(t *testing.T) { - dest := NewOrigStack() - require.Error(t, UnmarshalProtoOrigStack(dest, buf)) + dest := NewStack() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigStackUnknown(t *testing.T) { - dest := NewOrigStack() +func TestMarshalAndUnmarshalProtoStackUnknown(t *testing.T) { + dest := NewStack() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigStack(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigStack(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewStack(), dest) } -func TestMarshalAndUnmarshalProtoOrigStack(t *testing.T) { +func TestMarshalAndUnmarshalProtoStack(t *testing.T) { for name, src := range genTestEncodingValuesStack() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigStack(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigStack(src)) - gotSize := MarshalProtoOrigStack(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigStack() - require.NoError(t, UnmarshalProtoOrigStack(dest, buf)) + dest := NewStack() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigStack(dest, true) + DeleteStack(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigStack(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufStack(t *testing.T) { for name, src := range genTestEncodingValuesStack() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigStack(src)) - gotSize := MarshalProtoOrigStack(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.Stack{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufStack(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigStack() - require.NoError(t, UnmarshalProtoOrigStack(dest, goBuf)) + dest := NewStack() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -145,9 +194,9 @@ func genTestFailingUnmarshalProtoValuesStack() map[string][]byte { } } -func genTestEncodingValuesStack() map[string]*otlpprofiles.Stack { - return map[string]*otlpprofiles.Stack{ - "empty": NewOrigStack(), - "LocationIndices/default_and_test": {LocationIndices: []int32{int32(0), int32(13)}}, +func genTestEncodingValuesStack() map[string]*Stack { + return map[string]*Stack{ + "empty": NewStack(), + "LocationIndices/test": {LocationIndices: []int32{int32(0), int32(13)}}, } } diff --git a/pdata/internal/generated_proto_status.go b/pdata/internal/generated_proto_status.go new file mode 100644 index 00000000000..c2f2d37754f --- /dev/null +++ b/pdata/internal/generated_proto_status.go @@ -0,0 +1,260 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Status is an optional final status for this span. Semantically, when Status was not +// set, that means the span ended without errors and to assume Status.Ok (code = 0). +type Status struct { + Message string + Code StatusCode +} + +var ( + protoPoolStatus = sync.Pool{ + New: func() any { + return &Status{} + }, + } +) + +func NewStatus() *Status { + if !UseProtoPooling.IsEnabled() { + return &Status{} + } + return protoPoolStatus.Get().(*Status) +} + +func DeleteStatus(orig *Status, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolStatus.Put(orig) + } +} + +func CopyStatus(dest, src *Status) *Status { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewStatus() + } + dest.Message = src.Message + + dest.Code = src.Code + + return dest +} + +func CopyStatusSlice(dest, src []Status) []Status { + var newDest []Status + if cap(dest) < len(src) { + newDest = make([]Status, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteStatus(&dest[i], false) + } + } + for i := range src { + CopyStatus(&newDest[i], &src[i]) + } + return newDest +} + +func CopyStatusPtrSlice(dest, src []*Status) []*Status { + var newDest []*Status + if cap(dest) < len(src) { + newDest = make([]*Status, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewStatus() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteStatus(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewStatus() + } + } + for i := range src { + CopyStatus(newDest[i], src[i]) + } + return newDest +} + +func (orig *Status) Reset() { + *orig = Status{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Status) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Message != "" { + dest.WriteObjectField("message") + dest.WriteString(orig.Message) + } + + if int32(orig.Code) != 0 { + dest.WriteObjectField("code") + dest.WriteInt32(int32(orig.Code)) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Status) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "message": + orig.Message = iter.ReadString() + case "code": + orig.Code = StatusCode(iter.ReadEnumValue(StatusCode_value)) + default: + iter.Skip() + } + } +} + +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 { + n += 1 + proto.Sov(uint64(orig.Code)) + } + return n +} + +func (orig *Status) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.Message) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Message) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + if orig.Code != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.Code)) + pos-- + buf[pos] = 0x18 + } + return len(buf) - pos +} + +func (orig *Status) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Message = string(buf[startPos:pos]) + + case 3: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.Code = StatusCode(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestStatus() *Status { + orig := NewStatus() + orig.Message = "test_message" + orig.Code = StatusCode(13) + return orig +} + +func GenTestStatusPtrSlice() []*Status { + orig := make([]*Status, 5) + orig[0] = NewStatus() + orig[1] = GenTestStatus() + orig[2] = NewStatus() + orig[3] = GenTestStatus() + orig[4] = NewStatus() + return orig +} + +func GenTestStatusSlice() []Status { + orig := make([]Status, 5) + orig[1] = *GenTestStatus() + orig[3] = *GenTestStatus() + return orig +} diff --git a/pdata/internal/generated_wrapper_status_test.go b/pdata/internal/generated_proto_status_test.go similarity index 55% rename from pdata/internal/generated_wrapper_status_test.go rename to pdata/internal/generated_proto_status_test.go index f5eb6c69653..3511595899d 100644 --- a/pdata/internal/generated_wrapper_status_test.go +++ b/pdata/internal/generated_proto_status_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigStatus(t *testing.T) { +func TestCopyStatus(t *testing.T) { for name, src := range genTestEncodingValuesStatus() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigStatus(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigStatus() - CopyOrigStatus(dest, src) + dest := NewStatus() + CopyStatus(dest, src) assert.Equal(t, src, dest) - CopyOrigStatus(dest, dest) + CopyStatus(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigStatusUnknown(t *testing.T) { +func TestCopyStatusSlice(t *testing.T) { + src := []Status{} + dest := []Status{} + // Test CopyTo empty + dest = CopyStatusSlice(dest, src) + assert.Equal(t, []Status{}, dest) + + // Test CopyTo larger slice + src = GenTestStatusSlice() + dest = CopyStatusSlice(dest, src) + assert.Equal(t, GenTestStatusSlice(), dest) + + // Test CopyTo same size slice + dest = CopyStatusSlice(dest, src) + assert.Equal(t, GenTestStatusSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyStatusSlice(dest, []Status{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyStatusSlice(dest, src) + assert.Equal(t, GenTestStatusSlice(), dest) +} + +func TestCopyStatusPtrSlice(t *testing.T) { + src := []*Status{} + dest := []*Status{} + // Test CopyTo empty + dest = CopyStatusPtrSlice(dest, src) + assert.Equal(t, []*Status{}, dest) + + // Test CopyTo larger slice + src = GenTestStatusPtrSlice() + dest = CopyStatusPtrSlice(dest, src) + assert.Equal(t, GenTestStatusPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyStatusPtrSlice(dest, src) + assert.Equal(t, GenTestStatusPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyStatusPtrSlice(dest, []*Status{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyStatusPtrSlice(dest, src) + assert.Equal(t, GenTestStatusPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONStatusUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigStatus() - UnmarshalJSONOrigStatus(dest, iter) + dest := NewStatus() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigStatus(), dest) + assert.Equal(t, NewStatus(), dest) } -func TestMarshalAndUnmarshalJSONOrigStatus(t *testing.T) { +func TestMarshalAndUnmarshalJSONStatus(t *testing.T) { for name, src := range genTestEncodingValuesStatus() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigStatus(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigStatus(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigStatus() - UnmarshalJSONOrigStatus(dest, iter) + dest := NewStatus() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigStatus(dest, true) + DeleteStatus(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigStatusFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoStatusFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesStatus() { t.Run(name, func(t *testing.T) { - dest := NewOrigStatus() - require.Error(t, UnmarshalProtoOrigStatus(dest, buf)) + dest := NewStatus() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigStatusUnknown(t *testing.T) { - dest := NewOrigStatus() +func TestMarshalAndUnmarshalProtoStatusUnknown(t *testing.T) { + dest := NewStatus() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigStatus(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigStatus(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewStatus(), dest) } -func TestMarshalAndUnmarshalProtoOrigStatus(t *testing.T) { +func TestMarshalAndUnmarshalProtoStatus(t *testing.T) { for name, src := range genTestEncodingValuesStatus() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigStatus(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigStatus(src)) - gotSize := MarshalProtoOrigStatus(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigStatus() - require.NoError(t, UnmarshalProtoOrigStatus(dest, buf)) + dest := NewStatus() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigStatus(dest, true) + DeleteStatus(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigStatus(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufStatus(t *testing.T) { for name, src := range genTestEncodingValuesStatus() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigStatus(src)) - gotSize := MarshalProtoOrigStatus(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlptrace.Status{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufStatus(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigStatus() - require.NoError(t, UnmarshalProtoOrigStatus(dest, goBuf)) + dest := NewStatus() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -147,10 +196,10 @@ func genTestFailingUnmarshalProtoValuesStatus() map[string][]byte { } } -func genTestEncodingValuesStatus() map[string]*otlptrace.Status { - return map[string]*otlptrace.Status{ - "empty": NewOrigStatus(), +func genTestEncodingValuesStatus() map[string]*Status { + return map[string]*Status{ + "empty": NewStatus(), "Message/test": {Message: "test_message"}, - "Code/test": {Code: otlptrace.Status_StatusCode(13)}, + "Code/test": {Code: StatusCode(13)}, } } diff --git a/pdata/internal/generated_wrapper_sum.go b/pdata/internal/generated_proto_sum.go similarity index 50% rename from pdata/internal/generated_wrapper_sum.go rename to pdata/internal/generated_proto_sum.go index fcc015ad0fe..67be5d00f04 100644 --- a/pdata/internal/generated_wrapper_sum.go +++ b/pdata/internal/generated_proto_sum.go @@ -10,27 +10,33 @@ import ( "fmt" "sync" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// Sum represents the type of a numeric metric that is calculated as a sum of all reported measurements over a time interval. +type Sum struct { + DataPoints []*NumberDataPoint + AggregationTemporality AggregationTemporality + IsMonotonic bool +} + var ( protoPoolSum = sync.Pool{ New: func() any { - return &otlpmetrics.Sum{} + return &Sum{} }, } ) -func NewOrigSum() *otlpmetrics.Sum { +func NewSum() *Sum { if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.Sum{} + return &Sum{} } - return protoPoolSum.Get().(*otlpmetrics.Sum) + return protoPoolSum.Get().(*Sum) } -func DeleteOrigSum(orig *otlpmetrics.Sum, nullable bool) { +func DeleteSum(orig *Sum, nullable bool) { if orig == nil { return } @@ -41,7 +47,7 @@ func DeleteOrigSum(orig *otlpmetrics.Sum, nullable bool) { } for i := range orig.DataPoints { - DeleteOrigNumberDataPoint(orig.DataPoints[i], true) + DeleteNumberDataPoint(orig.DataPoints[i], true) } orig.Reset() @@ -50,34 +56,90 @@ func DeleteOrigSum(orig *otlpmetrics.Sum, nullable bool) { } } -func CopyOrigSum(dest, src *otlpmetrics.Sum) { +func CopySum(dest, src *Sum) *Sum { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil } - dest.DataPoints = CopyOrigNumberDataPointSlice(dest.DataPoints, src.DataPoints) + + if dest == nil { + dest = NewSum() + } + dest.DataPoints = CopyNumberDataPointPtrSlice(dest.DataPoints, src.DataPoints) + dest.AggregationTemporality = src.AggregationTemporality + dest.IsMonotonic = src.IsMonotonic + + return dest } -func GenTestOrigSum() *otlpmetrics.Sum { - orig := NewOrigSum() - orig.DataPoints = GenerateOrigTestNumberDataPointSlice() - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(1) - orig.IsMonotonic = true - return orig +func CopySumSlice(dest, src []Sum) []Sum { + var newDest []Sum + if cap(dest) < len(src) { + newDest = make([]Sum, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSum(&dest[i], false) + } + } + for i := range src { + CopySum(&newDest[i], &src[i]) + } + return newDest +} + +func CopySumPtrSlice(dest, src []*Sum) []*Sum { + var newDest []*Sum + if cap(dest) < len(src) { + newDest = make([]*Sum, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSum() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSum(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSum() + } + } + for i := range src { + CopySum(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSum(orig *otlpmetrics.Sum, dest *json.Stream) { +func (orig *Sum) Reset() { + *orig = Sum{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Sum) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.DataPoints) > 0 { dest.WriteObjectField("dataPoints") dest.WriteArrayStart() - MarshalJSONOrigNumberDataPoint(orig.DataPoints[0], dest) + orig.DataPoints[0].MarshalJSON(dest) for i := 1; i < len(orig.DataPoints); i++ { dest.WriteMore() - MarshalJSONOrigNumberDataPoint(orig.DataPoints[i], dest) + orig.DataPoints[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -93,18 +155,18 @@ func MarshalJSONOrigSum(orig *otlpmetrics.Sum, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigSum unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSum(orig *otlpmetrics.Sum, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Sum) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "dataPoints", "data_points": for iter.ReadArray() { - orig.DataPoints = append(orig.DataPoints, NewOrigNumberDataPoint()) - UnmarshalJSONOrigNumberDataPoint(orig.DataPoints[len(orig.DataPoints)-1], iter) + orig.DataPoints = append(orig.DataPoints, NewNumberDataPoint()) + orig.DataPoints[len(orig.DataPoints)-1].UnmarshalJSON(iter) } case "aggregationTemporality", "aggregation_temporality": - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(iter.ReadEnumValue(otlpmetrics.AggregationTemporality_value)) + orig.AggregationTemporality = AggregationTemporality(iter.ReadEnumValue(AggregationTemporality_value)) case "isMonotonic", "is_monotonic": orig.IsMonotonic = iter.ReadBool() default: @@ -113,12 +175,12 @@ func UnmarshalJSONOrigSum(orig *otlpmetrics.Sum, iter *json.Iterator) { } } -func SizeProtoOrigSum(orig *otlpmetrics.Sum) int { +func (orig *Sum) SizeProto() int { var n int var l int _ = l for i := range orig.DataPoints { - l = SizeProtoOrigNumberDataPoint(orig.DataPoints[i]) + l = orig.DataPoints[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.AggregationTemporality != 0 { @@ -130,12 +192,12 @@ func SizeProtoOrigSum(orig *otlpmetrics.Sum) int { return n } -func MarshalProtoOrigSum(orig *otlpmetrics.Sum, buf []byte) int { +func (orig *Sum) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.DataPoints) - 1; i >= 0; i-- { - l = MarshalProtoOrigNumberDataPoint(orig.DataPoints[i], buf[:pos]) + l = orig.DataPoints[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -159,7 +221,7 @@ func MarshalProtoOrigSum(orig *otlpmetrics.Sum, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigSum(orig *otlpmetrics.Sum, buf []byte) error { +func (orig *Sum) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -184,8 +246,8 @@ func UnmarshalProtoOrigSum(orig *otlpmetrics.Sum, buf []byte) error { return err } startPos := pos - length - orig.DataPoints = append(orig.DataPoints, NewOrigNumberDataPoint()) - err = UnmarshalProtoOrigNumberDataPoint(orig.DataPoints[len(orig.DataPoints)-1], buf[startPos:pos]) + orig.DataPoints = append(orig.DataPoints, NewNumberDataPoint()) + err = orig.DataPoints[len(orig.DataPoints)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -200,7 +262,7 @@ func UnmarshalProtoOrigSum(orig *otlpmetrics.Sum, buf []byte) error { return err } - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(num) + orig.AggregationTemporality = AggregationTemporality(num) case 3: if wireType != proto.WireTypeVarint { @@ -222,3 +284,28 @@ func UnmarshalProtoOrigSum(orig *otlpmetrics.Sum, buf []byte) error { } return nil } + +func GenTestSum() *Sum { + orig := NewSum() + orig.DataPoints = []*NumberDataPoint{{}, GenTestNumberDataPoint()} + orig.AggregationTemporality = AggregationTemporality(13) + orig.IsMonotonic = true + return orig +} + +func GenTestSumPtrSlice() []*Sum { + orig := make([]*Sum, 5) + orig[0] = NewSum() + orig[1] = GenTestSum() + orig[2] = NewSum() + orig[3] = GenTestSum() + orig[4] = NewSum() + return orig +} + +func GenTestSumSlice() []Sum { + orig := make([]Sum, 5) + orig[1] = *GenTestSum() + orig[3] = *GenTestSum() + return orig +} diff --git a/pdata/internal/generated_wrapper_sum_test.go b/pdata/internal/generated_proto_sum_test.go similarity index 56% rename from pdata/internal/generated_wrapper_sum_test.go rename to pdata/internal/generated_proto_sum_test.go index 2b303119dad..ab4ff295e91 100644 --- a/pdata/internal/generated_wrapper_sum_test.go +++ b/pdata/internal/generated_proto_sum_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSum(t *testing.T) { +func TestCopySum(t *testing.T) { for name, src := range genTestEncodingValuesSum() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigSum(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSum() - CopyOrigSum(dest, src) + dest := NewSum() + CopySum(dest, src) assert.Equal(t, src, dest) - CopyOrigSum(dest, dest) + CopySum(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSumUnknown(t *testing.T) { +func TestCopySumSlice(t *testing.T) { + src := []Sum{} + dest := []Sum{} + // Test CopyTo empty + dest = CopySumSlice(dest, src) + assert.Equal(t, []Sum{}, dest) + + // Test CopyTo larger slice + src = GenTestSumSlice() + dest = CopySumSlice(dest, src) + assert.Equal(t, GenTestSumSlice(), dest) + + // Test CopyTo same size slice + dest = CopySumSlice(dest, src) + assert.Equal(t, GenTestSumSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySumSlice(dest, []Sum{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySumSlice(dest, src) + assert.Equal(t, GenTestSumSlice(), dest) +} + +func TestCopySumPtrSlice(t *testing.T) { + src := []*Sum{} + dest := []*Sum{} + // Test CopyTo empty + dest = CopySumPtrSlice(dest, src) + assert.Equal(t, []*Sum{}, dest) + + // Test CopyTo larger slice + src = GenTestSumPtrSlice() + dest = CopySumPtrSlice(dest, src) + assert.Equal(t, GenTestSumPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySumPtrSlice(dest, src) + assert.Equal(t, GenTestSumPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySumPtrSlice(dest, []*Sum{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySumPtrSlice(dest, src) + assert.Equal(t, GenTestSumPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSumUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSum() - UnmarshalJSONOrigSum(dest, iter) + dest := NewSum() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSum(), dest) + assert.Equal(t, NewSum(), dest) } -func TestMarshalAndUnmarshalJSONOrigSum(t *testing.T) { +func TestMarshalAndUnmarshalJSONSum(t *testing.T) { for name, src := range genTestEncodingValuesSum() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigSum(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSum(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSum() - UnmarshalJSONOrigSum(dest, iter) + dest := NewSum() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSum(dest, true) + DeleteSum(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSumFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoSumFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesSum() { t.Run(name, func(t *testing.T) { - dest := NewOrigSum() - require.Error(t, UnmarshalProtoOrigSum(dest, buf)) + dest := NewSum() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSumUnknown(t *testing.T) { - dest := NewOrigSum() +func TestMarshalAndUnmarshalProtoSumUnknown(t *testing.T) { + dest := NewSum() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSum(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSum(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSum(), dest) } -func TestMarshalAndUnmarshalProtoOrigSum(t *testing.T) { +func TestMarshalAndUnmarshalProtoSum(t *testing.T) { for name, src := range genTestEncodingValuesSum() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigSum(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSum(src)) - gotSize := MarshalProtoOrigSum(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSum() - require.NoError(t, UnmarshalProtoOrigSum(dest, buf)) + dest := NewSum() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSum(dest, true) + DeleteSum(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigSum(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufSum(t *testing.T) { for name, src := range genTestEncodingValuesSum() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSum(src)) - gotSize := MarshalProtoOrigSum(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.Sum{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufSum(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSum() - require.NoError(t, UnmarshalProtoOrigSum(dest, goBuf)) + dest := NewSum() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesSum() map[string][]byte { } } -func genTestEncodingValuesSum() map[string]*otlpmetrics.Sum { - return map[string]*otlpmetrics.Sum{ - "empty": NewOrigSum(), - "DataPoints/default_and_test": {DataPoints: []*otlpmetrics.NumberDataPoint{{}, GenTestOrigNumberDataPoint()}}, - "AggregationTemporality/test": {AggregationTemporality: otlpmetrics.AggregationTemporality(13)}, +func genTestEncodingValuesSum() map[string]*Sum { + return map[string]*Sum{ + "empty": NewSum(), + "DataPoints/test": {DataPoints: []*NumberDataPoint{{}, GenTestNumberDataPoint()}}, + "AggregationTemporality/test": {AggregationTemporality: AggregationTemporality(13)}, "IsMonotonic/test": {IsMonotonic: true}, } } diff --git a/pdata/internal/generated_proto_summary.go b/pdata/internal/generated_proto_summary.go new file mode 100644 index 00000000000..8d40bd16603 --- /dev/null +++ b/pdata/internal/generated_proto_summary.go @@ -0,0 +1,245 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// Summary represents the type of a metric that is calculated by aggregating as a Summary of all reported double measurements over a time interval. +type Summary struct { + DataPoints []*SummaryDataPoint +} + +var ( + protoPoolSummary = sync.Pool{ + New: func() any { + return &Summary{} + }, + } +) + +func NewSummary() *Summary { + if !UseProtoPooling.IsEnabled() { + return &Summary{} + } + return protoPoolSummary.Get().(*Summary) +} + +func DeleteSummary(orig *Summary, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.DataPoints { + DeleteSummaryDataPoint(orig.DataPoints[i], true) + } + + orig.Reset() + if nullable { + protoPoolSummary.Put(orig) + } +} + +func CopySummary(dest, src *Summary) *Summary { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSummary() + } + dest.DataPoints = CopySummaryDataPointPtrSlice(dest.DataPoints, src.DataPoints) + + return dest +} + +func CopySummarySlice(dest, src []Summary) []Summary { + var newDest []Summary + if cap(dest) < len(src) { + newDest = make([]Summary, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSummary(&dest[i], false) + } + } + for i := range src { + CopySummary(&newDest[i], &src[i]) + } + return newDest +} + +func CopySummaryPtrSlice(dest, src []*Summary) []*Summary { + var newDest []*Summary + if cap(dest) < len(src) { + newDest = make([]*Summary, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSummary() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSummary(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSummary() + } + } + for i := range src { + CopySummary(newDest[i], src[i]) + } + return newDest +} + +func (orig *Summary) Reset() { + *orig = Summary{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *Summary) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.DataPoints) > 0 { + dest.WriteObjectField("dataPoints") + dest.WriteArrayStart() + orig.DataPoints[0].MarshalJSON(dest) + for i := 1; i < len(orig.DataPoints); i++ { + dest.WriteMore() + orig.DataPoints[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *Summary) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "dataPoints", "data_points": + for iter.ReadArray() { + orig.DataPoints = append(orig.DataPoints, NewSummaryDataPoint()) + orig.DataPoints[len(orig.DataPoints)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *Summary) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.DataPoints { + l = orig.DataPoints[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *Summary) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.DataPoints) - 1; i >= 0; i-- { + l = orig.DataPoints[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *Summary) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.DataPoints = append(orig.DataPoints, NewSummaryDataPoint()) + err = orig.DataPoints[len(orig.DataPoints)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestSummary() *Summary { + orig := NewSummary() + orig.DataPoints = []*SummaryDataPoint{{}, GenTestSummaryDataPoint()} + return orig +} + +func GenTestSummaryPtrSlice() []*Summary { + orig := make([]*Summary, 5) + orig[0] = NewSummary() + orig[1] = GenTestSummary() + orig[2] = NewSummary() + orig[3] = GenTestSummary() + orig[4] = NewSummary() + return orig +} + +func GenTestSummarySlice() []Summary { + orig := make([]Summary, 5) + orig[1] = *GenTestSummary() + orig[3] = *GenTestSummary() + return orig +} diff --git a/pdata/internal/generated_wrapper_summary_test.go b/pdata/internal/generated_proto_summary_test.go similarity index 54% rename from pdata/internal/generated_wrapper_summary_test.go rename to pdata/internal/generated_proto_summary_test.go index d890186ba37..52aa9cc051c 100644 --- a/pdata/internal/generated_wrapper_summary_test.go +++ b/pdata/internal/generated_proto_summary_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSummary(t *testing.T) { +func TestCopySummary(t *testing.T) { for name, src := range genTestEncodingValuesSummary() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigSummary(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSummary() - CopyOrigSummary(dest, src) + dest := NewSummary() + CopySummary(dest, src) assert.Equal(t, src, dest) - CopyOrigSummary(dest, dest) + CopySummary(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSummaryUnknown(t *testing.T) { +func TestCopySummarySlice(t *testing.T) { + src := []Summary{} + dest := []Summary{} + // Test CopyTo empty + dest = CopySummarySlice(dest, src) + assert.Equal(t, []Summary{}, dest) + + // Test CopyTo larger slice + src = GenTestSummarySlice() + dest = CopySummarySlice(dest, src) + assert.Equal(t, GenTestSummarySlice(), dest) + + // Test CopyTo same size slice + dest = CopySummarySlice(dest, src) + assert.Equal(t, GenTestSummarySlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySummarySlice(dest, []Summary{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySummarySlice(dest, src) + assert.Equal(t, GenTestSummarySlice(), dest) +} + +func TestCopySummaryPtrSlice(t *testing.T) { + src := []*Summary{} + dest := []*Summary{} + // Test CopyTo empty + dest = CopySummaryPtrSlice(dest, src) + assert.Equal(t, []*Summary{}, dest) + + // Test CopyTo larger slice + src = GenTestSummaryPtrSlice() + dest = CopySummaryPtrSlice(dest, src) + assert.Equal(t, GenTestSummaryPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySummaryPtrSlice(dest, src) + assert.Equal(t, GenTestSummaryPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySummaryPtrSlice(dest, []*Summary{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySummaryPtrSlice(dest, src) + assert.Equal(t, GenTestSummaryPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSummaryUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSummary() - UnmarshalJSONOrigSummary(dest, iter) + dest := NewSummary() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSummary(), dest) + assert.Equal(t, NewSummary(), dest) } -func TestMarshalAndUnmarshalJSONOrigSummary(t *testing.T) { +func TestMarshalAndUnmarshalJSONSummary(t *testing.T) { for name, src := range genTestEncodingValuesSummary() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigSummary(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSummary(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSummary() - UnmarshalJSONOrigSummary(dest, iter) + dest := NewSummary() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSummary(dest, true) + DeleteSummary(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSummaryFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoSummaryFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesSummary() { t.Run(name, func(t *testing.T) { - dest := NewOrigSummary() - require.Error(t, UnmarshalProtoOrigSummary(dest, buf)) + dest := NewSummary() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSummaryUnknown(t *testing.T) { - dest := NewOrigSummary() +func TestMarshalAndUnmarshalProtoSummaryUnknown(t *testing.T) { + dest := NewSummary() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSummary(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSummary(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSummary(), dest) } -func TestMarshalAndUnmarshalProtoOrigSummary(t *testing.T) { +func TestMarshalAndUnmarshalProtoSummary(t *testing.T) { for name, src := range genTestEncodingValuesSummary() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigSummary(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSummary(src)) - gotSize := MarshalProtoOrigSummary(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSummary() - require.NoError(t, UnmarshalProtoOrigSummary(dest, buf)) + dest := NewSummary() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSummary(dest, true) + DeleteSummary(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigSummary(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufSummary(t *testing.T) { for name, src := range genTestEncodingValuesSummary() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSummary(src)) - gotSize := MarshalProtoOrigSummary(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.Summary{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufSummary(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSummary() - require.NoError(t, UnmarshalProtoOrigSummary(dest, goBuf)) + dest := NewSummary() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -145,9 +194,9 @@ func genTestFailingUnmarshalProtoValuesSummary() map[string][]byte { } } -func genTestEncodingValuesSummary() map[string]*otlpmetrics.Summary { - return map[string]*otlpmetrics.Summary{ - "empty": NewOrigSummary(), - "DataPoints/default_and_test": {DataPoints: []*otlpmetrics.SummaryDataPoint{{}, GenTestOrigSummaryDataPoint()}}, +func genTestEncodingValuesSummary() map[string]*Summary { + return map[string]*Summary{ + "empty": NewSummary(), + "DataPoints/test": {DataPoints: []*SummaryDataPoint{{}, GenTestSummaryDataPoint()}}, } } diff --git a/pdata/internal/generated_wrapper_summarydatapoint.go b/pdata/internal/generated_proto_summarydatapoint.go similarity index 56% rename from pdata/internal/generated_wrapper_summarydatapoint.go rename to pdata/internal/generated_proto_summarydatapoint.go index 35b4132010a..bf30987a669 100644 --- a/pdata/internal/generated_wrapper_summarydatapoint.go +++ b/pdata/internal/generated_proto_summarydatapoint.go @@ -12,28 +12,37 @@ import ( "math" "sync" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// 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 + StartTimeUnixNano uint64 + TimeUnixNano uint64 + Count uint64 + Sum float64 + QuantileValues []*SummaryDataPointValueAtQuantile + Flags uint32 +} + var ( protoPoolSummaryDataPoint = sync.Pool{ New: func() any { - return &otlpmetrics.SummaryDataPoint{} + return &SummaryDataPoint{} }, } ) -func NewOrigSummaryDataPoint() *otlpmetrics.SummaryDataPoint { +func NewSummaryDataPoint() *SummaryDataPoint { if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.SummaryDataPoint{} + return &SummaryDataPoint{} } - return protoPoolSummaryDataPoint.Get().(*otlpmetrics.SummaryDataPoint) + return protoPoolSummaryDataPoint.Get().(*SummaryDataPoint) } -func DeleteOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, nullable bool) { +func DeleteSummaryDataPoint(orig *SummaryDataPoint, nullable bool) { if orig == nil { return } @@ -44,10 +53,10 @@ func DeleteOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, nullable boo } for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) + DeleteKeyValue(&orig.Attributes[i], false) } for i := range orig.QuantileValues { - DeleteOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[i], true) + DeleteSummaryDataPointValueAtQuantile(orig.QuantileValues[i], true) } orig.Reset() @@ -56,42 +65,98 @@ func DeleteOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, nullable boo } } -func CopyOrigSummaryDataPoint(dest, src *otlpmetrics.SummaryDataPoint) { +func CopySummaryDataPoint(dest, src *SummaryDataPoint) *SummaryDataPoint { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil } - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) + + if dest == nil { + dest = NewSummaryDataPoint() + } + 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 = CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest.QuantileValues, src.QuantileValues) + + dest.QuantileValues = CopySummaryDataPointValueAtQuantilePtrSlice(dest.QuantileValues, src.QuantileValues) + dest.Flags = src.Flags + + return dest } -func GenTestOrigSummaryDataPoint() *otlpmetrics.SummaryDataPoint { - orig := NewOrigSummaryDataPoint() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.StartTimeUnixNano = 1234567890 - orig.TimeUnixNano = 1234567890 - orig.Count = uint64(13) - orig.Sum = float64(3.1415926) - orig.QuantileValues = GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice() - orig.Flags = 1 - return orig +func CopySummaryDataPointSlice(dest, src []SummaryDataPoint) []SummaryDataPoint { + var newDest []SummaryDataPoint + if cap(dest) < len(src) { + newDest = make([]SummaryDataPoint, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSummaryDataPoint(&dest[i], false) + } + } + for i := range src { + CopySummaryDataPoint(&newDest[i], &src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, dest *json.Stream) { +func CopySummaryDataPointPtrSlice(dest, src []*SummaryDataPoint) []*SummaryDataPoint { + var newDest []*SummaryDataPoint + if cap(dest) < len(src) { + newDest = make([]*SummaryDataPoint, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSummaryDataPoint() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSummaryDataPoint(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSummaryDataPoint() + } + } + for i := range src { + CopySummaryDataPoint(newDest[i], src[i]) + } + return newDest +} + +func (orig *SummaryDataPoint) Reset() { + *orig = SummaryDataPoint{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *SummaryDataPoint) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if len(orig.Attributes) > 0 { dest.WriteObjectField("attributes") dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) + orig.Attributes[0].MarshalJSON(dest) for i := 1; i < len(orig.Attributes); i++ { dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) + orig.Attributes[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -114,10 +179,10 @@ func MarshalJSONOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, dest *j if len(orig.QuantileValues) > 0 { dest.WriteObjectField("quantileValues") dest.WriteArrayStart() - MarshalJSONOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[0], dest) + orig.QuantileValues[0].MarshalJSON(dest) for i := 1; i < len(orig.QuantileValues); i++ { dest.WriteMore() - MarshalJSONOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[i], dest) + orig.QuantileValues[i].MarshalJSON(dest) } dest.WriteArrayEnd() } @@ -128,14 +193,14 @@ func MarshalJSONOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, dest *j dest.WriteObjectEnd() } -// UnmarshalJSONOrigSummaryDataPoint unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *SummaryDataPoint) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "attributes": for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) + orig.Attributes = append(orig.Attributes, KeyValue{}) + orig.Attributes[len(orig.Attributes)-1].UnmarshalJSON(iter) } case "startTimeUnixNano", "start_time_unix_nano": @@ -148,8 +213,8 @@ func UnmarshalJSONOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, iter orig.Sum = iter.ReadFloat64() case "quantileValues", "quantile_values": for iter.ReadArray() { - orig.QuantileValues = append(orig.QuantileValues, NewOrigSummaryDataPoint_ValueAtQuantile()) - UnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[len(orig.QuantileValues)-1], iter) + orig.QuantileValues = append(orig.QuantileValues, NewSummaryDataPointValueAtQuantile()) + orig.QuantileValues[len(orig.QuantileValues)-1].UnmarshalJSON(iter) } case "flags": @@ -160,12 +225,12 @@ func UnmarshalJSONOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, iter } } -func SizeProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint) int { +func (orig *SummaryDataPoint) SizeProto() int { var n int var l int _ = l for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) + l = orig.Attributes[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.StartTimeUnixNano != 0 { @@ -181,7 +246,7 @@ func SizeProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint) int { n += 9 } for i := range orig.QuantileValues { - l = SizeProtoOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[i]) + l = orig.QuantileValues[i].SizeProto() n += 1 + proto.Sov(uint64(l)) + l } if orig.Flags != 0 { @@ -190,12 +255,12 @@ func SizeProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint) int { return n } -func MarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf []byte) int { +func (orig *SummaryDataPoint) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) + l = orig.Attributes[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -226,7 +291,7 @@ func MarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf [] buf[pos] = 0x29 } for i := len(orig.QuantileValues) - 1; i >= 0; i-- { - l = MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[i], buf[:pos]) + l = orig.QuantileValues[i].MarshalProto(buf[:pos]) pos -= l pos = proto.EncodeVarint(buf, pos, uint64(l)) pos-- @@ -240,7 +305,7 @@ func MarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf [] return len(buf) - pos } -func UnmarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf []byte) error { +func (orig *SummaryDataPoint) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -265,8 +330,8 @@ func UnmarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf return err } startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) + orig.Attributes = append(orig.Attributes, KeyValue{}) + err = orig.Attributes[len(orig.Attributes)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -329,8 +394,8 @@ func UnmarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf return err } startPos := pos - length - orig.QuantileValues = append(orig.QuantileValues, NewOrigSummaryDataPoint_ValueAtQuantile()) - err = UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(orig.QuantileValues[len(orig.QuantileValues)-1], buf[startPos:pos]) + orig.QuantileValues = append(orig.QuantileValues, NewSummaryDataPointValueAtQuantile()) + err = orig.QuantileValues[len(orig.QuantileValues)-1].UnmarshalProto(buf[startPos:pos]) if err != nil { return err } @@ -355,3 +420,32 @@ func UnmarshalProtoOrigSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, buf } return nil } + +func GenTestSummaryDataPoint() *SummaryDataPoint { + orig := NewSummaryDataPoint() + orig.Attributes = []KeyValue{{}, *GenTestKeyValue()} + orig.StartTimeUnixNano = uint64(13) + orig.TimeUnixNano = uint64(13) + orig.Count = uint64(13) + orig.Sum = float64(3.1415926) + orig.QuantileValues = []*SummaryDataPointValueAtQuantile{{}, GenTestSummaryDataPointValueAtQuantile()} + orig.Flags = uint32(13) + return orig +} + +func GenTestSummaryDataPointPtrSlice() []*SummaryDataPoint { + orig := make([]*SummaryDataPoint, 5) + orig[0] = NewSummaryDataPoint() + orig[1] = GenTestSummaryDataPoint() + orig[2] = NewSummaryDataPoint() + orig[3] = GenTestSummaryDataPoint() + orig[4] = NewSummaryDataPoint() + return orig +} + +func GenTestSummaryDataPointSlice() []SummaryDataPoint { + orig := make([]SummaryDataPoint, 5) + orig[1] = *GenTestSummaryDataPoint() + orig[3] = *GenTestSummaryDataPoint() + return orig +} diff --git a/pdata/internal/generated_wrapper_summarydatapoint_test.go b/pdata/internal/generated_proto_summarydatapoint_test.go similarity index 52% rename from pdata/internal/generated_wrapper_summarydatapoint_test.go rename to pdata/internal/generated_proto_summarydatapoint_test.go index 855723ba551..dd10cca6652 100644 --- a/pdata/internal/generated_wrapper_summarydatapoint_test.go +++ b/pdata/internal/generated_proto_summarydatapoint_test.go @@ -16,12 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigSummaryDataPoint(t *testing.T) { +func TestCopySummaryDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesSummaryDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -31,26 +29,76 @@ func TestCopyOrigSummaryDataPoint(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigSummaryDataPoint() - CopyOrigSummaryDataPoint(dest, src) + dest := NewSummaryDataPoint() + CopySummaryDataPoint(dest, src) assert.Equal(t, src, dest) - CopyOrigSummaryDataPoint(dest, dest) + CopySummaryDataPoint(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigSummaryDataPointUnknown(t *testing.T) { +func TestCopySummaryDataPointSlice(t *testing.T) { + src := []SummaryDataPoint{} + dest := []SummaryDataPoint{} + // Test CopyTo empty + dest = CopySummaryDataPointSlice(dest, src) + assert.Equal(t, []SummaryDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestSummaryDataPointSlice() + dest = CopySummaryDataPointSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointSlice(), dest) + + // Test CopyTo same size slice + dest = CopySummaryDataPointSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySummaryDataPointSlice(dest, []SummaryDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySummaryDataPointSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointSlice(), dest) +} + +func TestCopySummaryDataPointPtrSlice(t *testing.T) { + src := []*SummaryDataPoint{} + dest := []*SummaryDataPoint{} + // Test CopyTo empty + dest = CopySummaryDataPointPtrSlice(dest, src) + assert.Equal(t, []*SummaryDataPoint{}, dest) + + // Test CopyTo larger slice + src = GenTestSummaryDataPointPtrSlice() + dest = CopySummaryDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySummaryDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySummaryDataPointPtrSlice(dest, []*SummaryDataPoint{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySummaryDataPointPtrSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSummaryDataPointUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigSummaryDataPoint() - UnmarshalJSONOrigSummaryDataPoint(dest, iter) + dest := NewSummaryDataPoint() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSummaryDataPoint(), dest) + assert.Equal(t, NewSummaryDataPoint(), dest) } -func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint(t *testing.T) { +func TestMarshalAndUnmarshalJSONSummaryDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesSummaryDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -62,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigSummaryDataPoint(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigSummaryDataPoint() - UnmarshalJSONOrigSummaryDataPoint(dest, iter) + dest := NewSummaryDataPoint() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigSummaryDataPoint(dest, true) + DeleteSummaryDataPoint(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigSummaryDataPointFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoSummaryDataPointFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesSummaryDataPoint() { t.Run(name, func(t *testing.T) { - dest := NewOrigSummaryDataPoint() - require.Error(t, UnmarshalProtoOrigSummaryDataPoint(dest, buf)) + dest := NewSummaryDataPoint() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigSummaryDataPointUnknown(t *testing.T) { - dest := NewOrigSummaryDataPoint() +func TestMarshalAndUnmarshalProtoSummaryDataPointUnknown(t *testing.T) { + dest := NewSummaryDataPoint() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSummaryDataPoint(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSummaryDataPoint(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSummaryDataPoint(), dest) } -func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint(t *testing.T) { +func TestMarshalAndUnmarshalProtoSummaryDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesSummaryDataPoint() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -104,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigSummaryDataPoint(src)) - gotSize := MarshalProtoOrigSummaryDataPoint(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigSummaryDataPoint() - require.NoError(t, UnmarshalProtoOrigSummaryDataPoint(dest, buf)) + dest := NewSummaryDataPoint() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigSummaryDataPoint(dest, true) + DeleteSummaryDataPoint(dest, true) }) } } @@ -121,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufSummaryDataPoint(t *testing.T) { for name, src := range genTestEncodingValuesSummaryDataPoint() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSummaryDataPoint(src)) - gotSize := MarshalProtoOrigSummaryDataPoint(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpmetrics.SummaryDataPoint{} @@ -131,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufSummaryDataPoint(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigSummaryDataPoint() - require.NoError(t, UnmarshalProtoOrigSummaryDataPoint(dest, goBuf)) + dest := NewSummaryDataPoint() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -158,15 +206,15 @@ func genTestFailingUnmarshalProtoValuesSummaryDataPoint() map[string][]byte { } } -func genTestEncodingValuesSummaryDataPoint() map[string]*otlpmetrics.SummaryDataPoint { - return map[string]*otlpmetrics.SummaryDataPoint{ - "empty": NewOrigSummaryDataPoint(), - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, - "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, - "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, - "Count/test": {Count: uint64(13)}, - "Sum/test": {Sum: float64(3.1415926)}, - "QuantileValues/default_and_test": {QuantileValues: []*otlpmetrics.SummaryDataPoint_ValueAtQuantile{{}, GenTestOrigSummaryDataPoint_ValueAtQuantile()}}, - "Flags/test": {Flags: uint32(13)}, +func genTestEncodingValuesSummaryDataPoint() map[string]*SummaryDataPoint { + return map[string]*SummaryDataPoint{ + "empty": NewSummaryDataPoint(), + "Attributes/test": {Attributes: []KeyValue{{}, *GenTestKeyValue()}}, + "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, + "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, + "Count/test": {Count: uint64(13)}, + "Sum/test": {Sum: float64(3.1415926)}, + "QuantileValues/test": {QuantileValues: []*SummaryDataPointValueAtQuantile{{}, GenTestSummaryDataPointValueAtQuantile()}}, + "Flags/test": {Flags: uint32(13)}, } } diff --git a/pdata/internal/generated_proto_summarydatapointvalueatquantile.go b/pdata/internal/generated_proto_summarydatapointvalueatquantile.go new file mode 100644 index 00000000000..ae92399aa41 --- /dev/null +++ b/pdata/internal/generated_proto_summarydatapointvalueatquantile.go @@ -0,0 +1,258 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "math" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// SummaryDataPointValueAtQuantile is a quantile value within a Summary data point. +type SummaryDataPointValueAtQuantile struct { + Quantile float64 + Value float64 +} + +var ( + protoPoolSummaryDataPointValueAtQuantile = sync.Pool{ + New: func() any { + return &SummaryDataPointValueAtQuantile{} + }, + } +) + +func NewSummaryDataPointValueAtQuantile() *SummaryDataPointValueAtQuantile { + if !UseProtoPooling.IsEnabled() { + return &SummaryDataPointValueAtQuantile{} + } + return protoPoolSummaryDataPointValueAtQuantile.Get().(*SummaryDataPointValueAtQuantile) +} + +func DeleteSummaryDataPointValueAtQuantile(orig *SummaryDataPointValueAtQuantile, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolSummaryDataPointValueAtQuantile.Put(orig) + } +} + +func CopySummaryDataPointValueAtQuantile(dest, src *SummaryDataPointValueAtQuantile) *SummaryDataPointValueAtQuantile { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewSummaryDataPointValueAtQuantile() + } + dest.Quantile = src.Quantile + + dest.Value = src.Value + + return dest +} + +func CopySummaryDataPointValueAtQuantileSlice(dest, src []SummaryDataPointValueAtQuantile) []SummaryDataPointValueAtQuantile { + var newDest []SummaryDataPointValueAtQuantile + if cap(dest) < len(src) { + newDest = make([]SummaryDataPointValueAtQuantile, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSummaryDataPointValueAtQuantile(&dest[i], false) + } + } + for i := range src { + CopySummaryDataPointValueAtQuantile(&newDest[i], &src[i]) + } + return newDest +} + +func CopySummaryDataPointValueAtQuantilePtrSlice(dest, src []*SummaryDataPointValueAtQuantile) []*SummaryDataPointValueAtQuantile { + var newDest []*SummaryDataPointValueAtQuantile + if cap(dest) < len(src) { + newDest = make([]*SummaryDataPointValueAtQuantile, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSummaryDataPointValueAtQuantile() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteSummaryDataPointValueAtQuantile(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewSummaryDataPointValueAtQuantile() + } + } + for i := range src { + CopySummaryDataPointValueAtQuantile(newDest[i], src[i]) + } + return newDest +} + +func (orig *SummaryDataPointValueAtQuantile) Reset() { + *orig = SummaryDataPointValueAtQuantile{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *SummaryDataPointValueAtQuantile) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Quantile != float64(0) { + dest.WriteObjectField("quantile") + dest.WriteFloat64(orig.Quantile) + } + if orig.Value != float64(0) { + dest.WriteObjectField("value") + dest.WriteFloat64(orig.Value) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *SummaryDataPointValueAtQuantile) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "quantile": + orig.Quantile = iter.ReadFloat64() + case "value": + orig.Value = iter.ReadFloat64() + default: + iter.Skip() + } + } +} + +func (orig *SummaryDataPointValueAtQuantile) SizeProto() int { + var n int + var l int + _ = l + if orig.Quantile != 0 { + n += 9 + } + if orig.Value != 0 { + n += 9 + } + return n +} + +func (orig *SummaryDataPointValueAtQuantile) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.Quantile != 0 { + pos -= 8 + binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Quantile)) + pos-- + buf[pos] = 0x9 + } + if orig.Value != 0 { + pos -= 8 + binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Value)) + pos-- + buf[pos] = 0x11 + } + return len(buf) - pos +} + +func (orig *SummaryDataPointValueAtQuantile) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeI64 { + return fmt.Errorf("proto: wrong wireType = %d for field Quantile", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeI64(buf, pos) + if err != nil { + return err + } + + orig.Quantile = math.Float64frombits(num) + + case 2: + if wireType != proto.WireTypeI64 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeI64(buf, pos) + if err != nil { + return err + } + + orig.Value = math.Float64frombits(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestSummaryDataPointValueAtQuantile() *SummaryDataPointValueAtQuantile { + orig := NewSummaryDataPointValueAtQuantile() + orig.Quantile = float64(3.1415926) + orig.Value = float64(3.1415926) + return orig +} + +func GenTestSummaryDataPointValueAtQuantilePtrSlice() []*SummaryDataPointValueAtQuantile { + orig := make([]*SummaryDataPointValueAtQuantile, 5) + orig[0] = NewSummaryDataPointValueAtQuantile() + orig[1] = GenTestSummaryDataPointValueAtQuantile() + orig[2] = NewSummaryDataPointValueAtQuantile() + orig[3] = GenTestSummaryDataPointValueAtQuantile() + orig[4] = NewSummaryDataPointValueAtQuantile() + return orig +} + +func GenTestSummaryDataPointValueAtQuantileSlice() []SummaryDataPointValueAtQuantile { + orig := make([]SummaryDataPointValueAtQuantile, 5) + orig[1] = *GenTestSummaryDataPointValueAtQuantile() + orig[3] = *GenTestSummaryDataPointValueAtQuantile() + return orig +} diff --git a/pdata/internal/generated_proto_summarydatapointvalueatquantile_test.go b/pdata/internal/generated_proto_summarydatapointvalueatquantile_test.go new file mode 100644 index 00000000000..3b4ae3654b4 --- /dev/null +++ b/pdata/internal/generated_proto_summarydatapointvalueatquantile_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopySummaryDataPointValueAtQuantile(t *testing.T) { + for name, src := range genTestEncodingValuesSummaryDataPointValueAtQuantile() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewSummaryDataPointValueAtQuantile() + CopySummaryDataPointValueAtQuantile(dest, src) + assert.Equal(t, src, dest) + CopySummaryDataPointValueAtQuantile(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopySummaryDataPointValueAtQuantileSlice(t *testing.T) { + src := []SummaryDataPointValueAtQuantile{} + dest := []SummaryDataPointValueAtQuantile{} + // Test CopyTo empty + dest = CopySummaryDataPointValueAtQuantileSlice(dest, src) + assert.Equal(t, []SummaryDataPointValueAtQuantile{}, dest) + + // Test CopyTo larger slice + src = GenTestSummaryDataPointValueAtQuantileSlice() + dest = CopySummaryDataPointValueAtQuantileSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointValueAtQuantileSlice(), dest) + + // Test CopyTo same size slice + dest = CopySummaryDataPointValueAtQuantileSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointValueAtQuantileSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySummaryDataPointValueAtQuantileSlice(dest, []SummaryDataPointValueAtQuantile{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySummaryDataPointValueAtQuantileSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointValueAtQuantileSlice(), dest) +} + +func TestCopySummaryDataPointValueAtQuantilePtrSlice(t *testing.T) { + src := []*SummaryDataPointValueAtQuantile{} + dest := []*SummaryDataPointValueAtQuantile{} + // Test CopyTo empty + dest = CopySummaryDataPointValueAtQuantilePtrSlice(dest, src) + assert.Equal(t, []*SummaryDataPointValueAtQuantile{}, dest) + + // Test CopyTo larger slice + src = GenTestSummaryDataPointValueAtQuantilePtrSlice() + dest = CopySummaryDataPointValueAtQuantilePtrSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointValueAtQuantilePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopySummaryDataPointValueAtQuantilePtrSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointValueAtQuantilePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopySummaryDataPointValueAtQuantilePtrSlice(dest, []*SummaryDataPointValueAtQuantile{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopySummaryDataPointValueAtQuantilePtrSlice(dest, src) + assert.Equal(t, GenTestSummaryDataPointValueAtQuantilePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONSummaryDataPointValueAtQuantileUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewSummaryDataPointValueAtQuantile() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewSummaryDataPointValueAtQuantile(), dest) +} + +func TestMarshalAndUnmarshalJSONSummaryDataPointValueAtQuantile(t *testing.T) { + for name, src := range genTestEncodingValuesSummaryDataPointValueAtQuantile() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewSummaryDataPointValueAtQuantile() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteSummaryDataPointValueAtQuantile(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoSummaryDataPointValueAtQuantileFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesSummaryDataPointValueAtQuantile() { + t.Run(name, func(t *testing.T) { + dest := NewSummaryDataPointValueAtQuantile() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoSummaryDataPointValueAtQuantileUnknown(t *testing.T) { + dest := NewSummaryDataPointValueAtQuantile() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewSummaryDataPointValueAtQuantile(), dest) +} + +func TestMarshalAndUnmarshalProtoSummaryDataPointValueAtQuantile(t *testing.T) { + for name, src := range genTestEncodingValuesSummaryDataPointValueAtQuantile() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewSummaryDataPointValueAtQuantile() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteSummaryDataPointValueAtQuantile(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufSummaryDataPointValueAtQuantile(t *testing.T) { + for name, src := range genTestEncodingValuesSummaryDataPointValueAtQuantile() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlpmetrics.SummaryDataPoint_ValueAtQuantile{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewSummaryDataPointValueAtQuantile() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesSummaryDataPointValueAtQuantile() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Quantile/wrong_wire_type": {0xc}, + "Quantile/missing_value": {0x9}, + "Value/wrong_wire_type": {0x14}, + "Value/missing_value": {0x11}, + } +} + +func genTestEncodingValuesSummaryDataPointValueAtQuantile() map[string]*SummaryDataPointValueAtQuantile { + return map[string]*SummaryDataPointValueAtQuantile{ + "empty": NewSummaryDataPointValueAtQuantile(), + "Quantile/test": {Quantile: float64(3.1415926)}, + "Value/test": {Value: float64(3.1415926)}, + } +} diff --git a/pdata/internal/generated_proto_tcpaddr.go b/pdata/internal/generated_proto_tcpaddr.go new file mode 100644 index 00000000000..d2590bdbb1f --- /dev/null +++ b/pdata/internal/generated_proto_tcpaddr.go @@ -0,0 +1,295 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type TCPAddr struct { + IP []byte + Port int64 + Zone string +} + +var ( + protoPoolTCPAddr = sync.Pool{ + New: func() any { + return &TCPAddr{} + }, + } +) + +func NewTCPAddr() *TCPAddr { + if !UseProtoPooling.IsEnabled() { + return &TCPAddr{} + } + return protoPoolTCPAddr.Get().(*TCPAddr) +} + +func DeleteTCPAddr(orig *TCPAddr, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolTCPAddr.Put(orig) + } +} + +func CopyTCPAddr(dest, src *TCPAddr) *TCPAddr { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewTCPAddr() + } + dest.IP = src.IP + + dest.Port = src.Port + + dest.Zone = src.Zone + + return dest +} + +func CopyTCPAddrSlice(dest, src []TCPAddr) []TCPAddr { + var newDest []TCPAddr + if cap(dest) < len(src) { + newDest = make([]TCPAddr, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteTCPAddr(&dest[i], false) + } + } + for i := range src { + CopyTCPAddr(&newDest[i], &src[i]) + } + return newDest +} + +func CopyTCPAddrPtrSlice(dest, src []*TCPAddr) []*TCPAddr { + var newDest []*TCPAddr + if cap(dest) < len(src) { + newDest = make([]*TCPAddr, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewTCPAddr() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteTCPAddr(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewTCPAddr() + } + } + for i := range src { + CopyTCPAddr(newDest[i], src[i]) + } + return newDest +} + +func (orig *TCPAddr) Reset() { + *orig = TCPAddr{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *TCPAddr) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + + if len(orig.IP) > 0 { + dest.WriteObjectField("iP") + dest.WriteBytes(orig.IP) + } + if orig.Port != int64(0) { + dest.WriteObjectField("port") + dest.WriteInt64(orig.Port) + } + if orig.Zone != "" { + dest.WriteObjectField("zone") + dest.WriteString(orig.Zone) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *TCPAddr) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "iP": + orig.IP = iter.ReadBytes() + case "port": + orig.Port = iter.ReadInt64() + case "zone": + orig.Zone = iter.ReadString() + default: + iter.Skip() + } + } +} + +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 { + n += 1 + proto.Sov(uint64(orig.Port)) + } + l = len(orig.Zone) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *TCPAddr) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.IP) + if l > 0 { + pos -= l + copy(buf[pos:], orig.IP) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + if orig.Port != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.Port)) + pos-- + buf[pos] = 0x10 + } + l = len(orig.Zone) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Zone) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *TCPAddr) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + if length != 0 { + orig.IP = make([]byte, length) + copy(orig.IP, buf[startPos:pos]) + } + + case 2: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.Port = int64(num) + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Zone", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Zone = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestTCPAddr() *TCPAddr { + orig := NewTCPAddr() + orig.IP = []byte{1, 2, 3} + orig.Port = int64(13) + orig.Zone = "test_zone" + return orig +} + +func GenTestTCPAddrPtrSlice() []*TCPAddr { + orig := make([]*TCPAddr, 5) + orig[0] = NewTCPAddr() + orig[1] = GenTestTCPAddr() + orig[2] = NewTCPAddr() + orig[3] = GenTestTCPAddr() + orig[4] = NewTCPAddr() + return orig +} + +func GenTestTCPAddrSlice() []TCPAddr { + orig := make([]TCPAddr, 5) + orig[1] = *GenTestTCPAddr() + orig[3] = *GenTestTCPAddr() + return orig +} diff --git a/pdata/internal/generated_proto_tcpaddr_test.go b/pdata/internal/generated_proto_tcpaddr_test.go new file mode 100644 index 00000000000..8e731f16c41 --- /dev/null +++ b/pdata/internal/generated_proto_tcpaddr_test.go @@ -0,0 +1,208 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyTCPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesTCPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewTCPAddr() + CopyTCPAddr(dest, src) + assert.Equal(t, src, dest) + CopyTCPAddr(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyTCPAddrSlice(t *testing.T) { + src := []TCPAddr{} + dest := []TCPAddr{} + // Test CopyTo empty + dest = CopyTCPAddrSlice(dest, src) + assert.Equal(t, []TCPAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestTCPAddrSlice() + dest = CopyTCPAddrSlice(dest, src) + assert.Equal(t, GenTestTCPAddrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyTCPAddrSlice(dest, src) + assert.Equal(t, GenTestTCPAddrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyTCPAddrSlice(dest, []TCPAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyTCPAddrSlice(dest, src) + assert.Equal(t, GenTestTCPAddrSlice(), dest) +} + +func TestCopyTCPAddrPtrSlice(t *testing.T) { + src := []*TCPAddr{} + dest := []*TCPAddr{} + // Test CopyTo empty + dest = CopyTCPAddrPtrSlice(dest, src) + assert.Equal(t, []*TCPAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestTCPAddrPtrSlice() + dest = CopyTCPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestTCPAddrPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyTCPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestTCPAddrPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyTCPAddrPtrSlice(dest, []*TCPAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyTCPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestTCPAddrPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONTCPAddrUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewTCPAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewTCPAddr(), dest) +} + +func TestMarshalAndUnmarshalJSONTCPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesTCPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewTCPAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteTCPAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoTCPAddrFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesTCPAddr() { + t.Run(name, func(t *testing.T) { + dest := NewTCPAddr() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoTCPAddrUnknown(t *testing.T) { + dest := NewTCPAddr() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewTCPAddr(), dest) +} + +func TestMarshalAndUnmarshalProtoTCPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesTCPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewTCPAddr() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteTCPAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufTCPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesTCPAddr() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewTCPAddr() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesTCPAddr() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "IP/wrong_wire_type": {0xc}, + "IP/missing_value": {0xa}, + "Port/wrong_wire_type": {0x14}, + "Port/missing_value": {0x10}, + "Zone/wrong_wire_type": {0x1c}, + "Zone/missing_value": {0x1a}, + } +} + +func genTestEncodingValuesTCPAddr() map[string]*TCPAddr { + return map[string]*TCPAddr{ + "empty": NewTCPAddr(), + "IP/test": {IP: []byte{1, 2, 3}}, + "Port/test": {Port: int64(13)}, + "Zone/test": {Zone: "test_zone"}, + } +} diff --git a/pdata/internal/generated_proto_tracesdata.go b/pdata/internal/generated_proto_tracesdata.go new file mode 100644 index 00000000000..f63549f1cbc --- /dev/null +++ b/pdata/internal/generated_proto_tracesdata.go @@ -0,0 +1,247 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +// TracesData represents the traces data that can be stored in a persistent storage, +// OR can be embedded by other protocols that transfer OTLP traces data but do not +// implement the OTLP protocol. +type TracesData struct { + ResourceSpans []*ResourceSpans +} + +var ( + protoPoolTracesData = sync.Pool{ + New: func() any { + return &TracesData{} + }, + } +) + +func NewTracesData() *TracesData { + if !UseProtoPooling.IsEnabled() { + return &TracesData{} + } + return protoPoolTracesData.Get().(*TracesData) +} + +func DeleteTracesData(orig *TracesData, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + for i := range orig.ResourceSpans { + DeleteResourceSpans(orig.ResourceSpans[i], true) + } + + orig.Reset() + if nullable { + protoPoolTracesData.Put(orig) + } +} + +func CopyTracesData(dest, src *TracesData) *TracesData { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewTracesData() + } + dest.ResourceSpans = CopyResourceSpansPtrSlice(dest.ResourceSpans, src.ResourceSpans) + + return dest +} + +func CopyTracesDataSlice(dest, src []TracesData) []TracesData { + var newDest []TracesData + if cap(dest) < len(src) { + newDest = make([]TracesData, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteTracesData(&dest[i], false) + } + } + for i := range src { + CopyTracesData(&newDest[i], &src[i]) + } + return newDest +} + +func CopyTracesDataPtrSlice(dest, src []*TracesData) []*TracesData { + var newDest []*TracesData + if cap(dest) < len(src) { + newDest = make([]*TracesData, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewTracesData() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteTracesData(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewTracesData() + } + } + for i := range src { + CopyTracesData(newDest[i], src[i]) + } + return newDest +} + +func (orig *TracesData) Reset() { + *orig = TracesData{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *TracesData) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if len(orig.ResourceSpans) > 0 { + dest.WriteObjectField("resourceSpans") + dest.WriteArrayStart() + orig.ResourceSpans[0].MarshalJSON(dest) + for i := 1; i < len(orig.ResourceSpans); i++ { + dest.WriteMore() + orig.ResourceSpans[i].MarshalJSON(dest) + } + dest.WriteArrayEnd() + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *TracesData) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "resourceSpans", "resource_spans": + for iter.ReadArray() { + orig.ResourceSpans = append(orig.ResourceSpans, NewResourceSpans()) + orig.ResourceSpans[len(orig.ResourceSpans)-1].UnmarshalJSON(iter) + } + + default: + iter.Skip() + } + } +} + +func (orig *TracesData) SizeProto() int { + var n int + var l int + _ = l + for i := range orig.ResourceSpans { + l = orig.ResourceSpans[i].SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *TracesData) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + for i := len(orig.ResourceSpans) - 1; i >= 0; i-- { + l = orig.ResourceSpans[i].MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + return len(buf) - pos +} + +func (orig *TracesData) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceSpans", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.ResourceSpans = append(orig.ResourceSpans, NewResourceSpans()) + err = orig.ResourceSpans[len(orig.ResourceSpans)-1].UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestTracesData() *TracesData { + orig := NewTracesData() + orig.ResourceSpans = []*ResourceSpans{{}, GenTestResourceSpans()} + return orig +} + +func GenTestTracesDataPtrSlice() []*TracesData { + orig := make([]*TracesData, 5) + orig[0] = NewTracesData() + orig[1] = GenTestTracesData() + orig[2] = NewTracesData() + orig[3] = GenTestTracesData() + orig[4] = NewTracesData() + return orig +} + +func GenTestTracesDataSlice() []TracesData { + orig := make([]TracesData, 5) + orig[1] = *GenTestTracesData() + orig[3] = *GenTestTracesData() + return orig +} diff --git a/pdata/internal/generated_proto_tracesdata_test.go b/pdata/internal/generated_proto_tracesdata_test.go new file mode 100644 index 00000000000..33c7fdcb385 --- /dev/null +++ b/pdata/internal/generated_proto_tracesdata_test.go @@ -0,0 +1,202 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + gootlptrace "go.opentelemetry.io/proto/slim/otlp/trace/v1" + "google.golang.org/protobuf/proto" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyTracesData(t *testing.T) { + for name, src := range genTestEncodingValuesTracesData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewTracesData() + CopyTracesData(dest, src) + assert.Equal(t, src, dest) + CopyTracesData(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyTracesDataSlice(t *testing.T) { + src := []TracesData{} + dest := []TracesData{} + // Test CopyTo empty + dest = CopyTracesDataSlice(dest, src) + assert.Equal(t, []TracesData{}, dest) + + // Test CopyTo larger slice + src = GenTestTracesDataSlice() + dest = CopyTracesDataSlice(dest, src) + assert.Equal(t, GenTestTracesDataSlice(), dest) + + // Test CopyTo same size slice + dest = CopyTracesDataSlice(dest, src) + assert.Equal(t, GenTestTracesDataSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyTracesDataSlice(dest, []TracesData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyTracesDataSlice(dest, src) + assert.Equal(t, GenTestTracesDataSlice(), dest) +} + +func TestCopyTracesDataPtrSlice(t *testing.T) { + src := []*TracesData{} + dest := []*TracesData{} + // Test CopyTo empty + dest = CopyTracesDataPtrSlice(dest, src) + assert.Equal(t, []*TracesData{}, dest) + + // Test CopyTo larger slice + src = GenTestTracesDataPtrSlice() + dest = CopyTracesDataPtrSlice(dest, src) + assert.Equal(t, GenTestTracesDataPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyTracesDataPtrSlice(dest, src) + assert.Equal(t, GenTestTracesDataPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyTracesDataPtrSlice(dest, []*TracesData{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyTracesDataPtrSlice(dest, src) + assert.Equal(t, GenTestTracesDataPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONTracesDataUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewTracesData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewTracesData(), dest) +} + +func TestMarshalAndUnmarshalJSONTracesData(t *testing.T) { + for name, src := range genTestEncodingValuesTracesData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewTracesData() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteTracesData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoTracesDataFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesTracesData() { + t.Run(name, func(t *testing.T) { + dest := NewTracesData() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoTracesDataUnknown(t *testing.T) { + dest := NewTracesData() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewTracesData(), dest) +} + +func TestMarshalAndUnmarshalProtoTracesData(t *testing.T) { + for name, src := range genTestEncodingValuesTracesData() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewTracesData() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteTracesData(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufTracesData(t *testing.T) { + for name, src := range genTestEncodingValuesTracesData() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &gootlptrace.TracesData{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewTracesData() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesTracesData() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "ResourceSpans/wrong_wire_type": {0xc}, + "ResourceSpans/missing_value": {0xa}, + } +} + +func genTestEncodingValuesTracesData() map[string]*TracesData { + return map[string]*TracesData{ + "empty": NewTracesData(), + "ResourceSpans/test": {ResourceSpans: []*ResourceSpans{{}, GenTestResourceSpans()}}, + } +} diff --git a/pdata/internal/generated_proto_tracesrequest.go b/pdata/internal/generated_proto_tracesrequest.go new file mode 100644 index 00000000000..d3e3fd5633d --- /dev/null +++ b/pdata/internal/generated_proto_tracesrequest.go @@ -0,0 +1,300 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "encoding/binary" + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type TracesRequest struct { + RequestContext *RequestContext + TracesData TracesData + FormatVersion uint32 +} + +var ( + protoPoolTracesRequest = sync.Pool{ + New: func() any { + return &TracesRequest{} + }, + } +) + +func NewTracesRequest() *TracesRequest { + if !UseProtoPooling.IsEnabled() { + return &TracesRequest{} + } + return protoPoolTracesRequest.Get().(*TracesRequest) +} + +func DeleteTracesRequest(orig *TracesRequest, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + DeleteRequestContext(orig.RequestContext, true) + DeleteTracesData(&orig.TracesData, false) + + orig.Reset() + if nullable { + protoPoolTracesRequest.Put(orig) + } +} + +func CopyTracesRequest(dest, src *TracesRequest) *TracesRequest { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewTracesRequest() + } + dest.RequestContext = CopyRequestContext(dest.RequestContext, src.RequestContext) + + CopyTracesData(&dest.TracesData, &src.TracesData) + + dest.FormatVersion = src.FormatVersion + + return dest +} + +func CopyTracesRequestSlice(dest, src []TracesRequest) []TracesRequest { + var newDest []TracesRequest + if cap(dest) < len(src) { + newDest = make([]TracesRequest, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteTracesRequest(&dest[i], false) + } + } + for i := range src { + CopyTracesRequest(&newDest[i], &src[i]) + } + return newDest +} + +func CopyTracesRequestPtrSlice(dest, src []*TracesRequest) []*TracesRequest { + var newDest []*TracesRequest + if cap(dest) < len(src) { + newDest = make([]*TracesRequest, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewTracesRequest() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteTracesRequest(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewTracesRequest() + } + } + for i := range src { + CopyTracesRequest(newDest[i], src[i]) + } + return newDest +} + +func (orig *TracesRequest) Reset() { + *orig = TracesRequest{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *TracesRequest) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.RequestContext != nil { + dest.WriteObjectField("requestContext") + orig.RequestContext.MarshalJSON(dest) + } + dest.WriteObjectField("tracesData") + orig.TracesData.MarshalJSON(dest) + if orig.FormatVersion != uint32(0) { + dest.WriteObjectField("formatVersion") + dest.WriteUint32(orig.FormatVersion) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *TracesRequest) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "requestContext", "request_context": + orig.RequestContext = NewRequestContext() + orig.RequestContext.UnmarshalJSON(iter) + case "tracesData", "traces_data": + + orig.TracesData.UnmarshalJSON(iter) + case "formatVersion", "format_version": + orig.FormatVersion = iter.ReadUint32() + default: + iter.Skip() + } + } +} + +func (orig *TracesRequest) SizeProto() int { + var n int + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + } + l = orig.TracesData.SizeProto() + n += 1 + proto.Sov(uint64(l)) + l + if orig.FormatVersion != 0 { + n += 5 + } + return n +} + +func (orig *TracesRequest) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + if orig.RequestContext != nil { + l = orig.RequestContext.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + l = orig.TracesData.MarshalProto(buf[:pos]) + pos -= l + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + + if orig.FormatVersion != 0 { + pos -= 4 + binary.LittleEndian.PutUint32(buf[pos:], uint32(orig.FormatVersion)) + pos-- + buf[pos] = 0xd + } + return len(buf) - pos +} + +func (orig *TracesRequest) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + orig.RequestContext = NewRequestContext() + err = orig.RequestContext.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field TracesData", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + + err = orig.TracesData.UnmarshalProto(buf[startPos:pos]) + if err != nil { + return err + } + + case 1: + if wireType != proto.WireTypeI32 { + return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) + } + var num uint32 + num, pos, err = proto.ConsumeI32(buf, pos) + if err != nil { + return err + } + + orig.FormatVersion = uint32(num) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestTracesRequest() *TracesRequest { + orig := NewTracesRequest() + orig.RequestContext = GenTestRequestContext() + orig.TracesData = *GenTestTracesData() + orig.FormatVersion = uint32(13) + return orig +} + +func GenTestTracesRequestPtrSlice() []*TracesRequest { + orig := make([]*TracesRequest, 5) + orig[0] = NewTracesRequest() + orig[1] = GenTestTracesRequest() + orig[2] = NewTracesRequest() + orig[3] = GenTestTracesRequest() + orig[4] = NewTracesRequest() + return orig +} + +func GenTestTracesRequestSlice() []TracesRequest { + orig := make([]TracesRequest, 5) + orig[1] = *GenTestTracesRequest() + orig[3] = *GenTestTracesRequest() + return orig +} diff --git a/pdata/internal/generated_proto_tracesrequest_test.go b/pdata/internal/generated_proto_tracesrequest_test.go new file mode 100644 index 00000000000..de53ebdc7ee --- /dev/null +++ b/pdata/internal/generated_proto_tracesrequest_test.go @@ -0,0 +1,208 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyTracesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesTracesRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewTracesRequest() + CopyTracesRequest(dest, src) + assert.Equal(t, src, dest) + CopyTracesRequest(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyTracesRequestSlice(t *testing.T) { + src := []TracesRequest{} + dest := []TracesRequest{} + // Test CopyTo empty + dest = CopyTracesRequestSlice(dest, src) + assert.Equal(t, []TracesRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestTracesRequestSlice() + dest = CopyTracesRequestSlice(dest, src) + assert.Equal(t, GenTestTracesRequestSlice(), dest) + + // Test CopyTo same size slice + dest = CopyTracesRequestSlice(dest, src) + assert.Equal(t, GenTestTracesRequestSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyTracesRequestSlice(dest, []TracesRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyTracesRequestSlice(dest, src) + assert.Equal(t, GenTestTracesRequestSlice(), dest) +} + +func TestCopyTracesRequestPtrSlice(t *testing.T) { + src := []*TracesRequest{} + dest := []*TracesRequest{} + // Test CopyTo empty + dest = CopyTracesRequestPtrSlice(dest, src) + assert.Equal(t, []*TracesRequest{}, dest) + + // Test CopyTo larger slice + src = GenTestTracesRequestPtrSlice() + dest = CopyTracesRequestPtrSlice(dest, src) + assert.Equal(t, GenTestTracesRequestPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyTracesRequestPtrSlice(dest, src) + assert.Equal(t, GenTestTracesRequestPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyTracesRequestPtrSlice(dest, []*TracesRequest{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyTracesRequestPtrSlice(dest, src) + assert.Equal(t, GenTestTracesRequestPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONTracesRequestUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewTracesRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewTracesRequest(), dest) +} + +func TestMarshalAndUnmarshalJSONTracesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesTracesRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewTracesRequest() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteTracesRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoTracesRequestFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesTracesRequest() { + t.Run(name, func(t *testing.T) { + dest := NewTracesRequest() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoTracesRequestUnknown(t *testing.T) { + dest := NewTracesRequest() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewTracesRequest(), dest) +} + +func TestMarshalAndUnmarshalProtoTracesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesTracesRequest() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewTracesRequest() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteTracesRequest(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufTracesRequest(t *testing.T) { + for name, src := range genTestEncodingValuesTracesRequest() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewTracesRequest() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesTracesRequest() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "RequestContext/wrong_wire_type": {0x14}, + "RequestContext/missing_value": {0x12}, + "TracesData/wrong_wire_type": {0x1c}, + "TracesData/missing_value": {0x1a}, + "FormatVersion/wrong_wire_type": {0xc}, + "FormatVersion/missing_value": {0xd}, + } +} + +func genTestEncodingValuesTracesRequest() map[string]*TracesRequest { + return map[string]*TracesRequest{ + "empty": NewTracesRequest(), + "RequestContext/test": {RequestContext: GenTestRequestContext()}, + "TracesData/test": {TracesData: *GenTestTracesData()}, + "FormatVersion/test": {FormatVersion: uint32(13)}, + } +} diff --git a/pdata/internal/generated_proto_udpaddr.go b/pdata/internal/generated_proto_udpaddr.go new file mode 100644 index 00000000000..f197afd194a --- /dev/null +++ b/pdata/internal/generated_proto_udpaddr.go @@ -0,0 +1,295 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type UDPAddr struct { + IP []byte + Port int64 + Zone string +} + +var ( + protoPoolUDPAddr = sync.Pool{ + New: func() any { + return &UDPAddr{} + }, + } +) + +func NewUDPAddr() *UDPAddr { + if !UseProtoPooling.IsEnabled() { + return &UDPAddr{} + } + return protoPoolUDPAddr.Get().(*UDPAddr) +} + +func DeleteUDPAddr(orig *UDPAddr, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolUDPAddr.Put(orig) + } +} + +func CopyUDPAddr(dest, src *UDPAddr) *UDPAddr { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewUDPAddr() + } + dest.IP = src.IP + + dest.Port = src.Port + + dest.Zone = src.Zone + + return dest +} + +func CopyUDPAddrSlice(dest, src []UDPAddr) []UDPAddr { + var newDest []UDPAddr + if cap(dest) < len(src) { + newDest = make([]UDPAddr, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteUDPAddr(&dest[i], false) + } + } + for i := range src { + CopyUDPAddr(&newDest[i], &src[i]) + } + return newDest +} + +func CopyUDPAddrPtrSlice(dest, src []*UDPAddr) []*UDPAddr { + var newDest []*UDPAddr + if cap(dest) < len(src) { + newDest = make([]*UDPAddr, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewUDPAddr() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteUDPAddr(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewUDPAddr() + } + } + for i := range src { + CopyUDPAddr(newDest[i], src[i]) + } + return newDest +} + +func (orig *UDPAddr) Reset() { + *orig = UDPAddr{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *UDPAddr) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + + if len(orig.IP) > 0 { + dest.WriteObjectField("iP") + dest.WriteBytes(orig.IP) + } + if orig.Port != int64(0) { + dest.WriteObjectField("port") + dest.WriteInt64(orig.Port) + } + if orig.Zone != "" { + dest.WriteObjectField("zone") + dest.WriteString(orig.Zone) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *UDPAddr) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "iP": + orig.IP = iter.ReadBytes() + case "port": + orig.Port = iter.ReadInt64() + case "zone": + orig.Zone = iter.ReadString() + default: + iter.Skip() + } + } +} + +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 { + n += 1 + proto.Sov(uint64(orig.Port)) + } + l = len(orig.Zone) + if l > 0 { + n += 1 + proto.Sov(uint64(l)) + l + } + return n +} + +func (orig *UDPAddr) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.IP) + if l > 0 { + pos -= l + copy(buf[pos:], orig.IP) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + if orig.Port != 0 { + pos = proto.EncodeVarint(buf, pos, uint64(orig.Port)) + pos-- + buf[pos] = 0x10 + } + l = len(orig.Zone) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Zone) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x1a + } + return len(buf) - pos +} + +func (orig *UDPAddr) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field IP", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + if length != 0 { + orig.IP = make([]byte, length) + copy(orig.IP, buf[startPos:pos]) + } + + case 2: + if wireType != proto.WireTypeVarint { + return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) + } + var num uint64 + num, pos, err = proto.ConsumeVarint(buf, pos) + if err != nil { + return err + } + + orig.Port = int64(num) + + case 3: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Zone", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Zone = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestUDPAddr() *UDPAddr { + orig := NewUDPAddr() + orig.IP = []byte{1, 2, 3} + orig.Port = int64(13) + orig.Zone = "test_zone" + return orig +} + +func GenTestUDPAddrPtrSlice() []*UDPAddr { + orig := make([]*UDPAddr, 5) + orig[0] = NewUDPAddr() + orig[1] = GenTestUDPAddr() + orig[2] = NewUDPAddr() + orig[3] = GenTestUDPAddr() + orig[4] = NewUDPAddr() + return orig +} + +func GenTestUDPAddrSlice() []UDPAddr { + orig := make([]UDPAddr, 5) + orig[1] = *GenTestUDPAddr() + orig[3] = *GenTestUDPAddr() + return orig +} diff --git a/pdata/internal/generated_proto_udpaddr_test.go b/pdata/internal/generated_proto_udpaddr_test.go new file mode 100644 index 00000000000..027e542fe16 --- /dev/null +++ b/pdata/internal/generated_proto_udpaddr_test.go @@ -0,0 +1,208 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyUDPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUDPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewUDPAddr() + CopyUDPAddr(dest, src) + assert.Equal(t, src, dest) + CopyUDPAddr(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyUDPAddrSlice(t *testing.T) { + src := []UDPAddr{} + dest := []UDPAddr{} + // Test CopyTo empty + dest = CopyUDPAddrSlice(dest, src) + assert.Equal(t, []UDPAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestUDPAddrSlice() + dest = CopyUDPAddrSlice(dest, src) + assert.Equal(t, GenTestUDPAddrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyUDPAddrSlice(dest, src) + assert.Equal(t, GenTestUDPAddrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyUDPAddrSlice(dest, []UDPAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyUDPAddrSlice(dest, src) + assert.Equal(t, GenTestUDPAddrSlice(), dest) +} + +func TestCopyUDPAddrPtrSlice(t *testing.T) { + src := []*UDPAddr{} + dest := []*UDPAddr{} + // Test CopyTo empty + dest = CopyUDPAddrPtrSlice(dest, src) + assert.Equal(t, []*UDPAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestUDPAddrPtrSlice() + dest = CopyUDPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestUDPAddrPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyUDPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestUDPAddrPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyUDPAddrPtrSlice(dest, []*UDPAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyUDPAddrPtrSlice(dest, src) + assert.Equal(t, GenTestUDPAddrPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONUDPAddrUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewUDPAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewUDPAddr(), dest) +} + +func TestMarshalAndUnmarshalJSONUDPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUDPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewUDPAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteUDPAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoUDPAddrFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesUDPAddr() { + t.Run(name, func(t *testing.T) { + dest := NewUDPAddr() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoUDPAddrUnknown(t *testing.T) { + dest := NewUDPAddr() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewUDPAddr(), dest) +} + +func TestMarshalAndUnmarshalProtoUDPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUDPAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewUDPAddr() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteUDPAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufUDPAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUDPAddr() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewUDPAddr() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesUDPAddr() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "IP/wrong_wire_type": {0xc}, + "IP/missing_value": {0xa}, + "Port/wrong_wire_type": {0x14}, + "Port/missing_value": {0x10}, + "Zone/wrong_wire_type": {0x1c}, + "Zone/missing_value": {0x1a}, + } +} + +func genTestEncodingValuesUDPAddr() map[string]*UDPAddr { + return map[string]*UDPAddr{ + "empty": NewUDPAddr(), + "IP/test": {IP: []byte{1, 2, 3}}, + "Port/test": {Port: int64(13)}, + "Zone/test": {Zone: "test_zone"}, + } +} diff --git a/pdata/internal/generated_proto_unixaddr.go b/pdata/internal/generated_proto_unixaddr.go new file mode 100644 index 00000000000..b7d25686c02 --- /dev/null +++ b/pdata/internal/generated_proto_unixaddr.go @@ -0,0 +1,261 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "fmt" + "sync" + + "go.opentelemetry.io/collector/pdata/internal/json" + "go.opentelemetry.io/collector/pdata/internal/proto" +) + +type UnixAddr struct { + Name string + Net string +} + +var ( + protoPoolUnixAddr = sync.Pool{ + New: func() any { + return &UnixAddr{} + }, + } +) + +func NewUnixAddr() *UnixAddr { + if !UseProtoPooling.IsEnabled() { + return &UnixAddr{} + } + return protoPoolUnixAddr.Get().(*UnixAddr) +} + +func DeleteUnixAddr(orig *UnixAddr, nullable bool) { + if orig == nil { + return + } + + if !UseProtoPooling.IsEnabled() { + orig.Reset() + return + } + + orig.Reset() + if nullable { + protoPoolUnixAddr.Put(orig) + } +} + +func CopyUnixAddr(dest, src *UnixAddr) *UnixAddr { + // If copying to same object, just return. + if src == dest { + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewUnixAddr() + } + dest.Name = src.Name + + dest.Net = src.Net + + return dest +} + +func CopyUnixAddrSlice(dest, src []UnixAddr) []UnixAddr { + var newDest []UnixAddr + if cap(dest) < len(src) { + newDest = make([]UnixAddr, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteUnixAddr(&dest[i], false) + } + } + for i := range src { + CopyUnixAddr(&newDest[i], &src[i]) + } + return newDest +} + +func CopyUnixAddrPtrSlice(dest, src []*UnixAddr) []*UnixAddr { + var newDest []*UnixAddr + if cap(dest) < len(src) { + newDest = make([]*UnixAddr, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewUnixAddr() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteUnixAddr(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewUnixAddr() + } + } + for i := range src { + CopyUnixAddr(newDest[i], src[i]) + } + return newDest +} + +func (orig *UnixAddr) Reset() { + *orig = UnixAddr{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *UnixAddr) MarshalJSON(dest *json.Stream) { + dest.WriteObjectStart() + if orig.Name != "" { + dest.WriteObjectField("name") + dest.WriteString(orig.Name) + } + if orig.Net != "" { + dest.WriteObjectField("net") + dest.WriteString(orig.Net) + } + dest.WriteObjectEnd() +} + +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *UnixAddr) UnmarshalJSON(iter *json.Iterator) { + for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { + switch f { + case "name": + orig.Name = iter.ReadString() + case "net": + orig.Net = iter.ReadString() + default: + iter.Skip() + } + } +} + +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 + } + return n +} + +func (orig *UnixAddr) MarshalProto(buf []byte) int { + pos := len(buf) + var l int + _ = l + l = len(orig.Name) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Name) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0xa + } + l = len(orig.Net) + if l > 0 { + pos -= l + copy(buf[pos:], orig.Net) + pos = proto.EncodeVarint(buf, pos, uint64(l)) + pos-- + buf[pos] = 0x12 + } + return len(buf) - pos +} + +func (orig *UnixAddr) UnmarshalProto(buf []byte) error { + var err error + var fieldNum int32 + var wireType proto.WireType + + l := len(buf) + pos := 0 + for pos < l { + // If in a group parsing, move to the next tag. + fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) + if err != nil { + return err + } + switch fieldNum { + + case 1: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Name = string(buf[startPos:pos]) + + case 2: + if wireType != proto.WireTypeLen { + return fmt.Errorf("proto: wrong wireType = %d for field Net", wireType) + } + var length int + length, pos, err = proto.ConsumeLen(buf, pos) + if err != nil { + return err + } + startPos := pos - length + orig.Net = string(buf[startPos:pos]) + default: + pos, err = proto.ConsumeUnknown(buf, pos, wireType) + if err != nil { + return err + } + } + } + return nil +} + +func GenTestUnixAddr() *UnixAddr { + orig := NewUnixAddr() + orig.Name = "test_name" + orig.Net = "test_net" + return orig +} + +func GenTestUnixAddrPtrSlice() []*UnixAddr { + orig := make([]*UnixAddr, 5) + orig[0] = NewUnixAddr() + orig[1] = GenTestUnixAddr() + orig[2] = NewUnixAddr() + orig[3] = GenTestUnixAddr() + orig[4] = NewUnixAddr() + return orig +} + +func GenTestUnixAddrSlice() []UnixAddr { + orig := make([]UnixAddr, 5) + orig[1] = *GenTestUnixAddr() + orig[3] = *GenTestUnixAddr() + return orig +} diff --git a/pdata/internal/generated_proto_unixaddr_test.go b/pdata/internal/generated_proto_unixaddr_test.go new file mode 100644 index 00000000000..5e1ca9d8afc --- /dev/null +++ b/pdata/internal/generated_proto_unixaddr_test.go @@ -0,0 +1,205 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +import ( + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/emptypb" + + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestCopyUnixAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUnixAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + dest := NewUnixAddr() + CopyUnixAddr(dest, src) + assert.Equal(t, src, dest) + CopyUnixAddr(dest, dest) + assert.Equal(t, src, dest) + }) + } + } +} + +func TestCopyUnixAddrSlice(t *testing.T) { + src := []UnixAddr{} + dest := []UnixAddr{} + // Test CopyTo empty + dest = CopyUnixAddrSlice(dest, src) + assert.Equal(t, []UnixAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestUnixAddrSlice() + dest = CopyUnixAddrSlice(dest, src) + assert.Equal(t, GenTestUnixAddrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyUnixAddrSlice(dest, src) + assert.Equal(t, GenTestUnixAddrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyUnixAddrSlice(dest, []UnixAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyUnixAddrSlice(dest, src) + assert.Equal(t, GenTestUnixAddrSlice(), dest) +} + +func TestCopyUnixAddrPtrSlice(t *testing.T) { + src := []*UnixAddr{} + dest := []*UnixAddr{} + // Test CopyTo empty + dest = CopyUnixAddrPtrSlice(dest, src) + assert.Equal(t, []*UnixAddr{}, dest) + + // Test CopyTo larger slice + src = GenTestUnixAddrPtrSlice() + dest = CopyUnixAddrPtrSlice(dest, src) + assert.Equal(t, GenTestUnixAddrPtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyUnixAddrPtrSlice(dest, src) + assert.Equal(t, GenTestUnixAddrPtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyUnixAddrPtrSlice(dest, []*UnixAddr{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyUnixAddrPtrSlice(dest, src) + assert.Equal(t, GenTestUnixAddrPtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONUnixAddrUnknown(t *testing.T) { + iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) + defer json.ReturnIterator(iter) + dest := NewUnixAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + assert.Equal(t, NewUnixAddr(), dest) +} + +func TestMarshalAndUnmarshalJSONUnixAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUnixAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := NewUnixAddr() + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) + DeleteUnixAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoUnixAddrFailing(t *testing.T) { + for name, buf := range genTestFailingUnmarshalProtoValuesUnixAddr() { + t.Run(name, func(t *testing.T) { + dest := NewUnixAddr() + require.Error(t, dest.UnmarshalProto(buf)) + }) + } +} + +func TestMarshalAndUnmarshalProtoUnixAddrUnknown(t *testing.T) { + dest := NewUnixAddr() + // message Test { required int64 field = 1313; } encoding { "field": "1234" } + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewUnixAddr(), dest) +} + +func TestMarshalAndUnmarshalProtoUnixAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUnixAddr() { + for _, pooling := range []bool{true, false} { + t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { + prevPooling := UseProtoPooling.IsEnabled() + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) + defer func() { + require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) + }() + + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + dest := NewUnixAddr() + require.NoError(t, dest.UnmarshalProto(buf)) + + assert.Equal(t, src, dest) + DeleteUnixAddr(dest, true) + }) + } + } +} + +func TestMarshalAndUnmarshalProtoViaProtobufUnixAddr(t *testing.T) { + for name, src := range genTestEncodingValuesUnixAddr() { + t.Run(name, func(t *testing.T) { + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) + assert.Equal(t, len(buf), gotSize) + + goDest := &emptypb.Empty{} + require.NoError(t, proto.Unmarshal(buf, goDest)) + + goBuf, err := proto.Marshal(goDest) + require.NoError(t, err) + + dest := NewUnixAddr() + require.NoError(t, dest.UnmarshalProto(goBuf)) + assert.Equal(t, src, dest) + }) + } +} + +func genTestFailingUnmarshalProtoValuesUnixAddr() map[string][]byte { + return map[string][]byte{ + "invalid_field": {0x02}, + "Name/wrong_wire_type": {0xc}, + "Name/missing_value": {0xa}, + "Net/wrong_wire_type": {0x14}, + "Net/missing_value": {0x12}, + } +} + +func genTestEncodingValuesUnixAddr() map[string]*UnixAddr { + return map[string]*UnixAddr{ + "empty": NewUnixAddr(), + "Name/test": {Name: "test_name"}, + "Net/test": {Net: "test_net"}, + } +} diff --git a/pdata/internal/generated_wrapper_valuetype.go b/pdata/internal/generated_proto_valuetype.go similarity index 53% rename from pdata/internal/generated_wrapper_valuetype.go rename to pdata/internal/generated_proto_valuetype.go index b0b79601d26..a070ab3e70f 100644 --- a/pdata/internal/generated_wrapper_valuetype.go +++ b/pdata/internal/generated_proto_valuetype.go @@ -10,27 +10,33 @@ import ( "fmt" "sync" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/proto" ) +// ValueType describes the type and units of a value, with an optional aggregation temporality. +type ValueType struct { + TypeStrindex int32 + UnitStrindex int32 + AggregationTemporality AggregationTemporality +} + var ( protoPoolValueType = sync.Pool{ New: func() any { - return &otlpprofiles.ValueType{} + return &ValueType{} }, } ) -func NewOrigValueType() *otlpprofiles.ValueType { +func NewValueType() *ValueType { if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.ValueType{} + return &ValueType{} } - return protoPoolValueType.Get().(*otlpprofiles.ValueType) + return protoPoolValueType.Get().(*ValueType) } -func DeleteOrigValueType(orig *otlpprofiles.ValueType, nullable bool) { +func DeleteValueType(orig *ValueType, nullable bool) { if orig == nil { return } @@ -46,26 +52,82 @@ func DeleteOrigValueType(orig *otlpprofiles.ValueType, nullable bool) { } } -func CopyOrigValueType(dest, src *otlpprofiles.ValueType) { +func CopyValueType(dest, src *ValueType) *ValueType { // If copying to same object, just return. if src == dest { - return + return dest + } + + if src == nil { + return nil + } + + if dest == nil { + dest = NewValueType() } dest.TypeStrindex = src.TypeStrindex + dest.UnitStrindex = src.UnitStrindex + dest.AggregationTemporality = src.AggregationTemporality + + return dest } -func GenTestOrigValueType() *otlpprofiles.ValueType { - orig := NewOrigValueType() - orig.TypeStrindex = int32(13) - orig.UnitStrindex = int32(13) - orig.AggregationTemporality = otlpprofiles.AggregationTemporality(1) - return orig +func CopyValueTypeSlice(dest, src []ValueType) []ValueType { + var newDest []ValueType + if cap(dest) < len(src) { + newDest = make([]ValueType, len(src)) + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteValueType(&dest[i], false) + } + } + for i := range src { + CopyValueType(&newDest[i], &src[i]) + } + return newDest +} + +func CopyValueTypePtrSlice(dest, src []*ValueType) []*ValueType { + var newDest []*ValueType + if cap(dest) < len(src) { + newDest = make([]*ValueType, len(src)) + // Copy old pointers to re-use. + copy(newDest, dest) + // Add new pointers for missing elements from len(dest) to len(srt). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewValueType() + } + } else { + newDest = dest[:len(src)] + // Cleanup the rest of the elements so GC can free the memory. + // This can happen when len(src) < len(dest) < cap(dest). + for i := len(src); i < len(dest); i++ { + DeleteValueType(dest[i], true) + dest[i] = nil + } + // Add new pointers for missing elements. + // This can happen when len(dest) < len(src) < cap(dest). + for i := len(dest); i < len(src); i++ { + newDest[i] = NewValueType() + } + } + for i := range src { + CopyValueType(newDest[i], src[i]) + } + return newDest } -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigValueType(orig *otlpprofiles.ValueType, dest *json.Stream) { +func (orig *ValueType) Reset() { + *orig = ValueType{} +} + +// MarshalJSON marshals all properties from the current struct to the destination stream. +func (orig *ValueType) MarshalJSON(dest *json.Stream) { dest.WriteObjectStart() if orig.TypeStrindex != int32(0) { dest.WriteObjectField("typeStrindex") @@ -83,8 +145,8 @@ func MarshalJSONOrigValueType(orig *otlpprofiles.ValueType, dest *json.Stream) { dest.WriteObjectEnd() } -// UnmarshalJSONOrigValueType unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigValueType(orig *otlpprofiles.ValueType, iter *json.Iterator) { +// UnmarshalJSON unmarshals all properties from the current struct from the source iterator. +func (orig *ValueType) UnmarshalJSON(iter *json.Iterator) { for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { switch f { case "typeStrindex", "type_strindex": @@ -92,14 +154,14 @@ func UnmarshalJSONOrigValueType(orig *otlpprofiles.ValueType, iter *json.Iterato case "unitStrindex", "unit_strindex": orig.UnitStrindex = iter.ReadInt32() case "aggregationTemporality", "aggregation_temporality": - orig.AggregationTemporality = otlpprofiles.AggregationTemporality(iter.ReadEnumValue(otlpprofiles.AggregationTemporality_value)) + orig.AggregationTemporality = AggregationTemporality(iter.ReadEnumValue(AggregationTemporality_value)) default: iter.Skip() } } } -func SizeProtoOrigValueType(orig *otlpprofiles.ValueType) int { +func (orig *ValueType) SizeProto() int { var n int var l int _ = l @@ -115,7 +177,7 @@ func SizeProtoOrigValueType(orig *otlpprofiles.ValueType) int { return n } -func MarshalProtoOrigValueType(orig *otlpprofiles.ValueType, buf []byte) int { +func (orig *ValueType) MarshalProto(buf []byte) int { pos := len(buf) var l int _ = l @@ -137,7 +199,7 @@ func MarshalProtoOrigValueType(orig *otlpprofiles.ValueType, buf []byte) int { return len(buf) - pos } -func UnmarshalProtoOrigValueType(orig *otlpprofiles.ValueType, buf []byte) error { +func (orig *ValueType) UnmarshalProto(buf []byte) error { var err error var fieldNum int32 var wireType proto.WireType @@ -186,7 +248,7 @@ func UnmarshalProtoOrigValueType(orig *otlpprofiles.ValueType, buf []byte) error return err } - orig.AggregationTemporality = otlpprofiles.AggregationTemporality(num) + orig.AggregationTemporality = AggregationTemporality(num) default: pos, err = proto.ConsumeUnknown(buf, pos, wireType) if err != nil { @@ -196,3 +258,28 @@ func UnmarshalProtoOrigValueType(orig *otlpprofiles.ValueType, buf []byte) error } return nil } + +func GenTestValueType() *ValueType { + orig := NewValueType() + orig.TypeStrindex = int32(13) + orig.UnitStrindex = int32(13) + orig.AggregationTemporality = AggregationTemporality(13) + return orig +} + +func GenTestValueTypePtrSlice() []*ValueType { + orig := make([]*ValueType, 5) + orig[0] = NewValueType() + orig[1] = GenTestValueType() + orig[2] = NewValueType() + orig[3] = GenTestValueType() + orig[4] = NewValueType() + return orig +} + +func GenTestValueTypeSlice() []ValueType { + orig := make([]ValueType, 5) + orig[1] = *GenTestValueType() + orig[3] = *GenTestValueType() + return orig +} diff --git a/pdata/internal/generated_wrapper_valuetype_test.go b/pdata/internal/generated_proto_valuetype_test.go similarity index 55% rename from pdata/internal/generated_wrapper_valuetype_test.go rename to pdata/internal/generated_proto_valuetype_test.go index 84e8c0e4227..bb98e3a4dac 100644 --- a/pdata/internal/generated_wrapper_valuetype_test.go +++ b/pdata/internal/generated_proto_valuetype_test.go @@ -16,11 +16,10 @@ import ( "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/featuregate" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" ) -func TestCopyOrigValueType(t *testing.T) { +func TestCopyValueType(t *testing.T) { for name, src := range genTestEncodingValuesValueType() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -30,26 +29,76 @@ func TestCopyOrigValueType(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - dest := NewOrigValueType() - CopyOrigValueType(dest, src) + dest := NewValueType() + CopyValueType(dest, src) assert.Equal(t, src, dest) - CopyOrigValueType(dest, dest) + CopyValueType(dest, dest) assert.Equal(t, src, dest) }) } } } -func TestMarshalAndUnmarshalJSONOrigValueTypeUnknown(t *testing.T) { +func TestCopyValueTypeSlice(t *testing.T) { + src := []ValueType{} + dest := []ValueType{} + // Test CopyTo empty + dest = CopyValueTypeSlice(dest, src) + assert.Equal(t, []ValueType{}, dest) + + // Test CopyTo larger slice + src = GenTestValueTypeSlice() + dest = CopyValueTypeSlice(dest, src) + assert.Equal(t, GenTestValueTypeSlice(), dest) + + // Test CopyTo same size slice + dest = CopyValueTypeSlice(dest, src) + assert.Equal(t, GenTestValueTypeSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyValueTypeSlice(dest, []ValueType{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyValueTypeSlice(dest, src) + assert.Equal(t, GenTestValueTypeSlice(), dest) +} + +func TestCopyValueTypePtrSlice(t *testing.T) { + src := []*ValueType{} + dest := []*ValueType{} + // Test CopyTo empty + dest = CopyValueTypePtrSlice(dest, src) + assert.Equal(t, []*ValueType{}, dest) + + // Test CopyTo larger slice + src = GenTestValueTypePtrSlice() + dest = CopyValueTypePtrSlice(dest, src) + assert.Equal(t, GenTestValueTypePtrSlice(), dest) + + // Test CopyTo same size slice + dest = CopyValueTypePtrSlice(dest, src) + assert.Equal(t, GenTestValueTypePtrSlice(), dest) + + // Test CopyTo smaller size slice + dest = CopyValueTypePtrSlice(dest, []*ValueType{}) + assert.Len(t, dest, 0) + + // Test CopyTo larger slice with enough capacity + dest = CopyValueTypePtrSlice(dest, src) + assert.Equal(t, GenTestValueTypePtrSlice(), dest) +} + +func TestMarshalAndUnmarshalJSONValueTypeUnknown(t *testing.T) { iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) defer json.ReturnIterator(iter) - dest := NewOrigValueType() - UnmarshalJSONOrigValueType(dest, iter) + dest := NewValueType() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigValueType(), dest) + assert.Equal(t, NewValueType(), dest) } -func TestMarshalAndUnmarshalJSONOrigValueType(t *testing.T) { +func TestMarshalAndUnmarshalJSONValueType(t *testing.T) { for name, src := range genTestEncodingValuesValueType() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -61,39 +110,39 @@ func TestMarshalAndUnmarshalJSONOrigValueType(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - MarshalJSONOrigValueType(src, stream) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) - dest := NewOrigValueType() - UnmarshalJSONOrigValueType(dest, iter) + dest := NewValueType() + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) - DeleteOrigValueType(dest, true) + DeleteValueType(dest, true) }) } } } -func TestMarshalAndUnmarshalProtoOrigValueTypeFailing(t *testing.T) { +func TestMarshalAndUnmarshalProtoValueTypeFailing(t *testing.T) { for name, buf := range genTestFailingUnmarshalProtoValuesValueType() { t.Run(name, func(t *testing.T) { - dest := NewOrigValueType() - require.Error(t, UnmarshalProtoOrigValueType(dest, buf)) + dest := NewValueType() + require.Error(t, dest.UnmarshalProto(buf)) }) } } -func TestMarshalAndUnmarshalProtoOrigValueTypeUnknown(t *testing.T) { - dest := NewOrigValueType() +func TestMarshalAndUnmarshalProtoValueTypeUnknown(t *testing.T) { + dest := NewValueType() // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigValueType(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigValueType(), dest) + require.NoError(t, dest.UnmarshalProto([]byte{0x88, 0x52, 0xD2, 0x09})) + assert.Equal(t, NewValueType(), dest) } -func TestMarshalAndUnmarshalProtoOrigValueType(t *testing.T) { +func TestMarshalAndUnmarshalProtoValueType(t *testing.T) { for name, src := range genTestEncodingValuesValueType() { for _, pooling := range []bool{true, false} { t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { @@ -103,15 +152,15 @@ func TestMarshalAndUnmarshalProtoOrigValueType(t *testing.T) { require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) }() - buf := make([]byte, SizeProtoOrigValueType(src)) - gotSize := MarshalProtoOrigValueType(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) - dest := NewOrigValueType() - require.NoError(t, UnmarshalProtoOrigValueType(dest, buf)) + dest := NewValueType() + require.NoError(t, dest.UnmarshalProto(buf)) assert.Equal(t, src, dest) - DeleteOrigValueType(dest, true) + DeleteValueType(dest, true) }) } } @@ -120,8 +169,8 @@ func TestMarshalAndUnmarshalProtoOrigValueType(t *testing.T) { func TestMarshalAndUnmarshalProtoViaProtobufValueType(t *testing.T) { for name, src := range genTestEncodingValuesValueType() { t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigValueType(src)) - gotSize := MarshalProtoOrigValueType(src, buf) + buf := make([]byte, src.SizeProto()) + gotSize := src.MarshalProto(buf) assert.Equal(t, len(buf), gotSize) goDest := &gootlpprofiles.ValueType{} @@ -130,8 +179,8 @@ func TestMarshalAndUnmarshalProtoViaProtobufValueType(t *testing.T) { goBuf, err := proto.Marshal(goDest) require.NoError(t, err) - dest := NewOrigValueType() - require.NoError(t, UnmarshalProtoOrigValueType(dest, goBuf)) + dest := NewValueType() + require.NoError(t, dest.UnmarshalProto(goBuf)) assert.Equal(t, src, dest) }) } @@ -149,11 +198,11 @@ func genTestFailingUnmarshalProtoValuesValueType() map[string][]byte { } } -func genTestEncodingValuesValueType() map[string]*otlpprofiles.ValueType { - return map[string]*otlpprofiles.ValueType{ - "empty": NewOrigValueType(), +func genTestEncodingValuesValueType() map[string]*ValueType { + return map[string]*ValueType{ + "empty": NewValueType(), "TypeStrindex/test": {TypeStrindex: int32(13)}, "UnitStrindex/test": {UnitStrindex: int32(13)}, - "AggregationTemporality/test": {AggregationTemporality: otlpprofiles.AggregationTemporality(13)}, + "AggregationTemporality/test": {AggregationTemporality: AggregationTemporality(13)}, } } diff --git a/pdata/internal/generated_wrapper_anyvalue.go b/pdata/internal/generated_wrapper_anyvalue.go deleted file mode 100644 index 013192398cb..00000000000 --- a/pdata/internal/generated_wrapper_anyvalue.go +++ /dev/null @@ -1,596 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "encoding/binary" - "fmt" - "math" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolAnyValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue{} - }, - } - - ProtoPoolAnyValue_StringValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_StringValue{} - }, - } - - ProtoPoolAnyValue_BoolValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_BoolValue{} - }, - } - - ProtoPoolAnyValue_IntValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_IntValue{} - }, - } - - ProtoPoolAnyValue_DoubleValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_DoubleValue{} - }, - } - - ProtoPoolAnyValue_ArrayValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_ArrayValue{} - }, - } - - ProtoPoolAnyValue_KvlistValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_KvlistValue{} - }, - } - - ProtoPoolAnyValue_BytesValue = sync.Pool{ - New: func() any { - return &otlpcommon.AnyValue_BytesValue{} - }, - } -) - -func NewOrigAnyValue() *otlpcommon.AnyValue { - if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue{} - } - return protoPoolAnyValue.Get().(*otlpcommon.AnyValue) -} - -func DeleteOrigAnyValue(orig *otlpcommon.AnyValue, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - switch ov := orig.Value.(type) { - case *otlpcommon.AnyValue_StringValue: - if UseProtoPooling.IsEnabled() { - ov.StringValue = "" - ProtoPoolAnyValue_StringValue.Put(ov) - } - case *otlpcommon.AnyValue_BoolValue: - if UseProtoPooling.IsEnabled() { - ov.BoolValue = false - ProtoPoolAnyValue_BoolValue.Put(ov) - } - case *otlpcommon.AnyValue_IntValue: - if UseProtoPooling.IsEnabled() { - ov.IntValue = int64(0) - ProtoPoolAnyValue_IntValue.Put(ov) - } - case *otlpcommon.AnyValue_DoubleValue: - if UseProtoPooling.IsEnabled() { - ov.DoubleValue = float64(0) - ProtoPoolAnyValue_DoubleValue.Put(ov) - } - case *otlpcommon.AnyValue_ArrayValue: - DeleteOrigArrayValue(ov.ArrayValue, true) - ov.ArrayValue = nil - ProtoPoolAnyValue_ArrayValue.Put(ov) - case *otlpcommon.AnyValue_KvlistValue: - DeleteOrigKeyValueList(ov.KvlistValue, true) - ov.KvlistValue = nil - ProtoPoolAnyValue_KvlistValue.Put(ov) - case *otlpcommon.AnyValue_BytesValue: - if UseProtoPooling.IsEnabled() { - ov.BytesValue = nil - ProtoPoolAnyValue_BytesValue.Put(ov) - } - - } - - orig.Reset() - if nullable { - protoPoolAnyValue.Put(orig) - } -} - -func CopyOrigAnyValue(dest, src *otlpcommon.AnyValue) { - // If copying to same object, just return. - if src == dest { - return - } - switch t := src.Value.(type) { - case *otlpcommon.AnyValue_StringValue: - var ov *otlpcommon.AnyValue_StringValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_StringValue{} - } else { - ov = ProtoPoolAnyValue_StringValue.Get().(*otlpcommon.AnyValue_StringValue) - } - ov.StringValue = t.StringValue - dest.Value = ov - case *otlpcommon.AnyValue_BoolValue: - var ov *otlpcommon.AnyValue_BoolValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_BoolValue{} - } else { - ov = ProtoPoolAnyValue_BoolValue.Get().(*otlpcommon.AnyValue_BoolValue) - } - ov.BoolValue = t.BoolValue - dest.Value = ov - case *otlpcommon.AnyValue_IntValue: - var ov *otlpcommon.AnyValue_IntValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_IntValue{} - } else { - ov = ProtoPoolAnyValue_IntValue.Get().(*otlpcommon.AnyValue_IntValue) - } - ov.IntValue = t.IntValue - dest.Value = ov - case *otlpcommon.AnyValue_DoubleValue: - var ov *otlpcommon.AnyValue_DoubleValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_DoubleValue{} - } else { - ov = ProtoPoolAnyValue_DoubleValue.Get().(*otlpcommon.AnyValue_DoubleValue) - } - ov.DoubleValue = t.DoubleValue - dest.Value = ov - case *otlpcommon.AnyValue_ArrayValue: - var ov *otlpcommon.AnyValue_ArrayValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_ArrayValue{} - } else { - ov = ProtoPoolAnyValue_ArrayValue.Get().(*otlpcommon.AnyValue_ArrayValue) - } - ov.ArrayValue = NewOrigArrayValue() - CopyOrigArrayValue(ov.ArrayValue, t.ArrayValue) - dest.Value = ov - case *otlpcommon.AnyValue_KvlistValue: - var ov *otlpcommon.AnyValue_KvlistValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_KvlistValue{} - } else { - ov = ProtoPoolAnyValue_KvlistValue.Get().(*otlpcommon.AnyValue_KvlistValue) - } - ov.KvlistValue = NewOrigKeyValueList() - CopyOrigKeyValueList(ov.KvlistValue, t.KvlistValue) - dest.Value = ov - case *otlpcommon.AnyValue_BytesValue: - var ov *otlpcommon.AnyValue_BytesValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_BytesValue{} - } else { - ov = ProtoPoolAnyValue_BytesValue.Get().(*otlpcommon.AnyValue_BytesValue) - } - ov.BytesValue = t.BytesValue - dest.Value = ov - } -} - -func GenTestOrigAnyValue() *otlpcommon.AnyValue { - orig := NewOrigAnyValue() - orig.Value = &otlpcommon.AnyValue_BoolValue{BoolValue: true} - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigAnyValue(orig *otlpcommon.AnyValue, dest *json.Stream) { - dest.WriteObjectStart() - switch orig := orig.Value.(type) { - case *otlpcommon.AnyValue_StringValue: - dest.WriteObjectField("stringValue") - dest.WriteString(orig.StringValue) - case *otlpcommon.AnyValue_BoolValue: - dest.WriteObjectField("boolValue") - dest.WriteBool(orig.BoolValue) - case *otlpcommon.AnyValue_IntValue: - dest.WriteObjectField("intValue") - dest.WriteInt64(orig.IntValue) - case *otlpcommon.AnyValue_DoubleValue: - dest.WriteObjectField("doubleValue") - dest.WriteFloat64(orig.DoubleValue) - case *otlpcommon.AnyValue_ArrayValue: - if orig.ArrayValue != nil { - dest.WriteObjectField("arrayValue") - MarshalJSONOrigArrayValue(orig.ArrayValue, dest) - } - case *otlpcommon.AnyValue_KvlistValue: - if orig.KvlistValue != nil { - dest.WriteObjectField("kvlistValue") - MarshalJSONOrigKeyValueList(orig.KvlistValue, dest) - } - case *otlpcommon.AnyValue_BytesValue: - - dest.WriteObjectField("bytesValue") - dest.WriteBytes(orig.BytesValue) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigValue unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigAnyValue(orig *otlpcommon.AnyValue, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - - case "stringValue", "string_value": - { - var ov *otlpcommon.AnyValue_StringValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_StringValue{} - } else { - ov = ProtoPoolAnyValue_StringValue.Get().(*otlpcommon.AnyValue_StringValue) - } - ov.StringValue = iter.ReadString() - orig.Value = ov - } - - case "boolValue", "bool_value": - { - var ov *otlpcommon.AnyValue_BoolValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_BoolValue{} - } else { - ov = ProtoPoolAnyValue_BoolValue.Get().(*otlpcommon.AnyValue_BoolValue) - } - ov.BoolValue = iter.ReadBool() - orig.Value = ov - } - - case "intValue", "int_value": - { - var ov *otlpcommon.AnyValue_IntValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_IntValue{} - } else { - ov = ProtoPoolAnyValue_IntValue.Get().(*otlpcommon.AnyValue_IntValue) - } - ov.IntValue = iter.ReadInt64() - orig.Value = ov - } - - case "doubleValue", "double_value": - { - var ov *otlpcommon.AnyValue_DoubleValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_DoubleValue{} - } else { - ov = ProtoPoolAnyValue_DoubleValue.Get().(*otlpcommon.AnyValue_DoubleValue) - } - ov.DoubleValue = iter.ReadFloat64() - orig.Value = ov - } - - case "arrayValue", "array_value": - { - var ov *otlpcommon.AnyValue_ArrayValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_ArrayValue{} - } else { - ov = ProtoPoolAnyValue_ArrayValue.Get().(*otlpcommon.AnyValue_ArrayValue) - } - ov.ArrayValue = NewOrigArrayValue() - UnmarshalJSONOrigArrayValue(ov.ArrayValue, iter) - orig.Value = ov - } - - case "kvlistValue", "kvlist_value": - { - var ov *otlpcommon.AnyValue_KvlistValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_KvlistValue{} - } else { - ov = ProtoPoolAnyValue_KvlistValue.Get().(*otlpcommon.AnyValue_KvlistValue) - } - ov.KvlistValue = NewOrigKeyValueList() - UnmarshalJSONOrigKeyValueList(ov.KvlistValue, iter) - orig.Value = ov - } - - case "bytesValue", "bytes_value": - { - var ov *otlpcommon.AnyValue_BytesValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_BytesValue{} - } else { - ov = ProtoPoolAnyValue_BytesValue.Get().(*otlpcommon.AnyValue_BytesValue) - } - ov.BytesValue = iter.ReadBytes() - orig.Value = ov - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigAnyValue(orig *otlpcommon.AnyValue) int { - var n int - var l int - _ = l - switch orig := orig.Value.(type) { - case nil: - _ = orig - break - case *otlpcommon.AnyValue_StringValue: - l = len(orig.StringValue) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpcommon.AnyValue_BoolValue: - n += 2 - case *otlpcommon.AnyValue_IntValue: - n += 1 + proto.Sov(uint64(orig.IntValue)) - case *otlpcommon.AnyValue_DoubleValue: - n += 9 - case *otlpcommon.AnyValue_ArrayValue: - l = SizeProtoOrigArrayValue(orig.ArrayValue) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpcommon.AnyValue_KvlistValue: - l = SizeProtoOrigKeyValueList(orig.KvlistValue) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpcommon.AnyValue_BytesValue: - l = len(orig.BytesValue) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigAnyValue(orig *otlpcommon.AnyValue, buf []byte) int { - pos := len(buf) - var l int - _ = l - switch orig := orig.Value.(type) { - case *otlpcommon.AnyValue_StringValue: - l = len(orig.StringValue) - pos -= l - copy(buf[pos:], orig.StringValue) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - case *otlpcommon.AnyValue_BoolValue: - pos-- - if orig.BoolValue { - buf[pos] = 1 - } else { - buf[pos] = 0 - } - pos-- - buf[pos] = 0x10 - - case *otlpcommon.AnyValue_IntValue: - pos = proto.EncodeVarint(buf, pos, uint64(orig.IntValue)) - pos-- - buf[pos] = 0x18 - - case *otlpcommon.AnyValue_DoubleValue: - pos -= 8 - binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.DoubleValue)) - pos-- - buf[pos] = 0x21 - - case *otlpcommon.AnyValue_ArrayValue: - - l = MarshalProtoOrigArrayValue(orig.ArrayValue, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x2a - - case *otlpcommon.AnyValue_KvlistValue: - - l = MarshalProtoOrigKeyValueList(orig.KvlistValue, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x32 - - case *otlpcommon.AnyValue_BytesValue: - l = len(orig.BytesValue) - pos -= l - copy(buf[pos:], orig.BytesValue) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x3a - - } - return len(buf) - pos -} - -func UnmarshalProtoOrigAnyValue(orig *otlpcommon.AnyValue, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field StringValue", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpcommon.AnyValue_StringValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_StringValue{} - } else { - ov = ProtoPoolAnyValue_StringValue.Get().(*otlpcommon.AnyValue_StringValue) - } - ov.StringValue = string(buf[startPos:pos]) - orig.Value = ov - - case 2: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field BoolValue", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - var ov *otlpcommon.AnyValue_BoolValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_BoolValue{} - } else { - ov = ProtoPoolAnyValue_BoolValue.Get().(*otlpcommon.AnyValue_BoolValue) - } - ov.BoolValue = num != 0 - orig.Value = ov - - case 3: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field IntValue", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - var ov *otlpcommon.AnyValue_IntValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_IntValue{} - } else { - ov = ProtoPoolAnyValue_IntValue.Get().(*otlpcommon.AnyValue_IntValue) - } - ov.IntValue = int64(num) - orig.Value = ov - - case 4: - if wireType != proto.WireTypeI64 { - return fmt.Errorf("proto: wrong wireType = %d for field DoubleValue", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeI64(buf, pos) - if err != nil { - return err - } - var ov *otlpcommon.AnyValue_DoubleValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_DoubleValue{} - } else { - ov = ProtoPoolAnyValue_DoubleValue.Get().(*otlpcommon.AnyValue_DoubleValue) - } - ov.DoubleValue = math.Float64frombits(num) - orig.Value = ov - - case 5: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ArrayValue", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpcommon.AnyValue_ArrayValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_ArrayValue{} - } else { - ov = ProtoPoolAnyValue_ArrayValue.Get().(*otlpcommon.AnyValue_ArrayValue) - } - ov.ArrayValue = NewOrigArrayValue() - err = UnmarshalProtoOrigArrayValue(ov.ArrayValue, buf[startPos:pos]) - if err != nil { - return err - } - orig.Value = ov - - case 6: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field KvlistValue", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpcommon.AnyValue_KvlistValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_KvlistValue{} - } else { - ov = ProtoPoolAnyValue_KvlistValue.Get().(*otlpcommon.AnyValue_KvlistValue) - } - ov.KvlistValue = NewOrigKeyValueList() - err = UnmarshalProtoOrigKeyValueList(ov.KvlistValue, buf[startPos:pos]) - if err != nil { - return err - } - orig.Value = ov - - case 7: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field BytesValue", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpcommon.AnyValue_BytesValue - if !UseProtoPooling.IsEnabled() { - ov = &otlpcommon.AnyValue_BytesValue{} - } else { - ov = ProtoPoolAnyValue_BytesValue.Get().(*otlpcommon.AnyValue_BytesValue) - } - if length != 0 { - ov.BytesValue = make([]byte, length) - copy(ov.BytesValue, buf[startPos:pos]) - } - orig.Value = ov - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_anyvalue_test.go b/pdata/internal/generated_wrapper_anyvalue_test.go deleted file mode 100644 index 41d012ba0d0..00000000000 --- a/pdata/internal/generated_wrapper_anyvalue_test.go +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcommon "go.opentelemetry.io/proto/slim/otlp/common/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigAnyValue(t *testing.T) { - for name, src := range genTestEncodingValuesAnyValue() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigAnyValue() - CopyOrigAnyValue(dest, src) - assert.Equal(t, src, dest) - CopyOrigAnyValue(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigAnyValueUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigAnyValue() - UnmarshalJSONOrigAnyValue(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigAnyValue(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigAnyValue(t *testing.T) { - for name, src := range genTestEncodingValuesAnyValue() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigAnyValue(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigAnyValue() - UnmarshalJSONOrigAnyValue(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigAnyValue(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigAnyValueFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesAnyValue() { - t.Run(name, func(t *testing.T) { - dest := NewOrigAnyValue() - require.Error(t, UnmarshalProtoOrigAnyValue(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigAnyValueUnknown(t *testing.T) { - dest := NewOrigAnyValue() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigAnyValue(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigAnyValue(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigAnyValue(t *testing.T) { - for name, src := range genTestEncodingValuesAnyValue() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigAnyValue(src)) - gotSize := MarshalProtoOrigAnyValue(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigAnyValue() - require.NoError(t, UnmarshalProtoOrigAnyValue(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigAnyValue(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufAnyValue(t *testing.T) { - for name, src := range genTestEncodingValuesAnyValue() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigAnyValue(src)) - gotSize := MarshalProtoOrigAnyValue(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcommon.AnyValue{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigAnyValue() - require.NoError(t, UnmarshalProtoOrigAnyValue(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesAnyValue() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - - "StringValue/wrong_wire_type": {0xc}, - "StringValue/missing_value": {0xa}, - - "BoolValue/wrong_wire_type": {0x14}, - "BoolValue/missing_value": {0x10}, - - "IntValue/wrong_wire_type": {0x1c}, - "IntValue/missing_value": {0x18}, - - "DoubleValue/wrong_wire_type": {0x24}, - "DoubleValue/missing_value": {0x21}, - - "ArrayValue/wrong_wire_type": {0x2c}, - "ArrayValue/missing_value": {0x2a}, - - "KvlistValue/wrong_wire_type": {0x34}, - "KvlistValue/missing_value": {0x32}, - - "BytesValue/wrong_wire_type": {0x3c}, - "BytesValue/missing_value": {0x3a}, - } -} - -func genTestEncodingValuesAnyValue() map[string]*otlpcommon.AnyValue { - return map[string]*otlpcommon.AnyValue{ - "empty": NewOrigAnyValue(), - "StringValue/default": {Value: &otlpcommon.AnyValue_StringValue{StringValue: ""}}, - "StringValue/test": {Value: &otlpcommon.AnyValue_StringValue{StringValue: "test_stringvalue"}}, - "BoolValue/default": {Value: &otlpcommon.AnyValue_BoolValue{BoolValue: false}}, - "BoolValue/test": {Value: &otlpcommon.AnyValue_BoolValue{BoolValue: true}}, - "IntValue/default": {Value: &otlpcommon.AnyValue_IntValue{IntValue: int64(0)}}, - "IntValue/test": {Value: &otlpcommon.AnyValue_IntValue{IntValue: int64(13)}}, - "DoubleValue/default": {Value: &otlpcommon.AnyValue_DoubleValue{DoubleValue: float64(0)}}, - "DoubleValue/test": {Value: &otlpcommon.AnyValue_DoubleValue{DoubleValue: float64(3.1415926)}}, - "ArrayValue/default": {Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: &otlpcommon.ArrayValue{}}}, - "ArrayValue/test": {Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: GenTestOrigArrayValue()}}, - "KvlistValue/default": {Value: &otlpcommon.AnyValue_KvlistValue{KvlistValue: &otlpcommon.KeyValueList{}}}, - "KvlistValue/test": {Value: &otlpcommon.AnyValue_KvlistValue{KvlistValue: GenTestOrigKeyValueList()}}, - "BytesValue/default": {Value: &otlpcommon.AnyValue_BytesValue{BytesValue: nil}}, - "BytesValue/test": {Value: &otlpcommon.AnyValue_BytesValue{BytesValue: []byte{1, 2, 3}}}, - } -} diff --git a/pdata/internal/generated_wrapper_anyvalueslice.go b/pdata/internal/generated_wrapper_anyvalueslice.go index 7381e5f7728..2fd1f11324d 100644 --- a/pdata/internal/generated_wrapper_anyvalueslice.go +++ b/pdata/internal/generated_wrapper_anyvalueslice.go @@ -6,53 +6,24 @@ package internal -import ( - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -type Slice struct { - orig *[]otlpcommon.AnyValue +type SliceWrapper struct { + orig *[]AnyValue state *State } -func GetOrigSlice(ms Slice) *[]otlpcommon.AnyValue { +func GetSliceOrig(ms SliceWrapper) *[]AnyValue { return ms.orig } -func GetSliceState(ms Slice) *State { +func GetSliceState(ms SliceWrapper) *State { return ms.state } -func NewSlice(orig *[]otlpcommon.AnyValue, state *State) Slice { - return Slice{orig: orig, state: state} -} - -func GenerateTestSlice() Slice { - orig := GenerateOrigTestAnyValueSlice() - return NewSlice(&orig, NewState()) -} - -func CopyOrigAnyValueSlice(dest, src []otlpcommon.AnyValue) []otlpcommon.AnyValue { - var newDest []otlpcommon.AnyValue - if cap(dest) < len(src) { - newDest = make([]otlpcommon.AnyValue, len(src)) - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigAnyValue(&dest[i], false) - } - } - for i := range src { - CopyOrigAnyValue(&newDest[i], &src[i]) - } - return newDest +func NewSliceWrapper(orig *[]AnyValue, state *State) SliceWrapper { + return SliceWrapper{orig: orig, state: state} } -func GenerateOrigTestAnyValueSlice() []otlpcommon.AnyValue { - orig := make([]otlpcommon.AnyValue, 5) - orig[1] = *GenTestOrigAnyValue() - orig[3] = *GenTestOrigAnyValue() - return orig +func GenTestSliceWrapper() SliceWrapper { + orig := GenTestAnyValueSlice() + return NewSliceWrapper(&orig, NewState()) } diff --git a/pdata/internal/generated_wrapper_anyvalueslice_test.go b/pdata/internal/generated_wrapper_anyvalueslice_test.go deleted file mode 100644 index 387585a2819..00000000000 --- a/pdata/internal/generated_wrapper_anyvalueslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -func TestCopyOrigAnyValueSlice(t *testing.T) { - src := []otlpcommon.AnyValue{} - dest := []otlpcommon.AnyValue{} - // Test CopyTo empty - dest = CopyOrigAnyValueSlice(dest, src) - assert.Equal(t, []otlpcommon.AnyValue{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestAnyValueSlice() - dest = CopyOrigAnyValueSlice(dest, src) - assert.Equal(t, GenerateOrigTestAnyValueSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigAnyValueSlice(dest, src) - assert.Equal(t, GenerateOrigTestAnyValueSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigAnyValueSlice(dest, []otlpcommon.AnyValue{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigAnyValueSlice(dest, src) - assert.Equal(t, GenerateOrigTestAnyValueSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_arrayvalue.go b/pdata/internal/generated_wrapper_arrayvalue.go deleted file mode 100644 index c168fe718d2..00000000000 --- a/pdata/internal/generated_wrapper_arrayvalue.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolArrayValue = sync.Pool{ - New: func() any { - return &otlpcommon.ArrayValue{} - }, - } -) - -func NewOrigArrayValue() *otlpcommon.ArrayValue { - if !UseProtoPooling.IsEnabled() { - return &otlpcommon.ArrayValue{} - } - return protoPoolArrayValue.Get().(*otlpcommon.ArrayValue) -} - -func DeleteOrigArrayValue(orig *otlpcommon.ArrayValue, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.Values { - DeleteOrigAnyValue(&orig.Values[i], false) - } - - orig.Reset() - if nullable { - protoPoolArrayValue.Put(orig) - } -} - -func CopyOrigArrayValue(dest, src *otlpcommon.ArrayValue) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Values = CopyOrigAnyValueSlice(dest.Values, src.Values) -} - -func GenTestOrigArrayValue() *otlpcommon.ArrayValue { - orig := NewOrigArrayValue() - orig.Values = GenerateOrigTestAnyValueSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigArrayValue(orig *otlpcommon.ArrayValue, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.Values) > 0 { - dest.WriteObjectField("values") - dest.WriteArrayStart() - MarshalJSONOrigAnyValue(&orig.Values[0], dest) - for i := 1; i < len(orig.Values); i++ { - dest.WriteMore() - MarshalJSONOrigAnyValue(&orig.Values[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigArrayValue unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigArrayValue(orig *otlpcommon.ArrayValue, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "values": - for iter.ReadArray() { - orig.Values = append(orig.Values, otlpcommon.AnyValue{}) - UnmarshalJSONOrigAnyValue(&orig.Values[len(orig.Values)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigArrayValue(orig *otlpcommon.ArrayValue) int { - var n int - var l int - _ = l - for i := range orig.Values { - l = SizeProtoOrigAnyValue(&orig.Values[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigArrayValue(orig *otlpcommon.ArrayValue, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.Values) - 1; i >= 0; i-- { - l = MarshalProtoOrigAnyValue(&orig.Values[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigArrayValue(orig *otlpcommon.ArrayValue, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Values = append(orig.Values, otlpcommon.AnyValue{}) - err = UnmarshalProtoOrigAnyValue(&orig.Values[len(orig.Values)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_byteslice.go b/pdata/internal/generated_wrapper_byteslice.go index fe7e4128a70..ecdbd89cea8 100644 --- a/pdata/internal/generated_wrapper_byteslice.go +++ b/pdata/internal/generated_wrapper_byteslice.go @@ -6,32 +6,28 @@ package internal -type ByteSlice struct { +type ByteSliceWrapper struct { orig *[]byte state *State } -func GetOrigByteSlice(ms ByteSlice) *[]byte { +func GetByteSliceOrig(ms ByteSliceWrapper) *[]byte { return ms.orig } -func GetByteSliceState(ms ByteSlice) *State { +func GetByteSliceState(ms ByteSliceWrapper) *State { return ms.state } -func NewByteSlice(orig *[]byte, state *State) ByteSlice { - return ByteSlice{orig: orig, state: state} +func NewByteSliceWrapper(orig *[]byte, state *State) ByteSliceWrapper { + return ByteSliceWrapper{orig: orig, state: state} } -func GenerateTestByteSlice() ByteSlice { - orig := GenerateOrigTestByteSlice() - return NewByteSlice(&orig, NewState()) +func GenTestByteSliceWrapper() ByteSliceWrapper { + orig := []byte{1, 2, 3} + return NewByteSliceWrapper(&orig, NewState()) } -func CopyOrigByteSlice(dst, src []byte) []byte { - return append(dst[:0], src...) -} - -func GenerateOrigTestByteSlice() []byte { +func GenTestByteSlice() []byte { return []byte{1, 2, 3} } diff --git a/pdata/internal/generated_wrapper_byteslice_test.go b/pdata/internal/generated_wrapper_byteslice_test.go deleted file mode 100644 index a67ce85970e..00000000000 --- a/pdata/internal/generated_wrapper_byteslice_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCopyOrigByteSlice(t *testing.T) { - src := []byte{} - dest := []byte{} - // Copy empty - dest = CopyOrigByteSlice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTestByteSlice() - dest = CopyOrigByteSlice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/generated_wrapper_entityref.go b/pdata/internal/generated_wrapper_entityref.go index 36b6948152a..b4e4ea12ee6 100644 --- a/pdata/internal/generated_wrapper_entityref.go +++ b/pdata/internal/generated_wrapper_entityref.go @@ -6,271 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type EntityRef struct { - orig *otlpcommon.EntityRef +type EntityRefWrapper struct { + orig *EntityRef state *State } -func GetOrigEntityRef(ms EntityRef) *otlpcommon.EntityRef { +func GetEntityRefOrig(ms EntityRefWrapper) *EntityRef { return ms.orig } -func GetEntityRefState(ms EntityRef) *State { +func GetEntityRefState(ms EntityRefWrapper) *State { return ms.state } -func NewEntityRef(orig *otlpcommon.EntityRef, state *State) EntityRef { - return EntityRef{orig: orig, state: state} -} - -var ( - protoPoolEntityRef = sync.Pool{ - New: func() any { - return &otlpcommon.EntityRef{} - }, - } -) - -func NewOrigEntityRef() *otlpcommon.EntityRef { - if !UseProtoPooling.IsEnabled() { - return &otlpcommon.EntityRef{} - } - return protoPoolEntityRef.Get().(*otlpcommon.EntityRef) -} - -func DeleteOrigEntityRef(orig *otlpcommon.EntityRef, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolEntityRef.Put(orig) - } -} - -func CopyOrigEntityRef(dest, src *otlpcommon.EntityRef) { - // If copying to same object, just return. - if src == dest { - return - } - dest.SchemaUrl = src.SchemaUrl - dest.Type = src.Type - dest.IdKeys = CopyOrigStringSlice(dest.IdKeys, src.IdKeys) - dest.DescriptionKeys = CopyOrigStringSlice(dest.DescriptionKeys, src.DescriptionKeys) -} - -func GenTestOrigEntityRef() *otlpcommon.EntityRef { - orig := NewOrigEntityRef() - orig.SchemaUrl = "test_schemaurl" - orig.Type = "test_type" - orig.IdKeys = GenerateOrigTestStringSlice() - orig.DescriptionKeys = GenerateOrigTestStringSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigEntityRef(orig *otlpcommon.EntityRef, dest *json.Stream) { - dest.WriteObjectStart() - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - if orig.Type != "" { - dest.WriteObjectField("type") - dest.WriteString(orig.Type) - } - if len(orig.IdKeys) > 0 { - dest.WriteObjectField("idKeys") - dest.WriteArrayStart() - dest.WriteString(orig.IdKeys[0]) - for i := 1; i < len(orig.IdKeys); i++ { - dest.WriteMore() - dest.WriteString(orig.IdKeys[i]) - } - dest.WriteArrayEnd() - } - if len(orig.DescriptionKeys) > 0 { - dest.WriteObjectField("descriptionKeys") - dest.WriteArrayStart() - dest.WriteString(orig.DescriptionKeys[0]) - for i := 1; i < len(orig.DescriptionKeys); i++ { - dest.WriteMore() - dest.WriteString(orig.DescriptionKeys[i]) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigEntityRef unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigEntityRef(orig *otlpcommon.EntityRef, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - case "type": - orig.Type = iter.ReadString() - case "idKeys", "id_keys": - for iter.ReadArray() { - orig.IdKeys = append(orig.IdKeys, iter.ReadString()) - } - - case "descriptionKeys", "description_keys": - for iter.ReadArray() { - orig.DescriptionKeys = append(orig.DescriptionKeys, iter.ReadString()) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigEntityRef(orig *otlpcommon.EntityRef) 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 - } - for _, s := range orig.IdKeys { - l = len(s) - n += 1 + proto.Sov(uint64(l)) + l - } - for _, s := range orig.DescriptionKeys { - l = len(s) - n += 1 + proto.Sov(uint64(l)) + l - } - return n +func NewEntityRefWrapper(orig *EntityRef, state *State) EntityRefWrapper { + return EntityRefWrapper{orig: orig, state: state} } -func MarshalProtoOrigEntityRef(orig *otlpcommon.EntityRef, buf []byte) int { - pos := len(buf) - var l int - _ = l - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - l = len(orig.Type) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Type) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - for i := len(orig.IdKeys) - 1; i >= 0; i-- { - l = len(orig.IdKeys[i]) - pos -= l - copy(buf[pos:], orig.IdKeys[i]) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - for i := len(orig.DescriptionKeys) - 1; i >= 0; i-- { - l = len(orig.DescriptionKeys[i]) - pos -= l - copy(buf[pos:], orig.DescriptionKeys[i]) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x22 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigEntityRef(orig *otlpcommon.EntityRef, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Type = string(buf[startPos:pos]) - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field IdKeys", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.IdKeys = append(orig.IdKeys, string(buf[startPos:pos])) - - case 4: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field DescriptionKeys", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.DescriptionKeys = append(orig.DescriptionKeys, string(buf[startPos:pos])) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestEntityRefWrapper() EntityRefWrapper { + return NewEntityRefWrapper(GenTestEntityRef(), NewState()) } diff --git a/pdata/internal/generated_wrapper_entityrefslice.go b/pdata/internal/generated_wrapper_entityrefslice.go index ecd851ff6da..8e71ec1de0a 100644 --- a/pdata/internal/generated_wrapper_entityrefslice.go +++ b/pdata/internal/generated_wrapper_entityrefslice.go @@ -6,68 +6,24 @@ package internal -import ( - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -type EntityRefSlice struct { - orig *[]*otlpcommon.EntityRef +type EntityRefSliceWrapper struct { + orig *[]*EntityRef state *State } -func GetOrigEntityRefSlice(ms EntityRefSlice) *[]*otlpcommon.EntityRef { +func GetEntityRefSliceOrig(ms EntityRefSliceWrapper) *[]*EntityRef { return ms.orig } -func GetEntityRefSliceState(ms EntityRefSlice) *State { +func GetEntityRefSliceState(ms EntityRefSliceWrapper) *State { return ms.state } -func NewEntityRefSlice(orig *[]*otlpcommon.EntityRef, state *State) EntityRefSlice { - return EntityRefSlice{orig: orig, state: state} -} - -func GenerateTestEntityRefSlice() EntityRefSlice { - orig := GenerateOrigTestEntityRefSlice() - return NewEntityRefSlice(&orig, NewState()) -} - -func CopyOrigEntityRefSlice(dest, src []*otlpcommon.EntityRef) []*otlpcommon.EntityRef { - var newDest []*otlpcommon.EntityRef - if cap(dest) < len(src) { - newDest = make([]*otlpcommon.EntityRef, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigEntityRef() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigEntityRef(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigEntityRef() - } - } - for i := range src { - CopyOrigEntityRef(newDest[i], src[i]) - } - return newDest +func NewEntityRefSliceWrapper(orig *[]*EntityRef, state *State) EntityRefSliceWrapper { + return EntityRefSliceWrapper{orig: orig, state: state} } -func GenerateOrigTestEntityRefSlice() []*otlpcommon.EntityRef { - orig := make([]*otlpcommon.EntityRef, 5) - orig[0] = NewOrigEntityRef() - orig[1] = GenTestOrigEntityRef() - orig[2] = NewOrigEntityRef() - orig[3] = GenTestOrigEntityRef() - orig[4] = NewOrigEntityRef() - return orig +func GenTestEntityRefSliceWrapper() EntityRefSliceWrapper { + orig := GenTestEntityRefPtrSlice() + return NewEntityRefSliceWrapper(&orig, NewState()) } diff --git a/pdata/internal/generated_wrapper_entityrefslice_test.go b/pdata/internal/generated_wrapper_entityrefslice_test.go deleted file mode 100644 index 9b394306370..00000000000 --- a/pdata/internal/generated_wrapper_entityrefslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -func TestCopyOrigEntityRefSlice(t *testing.T) { - src := []*otlpcommon.EntityRef{} - dest := []*otlpcommon.EntityRef{} - // Test CopyTo empty - dest = CopyOrigEntityRefSlice(dest, src) - assert.Equal(t, []*otlpcommon.EntityRef{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestEntityRefSlice() - dest = CopyOrigEntityRefSlice(dest, src) - assert.Equal(t, GenerateOrigTestEntityRefSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigEntityRefSlice(dest, src) - assert.Equal(t, GenerateOrigTestEntityRefSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigEntityRefSlice(dest, []*otlpcommon.EntityRef{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigEntityRefSlice(dest, src) - assert.Equal(t, GenerateOrigTestEntityRefSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_exemplarslice.go b/pdata/internal/generated_wrapper_exemplarslice.go deleted file mode 100644 index ab91c7c5931..00000000000 --- a/pdata/internal/generated_wrapper_exemplarslice.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigExemplarSlice(dest, src []otlpmetrics.Exemplar) []otlpmetrics.Exemplar { - var newDest []otlpmetrics.Exemplar - if cap(dest) < len(src) { - newDest = make([]otlpmetrics.Exemplar, len(src)) - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigExemplar(&dest[i], false) - } - } - for i := range src { - CopyOrigExemplar(&newDest[i], &src[i]) - } - return newDest -} - -func GenerateOrigTestExemplarSlice() []otlpmetrics.Exemplar { - orig := make([]otlpmetrics.Exemplar, 5) - orig[1] = *GenTestOrigExemplar() - orig[3] = *GenTestOrigExemplar() - return orig -} diff --git a/pdata/internal/generated_wrapper_exemplarslice_test.go b/pdata/internal/generated_wrapper_exemplarslice_test.go deleted file mode 100644 index e9cc8175ade..00000000000 --- a/pdata/internal/generated_wrapper_exemplarslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigExemplarSlice(t *testing.T) { - src := []otlpmetrics.Exemplar{} - dest := []otlpmetrics.Exemplar{} - // Test CopyTo empty - dest = CopyOrigExemplarSlice(dest, src) - assert.Equal(t, []otlpmetrics.Exemplar{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestExemplarSlice() - dest = CopyOrigExemplarSlice(dest, src) - assert.Equal(t, GenerateOrigTestExemplarSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigExemplarSlice(dest, src) - assert.Equal(t, GenerateOrigTestExemplarSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigExemplarSlice(dest, []otlpmetrics.Exemplar{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigExemplarSlice(dest, src) - assert.Equal(t, GenerateOrigTestExemplarSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogram.go b/pdata/internal/generated_wrapper_exponentialhistogram.go deleted file mode 100644 index 1f4838d7457..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogram.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExponentialHistogram = sync.Pool{ - New: func() any { - return &otlpmetrics.ExponentialHistogram{} - }, - } -) - -func NewOrigExponentialHistogram() *otlpmetrics.ExponentialHistogram { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.ExponentialHistogram{} - } - return protoPoolExponentialHistogram.Get().(*otlpmetrics.ExponentialHistogram) -} - -func DeleteOrigExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.DataPoints { - DeleteOrigExponentialHistogramDataPoint(orig.DataPoints[i], true) - } - - orig.Reset() - if nullable { - protoPoolExponentialHistogram.Put(orig) - } -} - -func CopyOrigExponentialHistogram(dest, src *otlpmetrics.ExponentialHistogram) { - // If copying to same object, just return. - if src == dest { - return - } - dest.DataPoints = CopyOrigExponentialHistogramDataPointSlice(dest.DataPoints, src.DataPoints) - dest.AggregationTemporality = src.AggregationTemporality -} - -func GenTestOrigExponentialHistogram() *otlpmetrics.ExponentialHistogram { - orig := NewOrigExponentialHistogram() - orig.DataPoints = GenerateOrigTestExponentialHistogramDataPointSlice() - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(1) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.DataPoints) > 0 { - dest.WriteObjectField("dataPoints") - dest.WriteArrayStart() - MarshalJSONOrigExponentialHistogramDataPoint(orig.DataPoints[0], dest) - for i := 1; i < len(orig.DataPoints); i++ { - dest.WriteMore() - MarshalJSONOrigExponentialHistogramDataPoint(orig.DataPoints[i], dest) - } - dest.WriteArrayEnd() - } - - if int32(orig.AggregationTemporality) != 0 { - dest.WriteObjectField("aggregationTemporality") - dest.WriteInt32(int32(orig.AggregationTemporality)) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExponentialHistogram unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "dataPoints", "data_points": - for iter.ReadArray() { - orig.DataPoints = append(orig.DataPoints, NewOrigExponentialHistogramDataPoint()) - UnmarshalJSONOrigExponentialHistogramDataPoint(orig.DataPoints[len(orig.DataPoints)-1], iter) - } - - case "aggregationTemporality", "aggregation_temporality": - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(iter.ReadEnumValue(otlpmetrics.AggregationTemporality_value)) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExponentialHistogram(orig *otlpmetrics.ExponentialHistogram) int { - var n int - var l int - _ = l - for i := range orig.DataPoints { - l = SizeProtoOrigExponentialHistogramDataPoint(orig.DataPoints[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - if orig.AggregationTemporality != 0 { - n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) - } - return n -} - -func MarshalProtoOrigExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.DataPoints) - 1; i >= 0; i-- { - l = MarshalProtoOrigExponentialHistogramDataPoint(orig.DataPoints[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - if orig.AggregationTemporality != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) - pos-- - buf[pos] = 0x10 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.DataPoints = append(orig.DataPoints, NewOrigExponentialHistogramDataPoint()) - err = UnmarshalProtoOrigExponentialHistogramDataPoint(orig.DataPoints[len(orig.DataPoints)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(num) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogram_test.go b/pdata/internal/generated_wrapper_exponentialhistogram_test.go deleted file mode 100644 index 4d39390374f..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogram_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExponentialHistogram(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogram() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExponentialHistogram() - CopyOrigExponentialHistogram(dest, src) - assert.Equal(t, src, dest) - CopyOrigExponentialHistogram(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExponentialHistogramUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExponentialHistogram() - UnmarshalJSONOrigExponentialHistogram(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExponentialHistogram(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExponentialHistogram(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogram() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExponentialHistogram(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExponentialHistogram() - UnmarshalJSONOrigExponentialHistogram(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExponentialHistogram(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExponentialHistogram() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExponentialHistogram() - require.Error(t, UnmarshalProtoOrigExponentialHistogram(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramUnknown(t *testing.T) { - dest := NewOrigExponentialHistogram() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExponentialHistogram(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExponentialHistogram(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogram(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogram() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExponentialHistogram(src)) - gotSize := MarshalProtoOrigExponentialHistogram(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExponentialHistogram() - require.NoError(t, UnmarshalProtoOrigExponentialHistogram(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExponentialHistogram(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExponentialHistogram(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogram() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExponentialHistogram(src)) - gotSize := MarshalProtoOrigExponentialHistogram(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpmetrics.ExponentialHistogram{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExponentialHistogram() - require.NoError(t, UnmarshalProtoOrigExponentialHistogram(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExponentialHistogram() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "DataPoints/wrong_wire_type": {0xc}, - "DataPoints/missing_value": {0xa}, - "AggregationTemporality/wrong_wire_type": {0x14}, - "AggregationTemporality/missing_value": {0x10}, - } -} - -func genTestEncodingValuesExponentialHistogram() map[string]*otlpmetrics.ExponentialHistogram { - return map[string]*otlpmetrics.ExponentialHistogram{ - "empty": NewOrigExponentialHistogram(), - "DataPoints/default_and_test": {DataPoints: []*otlpmetrics.ExponentialHistogramDataPoint{{}, GenTestOrigExponentialHistogramDataPoint()}}, - "AggregationTemporality/test": {AggregationTemporality: otlpmetrics.AggregationTemporality(13)}, - } -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_buckets.go b/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_buckets.go deleted file mode 100644 index 35d7a78ec9a..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_buckets.go +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExponentialHistogramDataPoint_Buckets = sync.Pool{ - New: func() any { - return &otlpmetrics.ExponentialHistogramDataPoint_Buckets{} - }, - } -) - -func NewOrigExponentialHistogramDataPoint_Buckets() *otlpmetrics.ExponentialHistogramDataPoint_Buckets { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.ExponentialHistogramDataPoint_Buckets{} - } - return protoPoolExponentialHistogramDataPoint_Buckets.Get().(*otlpmetrics.ExponentialHistogramDataPoint_Buckets) -} - -func DeleteOrigExponentialHistogramDataPoint_Buckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolExponentialHistogramDataPoint_Buckets.Put(orig) - } -} - -func CopyOrigExponentialHistogramDataPoint_Buckets(dest, src *otlpmetrics.ExponentialHistogramDataPoint_Buckets) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Offset = src.Offset - dest.BucketCounts = CopyOrigUint64Slice(dest.BucketCounts, src.BucketCounts) -} - -func GenTestOrigExponentialHistogramDataPoint_Buckets() *otlpmetrics.ExponentialHistogramDataPoint_Buckets { - orig := NewOrigExponentialHistogramDataPoint_Buckets() - orig.Offset = int32(13) - orig.BucketCounts = GenerateOrigTestUint64Slice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExponentialHistogramDataPoint_Buckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets, dest *json.Stream) { - dest.WriteObjectStart() - if orig.Offset != int32(0) { - dest.WriteObjectField("offset") - dest.WriteInt32(orig.Offset) - } - if len(orig.BucketCounts) > 0 { - dest.WriteObjectField("bucketCounts") - dest.WriteArrayStart() - dest.WriteUint64(orig.BucketCounts[0]) - for i := 1; i < len(orig.BucketCounts); i++ { - dest.WriteMore() - dest.WriteUint64(orig.BucketCounts[i]) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExponentialHistogramDataPointBuckets unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "offset": - orig.Offset = iter.ReadInt32() - case "bucketCounts", "bucket_counts": - for iter.ReadArray() { - orig.BucketCounts = append(orig.BucketCounts, iter.ReadUint64()) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExponentialHistogramDataPoint_Buckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets) int { - var n int - var l int - _ = l - if orig.Offset != 0 { - n += 1 + proto.Soz(uint64(orig.Offset)) - } - if len(orig.BucketCounts) > 0 { - l = 0 - for _, e := range orig.BucketCounts { - l += proto.Sov(uint64(e)) - } - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExponentialHistogramDataPoint_Buckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.Offset != 0 { - pos = proto.EncodeVarint(buf, pos, uint64((uint32(orig.Offset)<<1)^uint32(orig.Offset>>31))) - pos-- - buf[pos] = 0x8 - } - l = len(orig.BucketCounts) - if l > 0 { - endPos := pos - for i := l - 1; i >= 0; i-- { - pos = proto.EncodeVarint(buf, pos, uint64(orig.BucketCounts[i])) - } - pos = proto.EncodeVarint(buf, pos, uint64(endPos-pos)) - pos-- - buf[pos] = 0x12 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.Offset = int32(uint32(num>>1) ^ uint32(int32((num&1)<<31)>>31)) - case 2: - switch wireType { - case proto.WireTypeLen: - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var num uint64 - for startPos < pos { - num, startPos, err = proto.ConsumeVarint(buf[:pos], startPos) - if err != nil { - return err - } - orig.BucketCounts = append(orig.BucketCounts, uint64(num)) - } - if startPos != pos { - return fmt.Errorf("proto: invalid field len = %d for field BucketCounts", pos-startPos) - } - case proto.WireTypeVarint: - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - orig.BucketCounts = append(orig.BucketCounts, uint64(num)) - default: - return fmt.Errorf("proto: wrong wireType = %d for field BucketCounts", wireType) - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_buckets_test.go b/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_buckets_test.go deleted file mode 100644 index 0b6b8cecbe9..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_buckets_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExponentialHistogramDataPoint_Buckets(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint_Buckets() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExponentialHistogramDataPoint_Buckets() - CopyOrigExponentialHistogramDataPoint_Buckets(dest, src) - assert.Equal(t, src, dest) - CopyOrigExponentialHistogramDataPoint_Buckets(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint_BucketsUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExponentialHistogramDataPoint_Buckets() - UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExponentialHistogramDataPoint_Buckets(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint_Buckets() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExponentialHistogramDataPoint_Buckets(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExponentialHistogramDataPoint_Buckets() - UnmarshalJSONOrigExponentialHistogramDataPoint_Buckets(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExponentialHistogramDataPoint_Buckets(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPoint_BucketsFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExponentialHistogramDataPoint_Buckets() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExponentialHistogramDataPoint_Buckets() - require.Error(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPoint_BucketsUnknown(t *testing.T) { - dest := NewOrigExponentialHistogramDataPoint_Buckets() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExponentialHistogramDataPoint_Buckets(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint_Buckets() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint_Buckets(src)) - gotSize := MarshalProtoOrigExponentialHistogramDataPoint_Buckets(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExponentialHistogramDataPoint_Buckets() - require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExponentialHistogramDataPoint_Buckets(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExponentialHistogramDataPoint_Buckets(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint_Buckets() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint_Buckets(src)) - gotSize := MarshalProtoOrigExponentialHistogramDataPoint_Buckets(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpmetrics.ExponentialHistogramDataPoint_Buckets{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExponentialHistogramDataPoint_Buckets() - require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExponentialHistogramDataPoint_Buckets() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "Offset/wrong_wire_type": {0xc}, - "Offset/missing_value": {0x8}, - "BucketCounts/wrong_wire_type": {0x14}, - "BucketCounts/missing_value": {0x12}, - } -} - -func genTestEncodingValuesExponentialHistogramDataPoint_Buckets() map[string]*otlpmetrics.ExponentialHistogramDataPoint_Buckets { - return map[string]*otlpmetrics.ExponentialHistogramDataPoint_Buckets{ - "empty": NewOrigExponentialHistogramDataPoint_Buckets(), - "Offset/test": {Offset: int32(13)}, - "BucketCounts/default_and_test": {BucketCounts: []uint64{uint64(0), uint64(13)}}, - } -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_test.go b/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_test.go deleted file mode 100644 index afa5e376a4d..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogramdatapoint_test.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExponentialHistogramDataPoint(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExponentialHistogramDataPoint() - CopyOrigExponentialHistogramDataPoint(dest, src) - assert.Equal(t, src, dest) - CopyOrigExponentialHistogramDataPoint(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPointUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExponentialHistogramDataPoint() - UnmarshalJSONOrigExponentialHistogramDataPoint(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExponentialHistogramDataPoint(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExponentialHistogramDataPoint(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExponentialHistogramDataPoint(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExponentialHistogramDataPoint() - UnmarshalJSONOrigExponentialHistogramDataPoint(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExponentialHistogramDataPoint(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPointFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExponentialHistogramDataPoint() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExponentialHistogramDataPoint() - require.Error(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPointUnknown(t *testing.T) { - dest := NewOrigExponentialHistogramDataPoint() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExponentialHistogramDataPoint(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExponentialHistogramDataPoint(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint(src)) - gotSize := MarshalProtoOrigExponentialHistogramDataPoint(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExponentialHistogramDataPoint() - require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExponentialHistogramDataPoint(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExponentialHistogramDataPoint(t *testing.T) { - for name, src := range genTestEncodingValuesExponentialHistogramDataPoint() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExponentialHistogramDataPoint(src)) - gotSize := MarshalProtoOrigExponentialHistogramDataPoint(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpmetrics.ExponentialHistogramDataPoint{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExponentialHistogramDataPoint() - require.NoError(t, UnmarshalProtoOrigExponentialHistogramDataPoint(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExponentialHistogramDataPoint() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "Attributes/wrong_wire_type": {0xc}, - "Attributes/missing_value": {0xa}, - "StartTimeUnixNano/wrong_wire_type": {0x14}, - "StartTimeUnixNano/missing_value": {0x11}, - "TimeUnixNano/wrong_wire_type": {0x1c}, - "TimeUnixNano/missing_value": {0x19}, - "Count/wrong_wire_type": {0x24}, - "Count/missing_value": {0x21}, - "Sum/wrong_wire_type": {0x2c}, - "Sum/missing_value": {0x29}, - "Scale/wrong_wire_type": {0x34}, - "Scale/missing_value": {0x30}, - "ZeroCount/wrong_wire_type": {0x3c}, - "ZeroCount/missing_value": {0x39}, - "Positive/wrong_wire_type": {0x44}, - "Positive/missing_value": {0x42}, - "Negative/wrong_wire_type": {0x4c}, - "Negative/missing_value": {0x4a}, - "Flags/wrong_wire_type": {0x54}, - "Flags/missing_value": {0x50}, - "Exemplars/wrong_wire_type": {0x5c}, - "Exemplars/missing_value": {0x5a}, - "Min/wrong_wire_type": {0x64}, - "Min/missing_value": {0x61}, - "Max/wrong_wire_type": {0x6c}, - "Max/missing_value": {0x69}, - "ZeroThreshold/wrong_wire_type": {0x74}, - "ZeroThreshold/missing_value": {0x71}, - } -} - -func genTestEncodingValuesExponentialHistogramDataPoint() map[string]*otlpmetrics.ExponentialHistogramDataPoint { - return map[string]*otlpmetrics.ExponentialHistogramDataPoint{ - "empty": NewOrigExponentialHistogramDataPoint(), - "Attributes/default_and_test": {Attributes: []otlpcommon.KeyValue{{}, *GenTestOrigKeyValue()}}, - "StartTimeUnixNano/test": {StartTimeUnixNano: uint64(13)}, - "TimeUnixNano/test": {TimeUnixNano: uint64(13)}, - "Count/test": {Count: uint64(13)}, "Sum/default": {Sum_: &otlpmetrics.ExponentialHistogramDataPoint_Sum{Sum: float64(0)}}, - "Sum/test": {Sum_: &otlpmetrics.ExponentialHistogramDataPoint_Sum{Sum: float64(3.1415926)}}, - "Scale/test": {Scale: int32(13)}, - "ZeroCount/test": {ZeroCount: uint64(13)}, - "Positive/test": {Positive: *GenTestOrigExponentialHistogramDataPoint_Buckets()}, - "Negative/test": {Negative: *GenTestOrigExponentialHistogramDataPoint_Buckets()}, - "Flags/test": {Flags: uint32(13)}, - "Exemplars/default_and_test": {Exemplars: []otlpmetrics.Exemplar{{}, *GenTestOrigExemplar()}}, "Min/default": {Min_: &otlpmetrics.ExponentialHistogramDataPoint_Min{Min: float64(0)}}, - "Min/test": {Min_: &otlpmetrics.ExponentialHistogramDataPoint_Min{Min: float64(3.1415926)}}, "Max/default": {Max_: &otlpmetrics.ExponentialHistogramDataPoint_Max{Max: float64(0)}}, - "Max/test": {Max_: &otlpmetrics.ExponentialHistogramDataPoint_Max{Max: float64(3.1415926)}}, - "ZeroThreshold/test": {ZeroThreshold: float64(3.1415926)}, - } -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogramdatapointslice.go b/pdata/internal/generated_wrapper_exponentialhistogramdatapointslice.go deleted file mode 100644 index 021c0d0a267..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogramdatapointslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigExponentialHistogramDataPointSlice(dest, src []*otlpmetrics.ExponentialHistogramDataPoint) []*otlpmetrics.ExponentialHistogramDataPoint { - var newDest []*otlpmetrics.ExponentialHistogramDataPoint - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.ExponentialHistogramDataPoint, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigExponentialHistogramDataPoint() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigExponentialHistogramDataPoint(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigExponentialHistogramDataPoint() - } - } - for i := range src { - CopyOrigExponentialHistogramDataPoint(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestExponentialHistogramDataPointSlice() []*otlpmetrics.ExponentialHistogramDataPoint { - orig := make([]*otlpmetrics.ExponentialHistogramDataPoint, 5) - orig[0] = NewOrigExponentialHistogramDataPoint() - orig[1] = GenTestOrigExponentialHistogramDataPoint() - orig[2] = NewOrigExponentialHistogramDataPoint() - orig[3] = GenTestOrigExponentialHistogramDataPoint() - orig[4] = NewOrigExponentialHistogramDataPoint() - return orig -} diff --git a/pdata/internal/generated_wrapper_exponentialhistogramdatapointslice_test.go b/pdata/internal/generated_wrapper_exponentialhistogramdatapointslice_test.go deleted file mode 100644 index efcbe69b1cd..00000000000 --- a/pdata/internal/generated_wrapper_exponentialhistogramdatapointslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigExponentialHistogramDataPointSlice(t *testing.T) { - src := []*otlpmetrics.ExponentialHistogramDataPoint{} - dest := []*otlpmetrics.ExponentialHistogramDataPoint{} - // Test CopyTo empty - dest = CopyOrigExponentialHistogramDataPointSlice(dest, src) - assert.Equal(t, []*otlpmetrics.ExponentialHistogramDataPoint{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestExponentialHistogramDataPointSlice() - dest = CopyOrigExponentialHistogramDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestExponentialHistogramDataPointSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigExponentialHistogramDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestExponentialHistogramDataPointSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigExponentialHistogramDataPointSlice(dest, []*otlpmetrics.ExponentialHistogramDataPoint{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigExponentialHistogramDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestExponentialHistogramDataPointSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_exportlogspartialsuccess.go b/pdata/internal/generated_wrapper_exportlogspartialsuccess.go deleted file mode 100644 index 4a55de6ded3..00000000000 --- a/pdata/internal/generated_wrapper_exportlogspartialsuccess.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportLogsPartialSuccess = sync.Pool{ - New: func() any { - return &otlpcollectorlogs.ExportLogsPartialSuccess{} - }, - } -) - -func NewOrigExportLogsPartialSuccess() *otlpcollectorlogs.ExportLogsPartialSuccess { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectorlogs.ExportLogsPartialSuccess{} - } - return protoPoolExportLogsPartialSuccess.Get().(*otlpcollectorlogs.ExportLogsPartialSuccess) -} - -func DeleteOrigExportLogsPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolExportLogsPartialSuccess.Put(orig) - } -} - -func CopyOrigExportLogsPartialSuccess(dest, src *otlpcollectorlogs.ExportLogsPartialSuccess) { - // If copying to same object, just return. - if src == dest { - return - } - dest.RejectedLogRecords = src.RejectedLogRecords - dest.ErrorMessage = src.ErrorMessage -} - -func GenTestOrigExportLogsPartialSuccess() *otlpcollectorlogs.ExportLogsPartialSuccess { - orig := NewOrigExportLogsPartialSuccess() - orig.RejectedLogRecords = int64(13) - orig.ErrorMessage = "test_errormessage" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportLogsPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, dest *json.Stream) { - dest.WriteObjectStart() - if orig.RejectedLogRecords != int64(0) { - dest.WriteObjectField("rejectedLogRecords") - dest.WriteInt64(orig.RejectedLogRecords) - } - if orig.ErrorMessage != "" { - dest.WriteObjectField("errorMessage") - dest.WriteString(orig.ErrorMessage) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportPartialSuccess unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportLogsPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "rejectedLogRecords", "rejected_log_records": - orig.RejectedLogRecords = iter.ReadInt64() - case "errorMessage", "error_message": - orig.ErrorMessage = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportLogsPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess) int { - var n int - var l int - _ = l - if orig.RejectedLogRecords != 0 { - n += 1 + proto.Sov(uint64(orig.RejectedLogRecords)) - } - l = len(orig.ErrorMessage) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportLogsPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.RejectedLogRecords != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedLogRecords)) - pos-- - buf[pos] = 0x8 - } - l = len(orig.ErrorMessage) - if l > 0 { - pos -= l - copy(buf[pos:], orig.ErrorMessage) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportLogsPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedLogRecords", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.RejectedLogRecords = int64(num) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ErrorMessage = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exportlogsservicerequest.go b/pdata/internal/generated_wrapper_exportlogsservicerequest.go index 090e82363ce..a529cd105bc 100644 --- a/pdata/internal/generated_wrapper_exportlogsservicerequest.go +++ b/pdata/internal/generated_wrapper_exportlogsservicerequest.go @@ -6,174 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type Logs struct { - orig *otlpcollectorlogs.ExportLogsServiceRequest +type LogsWrapper struct { + orig *ExportLogsServiceRequest state *State } -func GetOrigLogs(ms Logs) *otlpcollectorlogs.ExportLogsServiceRequest { +func GetLogsOrig(ms LogsWrapper) *ExportLogsServiceRequest { return ms.orig } -func GetLogsState(ms Logs) *State { +func GetLogsState(ms LogsWrapper) *State { return ms.state } -func NewLogs(orig *otlpcollectorlogs.ExportLogsServiceRequest, state *State) Logs { - return Logs{orig: orig, state: state} +func NewLogsWrapper(orig *ExportLogsServiceRequest, state *State) LogsWrapper { + return LogsWrapper{orig: orig, state: state} } -var ( - protoPoolExportLogsServiceRequest = sync.Pool{ - New: func() any { - return &otlpcollectorlogs.ExportLogsServiceRequest{} - }, - } -) - -func NewOrigExportLogsServiceRequest() *otlpcollectorlogs.ExportLogsServiceRequest { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectorlogs.ExportLogsServiceRequest{} - } - return protoPoolExportLogsServiceRequest.Get().(*otlpcollectorlogs.ExportLogsServiceRequest) -} - -func DeleteOrigExportLogsServiceRequest(orig *otlpcollectorlogs.ExportLogsServiceRequest, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.ResourceLogs { - DeleteOrigResourceLogs(orig.ResourceLogs[i], true) - } - - orig.Reset() - if nullable { - protoPoolExportLogsServiceRequest.Put(orig) - } -} - -func CopyOrigExportLogsServiceRequest(dest, src *otlpcollectorlogs.ExportLogsServiceRequest) { - // If copying to same object, just return. - if src == dest { - return - } - dest.ResourceLogs = CopyOrigResourceLogsSlice(dest.ResourceLogs, src.ResourceLogs) -} - -func GenTestOrigExportLogsServiceRequest() *otlpcollectorlogs.ExportLogsServiceRequest { - orig := NewOrigExportLogsServiceRequest() - orig.ResourceLogs = GenerateOrigTestResourceLogsSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportLogsServiceRequest(orig *otlpcollectorlogs.ExportLogsServiceRequest, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.ResourceLogs) > 0 { - dest.WriteObjectField("resourceLogs") - dest.WriteArrayStart() - MarshalJSONOrigResourceLogs(orig.ResourceLogs[0], dest) - for i := 1; i < len(orig.ResourceLogs); i++ { - dest.WriteMore() - MarshalJSONOrigResourceLogs(orig.ResourceLogs[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigLogs unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportLogsServiceRequest(orig *otlpcollectorlogs.ExportLogsServiceRequest, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resourceLogs", "resource_logs": - for iter.ReadArray() { - orig.ResourceLogs = append(orig.ResourceLogs, NewOrigResourceLogs()) - UnmarshalJSONOrigResourceLogs(orig.ResourceLogs[len(orig.ResourceLogs)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportLogsServiceRequest(orig *otlpcollectorlogs.ExportLogsServiceRequest) int { - var n int - var l int - _ = l - for i := range orig.ResourceLogs { - l = SizeProtoOrigResourceLogs(orig.ResourceLogs[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportLogsServiceRequest(orig *otlpcollectorlogs.ExportLogsServiceRequest, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.ResourceLogs) - 1; i >= 0; i-- { - l = MarshalProtoOrigResourceLogs(orig.ResourceLogs[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportLogsServiceRequest(orig *otlpcollectorlogs.ExportLogsServiceRequest, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceLogs", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ResourceLogs = append(orig.ResourceLogs, NewOrigResourceLogs()) - err = UnmarshalProtoOrigResourceLogs(orig.ResourceLogs[len(orig.ResourceLogs)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestLogsWrapper() LogsWrapper { + return NewLogsWrapper(GenTestExportLogsServiceRequest(), NewState()) } diff --git a/pdata/internal/generated_wrapper_exportlogsservicerequest_test.go b/pdata/internal/generated_wrapper_exportlogsservicerequest_test.go deleted file mode 100644 index 2eed34b4485..00000000000 --- a/pdata/internal/generated_wrapper_exportlogsservicerequest_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectorlogs "go.opentelemetry.io/proto/slim/otlp/collector/logs/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportLogsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportLogsServiceRequest() - CopyOrigExportLogsServiceRequest(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportLogsServiceRequest(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportLogsServiceRequestUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportLogsServiceRequest() - UnmarshalJSONOrigExportLogsServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportLogsServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportLogsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportLogsServiceRequest(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportLogsServiceRequest() - UnmarshalJSONOrigExportLogsServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportLogsServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportLogsServiceRequestFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportLogsServiceRequest() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportLogsServiceRequest() - require.Error(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportLogsServiceRequestUnknown(t *testing.T) { - dest := NewOrigExportLogsServiceRequest() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportLogsServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportLogsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportLogsServiceRequest(src)) - gotSize := MarshalProtoOrigExportLogsServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportLogsServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportLogsServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportLogsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceRequest() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportLogsServiceRequest(src)) - gotSize := MarshalProtoOrigExportLogsServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectorlogs.ExportLogsServiceRequest{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportLogsServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportLogsServiceRequest(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportLogsServiceRequest() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "ResourceLogs/wrong_wire_type": {0xc}, - "ResourceLogs/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportLogsServiceRequest() map[string]*otlpcollectorlogs.ExportLogsServiceRequest { - return map[string]*otlpcollectorlogs.ExportLogsServiceRequest{ - "empty": NewOrigExportLogsServiceRequest(), - "ResourceLogs/default_and_test": {ResourceLogs: []*otlplogs.ResourceLogs{{}, GenTestOrigResourceLogs()}}, - } -} diff --git a/pdata/internal/generated_wrapper_exportlogsserviceresponse.go b/pdata/internal/generated_wrapper_exportlogsserviceresponse.go deleted file mode 100644 index 13bb93a0499..00000000000 --- a/pdata/internal/generated_wrapper_exportlogsserviceresponse.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportLogsServiceResponse = sync.Pool{ - New: func() any { - return &otlpcollectorlogs.ExportLogsServiceResponse{} - }, - } -) - -func NewOrigExportLogsServiceResponse() *otlpcollectorlogs.ExportLogsServiceResponse { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectorlogs.ExportLogsServiceResponse{} - } - return protoPoolExportLogsServiceResponse.Get().(*otlpcollectorlogs.ExportLogsServiceResponse) -} - -func DeleteOrigExportLogsServiceResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigExportLogsPartialSuccess(&orig.PartialSuccess, false) - - orig.Reset() - if nullable { - protoPoolExportLogsServiceResponse.Put(orig) - } -} - -func CopyOrigExportLogsServiceResponse(dest, src *otlpcollectorlogs.ExportLogsServiceResponse) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigExportLogsPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) -} - -func GenTestOrigExportLogsServiceResponse() *otlpcollectorlogs.ExportLogsServiceResponse { - orig := NewOrigExportLogsServiceResponse() - orig.PartialSuccess = *GenTestOrigExportLogsPartialSuccess() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportLogsServiceResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("partialSuccess") - MarshalJSONOrigExportLogsPartialSuccess(&orig.PartialSuccess, dest) - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportResponse unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportLogsServiceResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "partialSuccess", "partial_success": - UnmarshalJSONOrigExportLogsPartialSuccess(&orig.PartialSuccess, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportLogsServiceResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse) int { - var n int - var l int - _ = l - l = SizeProtoOrigExportLogsPartialSuccess(&orig.PartialSuccess) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigExportLogsServiceResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigExportLogsPartialSuccess(&orig.PartialSuccess, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - return len(buf) - pos -} - -func UnmarshalProtoOrigExportLogsServiceResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigExportLogsPartialSuccess(&orig.PartialSuccess, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exportlogsserviceresponse_test.go b/pdata/internal/generated_wrapper_exportlogsserviceresponse_test.go deleted file mode 100644 index 9c901a901a3..00000000000 --- a/pdata/internal/generated_wrapper_exportlogsserviceresponse_test.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectorlogs "go.opentelemetry.io/proto/slim/otlp/collector/logs/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportLogsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportLogsServiceResponse() - CopyOrigExportLogsServiceResponse(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportLogsServiceResponse(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportLogsServiceResponseUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportLogsServiceResponse() - UnmarshalJSONOrigExportLogsServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportLogsServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportLogsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportLogsServiceResponse(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportLogsServiceResponse() - UnmarshalJSONOrigExportLogsServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportLogsServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportLogsServiceResponseFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportLogsServiceResponse() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportLogsServiceResponse() - require.Error(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportLogsServiceResponseUnknown(t *testing.T) { - dest := NewOrigExportLogsServiceResponse() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportLogsServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportLogsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportLogsServiceResponse(src)) - gotSize := MarshalProtoOrigExportLogsServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportLogsServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportLogsServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportLogsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportLogsServiceResponse() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportLogsServiceResponse(src)) - gotSize := MarshalProtoOrigExportLogsServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectorlogs.ExportLogsServiceResponse{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportLogsServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportLogsServiceResponse(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportLogsServiceResponse() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "PartialSuccess/wrong_wire_type": {0xc}, - "PartialSuccess/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportLogsServiceResponse() map[string]*otlpcollectorlogs.ExportLogsServiceResponse { - return map[string]*otlpcollectorlogs.ExportLogsServiceResponse{ - "empty": NewOrigExportLogsServiceResponse(), - "PartialSuccess/test": {PartialSuccess: *GenTestOrigExportLogsPartialSuccess()}, - } -} diff --git a/pdata/internal/generated_wrapper_exportmetricspartialsuccess.go b/pdata/internal/generated_wrapper_exportmetricspartialsuccess.go deleted file mode 100644 index 8bf2baeb230..00000000000 --- a/pdata/internal/generated_wrapper_exportmetricspartialsuccess.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportMetricsPartialSuccess = sync.Pool{ - New: func() any { - return &otlpcollectormetrics.ExportMetricsPartialSuccess{} - }, - } -) - -func NewOrigExportMetricsPartialSuccess() *otlpcollectormetrics.ExportMetricsPartialSuccess { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectormetrics.ExportMetricsPartialSuccess{} - } - return protoPoolExportMetricsPartialSuccess.Get().(*otlpcollectormetrics.ExportMetricsPartialSuccess) -} - -func DeleteOrigExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolExportMetricsPartialSuccess.Put(orig) - } -} - -func CopyOrigExportMetricsPartialSuccess(dest, src *otlpcollectormetrics.ExportMetricsPartialSuccess) { - // If copying to same object, just return. - if src == dest { - return - } - dest.RejectedDataPoints = src.RejectedDataPoints - dest.ErrorMessage = src.ErrorMessage -} - -func GenTestOrigExportMetricsPartialSuccess() *otlpcollectormetrics.ExportMetricsPartialSuccess { - orig := NewOrigExportMetricsPartialSuccess() - orig.RejectedDataPoints = int64(13) - orig.ErrorMessage = "test_errormessage" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess, dest *json.Stream) { - dest.WriteObjectStart() - if orig.RejectedDataPoints != int64(0) { - dest.WriteObjectField("rejectedDataPoints") - dest.WriteInt64(orig.RejectedDataPoints) - } - if orig.ErrorMessage != "" { - dest.WriteObjectField("errorMessage") - dest.WriteString(orig.ErrorMessage) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportPartialSuccess unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "rejectedDataPoints", "rejected_data_points": - orig.RejectedDataPoints = iter.ReadInt64() - case "errorMessage", "error_message": - orig.ErrorMessage = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess) int { - var n int - var l int - _ = l - if orig.RejectedDataPoints != 0 { - n += 1 + proto.Sov(uint64(orig.RejectedDataPoints)) - } - l = len(orig.ErrorMessage) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.RejectedDataPoints != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedDataPoints)) - pos-- - buf[pos] = 0x8 - } - l = len(orig.ErrorMessage) - if l > 0 { - pos -= l - copy(buf[pos:], orig.ErrorMessage) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedDataPoints", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.RejectedDataPoints = int64(num) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ErrorMessage = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exportmetricsservicerequest.go b/pdata/internal/generated_wrapper_exportmetricsservicerequest.go index b3c06e55eb4..0d378e4d74d 100644 --- a/pdata/internal/generated_wrapper_exportmetricsservicerequest.go +++ b/pdata/internal/generated_wrapper_exportmetricsservicerequest.go @@ -6,174 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type Metrics struct { - orig *otlpcollectormetrics.ExportMetricsServiceRequest +type MetricsWrapper struct { + orig *ExportMetricsServiceRequest state *State } -func GetOrigMetrics(ms Metrics) *otlpcollectormetrics.ExportMetricsServiceRequest { +func GetMetricsOrig(ms MetricsWrapper) *ExportMetricsServiceRequest { return ms.orig } -func GetMetricsState(ms Metrics) *State { +func GetMetricsState(ms MetricsWrapper) *State { return ms.state } -func NewMetrics(orig *otlpcollectormetrics.ExportMetricsServiceRequest, state *State) Metrics { - return Metrics{orig: orig, state: state} +func NewMetricsWrapper(orig *ExportMetricsServiceRequest, state *State) MetricsWrapper { + return MetricsWrapper{orig: orig, state: state} } -var ( - protoPoolExportMetricsServiceRequest = sync.Pool{ - New: func() any { - return &otlpcollectormetrics.ExportMetricsServiceRequest{} - }, - } -) - -func NewOrigExportMetricsServiceRequest() *otlpcollectormetrics.ExportMetricsServiceRequest { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectormetrics.ExportMetricsServiceRequest{} - } - return protoPoolExportMetricsServiceRequest.Get().(*otlpcollectormetrics.ExportMetricsServiceRequest) -} - -func DeleteOrigExportMetricsServiceRequest(orig *otlpcollectormetrics.ExportMetricsServiceRequest, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.ResourceMetrics { - DeleteOrigResourceMetrics(orig.ResourceMetrics[i], true) - } - - orig.Reset() - if nullable { - protoPoolExportMetricsServiceRequest.Put(orig) - } -} - -func CopyOrigExportMetricsServiceRequest(dest, src *otlpcollectormetrics.ExportMetricsServiceRequest) { - // If copying to same object, just return. - if src == dest { - return - } - dest.ResourceMetrics = CopyOrigResourceMetricsSlice(dest.ResourceMetrics, src.ResourceMetrics) -} - -func GenTestOrigExportMetricsServiceRequest() *otlpcollectormetrics.ExportMetricsServiceRequest { - orig := NewOrigExportMetricsServiceRequest() - orig.ResourceMetrics = GenerateOrigTestResourceMetricsSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportMetricsServiceRequest(orig *otlpcollectormetrics.ExportMetricsServiceRequest, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.ResourceMetrics) > 0 { - dest.WriteObjectField("resourceMetrics") - dest.WriteArrayStart() - MarshalJSONOrigResourceMetrics(orig.ResourceMetrics[0], dest) - for i := 1; i < len(orig.ResourceMetrics); i++ { - dest.WriteMore() - MarshalJSONOrigResourceMetrics(orig.ResourceMetrics[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigMetrics unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportMetricsServiceRequest(orig *otlpcollectormetrics.ExportMetricsServiceRequest, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resourceMetrics", "resource_metrics": - for iter.ReadArray() { - orig.ResourceMetrics = append(orig.ResourceMetrics, NewOrigResourceMetrics()) - UnmarshalJSONOrigResourceMetrics(orig.ResourceMetrics[len(orig.ResourceMetrics)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportMetricsServiceRequest(orig *otlpcollectormetrics.ExportMetricsServiceRequest) int { - var n int - var l int - _ = l - for i := range orig.ResourceMetrics { - l = SizeProtoOrigResourceMetrics(orig.ResourceMetrics[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportMetricsServiceRequest(orig *otlpcollectormetrics.ExportMetricsServiceRequest, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.ResourceMetrics) - 1; i >= 0; i-- { - l = MarshalProtoOrigResourceMetrics(orig.ResourceMetrics[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportMetricsServiceRequest(orig *otlpcollectormetrics.ExportMetricsServiceRequest, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceMetrics", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ResourceMetrics = append(orig.ResourceMetrics, NewOrigResourceMetrics()) - err = UnmarshalProtoOrigResourceMetrics(orig.ResourceMetrics[len(orig.ResourceMetrics)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestMetricsWrapper() MetricsWrapper { + return NewMetricsWrapper(GenTestExportMetricsServiceRequest(), NewState()) } diff --git a/pdata/internal/generated_wrapper_exportmetricsservicerequest_test.go b/pdata/internal/generated_wrapper_exportmetricsservicerequest_test.go deleted file mode 100644 index 8efdbe39701..00000000000 --- a/pdata/internal/generated_wrapper_exportmetricsservicerequest_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectormetrics "go.opentelemetry.io/proto/slim/otlp/collector/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportMetricsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportMetricsServiceRequest() - CopyOrigExportMetricsServiceRequest(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportMetricsServiceRequest(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceRequestUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportMetricsServiceRequest() - UnmarshalJSONOrigExportMetricsServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportMetricsServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportMetricsServiceRequest(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportMetricsServiceRequest() - UnmarshalJSONOrigExportMetricsServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportMetricsServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceRequestFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportMetricsServiceRequest() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportMetricsServiceRequest() - require.Error(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceRequestUnknown(t *testing.T) { - dest := NewOrigExportMetricsServiceRequest() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportMetricsServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportMetricsServiceRequest(src)) - gotSize := MarshalProtoOrigExportMetricsServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportMetricsServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportMetricsServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportMetricsServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceRequest() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportMetricsServiceRequest(src)) - gotSize := MarshalProtoOrigExportMetricsServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectormetrics.ExportMetricsServiceRequest{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportMetricsServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportMetricsServiceRequest(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportMetricsServiceRequest() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "ResourceMetrics/wrong_wire_type": {0xc}, - "ResourceMetrics/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportMetricsServiceRequest() map[string]*otlpcollectormetrics.ExportMetricsServiceRequest { - return map[string]*otlpcollectormetrics.ExportMetricsServiceRequest{ - "empty": NewOrigExportMetricsServiceRequest(), - "ResourceMetrics/default_and_test": {ResourceMetrics: []*otlpmetrics.ResourceMetrics{{}, GenTestOrigResourceMetrics()}}, - } -} diff --git a/pdata/internal/generated_wrapper_exportmetricsserviceresponse.go b/pdata/internal/generated_wrapper_exportmetricsserviceresponse.go deleted file mode 100644 index bdc770f475b..00000000000 --- a/pdata/internal/generated_wrapper_exportmetricsserviceresponse.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportMetricsServiceResponse = sync.Pool{ - New: func() any { - return &otlpcollectormetrics.ExportMetricsServiceResponse{} - }, - } -) - -func NewOrigExportMetricsServiceResponse() *otlpcollectormetrics.ExportMetricsServiceResponse { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectormetrics.ExportMetricsServiceResponse{} - } - return protoPoolExportMetricsServiceResponse.Get().(*otlpcollectormetrics.ExportMetricsServiceResponse) -} - -func DeleteOrigExportMetricsServiceResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigExportMetricsPartialSuccess(&orig.PartialSuccess, false) - - orig.Reset() - if nullable { - protoPoolExportMetricsServiceResponse.Put(orig) - } -} - -func CopyOrigExportMetricsServiceResponse(dest, src *otlpcollectormetrics.ExportMetricsServiceResponse) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigExportMetricsPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) -} - -func GenTestOrigExportMetricsServiceResponse() *otlpcollectormetrics.ExportMetricsServiceResponse { - orig := NewOrigExportMetricsServiceResponse() - orig.PartialSuccess = *GenTestOrigExportMetricsPartialSuccess() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportMetricsServiceResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("partialSuccess") - MarshalJSONOrigExportMetricsPartialSuccess(&orig.PartialSuccess, dest) - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportResponse unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportMetricsServiceResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "partialSuccess", "partial_success": - UnmarshalJSONOrigExportMetricsPartialSuccess(&orig.PartialSuccess, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportMetricsServiceResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse) int { - var n int - var l int - _ = l - l = SizeProtoOrigExportMetricsPartialSuccess(&orig.PartialSuccess) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigExportMetricsServiceResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigExportMetricsPartialSuccess(&orig.PartialSuccess, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - return len(buf) - pos -} - -func UnmarshalProtoOrigExportMetricsServiceResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigExportMetricsPartialSuccess(&orig.PartialSuccess, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exportmetricsserviceresponse_test.go b/pdata/internal/generated_wrapper_exportmetricsserviceresponse_test.go deleted file mode 100644 index 6bb567933a5..00000000000 --- a/pdata/internal/generated_wrapper_exportmetricsserviceresponse_test.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectormetrics "go.opentelemetry.io/proto/slim/otlp/collector/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportMetricsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportMetricsServiceResponse() - CopyOrigExportMetricsServiceResponse(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportMetricsServiceResponse(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceResponseUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportMetricsServiceResponse() - UnmarshalJSONOrigExportMetricsServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportMetricsServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportMetricsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportMetricsServiceResponse(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportMetricsServiceResponse() - UnmarshalJSONOrigExportMetricsServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportMetricsServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceResponseFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportMetricsServiceResponse() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportMetricsServiceResponse() - require.Error(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceResponseUnknown(t *testing.T) { - dest := NewOrigExportMetricsServiceResponse() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportMetricsServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportMetricsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportMetricsServiceResponse(src)) - gotSize := MarshalProtoOrigExportMetricsServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportMetricsServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportMetricsServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportMetricsServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportMetricsServiceResponse() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportMetricsServiceResponse(src)) - gotSize := MarshalProtoOrigExportMetricsServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectormetrics.ExportMetricsServiceResponse{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportMetricsServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportMetricsServiceResponse(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportMetricsServiceResponse() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "PartialSuccess/wrong_wire_type": {0xc}, - "PartialSuccess/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportMetricsServiceResponse() map[string]*otlpcollectormetrics.ExportMetricsServiceResponse { - return map[string]*otlpcollectormetrics.ExportMetricsServiceResponse{ - "empty": NewOrigExportMetricsServiceResponse(), - "PartialSuccess/test": {PartialSuccess: *GenTestOrigExportMetricsPartialSuccess()}, - } -} diff --git a/pdata/internal/generated_wrapper_exportprofilespartialsuccess.go b/pdata/internal/generated_wrapper_exportprofilespartialsuccess.go deleted file mode 100644 index f1305cc2d27..00000000000 --- a/pdata/internal/generated_wrapper_exportprofilespartialsuccess.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportProfilesPartialSuccess = sync.Pool{ - New: func() any { - return &otlpcollectorprofiles.ExportProfilesPartialSuccess{} - }, - } -) - -func NewOrigExportProfilesPartialSuccess() *otlpcollectorprofiles.ExportProfilesPartialSuccess { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectorprofiles.ExportProfilesPartialSuccess{} - } - return protoPoolExportProfilesPartialSuccess.Get().(*otlpcollectorprofiles.ExportProfilesPartialSuccess) -} - -func DeleteOrigExportProfilesPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolExportProfilesPartialSuccess.Put(orig) - } -} - -func CopyOrigExportProfilesPartialSuccess(dest, src *otlpcollectorprofiles.ExportProfilesPartialSuccess) { - // If copying to same object, just return. - if src == dest { - return - } - dest.RejectedProfiles = src.RejectedProfiles - dest.ErrorMessage = src.ErrorMessage -} - -func GenTestOrigExportProfilesPartialSuccess() *otlpcollectorprofiles.ExportProfilesPartialSuccess { - orig := NewOrigExportProfilesPartialSuccess() - orig.RejectedProfiles = int64(13) - orig.ErrorMessage = "test_errormessage" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportProfilesPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess, dest *json.Stream) { - dest.WriteObjectStart() - if orig.RejectedProfiles != int64(0) { - dest.WriteObjectField("rejectedProfiles") - dest.WriteInt64(orig.RejectedProfiles) - } - if orig.ErrorMessage != "" { - dest.WriteObjectField("errorMessage") - dest.WriteString(orig.ErrorMessage) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportPartialSuccess unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportProfilesPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "rejectedProfiles", "rejected_profiles": - orig.RejectedProfiles = iter.ReadInt64() - case "errorMessage", "error_message": - orig.ErrorMessage = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportProfilesPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess) int { - var n int - var l int - _ = l - if orig.RejectedProfiles != 0 { - n += 1 + proto.Sov(uint64(orig.RejectedProfiles)) - } - l = len(orig.ErrorMessage) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportProfilesPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.RejectedProfiles != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedProfiles)) - pos-- - buf[pos] = 0x8 - } - l = len(orig.ErrorMessage) - if l > 0 { - pos -= l - copy(buf[pos:], orig.ErrorMessage) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportProfilesPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedProfiles", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.RejectedProfiles = int64(num) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ErrorMessage = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exportprofilesservicerequest.go b/pdata/internal/generated_wrapper_exportprofilesservicerequest.go index 0cf9fdc9f21..8533626bebe 100644 --- a/pdata/internal/generated_wrapper_exportprofilesservicerequest.go +++ b/pdata/internal/generated_wrapper_exportprofilesservicerequest.go @@ -6,206 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type Profiles struct { - orig *otlpcollectorprofiles.ExportProfilesServiceRequest +type ProfilesWrapper struct { + orig *ExportProfilesServiceRequest state *State } -func GetOrigProfiles(ms Profiles) *otlpcollectorprofiles.ExportProfilesServiceRequest { +func GetProfilesOrig(ms ProfilesWrapper) *ExportProfilesServiceRequest { return ms.orig } -func GetProfilesState(ms Profiles) *State { +func GetProfilesState(ms ProfilesWrapper) *State { return ms.state } -func NewProfiles(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, state *State) Profiles { - return Profiles{orig: orig, state: state} -} - -var ( - protoPoolExportProfilesServiceRequest = sync.Pool{ - New: func() any { - return &otlpcollectorprofiles.ExportProfilesServiceRequest{} - }, - } -) - -func NewOrigExportProfilesServiceRequest() *otlpcollectorprofiles.ExportProfilesServiceRequest { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectorprofiles.ExportProfilesServiceRequest{} - } - return protoPoolExportProfilesServiceRequest.Get().(*otlpcollectorprofiles.ExportProfilesServiceRequest) +func NewProfilesWrapper(orig *ExportProfilesServiceRequest, state *State) ProfilesWrapper { + return ProfilesWrapper{orig: orig, state: state} } -func DeleteOrigExportProfilesServiceRequest(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.ResourceProfiles { - DeleteOrigResourceProfiles(orig.ResourceProfiles[i], true) - } - DeleteOrigProfilesDictionary(&orig.Dictionary, false) - - orig.Reset() - if nullable { - protoPoolExportProfilesServiceRequest.Put(orig) - } -} - -func CopyOrigExportProfilesServiceRequest(dest, src *otlpcollectorprofiles.ExportProfilesServiceRequest) { - // If copying to same object, just return. - if src == dest { - return - } - dest.ResourceProfiles = CopyOrigResourceProfilesSlice(dest.ResourceProfiles, src.ResourceProfiles) - CopyOrigProfilesDictionary(&dest.Dictionary, &src.Dictionary) -} - -func GenTestOrigExportProfilesServiceRequest() *otlpcollectorprofiles.ExportProfilesServiceRequest { - orig := NewOrigExportProfilesServiceRequest() - orig.ResourceProfiles = GenerateOrigTestResourceProfilesSlice() - orig.Dictionary = *GenTestOrigProfilesDictionary() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportProfilesServiceRequest(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.ResourceProfiles) > 0 { - dest.WriteObjectField("resourceProfiles") - dest.WriteArrayStart() - MarshalJSONOrigResourceProfiles(orig.ResourceProfiles[0], dest) - for i := 1; i < len(orig.ResourceProfiles); i++ { - dest.WriteMore() - MarshalJSONOrigResourceProfiles(orig.ResourceProfiles[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectField("dictionary") - MarshalJSONOrigProfilesDictionary(&orig.Dictionary, dest) - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigProfiles unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportProfilesServiceRequest(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resourceProfiles", "resource_profiles": - for iter.ReadArray() { - orig.ResourceProfiles = append(orig.ResourceProfiles, NewOrigResourceProfiles()) - UnmarshalJSONOrigResourceProfiles(orig.ResourceProfiles[len(orig.ResourceProfiles)-1], iter) - } - - case "dictionary": - UnmarshalJSONOrigProfilesDictionary(&orig.Dictionary, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportProfilesServiceRequest(orig *otlpcollectorprofiles.ExportProfilesServiceRequest) int { - var n int - var l int - _ = l - for i := range orig.ResourceProfiles { - l = SizeProtoOrigResourceProfiles(orig.ResourceProfiles[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = SizeProtoOrigProfilesDictionary(&orig.Dictionary) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigExportProfilesServiceRequest(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.ResourceProfiles) - 1; i >= 0; i-- { - l = MarshalProtoOrigResourceProfiles(orig.ResourceProfiles[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - - l = MarshalProtoOrigProfilesDictionary(&orig.Dictionary, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - - return len(buf) - pos -} - -func UnmarshalProtoOrigExportProfilesServiceRequest(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceProfiles", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ResourceProfiles = append(orig.ResourceProfiles, NewOrigResourceProfiles()) - err = UnmarshalProtoOrigResourceProfiles(orig.ResourceProfiles[len(orig.ResourceProfiles)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Dictionary", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigProfilesDictionary(&orig.Dictionary, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestProfilesWrapper() ProfilesWrapper { + return NewProfilesWrapper(GenTestExportProfilesServiceRequest(), NewState()) } diff --git a/pdata/internal/generated_wrapper_exportprofilesservicerequest_test.go b/pdata/internal/generated_wrapper_exportprofilesservicerequest_test.go deleted file mode 100644 index 422d73f1ff1..00000000000 --- a/pdata/internal/generated_wrapper_exportprofilesservicerequest_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectorprofiles "go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportProfilesServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportProfilesServiceRequest() - CopyOrigExportProfilesServiceRequest(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportProfilesServiceRequest(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceRequestUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportProfilesServiceRequest() - UnmarshalJSONOrigExportProfilesServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportProfilesServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportProfilesServiceRequest(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportProfilesServiceRequest() - UnmarshalJSONOrigExportProfilesServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportProfilesServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceRequestFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportProfilesServiceRequest() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportProfilesServiceRequest() - require.Error(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceRequestUnknown(t *testing.T) { - dest := NewOrigExportProfilesServiceRequest() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportProfilesServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportProfilesServiceRequest(src)) - gotSize := MarshalProtoOrigExportProfilesServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportProfilesServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportProfilesServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportProfilesServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceRequest() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportProfilesServiceRequest(src)) - gotSize := MarshalProtoOrigExportProfilesServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectorprofiles.ExportProfilesServiceRequest{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportProfilesServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportProfilesServiceRequest(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportProfilesServiceRequest() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "ResourceProfiles/wrong_wire_type": {0xc}, - "ResourceProfiles/missing_value": {0xa}, - "Dictionary/wrong_wire_type": {0x14}, - "Dictionary/missing_value": {0x12}, - } -} - -func genTestEncodingValuesExportProfilesServiceRequest() map[string]*otlpcollectorprofiles.ExportProfilesServiceRequest { - return map[string]*otlpcollectorprofiles.ExportProfilesServiceRequest{ - "empty": NewOrigExportProfilesServiceRequest(), - "ResourceProfiles/default_and_test": {ResourceProfiles: []*otlpprofiles.ResourceProfiles{{}, GenTestOrigResourceProfiles()}}, - "Dictionary/test": {Dictionary: *GenTestOrigProfilesDictionary()}, - } -} diff --git a/pdata/internal/generated_wrapper_exportprofilesserviceresponse.go b/pdata/internal/generated_wrapper_exportprofilesserviceresponse.go deleted file mode 100644 index 57f666fb0a4..00000000000 --- a/pdata/internal/generated_wrapper_exportprofilesserviceresponse.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportProfilesServiceResponse = sync.Pool{ - New: func() any { - return &otlpcollectorprofiles.ExportProfilesServiceResponse{} - }, - } -) - -func NewOrigExportProfilesServiceResponse() *otlpcollectorprofiles.ExportProfilesServiceResponse { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectorprofiles.ExportProfilesServiceResponse{} - } - return protoPoolExportProfilesServiceResponse.Get().(*otlpcollectorprofiles.ExportProfilesServiceResponse) -} - -func DeleteOrigExportProfilesServiceResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigExportProfilesPartialSuccess(&orig.PartialSuccess, false) - - orig.Reset() - if nullable { - protoPoolExportProfilesServiceResponse.Put(orig) - } -} - -func CopyOrigExportProfilesServiceResponse(dest, src *otlpcollectorprofiles.ExportProfilesServiceResponse) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigExportProfilesPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) -} - -func GenTestOrigExportProfilesServiceResponse() *otlpcollectorprofiles.ExportProfilesServiceResponse { - orig := NewOrigExportProfilesServiceResponse() - orig.PartialSuccess = *GenTestOrigExportProfilesPartialSuccess() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportProfilesServiceResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("partialSuccess") - MarshalJSONOrigExportProfilesPartialSuccess(&orig.PartialSuccess, dest) - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportResponse unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportProfilesServiceResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "partialSuccess", "partial_success": - UnmarshalJSONOrigExportProfilesPartialSuccess(&orig.PartialSuccess, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportProfilesServiceResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse) int { - var n int - var l int - _ = l - l = SizeProtoOrigExportProfilesPartialSuccess(&orig.PartialSuccess) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigExportProfilesServiceResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigExportProfilesPartialSuccess(&orig.PartialSuccess, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - return len(buf) - pos -} - -func UnmarshalProtoOrigExportProfilesServiceResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigExportProfilesPartialSuccess(&orig.PartialSuccess, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exportprofilesserviceresponse_test.go b/pdata/internal/generated_wrapper_exportprofilesserviceresponse_test.go deleted file mode 100644 index 1e836d1c4ab..00000000000 --- a/pdata/internal/generated_wrapper_exportprofilesserviceresponse_test.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectorprofiles "go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportProfilesServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportProfilesServiceResponse() - CopyOrigExportProfilesServiceResponse(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportProfilesServiceResponse(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceResponseUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportProfilesServiceResponse() - UnmarshalJSONOrigExportProfilesServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportProfilesServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportProfilesServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportProfilesServiceResponse(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportProfilesServiceResponse() - UnmarshalJSONOrigExportProfilesServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportProfilesServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceResponseFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportProfilesServiceResponse() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportProfilesServiceResponse() - require.Error(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceResponseUnknown(t *testing.T) { - dest := NewOrigExportProfilesServiceResponse() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportProfilesServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportProfilesServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportProfilesServiceResponse(src)) - gotSize := MarshalProtoOrigExportProfilesServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportProfilesServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportProfilesServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportProfilesServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportProfilesServiceResponse() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportProfilesServiceResponse(src)) - gotSize := MarshalProtoOrigExportProfilesServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectorprofiles.ExportProfilesServiceResponse{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportProfilesServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportProfilesServiceResponse(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportProfilesServiceResponse() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "PartialSuccess/wrong_wire_type": {0xc}, - "PartialSuccess/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportProfilesServiceResponse() map[string]*otlpcollectorprofiles.ExportProfilesServiceResponse { - return map[string]*otlpcollectorprofiles.ExportProfilesServiceResponse{ - "empty": NewOrigExportProfilesServiceResponse(), - "PartialSuccess/test": {PartialSuccess: *GenTestOrigExportProfilesPartialSuccess()}, - } -} diff --git a/pdata/internal/generated_wrapper_exporttracepartialsuccess.go b/pdata/internal/generated_wrapper_exporttracepartialsuccess.go deleted file mode 100644 index bd9774602a4..00000000000 --- a/pdata/internal/generated_wrapper_exporttracepartialsuccess.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportTracePartialSuccess = sync.Pool{ - New: func() any { - return &otlpcollectortrace.ExportTracePartialSuccess{} - }, - } -) - -func NewOrigExportTracePartialSuccess() *otlpcollectortrace.ExportTracePartialSuccess { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectortrace.ExportTracePartialSuccess{} - } - return protoPoolExportTracePartialSuccess.Get().(*otlpcollectortrace.ExportTracePartialSuccess) -} - -func DeleteOrigExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolExportTracePartialSuccess.Put(orig) - } -} - -func CopyOrigExportTracePartialSuccess(dest, src *otlpcollectortrace.ExportTracePartialSuccess) { - // If copying to same object, just return. - if src == dest { - return - } - dest.RejectedSpans = src.RejectedSpans - dest.ErrorMessage = src.ErrorMessage -} - -func GenTestOrigExportTracePartialSuccess() *otlpcollectortrace.ExportTracePartialSuccess { - orig := NewOrigExportTracePartialSuccess() - orig.RejectedSpans = int64(13) - orig.ErrorMessage = "test_errormessage" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, dest *json.Stream) { - dest.WriteObjectStart() - if orig.RejectedSpans != int64(0) { - dest.WriteObjectField("rejectedSpans") - dest.WriteInt64(orig.RejectedSpans) - } - if orig.ErrorMessage != "" { - dest.WriteObjectField("errorMessage") - dest.WriteString(orig.ErrorMessage) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportPartialSuccess unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "rejectedSpans", "rejected_spans": - orig.RejectedSpans = iter.ReadInt64() - case "errorMessage", "error_message": - orig.ErrorMessage = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess) int { - var n int - var l int - _ = l - if orig.RejectedSpans != 0 { - n += 1 + proto.Sov(uint64(orig.RejectedSpans)) - } - l = len(orig.ErrorMessage) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.RejectedSpans != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedSpans)) - pos-- - buf[pos] = 0x8 - } - l = len(orig.ErrorMessage) - if l > 0 { - pos -= l - copy(buf[pos:], orig.ErrorMessage) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field RejectedSpans", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.RejectedSpans = int64(num) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ErrorMessage = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exporttraceservicerequest.go b/pdata/internal/generated_wrapper_exporttraceservicerequest.go index 4ce9efc1e3d..75d82979d88 100644 --- a/pdata/internal/generated_wrapper_exporttraceservicerequest.go +++ b/pdata/internal/generated_wrapper_exporttraceservicerequest.go @@ -6,174 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type Traces struct { - orig *otlpcollectortrace.ExportTraceServiceRequest +type TracesWrapper struct { + orig *ExportTraceServiceRequest state *State } -func GetOrigTraces(ms Traces) *otlpcollectortrace.ExportTraceServiceRequest { +func GetTracesOrig(ms TracesWrapper) *ExportTraceServiceRequest { return ms.orig } -func GetTracesState(ms Traces) *State { +func GetTracesState(ms TracesWrapper) *State { return ms.state } -func NewTraces(orig *otlpcollectortrace.ExportTraceServiceRequest, state *State) Traces { - return Traces{orig: orig, state: state} +func NewTracesWrapper(orig *ExportTraceServiceRequest, state *State) TracesWrapper { + return TracesWrapper{orig: orig, state: state} } -var ( - protoPoolExportTraceServiceRequest = sync.Pool{ - New: func() any { - return &otlpcollectortrace.ExportTraceServiceRequest{} - }, - } -) - -func NewOrigExportTraceServiceRequest() *otlpcollectortrace.ExportTraceServiceRequest { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectortrace.ExportTraceServiceRequest{} - } - return protoPoolExportTraceServiceRequest.Get().(*otlpcollectortrace.ExportTraceServiceRequest) -} - -func DeleteOrigExportTraceServiceRequest(orig *otlpcollectortrace.ExportTraceServiceRequest, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.ResourceSpans { - DeleteOrigResourceSpans(orig.ResourceSpans[i], true) - } - - orig.Reset() - if nullable { - protoPoolExportTraceServiceRequest.Put(orig) - } -} - -func CopyOrigExportTraceServiceRequest(dest, src *otlpcollectortrace.ExportTraceServiceRequest) { - // If copying to same object, just return. - if src == dest { - return - } - dest.ResourceSpans = CopyOrigResourceSpansSlice(dest.ResourceSpans, src.ResourceSpans) -} - -func GenTestOrigExportTraceServiceRequest() *otlpcollectortrace.ExportTraceServiceRequest { - orig := NewOrigExportTraceServiceRequest() - orig.ResourceSpans = GenerateOrigTestResourceSpansSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportTraceServiceRequest(orig *otlpcollectortrace.ExportTraceServiceRequest, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.ResourceSpans) > 0 { - dest.WriteObjectField("resourceSpans") - dest.WriteArrayStart() - MarshalJSONOrigResourceSpans(orig.ResourceSpans[0], dest) - for i := 1; i < len(orig.ResourceSpans); i++ { - dest.WriteMore() - MarshalJSONOrigResourceSpans(orig.ResourceSpans[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigTraces unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportTraceServiceRequest(orig *otlpcollectortrace.ExportTraceServiceRequest, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resourceSpans", "resource_spans": - for iter.ReadArray() { - orig.ResourceSpans = append(orig.ResourceSpans, NewOrigResourceSpans()) - UnmarshalJSONOrigResourceSpans(orig.ResourceSpans[len(orig.ResourceSpans)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportTraceServiceRequest(orig *otlpcollectortrace.ExportTraceServiceRequest) int { - var n int - var l int - _ = l - for i := range orig.ResourceSpans { - l = SizeProtoOrigResourceSpans(orig.ResourceSpans[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigExportTraceServiceRequest(orig *otlpcollectortrace.ExportTraceServiceRequest, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.ResourceSpans) - 1; i >= 0; i-- { - l = MarshalProtoOrigResourceSpans(orig.ResourceSpans[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigExportTraceServiceRequest(orig *otlpcollectortrace.ExportTraceServiceRequest, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceSpans", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ResourceSpans = append(orig.ResourceSpans, NewOrigResourceSpans()) - err = UnmarshalProtoOrigResourceSpans(orig.ResourceSpans[len(orig.ResourceSpans)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestTracesWrapper() TracesWrapper { + return NewTracesWrapper(GenTestExportTraceServiceRequest(), NewState()) } diff --git a/pdata/internal/generated_wrapper_exporttraceservicerequest_test.go b/pdata/internal/generated_wrapper_exporttraceservicerequest_test.go deleted file mode 100644 index 782cf6f7e59..00000000000 --- a/pdata/internal/generated_wrapper_exporttraceservicerequest_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectortrace "go.opentelemetry.io/proto/slim/otlp/collector/trace/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportTraceServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportTraceServiceRequest() - CopyOrigExportTraceServiceRequest(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportTraceServiceRequest(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportTraceServiceRequestUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportTraceServiceRequest() - UnmarshalJSONOrigExportTraceServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportTraceServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportTraceServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportTraceServiceRequest(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportTraceServiceRequest() - UnmarshalJSONOrigExportTraceServiceRequest(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportTraceServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportTraceServiceRequestFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportTraceServiceRequest() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportTraceServiceRequest() - require.Error(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportTraceServiceRequestUnknown(t *testing.T) { - dest := NewOrigExportTraceServiceRequest() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportTraceServiceRequest(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportTraceServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceRequest() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportTraceServiceRequest(src)) - gotSize := MarshalProtoOrigExportTraceServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportTraceServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportTraceServiceRequest(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportTraceServiceRequest(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceRequest() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportTraceServiceRequest(src)) - gotSize := MarshalProtoOrigExportTraceServiceRequest(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectortrace.ExportTraceServiceRequest{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportTraceServiceRequest() - require.NoError(t, UnmarshalProtoOrigExportTraceServiceRequest(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportTraceServiceRequest() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "ResourceSpans/wrong_wire_type": {0xc}, - "ResourceSpans/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportTraceServiceRequest() map[string]*otlpcollectortrace.ExportTraceServiceRequest { - return map[string]*otlpcollectortrace.ExportTraceServiceRequest{ - "empty": NewOrigExportTraceServiceRequest(), - "ResourceSpans/default_and_test": {ResourceSpans: []*otlptrace.ResourceSpans{{}, GenTestOrigResourceSpans()}}, - } -} diff --git a/pdata/internal/generated_wrapper_exporttraceserviceresponse.go b/pdata/internal/generated_wrapper_exporttraceserviceresponse.go deleted file mode 100644 index 293386b3090..00000000000 --- a/pdata/internal/generated_wrapper_exporttraceserviceresponse.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolExportTraceServiceResponse = sync.Pool{ - New: func() any { - return &otlpcollectortrace.ExportTraceServiceResponse{} - }, - } -) - -func NewOrigExportTraceServiceResponse() *otlpcollectortrace.ExportTraceServiceResponse { - if !UseProtoPooling.IsEnabled() { - return &otlpcollectortrace.ExportTraceServiceResponse{} - } - return protoPoolExportTraceServiceResponse.Get().(*otlpcollectortrace.ExportTraceServiceResponse) -} - -func DeleteOrigExportTraceServiceResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigExportTracePartialSuccess(&orig.PartialSuccess, false) - - orig.Reset() - if nullable { - protoPoolExportTraceServiceResponse.Put(orig) - } -} - -func CopyOrigExportTraceServiceResponse(dest, src *otlpcollectortrace.ExportTraceServiceResponse) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigExportTracePartialSuccess(&dest.PartialSuccess, &src.PartialSuccess) -} - -func GenTestOrigExportTraceServiceResponse() *otlpcollectortrace.ExportTraceServiceResponse { - orig := NewOrigExportTraceServiceResponse() - orig.PartialSuccess = *GenTestOrigExportTracePartialSuccess() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigExportTraceServiceResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("partialSuccess") - MarshalJSONOrigExportTracePartialSuccess(&orig.PartialSuccess, dest) - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigExportResponse unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigExportTraceServiceResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "partialSuccess", "partial_success": - UnmarshalJSONOrigExportTracePartialSuccess(&orig.PartialSuccess, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigExportTraceServiceResponse(orig *otlpcollectortrace.ExportTraceServiceResponse) int { - var n int - var l int - _ = l - l = SizeProtoOrigExportTracePartialSuccess(&orig.PartialSuccess) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigExportTraceServiceResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigExportTracePartialSuccess(&orig.PartialSuccess, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - return len(buf) - pos -} - -func UnmarshalProtoOrigExportTraceServiceResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigExportTracePartialSuccess(&orig.PartialSuccess, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_exporttraceserviceresponse_test.go b/pdata/internal/generated_wrapper_exporttraceserviceresponse_test.go deleted file mode 100644 index b0ee1f61d23..00000000000 --- a/pdata/internal/generated_wrapper_exporttraceserviceresponse_test.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpcollectortrace "go.opentelemetry.io/proto/slim/otlp/collector/trace/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigExportTraceServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigExportTraceServiceResponse() - CopyOrigExportTraceServiceResponse(dest, src) - assert.Equal(t, src, dest) - CopyOrigExportTraceServiceResponse(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigExportTraceServiceResponseUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigExportTraceServiceResponse() - UnmarshalJSONOrigExportTraceServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigExportTraceServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigExportTraceServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigExportTraceServiceResponse(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigExportTraceServiceResponse() - UnmarshalJSONOrigExportTraceServiceResponse(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigExportTraceServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigExportTraceServiceResponseFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesExportTraceServiceResponse() { - t.Run(name, func(t *testing.T) { - dest := NewOrigExportTraceServiceResponse() - require.Error(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigExportTraceServiceResponseUnknown(t *testing.T) { - dest := NewOrigExportTraceServiceResponse() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigExportTraceServiceResponse(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigExportTraceServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceResponse() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigExportTraceServiceResponse(src)) - gotSize := MarshalProtoOrigExportTraceServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigExportTraceServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigExportTraceServiceResponse(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufExportTraceServiceResponse(t *testing.T) { - for name, src := range genTestEncodingValuesExportTraceServiceResponse() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigExportTraceServiceResponse(src)) - gotSize := MarshalProtoOrigExportTraceServiceResponse(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpcollectortrace.ExportTraceServiceResponse{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigExportTraceServiceResponse() - require.NoError(t, UnmarshalProtoOrigExportTraceServiceResponse(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesExportTraceServiceResponse() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "PartialSuccess/wrong_wire_type": {0xc}, - "PartialSuccess/missing_value": {0xa}, - } -} - -func genTestEncodingValuesExportTraceServiceResponse() map[string]*otlpcollectortrace.ExportTraceServiceResponse { - return map[string]*otlpcollectortrace.ExportTraceServiceResponse{ - "empty": NewOrigExportTraceServiceResponse(), - "PartialSuccess/test": {PartialSuccess: *GenTestOrigExportTracePartialSuccess()}, - } -} diff --git a/pdata/internal/generated_wrapper_float64slice.go b/pdata/internal/generated_wrapper_float64slice.go index 9f21f74ffa9..8d0d6ea6cf8 100644 --- a/pdata/internal/generated_wrapper_float64slice.go +++ b/pdata/internal/generated_wrapper_float64slice.go @@ -6,32 +6,28 @@ package internal -type Float64Slice struct { +type Float64SliceWrapper struct { orig *[]float64 state *State } -func GetOrigFloat64Slice(ms Float64Slice) *[]float64 { +func GetFloat64SliceOrig(ms Float64SliceWrapper) *[]float64 { return ms.orig } -func GetFloat64SliceState(ms Float64Slice) *State { +func GetFloat64SliceState(ms Float64SliceWrapper) *State { return ms.state } -func NewFloat64Slice(orig *[]float64, state *State) Float64Slice { - return Float64Slice{orig: orig, state: state} +func NewFloat64SliceWrapper(orig *[]float64, state *State) Float64SliceWrapper { + return Float64SliceWrapper{orig: orig, state: state} } -func GenerateTestFloat64Slice() Float64Slice { - orig := GenerateOrigTestFloat64Slice() - return NewFloat64Slice(&orig, NewState()) +func GenTestFloat64SliceWrapper() Float64SliceWrapper { + orig := []float64{1.1, 2.2, 3.3} + return NewFloat64SliceWrapper(&orig, NewState()) } -func CopyOrigFloat64Slice(dst, src []float64) []float64 { - return append(dst[:0], src...) -} - -func GenerateOrigTestFloat64Slice() []float64 { +func GenTestFloat64Slice() []float64 { return []float64{1.1, 2.2, 3.3} } diff --git a/pdata/internal/generated_wrapper_float64slice_test.go b/pdata/internal/generated_wrapper_float64slice_test.go deleted file mode 100644 index 420c1d9d6fd..00000000000 --- a/pdata/internal/generated_wrapper_float64slice_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCopyOrigFloat64Slice(t *testing.T) { - src := []float64{} - dest := []float64{} - // Copy empty - dest = CopyOrigFloat64Slice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTestFloat64Slice() - dest = CopyOrigFloat64Slice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/generated_wrapper_functionslice.go b/pdata/internal/generated_wrapper_functionslice.go deleted file mode 100644 index 4295cf2167d..00000000000 --- a/pdata/internal/generated_wrapper_functionslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigFunctionSlice(dest, src []*otlpprofiles.Function) []*otlpprofiles.Function { - var newDest []*otlpprofiles.Function - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Function, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigFunction() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigFunction(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigFunction() - } - } - for i := range src { - CopyOrigFunction(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestFunctionSlice() []*otlpprofiles.Function { - orig := make([]*otlpprofiles.Function, 5) - orig[0] = NewOrigFunction() - orig[1] = GenTestOrigFunction() - orig[2] = NewOrigFunction() - orig[3] = GenTestOrigFunction() - orig[4] = NewOrigFunction() - return orig -} diff --git a/pdata/internal/generated_wrapper_functionslice_test.go b/pdata/internal/generated_wrapper_functionslice_test.go deleted file mode 100644 index 1896601e95e..00000000000 --- a/pdata/internal/generated_wrapper_functionslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigFunctionSlice(t *testing.T) { - src := []*otlpprofiles.Function{} - dest := []*otlpprofiles.Function{} - // Test CopyTo empty - dest = CopyOrigFunctionSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Function{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestFunctionSlice() - dest = CopyOrigFunctionSlice(dest, src) - assert.Equal(t, GenerateOrigTestFunctionSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigFunctionSlice(dest, src) - assert.Equal(t, GenerateOrigTestFunctionSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigFunctionSlice(dest, []*otlpprofiles.Function{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigFunctionSlice(dest, src) - assert.Equal(t, GenerateOrigTestFunctionSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_gauge.go b/pdata/internal/generated_wrapper_gauge.go deleted file mode 100644 index 7fd96f46480..00000000000 --- a/pdata/internal/generated_wrapper_gauge.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolGauge = sync.Pool{ - New: func() any { - return &otlpmetrics.Gauge{} - }, - } -) - -func NewOrigGauge() *otlpmetrics.Gauge { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.Gauge{} - } - return protoPoolGauge.Get().(*otlpmetrics.Gauge) -} - -func DeleteOrigGauge(orig *otlpmetrics.Gauge, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.DataPoints { - DeleteOrigNumberDataPoint(orig.DataPoints[i], true) - } - - orig.Reset() - if nullable { - protoPoolGauge.Put(orig) - } -} - -func CopyOrigGauge(dest, src *otlpmetrics.Gauge) { - // If copying to same object, just return. - if src == dest { - return - } - dest.DataPoints = CopyOrigNumberDataPointSlice(dest.DataPoints, src.DataPoints) -} - -func GenTestOrigGauge() *otlpmetrics.Gauge { - orig := NewOrigGauge() - orig.DataPoints = GenerateOrigTestNumberDataPointSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigGauge(orig *otlpmetrics.Gauge, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.DataPoints) > 0 { - dest.WriteObjectField("dataPoints") - dest.WriteArrayStart() - MarshalJSONOrigNumberDataPoint(orig.DataPoints[0], dest) - for i := 1; i < len(orig.DataPoints); i++ { - dest.WriteMore() - MarshalJSONOrigNumberDataPoint(orig.DataPoints[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigGauge unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigGauge(orig *otlpmetrics.Gauge, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "dataPoints", "data_points": - for iter.ReadArray() { - orig.DataPoints = append(orig.DataPoints, NewOrigNumberDataPoint()) - UnmarshalJSONOrigNumberDataPoint(orig.DataPoints[len(orig.DataPoints)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigGauge(orig *otlpmetrics.Gauge) int { - var n int - var l int - _ = l - for i := range orig.DataPoints { - l = SizeProtoOrigNumberDataPoint(orig.DataPoints[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigGauge(orig *otlpmetrics.Gauge, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.DataPoints) - 1; i >= 0; i-- { - l = MarshalProtoOrigNumberDataPoint(orig.DataPoints[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigGauge(orig *otlpmetrics.Gauge, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.DataPoints = append(orig.DataPoints, NewOrigNumberDataPoint()) - err = UnmarshalProtoOrigNumberDataPoint(orig.DataPoints[len(orig.DataPoints)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_histogram.go b/pdata/internal/generated_wrapper_histogram.go deleted file mode 100644 index 006c222bfea..00000000000 --- a/pdata/internal/generated_wrapper_histogram.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolHistogram = sync.Pool{ - New: func() any { - return &otlpmetrics.Histogram{} - }, - } -) - -func NewOrigHistogram() *otlpmetrics.Histogram { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.Histogram{} - } - return protoPoolHistogram.Get().(*otlpmetrics.Histogram) -} - -func DeleteOrigHistogram(orig *otlpmetrics.Histogram, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.DataPoints { - DeleteOrigHistogramDataPoint(orig.DataPoints[i], true) - } - - orig.Reset() - if nullable { - protoPoolHistogram.Put(orig) - } -} - -func CopyOrigHistogram(dest, src *otlpmetrics.Histogram) { - // If copying to same object, just return. - if src == dest { - return - } - dest.DataPoints = CopyOrigHistogramDataPointSlice(dest.DataPoints, src.DataPoints) - dest.AggregationTemporality = src.AggregationTemporality -} - -func GenTestOrigHistogram() *otlpmetrics.Histogram { - orig := NewOrigHistogram() - orig.DataPoints = GenerateOrigTestHistogramDataPointSlice() - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(1) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigHistogram(orig *otlpmetrics.Histogram, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.DataPoints) > 0 { - dest.WriteObjectField("dataPoints") - dest.WriteArrayStart() - MarshalJSONOrigHistogramDataPoint(orig.DataPoints[0], dest) - for i := 1; i < len(orig.DataPoints); i++ { - dest.WriteMore() - MarshalJSONOrigHistogramDataPoint(orig.DataPoints[i], dest) - } - dest.WriteArrayEnd() - } - - if int32(orig.AggregationTemporality) != 0 { - dest.WriteObjectField("aggregationTemporality") - dest.WriteInt32(int32(orig.AggregationTemporality)) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigHistogram unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigHistogram(orig *otlpmetrics.Histogram, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "dataPoints", "data_points": - for iter.ReadArray() { - orig.DataPoints = append(orig.DataPoints, NewOrigHistogramDataPoint()) - UnmarshalJSONOrigHistogramDataPoint(orig.DataPoints[len(orig.DataPoints)-1], iter) - } - - case "aggregationTemporality", "aggregation_temporality": - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(iter.ReadEnumValue(otlpmetrics.AggregationTemporality_value)) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigHistogram(orig *otlpmetrics.Histogram) int { - var n int - var l int - _ = l - for i := range orig.DataPoints { - l = SizeProtoOrigHistogramDataPoint(orig.DataPoints[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - if orig.AggregationTemporality != 0 { - n += 1 + proto.Sov(uint64(orig.AggregationTemporality)) - } - return n -} - -func MarshalProtoOrigHistogram(orig *otlpmetrics.Histogram, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.DataPoints) - 1; i >= 0; i-- { - l = MarshalProtoOrigHistogramDataPoint(orig.DataPoints[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - if orig.AggregationTemporality != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.AggregationTemporality)) - pos-- - buf[pos] = 0x10 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigHistogram(orig *otlpmetrics.Histogram, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.DataPoints = append(orig.DataPoints, NewOrigHistogramDataPoint()) - err = UnmarshalProtoOrigHistogramDataPoint(orig.DataPoints[len(orig.DataPoints)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field AggregationTemporality", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.AggregationTemporality = otlpmetrics.AggregationTemporality(num) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_histogramdatapointslice.go b/pdata/internal/generated_wrapper_histogramdatapointslice.go deleted file mode 100644 index 210f02eab75..00000000000 --- a/pdata/internal/generated_wrapper_histogramdatapointslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigHistogramDataPointSlice(dest, src []*otlpmetrics.HistogramDataPoint) []*otlpmetrics.HistogramDataPoint { - var newDest []*otlpmetrics.HistogramDataPoint - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.HistogramDataPoint, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigHistogramDataPoint() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigHistogramDataPoint(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigHistogramDataPoint() - } - } - for i := range src { - CopyOrigHistogramDataPoint(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestHistogramDataPointSlice() []*otlpmetrics.HistogramDataPoint { - orig := make([]*otlpmetrics.HistogramDataPoint, 5) - orig[0] = NewOrigHistogramDataPoint() - orig[1] = GenTestOrigHistogramDataPoint() - orig[2] = NewOrigHistogramDataPoint() - orig[3] = GenTestOrigHistogramDataPoint() - orig[4] = NewOrigHistogramDataPoint() - return orig -} diff --git a/pdata/internal/generated_wrapper_histogramdatapointslice_test.go b/pdata/internal/generated_wrapper_histogramdatapointslice_test.go deleted file mode 100644 index 8efaf6efa39..00000000000 --- a/pdata/internal/generated_wrapper_histogramdatapointslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigHistogramDataPointSlice(t *testing.T) { - src := []*otlpmetrics.HistogramDataPoint{} - dest := []*otlpmetrics.HistogramDataPoint{} - // Test CopyTo empty - dest = CopyOrigHistogramDataPointSlice(dest, src) - assert.Equal(t, []*otlpmetrics.HistogramDataPoint{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestHistogramDataPointSlice() - dest = CopyOrigHistogramDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestHistogramDataPointSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigHistogramDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestHistogramDataPointSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigHistogramDataPointSlice(dest, []*otlpmetrics.HistogramDataPoint{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigHistogramDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestHistogramDataPointSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_instrumentationscope.go b/pdata/internal/generated_wrapper_instrumentationscope.go index f9fea6cb854..5fbe72e12ec 100644 --- a/pdata/internal/generated_wrapper_instrumentationscope.go +++ b/pdata/internal/generated_wrapper_instrumentationscope.go @@ -6,266 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type InstrumentationScope struct { - orig *otlpcommon.InstrumentationScope +type InstrumentationScopeWrapper struct { + orig *InstrumentationScope state *State } -func GetOrigInstrumentationScope(ms InstrumentationScope) *otlpcommon.InstrumentationScope { +func GetInstrumentationScopeOrig(ms InstrumentationScopeWrapper) *InstrumentationScope { return ms.orig } -func GetInstrumentationScopeState(ms InstrumentationScope) *State { +func GetInstrumentationScopeState(ms InstrumentationScopeWrapper) *State { return ms.state } -func NewInstrumentationScope(orig *otlpcommon.InstrumentationScope, state *State) InstrumentationScope { - return InstrumentationScope{orig: orig, state: state} -} - -var ( - protoPoolInstrumentationScope = sync.Pool{ - New: func() any { - return &otlpcommon.InstrumentationScope{} - }, - } -) - -func NewOrigInstrumentationScope() *otlpcommon.InstrumentationScope { - if !UseProtoPooling.IsEnabled() { - return &otlpcommon.InstrumentationScope{} - } - return protoPoolInstrumentationScope.Get().(*otlpcommon.InstrumentationScope) +func NewInstrumentationScopeWrapper(orig *InstrumentationScope, state *State) InstrumentationScopeWrapper { + return InstrumentationScopeWrapper{orig: orig, state: state} } -func DeleteOrigInstrumentationScope(orig *otlpcommon.InstrumentationScope, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) - } - - orig.Reset() - if nullable { - protoPoolInstrumentationScope.Put(orig) - } -} - -func CopyOrigInstrumentationScope(dest, src *otlpcommon.InstrumentationScope) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Name = src.Name - dest.Version = src.Version - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) - dest.DroppedAttributesCount = src.DroppedAttributesCount -} - -func GenTestOrigInstrumentationScope() *otlpcommon.InstrumentationScope { - orig := NewOrigInstrumentationScope() - orig.Name = "test_name" - orig.Version = "test_version" - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.DroppedAttributesCount = uint32(13) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigInstrumentationScope(orig *otlpcommon.InstrumentationScope, dest *json.Stream) { - dest.WriteObjectStart() - if orig.Name != "" { - dest.WriteObjectField("name") - dest.WriteString(orig.Name) - } - if orig.Version != "" { - dest.WriteObjectField("version") - dest.WriteString(orig.Version) - } - if len(orig.Attributes) > 0 { - dest.WriteObjectField("attributes") - dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) - for i := 1; i < len(orig.Attributes); i++ { - dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) - } - dest.WriteArrayEnd() - } - if orig.DroppedAttributesCount != uint32(0) { - dest.WriteObjectField("droppedAttributesCount") - dest.WriteUint32(orig.DroppedAttributesCount) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigInstrumentationScope unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigInstrumentationScope(orig *otlpcommon.InstrumentationScope, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "name": - orig.Name = iter.ReadString() - case "version": - orig.Version = iter.ReadString() - case "attributes": - for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) - } - - case "droppedAttributesCount", "dropped_attributes_count": - orig.DroppedAttributesCount = iter.ReadUint32() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigInstrumentationScope(orig *otlpcommon.InstrumentationScope) 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 - } - for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - if orig.DroppedAttributesCount != 0 { - n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) - } - return n -} - -func MarshalProtoOrigInstrumentationScope(orig *otlpcommon.InstrumentationScope, buf []byte) int { - pos := len(buf) - var l int - _ = l - l = len(orig.Name) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Name) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - l = len(orig.Version) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Version) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - if orig.DroppedAttributesCount != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) - pos-- - buf[pos] = 0x20 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigInstrumentationScope(orig *otlpcommon.InstrumentationScope, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Name = string(buf[startPos:pos]) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Version = string(buf[startPos:pos]) - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 4: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.DroppedAttributesCount = uint32(num) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestInstrumentationScopeWrapper() InstrumentationScopeWrapper { + return NewInstrumentationScopeWrapper(GenTestInstrumentationScope(), NewState()) } diff --git a/pdata/internal/generated_wrapper_int32slice.go b/pdata/internal/generated_wrapper_int32slice.go index 86ceaa8c50a..ed66b200738 100644 --- a/pdata/internal/generated_wrapper_int32slice.go +++ b/pdata/internal/generated_wrapper_int32slice.go @@ -6,32 +6,28 @@ package internal -type Int32Slice struct { +type Int32SliceWrapper struct { orig *[]int32 state *State } -func GetOrigInt32Slice(ms Int32Slice) *[]int32 { +func GetInt32SliceOrig(ms Int32SliceWrapper) *[]int32 { return ms.orig } -func GetInt32SliceState(ms Int32Slice) *State { +func GetInt32SliceState(ms Int32SliceWrapper) *State { return ms.state } -func NewInt32Slice(orig *[]int32, state *State) Int32Slice { - return Int32Slice{orig: orig, state: state} +func NewInt32SliceWrapper(orig *[]int32, state *State) Int32SliceWrapper { + return Int32SliceWrapper{orig: orig, state: state} } -func GenerateTestInt32Slice() Int32Slice { - orig := GenerateOrigTestInt32Slice() - return NewInt32Slice(&orig, NewState()) +func GenTestInt32SliceWrapper() Int32SliceWrapper { + orig := []int32{1, 2, 3} + return NewInt32SliceWrapper(&orig, NewState()) } -func CopyOrigInt32Slice(dst, src []int32) []int32 { - return append(dst[:0], src...) -} - -func GenerateOrigTestInt32Slice() []int32 { +func GenTestInt32Slice() []int32 { return []int32{1, 2, 3} } diff --git a/pdata/internal/generated_wrapper_int32slice_test.go b/pdata/internal/generated_wrapper_int32slice_test.go deleted file mode 100644 index dbd14e1ff76..00000000000 --- a/pdata/internal/generated_wrapper_int32slice_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCopyOrigInt32Slice(t *testing.T) { - src := []int32{} - dest := []int32{} - // Copy empty - dest = CopyOrigInt32Slice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTestInt32Slice() - dest = CopyOrigInt32Slice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/generated_wrapper_int64slice.go b/pdata/internal/generated_wrapper_int64slice.go index ec4df4f49ee..9174f8632a7 100644 --- a/pdata/internal/generated_wrapper_int64slice.go +++ b/pdata/internal/generated_wrapper_int64slice.go @@ -6,32 +6,28 @@ package internal -type Int64Slice struct { +type Int64SliceWrapper struct { orig *[]int64 state *State } -func GetOrigInt64Slice(ms Int64Slice) *[]int64 { +func GetInt64SliceOrig(ms Int64SliceWrapper) *[]int64 { return ms.orig } -func GetInt64SliceState(ms Int64Slice) *State { +func GetInt64SliceState(ms Int64SliceWrapper) *State { return ms.state } -func NewInt64Slice(orig *[]int64, state *State) Int64Slice { - return Int64Slice{orig: orig, state: state} +func NewInt64SliceWrapper(orig *[]int64, state *State) Int64SliceWrapper { + return Int64SliceWrapper{orig: orig, state: state} } -func GenerateTestInt64Slice() Int64Slice { - orig := GenerateOrigTestInt64Slice() - return NewInt64Slice(&orig, NewState()) +func GenTestInt64SliceWrapper() Int64SliceWrapper { + orig := []int64{1, 2, 3} + return NewInt64SliceWrapper(&orig, NewState()) } -func CopyOrigInt64Slice(dst, src []int64) []int64 { - return append(dst[:0], src...) -} - -func GenerateOrigTestInt64Slice() []int64 { +func GenTestInt64Slice() []int64 { return []int64{1, 2, 3} } diff --git a/pdata/internal/generated_wrapper_int64slice_test.go b/pdata/internal/generated_wrapper_int64slice_test.go deleted file mode 100644 index b8212d0bf95..00000000000 --- a/pdata/internal/generated_wrapper_int64slice_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCopyOrigInt64Slice(t *testing.T) { - src := []int64{} - dest := []int64{} - // Copy empty - dest = CopyOrigInt64Slice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTestInt64Slice() - dest = CopyOrigInt64Slice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/generated_wrapper_keyvalue.go b/pdata/internal/generated_wrapper_keyvalue.go deleted file mode 100644 index 6150f448fa4..00000000000 --- a/pdata/internal/generated_wrapper_keyvalue.go +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolKeyValue = sync.Pool{ - New: func() any { - return &otlpcommon.KeyValue{} - }, - } -) - -func NewOrigKeyValue() *otlpcommon.KeyValue { - if !UseProtoPooling.IsEnabled() { - return &otlpcommon.KeyValue{} - } - return protoPoolKeyValue.Get().(*otlpcommon.KeyValue) -} - -func DeleteOrigKeyValue(orig *otlpcommon.KeyValue, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigAnyValue(&orig.Value, false) - - orig.Reset() - if nullable { - protoPoolKeyValue.Put(orig) - } -} - -func CopyOrigKeyValue(dest, src *otlpcommon.KeyValue) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Key = src.Key - CopyOrigAnyValue(&dest.Value, &src.Value) -} - -func GenTestOrigKeyValue() *otlpcommon.KeyValue { - orig := NewOrigKeyValue() - orig.Key = "test_key" - orig.Value = *GenTestOrigAnyValue() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigKeyValue(orig *otlpcommon.KeyValue, dest *json.Stream) { - dest.WriteObjectStart() - if orig.Key != "" { - dest.WriteObjectField("key") - dest.WriteString(orig.Key) - } - dest.WriteObjectField("value") - MarshalJSONOrigAnyValue(&orig.Value, dest) - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigAttribute unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigKeyValue(orig *otlpcommon.KeyValue, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "key": - orig.Key = iter.ReadString() - case "value": - UnmarshalJSONOrigAnyValue(&orig.Value, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigKeyValue(orig *otlpcommon.KeyValue) int { - var n int - var l int - _ = l - l = len(orig.Key) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - l = SizeProtoOrigAnyValue(&orig.Value) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigKeyValue(orig *otlpcommon.KeyValue, buf []byte) int { - pos := len(buf) - var l int - _ = l - l = len(orig.Key) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Key) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - - l = MarshalProtoOrigAnyValue(&orig.Value, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - - return len(buf) - pos -} - -func UnmarshalProtoOrigKeyValue(orig *otlpcommon.KeyValue, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Key = string(buf[startPos:pos]) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigAnyValue(&orig.Value, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_keyvalueandunit.go b/pdata/internal/generated_wrapper_keyvalueandunit.go deleted file mode 100644 index d8bccf5c8ba..00000000000 --- a/pdata/internal/generated_wrapper_keyvalueandunit.go +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolKeyValueAndUnit = sync.Pool{ - New: func() any { - return &otlpprofiles.KeyValueAndUnit{} - }, - } -) - -func NewOrigKeyValueAndUnit() *otlpprofiles.KeyValueAndUnit { - if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.KeyValueAndUnit{} - } - return protoPoolKeyValueAndUnit.Get().(*otlpprofiles.KeyValueAndUnit) -} - -func DeleteOrigKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigAnyValue(&orig.Value, false) - - orig.Reset() - if nullable { - protoPoolKeyValueAndUnit.Put(orig) - } -} - -func CopyOrigKeyValueAndUnit(dest, src *otlpprofiles.KeyValueAndUnit) { - // If copying to same object, just return. - if src == dest { - return - } - dest.KeyStrindex = src.KeyStrindex - CopyOrigAnyValue(&dest.Value, &src.Value) - dest.UnitStrindex = src.UnitStrindex -} - -func GenTestOrigKeyValueAndUnit() *otlpprofiles.KeyValueAndUnit { - orig := NewOrigKeyValueAndUnit() - orig.KeyStrindex = int32(13) - orig.Value = *GenTestOrigAnyValue() - orig.UnitStrindex = int32(13) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, dest *json.Stream) { - dest.WriteObjectStart() - if orig.KeyStrindex != int32(0) { - dest.WriteObjectField("keyStrindex") - dest.WriteInt32(orig.KeyStrindex) - } - dest.WriteObjectField("value") - MarshalJSONOrigAnyValue(&orig.Value, dest) - if orig.UnitStrindex != int32(0) { - dest.WriteObjectField("unitStrindex") - dest.WriteInt32(orig.UnitStrindex) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigKeyValueAndUnit unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "keyStrindex", "key_strindex": - orig.KeyStrindex = iter.ReadInt32() - case "value": - UnmarshalJSONOrigAnyValue(&orig.Value, iter) - case "unitStrindex", "unit_strindex": - orig.UnitStrindex = iter.ReadInt32() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit) int { - var n int - var l int - _ = l - if orig.KeyStrindex != 0 { - n += 1 + proto.Sov(uint64(orig.KeyStrindex)) - } - l = SizeProtoOrigAnyValue(&orig.Value) - n += 1 + proto.Sov(uint64(l)) + l - if orig.UnitStrindex != 0 { - n += 1 + proto.Sov(uint64(orig.UnitStrindex)) - } - return n -} - -func MarshalProtoOrigKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.KeyStrindex != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.KeyStrindex)) - pos-- - buf[pos] = 0x8 - } - - l = MarshalProtoOrigAnyValue(&orig.Value, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - - if orig.UnitStrindex != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.UnitStrindex)) - pos-- - buf[pos] = 0x18 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field KeyStrindex", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.KeyStrindex = int32(num) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigAnyValue(&orig.Value, buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field UnitStrindex", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.UnitStrindex = int32(num) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_keyvalueandunitslice.go b/pdata/internal/generated_wrapper_keyvalueandunitslice.go deleted file mode 100644 index 0a2a9109c96..00000000000 --- a/pdata/internal/generated_wrapper_keyvalueandunitslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigKeyValueAndUnitSlice(dest, src []*otlpprofiles.KeyValueAndUnit) []*otlpprofiles.KeyValueAndUnit { - var newDest []*otlpprofiles.KeyValueAndUnit - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.KeyValueAndUnit, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigKeyValueAndUnit() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigKeyValueAndUnit(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigKeyValueAndUnit() - } - } - for i := range src { - CopyOrigKeyValueAndUnit(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestKeyValueAndUnitSlice() []*otlpprofiles.KeyValueAndUnit { - orig := make([]*otlpprofiles.KeyValueAndUnit, 5) - orig[0] = NewOrigKeyValueAndUnit() - orig[1] = GenTestOrigKeyValueAndUnit() - orig[2] = NewOrigKeyValueAndUnit() - orig[3] = GenTestOrigKeyValueAndUnit() - orig[4] = NewOrigKeyValueAndUnit() - return orig -} diff --git a/pdata/internal/generated_wrapper_keyvalueandunitslice_test.go b/pdata/internal/generated_wrapper_keyvalueandunitslice_test.go deleted file mode 100644 index d938ed96387..00000000000 --- a/pdata/internal/generated_wrapper_keyvalueandunitslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigKeyValueAndUnitSlice(t *testing.T) { - src := []*otlpprofiles.KeyValueAndUnit{} - dest := []*otlpprofiles.KeyValueAndUnit{} - // Test CopyTo empty - dest = CopyOrigKeyValueAndUnitSlice(dest, src) - assert.Equal(t, []*otlpprofiles.KeyValueAndUnit{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestKeyValueAndUnitSlice() - dest = CopyOrigKeyValueAndUnitSlice(dest, src) - assert.Equal(t, GenerateOrigTestKeyValueAndUnitSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigKeyValueAndUnitSlice(dest, src) - assert.Equal(t, GenerateOrigTestKeyValueAndUnitSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigKeyValueAndUnitSlice(dest, []*otlpprofiles.KeyValueAndUnit{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigKeyValueAndUnitSlice(dest, src) - assert.Equal(t, GenerateOrigTestKeyValueAndUnitSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_keyvaluelist.go b/pdata/internal/generated_wrapper_keyvaluelist.go deleted file mode 100644 index eed254a6c23..00000000000 --- a/pdata/internal/generated_wrapper_keyvaluelist.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolKeyValueList = sync.Pool{ - New: func() any { - return &otlpcommon.KeyValueList{} - }, - } -) - -func NewOrigKeyValueList() *otlpcommon.KeyValueList { - if !UseProtoPooling.IsEnabled() { - return &otlpcommon.KeyValueList{} - } - return protoPoolKeyValueList.Get().(*otlpcommon.KeyValueList) -} - -func DeleteOrigKeyValueList(orig *otlpcommon.KeyValueList, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.Values { - DeleteOrigKeyValue(&orig.Values[i], false) - } - - orig.Reset() - if nullable { - protoPoolKeyValueList.Put(orig) - } -} - -func CopyOrigKeyValueList(dest, src *otlpcommon.KeyValueList) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Values = CopyOrigKeyValueSlice(dest.Values, src.Values) -} - -func GenTestOrigKeyValueList() *otlpcommon.KeyValueList { - orig := NewOrigKeyValueList() - orig.Values = GenerateOrigTestKeyValueSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigKeyValueList(orig *otlpcommon.KeyValueList, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.Values) > 0 { - dest.WriteObjectField("values") - dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Values[0], dest) - for i := 1; i < len(orig.Values); i++ { - dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Values[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigKeyValueList unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigKeyValueList(orig *otlpcommon.KeyValueList, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "values": - for iter.ReadArray() { - orig.Values = append(orig.Values, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Values[len(orig.Values)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigKeyValueList(orig *otlpcommon.KeyValueList) int { - var n int - var l int - _ = l - for i := range orig.Values { - l = SizeProtoOrigKeyValue(&orig.Values[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigKeyValueList(orig *otlpcommon.KeyValueList, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.Values) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Values[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigKeyValueList(orig *otlpcommon.KeyValueList, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Values", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Values = append(orig.Values, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Values[len(orig.Values)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_keyvalueslice.go b/pdata/internal/generated_wrapper_keyvalueslice.go deleted file mode 100644 index 5143ee1140b..00000000000 --- a/pdata/internal/generated_wrapper_keyvalueslice.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -func CopyOrigKeyValueSlice(dest, src []otlpcommon.KeyValue) []otlpcommon.KeyValue { - var newDest []otlpcommon.KeyValue - if cap(dest) < len(src) { - newDest = make([]otlpcommon.KeyValue, len(src)) - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigKeyValue(&dest[i], false) - } - } - for i := range src { - CopyOrigKeyValue(&newDest[i], &src[i]) - } - return newDest -} - -func GenerateOrigTestKeyValueSlice() []otlpcommon.KeyValue { - orig := make([]otlpcommon.KeyValue, 5) - orig[1] = *GenTestOrigKeyValue() - orig[3] = *GenTestOrigKeyValue() - return orig -} diff --git a/pdata/internal/generated_wrapper_keyvalueslice_test.go b/pdata/internal/generated_wrapper_keyvalueslice_test.go deleted file mode 100644 index e49e953a37b..00000000000 --- a/pdata/internal/generated_wrapper_keyvalueslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -func TestCopyOrigKeyValueSlice(t *testing.T) { - src := []otlpcommon.KeyValue{} - dest := []otlpcommon.KeyValue{} - // Test CopyTo empty - dest = CopyOrigKeyValueSlice(dest, src) - assert.Equal(t, []otlpcommon.KeyValue{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestKeyValueSlice() - dest = CopyOrigKeyValueSlice(dest, src) - assert.Equal(t, GenerateOrigTestKeyValueSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigKeyValueSlice(dest, src) - assert.Equal(t, GenerateOrigTestKeyValueSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigKeyValueSlice(dest, []otlpcommon.KeyValue{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigKeyValueSlice(dest, src) - assert.Equal(t, GenerateOrigTestKeyValueSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_lineslice.go b/pdata/internal/generated_wrapper_lineslice.go deleted file mode 100644 index e43c1ababd4..00000000000 --- a/pdata/internal/generated_wrapper_lineslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigLineSlice(dest, src []*otlpprofiles.Line) []*otlpprofiles.Line { - var newDest []*otlpprofiles.Line - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Line, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLine() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigLine(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLine() - } - } - for i := range src { - CopyOrigLine(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestLineSlice() []*otlpprofiles.Line { - orig := make([]*otlpprofiles.Line, 5) - orig[0] = NewOrigLine() - orig[1] = GenTestOrigLine() - orig[2] = NewOrigLine() - orig[3] = GenTestOrigLine() - orig[4] = NewOrigLine() - return orig -} diff --git a/pdata/internal/generated_wrapper_lineslice_test.go b/pdata/internal/generated_wrapper_lineslice_test.go deleted file mode 100644 index 1ab7259a315..00000000000 --- a/pdata/internal/generated_wrapper_lineslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigLineSlice(t *testing.T) { - src := []*otlpprofiles.Line{} - dest := []*otlpprofiles.Line{} - // Test CopyTo empty - dest = CopyOrigLineSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Line{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestLineSlice() - dest = CopyOrigLineSlice(dest, src) - assert.Equal(t, GenerateOrigTestLineSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigLineSlice(dest, src) - assert.Equal(t, GenerateOrigTestLineSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigLineSlice(dest, []*otlpprofiles.Line{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigLineSlice(dest, src) - assert.Equal(t, GenerateOrigTestLineSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_link.go b/pdata/internal/generated_wrapper_link.go deleted file mode 100644 index 6fd64397270..00000000000 --- a/pdata/internal/generated_wrapper_link.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - "go.opentelemetry.io/collector/pdata/internal/data" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolLink = sync.Pool{ - New: func() any { - return &otlpprofiles.Link{} - }, - } -) - -func NewOrigLink() *otlpprofiles.Link { - if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.Link{} - } - return protoPoolLink.Get().(*otlpprofiles.Link) -} - -func DeleteOrigLink(orig *otlpprofiles.Link, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigTraceID(&orig.TraceId, false) - DeleteOrigSpanID(&orig.SpanId, false) - - orig.Reset() - if nullable { - protoPoolLink.Put(orig) - } -} - -func CopyOrigLink(dest, src *otlpprofiles.Link) { - // If copying to same object, just return. - if src == dest { - return - } - dest.TraceId = src.TraceId - dest.SpanId = src.SpanId -} - -func GenTestOrigLink() *otlpprofiles.Link { - orig := NewOrigLink() - orig.TraceId = data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) - orig.SpanId = data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigLink(orig *otlpprofiles.Link, dest *json.Stream) { - dest.WriteObjectStart() - if orig.TraceId != data.TraceID([16]byte{}) { - dest.WriteObjectField("traceId") - MarshalJSONOrigTraceID(&orig.TraceId, dest) - } - if orig.SpanId != data.SpanID([8]byte{}) { - dest.WriteObjectField("spanId") - MarshalJSONOrigSpanID(&orig.SpanId, dest) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigLink unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigLink(orig *otlpprofiles.Link, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "traceId", "trace_id": - UnmarshalJSONOrigTraceID(&orig.TraceId, iter) - case "spanId", "span_id": - UnmarshalJSONOrigSpanID(&orig.SpanId, iter) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigLink(orig *otlpprofiles.Link) int { - var n int - var l int - _ = l - l = SizeProtoOrigTraceID(&orig.TraceId) - n += 1 + proto.Sov(uint64(l)) + l - l = SizeProtoOrigSpanID(&orig.SpanId) - n += 1 + proto.Sov(uint64(l)) + l - return n -} - -func MarshalProtoOrigLink(orig *otlpprofiles.Link, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigTraceID(&orig.TraceId, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - l = MarshalProtoOrigSpanID(&orig.SpanId, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - - return len(buf) - pos -} - -func UnmarshalProtoOrigLink(orig *otlpprofiles.Link, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigTraceID(&orig.TraceId, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigSpanID(&orig.SpanId, buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_linkslice.go b/pdata/internal/generated_wrapper_linkslice.go deleted file mode 100644 index 27b981ec171..00000000000 --- a/pdata/internal/generated_wrapper_linkslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigLinkSlice(dest, src []*otlpprofiles.Link) []*otlpprofiles.Link { - var newDest []*otlpprofiles.Link - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Link, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLink() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigLink(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLink() - } - } - for i := range src { - CopyOrigLink(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestLinkSlice() []*otlpprofiles.Link { - orig := make([]*otlpprofiles.Link, 5) - orig[0] = NewOrigLink() - orig[1] = GenTestOrigLink() - orig[2] = NewOrigLink() - orig[3] = GenTestOrigLink() - orig[4] = NewOrigLink() - return orig -} diff --git a/pdata/internal/generated_wrapper_linkslice_test.go b/pdata/internal/generated_wrapper_linkslice_test.go deleted file mode 100644 index f16e2944f0d..00000000000 --- a/pdata/internal/generated_wrapper_linkslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigLinkSlice(t *testing.T) { - src := []*otlpprofiles.Link{} - dest := []*otlpprofiles.Link{} - // Test CopyTo empty - dest = CopyOrigLinkSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Link{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestLinkSlice() - dest = CopyOrigLinkSlice(dest, src) - assert.Equal(t, GenerateOrigTestLinkSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigLinkSlice(dest, src) - assert.Equal(t, GenerateOrigTestLinkSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigLinkSlice(dest, []*otlpprofiles.Link{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigLinkSlice(dest, src) - assert.Equal(t, GenerateOrigTestLinkSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_locationslice.go b/pdata/internal/generated_wrapper_locationslice.go deleted file mode 100644 index 83a10cc457b..00000000000 --- a/pdata/internal/generated_wrapper_locationslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigLocationSlice(dest, src []*otlpprofiles.Location) []*otlpprofiles.Location { - var newDest []*otlpprofiles.Location - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Location, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLocation() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigLocation(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLocation() - } - } - for i := range src { - CopyOrigLocation(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestLocationSlice() []*otlpprofiles.Location { - orig := make([]*otlpprofiles.Location, 5) - orig[0] = NewOrigLocation() - orig[1] = GenTestOrigLocation() - orig[2] = NewOrigLocation() - orig[3] = GenTestOrigLocation() - orig[4] = NewOrigLocation() - return orig -} diff --git a/pdata/internal/generated_wrapper_locationslice_test.go b/pdata/internal/generated_wrapper_locationslice_test.go deleted file mode 100644 index 37fd54aab05..00000000000 --- a/pdata/internal/generated_wrapper_locationslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigLocationSlice(t *testing.T) { - src := []*otlpprofiles.Location{} - dest := []*otlpprofiles.Location{} - // Test CopyTo empty - dest = CopyOrigLocationSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Location{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestLocationSlice() - dest = CopyOrigLocationSlice(dest, src) - assert.Equal(t, GenerateOrigTestLocationSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigLocationSlice(dest, src) - assert.Equal(t, GenerateOrigTestLocationSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigLocationSlice(dest, []*otlpprofiles.Location{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigLocationSlice(dest, src) - assert.Equal(t, GenerateOrigTestLocationSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_logrecordslice.go b/pdata/internal/generated_wrapper_logrecordslice.go deleted file mode 100644 index 12770cf5887..00000000000 --- a/pdata/internal/generated_wrapper_logrecordslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -func CopyOrigLogRecordSlice(dest, src []*otlplogs.LogRecord) []*otlplogs.LogRecord { - var newDest []*otlplogs.LogRecord - if cap(dest) < len(src) { - newDest = make([]*otlplogs.LogRecord, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLogRecord() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigLogRecord(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigLogRecord() - } - } - for i := range src { - CopyOrigLogRecord(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestLogRecordSlice() []*otlplogs.LogRecord { - orig := make([]*otlplogs.LogRecord, 5) - orig[0] = NewOrigLogRecord() - orig[1] = GenTestOrigLogRecord() - orig[2] = NewOrigLogRecord() - orig[3] = GenTestOrigLogRecord() - orig[4] = NewOrigLogRecord() - return orig -} diff --git a/pdata/internal/generated_wrapper_logrecordslice_test.go b/pdata/internal/generated_wrapper_logrecordslice_test.go deleted file mode 100644 index bffee5e6f36..00000000000 --- a/pdata/internal/generated_wrapper_logrecordslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -func TestCopyOrigLogRecordSlice(t *testing.T) { - src := []*otlplogs.LogRecord{} - dest := []*otlplogs.LogRecord{} - // Test CopyTo empty - dest = CopyOrigLogRecordSlice(dest, src) - assert.Equal(t, []*otlplogs.LogRecord{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestLogRecordSlice() - dest = CopyOrigLogRecordSlice(dest, src) - assert.Equal(t, GenerateOrigTestLogRecordSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigLogRecordSlice(dest, src) - assert.Equal(t, GenerateOrigTestLogRecordSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigLogRecordSlice(dest, []*otlplogs.LogRecord{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigLogRecordSlice(dest, src) - assert.Equal(t, GenerateOrigTestLogRecordSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_mappingslice.go b/pdata/internal/generated_wrapper_mappingslice.go deleted file mode 100644 index fa6e5bd416a..00000000000 --- a/pdata/internal/generated_wrapper_mappingslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigMappingSlice(dest, src []*otlpprofiles.Mapping) []*otlpprofiles.Mapping { - var newDest []*otlpprofiles.Mapping - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Mapping, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigMapping() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigMapping(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigMapping() - } - } - for i := range src { - CopyOrigMapping(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestMappingSlice() []*otlpprofiles.Mapping { - orig := make([]*otlpprofiles.Mapping, 5) - orig[0] = NewOrigMapping() - orig[1] = GenTestOrigMapping() - orig[2] = NewOrigMapping() - orig[3] = GenTestOrigMapping() - orig[4] = NewOrigMapping() - return orig -} diff --git a/pdata/internal/generated_wrapper_mappingslice_test.go b/pdata/internal/generated_wrapper_mappingslice_test.go deleted file mode 100644 index 78ff89d0956..00000000000 --- a/pdata/internal/generated_wrapper_mappingslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigMappingSlice(t *testing.T) { - src := []*otlpprofiles.Mapping{} - dest := []*otlpprofiles.Mapping{} - // Test CopyTo empty - dest = CopyOrigMappingSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Mapping{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestMappingSlice() - dest = CopyOrigMappingSlice(dest, src) - assert.Equal(t, GenerateOrigTestMappingSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigMappingSlice(dest, src) - assert.Equal(t, GenerateOrigTestMappingSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigMappingSlice(dest, []*otlpprofiles.Mapping{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigMappingSlice(dest, src) - assert.Equal(t, GenerateOrigTestMappingSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_metric.go b/pdata/internal/generated_wrapper_metric.go deleted file mode 100644 index 6dee89bdbbc..00000000000 --- a/pdata/internal/generated_wrapper_metric.go +++ /dev/null @@ -1,635 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolMetric = sync.Pool{ - New: func() any { - return &otlpmetrics.Metric{} - }, - } - - ProtoPoolMetric_Gauge = sync.Pool{ - New: func() any { - return &otlpmetrics.Metric_Gauge{} - }, - } - - ProtoPoolMetric_Sum = sync.Pool{ - New: func() any { - return &otlpmetrics.Metric_Sum{} - }, - } - - ProtoPoolMetric_Histogram = sync.Pool{ - New: func() any { - return &otlpmetrics.Metric_Histogram{} - }, - } - - ProtoPoolMetric_ExponentialHistogram = sync.Pool{ - New: func() any { - return &otlpmetrics.Metric_ExponentialHistogram{} - }, - } - - ProtoPoolMetric_Summary = sync.Pool{ - New: func() any { - return &otlpmetrics.Metric_Summary{} - }, - } -) - -func NewOrigMetric() *otlpmetrics.Metric { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.Metric{} - } - return protoPoolMetric.Get().(*otlpmetrics.Metric) -} - -func DeleteOrigMetric(orig *otlpmetrics.Metric, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - switch ov := orig.Data.(type) { - case *otlpmetrics.Metric_Gauge: - DeleteOrigGauge(ov.Gauge, true) - ov.Gauge = nil - ProtoPoolMetric_Gauge.Put(ov) - case *otlpmetrics.Metric_Sum: - DeleteOrigSum(ov.Sum, true) - ov.Sum = nil - ProtoPoolMetric_Sum.Put(ov) - case *otlpmetrics.Metric_Histogram: - DeleteOrigHistogram(ov.Histogram, true) - ov.Histogram = nil - ProtoPoolMetric_Histogram.Put(ov) - case *otlpmetrics.Metric_ExponentialHistogram: - DeleteOrigExponentialHistogram(ov.ExponentialHistogram, true) - ov.ExponentialHistogram = nil - ProtoPoolMetric_ExponentialHistogram.Put(ov) - case *otlpmetrics.Metric_Summary: - DeleteOrigSummary(ov.Summary, true) - ov.Summary = nil - ProtoPoolMetric_Summary.Put(ov) - - } - for i := range orig.Metadata { - DeleteOrigKeyValue(&orig.Metadata[i], false) - } - - orig.Reset() - if nullable { - protoPoolMetric.Put(orig) - } -} - -func CopyOrigMetric(dest, src *otlpmetrics.Metric) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Name = src.Name - dest.Description = src.Description - dest.Unit = src.Unit - switch t := src.Data.(type) { - case *otlpmetrics.Metric_Gauge: - var ov *otlpmetrics.Metric_Gauge - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Gauge{} - } else { - ov = ProtoPoolMetric_Gauge.Get().(*otlpmetrics.Metric_Gauge) - } - ov.Gauge = NewOrigGauge() - CopyOrigGauge(ov.Gauge, t.Gauge) - dest.Data = ov - case *otlpmetrics.Metric_Sum: - var ov *otlpmetrics.Metric_Sum - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Sum{} - } else { - ov = ProtoPoolMetric_Sum.Get().(*otlpmetrics.Metric_Sum) - } - ov.Sum = NewOrigSum() - CopyOrigSum(ov.Sum, t.Sum) - dest.Data = ov - case *otlpmetrics.Metric_Histogram: - var ov *otlpmetrics.Metric_Histogram - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Histogram{} - } else { - ov = ProtoPoolMetric_Histogram.Get().(*otlpmetrics.Metric_Histogram) - } - ov.Histogram = NewOrigHistogram() - CopyOrigHistogram(ov.Histogram, t.Histogram) - dest.Data = ov - case *otlpmetrics.Metric_ExponentialHistogram: - var ov *otlpmetrics.Metric_ExponentialHistogram - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_ExponentialHistogram{} - } else { - ov = ProtoPoolMetric_ExponentialHistogram.Get().(*otlpmetrics.Metric_ExponentialHistogram) - } - ov.ExponentialHistogram = NewOrigExponentialHistogram() - CopyOrigExponentialHistogram(ov.ExponentialHistogram, t.ExponentialHistogram) - dest.Data = ov - case *otlpmetrics.Metric_Summary: - var ov *otlpmetrics.Metric_Summary - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Summary{} - } else { - ov = ProtoPoolMetric_Summary.Get().(*otlpmetrics.Metric_Summary) - } - ov.Summary = NewOrigSummary() - CopyOrigSummary(ov.Summary, t.Summary) - dest.Data = ov - } - dest.Metadata = CopyOrigKeyValueSlice(dest.Metadata, src.Metadata) -} - -func GenTestOrigMetric() *otlpmetrics.Metric { - orig := NewOrigMetric() - orig.Name = "test_name" - orig.Description = "test_description" - orig.Unit = "test_unit" - orig.Data = &otlpmetrics.Metric_Sum{Sum: GenTestOrigSum()} - orig.Metadata = GenerateOrigTestKeyValueSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigMetric(orig *otlpmetrics.Metric, dest *json.Stream) { - dest.WriteObjectStart() - if orig.Name != "" { - dest.WriteObjectField("name") - dest.WriteString(orig.Name) - } - if orig.Description != "" { - dest.WriteObjectField("description") - dest.WriteString(orig.Description) - } - if orig.Unit != "" { - dest.WriteObjectField("unit") - dest.WriteString(orig.Unit) - } - switch orig := orig.Data.(type) { - case *otlpmetrics.Metric_Gauge: - if orig.Gauge != nil { - dest.WriteObjectField("gauge") - MarshalJSONOrigGauge(orig.Gauge, dest) - } - case *otlpmetrics.Metric_Sum: - if orig.Sum != nil { - dest.WriteObjectField("sum") - MarshalJSONOrigSum(orig.Sum, dest) - } - case *otlpmetrics.Metric_Histogram: - if orig.Histogram != nil { - dest.WriteObjectField("histogram") - MarshalJSONOrigHistogram(orig.Histogram, dest) - } - case *otlpmetrics.Metric_ExponentialHistogram: - if orig.ExponentialHistogram != nil { - dest.WriteObjectField("exponentialHistogram") - MarshalJSONOrigExponentialHistogram(orig.ExponentialHistogram, dest) - } - case *otlpmetrics.Metric_Summary: - if orig.Summary != nil { - dest.WriteObjectField("summary") - MarshalJSONOrigSummary(orig.Summary, dest) - } - } - if len(orig.Metadata) > 0 { - dest.WriteObjectField("metadata") - dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Metadata[0], dest) - for i := 1; i < len(orig.Metadata); i++ { - dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Metadata[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigMetric unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigMetric(orig *otlpmetrics.Metric, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "name": - orig.Name = iter.ReadString() - case "description": - orig.Description = iter.ReadString() - case "unit": - orig.Unit = iter.ReadString() - - case "gauge": - { - var ov *otlpmetrics.Metric_Gauge - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Gauge{} - } else { - ov = ProtoPoolMetric_Gauge.Get().(*otlpmetrics.Metric_Gauge) - } - ov.Gauge = NewOrigGauge() - UnmarshalJSONOrigGauge(ov.Gauge, iter) - orig.Data = ov - } - - case "sum": - { - var ov *otlpmetrics.Metric_Sum - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Sum{} - } else { - ov = ProtoPoolMetric_Sum.Get().(*otlpmetrics.Metric_Sum) - } - ov.Sum = NewOrigSum() - UnmarshalJSONOrigSum(ov.Sum, iter) - orig.Data = ov - } - - case "histogram": - { - var ov *otlpmetrics.Metric_Histogram - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Histogram{} - } else { - ov = ProtoPoolMetric_Histogram.Get().(*otlpmetrics.Metric_Histogram) - } - ov.Histogram = NewOrigHistogram() - UnmarshalJSONOrigHistogram(ov.Histogram, iter) - orig.Data = ov - } - - case "exponentialHistogram", "exponential_histogram": - { - var ov *otlpmetrics.Metric_ExponentialHistogram - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_ExponentialHistogram{} - } else { - ov = ProtoPoolMetric_ExponentialHistogram.Get().(*otlpmetrics.Metric_ExponentialHistogram) - } - ov.ExponentialHistogram = NewOrigExponentialHistogram() - UnmarshalJSONOrigExponentialHistogram(ov.ExponentialHistogram, iter) - orig.Data = ov - } - - case "summary": - { - var ov *otlpmetrics.Metric_Summary - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Summary{} - } else { - ov = ProtoPoolMetric_Summary.Get().(*otlpmetrics.Metric_Summary) - } - ov.Summary = NewOrigSummary() - UnmarshalJSONOrigSummary(ov.Summary, iter) - orig.Data = ov - } - - case "metadata": - for iter.ReadArray() { - orig.Metadata = append(orig.Metadata, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Metadata[len(orig.Metadata)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigMetric(orig *otlpmetrics.Metric) 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 - } - switch orig := orig.Data.(type) { - case nil: - _ = orig - break - case *otlpmetrics.Metric_Gauge: - l = SizeProtoOrigGauge(orig.Gauge) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpmetrics.Metric_Sum: - l = SizeProtoOrigSum(orig.Sum) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpmetrics.Metric_Histogram: - l = SizeProtoOrigHistogram(orig.Histogram) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpmetrics.Metric_ExponentialHistogram: - l = SizeProtoOrigExponentialHistogram(orig.ExponentialHistogram) - n += 1 + proto.Sov(uint64(l)) + l - case *otlpmetrics.Metric_Summary: - l = SizeProtoOrigSummary(orig.Summary) - n += 1 + proto.Sov(uint64(l)) + l - } - for i := range orig.Metadata { - l = SizeProtoOrigKeyValue(&orig.Metadata[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigMetric(orig *otlpmetrics.Metric, buf []byte) int { - pos := len(buf) - var l int - _ = l - l = len(orig.Name) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Name) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - l = len(orig.Description) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Description) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.Unit) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Unit) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - switch orig := orig.Data.(type) { - case *otlpmetrics.Metric_Gauge: - - l = MarshalProtoOrigGauge(orig.Gauge, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x2a - - case *otlpmetrics.Metric_Sum: - - l = MarshalProtoOrigSum(orig.Sum, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x3a - - case *otlpmetrics.Metric_Histogram: - - l = MarshalProtoOrigHistogram(orig.Histogram, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x4a - - case *otlpmetrics.Metric_ExponentialHistogram: - - l = MarshalProtoOrigExponentialHistogram(orig.ExponentialHistogram, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x52 - - case *otlpmetrics.Metric_Summary: - - l = MarshalProtoOrigSummary(orig.Summary, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x5a - - } - for i := len(orig.Metadata) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Metadata[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x62 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigMetric(orig *otlpmetrics.Metric, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Name = string(buf[startPos:pos]) - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Description = string(buf[startPos:pos]) - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Unit", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Unit = string(buf[startPos:pos]) - - case 5: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Gauge", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpmetrics.Metric_Gauge - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Gauge{} - } else { - ov = ProtoPoolMetric_Gauge.Get().(*otlpmetrics.Metric_Gauge) - } - ov.Gauge = NewOrigGauge() - err = UnmarshalProtoOrigGauge(ov.Gauge, buf[startPos:pos]) - if err != nil { - return err - } - orig.Data = ov - - case 7: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Sum", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpmetrics.Metric_Sum - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Sum{} - } else { - ov = ProtoPoolMetric_Sum.Get().(*otlpmetrics.Metric_Sum) - } - ov.Sum = NewOrigSum() - err = UnmarshalProtoOrigSum(ov.Sum, buf[startPos:pos]) - if err != nil { - return err - } - orig.Data = ov - - case 9: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Histogram", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpmetrics.Metric_Histogram - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Histogram{} - } else { - ov = ProtoPoolMetric_Histogram.Get().(*otlpmetrics.Metric_Histogram) - } - ov.Histogram = NewOrigHistogram() - err = UnmarshalProtoOrigHistogram(ov.Histogram, buf[startPos:pos]) - if err != nil { - return err - } - orig.Data = ov - - case 10: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ExponentialHistogram", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpmetrics.Metric_ExponentialHistogram - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_ExponentialHistogram{} - } else { - ov = ProtoPoolMetric_ExponentialHistogram.Get().(*otlpmetrics.Metric_ExponentialHistogram) - } - ov.ExponentialHistogram = NewOrigExponentialHistogram() - err = UnmarshalProtoOrigExponentialHistogram(ov.ExponentialHistogram, buf[startPos:pos]) - if err != nil { - return err - } - orig.Data = ov - - case 11: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Summary", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - var ov *otlpmetrics.Metric_Summary - if !UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Summary{} - } else { - ov = ProtoPoolMetric_Summary.Get().(*otlpmetrics.Metric_Summary) - } - ov.Summary = NewOrigSummary() - err = UnmarshalProtoOrigSummary(ov.Summary, buf[startPos:pos]) - if err != nil { - return err - } - orig.Data = ov - - case 12: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Metadata = append(orig.Metadata, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Metadata[len(orig.Metadata)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_metricslice.go b/pdata/internal/generated_wrapper_metricslice.go deleted file mode 100644 index b6b82452dc9..00000000000 --- a/pdata/internal/generated_wrapper_metricslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigMetricSlice(dest, src []*otlpmetrics.Metric) []*otlpmetrics.Metric { - var newDest []*otlpmetrics.Metric - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.Metric, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigMetric() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigMetric(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigMetric() - } - } - for i := range src { - CopyOrigMetric(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestMetricSlice() []*otlpmetrics.Metric { - orig := make([]*otlpmetrics.Metric, 5) - orig[0] = NewOrigMetric() - orig[1] = GenTestOrigMetric() - orig[2] = NewOrigMetric() - orig[3] = GenTestOrigMetric() - orig[4] = NewOrigMetric() - return orig -} diff --git a/pdata/internal/generated_wrapper_metricslice_test.go b/pdata/internal/generated_wrapper_metricslice_test.go deleted file mode 100644 index a020f5356ab..00000000000 --- a/pdata/internal/generated_wrapper_metricslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigMetricSlice(t *testing.T) { - src := []*otlpmetrics.Metric{} - dest := []*otlpmetrics.Metric{} - // Test CopyTo empty - dest = CopyOrigMetricSlice(dest, src) - assert.Equal(t, []*otlpmetrics.Metric{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestMetricSlice() - dest = CopyOrigMetricSlice(dest, src) - assert.Equal(t, GenerateOrigTestMetricSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigMetricSlice(dest, src) - assert.Equal(t, GenerateOrigTestMetricSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigMetricSlice(dest, []*otlpmetrics.Metric{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigMetricSlice(dest, src) - assert.Equal(t, GenerateOrigTestMetricSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_numberdatapointslice.go b/pdata/internal/generated_wrapper_numberdatapointslice.go deleted file mode 100644 index 3ac7b17ab52..00000000000 --- a/pdata/internal/generated_wrapper_numberdatapointslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigNumberDataPointSlice(dest, src []*otlpmetrics.NumberDataPoint) []*otlpmetrics.NumberDataPoint { - var newDest []*otlpmetrics.NumberDataPoint - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.NumberDataPoint, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigNumberDataPoint() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigNumberDataPoint(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigNumberDataPoint() - } - } - for i := range src { - CopyOrigNumberDataPoint(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestNumberDataPointSlice() []*otlpmetrics.NumberDataPoint { - orig := make([]*otlpmetrics.NumberDataPoint, 5) - orig[0] = NewOrigNumberDataPoint() - orig[1] = GenTestOrigNumberDataPoint() - orig[2] = NewOrigNumberDataPoint() - orig[3] = GenTestOrigNumberDataPoint() - orig[4] = NewOrigNumberDataPoint() - return orig -} diff --git a/pdata/internal/generated_wrapper_numberdatapointslice_test.go b/pdata/internal/generated_wrapper_numberdatapointslice_test.go deleted file mode 100644 index 2c2cfe2d9a1..00000000000 --- a/pdata/internal/generated_wrapper_numberdatapointslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigNumberDataPointSlice(t *testing.T) { - src := []*otlpmetrics.NumberDataPoint{} - dest := []*otlpmetrics.NumberDataPoint{} - // Test CopyTo empty - dest = CopyOrigNumberDataPointSlice(dest, src) - assert.Equal(t, []*otlpmetrics.NumberDataPoint{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestNumberDataPointSlice() - dest = CopyOrigNumberDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestNumberDataPointSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigNumberDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestNumberDataPointSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigNumberDataPointSlice(dest, []*otlpmetrics.NumberDataPoint{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigNumberDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestNumberDataPointSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_profilesdata.go b/pdata/internal/generated_wrapper_profilesdata.go new file mode 100644 index 00000000000..7bece6d028b --- /dev/null +++ b/pdata/internal/generated_wrapper_profilesdata.go @@ -0,0 +1,28 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package internal + +type ProfilesDataWrapper struct { + orig *ProfilesData + state *State +} + +func GetProfilesDataOrig(ms ProfilesDataWrapper) *ProfilesData { + return ms.orig +} + +func GetProfilesDataState(ms ProfilesDataWrapper) *State { + return ms.state +} + +func NewProfilesDataWrapper(orig *ProfilesData, state *State) ProfilesDataWrapper { + return ProfilesDataWrapper{orig: orig, state: state} +} + +func GenTestProfilesDataWrapper() ProfilesDataWrapper { + return NewProfilesDataWrapper(GenTestProfilesData(), NewState()) +} diff --git a/pdata/internal/generated_wrapper_profileslice.go b/pdata/internal/generated_wrapper_profileslice.go deleted file mode 100644 index 84ec005150f..00000000000 --- a/pdata/internal/generated_wrapper_profileslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigProfileSlice(dest, src []*otlpprofiles.Profile) []*otlpprofiles.Profile { - var newDest []*otlpprofiles.Profile - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Profile, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigProfile() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigProfile(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigProfile() - } - } - for i := range src { - CopyOrigProfile(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestProfileSlice() []*otlpprofiles.Profile { - orig := make([]*otlpprofiles.Profile, 5) - orig[0] = NewOrigProfile() - orig[1] = GenTestOrigProfile() - orig[2] = NewOrigProfile() - orig[3] = GenTestOrigProfile() - orig[4] = NewOrigProfile() - return orig -} diff --git a/pdata/internal/generated_wrapper_profileslice_test.go b/pdata/internal/generated_wrapper_profileslice_test.go deleted file mode 100644 index 773c597e83a..00000000000 --- a/pdata/internal/generated_wrapper_profileslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigProfileSlice(t *testing.T) { - src := []*otlpprofiles.Profile{} - dest := []*otlpprofiles.Profile{} - // Test CopyTo empty - dest = CopyOrigProfileSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Profile{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestProfileSlice() - dest = CopyOrigProfileSlice(dest, src) - assert.Equal(t, GenerateOrigTestProfileSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigProfileSlice(dest, src) - assert.Equal(t, GenerateOrigTestProfileSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigProfileSlice(dest, []*otlpprofiles.Profile{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigProfileSlice(dest, src) - assert.Equal(t, GenerateOrigTestProfileSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_resource.go b/pdata/internal/generated_wrapper_resource.go index 6e45dbdec69..1d6cabfebfd 100644 --- a/pdata/internal/generated_wrapper_resource.go +++ b/pdata/internal/generated_wrapper_resource.go @@ -6,251 +6,23 @@ package internal -import ( - "fmt" - "sync" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -type Resource struct { - orig *otlpresource.Resource +type ResourceWrapper struct { + orig *Resource state *State } -func GetOrigResource(ms Resource) *otlpresource.Resource { +func GetResourceOrig(ms ResourceWrapper) *Resource { return ms.orig } -func GetResourceState(ms Resource) *State { +func GetResourceState(ms ResourceWrapper) *State { return ms.state } -func NewResource(orig *otlpresource.Resource, state *State) Resource { - return Resource{orig: orig, state: state} -} - -var ( - protoPoolResource = sync.Pool{ - New: func() any { - return &otlpresource.Resource{} - }, - } -) - -func NewOrigResource() *otlpresource.Resource { - if !UseProtoPooling.IsEnabled() { - return &otlpresource.Resource{} - } - return protoPoolResource.Get().(*otlpresource.Resource) +func NewResourceWrapper(orig *Resource, state *State) ResourceWrapper { + return ResourceWrapper{orig: orig, state: state} } -func DeleteOrigResource(orig *otlpresource.Resource, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.Attributes { - DeleteOrigKeyValue(&orig.Attributes[i], false) - } - for i := range orig.EntityRefs { - DeleteOrigEntityRef(orig.EntityRefs[i], true) - } - - orig.Reset() - if nullable { - protoPoolResource.Put(orig) - } -} - -func CopyOrigResource(dest, src *otlpresource.Resource) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Attributes = CopyOrigKeyValueSlice(dest.Attributes, src.Attributes) - dest.DroppedAttributesCount = src.DroppedAttributesCount - dest.EntityRefs = CopyOrigEntityRefSlice(dest.EntityRefs, src.EntityRefs) -} - -func GenTestOrigResource() *otlpresource.Resource { - orig := NewOrigResource() - orig.Attributes = GenerateOrigTestKeyValueSlice() - orig.DroppedAttributesCount = uint32(13) - orig.EntityRefs = GenerateOrigTestEntityRefSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigResource(orig *otlpresource.Resource, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.Attributes) > 0 { - dest.WriteObjectField("attributes") - dest.WriteArrayStart() - MarshalJSONOrigKeyValue(&orig.Attributes[0], dest) - for i := 1; i < len(orig.Attributes); i++ { - dest.WriteMore() - MarshalJSONOrigKeyValue(&orig.Attributes[i], dest) - } - dest.WriteArrayEnd() - } - if orig.DroppedAttributesCount != uint32(0) { - dest.WriteObjectField("droppedAttributesCount") - dest.WriteUint32(orig.DroppedAttributesCount) - } - if len(orig.EntityRefs) > 0 { - dest.WriteObjectField("entityRefs") - dest.WriteArrayStart() - MarshalJSONOrigEntityRef(orig.EntityRefs[0], dest) - for i := 1; i < len(orig.EntityRefs); i++ { - dest.WriteMore() - MarshalJSONOrigEntityRef(orig.EntityRefs[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigResource unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigResource(orig *otlpresource.Resource, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "attributes": - for iter.ReadArray() { - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - UnmarshalJSONOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], iter) - } - - case "droppedAttributesCount", "dropped_attributes_count": - orig.DroppedAttributesCount = iter.ReadUint32() - case "entityRefs", "entity_refs": - for iter.ReadArray() { - orig.EntityRefs = append(orig.EntityRefs, NewOrigEntityRef()) - UnmarshalJSONOrigEntityRef(orig.EntityRefs[len(orig.EntityRefs)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigResource(orig *otlpresource.Resource) int { - var n int - var l int - _ = l - for i := range orig.Attributes { - l = SizeProtoOrigKeyValue(&orig.Attributes[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - if orig.DroppedAttributesCount != 0 { - n += 1 + proto.Sov(uint64(orig.DroppedAttributesCount)) - } - for i := range orig.EntityRefs { - l = SizeProtoOrigEntityRef(orig.EntityRefs[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigResource(orig *otlpresource.Resource, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.Attributes) - 1; i >= 0; i-- { - l = MarshalProtoOrigKeyValue(&orig.Attributes[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - if orig.DroppedAttributesCount != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.DroppedAttributesCount)) - pos-- - buf[pos] = 0x10 - } - for i := len(orig.EntityRefs) - 1; i >= 0; i-- { - l = MarshalProtoOrigEntityRef(orig.EntityRefs[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigResource(orig *otlpresource.Resource, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Attributes = append(orig.Attributes, otlpcommon.KeyValue{}) - err = UnmarshalProtoOrigKeyValue(&orig.Attributes[len(orig.Attributes)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field DroppedAttributesCount", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.DroppedAttributesCount = uint32(num) - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field EntityRefs", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.EntityRefs = append(orig.EntityRefs, NewOrigEntityRef()) - err = UnmarshalProtoOrigEntityRef(orig.EntityRefs[len(orig.EntityRefs)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil +func GenTestResourceWrapper() ResourceWrapper { + return NewResourceWrapper(GenTestResource(), NewState()) } diff --git a/pdata/internal/generated_wrapper_resourcelogs.go b/pdata/internal/generated_wrapper_resourcelogs.go deleted file mode 100644 index 4c78e1246a6..00000000000 --- a/pdata/internal/generated_wrapper_resourcelogs.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolResourceLogs = sync.Pool{ - New: func() any { - return &otlplogs.ResourceLogs{} - }, - } -) - -func NewOrigResourceLogs() *otlplogs.ResourceLogs { - if !UseProtoPooling.IsEnabled() { - return &otlplogs.ResourceLogs{} - } - return protoPoolResourceLogs.Get().(*otlplogs.ResourceLogs) -} - -func DeleteOrigResourceLogs(orig *otlplogs.ResourceLogs, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigResource(&orig.Resource, false) - for i := range orig.ScopeLogs { - DeleteOrigScopeLogs(orig.ScopeLogs[i], true) - } - - orig.Reset() - if nullable { - protoPoolResourceLogs.Put(orig) - } -} - -func CopyOrigResourceLogs(dest, src *otlplogs.ResourceLogs) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigResource(&dest.Resource, &src.Resource) - dest.ScopeLogs = CopyOrigScopeLogsSlice(dest.ScopeLogs, src.ScopeLogs) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigResourceLogs() *otlplogs.ResourceLogs { - orig := NewOrigResourceLogs() - orig.Resource = *GenTestOrigResource() - orig.ScopeLogs = GenerateOrigTestScopeLogsSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigResourceLogs(orig *otlplogs.ResourceLogs, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("resource") - MarshalJSONOrigResource(&orig.Resource, dest) - if len(orig.ScopeLogs) > 0 { - dest.WriteObjectField("scopeLogs") - dest.WriteArrayStart() - MarshalJSONOrigScopeLogs(orig.ScopeLogs[0], dest) - for i := 1; i < len(orig.ScopeLogs); i++ { - dest.WriteMore() - MarshalJSONOrigScopeLogs(orig.ScopeLogs[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigResourceLogs unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigResourceLogs(orig *otlplogs.ResourceLogs, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resource": - UnmarshalJSONOrigResource(&orig.Resource, iter) - case "scopeLogs", "scope_logs": - for iter.ReadArray() { - orig.ScopeLogs = append(orig.ScopeLogs, NewOrigScopeLogs()) - UnmarshalJSONOrigScopeLogs(orig.ScopeLogs[len(orig.ScopeLogs)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigResourceLogs(orig *otlplogs.ResourceLogs) int { - var n int - var l int - _ = l - l = SizeProtoOrigResource(&orig.Resource) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.ScopeLogs { - l = SizeProtoOrigScopeLogs(orig.ScopeLogs[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigResourceLogs(orig *otlplogs.ResourceLogs, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigResource(&orig.Resource, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.ScopeLogs) - 1; i >= 0; i-- { - l = MarshalProtoOrigScopeLogs(orig.ScopeLogs[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigResourceLogs(orig *otlplogs.ResourceLogs, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigResource(&orig.Resource, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeLogs", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ScopeLogs = append(orig.ScopeLogs, NewOrigScopeLogs()) - err = UnmarshalProtoOrigScopeLogs(orig.ScopeLogs[len(orig.ScopeLogs)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_resourcelogs_test.go b/pdata/internal/generated_wrapper_resourcelogs_test.go deleted file mode 100644 index 22e1d631b1f..00000000000 --- a/pdata/internal/generated_wrapper_resourcelogs_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlplogs "go.opentelemetry.io/proto/slim/otlp/logs/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigResourceLogs(t *testing.T) { - for name, src := range genTestEncodingValuesResourceLogs() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigResourceLogs() - CopyOrigResourceLogs(dest, src) - assert.Equal(t, src, dest) - CopyOrigResourceLogs(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigResourceLogsUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigResourceLogs() - UnmarshalJSONOrigResourceLogs(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigResourceLogs(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigResourceLogs(t *testing.T) { - for name, src := range genTestEncodingValuesResourceLogs() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigResourceLogs(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigResourceLogs() - UnmarshalJSONOrigResourceLogs(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigResourceLogs(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigResourceLogsFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesResourceLogs() { - t.Run(name, func(t *testing.T) { - dest := NewOrigResourceLogs() - require.Error(t, UnmarshalProtoOrigResourceLogs(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigResourceLogsUnknown(t *testing.T) { - dest := NewOrigResourceLogs() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigResourceLogs(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigResourceLogs(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigResourceLogs(t *testing.T) { - for name, src := range genTestEncodingValuesResourceLogs() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigResourceLogs(src)) - gotSize := MarshalProtoOrigResourceLogs(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigResourceLogs() - require.NoError(t, UnmarshalProtoOrigResourceLogs(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigResourceLogs(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufResourceLogs(t *testing.T) { - for name, src := range genTestEncodingValuesResourceLogs() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigResourceLogs(src)) - gotSize := MarshalProtoOrigResourceLogs(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlplogs.ResourceLogs{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigResourceLogs() - require.NoError(t, UnmarshalProtoOrigResourceLogs(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesResourceLogs() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "Resource/wrong_wire_type": {0xc}, - "Resource/missing_value": {0xa}, - "ScopeLogs/wrong_wire_type": {0x14}, - "ScopeLogs/missing_value": {0x12}, - "SchemaUrl/wrong_wire_type": {0x1c}, - "SchemaUrl/missing_value": {0x1a}, - } -} - -func genTestEncodingValuesResourceLogs() map[string]*otlplogs.ResourceLogs { - return map[string]*otlplogs.ResourceLogs{ - "empty": NewOrigResourceLogs(), - "Resource/test": {Resource: *GenTestOrigResource()}, - "ScopeLogs/default_and_test": {ScopeLogs: []*otlplogs.ScopeLogs{{}, GenTestOrigScopeLogs()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, - } -} diff --git a/pdata/internal/generated_wrapper_resourcelogsslice.go b/pdata/internal/generated_wrapper_resourcelogsslice.go deleted file mode 100644 index dcf0a0afb08..00000000000 --- a/pdata/internal/generated_wrapper_resourcelogsslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -func CopyOrigResourceLogsSlice(dest, src []*otlplogs.ResourceLogs) []*otlplogs.ResourceLogs { - var newDest []*otlplogs.ResourceLogs - if cap(dest) < len(src) { - newDest = make([]*otlplogs.ResourceLogs, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceLogs() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigResourceLogs(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceLogs() - } - } - for i := range src { - CopyOrigResourceLogs(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestResourceLogsSlice() []*otlplogs.ResourceLogs { - orig := make([]*otlplogs.ResourceLogs, 5) - orig[0] = NewOrigResourceLogs() - orig[1] = GenTestOrigResourceLogs() - orig[2] = NewOrigResourceLogs() - orig[3] = GenTestOrigResourceLogs() - orig[4] = NewOrigResourceLogs() - return orig -} diff --git a/pdata/internal/generated_wrapper_resourcelogsslice_test.go b/pdata/internal/generated_wrapper_resourcelogsslice_test.go deleted file mode 100644 index f05862e8244..00000000000 --- a/pdata/internal/generated_wrapper_resourcelogsslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -func TestCopyOrigResourceLogsSlice(t *testing.T) { - src := []*otlplogs.ResourceLogs{} - dest := []*otlplogs.ResourceLogs{} - // Test CopyTo empty - dest = CopyOrigResourceLogsSlice(dest, src) - assert.Equal(t, []*otlplogs.ResourceLogs{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestResourceLogsSlice() - dest = CopyOrigResourceLogsSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceLogsSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigResourceLogsSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceLogsSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigResourceLogsSlice(dest, []*otlplogs.ResourceLogs{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigResourceLogsSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceLogsSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_resourcemetrics.go b/pdata/internal/generated_wrapper_resourcemetrics.go deleted file mode 100644 index a412cfee854..00000000000 --- a/pdata/internal/generated_wrapper_resourcemetrics.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolResourceMetrics = sync.Pool{ - New: func() any { - return &otlpmetrics.ResourceMetrics{} - }, - } -) - -func NewOrigResourceMetrics() *otlpmetrics.ResourceMetrics { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.ResourceMetrics{} - } - return protoPoolResourceMetrics.Get().(*otlpmetrics.ResourceMetrics) -} - -func DeleteOrigResourceMetrics(orig *otlpmetrics.ResourceMetrics, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigResource(&orig.Resource, false) - for i := range orig.ScopeMetrics { - DeleteOrigScopeMetrics(orig.ScopeMetrics[i], true) - } - - orig.Reset() - if nullable { - protoPoolResourceMetrics.Put(orig) - } -} - -func CopyOrigResourceMetrics(dest, src *otlpmetrics.ResourceMetrics) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigResource(&dest.Resource, &src.Resource) - dest.ScopeMetrics = CopyOrigScopeMetricsSlice(dest.ScopeMetrics, src.ScopeMetrics) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigResourceMetrics() *otlpmetrics.ResourceMetrics { - orig := NewOrigResourceMetrics() - orig.Resource = *GenTestOrigResource() - orig.ScopeMetrics = GenerateOrigTestScopeMetricsSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigResourceMetrics(orig *otlpmetrics.ResourceMetrics, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("resource") - MarshalJSONOrigResource(&orig.Resource, dest) - if len(orig.ScopeMetrics) > 0 { - dest.WriteObjectField("scopeMetrics") - dest.WriteArrayStart() - MarshalJSONOrigScopeMetrics(orig.ScopeMetrics[0], dest) - for i := 1; i < len(orig.ScopeMetrics); i++ { - dest.WriteMore() - MarshalJSONOrigScopeMetrics(orig.ScopeMetrics[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigResourceMetrics unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigResourceMetrics(orig *otlpmetrics.ResourceMetrics, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resource": - UnmarshalJSONOrigResource(&orig.Resource, iter) - case "scopeMetrics", "scope_metrics": - for iter.ReadArray() { - orig.ScopeMetrics = append(orig.ScopeMetrics, NewOrigScopeMetrics()) - UnmarshalJSONOrigScopeMetrics(orig.ScopeMetrics[len(orig.ScopeMetrics)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigResourceMetrics(orig *otlpmetrics.ResourceMetrics) int { - var n int - var l int - _ = l - l = SizeProtoOrigResource(&orig.Resource) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.ScopeMetrics { - l = SizeProtoOrigScopeMetrics(orig.ScopeMetrics[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigResourceMetrics(orig *otlpmetrics.ResourceMetrics, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigResource(&orig.Resource, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.ScopeMetrics) - 1; i >= 0; i-- { - l = MarshalProtoOrigScopeMetrics(orig.ScopeMetrics[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigResourceMetrics(orig *otlpmetrics.ResourceMetrics, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigResource(&orig.Resource, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeMetrics", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ScopeMetrics = append(orig.ScopeMetrics, NewOrigScopeMetrics()) - err = UnmarshalProtoOrigScopeMetrics(orig.ScopeMetrics[len(orig.ScopeMetrics)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_resourcemetrics_test.go b/pdata/internal/generated_wrapper_resourcemetrics_test.go deleted file mode 100644 index a4ee6dba6b1..00000000000 --- a/pdata/internal/generated_wrapper_resourcemetrics_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigResourceMetrics(t *testing.T) { - for name, src := range genTestEncodingValuesResourceMetrics() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigResourceMetrics() - CopyOrigResourceMetrics(dest, src) - assert.Equal(t, src, dest) - CopyOrigResourceMetrics(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigResourceMetricsUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigResourceMetrics() - UnmarshalJSONOrigResourceMetrics(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigResourceMetrics(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigResourceMetrics(t *testing.T) { - for name, src := range genTestEncodingValuesResourceMetrics() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigResourceMetrics(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigResourceMetrics() - UnmarshalJSONOrigResourceMetrics(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigResourceMetrics(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigResourceMetricsFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesResourceMetrics() { - t.Run(name, func(t *testing.T) { - dest := NewOrigResourceMetrics() - require.Error(t, UnmarshalProtoOrigResourceMetrics(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigResourceMetricsUnknown(t *testing.T) { - dest := NewOrigResourceMetrics() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigResourceMetrics(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigResourceMetrics(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigResourceMetrics(t *testing.T) { - for name, src := range genTestEncodingValuesResourceMetrics() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigResourceMetrics(src)) - gotSize := MarshalProtoOrigResourceMetrics(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigResourceMetrics() - require.NoError(t, UnmarshalProtoOrigResourceMetrics(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigResourceMetrics(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufResourceMetrics(t *testing.T) { - for name, src := range genTestEncodingValuesResourceMetrics() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigResourceMetrics(src)) - gotSize := MarshalProtoOrigResourceMetrics(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpmetrics.ResourceMetrics{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigResourceMetrics() - require.NoError(t, UnmarshalProtoOrigResourceMetrics(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesResourceMetrics() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "Resource/wrong_wire_type": {0xc}, - "Resource/missing_value": {0xa}, - "ScopeMetrics/wrong_wire_type": {0x14}, - "ScopeMetrics/missing_value": {0x12}, - "SchemaUrl/wrong_wire_type": {0x1c}, - "SchemaUrl/missing_value": {0x1a}, - } -} - -func genTestEncodingValuesResourceMetrics() map[string]*otlpmetrics.ResourceMetrics { - return map[string]*otlpmetrics.ResourceMetrics{ - "empty": NewOrigResourceMetrics(), - "Resource/test": {Resource: *GenTestOrigResource()}, - "ScopeMetrics/default_and_test": {ScopeMetrics: []*otlpmetrics.ScopeMetrics{{}, GenTestOrigScopeMetrics()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, - } -} diff --git a/pdata/internal/generated_wrapper_resourcemetricsslice.go b/pdata/internal/generated_wrapper_resourcemetricsslice.go deleted file mode 100644 index 7bd0db8fc51..00000000000 --- a/pdata/internal/generated_wrapper_resourcemetricsslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigResourceMetricsSlice(dest, src []*otlpmetrics.ResourceMetrics) []*otlpmetrics.ResourceMetrics { - var newDest []*otlpmetrics.ResourceMetrics - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.ResourceMetrics, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceMetrics() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigResourceMetrics(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceMetrics() - } - } - for i := range src { - CopyOrigResourceMetrics(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestResourceMetricsSlice() []*otlpmetrics.ResourceMetrics { - orig := make([]*otlpmetrics.ResourceMetrics, 5) - orig[0] = NewOrigResourceMetrics() - orig[1] = GenTestOrigResourceMetrics() - orig[2] = NewOrigResourceMetrics() - orig[3] = GenTestOrigResourceMetrics() - orig[4] = NewOrigResourceMetrics() - return orig -} diff --git a/pdata/internal/generated_wrapper_resourcemetricsslice_test.go b/pdata/internal/generated_wrapper_resourcemetricsslice_test.go deleted file mode 100644 index e1626a0fcdd..00000000000 --- a/pdata/internal/generated_wrapper_resourcemetricsslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigResourceMetricsSlice(t *testing.T) { - src := []*otlpmetrics.ResourceMetrics{} - dest := []*otlpmetrics.ResourceMetrics{} - // Test CopyTo empty - dest = CopyOrigResourceMetricsSlice(dest, src) - assert.Equal(t, []*otlpmetrics.ResourceMetrics{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestResourceMetricsSlice() - dest = CopyOrigResourceMetricsSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceMetricsSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigResourceMetricsSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceMetricsSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigResourceMetricsSlice(dest, []*otlpmetrics.ResourceMetrics{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigResourceMetricsSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceMetricsSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_resourceprofiles.go b/pdata/internal/generated_wrapper_resourceprofiles.go deleted file mode 100644 index 5481ab28651..00000000000 --- a/pdata/internal/generated_wrapper_resourceprofiles.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolResourceProfiles = sync.Pool{ - New: func() any { - return &otlpprofiles.ResourceProfiles{} - }, - } -) - -func NewOrigResourceProfiles() *otlpprofiles.ResourceProfiles { - if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.ResourceProfiles{} - } - return protoPoolResourceProfiles.Get().(*otlpprofiles.ResourceProfiles) -} - -func DeleteOrigResourceProfiles(orig *otlpprofiles.ResourceProfiles, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigResource(&orig.Resource, false) - for i := range orig.ScopeProfiles { - DeleteOrigScopeProfiles(orig.ScopeProfiles[i], true) - } - - orig.Reset() - if nullable { - protoPoolResourceProfiles.Put(orig) - } -} - -func CopyOrigResourceProfiles(dest, src *otlpprofiles.ResourceProfiles) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigResource(&dest.Resource, &src.Resource) - dest.ScopeProfiles = CopyOrigScopeProfilesSlice(dest.ScopeProfiles, src.ScopeProfiles) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigResourceProfiles() *otlpprofiles.ResourceProfiles { - orig := NewOrigResourceProfiles() - orig.Resource = *GenTestOrigResource() - orig.ScopeProfiles = GenerateOrigTestScopeProfilesSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigResourceProfiles(orig *otlpprofiles.ResourceProfiles, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("resource") - MarshalJSONOrigResource(&orig.Resource, dest) - if len(orig.ScopeProfiles) > 0 { - dest.WriteObjectField("scopeProfiles") - dest.WriteArrayStart() - MarshalJSONOrigScopeProfiles(orig.ScopeProfiles[0], dest) - for i := 1; i < len(orig.ScopeProfiles); i++ { - dest.WriteMore() - MarshalJSONOrigScopeProfiles(orig.ScopeProfiles[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigResourceProfiles unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigResourceProfiles(orig *otlpprofiles.ResourceProfiles, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resource": - UnmarshalJSONOrigResource(&orig.Resource, iter) - case "scopeProfiles", "scope_profiles": - for iter.ReadArray() { - orig.ScopeProfiles = append(orig.ScopeProfiles, NewOrigScopeProfiles()) - UnmarshalJSONOrigScopeProfiles(orig.ScopeProfiles[len(orig.ScopeProfiles)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigResourceProfiles(orig *otlpprofiles.ResourceProfiles) int { - var n int - var l int - _ = l - l = SizeProtoOrigResource(&orig.Resource) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.ScopeProfiles { - l = SizeProtoOrigScopeProfiles(orig.ScopeProfiles[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigResourceProfiles(orig *otlpprofiles.ResourceProfiles, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigResource(&orig.Resource, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.ScopeProfiles) - 1; i >= 0; i-- { - l = MarshalProtoOrigScopeProfiles(orig.ScopeProfiles[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigResourceProfiles(orig *otlpprofiles.ResourceProfiles, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigResource(&orig.Resource, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeProfiles", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ScopeProfiles = append(orig.ScopeProfiles, NewOrigScopeProfiles()) - err = UnmarshalProtoOrigScopeProfiles(orig.ScopeProfiles[len(orig.ScopeProfiles)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_resourceprofilesslice.go b/pdata/internal/generated_wrapper_resourceprofilesslice.go deleted file mode 100644 index 978753cdc1d..00000000000 --- a/pdata/internal/generated_wrapper_resourceprofilesslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigResourceProfilesSlice(dest, src []*otlpprofiles.ResourceProfiles) []*otlpprofiles.ResourceProfiles { - var newDest []*otlpprofiles.ResourceProfiles - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.ResourceProfiles, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceProfiles() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigResourceProfiles(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceProfiles() - } - } - for i := range src { - CopyOrigResourceProfiles(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestResourceProfilesSlice() []*otlpprofiles.ResourceProfiles { - orig := make([]*otlpprofiles.ResourceProfiles, 5) - orig[0] = NewOrigResourceProfiles() - orig[1] = GenTestOrigResourceProfiles() - orig[2] = NewOrigResourceProfiles() - orig[3] = GenTestOrigResourceProfiles() - orig[4] = NewOrigResourceProfiles() - return orig -} diff --git a/pdata/internal/generated_wrapper_resourceprofilesslice_test.go b/pdata/internal/generated_wrapper_resourceprofilesslice_test.go deleted file mode 100644 index 2e732b3ef56..00000000000 --- a/pdata/internal/generated_wrapper_resourceprofilesslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigResourceProfilesSlice(t *testing.T) { - src := []*otlpprofiles.ResourceProfiles{} - dest := []*otlpprofiles.ResourceProfiles{} - // Test CopyTo empty - dest = CopyOrigResourceProfilesSlice(dest, src) - assert.Equal(t, []*otlpprofiles.ResourceProfiles{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestResourceProfilesSlice() - dest = CopyOrigResourceProfilesSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceProfilesSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigResourceProfilesSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceProfilesSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigResourceProfilesSlice(dest, []*otlpprofiles.ResourceProfiles{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigResourceProfilesSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceProfilesSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_resourcespans.go b/pdata/internal/generated_wrapper_resourcespans.go deleted file mode 100644 index 3599e21cd60..00000000000 --- a/pdata/internal/generated_wrapper_resourcespans.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolResourceSpans = sync.Pool{ - New: func() any { - return &otlptrace.ResourceSpans{} - }, - } -) - -func NewOrigResourceSpans() *otlptrace.ResourceSpans { - if !UseProtoPooling.IsEnabled() { - return &otlptrace.ResourceSpans{} - } - return protoPoolResourceSpans.Get().(*otlptrace.ResourceSpans) -} - -func DeleteOrigResourceSpans(orig *otlptrace.ResourceSpans, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigResource(&orig.Resource, false) - for i := range orig.ScopeSpans { - DeleteOrigScopeSpans(orig.ScopeSpans[i], true) - } - - orig.Reset() - if nullable { - protoPoolResourceSpans.Put(orig) - } -} - -func CopyOrigResourceSpans(dest, src *otlptrace.ResourceSpans) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigResource(&dest.Resource, &src.Resource) - dest.ScopeSpans = CopyOrigScopeSpansSlice(dest.ScopeSpans, src.ScopeSpans) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigResourceSpans() *otlptrace.ResourceSpans { - orig := NewOrigResourceSpans() - orig.Resource = *GenTestOrigResource() - orig.ScopeSpans = GenerateOrigTestScopeSpansSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigResourceSpans(orig *otlptrace.ResourceSpans, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("resource") - MarshalJSONOrigResource(&orig.Resource, dest) - if len(orig.ScopeSpans) > 0 { - dest.WriteObjectField("scopeSpans") - dest.WriteArrayStart() - MarshalJSONOrigScopeSpans(orig.ScopeSpans[0], dest) - for i := 1; i < len(orig.ScopeSpans); i++ { - dest.WriteMore() - MarshalJSONOrigScopeSpans(orig.ScopeSpans[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigResourceSpans unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigResourceSpans(orig *otlptrace.ResourceSpans, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "resource": - UnmarshalJSONOrigResource(&orig.Resource, iter) - case "scopeSpans", "scope_spans": - for iter.ReadArray() { - orig.ScopeSpans = append(orig.ScopeSpans, NewOrigScopeSpans()) - UnmarshalJSONOrigScopeSpans(orig.ScopeSpans[len(orig.ScopeSpans)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigResourceSpans(orig *otlptrace.ResourceSpans) int { - var n int - var l int - _ = l - l = SizeProtoOrigResource(&orig.Resource) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.ScopeSpans { - l = SizeProtoOrigScopeSpans(orig.ScopeSpans[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigResourceSpans(orig *otlptrace.ResourceSpans, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigResource(&orig.Resource, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.ScopeSpans) - 1; i >= 0; i-- { - l = MarshalProtoOrigScopeSpans(orig.ScopeSpans[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigResourceSpans(orig *otlptrace.ResourceSpans, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigResource(&orig.Resource, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field ScopeSpans", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.ScopeSpans = append(orig.ScopeSpans, NewOrigScopeSpans()) - err = UnmarshalProtoOrigScopeSpans(orig.ScopeSpans[len(orig.ScopeSpans)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_resourcespans_test.go b/pdata/internal/generated_wrapper_resourcespans_test.go deleted file mode 100644 index 5afa710528f..00000000000 --- a/pdata/internal/generated_wrapper_resourcespans_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlptrace "go.opentelemetry.io/proto/slim/otlp/trace/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigResourceSpans(t *testing.T) { - for name, src := range genTestEncodingValuesResourceSpans() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigResourceSpans() - CopyOrigResourceSpans(dest, src) - assert.Equal(t, src, dest) - CopyOrigResourceSpans(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigResourceSpansUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigResourceSpans() - UnmarshalJSONOrigResourceSpans(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigResourceSpans(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigResourceSpans(t *testing.T) { - for name, src := range genTestEncodingValuesResourceSpans() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigResourceSpans(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigResourceSpans() - UnmarshalJSONOrigResourceSpans(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigResourceSpans(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigResourceSpansFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesResourceSpans() { - t.Run(name, func(t *testing.T) { - dest := NewOrigResourceSpans() - require.Error(t, UnmarshalProtoOrigResourceSpans(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigResourceSpansUnknown(t *testing.T) { - dest := NewOrigResourceSpans() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigResourceSpans(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigResourceSpans(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigResourceSpans(t *testing.T) { - for name, src := range genTestEncodingValuesResourceSpans() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigResourceSpans(src)) - gotSize := MarshalProtoOrigResourceSpans(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigResourceSpans() - require.NoError(t, UnmarshalProtoOrigResourceSpans(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigResourceSpans(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufResourceSpans(t *testing.T) { - for name, src := range genTestEncodingValuesResourceSpans() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigResourceSpans(src)) - gotSize := MarshalProtoOrigResourceSpans(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlptrace.ResourceSpans{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigResourceSpans() - require.NoError(t, UnmarshalProtoOrigResourceSpans(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesResourceSpans() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "Resource/wrong_wire_type": {0xc}, - "Resource/missing_value": {0xa}, - "ScopeSpans/wrong_wire_type": {0x14}, - "ScopeSpans/missing_value": {0x12}, - "SchemaUrl/wrong_wire_type": {0x1c}, - "SchemaUrl/missing_value": {0x1a}, - } -} - -func genTestEncodingValuesResourceSpans() map[string]*otlptrace.ResourceSpans { - return map[string]*otlptrace.ResourceSpans{ - "empty": NewOrigResourceSpans(), - "Resource/test": {Resource: *GenTestOrigResource()}, - "ScopeSpans/default_and_test": {ScopeSpans: []*otlptrace.ScopeSpans{{}, GenTestOrigScopeSpans()}}, - "SchemaUrl/test": {SchemaUrl: "test_schemaurl"}, - } -} diff --git a/pdata/internal/generated_wrapper_resourcespansslice.go b/pdata/internal/generated_wrapper_resourcespansslice.go deleted file mode 100644 index 3128ef7581f..00000000000 --- a/pdata/internal/generated_wrapper_resourcespansslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func CopyOrigResourceSpansSlice(dest, src []*otlptrace.ResourceSpans) []*otlptrace.ResourceSpans { - var newDest []*otlptrace.ResourceSpans - if cap(dest) < len(src) { - newDest = make([]*otlptrace.ResourceSpans, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceSpans() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigResourceSpans(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigResourceSpans() - } - } - for i := range src { - CopyOrigResourceSpans(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestResourceSpansSlice() []*otlptrace.ResourceSpans { - orig := make([]*otlptrace.ResourceSpans, 5) - orig[0] = NewOrigResourceSpans() - orig[1] = GenTestOrigResourceSpans() - orig[2] = NewOrigResourceSpans() - orig[3] = GenTestOrigResourceSpans() - orig[4] = NewOrigResourceSpans() - return orig -} diff --git a/pdata/internal/generated_wrapper_resourcespansslice_test.go b/pdata/internal/generated_wrapper_resourcespansslice_test.go deleted file mode 100644 index 5e019a53aee..00000000000 --- a/pdata/internal/generated_wrapper_resourcespansslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func TestCopyOrigResourceSpansSlice(t *testing.T) { - src := []*otlptrace.ResourceSpans{} - dest := []*otlptrace.ResourceSpans{} - // Test CopyTo empty - dest = CopyOrigResourceSpansSlice(dest, src) - assert.Equal(t, []*otlptrace.ResourceSpans{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestResourceSpansSlice() - dest = CopyOrigResourceSpansSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceSpansSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigResourceSpansSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceSpansSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigResourceSpansSlice(dest, []*otlptrace.ResourceSpans{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigResourceSpansSlice(dest, src) - assert.Equal(t, GenerateOrigTestResourceSpansSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_sampleslice.go b/pdata/internal/generated_wrapper_sampleslice.go deleted file mode 100644 index a2dfca32163..00000000000 --- a/pdata/internal/generated_wrapper_sampleslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigSampleSlice(dest, src []*otlpprofiles.Sample) []*otlpprofiles.Sample { - var newDest []*otlpprofiles.Sample - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Sample, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSample() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigSample(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSample() - } - } - for i := range src { - CopyOrigSample(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestSampleSlice() []*otlpprofiles.Sample { - orig := make([]*otlpprofiles.Sample, 5) - orig[0] = NewOrigSample() - orig[1] = GenTestOrigSample() - orig[2] = NewOrigSample() - orig[3] = GenTestOrigSample() - orig[4] = NewOrigSample() - return orig -} diff --git a/pdata/internal/generated_wrapper_sampleslice_test.go b/pdata/internal/generated_wrapper_sampleslice_test.go deleted file mode 100644 index 26113666f57..00000000000 --- a/pdata/internal/generated_wrapper_sampleslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigSampleSlice(t *testing.T) { - src := []*otlpprofiles.Sample{} - dest := []*otlpprofiles.Sample{} - // Test CopyTo empty - dest = CopyOrigSampleSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Sample{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestSampleSlice() - dest = CopyOrigSampleSlice(dest, src) - assert.Equal(t, GenerateOrigTestSampleSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigSampleSlice(dest, src) - assert.Equal(t, GenerateOrigTestSampleSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigSampleSlice(dest, []*otlpprofiles.Sample{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigSampleSlice(dest, src) - assert.Equal(t, GenerateOrigTestSampleSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_scopelogs.go b/pdata/internal/generated_wrapper_scopelogs.go deleted file mode 100644 index c98a86112d2..00000000000 --- a/pdata/internal/generated_wrapper_scopelogs.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolScopeLogs = sync.Pool{ - New: func() any { - return &otlplogs.ScopeLogs{} - }, - } -) - -func NewOrigScopeLogs() *otlplogs.ScopeLogs { - if !UseProtoPooling.IsEnabled() { - return &otlplogs.ScopeLogs{} - } - return protoPoolScopeLogs.Get().(*otlplogs.ScopeLogs) -} - -func DeleteOrigScopeLogs(orig *otlplogs.ScopeLogs, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigInstrumentationScope(&orig.Scope, false) - for i := range orig.LogRecords { - DeleteOrigLogRecord(orig.LogRecords[i], true) - } - - orig.Reset() - if nullable { - protoPoolScopeLogs.Put(orig) - } -} - -func CopyOrigScopeLogs(dest, src *otlplogs.ScopeLogs) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigInstrumentationScope(&dest.Scope, &src.Scope) - dest.LogRecords = CopyOrigLogRecordSlice(dest.LogRecords, src.LogRecords) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigScopeLogs() *otlplogs.ScopeLogs { - orig := NewOrigScopeLogs() - orig.Scope = *GenTestOrigInstrumentationScope() - orig.LogRecords = GenerateOrigTestLogRecordSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigScopeLogs(orig *otlplogs.ScopeLogs, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("scope") - MarshalJSONOrigInstrumentationScope(&orig.Scope, dest) - if len(orig.LogRecords) > 0 { - dest.WriteObjectField("logRecords") - dest.WriteArrayStart() - MarshalJSONOrigLogRecord(orig.LogRecords[0], dest) - for i := 1; i < len(orig.LogRecords); i++ { - dest.WriteMore() - MarshalJSONOrigLogRecord(orig.LogRecords[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigScopeLogs unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigScopeLogs(orig *otlplogs.ScopeLogs, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "scope": - UnmarshalJSONOrigInstrumentationScope(&orig.Scope, iter) - case "logRecords", "log_records": - for iter.ReadArray() { - orig.LogRecords = append(orig.LogRecords, NewOrigLogRecord()) - UnmarshalJSONOrigLogRecord(orig.LogRecords[len(orig.LogRecords)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigScopeLogs(orig *otlplogs.ScopeLogs) int { - var n int - var l int - _ = l - l = SizeProtoOrigInstrumentationScope(&orig.Scope) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.LogRecords { - l = SizeProtoOrigLogRecord(orig.LogRecords[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigScopeLogs(orig *otlplogs.ScopeLogs, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigInstrumentationScope(&orig.Scope, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.LogRecords) - 1; i >= 0; i-- { - l = MarshalProtoOrigLogRecord(orig.LogRecords[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigScopeLogs(orig *otlplogs.ScopeLogs, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigInstrumentationScope(&orig.Scope, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field LogRecords", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.LogRecords = append(orig.LogRecords, NewOrigLogRecord()) - err = UnmarshalProtoOrigLogRecord(orig.LogRecords[len(orig.LogRecords)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_scopelogsslice.go b/pdata/internal/generated_wrapper_scopelogsslice.go deleted file mode 100644 index ed0b6cc78fb..00000000000 --- a/pdata/internal/generated_wrapper_scopelogsslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -func CopyOrigScopeLogsSlice(dest, src []*otlplogs.ScopeLogs) []*otlplogs.ScopeLogs { - var newDest []*otlplogs.ScopeLogs - if cap(dest) < len(src) { - newDest = make([]*otlplogs.ScopeLogs, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeLogs() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigScopeLogs(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeLogs() - } - } - for i := range src { - CopyOrigScopeLogs(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestScopeLogsSlice() []*otlplogs.ScopeLogs { - orig := make([]*otlplogs.ScopeLogs, 5) - orig[0] = NewOrigScopeLogs() - orig[1] = GenTestOrigScopeLogs() - orig[2] = NewOrigScopeLogs() - orig[3] = GenTestOrigScopeLogs() - orig[4] = NewOrigScopeLogs() - return orig -} diff --git a/pdata/internal/generated_wrapper_scopelogsslice_test.go b/pdata/internal/generated_wrapper_scopelogsslice_test.go deleted file mode 100644 index 44d67b25117..00000000000 --- a/pdata/internal/generated_wrapper_scopelogsslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - -func TestCopyOrigScopeLogsSlice(t *testing.T) { - src := []*otlplogs.ScopeLogs{} - dest := []*otlplogs.ScopeLogs{} - // Test CopyTo empty - dest = CopyOrigScopeLogsSlice(dest, src) - assert.Equal(t, []*otlplogs.ScopeLogs{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestScopeLogsSlice() - dest = CopyOrigScopeLogsSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeLogsSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigScopeLogsSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeLogsSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigScopeLogsSlice(dest, []*otlplogs.ScopeLogs{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigScopeLogsSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeLogsSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_scopemetrics.go b/pdata/internal/generated_wrapper_scopemetrics.go deleted file mode 100644 index 59e05b32feb..00000000000 --- a/pdata/internal/generated_wrapper_scopemetrics.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolScopeMetrics = sync.Pool{ - New: func() any { - return &otlpmetrics.ScopeMetrics{} - }, - } -) - -func NewOrigScopeMetrics() *otlpmetrics.ScopeMetrics { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.ScopeMetrics{} - } - return protoPoolScopeMetrics.Get().(*otlpmetrics.ScopeMetrics) -} - -func DeleteOrigScopeMetrics(orig *otlpmetrics.ScopeMetrics, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigInstrumentationScope(&orig.Scope, false) - for i := range orig.Metrics { - DeleteOrigMetric(orig.Metrics[i], true) - } - - orig.Reset() - if nullable { - protoPoolScopeMetrics.Put(orig) - } -} - -func CopyOrigScopeMetrics(dest, src *otlpmetrics.ScopeMetrics) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigInstrumentationScope(&dest.Scope, &src.Scope) - dest.Metrics = CopyOrigMetricSlice(dest.Metrics, src.Metrics) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigScopeMetrics() *otlpmetrics.ScopeMetrics { - orig := NewOrigScopeMetrics() - orig.Scope = *GenTestOrigInstrumentationScope() - orig.Metrics = GenerateOrigTestMetricSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigScopeMetrics(orig *otlpmetrics.ScopeMetrics, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("scope") - MarshalJSONOrigInstrumentationScope(&orig.Scope, dest) - if len(orig.Metrics) > 0 { - dest.WriteObjectField("metrics") - dest.WriteArrayStart() - MarshalJSONOrigMetric(orig.Metrics[0], dest) - for i := 1; i < len(orig.Metrics); i++ { - dest.WriteMore() - MarshalJSONOrigMetric(orig.Metrics[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigScopeMetrics unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigScopeMetrics(orig *otlpmetrics.ScopeMetrics, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "scope": - UnmarshalJSONOrigInstrumentationScope(&orig.Scope, iter) - case "metrics": - for iter.ReadArray() { - orig.Metrics = append(orig.Metrics, NewOrigMetric()) - UnmarshalJSONOrigMetric(orig.Metrics[len(orig.Metrics)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigScopeMetrics(orig *otlpmetrics.ScopeMetrics) int { - var n int - var l int - _ = l - l = SizeProtoOrigInstrumentationScope(&orig.Scope) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.Metrics { - l = SizeProtoOrigMetric(orig.Metrics[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigScopeMetrics(orig *otlpmetrics.ScopeMetrics, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigInstrumentationScope(&orig.Scope, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.Metrics) - 1; i >= 0; i-- { - l = MarshalProtoOrigMetric(orig.Metrics[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigScopeMetrics(orig *otlpmetrics.ScopeMetrics, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigInstrumentationScope(&orig.Scope, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Metrics = append(orig.Metrics, NewOrigMetric()) - err = UnmarshalProtoOrigMetric(orig.Metrics[len(orig.Metrics)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_scopemetricsslice.go b/pdata/internal/generated_wrapper_scopemetricsslice.go deleted file mode 100644 index 31cfbf52ef0..00000000000 --- a/pdata/internal/generated_wrapper_scopemetricsslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigScopeMetricsSlice(dest, src []*otlpmetrics.ScopeMetrics) []*otlpmetrics.ScopeMetrics { - var newDest []*otlpmetrics.ScopeMetrics - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.ScopeMetrics, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeMetrics() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigScopeMetrics(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeMetrics() - } - } - for i := range src { - CopyOrigScopeMetrics(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestScopeMetricsSlice() []*otlpmetrics.ScopeMetrics { - orig := make([]*otlpmetrics.ScopeMetrics, 5) - orig[0] = NewOrigScopeMetrics() - orig[1] = GenTestOrigScopeMetrics() - orig[2] = NewOrigScopeMetrics() - orig[3] = GenTestOrigScopeMetrics() - orig[4] = NewOrigScopeMetrics() - return orig -} diff --git a/pdata/internal/generated_wrapper_scopemetricsslice_test.go b/pdata/internal/generated_wrapper_scopemetricsslice_test.go deleted file mode 100644 index 93dffe31f74..00000000000 --- a/pdata/internal/generated_wrapper_scopemetricsslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigScopeMetricsSlice(t *testing.T) { - src := []*otlpmetrics.ScopeMetrics{} - dest := []*otlpmetrics.ScopeMetrics{} - // Test CopyTo empty - dest = CopyOrigScopeMetricsSlice(dest, src) - assert.Equal(t, []*otlpmetrics.ScopeMetrics{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestScopeMetricsSlice() - dest = CopyOrigScopeMetricsSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeMetricsSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigScopeMetricsSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeMetricsSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigScopeMetricsSlice(dest, []*otlpmetrics.ScopeMetrics{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigScopeMetricsSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeMetricsSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_scopeprofiles.go b/pdata/internal/generated_wrapper_scopeprofiles.go deleted file mode 100644 index b64845a360d..00000000000 --- a/pdata/internal/generated_wrapper_scopeprofiles.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolScopeProfiles = sync.Pool{ - New: func() any { - return &otlpprofiles.ScopeProfiles{} - }, - } -) - -func NewOrigScopeProfiles() *otlpprofiles.ScopeProfiles { - if !UseProtoPooling.IsEnabled() { - return &otlpprofiles.ScopeProfiles{} - } - return protoPoolScopeProfiles.Get().(*otlpprofiles.ScopeProfiles) -} - -func DeleteOrigScopeProfiles(orig *otlpprofiles.ScopeProfiles, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigInstrumentationScope(&orig.Scope, false) - for i := range orig.Profiles { - DeleteOrigProfile(orig.Profiles[i], true) - } - - orig.Reset() - if nullable { - protoPoolScopeProfiles.Put(orig) - } -} - -func CopyOrigScopeProfiles(dest, src *otlpprofiles.ScopeProfiles) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigInstrumentationScope(&dest.Scope, &src.Scope) - dest.Profiles = CopyOrigProfileSlice(dest.Profiles, src.Profiles) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigScopeProfiles() *otlpprofiles.ScopeProfiles { - orig := NewOrigScopeProfiles() - orig.Scope = *GenTestOrigInstrumentationScope() - orig.Profiles = GenerateOrigTestProfileSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigScopeProfiles(orig *otlpprofiles.ScopeProfiles, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("scope") - MarshalJSONOrigInstrumentationScope(&orig.Scope, dest) - if len(orig.Profiles) > 0 { - dest.WriteObjectField("profiles") - dest.WriteArrayStart() - MarshalJSONOrigProfile(orig.Profiles[0], dest) - for i := 1; i < len(orig.Profiles); i++ { - dest.WriteMore() - MarshalJSONOrigProfile(orig.Profiles[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigScopeProfiles unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigScopeProfiles(orig *otlpprofiles.ScopeProfiles, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "scope": - UnmarshalJSONOrigInstrumentationScope(&orig.Scope, iter) - case "profiles": - for iter.ReadArray() { - orig.Profiles = append(orig.Profiles, NewOrigProfile()) - UnmarshalJSONOrigProfile(orig.Profiles[len(orig.Profiles)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigScopeProfiles(orig *otlpprofiles.ScopeProfiles) int { - var n int - var l int - _ = l - l = SizeProtoOrigInstrumentationScope(&orig.Scope) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.Profiles { - l = SizeProtoOrigProfile(orig.Profiles[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigScopeProfiles(orig *otlpprofiles.ScopeProfiles, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigInstrumentationScope(&orig.Scope, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.Profiles) - 1; i >= 0; i-- { - l = MarshalProtoOrigProfile(orig.Profiles[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigScopeProfiles(orig *otlpprofiles.ScopeProfiles, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigInstrumentationScope(&orig.Scope, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Profiles", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Profiles = append(orig.Profiles, NewOrigProfile()) - err = UnmarshalProtoOrigProfile(orig.Profiles[len(orig.Profiles)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_scopeprofilesslice.go b/pdata/internal/generated_wrapper_scopeprofilesslice.go deleted file mode 100644 index 01e0894131f..00000000000 --- a/pdata/internal/generated_wrapper_scopeprofilesslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigScopeProfilesSlice(dest, src []*otlpprofiles.ScopeProfiles) []*otlpprofiles.ScopeProfiles { - var newDest []*otlpprofiles.ScopeProfiles - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.ScopeProfiles, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeProfiles() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigScopeProfiles(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeProfiles() - } - } - for i := range src { - CopyOrigScopeProfiles(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestScopeProfilesSlice() []*otlpprofiles.ScopeProfiles { - orig := make([]*otlpprofiles.ScopeProfiles, 5) - orig[0] = NewOrigScopeProfiles() - orig[1] = GenTestOrigScopeProfiles() - orig[2] = NewOrigScopeProfiles() - orig[3] = GenTestOrigScopeProfiles() - orig[4] = NewOrigScopeProfiles() - return orig -} diff --git a/pdata/internal/generated_wrapper_scopeprofilesslice_test.go b/pdata/internal/generated_wrapper_scopeprofilesslice_test.go deleted file mode 100644 index b4bf5ac3ca0..00000000000 --- a/pdata/internal/generated_wrapper_scopeprofilesslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigScopeProfilesSlice(t *testing.T) { - src := []*otlpprofiles.ScopeProfiles{} - dest := []*otlpprofiles.ScopeProfiles{} - // Test CopyTo empty - dest = CopyOrigScopeProfilesSlice(dest, src) - assert.Equal(t, []*otlpprofiles.ScopeProfiles{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestScopeProfilesSlice() - dest = CopyOrigScopeProfilesSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeProfilesSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigScopeProfilesSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeProfilesSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigScopeProfilesSlice(dest, []*otlpprofiles.ScopeProfiles{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigScopeProfilesSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeProfilesSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_scopespans.go b/pdata/internal/generated_wrapper_scopespans.go deleted file mode 100644 index d8778228f05..00000000000 --- a/pdata/internal/generated_wrapper_scopespans.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolScopeSpans = sync.Pool{ - New: func() any { - return &otlptrace.ScopeSpans{} - }, - } -) - -func NewOrigScopeSpans() *otlptrace.ScopeSpans { - if !UseProtoPooling.IsEnabled() { - return &otlptrace.ScopeSpans{} - } - return protoPoolScopeSpans.Get().(*otlptrace.ScopeSpans) -} - -func DeleteOrigScopeSpans(orig *otlptrace.ScopeSpans, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - DeleteOrigInstrumentationScope(&orig.Scope, false) - for i := range orig.Spans { - DeleteOrigSpan(orig.Spans[i], true) - } - - orig.Reset() - if nullable { - protoPoolScopeSpans.Put(orig) - } -} - -func CopyOrigScopeSpans(dest, src *otlptrace.ScopeSpans) { - // If copying to same object, just return. - if src == dest { - return - } - CopyOrigInstrumentationScope(&dest.Scope, &src.Scope) - dest.Spans = CopyOrigSpanSlice(dest.Spans, src.Spans) - dest.SchemaUrl = src.SchemaUrl -} - -func GenTestOrigScopeSpans() *otlptrace.ScopeSpans { - orig := NewOrigScopeSpans() - orig.Scope = *GenTestOrigInstrumentationScope() - orig.Spans = GenerateOrigTestSpanSlice() - orig.SchemaUrl = "test_schemaurl" - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigScopeSpans(orig *otlptrace.ScopeSpans, dest *json.Stream) { - dest.WriteObjectStart() - dest.WriteObjectField("scope") - MarshalJSONOrigInstrumentationScope(&orig.Scope, dest) - if len(orig.Spans) > 0 { - dest.WriteObjectField("spans") - dest.WriteArrayStart() - MarshalJSONOrigSpan(orig.Spans[0], dest) - for i := 1; i < len(orig.Spans); i++ { - dest.WriteMore() - MarshalJSONOrigSpan(orig.Spans[i], dest) - } - dest.WriteArrayEnd() - } - if orig.SchemaUrl != "" { - dest.WriteObjectField("schemaUrl") - dest.WriteString(orig.SchemaUrl) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigScopeSpans unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigScopeSpans(orig *otlptrace.ScopeSpans, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "scope": - UnmarshalJSONOrigInstrumentationScope(&orig.Scope, iter) - case "spans": - for iter.ReadArray() { - orig.Spans = append(orig.Spans, NewOrigSpan()) - UnmarshalJSONOrigSpan(orig.Spans[len(orig.Spans)-1], iter) - } - - case "schemaUrl", "schema_url": - orig.SchemaUrl = iter.ReadString() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigScopeSpans(orig *otlptrace.ScopeSpans) int { - var n int - var l int - _ = l - l = SizeProtoOrigInstrumentationScope(&orig.Scope) - n += 1 + proto.Sov(uint64(l)) + l - for i := range orig.Spans { - l = SizeProtoOrigSpan(orig.Spans[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - l = len(orig.SchemaUrl) - if l > 0 { - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigScopeSpans(orig *otlptrace.ScopeSpans, buf []byte) int { - pos := len(buf) - var l int - _ = l - - l = MarshalProtoOrigInstrumentationScope(&orig.Scope, buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - - for i := len(orig.Spans) - 1; i >= 0; i-- { - l = MarshalProtoOrigSpan(orig.Spans[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - l = len(orig.SchemaUrl) - if l > 0 { - pos -= l - copy(buf[pos:], orig.SchemaUrl) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x1a - } - return len(buf) - pos -} - -func UnmarshalProtoOrigScopeSpans(orig *otlptrace.ScopeSpans, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Scope", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - - err = UnmarshalProtoOrigInstrumentationScope(&orig.Scope, buf[startPos:pos]) - if err != nil { - return err - } - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Spans", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Spans = append(orig.Spans, NewOrigSpan()) - err = UnmarshalProtoOrigSpan(orig.Spans[len(orig.Spans)-1], buf[startPos:pos]) - if err != nil { - return err - } - - case 3: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaUrl", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.SchemaUrl = string(buf[startPos:pos]) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_scopespansslice.go b/pdata/internal/generated_wrapper_scopespansslice.go deleted file mode 100644 index 23583b1cd79..00000000000 --- a/pdata/internal/generated_wrapper_scopespansslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func CopyOrigScopeSpansSlice(dest, src []*otlptrace.ScopeSpans) []*otlptrace.ScopeSpans { - var newDest []*otlptrace.ScopeSpans - if cap(dest) < len(src) { - newDest = make([]*otlptrace.ScopeSpans, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeSpans() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigScopeSpans(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigScopeSpans() - } - } - for i := range src { - CopyOrigScopeSpans(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestScopeSpansSlice() []*otlptrace.ScopeSpans { - orig := make([]*otlptrace.ScopeSpans, 5) - orig[0] = NewOrigScopeSpans() - orig[1] = GenTestOrigScopeSpans() - orig[2] = NewOrigScopeSpans() - orig[3] = GenTestOrigScopeSpans() - orig[4] = NewOrigScopeSpans() - return orig -} diff --git a/pdata/internal/generated_wrapper_scopespansslice_test.go b/pdata/internal/generated_wrapper_scopespansslice_test.go deleted file mode 100644 index d4075ca7d5a..00000000000 --- a/pdata/internal/generated_wrapper_scopespansslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func TestCopyOrigScopeSpansSlice(t *testing.T) { - src := []*otlptrace.ScopeSpans{} - dest := []*otlptrace.ScopeSpans{} - // Test CopyTo empty - dest = CopyOrigScopeSpansSlice(dest, src) - assert.Equal(t, []*otlptrace.ScopeSpans{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestScopeSpansSlice() - dest = CopyOrigScopeSpansSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeSpansSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigScopeSpansSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeSpansSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigScopeSpansSlice(dest, []*otlptrace.ScopeSpans{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigScopeSpansSlice(dest, src) - assert.Equal(t, GenerateOrigTestScopeSpansSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_span_eventslice.go b/pdata/internal/generated_wrapper_span_eventslice.go deleted file mode 100644 index b9bd2e44509..00000000000 --- a/pdata/internal/generated_wrapper_span_eventslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func CopyOrigSpan_EventSlice(dest, src []*otlptrace.Span_Event) []*otlptrace.Span_Event { - var newDest []*otlptrace.Span_Event - if cap(dest) < len(src) { - newDest = make([]*otlptrace.Span_Event, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSpan_Event() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigSpan_Event(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSpan_Event() - } - } - for i := range src { - CopyOrigSpan_Event(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestSpan_EventSlice() []*otlptrace.Span_Event { - orig := make([]*otlptrace.Span_Event, 5) - orig[0] = NewOrigSpan_Event() - orig[1] = GenTestOrigSpan_Event() - orig[2] = NewOrigSpan_Event() - orig[3] = GenTestOrigSpan_Event() - orig[4] = NewOrigSpan_Event() - return orig -} diff --git a/pdata/internal/generated_wrapper_span_eventslice_test.go b/pdata/internal/generated_wrapper_span_eventslice_test.go deleted file mode 100644 index 2af8b0d26d4..00000000000 --- a/pdata/internal/generated_wrapper_span_eventslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func TestCopyOrigSpan_EventSlice(t *testing.T) { - src := []*otlptrace.Span_Event{} - dest := []*otlptrace.Span_Event{} - // Test CopyTo empty - dest = CopyOrigSpan_EventSlice(dest, src) - assert.Equal(t, []*otlptrace.Span_Event{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestSpan_EventSlice() - dest = CopyOrigSpan_EventSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpan_EventSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigSpan_EventSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpan_EventSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigSpan_EventSlice(dest, []*otlptrace.Span_Event{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigSpan_EventSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpan_EventSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_span_linkslice.go b/pdata/internal/generated_wrapper_span_linkslice.go deleted file mode 100644 index 55aed82146d..00000000000 --- a/pdata/internal/generated_wrapper_span_linkslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func CopyOrigSpan_LinkSlice(dest, src []*otlptrace.Span_Link) []*otlptrace.Span_Link { - var newDest []*otlptrace.Span_Link - if cap(dest) < len(src) { - newDest = make([]*otlptrace.Span_Link, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSpan_Link() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigSpan_Link(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSpan_Link() - } - } - for i := range src { - CopyOrigSpan_Link(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestSpan_LinkSlice() []*otlptrace.Span_Link { - orig := make([]*otlptrace.Span_Link, 5) - orig[0] = NewOrigSpan_Link() - orig[1] = GenTestOrigSpan_Link() - orig[2] = NewOrigSpan_Link() - orig[3] = GenTestOrigSpan_Link() - orig[4] = NewOrigSpan_Link() - return orig -} diff --git a/pdata/internal/generated_wrapper_span_linkslice_test.go b/pdata/internal/generated_wrapper_span_linkslice_test.go deleted file mode 100644 index 2f0befbff8d..00000000000 --- a/pdata/internal/generated_wrapper_span_linkslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func TestCopyOrigSpan_LinkSlice(t *testing.T) { - src := []*otlptrace.Span_Link{} - dest := []*otlptrace.Span_Link{} - // Test CopyTo empty - dest = CopyOrigSpan_LinkSlice(dest, src) - assert.Equal(t, []*otlptrace.Span_Link{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestSpan_LinkSlice() - dest = CopyOrigSpan_LinkSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpan_LinkSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigSpan_LinkSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpan_LinkSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigSpan_LinkSlice(dest, []*otlptrace.Span_Link{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigSpan_LinkSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpan_LinkSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_spanslice.go b/pdata/internal/generated_wrapper_spanslice.go deleted file mode 100644 index 7dcbb05f463..00000000000 --- a/pdata/internal/generated_wrapper_spanslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func CopyOrigSpanSlice(dest, src []*otlptrace.Span) []*otlptrace.Span { - var newDest []*otlptrace.Span - if cap(dest) < len(src) { - newDest = make([]*otlptrace.Span, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSpan() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigSpan(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSpan() - } - } - for i := range src { - CopyOrigSpan(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestSpanSlice() []*otlptrace.Span { - orig := make([]*otlptrace.Span, 5) - orig[0] = NewOrigSpan() - orig[1] = GenTestOrigSpan() - orig[2] = NewOrigSpan() - orig[3] = GenTestOrigSpan() - orig[4] = NewOrigSpan() - return orig -} diff --git a/pdata/internal/generated_wrapper_spanslice_test.go b/pdata/internal/generated_wrapper_spanslice_test.go deleted file mode 100644 index f551694fcc3..00000000000 --- a/pdata/internal/generated_wrapper_spanslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -func TestCopyOrigSpanSlice(t *testing.T) { - src := []*otlptrace.Span{} - dest := []*otlptrace.Span{} - // Test CopyTo empty - dest = CopyOrigSpanSlice(dest, src) - assert.Equal(t, []*otlptrace.Span{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestSpanSlice() - dest = CopyOrigSpanSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpanSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigSpanSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpanSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigSpanSlice(dest, []*otlptrace.Span{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigSpanSlice(dest, src) - assert.Equal(t, GenerateOrigTestSpanSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_stackslice.go b/pdata/internal/generated_wrapper_stackslice.go deleted file mode 100644 index c49f24d3340..00000000000 --- a/pdata/internal/generated_wrapper_stackslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigStackSlice(dest, src []*otlpprofiles.Stack) []*otlpprofiles.Stack { - var newDest []*otlpprofiles.Stack - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.Stack, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigStack() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigStack(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigStack() - } - } - for i := range src { - CopyOrigStack(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestStackSlice() []*otlpprofiles.Stack { - orig := make([]*otlpprofiles.Stack, 5) - orig[0] = NewOrigStack() - orig[1] = GenTestOrigStack() - orig[2] = NewOrigStack() - orig[3] = GenTestOrigStack() - orig[4] = NewOrigStack() - return orig -} diff --git a/pdata/internal/generated_wrapper_stackslice_test.go b/pdata/internal/generated_wrapper_stackslice_test.go deleted file mode 100644 index 2a60774787f..00000000000 --- a/pdata/internal/generated_wrapper_stackslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigStackSlice(t *testing.T) { - src := []*otlpprofiles.Stack{} - dest := []*otlpprofiles.Stack{} - // Test CopyTo empty - dest = CopyOrigStackSlice(dest, src) - assert.Equal(t, []*otlpprofiles.Stack{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestStackSlice() - dest = CopyOrigStackSlice(dest, src) - assert.Equal(t, GenerateOrigTestStackSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigStackSlice(dest, src) - assert.Equal(t, GenerateOrigTestStackSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigStackSlice(dest, []*otlpprofiles.Stack{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigStackSlice(dest, src) - assert.Equal(t, GenerateOrigTestStackSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_status.go b/pdata/internal/generated_wrapper_status.go deleted file mode 100644 index 26d64e86317..00000000000 --- a/pdata/internal/generated_wrapper_status.go +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolStatus = sync.Pool{ - New: func() any { - return &otlptrace.Status{} - }, - } -) - -func NewOrigStatus() *otlptrace.Status { - if !UseProtoPooling.IsEnabled() { - return &otlptrace.Status{} - } - return protoPoolStatus.Get().(*otlptrace.Status) -} - -func DeleteOrigStatus(orig *otlptrace.Status, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolStatus.Put(orig) - } -} - -func CopyOrigStatus(dest, src *otlptrace.Status) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Message = src.Message - dest.Code = src.Code -} - -func GenTestOrigStatus() *otlptrace.Status { - orig := NewOrigStatus() - orig.Message = "test_message" - orig.Code = otlptrace.Status_StatusCode(1) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigStatus(orig *otlptrace.Status, dest *json.Stream) { - dest.WriteObjectStart() - if orig.Message != "" { - dest.WriteObjectField("message") - dest.WriteString(orig.Message) - } - - if int32(orig.Code) != 0 { - dest.WriteObjectField("code") - dest.WriteInt32(int32(orig.Code)) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigStatus unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigStatus(orig *otlptrace.Status, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "message": - orig.Message = iter.ReadString() - case "code": - orig.Code = otlptrace.Status_StatusCode(iter.ReadEnumValue(otlptrace.Status_StatusCode_value)) - default: - iter.Skip() - } - } -} - -func SizeProtoOrigStatus(orig *otlptrace.Status) 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 { - n += 1 + proto.Sov(uint64(orig.Code)) - } - return n -} - -func MarshalProtoOrigStatus(orig *otlptrace.Status, buf []byte) int { - pos := len(buf) - var l int - _ = l - l = len(orig.Message) - if l > 0 { - pos -= l - copy(buf[pos:], orig.Message) - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0x12 - } - if orig.Code != 0 { - pos = proto.EncodeVarint(buf, pos, uint64(orig.Code)) - pos-- - buf[pos] = 0x18 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigStatus(orig *otlptrace.Status, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 2: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.Message = string(buf[startPos:pos]) - - case 3: - if wireType != proto.WireTypeVarint { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeVarint(buf, pos) - if err != nil { - return err - } - - orig.Code = otlptrace.Status_StatusCode(num) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_stringslice.go b/pdata/internal/generated_wrapper_stringslice.go index 3ed5c18ccba..d922f65d80c 100644 --- a/pdata/internal/generated_wrapper_stringslice.go +++ b/pdata/internal/generated_wrapper_stringslice.go @@ -6,32 +6,28 @@ package internal -type StringSlice struct { +type StringSliceWrapper struct { orig *[]string state *State } -func GetOrigStringSlice(ms StringSlice) *[]string { +func GetStringSliceOrig(ms StringSliceWrapper) *[]string { return ms.orig } -func GetStringSliceState(ms StringSlice) *State { +func GetStringSliceState(ms StringSliceWrapper) *State { return ms.state } -func NewStringSlice(orig *[]string, state *State) StringSlice { - return StringSlice{orig: orig, state: state} +func NewStringSliceWrapper(orig *[]string, state *State) StringSliceWrapper { + return StringSliceWrapper{orig: orig, state: state} } -func GenerateTestStringSlice() StringSlice { - orig := GenerateOrigTestStringSlice() - return NewStringSlice(&orig, NewState()) +func GenTestStringSliceWrapper() StringSliceWrapper { + orig := []string{"a", "b", "c"} + return NewStringSliceWrapper(&orig, NewState()) } -func CopyOrigStringSlice(dst, src []string) []string { - return append(dst[:0], src...) -} - -func GenerateOrigTestStringSlice() []string { +func GenTestStringSlice() []string { return []string{"a", "b", "c"} } diff --git a/pdata/internal/generated_wrapper_stringslice_test.go b/pdata/internal/generated_wrapper_stringslice_test.go deleted file mode 100644 index a71902a4495..00000000000 --- a/pdata/internal/generated_wrapper_stringslice_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCopyOrigStringSlice(t *testing.T) { - src := []string{} - dest := []string{} - // Copy empty - dest = CopyOrigStringSlice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTestStringSlice() - dest = CopyOrigStringSlice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/generated_wrapper_summary.go b/pdata/internal/generated_wrapper_summary.go deleted file mode 100644 index 215d60ab4ae..00000000000 --- a/pdata/internal/generated_wrapper_summary.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "fmt" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolSummary = sync.Pool{ - New: func() any { - return &otlpmetrics.Summary{} - }, - } -) - -func NewOrigSummary() *otlpmetrics.Summary { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.Summary{} - } - return protoPoolSummary.Get().(*otlpmetrics.Summary) -} - -func DeleteOrigSummary(orig *otlpmetrics.Summary, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - for i := range orig.DataPoints { - DeleteOrigSummaryDataPoint(orig.DataPoints[i], true) - } - - orig.Reset() - if nullable { - protoPoolSummary.Put(orig) - } -} - -func CopyOrigSummary(dest, src *otlpmetrics.Summary) { - // If copying to same object, just return. - if src == dest { - return - } - dest.DataPoints = CopyOrigSummaryDataPointSlice(dest.DataPoints, src.DataPoints) -} - -func GenTestOrigSummary() *otlpmetrics.Summary { - orig := NewOrigSummary() - orig.DataPoints = GenerateOrigTestSummaryDataPointSlice() - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSummary(orig *otlpmetrics.Summary, dest *json.Stream) { - dest.WriteObjectStart() - if len(orig.DataPoints) > 0 { - dest.WriteObjectField("dataPoints") - dest.WriteArrayStart() - MarshalJSONOrigSummaryDataPoint(orig.DataPoints[0], dest) - for i := 1; i < len(orig.DataPoints); i++ { - dest.WriteMore() - MarshalJSONOrigSummaryDataPoint(orig.DataPoints[i], dest) - } - dest.WriteArrayEnd() - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigSummary unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSummary(orig *otlpmetrics.Summary, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "dataPoints", "data_points": - for iter.ReadArray() { - orig.DataPoints = append(orig.DataPoints, NewOrigSummaryDataPoint()) - UnmarshalJSONOrigSummaryDataPoint(orig.DataPoints[len(orig.DataPoints)-1], iter) - } - - default: - iter.Skip() - } - } -} - -func SizeProtoOrigSummary(orig *otlpmetrics.Summary) int { - var n int - var l int - _ = l - for i := range orig.DataPoints { - l = SizeProtoOrigSummaryDataPoint(orig.DataPoints[i]) - n += 1 + proto.Sov(uint64(l)) + l - } - return n -} - -func MarshalProtoOrigSummary(orig *otlpmetrics.Summary, buf []byte) int { - pos := len(buf) - var l int - _ = l - for i := len(orig.DataPoints) - 1; i >= 0; i-- { - l = MarshalProtoOrigSummaryDataPoint(orig.DataPoints[i], buf[:pos]) - pos -= l - pos = proto.EncodeVarint(buf, pos, uint64(l)) - pos-- - buf[pos] = 0xa - } - return len(buf) - pos -} - -func UnmarshalProtoOrigSummary(orig *otlpmetrics.Summary, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeLen { - return fmt.Errorf("proto: wrong wireType = %d for field DataPoints", wireType) - } - var length int - length, pos, err = proto.ConsumeLen(buf, pos) - if err != nil { - return err - } - startPos := pos - length - orig.DataPoints = append(orig.DataPoints, NewOrigSummaryDataPoint()) - err = UnmarshalProtoOrigSummaryDataPoint(orig.DataPoints[len(orig.DataPoints)-1], buf[startPos:pos]) - if err != nil { - return err - } - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantile.go b/pdata/internal/generated_wrapper_summarydatapoint_valueatquantile.go deleted file mode 100644 index 3195880d952..00000000000 --- a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantile.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "encoding/binary" - "fmt" - "math" - "sync" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" - "go.opentelemetry.io/collector/pdata/internal/proto" -) - -var ( - protoPoolSummaryDataPoint_ValueAtQuantile = sync.Pool{ - New: func() any { - return &otlpmetrics.SummaryDataPoint_ValueAtQuantile{} - }, - } -) - -func NewOrigSummaryDataPoint_ValueAtQuantile() *otlpmetrics.SummaryDataPoint_ValueAtQuantile { - if !UseProtoPooling.IsEnabled() { - return &otlpmetrics.SummaryDataPoint_ValueAtQuantile{} - } - return protoPoolSummaryDataPoint_ValueAtQuantile.Get().(*otlpmetrics.SummaryDataPoint_ValueAtQuantile) -} - -func DeleteOrigSummaryDataPoint_ValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile, nullable bool) { - if orig == nil { - return - } - - if !UseProtoPooling.IsEnabled() { - orig.Reset() - return - } - - orig.Reset() - if nullable { - protoPoolSummaryDataPoint_ValueAtQuantile.Put(orig) - } -} - -func CopyOrigSummaryDataPoint_ValueAtQuantile(dest, src *otlpmetrics.SummaryDataPoint_ValueAtQuantile) { - // If copying to same object, just return. - if src == dest { - return - } - dest.Quantile = src.Quantile - dest.Value = src.Value -} - -func GenTestOrigSummaryDataPoint_ValueAtQuantile() *otlpmetrics.SummaryDataPoint_ValueAtQuantile { - orig := NewOrigSummaryDataPoint_ValueAtQuantile() - orig.Quantile = float64(3.1415926) - orig.Value = float64(3.1415926) - return orig -} - -// MarshalJSONOrig marshals all properties from the current struct to the destination stream. -func MarshalJSONOrigSummaryDataPoint_ValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile, dest *json.Stream) { - dest.WriteObjectStart() - if orig.Quantile != float64(0) { - dest.WriteObjectField("quantile") - dest.WriteFloat64(orig.Quantile) - } - if orig.Value != float64(0) { - dest.WriteObjectField("value") - dest.WriteFloat64(orig.Value) - } - dest.WriteObjectEnd() -} - -// UnmarshalJSONOrigSummaryDataPointValueAtQuantile unmarshals all properties from the current struct from the source iterator. -func UnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile, iter *json.Iterator) { - for f := iter.ReadObject(); f != ""; f = iter.ReadObject() { - switch f { - case "quantile": - orig.Quantile = iter.ReadFloat64() - case "value": - orig.Value = iter.ReadFloat64() - default: - iter.Skip() - } - } -} - -func SizeProtoOrigSummaryDataPoint_ValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile) int { - var n int - var l int - _ = l - if orig.Quantile != 0 { - n += 9 - } - if orig.Value != 0 { - n += 9 - } - return n -} - -func MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile, buf []byte) int { - pos := len(buf) - var l int - _ = l - if orig.Quantile != 0 { - pos -= 8 - binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Quantile)) - pos-- - buf[pos] = 0x9 - } - if orig.Value != 0 { - pos -= 8 - binary.LittleEndian.PutUint64(buf[pos:], math.Float64bits(orig.Value)) - pos-- - buf[pos] = 0x11 - } - return len(buf) - pos -} - -func UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile, buf []byte) error { - var err error - var fieldNum int32 - var wireType proto.WireType - - l := len(buf) - pos := 0 - for pos < l { - // If in a group parsing, move to the next tag. - fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos) - if err != nil { - return err - } - switch fieldNum { - - case 1: - if wireType != proto.WireTypeI64 { - return fmt.Errorf("proto: wrong wireType = %d for field Quantile", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeI64(buf, pos) - if err != nil { - return err - } - - orig.Quantile = math.Float64frombits(num) - - case 2: - if wireType != proto.WireTypeI64 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var num uint64 - num, pos, err = proto.ConsumeI64(buf, pos) - if err != nil { - return err - } - - orig.Value = math.Float64frombits(num) - default: - pos, err = proto.ConsumeUnknown(buf, pos, wireType) - if err != nil { - return err - } - } - } - return nil -} diff --git a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantile_test.go b/pdata/internal/generated_wrapper_summarydatapoint_valueatquantile_test.go deleted file mode 100644 index c447c255322..00000000000 --- a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantile_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - gootlpmetrics "go.opentelemetry.io/proto/slim/otlp/metrics/v1" - "google.golang.org/protobuf/proto" - - "go.opentelemetry.io/collector/featuregate" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func TestCopyOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) { - for name, src := range genTestEncodingValuesSummaryDataPoint_ValueAtQuantile() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - CopyOrigSummaryDataPoint_ValueAtQuantile(dest, src) - assert.Equal(t, src, dest) - CopyOrigSummaryDataPoint_ValueAtQuantile(dest, dest) - assert.Equal(t, src, dest) - }) - } - } -} - -func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint_ValueAtQuantileUnknown(t *testing.T) { - iter := json.BorrowIterator([]byte(`{"unknown": "string"}`)) - defer json.ReturnIterator(iter) - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - UnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(dest, iter) - require.NoError(t, iter.Error()) - assert.Equal(t, NewOrigSummaryDataPoint_ValueAtQuantile(), dest) -} - -func TestMarshalAndUnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) { - for name, src := range genTestEncodingValuesSummaryDataPoint_ValueAtQuantile() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - stream := json.BorrowStream(nil) - defer json.ReturnStream(stream) - MarshalJSONOrigSummaryDataPoint_ValueAtQuantile(src, stream) - require.NoError(t, stream.Error()) - - iter := json.BorrowIterator(stream.Buffer()) - defer json.ReturnIterator(iter) - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - UnmarshalJSONOrigSummaryDataPoint_ValueAtQuantile(dest, iter) - require.NoError(t, iter.Error()) - - assert.Equal(t, src, dest) - DeleteOrigSummaryDataPoint_ValueAtQuantile(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint_ValueAtQuantileFailing(t *testing.T) { - for name, buf := range genTestFailingUnmarshalProtoValuesSummaryDataPoint_ValueAtQuantile() { - t.Run(name, func(t *testing.T) { - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - require.Error(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, buf)) - }) - } -} - -func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint_ValueAtQuantileUnknown(t *testing.T) { - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - // message Test { required int64 field = 1313; } encoding { "field": "1234" } - require.NoError(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, []byte{0x88, 0x52, 0xD2, 0x09})) - assert.Equal(t, NewOrigSummaryDataPoint_ValueAtQuantile(), dest) -} - -func TestMarshalAndUnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(t *testing.T) { - for name, src := range genTestEncodingValuesSummaryDataPoint_ValueAtQuantile() { - for _, pooling := range []bool{true, false} { - t.Run(name+"/Pooling="+strconv.FormatBool(pooling), func(t *testing.T) { - prevPooling := UseProtoPooling.IsEnabled() - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), pooling)) - defer func() { - require.NoError(t, featuregate.GlobalRegistry().Set(UseProtoPooling.ID(), prevPooling)) - }() - - buf := make([]byte, SizeProtoOrigSummaryDataPoint_ValueAtQuantile(src)) - gotSize := MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(src, buf) - assert.Equal(t, len(buf), gotSize) - - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - require.NoError(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, buf)) - - assert.Equal(t, src, dest) - DeleteOrigSummaryDataPoint_ValueAtQuantile(dest, true) - }) - } - } -} - -func TestMarshalAndUnmarshalProtoViaProtobufSummaryDataPoint_ValueAtQuantile(t *testing.T) { - for name, src := range genTestEncodingValuesSummaryDataPoint_ValueAtQuantile() { - t.Run(name, func(t *testing.T) { - buf := make([]byte, SizeProtoOrigSummaryDataPoint_ValueAtQuantile(src)) - gotSize := MarshalProtoOrigSummaryDataPoint_ValueAtQuantile(src, buf) - assert.Equal(t, len(buf), gotSize) - - goDest := &gootlpmetrics.SummaryDataPoint_ValueAtQuantile{} - require.NoError(t, proto.Unmarshal(buf, goDest)) - - goBuf, err := proto.Marshal(goDest) - require.NoError(t, err) - - dest := NewOrigSummaryDataPoint_ValueAtQuantile() - require.NoError(t, UnmarshalProtoOrigSummaryDataPoint_ValueAtQuantile(dest, goBuf)) - assert.Equal(t, src, dest) - }) - } -} - -func genTestFailingUnmarshalProtoValuesSummaryDataPoint_ValueAtQuantile() map[string][]byte { - return map[string][]byte{ - "invalid_field": {0x02}, - "Quantile/wrong_wire_type": {0xc}, - "Quantile/missing_value": {0x9}, - "Value/wrong_wire_type": {0x14}, - "Value/missing_value": {0x11}, - } -} - -func genTestEncodingValuesSummaryDataPoint_ValueAtQuantile() map[string]*otlpmetrics.SummaryDataPoint_ValueAtQuantile { - return map[string]*otlpmetrics.SummaryDataPoint_ValueAtQuantile{ - "empty": NewOrigSummaryDataPoint_ValueAtQuantile(), - "Quantile/test": {Quantile: float64(3.1415926)}, - "Value/test": {Value: float64(3.1415926)}, - } -} diff --git a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantileslice.go b/pdata/internal/generated_wrapper_summarydatapoint_valueatquantileslice.go deleted file mode 100644 index e8341dee47c..00000000000 --- a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantileslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest, src []*otlpmetrics.SummaryDataPoint_ValueAtQuantile) []*otlpmetrics.SummaryDataPoint_ValueAtQuantile { - var newDest []*otlpmetrics.SummaryDataPoint_ValueAtQuantile - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.SummaryDataPoint_ValueAtQuantile, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSummaryDataPoint_ValueAtQuantile() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigSummaryDataPoint_ValueAtQuantile(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSummaryDataPoint_ValueAtQuantile() - } - } - for i := range src { - CopyOrigSummaryDataPoint_ValueAtQuantile(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice() []*otlpmetrics.SummaryDataPoint_ValueAtQuantile { - orig := make([]*otlpmetrics.SummaryDataPoint_ValueAtQuantile, 5) - orig[0] = NewOrigSummaryDataPoint_ValueAtQuantile() - orig[1] = GenTestOrigSummaryDataPoint_ValueAtQuantile() - orig[2] = NewOrigSummaryDataPoint_ValueAtQuantile() - orig[3] = GenTestOrigSummaryDataPoint_ValueAtQuantile() - orig[4] = NewOrigSummaryDataPoint_ValueAtQuantile() - return orig -} diff --git a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantileslice_test.go b/pdata/internal/generated_wrapper_summarydatapoint_valueatquantileslice_test.go deleted file mode 100644 index 2d4756b189f..00000000000 --- a/pdata/internal/generated_wrapper_summarydatapoint_valueatquantileslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigSummaryDataPoint_ValueAtQuantileSlice(t *testing.T) { - src := []*otlpmetrics.SummaryDataPoint_ValueAtQuantile{} - dest := []*otlpmetrics.SummaryDataPoint_ValueAtQuantile{} - // Test CopyTo empty - dest = CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest, src) - assert.Equal(t, []*otlpmetrics.SummaryDataPoint_ValueAtQuantile{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice() - dest = CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest, src) - assert.Equal(t, GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest, src) - assert.Equal(t, GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest, []*otlpmetrics.SummaryDataPoint_ValueAtQuantile{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigSummaryDataPoint_ValueAtQuantileSlice(dest, src) - assert.Equal(t, GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_summarydatapointslice.go b/pdata/internal/generated_wrapper_summarydatapointslice.go deleted file mode 100644 index 2da01f377aa..00000000000 --- a/pdata/internal/generated_wrapper_summarydatapointslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func CopyOrigSummaryDataPointSlice(dest, src []*otlpmetrics.SummaryDataPoint) []*otlpmetrics.SummaryDataPoint { - var newDest []*otlpmetrics.SummaryDataPoint - if cap(dest) < len(src) { - newDest = make([]*otlpmetrics.SummaryDataPoint, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSummaryDataPoint() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigSummaryDataPoint(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigSummaryDataPoint() - } - } - for i := range src { - CopyOrigSummaryDataPoint(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestSummaryDataPointSlice() []*otlpmetrics.SummaryDataPoint { - orig := make([]*otlpmetrics.SummaryDataPoint, 5) - orig[0] = NewOrigSummaryDataPoint() - orig[1] = GenTestOrigSummaryDataPoint() - orig[2] = NewOrigSummaryDataPoint() - orig[3] = GenTestOrigSummaryDataPoint() - orig[4] = NewOrigSummaryDataPoint() - return orig -} diff --git a/pdata/internal/generated_wrapper_summarydatapointslice_test.go b/pdata/internal/generated_wrapper_summarydatapointslice_test.go deleted file mode 100644 index 7c2898219a1..00000000000 --- a/pdata/internal/generated_wrapper_summarydatapointslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - -func TestCopyOrigSummaryDataPointSlice(t *testing.T) { - src := []*otlpmetrics.SummaryDataPoint{} - dest := []*otlpmetrics.SummaryDataPoint{} - // Test CopyTo empty - dest = CopyOrigSummaryDataPointSlice(dest, src) - assert.Equal(t, []*otlpmetrics.SummaryDataPoint{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestSummaryDataPointSlice() - dest = CopyOrigSummaryDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestSummaryDataPointSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigSummaryDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestSummaryDataPointSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigSummaryDataPointSlice(dest, []*otlpmetrics.SummaryDataPoint{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigSummaryDataPointSlice(dest, src) - assert.Equal(t, GenerateOrigTestSummaryDataPointSlice(), dest) -} diff --git a/pdata/internal/generated_wrapper_uint64slice.go b/pdata/internal/generated_wrapper_uint64slice.go index 954987d85e3..c20fd9d0e15 100644 --- a/pdata/internal/generated_wrapper_uint64slice.go +++ b/pdata/internal/generated_wrapper_uint64slice.go @@ -6,32 +6,28 @@ package internal -type UInt64Slice struct { +type UInt64SliceWrapper struct { orig *[]uint64 state *State } -func GetOrigUInt64Slice(ms UInt64Slice) *[]uint64 { +func GetUInt64SliceOrig(ms UInt64SliceWrapper) *[]uint64 { return ms.orig } -func GetUInt64SliceState(ms UInt64Slice) *State { +func GetUInt64SliceState(ms UInt64SliceWrapper) *State { return ms.state } -func NewUInt64Slice(orig *[]uint64, state *State) UInt64Slice { - return UInt64Slice{orig: orig, state: state} +func NewUInt64SliceWrapper(orig *[]uint64, state *State) UInt64SliceWrapper { + return UInt64SliceWrapper{orig: orig, state: state} } -func GenerateTestUInt64Slice() UInt64Slice { - orig := GenerateOrigTestUint64Slice() - return NewUInt64Slice(&orig, NewState()) +func GenTestUInt64SliceWrapper() UInt64SliceWrapper { + orig := []uint64{1, 2, 3} + return NewUInt64SliceWrapper(&orig, NewState()) } -func CopyOrigUint64Slice(dst, src []uint64) []uint64 { - return append(dst[:0], src...) -} - -func GenerateOrigTestUint64Slice() []uint64 { +func GenTestUint64Slice() []uint64 { return []uint64{1, 2, 3} } diff --git a/pdata/internal/generated_wrapper_uint64slice_test.go b/pdata/internal/generated_wrapper_uint64slice_test.go deleted file mode 100644 index f3a722e1ba2..00000000000 --- a/pdata/internal/generated_wrapper_uint64slice_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCopyOrigUint64Slice(t *testing.T) { - src := []uint64{} - dest := []uint64{} - // Copy empty - dest = CopyOrigUint64Slice(dest, src) - assert.Equal(t, src, dest) - src = GenerateOrigTestUint64Slice() - dest = CopyOrigUint64Slice(dest, src) - assert.Equal(t, src, dest) -} diff --git a/pdata/internal/generated_wrapper_valuetypeslice.go b/pdata/internal/generated_wrapper_valuetypeslice.go deleted file mode 100644 index 6b1973a7183..00000000000 --- a/pdata/internal/generated_wrapper_valuetypeslice.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func CopyOrigValueTypeSlice(dest, src []*otlpprofiles.ValueType) []*otlpprofiles.ValueType { - var newDest []*otlpprofiles.ValueType - if cap(dest) < len(src) { - newDest = make([]*otlpprofiles.ValueType, len(src)) - // Copy old pointers to re-use. - copy(newDest, dest) - // Add new pointers for missing elements from len(dest) to len(srt). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigValueType() - } - } else { - newDest = dest[:len(src)] - // Cleanup the rest of the elements so GC can free the memory. - // This can happen when len(src) < len(dest) < cap(dest). - for i := len(src); i < len(dest); i++ { - DeleteOrigValueType(dest[i], true) - dest[i] = nil - } - // Add new pointers for missing elements. - // This can happen when len(dest) < len(src) < cap(dest). - for i := len(dest); i < len(src); i++ { - newDest[i] = NewOrigValueType() - } - } - for i := range src { - CopyOrigValueType(newDest[i], src[i]) - } - return newDest -} - -func GenerateOrigTestValueTypeSlice() []*otlpprofiles.ValueType { - orig := make([]*otlpprofiles.ValueType, 5) - orig[0] = NewOrigValueType() - orig[1] = GenTestOrigValueType() - orig[2] = NewOrigValueType() - orig[3] = GenTestOrigValueType() - orig[4] = NewOrigValueType() - return orig -} diff --git a/pdata/internal/generated_wrapper_valuetypeslice_test.go b/pdata/internal/generated_wrapper_valuetypeslice_test.go deleted file mode 100644 index 292954a35c9..00000000000 --- a/pdata/internal/generated_wrapper_valuetypeslice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. -// To regenerate this file run "make genpdata". - -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - -func TestCopyOrigValueTypeSlice(t *testing.T) { - src := []*otlpprofiles.ValueType{} - dest := []*otlpprofiles.ValueType{} - // Test CopyTo empty - dest = CopyOrigValueTypeSlice(dest, src) - assert.Equal(t, []*otlpprofiles.ValueType{}, dest) - - // Test CopyTo larger slice - src = GenerateOrigTestValueTypeSlice() - dest = CopyOrigValueTypeSlice(dest, src) - assert.Equal(t, GenerateOrigTestValueTypeSlice(), dest) - - // Test CopyTo same size slice - dest = CopyOrigValueTypeSlice(dest, src) - assert.Equal(t, GenerateOrigTestValueTypeSlice(), dest) - - // Test CopyTo smaller size slice - dest = CopyOrigValueTypeSlice(dest, []*otlpprofiles.ValueType{}) - assert.Len(t, dest, 0) - - // Test CopyTo larger slice with enough capacity - dest = CopyOrigValueTypeSlice(dest, src) - assert.Equal(t, GenerateOrigTestValueTypeSlice(), dest) -} diff --git a/pdata/internal/grpcencoding/encoding.go b/pdata/internal/grpcencoding/encoding.go deleted file mode 100644 index f2df60ab2c0..00000000000 --- a/pdata/internal/grpcencoding/encoding.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package grpcencoding // import "go.opentelemetry.io/collector/pdata/internal/grpcencoding" - -import ( - "google.golang.org/grpc/encoding" - "google.golang.org/grpc/mem" - - "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - otlpcollectorprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - otlpcollectortraces "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" -) - -var ( - defaultBufferPoolSizes = []int{ - 256, - 4 << 10, // 4KB (go page size) - 16 << 10, // 16KB (max HTTP/2 frame size used by gRPC) - 32 << 10, // 32KB (default buffer size for io.Copy) - 512 << 10, // 512KB - 1 << 20, // 1MB - 4 << 20, // 4MB - 16 << 20, // 16MB - } - otelBufferPool = mem.NewTieredBufferPool(defaultBufferPoolSizes...) -) - -// DefaultBufferPool returns the current default buffer pool. It is a BufferPool -// created with mem.NewTieredBufferPool that uses a set of default sizes optimized for -// expected telemetry workflows. -func DefaultBufferPool() mem.BufferPool { - return otelBufferPool -} - -// Name is the name registered for the proto compressor. -const Name = "proto" - -func init() { - encoding.RegisterCodecV2(&codecV2{delegate: encoding.GetCodecV2(Name)}) -} - -// codecV2 is a custom proto encoding that uses a different tier schema for the TieredBufferPool as well -// as it call into the custom marshal/unmarshal logic that works with memory pooling. -// If not an otlp payload fallback on the default grpc/proto encoding. -type codecV2 struct { - delegate encoding.CodecV2 -} - -func (c *codecV2) Marshal(v any) (mem.BufferSlice, error) { - switch req := v.(type) { - case *otlpcollectorlogs.ExportLogsServiceRequest: - size := internal.SizeProtoOrigExportLogsServiceRequest(req) - buf := otelBufferPool.Get(size) - n := internal.MarshalProtoOrigExportLogsServiceRequest(req, (*buf)[:size]) - *buf = (*buf)[:n] - return []mem.Buffer{mem.NewBuffer(buf, otelBufferPool)}, nil - case *otlpcollectormetrics.ExportMetricsServiceRequest: - size := internal.SizeProtoOrigExportMetricsServiceRequest(req) - buf := otelBufferPool.Get(size) - n := internal.MarshalProtoOrigExportMetricsServiceRequest(req, (*buf)[:size]) - *buf = (*buf)[:n] - return []mem.Buffer{mem.NewBuffer(buf, otelBufferPool)}, nil - case *otlpcollectortraces.ExportTraceServiceRequest: - size := internal.SizeProtoOrigExportTraceServiceRequest(req) - buf := otelBufferPool.Get(size) - n := internal.MarshalProtoOrigExportTraceServiceRequest(req, (*buf)[:size]) - *buf = (*buf)[:n] - return []mem.Buffer{mem.NewBuffer(buf, otelBufferPool)}, nil - case *otlpcollectorprofile.ExportProfilesServiceRequest: - size := internal.SizeProtoOrigExportProfilesServiceRequest(req) - buf := otelBufferPool.Get(size) - n := internal.MarshalProtoOrigExportProfilesServiceRequest(req, (*buf)[:size]) - *buf = (*buf)[:n] - return []mem.Buffer{mem.NewBuffer(buf, otelBufferPool)}, nil - } - - return c.delegate.Marshal(v) -} - -func (c *codecV2) Unmarshal(data mem.BufferSlice, v any) (err error) { - switch req := v.(type) { - case *otlpcollectorlogs.ExportLogsServiceRequest: - // TODO: Upgrade custom Unmarshal logic to support reading from mem.BufferSlice. - buf := data.MaterializeToBuffer(otelBufferPool) - defer buf.Free() - return internal.UnmarshalProtoOrigExportLogsServiceRequest(req, buf.ReadOnlyData()) - case *otlpcollectormetrics.ExportMetricsServiceRequest: - // TODO: Upgrade custom Unmarshal logic to support reading from mem.BufferSlice. - buf := data.MaterializeToBuffer(otelBufferPool) - defer buf.Free() - return internal.UnmarshalProtoOrigExportMetricsServiceRequest(req, buf.ReadOnlyData()) - case *otlpcollectortraces.ExportTraceServiceRequest: - // TODO: Upgrade custom Unmarshal logic to support reading from mem.BufferSlice. - buf := data.MaterializeToBuffer(otelBufferPool) - defer buf.Free() - return internal.UnmarshalProtoOrigExportTraceServiceRequest(req, buf.ReadOnlyData()) - case *otlpcollectorprofile.ExportProfilesServiceRequest: - // TODO: Upgrade custom Unmarshal logic to support reading from mem.BufferSlice. - buf := data.MaterializeToBuffer(otelBufferPool) - defer buf.Free() - return internal.UnmarshalProtoOrigExportProfilesServiceRequest(req, buf.ReadOnlyData()) - } - - return c.delegate.Unmarshal(data, v) -} - -func (c *codecV2) Name() string { - return Name -} diff --git a/pdata/internal/ids.go b/pdata/internal/ids.go deleted file mode 100644 index 59b9a9456ad..00000000000 --- a/pdata/internal/ids.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal // import "go.opentelemetry.io/collector/pdata/internal" - -import ( - "go.opentelemetry.io/collector/pdata/internal/data" - "go.opentelemetry.io/collector/pdata/internal/json" -) - -func DeleteOrigTraceID(*data.TraceID, bool) {} - -func DeleteOrigSpanID(*data.SpanID, bool) {} - -func DeleteOrigProfileID(*data.ProfileID, bool) {} - -func GenTestOrigTraceID() *data.TraceID { - id := data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}) - return &id -} - -func GenTestOrigSpanID() *data.SpanID { - id := data.SpanID([8]byte{1, 2, 3, 4, 5, 6, 7, 8}) - return &id -} - -func GenTestOrigProfileID() *data.ProfileID { - id := data.ProfileID([16]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) - return &id -} - -func MarshalJSONOrigTraceID(id *data.TraceID, dest *json.Stream) { - id.MarshalJSONStream(dest) -} - -func MarshalJSONOrigSpanID(id *data.SpanID, dest *json.Stream) { - id.MarshalJSONStream(dest) -} - -func MarshalJSONOrigProfileID(id *data.ProfileID, dest *json.Stream) { - id.MarshalJSONStream(dest) -} - -func UnmarshalJSONOrigTraceID(id *data.TraceID, iter *json.Iterator) { - id.UnmarshalJSONIter(iter) -} - -func UnmarshalJSONOrigSpanID(id *data.SpanID, iter *json.Iterator) { - id.UnmarshalJSONIter(iter) -} - -func UnmarshalJSONOrigProfileID(id *data.ProfileID, iter *json.Iterator) { - id.UnmarshalJSONIter(iter) -} - -func SizeProtoOrigTraceID(id *data.TraceID) int { - return id.Size() -} - -func SizeProtoOrigSpanID(id *data.SpanID) int { - return id.Size() -} - -func SizeProtoOrigProfileID(id *data.ProfileID) int { - return id.Size() -} - -func MarshalProtoOrigTraceID(id *data.TraceID, buf []byte) int { - size := id.Size() - _, _ = id.MarshalTo(buf[len(buf)-size:]) - return size -} - -func MarshalProtoOrigSpanID(id *data.SpanID, buf []byte) int { - size := id.Size() - _, _ = id.MarshalTo(buf[len(buf)-size:]) - return size -} - -func MarshalProtoOrigProfileID(id *data.ProfileID, buf []byte) int { - size := id.Size() - _, _ = id.MarshalTo(buf[len(buf)-size:]) - return size -} - -func UnmarshalProtoOrigTraceID(id *data.TraceID, buf []byte) error { - return id.Unmarshal(buf) -} - -func UnmarshalProtoOrigSpanID(id *data.SpanID, buf []byte) error { - return id.Unmarshal(buf) -} - -func UnmarshalProtoOrigProfileID(id *data.ProfileID, buf []byte) error { - return id.Unmarshal(buf) -} diff --git a/pdata/internal/otelgrpc/encoding.go b/pdata/internal/otelgrpc/encoding.go new file mode 100644 index 00000000000..4f3bfdb6ccc --- /dev/null +++ b/pdata/internal/otelgrpc/encoding.go @@ -0,0 +1,77 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package otelgrpc // import "go.opentelemetry.io/collector/pdata/internal/otelgrpc" + +import ( + "google.golang.org/grpc/encoding" + "google.golang.org/grpc/mem" +) + +var ( + defaultBufferPoolSizes = []int{ + 256, + 4 << 10, // 4KB (go page size) + 16 << 10, // 16KB (max HTTP/2 frame size used by gRPC) + 32 << 10, // 32KB (default buffer size for io.Copy) + 512 << 10, // 512KB + 1 << 20, // 1MB + 4 << 20, // 4MB + 16 << 20, // 16MB + } + otelBufferPool = mem.NewTieredBufferPool(defaultBufferPoolSizes...) +) + +// DefaultBufferPool returns the current default buffer pool. It is a BufferPool +// created with mem.NewTieredBufferPool that uses a set of default sizes optimized for +// expected telemetry workflows. +func DefaultBufferPool() mem.BufferPool { + return otelBufferPool +} + +// Name is the name registered for the proto compressor. +const Name = "proto" + +func init() { + encoding.RegisterCodecV2(&codecV2{delegate: encoding.GetCodecV2(Name)}) +} + +// codecV2 is a custom proto encoding that uses a different tier schema for the TieredBufferPool as well +// as it call into the custom marshal/unmarshal logic that works with memory pooling. +// If not an otlp payload fallback on the default grpc/proto encoding. +type codecV2 struct { + delegate encoding.CodecV2 +} + +type otelEncoder interface { + SizeProto() int + MarshalProto([]byte) int + UnmarshalProto([]byte) error +} + +func (c *codecV2) Marshal(v any) (mem.BufferSlice, error) { + if m, ok := v.(otelEncoder); ok { + size := m.SizeProto() + buf := otelBufferPool.Get(size) + n := m.MarshalProto((*buf)[:size]) + *buf = (*buf)[:n] + return []mem.Buffer{mem.NewBuffer(buf, otelBufferPool)}, nil + } + + return c.delegate.Marshal(v) +} + +func (c *codecV2) Unmarshal(data mem.BufferSlice, v any) (err error) { + if m, ok := v.(otelEncoder); ok { + // TODO: Upgrade custom Unmarshal logic to support reading from mem.BufferSlice. + buf := data.MaterializeToBuffer(otelBufferPool) + defer buf.Free() + return m.UnmarshalProto(buf.ReadOnlyData()) + } + + return c.delegate.Unmarshal(data, v) +} + +func (c *codecV2) Name() string { + return Name +} diff --git a/pdata/internal/otelgrpc/logs_service.go b/pdata/internal/otelgrpc/logs_service.go new file mode 100644 index 00000000000..ef26e365485 --- /dev/null +++ b/pdata/internal/otelgrpc/logs_service.go @@ -0,0 +1,88 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package otelgrpc // import "go.opentelemetry.io/collector/pdata/internal/otelgrpc" + +import ( + "context" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "go.opentelemetry.io/collector/pdata/internal" +) + +// LogsServiceClient is the client API for LogsService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type LogsServiceClient interface { + Export(context.Context, *internal.ExportLogsServiceRequest, ...grpc.CallOption) (*internal.ExportLogsServiceResponse, error) +} + +type logsServiceClient struct { + cc *grpc.ClientConn +} + +func NewLogsServiceClient(cc *grpc.ClientConn) LogsServiceClient { + return &logsServiceClient{cc} +} + +func (c *logsServiceClient) Export(ctx context.Context, in *internal.ExportLogsServiceRequest, opts ...grpc.CallOption) (*internal.ExportLogsServiceResponse, error) { + out := new(internal.ExportLogsServiceResponse) + err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.logs.v1.LogsService/Export", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// LogsServiceServer is the server API for LogsService service. +type LogsServiceServer interface { + Export(context.Context, *internal.ExportLogsServiceRequest) (*internal.ExportLogsServiceResponse, error) +} + +// UnimplementedLogsServiceServer can be embedded to have forward compatible implementations. +type UnimplementedLogsServiceServer struct{} + +func (*UnimplementedLogsServiceServer) Export(context.Context, *internal.ExportLogsServiceRequest) (*internal.ExportLogsServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") +} + +func RegisterLogsServiceServer(s *grpc.Server, srv LogsServiceServer) { + s.RegisterService(&logsServiceServiceDesc, srv) +} + +// Context cannot be the first parameter of the function because gRPC definition. +// +//nolint:revive +func logsServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(internal.ExportLogsServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LogsServiceServer).Export(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(LogsServiceServer).Export(ctx, req.(*internal.ExportLogsServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var logsServiceServiceDesc = grpc.ServiceDesc{ + ServiceName: "opentelemetry.proto.collector.logs.v1.LogsService", + HandlerType: (*LogsServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Export", + Handler: logsServiceExportHandler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "opentelemetry/proto/collector/logs/v1/logs_service.proto", +} diff --git a/pdata/internal/otelgrpc/metrics_service.go b/pdata/internal/otelgrpc/metrics_service.go new file mode 100644 index 00000000000..daf4f5cc8a9 --- /dev/null +++ b/pdata/internal/otelgrpc/metrics_service.go @@ -0,0 +1,88 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package otelgrpc // import "go.opentelemetry.io/collector/pdata/internal/otelgrpc" + +import ( + "context" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "go.opentelemetry.io/collector/pdata/internal" +) + +// MetricsServiceClient is the client API for MetricsService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MetricsServiceClient interface { + Export(context.Context, *internal.ExportMetricsServiceRequest, ...grpc.CallOption) (*internal.ExportMetricsServiceResponse, error) +} + +type metricsServiceClient struct { + cc *grpc.ClientConn +} + +func NewMetricsServiceClient(cc *grpc.ClientConn) MetricsServiceClient { + return &metricsServiceClient{cc} +} + +func (c *metricsServiceClient) Export(ctx context.Context, in *internal.ExportMetricsServiceRequest, opts ...grpc.CallOption) (*internal.ExportMetricsServiceResponse, error) { + out := new(internal.ExportMetricsServiceResponse) + err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MetricsServiceServer is the server API for MetricsService service. +type MetricsServiceServer interface { + Export(context.Context, *internal.ExportMetricsServiceRequest) (*internal.ExportMetricsServiceResponse, error) +} + +// UnimplementedMetricsServiceServer can be embedded to have forward compatible implementations. +type UnimplementedMetricsServiceServer struct{} + +func (*UnimplementedMetricsServiceServer) Export(context.Context, *internal.ExportMetricsServiceRequest) (*internal.ExportMetricsServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") +} + +func RegisterMetricsServiceServer(s *grpc.Server, srv MetricsServiceServer) { + s.RegisterService(&metricsServiceServiceDesc, srv) +} + +// Context cannot be the first parameter of the function because gRPC definition. +// +//nolint:revive +func metricsServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(internal.ExportMetricsServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MetricsServiceServer).Export(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(MetricsServiceServer).Export(ctx, req.(*internal.ExportMetricsServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var metricsServiceServiceDesc = grpc.ServiceDesc{ + ServiceName: "opentelemetry.proto.collector.metrics.v1.MetricsService", + HandlerType: (*MetricsServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Export", + Handler: metricsServiceExportHandler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "opentelemetry/proto/collector/metrics/v1/metrics_service.proto", +} diff --git a/pdata/internal/otelgrpc/profiles_service.go b/pdata/internal/otelgrpc/profiles_service.go new file mode 100644 index 00000000000..db846146ff8 --- /dev/null +++ b/pdata/internal/otelgrpc/profiles_service.go @@ -0,0 +1,88 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package otelgrpc // import "go.opentelemetry.io/collector/pdata/internal/otelgrpc" + +import ( + "context" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "go.opentelemetry.io/collector/pdata/internal" +) + +// ProfilesServiceClient is the client API for ProfilesService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ProfilesServiceClient interface { + Export(context.Context, *internal.ExportProfilesServiceRequest, ...grpc.CallOption) (*internal.ExportProfilesServiceResponse, error) +} + +type profilesServiceClient struct { + cc *grpc.ClientConn +} + +func NewProfilesServiceClient(cc *grpc.ClientConn) ProfilesServiceClient { + return &profilesServiceClient{cc} +} + +func (c *profilesServiceClient) Export(ctx context.Context, in *internal.ExportProfilesServiceRequest, opts ...grpc.CallOption) (*internal.ExportProfilesServiceResponse, error) { + out := new(internal.ExportProfilesServiceResponse) + err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ProfilesServiceServer is the server API for ProfilesService service. +type ProfilesServiceServer interface { + Export(context.Context, *internal.ExportProfilesServiceRequest) (*internal.ExportProfilesServiceResponse, error) +} + +// UnimplementedProfilesServiceServer can be embedded to have forward compatible implementations. +type UnimplementedProfilesServiceServer struct{} + +func (*UnimplementedProfilesServiceServer) Export(context.Context, *internal.ExportProfilesServiceRequest) (*internal.ExportProfilesServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") +} + +func RegisterProfilesServiceServer(s *grpc.Server, srv ProfilesServiceServer) { + s.RegisterService(&profilesServiceServiceDesc, srv) +} + +// Context cannot be the first parameter of the function because gRPC definition. +// +//nolint:revive +func profilesServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(internal.ExportProfilesServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProfilesServiceServer).Export(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(ProfilesServiceServer).Export(ctx, req.(*internal.ExportProfilesServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var profilesServiceServiceDesc = grpc.ServiceDesc{ + ServiceName: "opentelemetry.proto.collector.profiles.v1development.ProfilesService", + HandlerType: (*ProfilesServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Export", + Handler: profilesServiceExportHandler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "opentelemetry/proto/collector/profiles/v1development/profiles_service.proto", +} diff --git a/pdata/internal/otelgrpc/trace_service.go b/pdata/internal/otelgrpc/trace_service.go new file mode 100644 index 00000000000..943f61792bd --- /dev/null +++ b/pdata/internal/otelgrpc/trace_service.go @@ -0,0 +1,88 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package otelgrpc // import "go.opentelemetry.io/collector/pdata/internal/otelgrpc" + +import ( + "context" + + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "go.opentelemetry.io/collector/pdata/internal" +) + +// TraceServiceClient is the client API for TraceService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type TraceServiceClient interface { + Export(context.Context, *internal.ExportTraceServiceRequest, ...grpc.CallOption) (*internal.ExportTraceServiceResponse, error) +} + +type traceServiceClient struct { + cc *grpc.ClientConn +} + +func NewTraceServiceClient(cc *grpc.ClientConn) TraceServiceClient { + return &traceServiceClient{cc} +} + +func (c *traceServiceClient) Export(ctx context.Context, in *internal.ExportTraceServiceRequest, opts ...grpc.CallOption) (*internal.ExportTraceServiceResponse, error) { + out := new(internal.ExportTraceServiceResponse) + err := c.cc.Invoke(ctx, "/opentelemetry.proto.collector.trace.v1.TraceService/Export", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TraceServiceServer is the server API for TraceService service. +type TraceServiceServer interface { + Export(context.Context, *internal.ExportTraceServiceRequest) (*internal.ExportTraceServiceResponse, error) +} + +// UnimplementedTraceServiceServer can be embedded to have forward compatible implementations. +type UnimplementedTraceServiceServer struct{} + +func (*UnimplementedTraceServiceServer) Export(context.Context, *internal.ExportTraceServiceRequest) (*internal.ExportTraceServiceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Export not implemented") +} + +func RegisterTraceServiceServer(s *grpc.Server, srv TraceServiceServer) { + s.RegisterService(&traceServiceServiceDesc, srv) +} + +// Context cannot be the first parameter of the function because gRPC definition. +// +//nolint:revive +func traceServiceExportHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { + in := new(internal.ExportTraceServiceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TraceServiceServer).Export(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/opentelemetry.proto.collector.trace.v1.TraceService/Export", + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(TraceServiceServer).Export(ctx, req.(*internal.ExportTraceServiceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var traceServiceServiceDesc = grpc.ServiceDesc{ + ServiceName: "opentelemetry.proto.collector.trace.v1.TraceService", + HandlerType: (*TraceServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Export", + Handler: traceServiceExportHandler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "opentelemetry/proto/collector/trace/v1/trace_service.proto", +} diff --git a/pdata/internal/otlp/logs.go b/pdata/internal/otlp/logs.go index c0328a5b41d..aad78de4e22 100644 --- a/pdata/internal/otlp/logs.go +++ b/pdata/internal/otlp/logs.go @@ -4,12 +4,12 @@ package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // MigrateLogs implements any translation needed due to deprecation in OTLP logs protocol. // Any plog.Unmarshaler implementation from OTLP (proto/json) MUST call this, and the gRPC Server implementation. -func MigrateLogs(rls []*otlplogs.ResourceLogs) { +func MigrateLogs(rls []*internal.ResourceLogs) { for _, rl := range rls { if len(rl.ScopeLogs) == 0 { rl.ScopeLogs = rl.DeprecatedScopeLogs diff --git a/pdata/internal/otlp/logs_test.go b/pdata/internal/otlp/logs_test.go index b7e8744d298..6f147c980a2 100644 --- a/pdata/internal/otlp/logs_test.go +++ b/pdata/internal/otlp/logs_test.go @@ -8,19 +8,19 @@ import ( "github.com/stretchr/testify/assert" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + "go.opentelemetry.io/collector/pdata/internal" ) func TestDeprecatedScopeLogs(t *testing.T) { - sl := new(otlplogs.ScopeLogs) - rls := []*otlplogs.ResourceLogs{ + sl := new(internal.ScopeLogs) + rls := []*internal.ResourceLogs{ { - ScopeLogs: []*otlplogs.ScopeLogs{sl}, - DeprecatedScopeLogs: []*otlplogs.ScopeLogs{sl}, + ScopeLogs: []*internal.ScopeLogs{sl}, + DeprecatedScopeLogs: []*internal.ScopeLogs{sl}, }, { - ScopeLogs: []*otlplogs.ScopeLogs{}, - DeprecatedScopeLogs: []*otlplogs.ScopeLogs{sl}, + ScopeLogs: []*internal.ScopeLogs{}, + DeprecatedScopeLogs: []*internal.ScopeLogs{sl}, }, } diff --git a/pdata/internal/otlp/metrics.go b/pdata/internal/otlp/metrics.go index 9a7da14868c..fb1776c4ffd 100644 --- a/pdata/internal/otlp/metrics.go +++ b/pdata/internal/otlp/metrics.go @@ -4,12 +4,12 @@ package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // MigrateMetrics implements any translation needed due to deprecation in OTLP metrics protocol. // Any pmetric.Unmarshaler implementation from OTLP (proto/json) MUST call this, and the gRPC Server implementation. -func MigrateMetrics(rms []*otlpmetrics.ResourceMetrics) { +func MigrateMetrics(rms []*internal.ResourceMetrics) { for _, rm := range rms { if len(rm.ScopeMetrics) == 0 { rm.ScopeMetrics = rm.DeprecatedScopeMetrics diff --git a/pdata/internal/otlp/metrics_test.go b/pdata/internal/otlp/metrics_test.go index e3f1091a29b..6f7ddd4fb66 100644 --- a/pdata/internal/otlp/metrics_test.go +++ b/pdata/internal/otlp/metrics_test.go @@ -8,19 +8,19 @@ import ( "github.com/stretchr/testify/assert" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + "go.opentelemetry.io/collector/pdata/internal" ) func TestDeprecatedScopeMetrics(t *testing.T) { - sm := new(otlpmetrics.ScopeMetrics) - rms := []*otlpmetrics.ResourceMetrics{ + sm := new(internal.ScopeMetrics) + rms := []*internal.ResourceMetrics{ { - ScopeMetrics: []*otlpmetrics.ScopeMetrics{sm}, - DeprecatedScopeMetrics: []*otlpmetrics.ScopeMetrics{sm}, + ScopeMetrics: []*internal.ScopeMetrics{sm}, + DeprecatedScopeMetrics: []*internal.ScopeMetrics{sm}, }, { - ScopeMetrics: []*otlpmetrics.ScopeMetrics{}, - DeprecatedScopeMetrics: []*otlpmetrics.ScopeMetrics{sm}, + ScopeMetrics: []*internal.ScopeMetrics{}, + DeprecatedScopeMetrics: []*internal.ScopeMetrics{sm}, }, } diff --git a/pdata/internal/otlp/profiles.go b/pdata/internal/otlp/profiles.go index 59c23cc672b..5144e7c4d2f 100644 --- a/pdata/internal/otlp/profiles.go +++ b/pdata/internal/otlp/profiles.go @@ -4,9 +4,9 @@ package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" + "go.opentelemetry.io/collector/pdata/internal" ) // MigrateProfiles implements any translation needed due to deprecation in OTLP profiles protocol. // Any pprofile.Unmarshaler implementation from OTLP (proto/json) MUST call this, and the gRPC Server implementation. -func MigrateProfiles(_ []*otlpprofiles.ResourceProfiles) {} +func MigrateProfiles(_ []*internal.ResourceProfiles) {} diff --git a/pdata/internal/otlp/profiles_test.go b/pdata/internal/otlp/profiles_test.go index de1020bca35..7c15383c14e 100644 --- a/pdata/internal/otlp/profiles_test.go +++ b/pdata/internal/otlp/profiles_test.go @@ -6,11 +6,11 @@ package otlp import ( "testing" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" + "go.opentelemetry.io/collector/pdata/internal" ) func TestMigrateProfiles(_ *testing.T) { - rps := []*otlpprofiles.ResourceProfiles{ + rps := []*internal.ResourceProfiles{ {}, } diff --git a/pdata/internal/otlp/traces.go b/pdata/internal/otlp/traces.go index 627881fc3dc..84f5deadef0 100644 --- a/pdata/internal/otlp/traces.go +++ b/pdata/internal/otlp/traces.go @@ -4,12 +4,12 @@ package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp" import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // MigrateTraces implements any translation needed due to deprecation in OTLP traces protocol. // Any ptrace.Unmarshaler implementation from OTLP (proto/json) MUST call this, and the gRPC Server implementation. -func MigrateTraces(rss []*otlptrace.ResourceSpans) { +func MigrateTraces(rss []*internal.ResourceSpans) { for _, rs := range rss { if len(rs.ScopeSpans) == 0 { rs.ScopeSpans = rs.DeprecatedScopeSpans diff --git a/pdata/internal/otlp/traces_test.go b/pdata/internal/otlp/traces_test.go index ea7ab40d556..1335b25b883 100644 --- a/pdata/internal/otlp/traces_test.go +++ b/pdata/internal/otlp/traces_test.go @@ -8,19 +8,19 @@ import ( "github.com/stretchr/testify/assert" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal" ) func TestDeprecatedScopeSpans(t *testing.T) { - ss := new(otlptrace.ScopeSpans) - rss := []*otlptrace.ResourceSpans{ + ss := new(internal.ScopeSpans) + rss := []*internal.ResourceSpans{ { - ScopeSpans: []*otlptrace.ScopeSpans{ss}, - DeprecatedScopeSpans: []*otlptrace.ScopeSpans{ss}, + ScopeSpans: []*internal.ScopeSpans{ss}, + DeprecatedScopeSpans: []*internal.ScopeSpans{ss}, }, { - ScopeSpans: []*otlptrace.ScopeSpans{}, - DeprecatedScopeSpans: []*otlptrace.ScopeSpans{ss}, + ScopeSpans: []*internal.ScopeSpans{}, + DeprecatedScopeSpans: []*internal.ScopeSpans{ss}, }, } diff --git a/pdata/internal/profileid.go b/pdata/internal/profileid.go new file mode 100644 index 00000000000..5a038fe0854 --- /dev/null +++ b/pdata/internal/profileid.go @@ -0,0 +1,83 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package internal // import "go.opentelemetry.io/collector/pdata/internal" + +import ( + "encoding/hex" + "errors" + + "go.opentelemetry.io/collector/pdata/internal/json" +) + +const profileIDSize = 16 + +var errUnmarshalProfileID = errors.New("unmarshal: invalid ProfileID length") + +// ProfileID is a custom data type that is used for all profile_id fields in OTLP +// Protobuf messages. +type ProfileID [profileIDSize]byte + +func DeleteProfileID(*ProfileID, bool) {} + +func CopyProfileID(dest, src *ProfileID) { + *dest = *src +} + +// IsEmpty returns true if id contains at leas one non-zero byte. +func (pid ProfileID) IsEmpty() bool { + return pid == [profileIDSize]byte{} +} + +// SizeProto returns the size of the data to serialize in proto format. +func (pid ProfileID) SizeProto() int { + if pid.IsEmpty() { + return 0 + } + + return profileIDSize +} + +// MarshalProto converts profile ID into a binary representation. Called by Protobuf serialization. +func (pid ProfileID) MarshalProto(buf []byte) int { + if pid.IsEmpty() { + return 0 + } + + return copy(buf[len(buf)-profileIDSize:], pid[:]) +} + +// UnmarshalProto inflates this profile ID from binary representation. Called by Protobuf serialization. +func (pid *ProfileID) UnmarshalProto(buf []byte) error { + if len(buf) == 0 { + *pid = [profileIDSize]byte{} + return nil + } + + if len(buf) != profileIDSize { + return errUnmarshalProfileID + } + + copy(pid[:], buf) + return nil +} + +// MarshalJSON converts ProfileID into a hex string. +// +//nolint:govet +func (pid ProfileID) MarshalJSON(dest *json.Stream) { + dest.WriteString(hex.EncodeToString(pid[:])) +} + +// UnmarshalJSON decodes ProfileID from hex string. +// +//nolint:govet +func (pid *ProfileID) UnmarshalJSON(iter *json.Iterator) { + *pid = [profileIDSize]byte{} + unmarshalJSON(pid[:], iter) +} + +func GenTestProfileID() *ProfileID { + pid := ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) + return &pid +} diff --git a/pdata/internal/profileid_test.go b/pdata/internal/profileid_test.go new file mode 100644 index 00000000000..ad59091cf30 --- /dev/null +++ b/pdata/internal/profileid_test.go @@ -0,0 +1,70 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package internal + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestProfileID(t *testing.T) { + tid := ProfileID([profileIDSize]byte{}) + assert.EqualValues(t, [profileIDSize]byte{}, tid) + assert.Equal(t, 0, tid.SizeProto()) + + b := [profileIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} + tid = b + assert.EqualValues(t, b, tid) + assert.Equal(t, profileIDSize, tid.SizeProto()) +} + +func TestProfileIDMarshal(t *testing.T) { + buf := make([]byte, profileIDSize) + + tid := ProfileID([profileIDSize]byte{}) + n := tid.MarshalProto(buf) + assert.Equal(t, 0, n) + + tid = [profileIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} + n = tid.MarshalProto(buf) + assert.Equal(t, profileIDSize, n) + assert.Equal(t, []byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}, buf[0:profileIDSize]) +} + +func TestProfileIDUnmarshal(t *testing.T) { + buf := [profileIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} + + tid := ProfileID{} + err := tid.UnmarshalProto(buf[:]) + require.NoError(t, err) + assert.EqualValues(t, buf, tid) + + err = tid.UnmarshalProto(buf[0:0]) + require.NoError(t, err) + assert.EqualValues(t, [profileIDSize]byte{}, tid) + + err = tid.UnmarshalProto(nil) + require.NoError(t, err) + assert.EqualValues(t, [profileIDSize]byte{}, tid) +} + +func TestProfileIDMarshalAndUnmarshalJSON(t *testing.T) { + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src := ProfileID([profileIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := ProfileID{} + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) +} diff --git a/pdata/internal/spanid.go b/pdata/internal/spanid.go new file mode 100644 index 00000000000..9ec0f465fb0 --- /dev/null +++ b/pdata/internal/spanid.go @@ -0,0 +1,82 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package internal // import "go.opentelemetry.io/collector/pdata/internal" + +import ( + "encoding/hex" + "errors" + + "go.opentelemetry.io/collector/pdata/internal/json" +) + +const spanIDSize = 8 + +var errUnmarshalSpanID = errors.New("unmarshal: invalid SpanID length") + +// SpanID is a custom data type that is used for all span_id fields in OTLP +// Protobuf messages. +type SpanID [spanIDSize]byte + +func DeleteSpanID(*SpanID, bool) {} + +func CopySpanID(dest, src *SpanID) { + *dest = *src +} + +// IsEmpty returns true if id contains at least one non-zero byte. +func (sid SpanID) IsEmpty() bool { + return sid == [spanIDSize]byte{} +} + +// SizeProto returns the size of the data to serialize in proto format. +func (sid SpanID) SizeProto() int { + if sid.IsEmpty() { + return 0 + } + return spanIDSize +} + +// MarshalProto converts span ID into a binary representation. Called by Protobuf serialization. +func (sid SpanID) MarshalProto(buf []byte) int { + if sid.IsEmpty() { + return 0 + } + + return copy(buf[len(buf)-spanIDSize:], sid[:]) +} + +// UnmarshalProto inflates this span ID from binary representation. Called by Protobuf serialization. +func (sid *SpanID) UnmarshalProto(data []byte) error { + if len(data) == 0 { + *sid = [spanIDSize]byte{} + return nil + } + + if len(data) != spanIDSize { + return errUnmarshalSpanID + } + + copy(sid[:], data) + return nil +} + +// MarshalJSON converts SpanID into a hex string. +// +//nolint:govet +func (sid SpanID) MarshalJSON(dest *json.Stream) { + dest.WriteString(hex.EncodeToString(sid[:])) +} + +// UnmarshalJSON decodes SpanID from hex string. +// +//nolint:govet +func (sid *SpanID) UnmarshalJSON(iter *json.Iterator) { + *sid = [spanIDSize]byte{} + unmarshalJSON(sid[:], iter) +} + +func GenTestSpanID() *SpanID { + sid := SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1}) + return &sid +} diff --git a/pdata/internal/spanid_test.go b/pdata/internal/spanid_test.go new file mode 100644 index 00000000000..0f62dad3496 --- /dev/null +++ b/pdata/internal/spanid_test.go @@ -0,0 +1,73 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package internal + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "go.opentelemetry.io/collector/pdata/internal/json" +) + +func TestSpanID(t *testing.T) { + sid := SpanID([spanIDSize]byte{}) + assert.EqualValues(t, [spanIDSize]byte{}, sid) + assert.Equal(t, 0, sid.SizeProto()) + + b := [spanIDSize]byte{1, 2, 3, 4, 5, 6, 7, 8} + sid = b + assert.EqualValues(t, b, sid) + assert.Equal(t, 8, sid.SizeProto()) +} + +func TestSpanIDMarshal(t *testing.T) { + buf := make([]byte, spanIDSize) + + sid := SpanID([spanIDSize]byte{}) + n := sid.MarshalProto(buf) + assert.Equal(t, 0, n) + + sid = [spanIDSize]byte{1, 2, 3, 4, 5, 6, 7, 8} + n = sid.MarshalProto(buf) + assert.Equal(t, spanIDSize, n) + assert.Equal(t, []byte{1, 2, 3, 4, 5, 6, 7, 8}, buf[0:spanIDSize]) +} + +func TestSpanIDUnmarshal(t *testing.T) { + buf := [spanIDSize]byte{0x12, 0x23, 0xAD, 0x12, 0x23, 0xAD, 0x12, 0x23} + + sid := SpanID{} + err := sid.UnmarshalProto(buf[:]) + require.NoError(t, err) + assert.EqualValues(t, [spanIDSize]byte{0x12, 0x23, 0xAD, 0x12, 0x23, 0xAD, 0x12, 0x23}, sid) + + err = sid.UnmarshalProto(buf[0:0]) + require.NoError(t, err) + assert.EqualValues(t, [spanIDSize]byte{}, sid) + + err = sid.UnmarshalProto(nil) + require.NoError(t, err) + assert.EqualValues(t, [spanIDSize]byte{}, sid) + + err = sid.UnmarshalProto(buf[0:3]) + assert.Error(t, err) +} + +func TestSpanIDMarshalAndUnmarshalJSON(t *testing.T) { + stream := json.BorrowStream(nil) + defer json.ReturnStream(stream) + src := SpanID([spanIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}) + src.MarshalJSON(stream) + require.NoError(t, stream.Error()) + + iter := json.BorrowIterator(stream.Buffer()) + defer json.ReturnIterator(iter) + dest := SpanID{} + dest.UnmarshalJSON(iter) + require.NoError(t, iter.Error()) + + assert.Equal(t, src, dest) +} diff --git a/pdata/internal/traceid.go b/pdata/internal/traceid.go new file mode 100644 index 00000000000..fe54123de6d --- /dev/null +++ b/pdata/internal/traceid.go @@ -0,0 +1,83 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +package internal // import "go.opentelemetry.io/collector/pdata/internal" + +import ( + "encoding/hex" + "errors" + + "go.opentelemetry.io/collector/pdata/internal/json" +) + +const traceIDSize = 16 + +var errUnmarshalTraceID = errors.New("unmarshal: invalid TraceID length") + +// TraceID is a custom data type that is used for all trace_id fields in OTLP +// Protobuf messages. +type TraceID [traceIDSize]byte + +func DeleteTraceID(*TraceID, bool) {} + +func CopyTraceID(dest, src *TraceID) { + *dest = *src +} + +// IsEmpty returns true if id contains at leas one non-zero byte. +func (tid TraceID) IsEmpty() bool { + return tid == [traceIDSize]byte{} +} + +// SizeProto returns the size of the data to serialize in proto format. +func (tid TraceID) SizeProto() int { + if tid.IsEmpty() { + return 0 + } + + return traceIDSize +} + +// MarshalProto converts trace ID into a binary representation. Called by Protobuf serialization. +func (tid TraceID) MarshalProto(buf []byte) int { + if tid.IsEmpty() { + return 0 + } + + return copy(buf[len(buf)-traceIDSize:], tid[:]) +} + +// UnmarshalProto inflates this trace ID from binary representation. Called by Protobuf serialization. +func (tid *TraceID) UnmarshalProto(buf []byte) error { + if len(buf) == 0 { + *tid = [traceIDSize]byte{} + return nil + } + + if len(buf) != traceIDSize { + return errUnmarshalTraceID + } + + copy(tid[:], buf) + return nil +} + +// MarshalJSON converts TraceID into a hex string. +// +//nolint:govet +func (tid TraceID) MarshalJSON(dest *json.Stream) { + dest.WriteString(hex.EncodeToString(tid[:])) +} + +// UnmarshalJSON decodes TraceID from hex string. +// +//nolint:govet +func (tid *TraceID) UnmarshalJSON(iter *json.Iterator) { + *tid = [profileIDSize]byte{} + unmarshalJSON(tid[:], iter) +} + +func GenTestTraceID() *TraceID { + tid := TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) + return &tid +} diff --git a/pdata/internal/data/traceid_test.go b/pdata/internal/traceid_test.go similarity index 50% rename from pdata/internal/data/traceid_test.go rename to pdata/internal/traceid_test.go index 231a9f25cae..43f68b60ad7 100644 --- a/pdata/internal/data/traceid_test.go +++ b/pdata/internal/traceid_test.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package data +package internal import ( "testing" @@ -13,62 +13,57 @@ import ( ) func TestTraceID(t *testing.T) { - tid := TraceID([16]byte{}) - assert.EqualValues(t, [16]byte{}, tid) - assert.Equal(t, 0, tid.Size()) + tid := TraceID([traceIDSize]byte{}) + assert.EqualValues(t, [traceIDSize]byte{}, tid) + assert.Equal(t, 0, tid.SizeProto()) - b := [16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} + b := [traceIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} tid = b assert.EqualValues(t, b, tid) - assert.Equal(t, 16, tid.Size()) + assert.Equal(t, traceIDSize, tid.SizeProto()) } func TestTraceIDMarshal(t *testing.T) { - buf := make([]byte, 20) + buf := make([]byte, traceIDSize) - tid := TraceID([16]byte{}) - n, err := tid.MarshalTo(buf) + tid := TraceID([traceIDSize]byte{}) + n := tid.MarshalProto(buf) assert.Equal(t, 0, n) - require.NoError(t, err) - - tid = [16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} - n, err = tid.MarshalTo(buf) - assert.Equal(t, 16, n) - assert.Equal(t, []byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}, buf[0:16]) - require.NoError(t, err) - _, err = tid.MarshalTo(buf[0:1]) - assert.Error(t, err) + tid = [traceIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} + n = tid.MarshalProto(buf) + assert.Equal(t, traceIDSize, n) + assert.Equal(t, []byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}, buf[0:traceIDSize]) } func TestTraceIDUnmarshal(t *testing.T) { buf := [16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78} tid := TraceID{} - err := tid.Unmarshal(buf[0:16]) + err := tid.UnmarshalProto(buf[:]) require.NoError(t, err) assert.EqualValues(t, buf, tid) - err = tid.Unmarshal(buf[0:0]) + err = tid.UnmarshalProto(buf[0:0]) require.NoError(t, err) - assert.EqualValues(t, [16]byte{}, tid) + assert.EqualValues(t, [traceIDSize]byte{}, tid) - err = tid.Unmarshal(nil) + err = tid.UnmarshalProto(nil) require.NoError(t, err) - assert.EqualValues(t, [16]byte{}, tid) + assert.EqualValues(t, [traceIDSize]byte{}, tid) } func TestTraceIDMarshalAndUnmarshalJSON(t *testing.T) { stream := json.BorrowStream(nil) defer json.ReturnStream(stream) - src := TraceID([16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}) - src.MarshalJSONStream(stream) + src := TraceID([traceIDSize]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78}) + src.MarshalJSON(stream) require.NoError(t, stream.Error()) iter := json.BorrowIterator(stream.Buffer()) defer json.ReturnIterator(iter) dest := TraceID{} - dest.UnmarshalJSONIter(iter) + dest.UnmarshalJSON(iter) require.NoError(t, iter.Error()) assert.Equal(t, src, dest) diff --git a/pdata/internal/unpacked_unmarshal_test.go b/pdata/internal/unpacked_unmarshal_test.go index 013801c816c..b51c57bd67d 100644 --- a/pdata/internal/unpacked_unmarshal_test.go +++ b/pdata/internal/unpacked_unmarshal_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/proto" ) @@ -40,10 +39,10 @@ func TestUnmarshalUnpackedHistogramDataPoint(t *testing.T) { pb = appendTag(pb, 7, proto.WireTypeI64) // explicit_bounds pb = binary.LittleEndian.AppendUint64(pb, math.Float64bits(42.0)) - var hdp otlpmetrics.HistogramDataPoint - err := UnmarshalProtoOrigHistogramDataPoint(&hdp, pb) + var hdp HistogramDataPoint + err := hdp.UnmarshalProto(pb) require.NoError(t, err) - assert.Equal(t, otlpmetrics.HistogramDataPoint{ + assert.Equal(t, HistogramDataPoint{ BucketCounts: []uint64{42}, ExplicitBounds: []float64{42.0}, }, hdp) @@ -54,10 +53,10 @@ func TestUnmarshalUnpackedExponentialHistogramDataPoint_Buckets(t *testing.T) { pb = appendTag(pb, 2, proto.WireTypeVarint) // bucket_counts pb = appendVarint(pb, 42) - var ehdpb otlpmetrics.ExponentialHistogramDataPoint_Buckets - err := UnmarshalProtoOrigExponentialHistogramDataPoint_Buckets(&ehdpb, pb) + var ehdpb ExponentialHistogramDataPointBuckets + err := ehdpb.UnmarshalProto(pb) require.NoError(t, err) - assert.Equal(t, otlpmetrics.ExponentialHistogramDataPoint_Buckets{ + assert.Equal(t, ExponentialHistogramDataPointBuckets{ BucketCounts: []uint64{42}, }, ehdpb) } diff --git a/pdata/internal/wrapper_logs.go b/pdata/internal/wrapper_logs.go index 31b20766cf9..b47b508336c 100644 --- a/pdata/internal/wrapper_logs.go +++ b/pdata/internal/wrapper_logs.go @@ -3,22 +3,17 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" -) - // LogsToProto internal helper to convert Logs to protobuf representation. -func LogsToProto(l Logs) otlplogs.LogsData { - return otlplogs.LogsData{ +func LogsToProto(l LogsWrapper) LogsData { + return LogsData{ ResourceLogs: l.orig.ResourceLogs, } } // LogsFromProto internal helper to convert protobuf representation to Logs. // This function set exclusive state assuming that it's called only once per Logs. -func LogsFromProto(orig otlplogs.LogsData) Logs { - return NewLogs(&otlpcollectorlog.ExportLogsServiceRequest{ +func LogsFromProto(orig LogsData) LogsWrapper { + return NewLogsWrapper(&ExportLogsServiceRequest{ ResourceLogs: orig.ResourceLogs, }, NewState()) } diff --git a/pdata/internal/wrapper_map.go b/pdata/internal/wrapper_map.go index 33453c0e6f3..c5c6ca7f6da 100644 --- a/pdata/internal/wrapper_map.go +++ b/pdata/internal/wrapper_map.go @@ -3,28 +3,24 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - -type Map struct { - orig *[]otlpcommon.KeyValue +type MapWrapper struct { + orig *[]KeyValue state *State } -func GetOrigMap(ms Map) *[]otlpcommon.KeyValue { +func GetMapOrig(ms MapWrapper) *[]KeyValue { return ms.orig } -func GetMapState(ms Map) *State { +func GetMapState(ms MapWrapper) *State { return ms.state } -func NewMap(orig *[]otlpcommon.KeyValue, state *State) Map { - return Map{orig: orig, state: state} +func NewMapWrapper(orig *[]KeyValue, state *State) MapWrapper { + return MapWrapper{orig: orig, state: state} } -func GenerateTestMap() Map { - orig := GenerateOrigTestKeyValueSlice() - return NewMap(&orig, NewState()) +func GenTestMapWrapper() MapWrapper { + orig := GenTestKeyValueSlice() + return NewMapWrapper(&orig, NewState()) } diff --git a/pdata/internal/wrapper_metrics.go b/pdata/internal/wrapper_metrics.go index ef684b2842d..3cb790395fc 100644 --- a/pdata/internal/wrapper_metrics.go +++ b/pdata/internal/wrapper_metrics.go @@ -3,22 +3,17 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" -) - // MetricsToProto internal helper to convert Metrics to protobuf representation. -func MetricsToProto(l Metrics) otlpmetrics.MetricsData { - return otlpmetrics.MetricsData{ +func MetricsToProto(l MetricsWrapper) MetricsData { + return MetricsData{ ResourceMetrics: l.orig.ResourceMetrics, } } // MetricsFromProto internal helper to convert protobuf representation to Metrics. // This function set exclusive state assuming that it's called only once per Metrics. -func MetricsFromProto(orig otlpmetrics.MetricsData) Metrics { - return NewMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ +func MetricsFromProto(orig MetricsData) MetricsWrapper { + return NewMetricsWrapper(&ExportMetricsServiceRequest{ ResourceMetrics: orig.ResourceMetrics, }, NewState()) } diff --git a/pdata/internal/wrapper_profiles.go b/pdata/internal/wrapper_profiles.go index add52635614..1a56d922975 100644 --- a/pdata/internal/wrapper_profiles.go +++ b/pdata/internal/wrapper_profiles.go @@ -3,14 +3,9 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - otlpcollectorprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - otlpprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" -) - // ProfilesToProto internal helper to convert Profiles to protobuf representation. -func ProfilesToProto(l Profiles) otlpprofile.ProfilesData { - return otlpprofile.ProfilesData{ +func ProfilesToProto(l ProfilesWrapper) ProfilesData { + return ProfilesData{ ResourceProfiles: l.orig.ResourceProfiles, Dictionary: l.orig.Dictionary, } @@ -18,8 +13,8 @@ func ProfilesToProto(l Profiles) otlpprofile.ProfilesData { // ProfilesFromProto internal helper to convert protobuf representation to Profiles. // This function set exclusive state assuming that it's called only once per Profiles. -func ProfilesFromProto(orig otlpprofile.ProfilesData) Profiles { - return NewProfiles(&otlpcollectorprofile.ExportProfilesServiceRequest{ +func ProfilesFromProto(orig ProfilesData) ProfilesWrapper { + return NewProfilesWrapper(&ExportProfilesServiceRequest{ ResourceProfiles: orig.ResourceProfiles, Dictionary: orig.Dictionary, }, NewState()) diff --git a/pdata/internal/wrapper_traces.go b/pdata/internal/wrapper_traces.go index bdc7d93bbab..758a1cb27e0 100644 --- a/pdata/internal/wrapper_traces.go +++ b/pdata/internal/wrapper_traces.go @@ -3,22 +3,17 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - // TracesToProto internal helper to convert Traces to protobuf representation. -func TracesToProto(l Traces) otlptrace.TracesData { - return otlptrace.TracesData{ +func TracesToProto(l TracesWrapper) TracesData { + return TracesData{ ResourceSpans: l.orig.ResourceSpans, } } // TracesFromProto internal helper to convert protobuf representation to Traces. // This function set exclusive state assuming that it's called only once per Traces. -func TracesFromProto(orig otlptrace.TracesData) Traces { - return NewTraces(&otlpcollectortrace.ExportTraceServiceRequest{ +func TracesFromProto(orig TracesData) TracesWrapper { + return NewTracesWrapper(&ExportTraceServiceRequest{ ResourceSpans: orig.ResourceSpans, }, NewState()) } diff --git a/pdata/internal/wrapper_tracestate.go b/pdata/internal/wrapper_tracestate.go index ce3bfe232f0..56278b728dd 100644 --- a/pdata/internal/wrapper_tracestate.go +++ b/pdata/internal/wrapper_tracestate.go @@ -3,41 +3,28 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - "go.opentelemetry.io/collector/pdata/internal/json" -) - -type TraceState struct { +type TraceStateWrapper struct { orig *string state *State } -func GetOrigTraceState(ms TraceState) *string { +func GetTraceStateOrig(ms TraceStateWrapper) *string { return ms.orig } -func GetTraceStateState(ms TraceState) *State { +func GetTraceStateState(ms TraceStateWrapper) *State { return ms.state } -func NewTraceState(orig *string, state *State) TraceState { - return TraceState{orig: orig, state: state} -} - -func GenerateTestTraceState() TraceState { - return NewTraceState(GenTestOrigTraceState(), NewState()) -} - -// UnmarshalJSONOrigTraceState marshals all properties from the current struct to the destination stream. -func UnmarshalJSONOrigTraceState(orig *string, iter *json.Iterator) { - *orig = iter.ReadString() +func NewTraceStateWrapper(orig *string, state *State) TraceStateWrapper { + return TraceStateWrapper{orig: orig, state: state} } -func CopyOrigTraceState(dest, src *string) { - *dest = *src +func GenTestTraceStateWrapper() TraceStateWrapper { + return NewTraceStateWrapper(GenTestTraceState(), NewState()) } -func GenTestOrigTraceState() *string { +func GenTestTraceState() *string { orig := new(string) *orig = "rojo=00f067aa0ba902b7" return orig diff --git a/pdata/internal/wrapper_value.go b/pdata/internal/wrapper_value.go index 43839ae8248..0e77ccb815c 100644 --- a/pdata/internal/wrapper_value.go +++ b/pdata/internal/wrapper_value.go @@ -3,16 +3,12 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal" -import ( - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" -) - type Value struct { - orig *otlpcommon.AnyValue + orig *AnyValue state *State } -func GetOrigValue(ms Value) *otlpcommon.AnyValue { +func GetOrigValue(ms Value) *AnyValue { return ms.orig } @@ -20,55 +16,59 @@ func GetValueState(ms Value) *State { return ms.state } -func NewValue(orig *otlpcommon.AnyValue, state *State) Value { +func NewValueWrapper(orig *AnyValue, state *State) Value { return Value{orig: orig, state: state} } -func NewOrigAnyValueStringValue() *otlpcommon.AnyValue_StringValue { +func NewAnyValueStringValue() *AnyValue_StringValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_StringValue{} + return &AnyValue_StringValue{} } - return ProtoPoolAnyValue_StringValue.Get().(*otlpcommon.AnyValue_StringValue) + return ProtoPoolAnyValue_StringValue.Get().(*AnyValue_StringValue) } -func NewOrigAnyValueIntValue() *otlpcommon.AnyValue_IntValue { +func NewAnyValueIntValue() *AnyValue_IntValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_IntValue{} + return &AnyValue_IntValue{} } - return ProtoPoolAnyValue_IntValue.Get().(*otlpcommon.AnyValue_IntValue) + return ProtoPoolAnyValue_IntValue.Get().(*AnyValue_IntValue) } -func NewOrigAnyValueBoolValue() *otlpcommon.AnyValue_BoolValue { +func NewAnyValueBoolValue() *AnyValue_BoolValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_BoolValue{} + return &AnyValue_BoolValue{} } - return ProtoPoolAnyValue_BoolValue.Get().(*otlpcommon.AnyValue_BoolValue) + return ProtoPoolAnyValue_BoolValue.Get().(*AnyValue_BoolValue) } -func NewOrigAnyValueDoubleValue() *otlpcommon.AnyValue_DoubleValue { +func NewAnyValueDoubleValue() *AnyValue_DoubleValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_DoubleValue{} + return &AnyValue_DoubleValue{} } - return ProtoPoolAnyValue_DoubleValue.Get().(*otlpcommon.AnyValue_DoubleValue) + return ProtoPoolAnyValue_DoubleValue.Get().(*AnyValue_DoubleValue) } -func NewOrigAnyValueBytesValue() *otlpcommon.AnyValue_BytesValue { +func NewAnyValueBytesValue() *AnyValue_BytesValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_BytesValue{} + return &AnyValue_BytesValue{} } - return ProtoPoolAnyValue_BytesValue.Get().(*otlpcommon.AnyValue_BytesValue) + return ProtoPoolAnyValue_BytesValue.Get().(*AnyValue_BytesValue) } -func NewOrigAnyValueArrayValue() *otlpcommon.AnyValue_ArrayValue { +func NewAnyValueArrayValue() *AnyValue_ArrayValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_ArrayValue{} + return &AnyValue_ArrayValue{} } - return ProtoPoolAnyValue_ArrayValue.Get().(*otlpcommon.AnyValue_ArrayValue) + return ProtoPoolAnyValue_ArrayValue.Get().(*AnyValue_ArrayValue) } -func NewOrigAnyValueKvlistValue() *otlpcommon.AnyValue_KvlistValue { +func NewAnyValueKvlistValue() *AnyValue_KvlistValue { if !UseProtoPooling.IsEnabled() { - return &otlpcommon.AnyValue_KvlistValue{} + return &AnyValue_KvlistValue{} } - return ProtoPoolAnyValue_KvlistValue.Get().(*otlpcommon.AnyValue_KvlistValue) + return ProtoPoolAnyValue_KvlistValue.Get().(*AnyValue_KvlistValue) +} + +func GenTestValueWrapper() Value { + return NewValueWrapper(GenTestAnyValue(), NewState()) } diff --git a/pdata/internal/wrapper_value_test.go b/pdata/internal/wrapper_value_test.go index 67d0fe68a75..ba2681e4f36 100644 --- a/pdata/internal/wrapper_value_test.go +++ b/pdata/internal/wrapper_value_test.go @@ -9,8 +9,6 @@ import ( "github.com/stretchr/testify/require" gootlpcommon "go.opentelemetry.io/proto/slim/otlp/common/v1" goproto "google.golang.org/protobuf/proto" - - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestAnyValueBytes(t *testing.T) { @@ -18,9 +16,9 @@ func TestAnyValueBytes(t *testing.T) { buf, err := goproto.Marshal(av) require.NoError(t, err) - pav := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_BytesValue{BytesValue: nil}} - pbuf := make([]byte, SizeProtoOrigAnyValue(pav)) - n := MarshalProtoOrigAnyValue(pav, pbuf) + pav := &AnyValue{Value: &AnyValue_BytesValue{BytesValue: nil}} + pbuf := make([]byte, pav.SizeProto()) + n := pav.MarshalProto(pbuf) pbuf = pbuf[:n] require.Equal(t, buf, pbuf) } diff --git a/pdata/pcommon/generated_byteslice.go b/pdata/pcommon/generated_byteslice.go index 8cdedc2efb6..073b55d3416 100644 --- a/pdata/pcommon/generated_byteslice.go +++ b/pdata/pcommon/generated_byteslice.go @@ -18,31 +18,31 @@ import ( // // Must use NewByteSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type ByteSlice internal.ByteSlice +type ByteSlice internal.ByteSliceWrapper func (ms ByteSlice) getOrig() *[]byte { - return internal.GetOrigByteSlice(internal.ByteSlice(ms)) + return internal.GetByteSliceOrig(internal.ByteSliceWrapper(ms)) } func (ms ByteSlice) getState() *internal.State { - return internal.GetByteSliceState(internal.ByteSlice(ms)) + return internal.GetByteSliceState(internal.ByteSliceWrapper(ms)) } // NewByteSlice creates a new empty ByteSlice. func NewByteSlice() ByteSlice { orig := []byte(nil) - return ByteSlice(internal.NewByteSlice(&orig, internal.NewState())) + return ByteSlice(internal.NewByteSliceWrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []byte slice. func (ms ByteSlice) AsRaw() []byte { - return internal.CopyOrigByteSlice(nil, *ms.getOrig()) + return copyByteSlice(nil, *ms.getOrig()) } // FromRaw copies raw []byte into the slice ByteSlice. func (ms ByteSlice) FromRaw(val []byte) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrigByteSlice(*ms.getOrig(), val) + *ms.getOrig() = copyByteSlice(*ms.getOrig(), val) } // Len returns length of the []byte slice value. @@ -155,10 +155,14 @@ func (ms ByteSlice) CopyTo(dest ByteSlice) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigByteSlice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copyByteSlice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another ByteSlice func (ms ByteSlice) Equal(val ByteSlice) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copyByteSlice(dst, src []byte) []byte { + return append(dst[:0], src...) +} diff --git a/pdata/pcommon/generated_byteslice_test.go b/pdata/pcommon/generated_byteslice_test.go index a54dfe64d38..aca1e24709e 100644 --- a/pdata/pcommon/generated_byteslice_test.go +++ b/pdata/pcommon/generated_byteslice_test.go @@ -52,7 +52,7 @@ func TestByteSliceReadOnly(t *testing.T) { raw := []byte{1, 2, 3} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := ByteSlice(internal.NewByteSlice(&raw, sharedState)) + ms := ByteSlice(internal.NewByteSliceWrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) assert.Equal(t, byte(1), ms.At(0)) diff --git a/pdata/pcommon/generated_float64slice.go b/pdata/pcommon/generated_float64slice.go index 0efbfd0f5b9..dac9ebc4edf 100644 --- a/pdata/pcommon/generated_float64slice.go +++ b/pdata/pcommon/generated_float64slice.go @@ -18,31 +18,31 @@ import ( // // Must use NewFloat64Slice function to create new instances. // Important: zero-initialized instance is not valid for use. -type Float64Slice internal.Float64Slice +type Float64Slice internal.Float64SliceWrapper func (ms Float64Slice) getOrig() *[]float64 { - return internal.GetOrigFloat64Slice(internal.Float64Slice(ms)) + return internal.GetFloat64SliceOrig(internal.Float64SliceWrapper(ms)) } func (ms Float64Slice) getState() *internal.State { - return internal.GetFloat64SliceState(internal.Float64Slice(ms)) + return internal.GetFloat64SliceState(internal.Float64SliceWrapper(ms)) } // NewFloat64Slice creates a new empty Float64Slice. func NewFloat64Slice() Float64Slice { orig := []float64(nil) - return Float64Slice(internal.NewFloat64Slice(&orig, internal.NewState())) + return Float64Slice(internal.NewFloat64SliceWrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []float64 slice. func (ms Float64Slice) AsRaw() []float64 { - return internal.CopyOrigFloat64Slice(nil, *ms.getOrig()) + return copyFloat64Slice(nil, *ms.getOrig()) } // FromRaw copies raw []float64 into the slice Float64Slice. func (ms Float64Slice) FromRaw(val []float64) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrigFloat64Slice(*ms.getOrig(), val) + *ms.getOrig() = copyFloat64Slice(*ms.getOrig(), val) } // Len returns length of the []float64 slice value. @@ -155,10 +155,14 @@ func (ms Float64Slice) CopyTo(dest Float64Slice) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigFloat64Slice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copyFloat64Slice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another Float64Slice func (ms Float64Slice) Equal(val Float64Slice) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copyFloat64Slice(dst, src []float64) []float64 { + return append(dst[:0], src...) +} diff --git a/pdata/pcommon/generated_float64slice_test.go b/pdata/pcommon/generated_float64slice_test.go index e7d67958cd4..ad8a93feec9 100644 --- a/pdata/pcommon/generated_float64slice_test.go +++ b/pdata/pcommon/generated_float64slice_test.go @@ -52,7 +52,7 @@ func TestFloat64SliceReadOnly(t *testing.T) { raw := []float64{1.1, 2.2, 3.3} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := Float64Slice(internal.NewFloat64Slice(&raw, sharedState)) + ms := Float64Slice(internal.NewFloat64SliceWrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) assert.InDelta(t, float64(1.1), ms.At(0), 0.01) diff --git a/pdata/pcommon/generated_instrumentationscope.go b/pdata/pcommon/generated_instrumentationscope.go index b4385a0884e..6eeeab6e3cb 100644 --- a/pdata/pcommon/generated_instrumentationscope.go +++ b/pdata/pcommon/generated_instrumentationscope.go @@ -8,7 +8,6 @@ package pcommon import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // InstrumentationScope is a message representing the instrumentation scope information. @@ -18,10 +17,10 @@ import ( // // Must use NewInstrumentationScope function to create new instances. // Important: zero-initialized instance is not valid for use. -type InstrumentationScope internal.InstrumentationScope +type InstrumentationScope internal.InstrumentationScopeWrapper -func newInstrumentationScope(orig *otlpcommon.InstrumentationScope, state *internal.State) InstrumentationScope { - return InstrumentationScope(internal.NewInstrumentationScope(orig, state)) +func newInstrumentationScope(orig *internal.InstrumentationScope, state *internal.State) InstrumentationScope { + return InstrumentationScope(internal.NewInstrumentationScopeWrapper(orig, state)) } // NewInstrumentationScope creates a new empty InstrumentationScope. @@ -29,7 +28,7 @@ func newInstrumentationScope(orig *otlpcommon.InstrumentationScope, state *inter // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewInstrumentationScope() InstrumentationScope { - return newInstrumentationScope(internal.NewOrigInstrumentationScope(), internal.NewState()) + return newInstrumentationScope(internal.NewInstrumentationScope(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -41,7 +40,7 @@ func (ms InstrumentationScope) MoveTo(dest InstrumentationScope) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigInstrumentationScope(dest.getOrig(), false) + internal.DeleteInstrumentationScope(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } @@ -69,7 +68,7 @@ func (ms InstrumentationScope) SetVersion(v string) { // Attributes returns the Attributes associated with this InstrumentationScope. func (ms InstrumentationScope) Attributes() Map { - return Map(internal.NewMap(&ms.getOrig().Attributes, ms.getState())) + return Map(internal.NewMapWrapper(&ms.getOrig().Attributes, ms.getState())) } // DroppedAttributesCount returns the droppedattributescount associated with this InstrumentationScope. @@ -86,13 +85,13 @@ func (ms InstrumentationScope) SetDroppedAttributesCount(v uint32) { // CopyTo copies all properties from the current struct overriding the destination. func (ms InstrumentationScope) CopyTo(dest InstrumentationScope) { dest.getState().AssertMutable() - internal.CopyOrigInstrumentationScope(dest.getOrig(), ms.getOrig()) + internal.CopyInstrumentationScope(dest.getOrig(), ms.getOrig()) } -func (ms InstrumentationScope) getOrig() *otlpcommon.InstrumentationScope { - return internal.GetOrigInstrumentationScope(internal.InstrumentationScope(ms)) +func (ms InstrumentationScope) getOrig() *internal.InstrumentationScope { + return internal.GetInstrumentationScopeOrig(internal.InstrumentationScopeWrapper(ms)) } func (ms InstrumentationScope) getState() *internal.State { - return internal.GetInstrumentationScopeState(internal.InstrumentationScope(ms)) + return internal.GetInstrumentationScopeState(internal.InstrumentationScopeWrapper(ms)) } diff --git a/pdata/pcommon/generated_instrumentationscope_test.go b/pdata/pcommon/generated_instrumentationscope_test.go index eb68667eec7..9cd7f3d487b 100644 --- a/pdata/pcommon/generated_instrumentationscope_test.go +++ b/pdata/pcommon/generated_instrumentationscope_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestInstrumentationScope_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestInstrumentationScope_MoveTo(t *testing.T) { assert.Equal(t, generateTestInstrumentationScope(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newInstrumentationScope(internal.NewOrigInstrumentationScope(), sharedState)) }) - assert.Panics(t, func() { newInstrumentationScope(internal.NewOrigInstrumentationScope(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newInstrumentationScope(internal.NewInstrumentationScope(), sharedState)) }) + assert.Panics(t, func() { newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).MoveTo(dest) }) } func TestInstrumentationScope_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestInstrumentationScope_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newInstrumentationScope(internal.NewOrigInstrumentationScope(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newInstrumentationScope(internal.NewInstrumentationScope(), sharedState)) }) } func TestInstrumentationScope_Name(t *testing.T) { @@ -49,7 +48,7 @@ func TestInstrumentationScope_Name(t *testing.T) { assert.Equal(t, "test_name", ms.Name()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newInstrumentationScope(&otlpcommon.InstrumentationScope{}, sharedState).SetName("test_name") }) + assert.Panics(t, func() { newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).SetName("test_name") }) } func TestInstrumentationScope_Version(t *testing.T) { @@ -60,15 +59,15 @@ func TestInstrumentationScope_Version(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newInstrumentationScope(&otlpcommon.InstrumentationScope{}, sharedState).SetVersion("test_version") + newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).SetVersion("test_version") }) } func TestInstrumentationScope_Attributes(t *testing.T) { ms := NewInstrumentationScope() assert.Equal(t, NewMap(), ms.Attributes()) - ms.getOrig().Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, Map(internal.GenerateTestMap()), ms.Attributes()) + ms.getOrig().Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestInstrumentationScope_DroppedAttributesCount(t *testing.T) { @@ -79,11 +78,10 @@ func TestInstrumentationScope_DroppedAttributesCount(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newInstrumentationScope(&otlpcommon.InstrumentationScope{}, sharedState).SetDroppedAttributesCount(uint32(13)) + newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func generateTestInstrumentationScope() InstrumentationScope { - ms := newInstrumentationScope(internal.GenTestOrigInstrumentationScope(), internal.NewState()) - return ms + return newInstrumentationScope(internal.GenTestInstrumentationScope(), internal.NewState()) } diff --git a/pdata/pcommon/generated_int32slice.go b/pdata/pcommon/generated_int32slice.go index 6cf7e2822fb..d2bb746df53 100644 --- a/pdata/pcommon/generated_int32slice.go +++ b/pdata/pcommon/generated_int32slice.go @@ -18,31 +18,31 @@ import ( // // Must use NewInt32Slice function to create new instances. // Important: zero-initialized instance is not valid for use. -type Int32Slice internal.Int32Slice +type Int32Slice internal.Int32SliceWrapper func (ms Int32Slice) getOrig() *[]int32 { - return internal.GetOrigInt32Slice(internal.Int32Slice(ms)) + return internal.GetInt32SliceOrig(internal.Int32SliceWrapper(ms)) } func (ms Int32Slice) getState() *internal.State { - return internal.GetInt32SliceState(internal.Int32Slice(ms)) + return internal.GetInt32SliceState(internal.Int32SliceWrapper(ms)) } // NewInt32Slice creates a new empty Int32Slice. func NewInt32Slice() Int32Slice { orig := []int32(nil) - return Int32Slice(internal.NewInt32Slice(&orig, internal.NewState())) + return Int32Slice(internal.NewInt32SliceWrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []int32 slice. func (ms Int32Slice) AsRaw() []int32 { - return internal.CopyOrigInt32Slice(nil, *ms.getOrig()) + return copyInt32Slice(nil, *ms.getOrig()) } // FromRaw copies raw []int32 into the slice Int32Slice. func (ms Int32Slice) FromRaw(val []int32) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrigInt32Slice(*ms.getOrig(), val) + *ms.getOrig() = copyInt32Slice(*ms.getOrig(), val) } // Len returns length of the []int32 slice value. @@ -155,10 +155,14 @@ func (ms Int32Slice) CopyTo(dest Int32Slice) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigInt32Slice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copyInt32Slice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another Int32Slice func (ms Int32Slice) Equal(val Int32Slice) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copyInt32Slice(dst, src []int32) []int32 { + return append(dst[:0], src...) +} diff --git a/pdata/pcommon/generated_int32slice_test.go b/pdata/pcommon/generated_int32slice_test.go index 342ff1ba180..3c1a3ed12e7 100644 --- a/pdata/pcommon/generated_int32slice_test.go +++ b/pdata/pcommon/generated_int32slice_test.go @@ -52,7 +52,7 @@ func TestInt32SliceReadOnly(t *testing.T) { raw := []int32{1, 2, 3} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := Int32Slice(internal.NewInt32Slice(&raw, sharedState)) + ms := Int32Slice(internal.NewInt32SliceWrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) assert.Equal(t, int32(1), ms.At(0)) diff --git a/pdata/pcommon/generated_int64slice.go b/pdata/pcommon/generated_int64slice.go index f38f92baec4..4c22f2ed825 100644 --- a/pdata/pcommon/generated_int64slice.go +++ b/pdata/pcommon/generated_int64slice.go @@ -18,31 +18,31 @@ import ( // // Must use NewInt64Slice function to create new instances. // Important: zero-initialized instance is not valid for use. -type Int64Slice internal.Int64Slice +type Int64Slice internal.Int64SliceWrapper func (ms Int64Slice) getOrig() *[]int64 { - return internal.GetOrigInt64Slice(internal.Int64Slice(ms)) + return internal.GetInt64SliceOrig(internal.Int64SliceWrapper(ms)) } func (ms Int64Slice) getState() *internal.State { - return internal.GetInt64SliceState(internal.Int64Slice(ms)) + return internal.GetInt64SliceState(internal.Int64SliceWrapper(ms)) } // NewInt64Slice creates a new empty Int64Slice. func NewInt64Slice() Int64Slice { orig := []int64(nil) - return Int64Slice(internal.NewInt64Slice(&orig, internal.NewState())) + return Int64Slice(internal.NewInt64SliceWrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []int64 slice. func (ms Int64Slice) AsRaw() []int64 { - return internal.CopyOrigInt64Slice(nil, *ms.getOrig()) + return copyInt64Slice(nil, *ms.getOrig()) } // FromRaw copies raw []int64 into the slice Int64Slice. func (ms Int64Slice) FromRaw(val []int64) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrigInt64Slice(*ms.getOrig(), val) + *ms.getOrig() = copyInt64Slice(*ms.getOrig(), val) } // Len returns length of the []int64 slice value. @@ -155,10 +155,14 @@ func (ms Int64Slice) CopyTo(dest Int64Slice) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigInt64Slice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copyInt64Slice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another Int64Slice func (ms Int64Slice) Equal(val Int64Slice) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copyInt64Slice(dst, src []int64) []int64 { + return append(dst[:0], src...) +} diff --git a/pdata/pcommon/generated_int64slice_test.go b/pdata/pcommon/generated_int64slice_test.go index 796b21ba436..f9e58168546 100644 --- a/pdata/pcommon/generated_int64slice_test.go +++ b/pdata/pcommon/generated_int64slice_test.go @@ -52,7 +52,7 @@ func TestInt64SliceReadOnly(t *testing.T) { raw := []int64{1, 2, 3} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := Int64Slice(internal.NewInt64Slice(&raw, sharedState)) + ms := Int64Slice(internal.NewInt64SliceWrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) assert.Equal(t, int64(1), ms.At(0)) diff --git a/pdata/pcommon/generated_resource.go b/pdata/pcommon/generated_resource.go index 66cd5156d27..4f767693b72 100644 --- a/pdata/pcommon/generated_resource.go +++ b/pdata/pcommon/generated_resource.go @@ -8,7 +8,6 @@ package pcommon import ( "go.opentelemetry.io/collector/pdata/internal" - otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) // Resource is a message representing the resource information. @@ -18,10 +17,10 @@ import ( // // Must use NewResource function to create new instances. // Important: zero-initialized instance is not valid for use. -type Resource internal.Resource +type Resource internal.ResourceWrapper -func newResource(orig *otlpresource.Resource, state *internal.State) Resource { - return Resource(internal.NewResource(orig, state)) +func newResource(orig *internal.Resource, state *internal.State) Resource { + return Resource(internal.NewResourceWrapper(orig, state)) } // NewResource creates a new empty Resource. @@ -29,7 +28,7 @@ func newResource(orig *otlpresource.Resource, state *internal.State) Resource { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewResource() Resource { - return newResource(internal.NewOrigResource(), internal.NewState()) + return newResource(internal.NewResource(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -41,13 +40,13 @@ func (ms Resource) MoveTo(dest Resource) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigResource(dest.getOrig(), false) + internal.DeleteResource(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } // Attributes returns the Attributes associated with this Resource. func (ms Resource) Attributes() Map { - return Map(internal.NewMap(&ms.getOrig().Attributes, ms.getState())) + return Map(internal.NewMapWrapper(&ms.getOrig().Attributes, ms.getState())) } // DroppedAttributesCount returns the droppedattributescount associated with this Resource. @@ -64,13 +63,13 @@ func (ms Resource) SetDroppedAttributesCount(v uint32) { // CopyTo copies all properties from the current struct overriding the destination. func (ms Resource) CopyTo(dest Resource) { dest.getState().AssertMutable() - internal.CopyOrigResource(dest.getOrig(), ms.getOrig()) + internal.CopyResource(dest.getOrig(), ms.getOrig()) } -func (ms Resource) getOrig() *otlpresource.Resource { - return internal.GetOrigResource(internal.Resource(ms)) +func (ms Resource) getOrig() *internal.Resource { + return internal.GetResourceOrig(internal.ResourceWrapper(ms)) } func (ms Resource) getState() *internal.State { - return internal.GetResourceState(internal.Resource(ms)) + return internal.GetResourceState(internal.ResourceWrapper(ms)) } diff --git a/pdata/pcommon/generated_resource_test.go b/pdata/pcommon/generated_resource_test.go index 7754bc46ca5..b74db180398 100644 --- a/pdata/pcommon/generated_resource_test.go +++ b/pdata/pcommon/generated_resource_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" ) func TestResource_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestResource_MoveTo(t *testing.T) { assert.Equal(t, generateTestResource(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newResource(internal.NewOrigResource(), sharedState)) }) - assert.Panics(t, func() { newResource(internal.NewOrigResource(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newResource(internal.NewResource(), sharedState)) }) + assert.Panics(t, func() { newResource(internal.NewResource(), sharedState).MoveTo(dest) }) } func TestResource_CopyTo(t *testing.T) { @@ -39,14 +38,14 @@ func TestResource_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newResource(internal.NewOrigResource(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newResource(internal.NewResource(), sharedState)) }) } func TestResource_Attributes(t *testing.T) { ms := NewResource() assert.Equal(t, NewMap(), ms.Attributes()) - ms.getOrig().Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, Map(internal.GenerateTestMap()), ms.Attributes()) + ms.getOrig().Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestResource_DroppedAttributesCount(t *testing.T) { @@ -56,10 +55,9 @@ func TestResource_DroppedAttributesCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newResource(&otlpresource.Resource{}, sharedState).SetDroppedAttributesCount(uint32(13)) }) + assert.Panics(t, func() { newResource(internal.NewResource(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func generateTestResource() Resource { - ms := newResource(internal.GenTestOrigResource(), internal.NewState()) - return ms + return newResource(internal.GenTestResource(), internal.NewState()) } diff --git a/pdata/pcommon/generated_slice.go b/pdata/pcommon/generated_slice.go index c60caaa33c1..ca81653b077 100644 --- a/pdata/pcommon/generated_slice.go +++ b/pdata/pcommon/generated_slice.go @@ -10,7 +10,6 @@ import ( "iter" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // Slice logically represents a slice of Value. @@ -20,16 +19,16 @@ import ( // // Must use NewSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type Slice internal.Slice +type Slice internal.SliceWrapper -func newSlice(orig *[]otlpcommon.AnyValue, state *internal.State) Slice { - return Slice(internal.NewSlice(orig, state)) +func newSlice(orig *[]internal.AnyValue, state *internal.State) Slice { + return Slice(internal.NewSliceWrapper(orig, state)) } // NewSlice creates a Slice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSlice() Slice { - orig := []otlpcommon.AnyValue(nil) + orig := []internal.AnyValue(nil) return newSlice(&orig, internal.NewState()) } @@ -86,7 +85,7 @@ func (es Slice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpcommon.AnyValue, len(*es.getOrig()), newCap) + newOrig := make([]internal.AnyValue, len(*es.getOrig()), newCap) copy(newOrig, *es.getOrig()) *es.getOrig() = newOrig } @@ -95,7 +94,7 @@ func (es Slice) EnsureCapacity(newCap int) { // It returns the newly added Value. func (es Slice) AppendEmpty() Value { es.getState().AssertMutable() - *es.getOrig() = append(*es.getOrig(), otlpcommon.AnyValue{}) + *es.getOrig() = append(*es.getOrig(), internal.AnyValue{}) return es.At(es.Len() - 1) } @@ -124,7 +123,7 @@ func (es Slice) RemoveIf(f func(Value) bool) { newLen := 0 for i := 0; i < len(*es.getOrig()); i++ { if f(es.At(i)) { - internal.DeleteOrigAnyValue(&(*es.getOrig())[i], false) + internal.DeleteAnyValue(&(*es.getOrig())[i], false) continue } if newLen == i { @@ -145,13 +144,13 @@ func (es Slice) CopyTo(dest Slice) { if es.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigAnyValueSlice(*dest.getOrig(), *es.getOrig()) + *dest.getOrig() = internal.CopyAnyValueSlice(*dest.getOrig(), *es.getOrig()) } -func (ms Slice) getOrig() *[]otlpcommon.AnyValue { - return internal.GetOrigSlice(internal.Slice(ms)) +func (ms Slice) getOrig() *[]internal.AnyValue { + return internal.GetSliceOrig(internal.SliceWrapper(ms)) } func (ms Slice) getState() *internal.State { - return internal.GetSliceState(internal.Slice(ms)) + return internal.GetSliceState(internal.SliceWrapper(ms)) } diff --git a/pdata/pcommon/generated_slice_test.go b/pdata/pcommon/generated_slice_test.go index f4f31712246..cbc3dedbfa8 100644 --- a/pdata/pcommon/generated_slice_test.go +++ b/pdata/pcommon/generated_slice_test.go @@ -12,21 +12,20 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestSlice(t *testing.T) { es := NewSlice() assert.Equal(t, 0, es.Len()) - es = newSlice(&[]otlpcommon.AnyValue{}, internal.NewState()) + es = newSlice(&[]internal.AnyValue{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewValueEmpty() - testVal := Value(internal.NewValue(internal.GenTestOrigAnyValue(), internal.NewState())) + testVal := Value(internal.GenTestValueWrapper()) for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.getOrig())[i] = *internal.GenTestOrigAnyValue() + (*es.getOrig())[i] = *internal.GenTestAnyValue() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -35,7 +34,7 @@ func TestSlice(t *testing.T) { func TestSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSlice(&[]otlpcommon.AnyValue{}, sharedState) + es := newSlice(&[]internal.AnyValue{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -145,6 +144,6 @@ func TestSliceAll(t *testing.T) { func generateTestSlice() Slice { ms := NewSlice() - *ms.getOrig() = internal.GenerateOrigTestAnyValueSlice() + *ms.getOrig() = internal.GenTestAnyValueSlice() return ms } diff --git a/pdata/pcommon/generated_stringslice.go b/pdata/pcommon/generated_stringslice.go index a38c9b180e8..ff8422805d8 100644 --- a/pdata/pcommon/generated_stringslice.go +++ b/pdata/pcommon/generated_stringslice.go @@ -18,31 +18,31 @@ import ( // // Must use NewStringSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type StringSlice internal.StringSlice +type StringSlice internal.StringSliceWrapper func (ms StringSlice) getOrig() *[]string { - return internal.GetOrigStringSlice(internal.StringSlice(ms)) + return internal.GetStringSliceOrig(internal.StringSliceWrapper(ms)) } func (ms StringSlice) getState() *internal.State { - return internal.GetStringSliceState(internal.StringSlice(ms)) + return internal.GetStringSliceState(internal.StringSliceWrapper(ms)) } // NewStringSlice creates a new empty StringSlice. func NewStringSlice() StringSlice { orig := []string(nil) - return StringSlice(internal.NewStringSlice(&orig, internal.NewState())) + return StringSlice(internal.NewStringSliceWrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []string slice. func (ms StringSlice) AsRaw() []string { - return internal.CopyOrigStringSlice(nil, *ms.getOrig()) + return copyStringSlice(nil, *ms.getOrig()) } // FromRaw copies raw []string into the slice StringSlice. func (ms StringSlice) FromRaw(val []string) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrigStringSlice(*ms.getOrig(), val) + *ms.getOrig() = copyStringSlice(*ms.getOrig(), val) } // Len returns length of the []string slice value. @@ -155,10 +155,14 @@ func (ms StringSlice) CopyTo(dest StringSlice) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigStringSlice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copyStringSlice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another StringSlice func (ms StringSlice) Equal(val StringSlice) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copyStringSlice(dst, src []string) []string { + return append(dst[:0], src...) +} diff --git a/pdata/pcommon/generated_stringslice_test.go b/pdata/pcommon/generated_stringslice_test.go index 10491e1d9c8..4c840bba53a 100644 --- a/pdata/pcommon/generated_stringslice_test.go +++ b/pdata/pcommon/generated_stringslice_test.go @@ -52,7 +52,7 @@ func TestStringSliceReadOnly(t *testing.T) { raw := []string{"a", "b", "c"} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := StringSlice(internal.NewStringSlice(&raw, sharedState)) + ms := StringSlice(internal.NewStringSliceWrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) assert.Equal(t, string("a"), ms.At(0)) diff --git a/pdata/pcommon/generated_uint64slice.go b/pdata/pcommon/generated_uint64slice.go index 0ea448a2b41..22539d9875e 100644 --- a/pdata/pcommon/generated_uint64slice.go +++ b/pdata/pcommon/generated_uint64slice.go @@ -18,31 +18,31 @@ import ( // // Must use NewUInt64Slice function to create new instances. // Important: zero-initialized instance is not valid for use. -type UInt64Slice internal.UInt64Slice +type UInt64Slice internal.UInt64SliceWrapper func (ms UInt64Slice) getOrig() *[]uint64 { - return internal.GetOrigUInt64Slice(internal.UInt64Slice(ms)) + return internal.GetUInt64SliceOrig(internal.UInt64SliceWrapper(ms)) } func (ms UInt64Slice) getState() *internal.State { - return internal.GetUInt64SliceState(internal.UInt64Slice(ms)) + return internal.GetUInt64SliceState(internal.UInt64SliceWrapper(ms)) } // NewUInt64Slice creates a new empty UInt64Slice. func NewUInt64Slice() UInt64Slice { orig := []uint64(nil) - return UInt64Slice(internal.NewUInt64Slice(&orig, internal.NewState())) + return UInt64Slice(internal.NewUInt64SliceWrapper(&orig, internal.NewState())) } // AsRaw returns a copy of the []uint64 slice. func (ms UInt64Slice) AsRaw() []uint64 { - return internal.CopyOrigUint64Slice(nil, *ms.getOrig()) + return copyUint64Slice(nil, *ms.getOrig()) } // FromRaw copies raw []uint64 into the slice UInt64Slice. func (ms UInt64Slice) FromRaw(val []uint64) { ms.getState().AssertMutable() - *ms.getOrig() = internal.CopyOrigUint64Slice(*ms.getOrig(), val) + *ms.getOrig() = copyUint64Slice(*ms.getOrig(), val) } // Len returns length of the []uint64 slice value. @@ -155,10 +155,14 @@ func (ms UInt64Slice) CopyTo(dest UInt64Slice) { if ms.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigUint64Slice(*dest.getOrig(), *ms.getOrig()) + *dest.getOrig() = copyUint64Slice(*dest.getOrig(), *ms.getOrig()) } // Equal checks equality with another UInt64Slice func (ms UInt64Slice) Equal(val UInt64Slice) bool { return slices.Equal(*ms.getOrig(), *val.getOrig()) } + +func copyUint64Slice(dst, src []uint64) []uint64 { + return append(dst[:0], src...) +} diff --git a/pdata/pcommon/generated_uint64slice_test.go b/pdata/pcommon/generated_uint64slice_test.go index 2165bbfd822..44ea2bee200 100644 --- a/pdata/pcommon/generated_uint64slice_test.go +++ b/pdata/pcommon/generated_uint64slice_test.go @@ -52,7 +52,7 @@ func TestUInt64SliceReadOnly(t *testing.T) { raw := []uint64{1, 2, 3} sharedState := internal.NewState() sharedState.MarkReadOnly() - ms := UInt64Slice(internal.NewUInt64Slice(&raw, sharedState)) + ms := UInt64Slice(internal.NewUInt64SliceWrapper(&raw, sharedState)) assert.Equal(t, 3, ms.Len()) assert.Equal(t, uint64(1), ms.At(0)) diff --git a/pdata/pcommon/map.go b/pdata/pcommon/map.go index 9175dd0ea03..b5d94967c28 100644 --- a/pdata/pcommon/map.go +++ b/pdata/pcommon/map.go @@ -9,31 +9,30 @@ import ( "go.uber.org/multierr" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // Map stores a map of string keys to elements of Value type. // // Must use NewMap function to create new instances. // Important: zero-initialized instance is not valid for use. -type Map internal.Map +type Map internal.MapWrapper // NewMap creates a Map with 0 elements. func NewMap() Map { - orig := []otlpcommon.KeyValue(nil) - return Map(internal.NewMap(&orig, internal.NewState())) + orig := []internal.KeyValue(nil) + return Map(internal.NewMapWrapper(&orig, internal.NewState())) } -func (m Map) getOrig() *[]otlpcommon.KeyValue { - return internal.GetOrigMap(internal.Map(m)) +func (m Map) getOrig() *[]internal.KeyValue { + return internal.GetMapOrig(internal.MapWrapper(m)) } func (m Map) getState() *internal.State { - return internal.GetMapState(internal.Map(m)) + return internal.GetMapState(internal.MapWrapper(m)) } -func newMap(orig *[]otlpcommon.KeyValue, state *internal.State) Map { - return Map(internal.NewMap(orig, state)) +func newMap(orig *[]internal.KeyValue, state *internal.State) Map { + return Map(internal.NewMapWrapper(orig, state)) } // Clear erases any existing entries in this Map instance. @@ -50,7 +49,7 @@ func (m Map) EnsureCapacity(capacity int) { if capacity <= cap(oldOrig) { return } - *m.getOrig() = make([]otlpcommon.KeyValue, len(oldOrig), capacity) + *m.getOrig() = make([]internal.KeyValue, len(oldOrig), capacity) copy(*m.getOrig(), oldOrig) } @@ -94,7 +93,7 @@ func (m Map) RemoveIf(f func(string, Value) bool) { newLen := 0 for i := 0; i < len(*m.getOrig()); i++ { if f((*m.getOrig())[i].Key, newValue(&(*m.getOrig())[i].Value, m.getState())) { - (*m.getOrig())[i] = otlpcommon.KeyValue{} + (*m.getOrig())[i] = internal.KeyValue{} continue } if newLen == i { @@ -103,7 +102,7 @@ func (m Map) RemoveIf(f func(string, Value) bool) { continue } (*m.getOrig())[newLen] = (*m.getOrig())[i] - (*m.getOrig())[i] = otlpcommon.KeyValue{} + (*m.getOrig())[i] = internal.KeyValue{} newLen++ } *m.getOrig() = (*m.getOrig())[:newLen] @@ -117,7 +116,7 @@ func (m Map) PutEmpty(k string) Value { av.getOrig().Value = nil return newValue(av.getOrig(), m.getState()) } - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k}) + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k}) return newValue(&(*m.getOrig())[len(*m.getOrig())-1].Value, m.getState()) } @@ -129,7 +128,7 @@ func (m Map) GetOrPutEmpty(k string) (Value, bool) { if av, existing := m.Get(k); existing { return av, true } - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k}) + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k}) return newValue(&(*m.getOrig())[len(*m.getOrig())-1].Value, m.getState()), false } @@ -142,9 +141,9 @@ func (m Map) PutStr(k, v string) { av.SetStr(v) return } - ov := internal.NewOrigAnyValueStringValue() + ov := internal.NewAnyValueStringValue() ov.StringValue = v - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) } // PutInt performs the Insert or Update action. The int Value is @@ -156,9 +155,9 @@ func (m Map) PutInt(k string, v int64) { av.SetInt(v) return } - ov := internal.NewOrigAnyValueIntValue() + ov := internal.NewAnyValueIntValue() ov.IntValue = v - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) } // PutDouble performs the Insert or Update action. The double Value is @@ -170,9 +169,9 @@ func (m Map) PutDouble(k string, v float64) { av.SetDouble(v) return } - ov := internal.NewOrigAnyValueDoubleValue() + ov := internal.NewAnyValueDoubleValue() ov.DoubleValue = v - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) } // PutBool performs the Insert or Update action. The bool Value is @@ -184,9 +183,9 @@ func (m Map) PutBool(k string, v bool) { av.SetBool(v) return } - ov := internal.NewOrigAnyValueBoolValue() + ov := internal.NewAnyValueBoolValue() ov.BoolValue = v - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) } // PutEmptyBytes inserts or updates an empty byte slice under given key and returns it. @@ -195,9 +194,9 @@ func (m Map) PutEmptyBytes(k string) ByteSlice { if av, existing := m.Get(k); existing { return av.SetEmptyBytes() } - ov := internal.NewOrigAnyValueBytesValue() - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) - return ByteSlice(internal.NewByteSlice(&ov.BytesValue, m.getState())) + ov := internal.NewAnyValueBytesValue() + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) + return ByteSlice(internal.NewByteSliceWrapper(&ov.BytesValue, m.getState())) } // PutEmptyMap inserts or updates an empty map under given key and returns it. @@ -206,10 +205,10 @@ func (m Map) PutEmptyMap(k string) Map { if av, existing := m.Get(k); existing { return av.SetEmptyMap() } - ov := internal.NewOrigAnyValueKvlistValue() - ov.KvlistValue = internal.NewOrigKeyValueList() - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) - return Map(internal.NewMap(&ov.KvlistValue.Values, m.getState())) + ov := internal.NewAnyValueKvlistValue() + ov.KvlistValue = internal.NewKeyValueList() + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) + return Map(internal.NewMapWrapper(&ov.KvlistValue.Values, m.getState())) } // PutEmptySlice inserts or updates an empty slice under given key and returns it. @@ -218,10 +217,10 @@ func (m Map) PutEmptySlice(k string) Slice { if av, existing := m.Get(k); existing { return av.SetEmptySlice() } - ov := internal.NewOrigAnyValueArrayValue() - ov.ArrayValue = internal.NewOrigArrayValue() - *m.getOrig() = append(*m.getOrig(), otlpcommon.KeyValue{Key: k, Value: otlpcommon.AnyValue{Value: ov}}) - return Slice(internal.NewSlice(&ov.ArrayValue.Values, m.getState())) + ov := internal.NewAnyValueArrayValue() + ov.ArrayValue = internal.NewArrayValue() + *m.getOrig() = append(*m.getOrig(), internal.KeyValue{Key: k, Value: internal.AnyValue{Value: ov}}) + return Slice(internal.NewSliceWrapper(&ov.ArrayValue.Values, m.getState())) } // Len returns the length of this map. @@ -242,7 +241,7 @@ func (m Map) Len() int { func (m Map) Range(f func(k string, v Value) bool) { for i := range *m.getOrig() { kv := &(*m.getOrig())[i] - if !f(kv.Key, Value(internal.NewValue(&kv.Value, m.getState()))) { + if !f(kv.Key, Value(internal.NewValueWrapper(&kv.Value, m.getState()))) { break } } @@ -257,7 +256,7 @@ func (m Map) All() iter.Seq2[string, Value] { return func(yield func(string, Value) bool) { for i := range *m.getOrig() { kv := &(*m.getOrig())[i] - if !yield(kv.Key, Value(internal.NewValue(&kv.Value, m.getState()))) { + if !yield(kv.Key, Value(internal.NewValueWrapper(&kv.Value, m.getState()))) { return } } @@ -283,7 +282,7 @@ func (m Map) CopyTo(dest Map) { if m.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigKeyValueSlice(*dest.getOrig(), *m.getOrig()) + *dest.getOrig() = internal.CopyKeyValueSlice(*dest.getOrig(), *m.getOrig()) } // AsRaw returns a standard go map representation of this Map. @@ -305,7 +304,7 @@ func (m Map) FromRaw(rawMap map[string]any) error { } var errs error - origs := make([]otlpcommon.KeyValue, len(rawMap)) + origs := make([]internal.KeyValue, len(rawMap)) ix := 0 for k, iv := range rawMap { origs[ix].Key = k diff --git a/pdata/pcommon/map_test.go b/pdata/pcommon/map_test.go index 1a8eb0cd53f..b54d4a9b5f2 100644 --- a/pdata/pcommon/map_test.go +++ b/pdata/pcommon/map_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestMap(t *testing.T) { @@ -56,8 +55,8 @@ func TestMap(t *testing.T) { func TestMapReadOnly(t *testing.T) { state := internal.NewState() state.MarkReadOnly() - m := newMap(&[]otlpcommon.KeyValue{ - {Key: "k1", Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "v1"}}}, + m := newMap(&[]internal.KeyValue{ + {Key: "k1", Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "v1"}}}, }, state) assert.Equal(t, 1, m.Len()) @@ -197,15 +196,15 @@ func TestMapPutEmptyBytes(t *testing.T) { } func TestMapWithEmpty(t *testing.T) { - origWithNil := []otlpcommon.KeyValue{ + origWithNil := []internal.KeyValue{ {}, { Key: "test_key", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "test_value"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "test_value"}}, }, { Key: "test_key2", - Value: otlpcommon.AnyValue{Value: nil}, + Value: internal.AnyValue{Value: nil}, }, } sm := newMap(&origWithNil, internal.NewState()) @@ -427,9 +426,9 @@ func TestMap_MoveTo(t *testing.T) { assert.Equal(t, 0, dest.Len()) // Test MoveTo larger slice - src := Map(internal.GenerateTestMap()) + src := Map(internal.GenTestMapWrapper()) src.MoveTo(dest) - assert.Equal(t, Map(internal.GenerateTestMap()), dest) + assert.Equal(t, Map(internal.GenTestMapWrapper()), dest) assert.Equal(t, 0, src.Len()) // Test MoveTo from empty to non-empty @@ -449,29 +448,29 @@ func TestMap_CopyTo(t *testing.T) { assert.Equal(t, 0, dest.Len()) // Test CopyTo larger slice - Map(internal.GenerateTestMap()).CopyTo(dest) - assert.Equal(t, Map(internal.GenerateTestMap()), dest) + Map(internal.GenTestMapWrapper()).CopyTo(dest) + assert.Equal(t, Map(internal.GenTestMapWrapper()), dest) // Test CopyTo same size slice - Map(internal.GenerateTestMap()).CopyTo(dest) - assert.Equal(t, Map(internal.GenerateTestMap()), dest) + Map(internal.GenTestMapWrapper()).CopyTo(dest) + assert.Equal(t, Map(internal.GenTestMapWrapper()), dest) // Test CopyTo with an empty Value in the destination - (*dest.getOrig())[0].Value = otlpcommon.AnyValue{} - Map(internal.GenerateTestMap()).CopyTo(dest) - assert.Equal(t, Map(internal.GenerateTestMap()), dest) + (*dest.getOrig())[0].Value = internal.AnyValue{} + Map(internal.GenTestMapWrapper()).CopyTo(dest) + assert.Equal(t, Map(internal.GenTestMapWrapper()), dest) // Test CopyTo same size slice dest.CopyTo(dest) - assert.Equal(t, Map(internal.GenerateTestMap()), dest) + assert.Equal(t, Map(internal.GenTestMapWrapper()), dest) } func TestMap_CopyToAndEnsureCapacity(t *testing.T) { dest := NewMap() - src := Map(internal.GenerateTestMap()) + src := Map(internal.GenTestMapWrapper()) dest.EnsureCapacity(src.Len()) src.CopyTo(dest) - assert.Equal(t, Map(internal.GenerateTestMap()), dest) + assert.Equal(t, Map(internal.GenTestMapWrapper()), dest) } func TestMap_EnsureCapacity_Zero(t *testing.T) { @@ -564,7 +563,7 @@ func TestMap_RemoveIf(t *testing.T) { } func TestMap_RemoveIfAll(t *testing.T) { - am := Map(internal.GenerateTestMap()) + am := Map(internal.GenTestMapWrapper()) assert.Equal(t, 5, am.Len()) am.RemoveIf(func(string, Value) bool { return true diff --git a/pdata/pcommon/slice.go b/pdata/pcommon/slice.go index d4276a1d86b..380fc5c1b61 100644 --- a/pdata/pcommon/slice.go +++ b/pdata/pcommon/slice.go @@ -6,7 +6,7 @@ package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" import ( "go.uber.org/multierr" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // AsRaw return []any copy of the Slice. @@ -26,7 +26,7 @@ func (es Slice) FromRaw(rawSlice []any) error { return nil } var errs error - origs := make([]otlpcommon.AnyValue, len(rawSlice)) + origs := make([]internal.AnyValue, len(rawSlice)) for ix, iv := range rawSlice { errs = multierr.Append(errs, newValue(&origs[ix], es.getState()).FromRaw(iv)) } diff --git a/pdata/pcommon/spanid.go b/pdata/pcommon/spanid.go index 63399cb58ca..853c1a2d017 100644 --- a/pdata/pcommon/spanid.go +++ b/pdata/pcommon/spanid.go @@ -5,7 +5,7 @@ package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" import ( "encoding/hex" - "go.opentelemetry.io/collector/pdata/internal/data" + "go.opentelemetry.io/collector/pdata/internal" ) var emptySpanID = SpanID([8]byte{}) @@ -32,5 +32,5 @@ func (ms SpanID) String() string { // IsEmpty returns true if id doesn't contain at least one non-zero byte. func (ms SpanID) IsEmpty() bool { - return data.SpanID(ms).IsEmpty() + return internal.SpanID(ms).IsEmpty() } diff --git a/pdata/pcommon/trace_state.go b/pdata/pcommon/trace_state.go index a78f4ff0c70..167f7a3278c 100644 --- a/pdata/pcommon/trace_state.go +++ b/pdata/pcommon/trace_state.go @@ -11,18 +11,18 @@ import ( // // Must use NewTraceState function to create new instances. // Important: zero-initialized instance is not valid for use. -type TraceState internal.TraceState +type TraceState internal.TraceStateWrapper func NewTraceState() TraceState { - return TraceState(internal.NewTraceState(new(string), internal.NewState())) + return TraceState(internal.NewTraceStateWrapper(new(string), internal.NewState())) } func (ms TraceState) getOrig() *string { - return internal.GetOrigTraceState(internal.TraceState(ms)) + return internal.GetTraceStateOrig(internal.TraceStateWrapper(ms)) } func (ms TraceState) getState() *internal.State { - return internal.GetTraceStateState(internal.TraceState(ms)) + return internal.GetTraceStateState(internal.TraceStateWrapper(ms)) } // AsRaw returns the string representation of the tracestate in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header diff --git a/pdata/pcommon/trace_state_test.go b/pdata/pcommon/trace_state_test.go index aafe2594855..72148fc5dce 100644 --- a/pdata/pcommon/trace_state_test.go +++ b/pdata/pcommon/trace_state_test.go @@ -12,14 +12,14 @@ import ( ) func TestTraceState_MoveTo(t *testing.T) { - ms := TraceState(internal.GenerateTestTraceState()) + ms := TraceState(internal.GenTestTraceStateWrapper()) dest := NewTraceState() ms.MoveTo(dest) assert.Equal(t, NewTraceState(), ms) - assert.Equal(t, TraceState(internal.GenerateTestTraceState()), dest) + assert.Equal(t, TraceState(internal.GenTestTraceStateWrapper()), dest) dest.MoveTo(dest) - assert.Equal(t, TraceState(internal.GenerateTestTraceState()), dest) + assert.Equal(t, TraceState(internal.GenTestTraceStateWrapper()), dest) } func TestTraceState_CopyTo(t *testing.T) { @@ -27,7 +27,7 @@ func TestTraceState_CopyTo(t *testing.T) { orig := NewTraceState() orig.CopyTo(ms) assert.Equal(t, orig, ms) - orig = TraceState(internal.GenerateTestTraceState()) + orig = TraceState(internal.GenTestTraceStateWrapper()) orig.CopyTo(ms) assert.Equal(t, orig, ms) } diff --git a/pdata/pcommon/traceid.go b/pdata/pcommon/traceid.go index 22ad5a5af4e..fd1df45d2c2 100644 --- a/pdata/pcommon/traceid.go +++ b/pdata/pcommon/traceid.go @@ -6,7 +6,7 @@ package pcommon // import "go.opentelemetry.io/collector/pdata/pcommon" import ( "encoding/hex" - "go.opentelemetry.io/collector/pdata/internal/data" + "go.opentelemetry.io/collector/pdata/internal" ) var emptyTraceID = TraceID([16]byte{}) @@ -33,5 +33,5 @@ func (ms TraceID) String() string { // IsEmpty returns true if id doesn't contain at least one non-zero byte. func (ms TraceID) IsEmpty() bool { - return data.TraceID(ms).IsEmpty() + return internal.TraceID(ms).IsEmpty() } diff --git a/pdata/pcommon/value.go b/pdata/pcommon/value.go index ad16e6173a5..f58db8ab5ff 100644 --- a/pdata/pcommon/value.go +++ b/pdata/pcommon/value.go @@ -11,7 +11,6 @@ import ( "strconv" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // ValueType specifies the type of Value. @@ -71,76 +70,76 @@ type Value internal.Value // NewValueEmpty creates a new Value with an empty value. func NewValueEmpty() Value { - return newValue(&otlpcommon.AnyValue{}, internal.NewState()) + return newValue(&internal.AnyValue{}, internal.NewState()) } // NewValueStr creates a new Value with the given string value. func NewValueStr(v string) Value { - ov := internal.NewOrigAnyValueStringValue() + ov := internal.NewAnyValueStringValue() ov.StringValue = v - orig := internal.NewOrigAnyValue() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } // NewValueInt creates a new Value with the given int64 value. func NewValueInt(v int64) Value { - ov := internal.NewOrigAnyValueIntValue() + ov := internal.NewAnyValueIntValue() ov.IntValue = v - orig := internal.NewOrigAnyValue() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } // NewValueDouble creates a new Value with the given float64 value. func NewValueDouble(v float64) Value { - ov := internal.NewOrigAnyValueDoubleValue() + ov := internal.NewAnyValueDoubleValue() ov.DoubleValue = v - orig := internal.NewOrigAnyValue() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } // NewValueBool creates a new Value with the given bool value. func NewValueBool(v bool) Value { - ov := internal.NewOrigAnyValueBoolValue() + ov := internal.NewAnyValueBoolValue() ov.BoolValue = v - orig := internal.NewOrigAnyValue() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } // NewValueMap creates a new Value of map type. func NewValueMap() Value { - ov := internal.NewOrigAnyValueKvlistValue() - ov.KvlistValue = internal.NewOrigKeyValueList() - orig := internal.NewOrigAnyValue() + ov := internal.NewAnyValueKvlistValue() + ov.KvlistValue = internal.NewKeyValueList() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } // NewValueSlice creates a new Value of array type. func NewValueSlice() Value { - ov := internal.NewOrigAnyValueArrayValue() - ov.ArrayValue = internal.NewOrigArrayValue() - orig := internal.NewOrigAnyValue() + ov := internal.NewAnyValueArrayValue() + ov.ArrayValue = internal.NewArrayValue() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } // NewValueBytes creates a new empty Value of byte type. func NewValueBytes() Value { - ov := internal.NewOrigAnyValueBytesValue() - orig := internal.NewOrigAnyValue() + ov := internal.NewAnyValueBytesValue() + orig := internal.NewAnyValue() orig.Value = ov return newValue(orig, internal.NewState()) } -func newValue(orig *otlpcommon.AnyValue, state *internal.State) Value { - return Value(internal.NewValue(orig, state)) +func newValue(orig *internal.AnyValue, state *internal.State) Value { + return Value(internal.NewValueWrapper(orig, state)) } -func (v Value) getOrig() *otlpcommon.AnyValue { +func (v Value) getOrig() *internal.AnyValue { return internal.GetOrigValue(internal.Value(v)) } @@ -200,19 +199,19 @@ func (v Value) FromRaw(iv any) error { // Calling this function on zero-initialized Value will cause a panic. func (v Value) Type() ValueType { switch v.getOrig().Value.(type) { - case *otlpcommon.AnyValue_StringValue: + case *internal.AnyValue_StringValue: return ValueTypeStr - case *otlpcommon.AnyValue_BoolValue: + case *internal.AnyValue_BoolValue: return ValueTypeBool - case *otlpcommon.AnyValue_IntValue: + case *internal.AnyValue_IntValue: return ValueTypeInt - case *otlpcommon.AnyValue_DoubleValue: + case *internal.AnyValue_DoubleValue: return ValueTypeDouble - case *otlpcommon.AnyValue_KvlistValue: + case *internal.AnyValue_KvlistValue: return ValueTypeMap - case *otlpcommon.AnyValue_ArrayValue: + case *internal.AnyValue_ArrayValue: return ValueTypeSlice - case *otlpcommon.AnyValue_BytesValue: + case *internal.AnyValue_BytesValue: return ValueTypeBytes } return ValueTypeEmpty @@ -269,11 +268,11 @@ func (v Value) Slice() Slice { // If the function is called on zero-initialized Value or if the Type() is not ValueTypeBytes // then returns an invalid ByteSlice object. Note that using such slice can cause panic. func (v Value) Bytes() ByteSlice { - bv, ok := v.getOrig().GetValue().(*otlpcommon.AnyValue_BytesValue) + bv, ok := v.getOrig().GetValue().(*internal.AnyValue_BytesValue) if !ok { return ByteSlice{} } - return ByteSlice(internal.NewByteSlice(&bv.BytesValue, internal.GetValueState(internal.Value(v)))) + return ByteSlice(internal.NewByteSliceWrapper(&bv.BytesValue, internal.GetValueState(internal.Value(v)))) } // SetStr replaces the string value associated with this Value, @@ -284,8 +283,8 @@ func (v Value) Bytes() ByteSlice { func (v Value) SetStr(sv string) { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - ov := internal.NewOrigAnyValueStringValue() + internal.DeleteAnyValue(v.getOrig(), false) + ov := internal.NewAnyValueStringValue() ov.StringValue = sv v.getOrig().Value = ov } @@ -296,8 +295,8 @@ func (v Value) SetStr(sv string) { func (v Value) SetInt(iv int64) { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - ov := internal.NewOrigAnyValueIntValue() + internal.DeleteAnyValue(v.getOrig(), false) + ov := internal.NewAnyValueIntValue() ov.IntValue = iv v.getOrig().Value = ov } @@ -308,8 +307,8 @@ func (v Value) SetInt(iv int64) { func (v Value) SetDouble(dv float64) { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - ov := internal.NewOrigAnyValueDoubleValue() + internal.DeleteAnyValue(v.getOrig(), false) + ov := internal.NewAnyValueDoubleValue() ov.DoubleValue = dv v.getOrig().Value = ov } @@ -320,8 +319,8 @@ func (v Value) SetDouble(dv float64) { func (v Value) SetBool(bv bool) { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - ov := internal.NewOrigAnyValueBoolValue() + internal.DeleteAnyValue(v.getOrig(), false) + ov := internal.NewAnyValueBoolValue() ov.BoolValue = bv v.getOrig().Value = ov } @@ -331,10 +330,10 @@ func (v Value) SetBool(bv bool) { func (v Value) SetEmptyBytes() ByteSlice { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - bv := internal.NewOrigAnyValueBytesValue() + internal.DeleteAnyValue(v.getOrig(), false) + bv := internal.NewAnyValueBytesValue() v.getOrig().Value = bv - return ByteSlice(internal.NewByteSlice(&bv.BytesValue, v.getState())) + return ByteSlice(internal.NewByteSliceWrapper(&bv.BytesValue, v.getState())) } // SetEmptyMap sets value to an empty map and returns it. @@ -342,9 +341,9 @@ func (v Value) SetEmptyBytes() ByteSlice { func (v Value) SetEmptyMap() Map { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - ov := internal.NewOrigAnyValueKvlistValue() - ov.KvlistValue = internal.NewOrigKeyValueList() + internal.DeleteAnyValue(v.getOrig(), false) + ov := internal.NewAnyValueKvlistValue() + ov.KvlistValue = internal.NewKeyValueList() v.getOrig().Value = ov return newMap(&ov.KvlistValue.Values, v.getState()) } @@ -354,9 +353,9 @@ func (v Value) SetEmptyMap() Map { func (v Value) SetEmptySlice() Slice { v.getState().AssertMutable() // Delete everything but the AnyValue object itself. - internal.DeleteOrigAnyValue(v.getOrig(), false) - ov := internal.NewOrigAnyValueArrayValue() - ov.ArrayValue = internal.NewOrigArrayValue() + internal.DeleteAnyValue(v.getOrig(), false) + ov := internal.NewAnyValueArrayValue() + ov.ArrayValue = internal.NewArrayValue() v.getOrig().Value = ov return newSlice(&ov.ArrayValue.Values, v.getState()) } @@ -379,7 +378,7 @@ func (v Value) MoveTo(dest Value) { // Calling this function on zero-initialized Value will cause a panic. func (v Value) CopyTo(dest Value) { dest.getState().AssertMutable() - internal.CopyOrigAnyValue(dest.getOrig(), v.getOrig()) + internal.CopyAnyValue(dest.getOrig(), v.getOrig()) } // AsString converts an OTLP Value object of any type to its equivalent string diff --git a/pdata/pcommon/value_test.go b/pdata/pcommon/value_test.go index ac424a56ac9..7eff1cacdfa 100644 --- a/pdata/pcommon/value_test.go +++ b/pdata/pcommon/value_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestValue(t *testing.T) { @@ -48,7 +47,7 @@ func TestValue(t *testing.T) { func TestValueReadOnly(t *testing.T) { state := internal.NewState() state.MarkReadOnly() - v := newValue(&otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "v"}}, state) + v := newValue(&internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "v"}}, state) assert.Equal(t, ValueTypeStr, v.Type()) assert.Equal(t, "v", v.Str()) @@ -157,8 +156,8 @@ func TestValueMap(t *testing.T) { _, exists = m1.Map().Get("child_map") assert.False(t, exists) - // Test nil KvlistValue case for Map() func. - orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_KvlistValue{KvlistValue: nil}} + // Test nil KvlistValue case for MapWrapper() func. + orig := &internal.AnyValue{Value: &internal.AnyValue_KvlistValue{KvlistValue: nil}} m1 = newValue(orig, internal.NewState()) assert.Equal(t, Map{}, m1.Map()) } @@ -196,7 +195,7 @@ func TestValueSlice(t *testing.T) { assert.Equal(t, "somestr", v.Str()) // Test nil values case for Slice() func. - a1 = newValue(&otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: nil}}, internal.NewState()) + a1 = newValue(&internal.AnyValue{Value: &internal.AnyValue_ArrayValue{ArrayValue: nil}}, internal.NewState()) assert.Equal(t, newSlice(nil, nil), a1.Slice()) } @@ -250,15 +249,15 @@ func TestValue_MoveTo(t *testing.T) { func TestValue_CopyTo(t *testing.T) { dest := NewValueEmpty() - orig := internal.GenTestOrigAnyValue() + orig := internal.GenTestAnyValue() newValue(orig, internal.NewState()).CopyTo(dest) - assert.Equal(t, internal.GenTestOrigAnyValue(), dest.getOrig()) + assert.Equal(t, internal.GenTestAnyValue(), dest.getOrig()) } func TestSliceWithNilValues(t *testing.T) { - origWithNil := []otlpcommon.AnyValue{ + origWithNil := []internal.AnyValue{ {}, - {Value: &otlpcommon.AnyValue_StringValue{StringValue: "test_value"}}, + {Value: &internal.AnyValue_StringValue{StringValue: "test_value"}}, } sm := newSlice(&origWithNil, internal.NewState()) @@ -572,7 +571,9 @@ func TestInvalidValue(t *testing.T) { assert.Panics(t, func() { v.SetEmptyBytes() }) assert.Panics(t, func() { v.SetEmptyMap() }) assert.Panics(t, func() { v.SetEmptySlice() }) - assert.Panics(t, func() { v.CopyTo(NewValueEmpty()) }) + nv := NewValueEmpty() + v.CopyTo(nv) + assert.Nil(t, nv.getOrig().Value) } func TestValueEqual(t *testing.T) { diff --git a/pdata/plog/generated_logrecord.go b/pdata/plog/generated_logrecord.go index 4585c326a1d..80910c903fc 100644 --- a/pdata/plog/generated_logrecord.go +++ b/pdata/plog/generated_logrecord.go @@ -8,8 +8,6 @@ package plog import ( "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -21,11 +19,11 @@ import ( // Must use NewLogRecord function to create new instances. // Important: zero-initialized instance is not valid for use. type LogRecord struct { - orig *otlplogs.LogRecord + orig *internal.LogRecord state *internal.State } -func newLogRecord(orig *otlplogs.LogRecord, state *internal.State) LogRecord { +func newLogRecord(orig *internal.LogRecord, state *internal.State) LogRecord { return LogRecord{orig: orig, state: state} } @@ -34,7 +32,7 @@ func newLogRecord(orig *otlplogs.LogRecord, state *internal.State) LogRecord { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewLogRecord() LogRecord { - return newLogRecord(internal.NewOrigLogRecord(), internal.NewState()) + return newLogRecord(internal.NewLogRecord(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -46,7 +44,7 @@ func (ms LogRecord) MoveTo(dest LogRecord) { if ms.orig == dest.orig { return } - internal.DeleteOrigLogRecord(dest.orig, false) + internal.DeleteLogRecord(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -80,7 +78,7 @@ func (ms LogRecord) SeverityNumber() SeverityNumber { // SetSeverityNumber replaces the severitynumber associated with this LogRecord. func (ms LogRecord) SetSeverityNumber(v SeverityNumber) { ms.state.AssertMutable() - ms.orig.SeverityNumber = otlplogs.SeverityNumber(v) + ms.orig.SeverityNumber = internal.SeverityNumber(v) } // SeverityText returns the severitytext associated with this LogRecord. @@ -96,12 +94,12 @@ func (ms LogRecord) SetSeverityText(v string) { // Body returns the body associated with this LogRecord. func (ms LogRecord) Body() pcommon.Value { - return pcommon.Value(internal.NewValue(&ms.orig.Body, ms.state)) + return pcommon.Value(internal.NewValueWrapper(&ms.orig.Body, ms.state)) } // Attributes returns the Attributes associated with this LogRecord. func (ms LogRecord) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // DroppedAttributesCount returns the droppedattributescount associated with this LogRecord. @@ -134,7 +132,7 @@ func (ms LogRecord) TraceID() pcommon.TraceID { // SetTraceID replaces the traceid associated with this LogRecord. func (ms LogRecord) SetTraceID(v pcommon.TraceID) { ms.state.AssertMutable() - ms.orig.TraceId = data.TraceID(v) + ms.orig.TraceId = internal.TraceID(v) } // SpanID returns the spanid associated with this LogRecord. @@ -145,7 +143,7 @@ func (ms LogRecord) SpanID() pcommon.SpanID { // SetSpanID replaces the spanid associated with this LogRecord. func (ms LogRecord) SetSpanID(v pcommon.SpanID) { ms.state.AssertMutable() - ms.orig.SpanId = data.SpanID(v) + ms.orig.SpanId = internal.SpanID(v) } // EventName returns the eventname associated with this LogRecord. @@ -162,5 +160,5 @@ func (ms LogRecord) SetEventName(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms LogRecord) CopyTo(dest LogRecord) { dest.state.AssertMutable() - internal.CopyOrigLogRecord(dest.orig, ms.orig) + internal.CopyLogRecord(dest.orig, ms.orig) } diff --git a/pdata/plog/generated_logrecord_test.go b/pdata/plog/generated_logrecord_test.go index c7a6f803974..4d62762de44 100644 --- a/pdata/plog/generated_logrecord_test.go +++ b/pdata/plog/generated_logrecord_test.go @@ -12,8 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,8 +25,8 @@ func TestLogRecord_MoveTo(t *testing.T) { assert.Equal(t, generateTestLogRecord(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newLogRecord(internal.NewOrigLogRecord(), sharedState)) }) - assert.Panics(t, func() { newLogRecord(internal.NewOrigLogRecord(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newLogRecord(internal.NewLogRecord(), sharedState)) }) + assert.Panics(t, func() { newLogRecord(internal.NewLogRecord(), sharedState).MoveTo(dest) }) } func TestLogRecord_CopyTo(t *testing.T) { @@ -41,7 +39,7 @@ func TestLogRecord_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newLogRecord(internal.NewOrigLogRecord(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newLogRecord(internal.NewLogRecord(), sharedState)) }) } func TestLogRecord_Timestamp(t *testing.T) { @@ -62,8 +60,8 @@ func TestLogRecord_ObservedTimestamp(t *testing.T) { func TestLogRecord_SeverityNumber(t *testing.T) { ms := NewLogRecord() - assert.Equal(t, SeverityNumber(otlplogs.SeverityNumber(0)), ms.SeverityNumber()) - testValSeverityNumber := SeverityNumber(otlplogs.SeverityNumber(5)) + assert.Equal(t, SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED), ms.SeverityNumber()) + testValSeverityNumber := SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_DEBUG) ms.SetSeverityNumber(testValSeverityNumber) assert.Equal(t, testValSeverityNumber, ms.SeverityNumber()) } @@ -75,21 +73,21 @@ func TestLogRecord_SeverityText(t *testing.T) { assert.Equal(t, "test_severitytext", ms.SeverityText()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLogRecord(&otlplogs.LogRecord{}, sharedState).SetSeverityText("test_severitytext") }) + assert.Panics(t, func() { newLogRecord(internal.NewLogRecord(), sharedState).SetSeverityText("test_severitytext") }) } func TestLogRecord_Body(t *testing.T) { ms := NewLogRecord() assert.Equal(t, pcommon.NewValueEmpty(), ms.Body()) - ms.orig.Body = *internal.GenTestOrigAnyValue() - assert.Equal(t, pcommon.Value(internal.NewValue(internal.GenTestOrigAnyValue(), ms.state)), ms.Body()) + ms.orig.Body = *internal.GenTestAnyValue() + assert.Equal(t, pcommon.Value(internal.GenTestValueWrapper()), ms.Body()) } func TestLogRecord_Attributes(t *testing.T) { ms := NewLogRecord() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestLogRecord_DroppedAttributesCount(t *testing.T) { @@ -99,7 +97,7 @@ func TestLogRecord_DroppedAttributesCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLogRecord(&otlplogs.LogRecord{}, sharedState).SetDroppedAttributesCount(uint32(13)) }) + assert.Panics(t, func() { newLogRecord(internal.NewLogRecord(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func TestLogRecord_Flags(t *testing.T) { @@ -112,16 +110,16 @@ func TestLogRecord_Flags(t *testing.T) { func TestLogRecord_TraceID(t *testing.T) { ms := NewLogRecord() - assert.Equal(t, pcommon.TraceID(data.TraceID([16]byte{})), ms.TraceID()) - testValTraceID := pcommon.TraceID(data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.TraceID(internal.TraceID([16]byte{})), ms.TraceID()) + testValTraceID := pcommon.TraceID(internal.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) ms.SetTraceID(testValTraceID) assert.Equal(t, testValTraceID, ms.TraceID()) } func TestLogRecord_SpanID(t *testing.T) { ms := NewLogRecord() - assert.Equal(t, pcommon.SpanID(data.SpanID([8]byte{})), ms.SpanID()) - testValSpanID := pcommon.SpanID(data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.SpanID(internal.SpanID([8]byte{})), ms.SpanID()) + testValSpanID := pcommon.SpanID(internal.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) ms.SetSpanID(testValSpanID) assert.Equal(t, testValSpanID, ms.SpanID()) } @@ -133,10 +131,9 @@ func TestLogRecord_EventName(t *testing.T) { assert.Equal(t, "test_eventname", ms.EventName()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLogRecord(&otlplogs.LogRecord{}, sharedState).SetEventName("test_eventname") }) + assert.Panics(t, func() { newLogRecord(internal.NewLogRecord(), sharedState).SetEventName("test_eventname") }) } func generateTestLogRecord() LogRecord { - ms := newLogRecord(internal.GenTestOrigLogRecord(), internal.NewState()) - return ms + return newLogRecord(internal.GenTestLogRecord(), internal.NewState()) } diff --git a/pdata/plog/generated_logrecordslice.go b/pdata/plog/generated_logrecordslice.go index cc06afe99be..f28c9f21bdc 100644 --- a/pdata/plog/generated_logrecordslice.go +++ b/pdata/plog/generated_logrecordslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // LogRecordSlice logically represents a slice of LogRecord. @@ -22,18 +21,18 @@ import ( // Must use NewLogRecordSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LogRecordSlice struct { - orig *[]*otlplogs.LogRecord + orig *[]*internal.LogRecord state *internal.State } -func newLogRecordSlice(orig *[]*otlplogs.LogRecord, state *internal.State) LogRecordSlice { +func newLogRecordSlice(orig *[]*internal.LogRecord, state *internal.State) LogRecordSlice { return LogRecordSlice{orig: orig, state: state} } // NewLogRecordSlice creates a LogRecordSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLogRecordSlice() LogRecordSlice { - orig := []*otlplogs.LogRecord(nil) + orig := []*internal.LogRecord(nil) return newLogRecordSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es LogRecordSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlplogs.LogRecord, len(*es.orig), newCap) + newOrig := make([]*internal.LogRecord, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es LogRecordSlice) EnsureCapacity(newCap int) { // It returns the newly added LogRecord. func (es LogRecordSlice) AppendEmpty() LogRecord { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigLogRecord()) + *es.orig = append(*es.orig, internal.NewLogRecord()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es LogRecordSlice) RemoveIf(f func(LogRecord) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigLogRecord((*es.orig)[i], true) + internal.DeleteLogRecord((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es LogRecordSlice) CopyTo(dest LogRecordSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigLogRecordSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyLogRecordPtrSlice(*dest.orig, *es.orig) } // Sort sorts the LogRecord elements within LogRecordSlice given the diff --git a/pdata/plog/generated_logrecordslice_test.go b/pdata/plog/generated_logrecordslice_test.go index 54e39b158ef..102b785feab 100644 --- a/pdata/plog/generated_logrecordslice_test.go +++ b/pdata/plog/generated_logrecordslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) func TestLogRecordSlice(t *testing.T) { es := NewLogRecordSlice() assert.Equal(t, 0, es.Len()) - es = newLogRecordSlice(&[]*otlplogs.LogRecord{}, internal.NewState()) + es = newLogRecordSlice(&[]*internal.LogRecord{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewLogRecord() @@ -27,7 +26,7 @@ func TestLogRecordSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigLogRecord() + (*es.orig)[i] = internal.GenTestLogRecord() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestLogRecordSlice(t *testing.T) { func TestLogRecordSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newLogRecordSlice(&[]*otlplogs.LogRecord{}, sharedState) + es := newLogRecordSlice(&[]*internal.LogRecord{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestLogRecordSlice_Sort(t *testing.T) { func generateTestLogRecordSlice() LogRecordSlice { ms := NewLogRecordSlice() - *ms.orig = internal.GenerateOrigTestLogRecordSlice() + *ms.orig = internal.GenTestLogRecordPtrSlice() return ms } diff --git a/pdata/plog/generated_logs.go b/pdata/plog/generated_logs.go index 2bd4ee199f2..238ed8764d5 100644 --- a/pdata/plog/generated_logs.go +++ b/pdata/plog/generated_logs.go @@ -8,7 +8,6 @@ package plog import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" ) // Logs is the top-level struct that is propagated through the logs pipeline. @@ -19,10 +18,10 @@ import ( // // Must use NewLogs function to create new instances. // Important: zero-initialized instance is not valid for use. -type Logs internal.Logs +type Logs internal.LogsWrapper -func newLogs(orig *otlpcollectorlogs.ExportLogsServiceRequest, state *internal.State) Logs { - return Logs(internal.NewLogs(orig, state)) +func newLogs(orig *internal.ExportLogsServiceRequest, state *internal.State) Logs { + return Logs(internal.NewLogsWrapper(orig, state)) } // NewLogs creates a new empty Logs. @@ -30,7 +29,7 @@ func newLogs(orig *otlpcollectorlogs.ExportLogsServiceRequest, state *internal.S // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewLogs() Logs { - return newLogs(internal.NewOrigExportLogsServiceRequest(), internal.NewState()) + return newLogs(internal.NewExportLogsServiceRequest(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -42,7 +41,7 @@ func (ms Logs) MoveTo(dest Logs) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigExportLogsServiceRequest(dest.getOrig(), false) + internal.DeleteExportLogsServiceRequest(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } @@ -54,13 +53,13 @@ func (ms Logs) ResourceLogs() ResourceLogsSlice { // CopyTo copies all properties from the current struct overriding the destination. func (ms Logs) CopyTo(dest Logs) { dest.getState().AssertMutable() - internal.CopyOrigExportLogsServiceRequest(dest.getOrig(), ms.getOrig()) + internal.CopyExportLogsServiceRequest(dest.getOrig(), ms.getOrig()) } -func (ms Logs) getOrig() *otlpcollectorlogs.ExportLogsServiceRequest { - return internal.GetOrigLogs(internal.Logs(ms)) +func (ms Logs) getOrig() *internal.ExportLogsServiceRequest { + return internal.GetLogsOrig(internal.LogsWrapper(ms)) } func (ms Logs) getState() *internal.State { - return internal.GetLogsState(internal.Logs(ms)) + return internal.GetLogsState(internal.LogsWrapper(ms)) } diff --git a/pdata/plog/generated_logs_test.go b/pdata/plog/generated_logs_test.go index c379bf15091..b64e4e46feb 100644 --- a/pdata/plog/generated_logs_test.go +++ b/pdata/plog/generated_logs_test.go @@ -24,8 +24,8 @@ func TestLogs_MoveTo(t *testing.T) { assert.Equal(t, generateTestLogs(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newLogs(internal.NewOrigExportLogsServiceRequest(), sharedState)) }) - assert.Panics(t, func() { newLogs(internal.NewOrigExportLogsServiceRequest(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newLogs(internal.NewExportLogsServiceRequest(), sharedState)) }) + assert.Panics(t, func() { newLogs(internal.NewExportLogsServiceRequest(), sharedState).MoveTo(dest) }) } func TestLogs_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestLogs_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newLogs(internal.NewOrigExportLogsServiceRequest(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newLogs(internal.NewExportLogsServiceRequest(), sharedState)) }) } func TestLogs_ResourceLogs(t *testing.T) { ms := NewLogs() assert.Equal(t, NewResourceLogsSlice(), ms.ResourceLogs()) - ms.getOrig().ResourceLogs = internal.GenerateOrigTestResourceLogsSlice() + ms.getOrig().ResourceLogs = internal.GenTestResourceLogsPtrSlice() assert.Equal(t, generateTestResourceLogsSlice(), ms.ResourceLogs()) } func generateTestLogs() Logs { - ms := newLogs(internal.GenTestOrigExportLogsServiceRequest(), internal.NewState()) - return ms + return newLogs(internal.GenTestExportLogsServiceRequest(), internal.NewState()) } diff --git a/pdata/plog/generated_resourcelogs.go b/pdata/plog/generated_resourcelogs.go index 2283d5451b7..b3b64ff4461 100644 --- a/pdata/plog/generated_resourcelogs.go +++ b/pdata/plog/generated_resourcelogs.go @@ -8,7 +8,6 @@ package plog import ( "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewResourceLogs function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceLogs struct { - orig *otlplogs.ResourceLogs + orig *internal.ResourceLogs state *internal.State } -func newResourceLogs(orig *otlplogs.ResourceLogs, state *internal.State) ResourceLogs { +func newResourceLogs(orig *internal.ResourceLogs, state *internal.State) ResourceLogs { return ResourceLogs{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newResourceLogs(orig *otlplogs.ResourceLogs, state *internal.State) Resourc // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewResourceLogs() ResourceLogs { - return newResourceLogs(internal.NewOrigResourceLogs(), internal.NewState()) + return newResourceLogs(internal.NewResourceLogs(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ResourceLogs) MoveTo(dest ResourceLogs) { if ms.orig == dest.orig { return } - internal.DeleteOrigResourceLogs(dest.orig, false) + internal.DeleteResourceLogs(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Resource returns the resource associated with this ResourceLogs. func (ms ResourceLogs) Resource() pcommon.Resource { - return pcommon.Resource(internal.NewResource(&ms.orig.Resource, ms.state)) + return pcommon.Resource(internal.NewResourceWrapper(&ms.orig.Resource, ms.state)) } // ScopeLogs returns the ScopeLogs associated with this ResourceLogs. @@ -73,5 +72,5 @@ func (ms ResourceLogs) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ResourceLogs) CopyTo(dest ResourceLogs) { dest.state.AssertMutable() - internal.CopyOrigResourceLogs(dest.orig, ms.orig) + internal.CopyResourceLogs(dest.orig, ms.orig) } diff --git a/pdata/plog/generated_resourcelogs_test.go b/pdata/plog/generated_resourcelogs_test.go index 52d7f4612ac..9a03831e19a 100644 --- a/pdata/plog/generated_resourcelogs_test.go +++ b/pdata/plog/generated_resourcelogs_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestResourceLogs_MoveTo(t *testing.T) { assert.Equal(t, generateTestResourceLogs(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newResourceLogs(internal.NewOrigResourceLogs(), sharedState)) }) - assert.Panics(t, func() { newResourceLogs(internal.NewOrigResourceLogs(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newResourceLogs(internal.NewResourceLogs(), sharedState)) }) + assert.Panics(t, func() { newResourceLogs(internal.NewResourceLogs(), sharedState).MoveTo(dest) }) } func TestResourceLogs_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestResourceLogs_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newResourceLogs(internal.NewOrigResourceLogs(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newResourceLogs(internal.NewResourceLogs(), sharedState)) }) } func TestResourceLogs_Resource(t *testing.T) { ms := NewResourceLogs() assert.Equal(t, pcommon.NewResource(), ms.Resource()) - ms.orig.Resource = *internal.GenTestOrigResource() - assert.Equal(t, pcommon.Resource(internal.NewResource(internal.GenTestOrigResource(), ms.state)), ms.Resource()) + ms.orig.Resource = *internal.GenTestResource() + assert.Equal(t, pcommon.Resource(internal.GenTestResourceWrapper()), ms.Resource()) } func TestResourceLogs_ScopeLogs(t *testing.T) { ms := NewResourceLogs() assert.Equal(t, NewScopeLogsSlice(), ms.ScopeLogs()) - ms.orig.ScopeLogs = internal.GenerateOrigTestScopeLogsSlice() + ms.orig.ScopeLogs = internal.GenTestScopeLogsPtrSlice() assert.Equal(t, generateTestScopeLogsSlice(), ms.ScopeLogs()) } @@ -64,10 +63,9 @@ func TestResourceLogs_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newResourceLogs(&otlplogs.ResourceLogs{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newResourceLogs(internal.NewResourceLogs(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestResourceLogs() ResourceLogs { - ms := newResourceLogs(internal.GenTestOrigResourceLogs(), internal.NewState()) - return ms + return newResourceLogs(internal.GenTestResourceLogs(), internal.NewState()) } diff --git a/pdata/plog/generated_resourcelogsslice.go b/pdata/plog/generated_resourcelogsslice.go index eb358473850..3c4a1aaba13 100644 --- a/pdata/plog/generated_resourcelogsslice.go +++ b/pdata/plog/generated_resourcelogsslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // ResourceLogsSlice logically represents a slice of ResourceLogs. @@ -22,18 +21,18 @@ import ( // Must use NewResourceLogsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceLogsSlice struct { - orig *[]*otlplogs.ResourceLogs + orig *[]*internal.ResourceLogs state *internal.State } -func newResourceLogsSlice(orig *[]*otlplogs.ResourceLogs, state *internal.State) ResourceLogsSlice { +func newResourceLogsSlice(orig *[]*internal.ResourceLogs, state *internal.State) ResourceLogsSlice { return ResourceLogsSlice{orig: orig, state: state} } // NewResourceLogsSlice creates a ResourceLogsSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewResourceLogsSlice() ResourceLogsSlice { - orig := []*otlplogs.ResourceLogs(nil) + orig := []*internal.ResourceLogs(nil) return newResourceLogsSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ResourceLogsSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlplogs.ResourceLogs, len(*es.orig), newCap) + newOrig := make([]*internal.ResourceLogs, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ResourceLogsSlice) EnsureCapacity(newCap int) { // It returns the newly added ResourceLogs. func (es ResourceLogsSlice) AppendEmpty() ResourceLogs { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigResourceLogs()) + *es.orig = append(*es.orig, internal.NewResourceLogs()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ResourceLogsSlice) RemoveIf(f func(ResourceLogs) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigResourceLogs((*es.orig)[i], true) + internal.DeleteResourceLogs((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ResourceLogsSlice) CopyTo(dest ResourceLogsSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigResourceLogsSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyResourceLogsPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ResourceLogs elements within ResourceLogsSlice given the diff --git a/pdata/plog/generated_resourcelogsslice_test.go b/pdata/plog/generated_resourcelogsslice_test.go index 76e9ba68d56..1499a3ff65e 100644 --- a/pdata/plog/generated_resourcelogsslice_test.go +++ b/pdata/plog/generated_resourcelogsslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) func TestResourceLogsSlice(t *testing.T) { es := NewResourceLogsSlice() assert.Equal(t, 0, es.Len()) - es = newResourceLogsSlice(&[]*otlplogs.ResourceLogs{}, internal.NewState()) + es = newResourceLogsSlice(&[]*internal.ResourceLogs{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewResourceLogs() @@ -27,7 +26,7 @@ func TestResourceLogsSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigResourceLogs() + (*es.orig)[i] = internal.GenTestResourceLogs() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestResourceLogsSlice(t *testing.T) { func TestResourceLogsSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newResourceLogsSlice(&[]*otlplogs.ResourceLogs{}, sharedState) + es := newResourceLogsSlice(&[]*internal.ResourceLogs{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestResourceLogsSlice_Sort(t *testing.T) { func generateTestResourceLogsSlice() ResourceLogsSlice { ms := NewResourceLogsSlice() - *ms.orig = internal.GenerateOrigTestResourceLogsSlice() + *ms.orig = internal.GenTestResourceLogsPtrSlice() return ms } diff --git a/pdata/plog/generated_scopelogs.go b/pdata/plog/generated_scopelogs.go index b6ae0a100fb..9cb55863ad2 100644 --- a/pdata/plog/generated_scopelogs.go +++ b/pdata/plog/generated_scopelogs.go @@ -8,7 +8,6 @@ package plog import ( "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewScopeLogs function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeLogs struct { - orig *otlplogs.ScopeLogs + orig *internal.ScopeLogs state *internal.State } -func newScopeLogs(orig *otlplogs.ScopeLogs, state *internal.State) ScopeLogs { +func newScopeLogs(orig *internal.ScopeLogs, state *internal.State) ScopeLogs { return ScopeLogs{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newScopeLogs(orig *otlplogs.ScopeLogs, state *internal.State) ScopeLogs { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewScopeLogs() ScopeLogs { - return newScopeLogs(internal.NewOrigScopeLogs(), internal.NewState()) + return newScopeLogs(internal.NewScopeLogs(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ScopeLogs) MoveTo(dest ScopeLogs) { if ms.orig == dest.orig { return } - internal.DeleteOrigScopeLogs(dest.orig, false) + internal.DeleteScopeLogs(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Scope returns the scope associated with this ScopeLogs. func (ms ScopeLogs) Scope() pcommon.InstrumentationScope { - return pcommon.InstrumentationScope(internal.NewInstrumentationScope(&ms.orig.Scope, ms.state)) + return pcommon.InstrumentationScope(internal.NewInstrumentationScopeWrapper(&ms.orig.Scope, ms.state)) } // LogRecords returns the LogRecords associated with this ScopeLogs. @@ -73,5 +72,5 @@ func (ms ScopeLogs) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ScopeLogs) CopyTo(dest ScopeLogs) { dest.state.AssertMutable() - internal.CopyOrigScopeLogs(dest.orig, ms.orig) + internal.CopyScopeLogs(dest.orig, ms.orig) } diff --git a/pdata/plog/generated_scopelogs_test.go b/pdata/plog/generated_scopelogs_test.go index a4adcaf5709..b807ff17d32 100644 --- a/pdata/plog/generated_scopelogs_test.go +++ b/pdata/plog/generated_scopelogs_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestScopeLogs_MoveTo(t *testing.T) { assert.Equal(t, generateTestScopeLogs(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newScopeLogs(internal.NewOrigScopeLogs(), sharedState)) }) - assert.Panics(t, func() { newScopeLogs(internal.NewOrigScopeLogs(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newScopeLogs(internal.NewScopeLogs(), sharedState)) }) + assert.Panics(t, func() { newScopeLogs(internal.NewScopeLogs(), sharedState).MoveTo(dest) }) } func TestScopeLogs_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestScopeLogs_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newScopeLogs(internal.NewOrigScopeLogs(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newScopeLogs(internal.NewScopeLogs(), sharedState)) }) } func TestScopeLogs_Scope(t *testing.T) { ms := NewScopeLogs() assert.Equal(t, pcommon.NewInstrumentationScope(), ms.Scope()) - ms.orig.Scope = *internal.GenTestOrigInstrumentationScope() - assert.Equal(t, pcommon.InstrumentationScope(internal.NewInstrumentationScope(internal.GenTestOrigInstrumentationScope(), ms.state)), ms.Scope()) + ms.orig.Scope = *internal.GenTestInstrumentationScope() + assert.Equal(t, pcommon.InstrumentationScope(internal.GenTestInstrumentationScopeWrapper()), ms.Scope()) } func TestScopeLogs_LogRecords(t *testing.T) { ms := NewScopeLogs() assert.Equal(t, NewLogRecordSlice(), ms.LogRecords()) - ms.orig.LogRecords = internal.GenerateOrigTestLogRecordSlice() + ms.orig.LogRecords = internal.GenTestLogRecordPtrSlice() assert.Equal(t, generateTestLogRecordSlice(), ms.LogRecords()) } @@ -64,10 +63,9 @@ func TestScopeLogs_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newScopeLogs(&otlplogs.ScopeLogs{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newScopeLogs(internal.NewScopeLogs(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestScopeLogs() ScopeLogs { - ms := newScopeLogs(internal.GenTestOrigScopeLogs(), internal.NewState()) - return ms + return newScopeLogs(internal.GenTestScopeLogs(), internal.NewState()) } diff --git a/pdata/plog/generated_scopelogsslice.go b/pdata/plog/generated_scopelogsslice.go index af4f01eb09b..3b37c545a91 100644 --- a/pdata/plog/generated_scopelogsslice.go +++ b/pdata/plog/generated_scopelogsslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) // ScopeLogsSlice logically represents a slice of ScopeLogs. @@ -22,18 +21,18 @@ import ( // Must use NewScopeLogsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeLogsSlice struct { - orig *[]*otlplogs.ScopeLogs + orig *[]*internal.ScopeLogs state *internal.State } -func newScopeLogsSlice(orig *[]*otlplogs.ScopeLogs, state *internal.State) ScopeLogsSlice { +func newScopeLogsSlice(orig *[]*internal.ScopeLogs, state *internal.State) ScopeLogsSlice { return ScopeLogsSlice{orig: orig, state: state} } // NewScopeLogsSlice creates a ScopeLogsSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewScopeLogsSlice() ScopeLogsSlice { - orig := []*otlplogs.ScopeLogs(nil) + orig := []*internal.ScopeLogs(nil) return newScopeLogsSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ScopeLogsSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlplogs.ScopeLogs, len(*es.orig), newCap) + newOrig := make([]*internal.ScopeLogs, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ScopeLogsSlice) EnsureCapacity(newCap int) { // It returns the newly added ScopeLogs. func (es ScopeLogsSlice) AppendEmpty() ScopeLogs { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigScopeLogs()) + *es.orig = append(*es.orig, internal.NewScopeLogs()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ScopeLogsSlice) RemoveIf(f func(ScopeLogs) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigScopeLogs((*es.orig)[i], true) + internal.DeleteScopeLogs((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ScopeLogsSlice) CopyTo(dest ScopeLogsSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigScopeLogsSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyScopeLogsPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ScopeLogs elements within ScopeLogsSlice given the diff --git a/pdata/plog/generated_scopelogsslice_test.go b/pdata/plog/generated_scopelogsslice_test.go index 60caa9039c3..a1f5dc92714 100644 --- a/pdata/plog/generated_scopelogsslice_test.go +++ b/pdata/plog/generated_scopelogsslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" ) func TestScopeLogsSlice(t *testing.T) { es := NewScopeLogsSlice() assert.Equal(t, 0, es.Len()) - es = newScopeLogsSlice(&[]*otlplogs.ScopeLogs{}, internal.NewState()) + es = newScopeLogsSlice(&[]*internal.ScopeLogs{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewScopeLogs() @@ -27,7 +26,7 @@ func TestScopeLogsSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigScopeLogs() + (*es.orig)[i] = internal.GenTestScopeLogs() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestScopeLogsSlice(t *testing.T) { func TestScopeLogsSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newScopeLogsSlice(&[]*otlplogs.ScopeLogs{}, sharedState) + es := newScopeLogsSlice(&[]*internal.ScopeLogs{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestScopeLogsSlice_Sort(t *testing.T) { func generateTestScopeLogsSlice() ScopeLogsSlice { ms := NewScopeLogsSlice() - *ms.orig = internal.GenerateOrigTestScopeLogsSlice() + *ms.orig = internal.GenTestScopeLogsPtrSlice() return ms } diff --git a/pdata/plog/json.go b/pdata/plog/json.go index 362ee3df3a7..7d7bdaae256 100644 --- a/pdata/plog/json.go +++ b/pdata/plog/json.go @@ -6,7 +6,6 @@ package plog // import "go.opentelemetry.io/collector/pdata/plog" import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -18,7 +17,7 @@ type JSONMarshaler struct{} func (*JSONMarshaler) MarshalLogs(ld Logs) ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportLogsServiceRequest(ld.getOrig(), dest) + ld.getOrig().MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -35,7 +34,7 @@ func (*JSONUnmarshaler) UnmarshalLogs(buf []byte) (Logs, error) { iter := json.BorrowIterator(buf) defer json.ReturnIterator(iter) ld := NewLogs() - internal.UnmarshalJSONOrigExportLogsServiceRequest(ld.getOrig(), iter) + ld.getOrig().UnmarshalJSON(iter) if iter.Error() != nil { return Logs{}, iter.Error() } diff --git a/pdata/plog/logs_test.go b/pdata/plog/logs_test.go index 78a405a9ebf..fdd11df5898 100644 --- a/pdata/plog/logs_test.go +++ b/pdata/plog/logs_test.go @@ -11,8 +11,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -42,22 +40,22 @@ func TestLogRecordCount(t *testing.T) { func TestLogRecordCountWithEmpty(t *testing.T) { assert.Zero(t, NewLogs().LogRecordCount()) - assert.Zero(t, newLogs(&otlpcollectorlog.ExportLogsServiceRequest{ - ResourceLogs: []*otlplogs.ResourceLogs{{}}, + assert.Zero(t, newLogs(&internal.ExportLogsServiceRequest{ + ResourceLogs: []*internal.ResourceLogs{{}}, }, new(internal.State)).LogRecordCount()) - assert.Zero(t, newLogs(&otlpcollectorlog.ExportLogsServiceRequest{ - ResourceLogs: []*otlplogs.ResourceLogs{ + assert.Zero(t, newLogs(&internal.ExportLogsServiceRequest{ + ResourceLogs: []*internal.ResourceLogs{ { - ScopeLogs: []*otlplogs.ScopeLogs{{}}, + ScopeLogs: []*internal.ScopeLogs{{}}, }, }, }, new(internal.State)).LogRecordCount()) - assert.Equal(t, 1, newLogs(&otlpcollectorlog.ExportLogsServiceRequest{ - ResourceLogs: []*otlplogs.ResourceLogs{ + assert.Equal(t, 1, newLogs(&internal.ExportLogsServiceRequest{ + ResourceLogs: []*internal.ResourceLogs{ { - ScopeLogs: []*otlplogs.ScopeLogs{ + ScopeLogs: []*internal.ScopeLogs{ { - LogRecords: []*otlplogs.LogRecord{{}}, + LogRecords: []*internal.LogRecord{{}}, }, }, }, diff --git a/pdata/plog/pb.go b/pdata/plog/pb.go index aad904c6d82..1f717928f93 100644 --- a/pdata/plog/pb.go +++ b/pdata/plog/pb.go @@ -3,35 +3,31 @@ package plog // import "go.opentelemetry.io/collector/pdata/plog" -import ( - "go.opentelemetry.io/collector/pdata/internal" -) - var _ MarshalSizer = (*ProtoMarshaler)(nil) type ProtoMarshaler struct{} func (e *ProtoMarshaler) MarshalLogs(ld Logs) ([]byte, error) { - size := internal.SizeProtoOrigExportLogsServiceRequest(ld.getOrig()) + size := ld.getOrig().SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportLogsServiceRequest(ld.getOrig(), buf) + _ = ld.getOrig().MarshalProto(buf) return buf, nil } func (e *ProtoMarshaler) LogsSize(ld Logs) int { - return internal.SizeProtoOrigExportLogsServiceRequest(ld.getOrig()) + return ld.getOrig().SizeProto() } func (e *ProtoMarshaler) ResourceLogsSize(ld ResourceLogs) int { - return internal.SizeProtoOrigResourceLogs(ld.orig) + return ld.orig.SizeProto() } func (e *ProtoMarshaler) ScopeLogsSize(ld ScopeLogs) int { - return internal.SizeProtoOrigScopeLogs(ld.orig) + return ld.orig.SizeProto() } func (e *ProtoMarshaler) LogRecordSize(ld LogRecord) int { - return internal.SizeProtoOrigLogRecord(ld.orig) + return ld.orig.SizeProto() } var _ Unmarshaler = (*ProtoUnmarshaler)(nil) @@ -40,7 +36,7 @@ type ProtoUnmarshaler struct{} func (d *ProtoUnmarshaler) UnmarshalLogs(buf []byte) (Logs, error) { ld := NewLogs() - err := internal.UnmarshalProtoOrigExportLogsServiceRequest(ld.getOrig(), buf) + err := ld.getOrig().UnmarshalProto(buf) if err != nil { return Logs{}, err } diff --git a/pdata/plog/plogotlp/generated_exportpartialsuccess.go b/pdata/plog/plogotlp/generated_exportpartialsuccess.go index b92bd222beb..e465eb01e5d 100644 --- a/pdata/plog/plogotlp/generated_exportpartialsuccess.go +++ b/pdata/plog/plogotlp/generated_exportpartialsuccess.go @@ -8,7 +8,6 @@ package plogotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" ) // ExportPartialSuccess represents the details of a partially successful export request. @@ -19,11 +18,11 @@ import ( // Must use NewExportPartialSuccess function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportPartialSuccess struct { - orig *otlpcollectorlogs.ExportLogsPartialSuccess + orig *internal.ExportLogsPartialSuccess state *internal.State } -func newExportPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, state *internal.State) ExportPartialSuccess { +func newExportPartialSuccess(orig *internal.ExportLogsPartialSuccess, state *internal.State) ExportPartialSuccess { return ExportPartialSuccess{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportPartialSuccess(orig *otlpcollectorlogs.ExportLogsPartialSuccess, s // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportPartialSuccess() ExportPartialSuccess { - return newExportPartialSuccess(internal.NewOrigExportLogsPartialSuccess(), internal.NewState()) + return newExportPartialSuccess(internal.NewExportLogsPartialSuccess(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportPartialSuccess) MoveTo(dest ExportPartialSuccess) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportLogsPartialSuccess(dest.orig, false) + internal.DeleteExportLogsPartialSuccess(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -73,5 +72,5 @@ func (ms ExportPartialSuccess) SetErrorMessage(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportPartialSuccess) CopyTo(dest ExportPartialSuccess) { dest.state.AssertMutable() - internal.CopyOrigExportLogsPartialSuccess(dest.orig, ms.orig) + internal.CopyExportLogsPartialSuccess(dest.orig, ms.orig) } diff --git a/pdata/plog/plogotlp/generated_exportpartialsuccess_test.go b/pdata/plog/plogotlp/generated_exportpartialsuccess_test.go index de96b4ae192..ac5a5893159 100644 --- a/pdata/plog/plogotlp/generated_exportpartialsuccess_test.go +++ b/pdata/plog/plogotlp/generated_exportpartialsuccess_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" ) func TestExportPartialSuccess_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestExportPartialSuccess_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportPartialSuccess(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewOrigExportLogsPartialSuccess(), sharedState)) }) - assert.Panics(t, func() { newExportPartialSuccess(internal.NewOrigExportLogsPartialSuccess(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewExportLogsPartialSuccess(), sharedState)) }) + assert.Panics(t, func() { newExportPartialSuccess(internal.NewExportLogsPartialSuccess(), sharedState).MoveTo(dest) }) } func TestExportPartialSuccess_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestExportPartialSuccess_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewOrigExportLogsPartialSuccess(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewExportLogsPartialSuccess(), sharedState)) }) } func TestExportPartialSuccess_RejectedLogRecords(t *testing.T) { @@ -50,7 +49,7 @@ func TestExportPartialSuccess_RejectedLogRecords(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectorlogs.ExportLogsPartialSuccess{}, sharedState).SetRejectedLogRecords(int64(13)) + newExportPartialSuccess(internal.NewExportLogsPartialSuccess(), sharedState).SetRejectedLogRecords(int64(13)) }) } @@ -62,11 +61,10 @@ func TestExportPartialSuccess_ErrorMessage(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectorlogs.ExportLogsPartialSuccess{}, sharedState).SetErrorMessage("test_errormessage") + newExportPartialSuccess(internal.NewExportLogsPartialSuccess(), sharedState).SetErrorMessage("test_errormessage") }) } func generateTestExportPartialSuccess() ExportPartialSuccess { - ms := newExportPartialSuccess(internal.GenTestOrigExportLogsPartialSuccess(), internal.NewState()) - return ms + return newExportPartialSuccess(internal.GenTestExportLogsPartialSuccess(), internal.NewState()) } diff --git a/pdata/plog/plogotlp/generated_exportresponse.go b/pdata/plog/plogotlp/generated_exportresponse.go index 7506faba692..09145a747c7 100644 --- a/pdata/plog/plogotlp/generated_exportresponse.go +++ b/pdata/plog/plogotlp/generated_exportresponse.go @@ -8,7 +8,6 @@ package plogotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" ) // ExportResponse represents the response for gRPC/HTTP client/server. @@ -19,11 +18,11 @@ import ( // Must use NewExportResponse function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportResponse struct { - orig *otlpcollectorlogs.ExportLogsServiceResponse + orig *internal.ExportLogsServiceResponse state *internal.State } -func newExportResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, state *internal.State) ExportResponse { +func newExportResponse(orig *internal.ExportLogsServiceResponse, state *internal.State) ExportResponse { return ExportResponse{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportResponse(orig *otlpcollectorlogs.ExportLogsServiceResponse, state // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportResponse() ExportResponse { - return newExportResponse(internal.NewOrigExportLogsServiceResponse(), internal.NewState()) + return newExportResponse(internal.NewExportLogsServiceResponse(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportResponse) MoveTo(dest ExportResponse) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportLogsServiceResponse(dest.orig, false) + internal.DeleteExportLogsServiceResponse(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -56,5 +55,5 @@ func (ms ExportResponse) PartialSuccess() ExportPartialSuccess { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportResponse) CopyTo(dest ExportResponse) { dest.state.AssertMutable() - internal.CopyOrigExportLogsServiceResponse(dest.orig, ms.orig) + internal.CopyExportLogsServiceResponse(dest.orig, ms.orig) } diff --git a/pdata/plog/plogotlp/generated_exportresponse_test.go b/pdata/plog/plogotlp/generated_exportresponse_test.go index 5bcd6e60619..644605690fb 100644 --- a/pdata/plog/plogotlp/generated_exportresponse_test.go +++ b/pdata/plog/plogotlp/generated_exportresponse_test.go @@ -24,8 +24,8 @@ func TestExportResponse_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportResponse(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewOrigExportLogsServiceResponse(), sharedState)) }) - assert.Panics(t, func() { newExportResponse(internal.NewOrigExportLogsServiceResponse(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewExportLogsServiceResponse(), sharedState)) }) + assert.Panics(t, func() { newExportResponse(internal.NewExportLogsServiceResponse(), sharedState).MoveTo(dest) }) } func TestExportResponse_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestExportResponse_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewOrigExportLogsServiceResponse(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewExportLogsServiceResponse(), sharedState)) }) } func TestExportResponse_PartialSuccess(t *testing.T) { ms := NewExportResponse() assert.Equal(t, NewExportPartialSuccess(), ms.PartialSuccess()) - ms.orig.PartialSuccess = *internal.GenTestOrigExportLogsPartialSuccess() + ms.orig.PartialSuccess = *internal.GenTestExportLogsPartialSuccess() assert.Equal(t, generateTestExportPartialSuccess(), ms.PartialSuccess()) } func generateTestExportResponse() ExportResponse { - ms := newExportResponse(internal.GenTestOrigExportLogsServiceResponse(), internal.NewState()) - return ms + return newExportResponse(internal.GenTestExportLogsServiceResponse(), internal.NewState()) } diff --git a/pdata/plog/plogotlp/grpc.go b/pdata/plog/plogotlp/grpc.go index 6a892606d88..77cc3b80609 100644 --- a/pdata/plog/plogotlp/grpc.go +++ b/pdata/plog/plogotlp/grpc.go @@ -11,8 +11,7 @@ import ( "google.golang.org/grpc/status" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" - _ "go.opentelemetry.io/collector/pdata/internal/grpcencoding" // enforces custom gRPC encoding to be loaded. + "go.opentelemetry.io/collector/pdata/internal/otelgrpc" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -32,11 +31,11 @@ type GRPCClient interface { // NewGRPCClient returns a new GRPCClient connected using the given connection. func NewGRPCClient(cc *grpc.ClientConn) GRPCClient { - return &grpcClient{rawClient: otlpcollectorlog.NewLogsServiceClient(cc)} + return &grpcClient{rawClient: otelgrpc.NewLogsServiceClient(cc)} } type grpcClient struct { - rawClient otlpcollectorlog.LogsServiceClient + rawClient otelgrpc.LogsServiceClient } func (c *grpcClient) Export(ctx context.Context, request ExportRequest, opts ...grpc.CallOption) (ExportResponse, error) { @@ -75,14 +74,14 @@ func (*UnimplementedGRPCServer) unexported() {} // RegisterGRPCServer registers the Server to the grpc.Server. func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { - otlpcollectorlog.RegisterLogsServiceServer(s, &rawLogsServer{srv: srv}) + otelgrpc.RegisterLogsServiceServer(s, &rawLogsServer{srv: srv}) } type rawLogsServer struct { srv GRPCServer } -func (s rawLogsServer) Export(ctx context.Context, request *otlpcollectorlog.ExportLogsServiceRequest) (*otlpcollectorlog.ExportLogsServiceResponse, error) { +func (s rawLogsServer) Export(ctx context.Context, request *internal.ExportLogsServiceRequest) (*internal.ExportLogsServiceResponse, error) { otlp.MigrateLogs(request.ResourceLogs) rsp, err := s.srv.Export(ctx, ExportRequest{orig: request, state: internal.NewState()}) return rsp.orig, err diff --git a/pdata/plog/plogotlp/request.go b/pdata/plog/plogotlp/request.go index 57b8743f4b8..a25f873e8a5 100644 --- a/pdata/plog/plogotlp/request.go +++ b/pdata/plog/plogotlp/request.go @@ -7,7 +7,6 @@ import ( "slices" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/plog" @@ -16,14 +15,14 @@ import ( // ExportRequest represents the request for gRPC/HTTP client/server. // It's a wrapper for plog.Logs data. type ExportRequest struct { - orig *otlpcollectorlog.ExportLogsServiceRequest + orig *internal.ExportLogsServiceRequest state *internal.State } // NewExportRequest returns an empty ExportRequest. func NewExportRequest() ExportRequest { return ExportRequest{ - orig: &otlpcollectorlog.ExportLogsServiceRequest{}, + orig: &internal.ExportLogsServiceRequest{}, state: internal.NewState(), } } @@ -33,22 +32,22 @@ func NewExportRequest() ExportRequest { // any changes to the provided Logs struct will be reflected in the ExportRequest and vice versa. func NewExportRequestFromLogs(ld plog.Logs) ExportRequest { return ExportRequest{ - orig: internal.GetOrigLogs(internal.Logs(ld)), - state: internal.GetLogsState(internal.Logs(ld)), + orig: internal.GetLogsOrig(internal.LogsWrapper(ld)), + state: internal.GetLogsState(internal.LogsWrapper(ld)), } } // MarshalProto marshals ExportRequest into proto bytes. func (ms ExportRequest) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportLogsServiceRequest(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportLogsServiceRequest(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportRequest from proto bytes. func (ms ExportRequest) UnmarshalProto(data []byte) error { - err := internal.UnmarshalProtoOrigExportLogsServiceRequest(ms.orig, data) + err := ms.orig.UnmarshalProto(data) if err != nil { return err } @@ -60,7 +59,7 @@ func (ms ExportRequest) UnmarshalProto(data []byte) error { func (ms ExportRequest) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportLogsServiceRequest(ms.orig, dest) + ms.orig.MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -71,10 +70,10 @@ func (ms ExportRequest) MarshalJSON() ([]byte, error) { func (ms ExportRequest) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportLogsServiceRequest(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } func (ms ExportRequest) Logs() plog.Logs { - return plog.Logs(internal.NewLogs(ms.orig, ms.state)) + return plog.Logs(internal.NewLogsWrapper(ms.orig, ms.state)) } diff --git a/pdata/plog/plogotlp/request_test.go b/pdata/plog/plogotlp/request_test.go index 9ccc8289dec..e2f5c19e6d2 100644 --- a/pdata/plog/plogotlp/request_test.go +++ b/pdata/plog/plogotlp/request_test.go @@ -14,6 +14,7 @@ import ( goproto "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/pdata/internal" + "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/plog" ) @@ -66,7 +67,7 @@ func TestLogsProtoWireCompatibility(t *testing.T) { // this repository are wire compatible. // Generate Logs as pdata struct. - ld := NewExportRequestFromLogs(plog.Logs(internal.NewLogs(internal.GenTestOrigExportLogsServiceRequest(), internal.NewState()))) + ld := NewExportRequestFromLogs(plog.Logs(internal.GenTestLogsWrapper())) // Marshal its underlying ProtoBuf to wire. wire1, err := ld.MarshalProto() @@ -84,11 +85,13 @@ func TestLogsProtoWireCompatibility(t *testing.T) { assert.NotNil(t, wire2) // Unmarshal from the wire into gogoproto's representation. - td2 := NewExportRequest() - err = td2.UnmarshalProto(wire2) + ld2 := NewExportRequest() + err = ld2.UnmarshalProto(wire2) require.NoError(t, err) // Now compare that the original and final ProtoBuf messages are the same. // This proves that goproto and gogoproto marshaling/unmarshaling are wire compatible. - assert.Equal(t, ld, td2) + // Migration logic will run, so run it on the original message as well. + otlp.MigrateLogs(ld.orig.ResourceLogs) + assert.Equal(t, ld, ld2) } diff --git a/pdata/plog/plogotlp/response.go b/pdata/plog/plogotlp/response.go index 5a997ac14d7..8a332ba4e6f 100644 --- a/pdata/plog/plogotlp/response.go +++ b/pdata/plog/plogotlp/response.go @@ -6,28 +6,27 @@ package plogotlp // import "go.opentelemetry.io/collector/pdata/plog/plogotlp" import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" ) // MarshalProto marshals ExportResponse into proto bytes. func (ms ExportResponse) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportLogsServiceResponse(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportLogsServiceResponse(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportResponse from proto bytes. func (ms ExportResponse) UnmarshalProto(data []byte) error { - return internal.UnmarshalProtoOrigExportLogsServiceResponse(ms.orig, data) + return ms.orig.UnmarshalProto(data) } // MarshalJSON marshals ExportResponse into JSON bytes. func (ms ExportResponse) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportLogsServiceResponse(ms.orig, dest) + ms.orig.MarshalJSON(dest) return slices.Clone(dest.Buffer()), dest.Error() } @@ -35,6 +34,6 @@ func (ms ExportResponse) MarshalJSON() ([]byte, error) { func (ms ExportResponse) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportLogsServiceResponse(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } diff --git a/pdata/plog/severity_number.go b/pdata/plog/severity_number.go index 53a9d4179c4..5df0690872b 100644 --- a/pdata/plog/severity_number.go +++ b/pdata/plog/severity_number.go @@ -4,38 +4,38 @@ package plog // import "go.opentelemetry.io/collector/pdata/plog" import ( - otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // SeverityNumber represents severity number of a log record. type SeverityNumber int32 const ( - SeverityNumberUnspecified = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED) - SeverityNumberTrace = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_TRACE) - SeverityNumberTrace2 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_TRACE2) - SeverityNumberTrace3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_TRACE3) - SeverityNumberTrace4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_TRACE4) - SeverityNumberDebug = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_DEBUG) - SeverityNumberDebug2 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_DEBUG2) - SeverityNumberDebug3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_DEBUG3) - SeverityNumberDebug4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_DEBUG4) - SeverityNumberInfo = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_INFO) - SeverityNumberInfo2 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_INFO2) - SeverityNumberInfo3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_INFO3) - SeverityNumberInfo4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_INFO4) - SeverityNumberWarn = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_WARN) - SeverityNumberWarn2 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_WARN2) - SeverityNumberWarn3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_WARN3) - SeverityNumberWarn4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_WARN4) - SeverityNumberError = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_ERROR) - SeverityNumberError2 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_ERROR2) - SeverityNumberError3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_ERROR3) - SeverityNumberError4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_ERROR4) - SeverityNumberFatal = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL) - SeverityNumberFatal2 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL2) - SeverityNumberFatal3 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL3) - SeverityNumberFatal4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL4) + SeverityNumberUnspecified = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_UNSPECIFIED) + SeverityNumberTrace = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_TRACE) + SeverityNumberTrace2 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_TRACE2) + SeverityNumberTrace3 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_TRACE3) + SeverityNumberTrace4 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_TRACE4) + SeverityNumberDebug = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_DEBUG) + SeverityNumberDebug2 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_DEBUG2) + SeverityNumberDebug3 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_DEBUG3) + SeverityNumberDebug4 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_DEBUG4) + SeverityNumberInfo = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_INFO) + SeverityNumberInfo2 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_INFO2) + SeverityNumberInfo3 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_INFO3) + SeverityNumberInfo4 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_INFO4) + SeverityNumberWarn = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_WARN) + SeverityNumberWarn2 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_WARN2) + SeverityNumberWarn3 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_WARN3) + SeverityNumberWarn4 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_WARN4) + SeverityNumberError = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_ERROR) + SeverityNumberError2 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_ERROR2) + SeverityNumberError3 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_ERROR3) + SeverityNumberError4 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_ERROR4) + SeverityNumberFatal = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_FATAL) + SeverityNumberFatal2 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_FATAL2) + SeverityNumberFatal3 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_FATAL3) + SeverityNumberFatal4 = SeverityNumber(internal.SeverityNumber_SEVERITY_NUMBER_FATAL4) ) // String returns the string representation of the SeverityNumber. diff --git a/pdata/pmetric/aggregation_temporality.go b/pdata/pmetric/aggregation_temporality.go index 0ba2b28c29b..f2abb4f62b8 100644 --- a/pdata/pmetric/aggregation_temporality.go +++ b/pdata/pmetric/aggregation_temporality.go @@ -4,7 +4,7 @@ package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" import ( - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // AggregationTemporality defines how a metric aggregator reports aggregated values. @@ -13,11 +13,11 @@ type AggregationTemporality int32 const ( // AggregationTemporalityUnspecified is the default AggregationTemporality, it MUST NOT be used. - AggregationTemporalityUnspecified = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED) + AggregationTemporalityUnspecified = AggregationTemporality(internal.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED) // AggregationTemporalityDelta is a AggregationTemporality for a metric aggregator which reports changes since last report time. - AggregationTemporalityDelta = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA) + AggregationTemporalityDelta = AggregationTemporality(internal.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA) // AggregationTemporalityCumulative is a AggregationTemporality for a metric aggregator which reports changes since a fixed start time. - AggregationTemporalityCumulative = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE) + AggregationTemporalityCumulative = AggregationTemporality(internal.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE) ) // String returns the string representation of the AggregationTemporality. diff --git a/pdata/pmetric/generated_exemplar.go b/pdata/pmetric/generated_exemplar.go index a827a4214c1..e0681f6d17f 100644 --- a/pdata/pmetric/generated_exemplar.go +++ b/pdata/pmetric/generated_exemplar.go @@ -8,8 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -24,11 +22,11 @@ import ( // Must use NewExemplar function to create new instances. // Important: zero-initialized instance is not valid for use. type Exemplar struct { - orig *otlpmetrics.Exemplar + orig *internal.Exemplar state *internal.State } -func newExemplar(orig *otlpmetrics.Exemplar, state *internal.State) Exemplar { +func newExemplar(orig *internal.Exemplar, state *internal.State) Exemplar { return Exemplar{orig: orig, state: state} } @@ -37,7 +35,7 @@ func newExemplar(orig *otlpmetrics.Exemplar, state *internal.State) Exemplar { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExemplar() Exemplar { - return newExemplar(internal.NewOrigExemplar(), internal.NewState()) + return newExemplar(internal.NewExemplar(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -49,13 +47,13 @@ func (ms Exemplar) MoveTo(dest Exemplar) { if ms.orig == dest.orig { return } - internal.DeleteOrigExemplar(dest.orig, false) + internal.DeleteExemplar(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // FilteredAttributes returns the FilteredAttributes associated with this Exemplar. func (ms Exemplar) FilteredAttributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.FilteredAttributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.FilteredAttributes, ms.state)) } // Timestamp returns the timestamp associated with this Exemplar. @@ -73,9 +71,9 @@ func (ms Exemplar) SetTimestamp(v pcommon.Timestamp) { // Calling this function on zero-initialized Exemplar will cause a panic. func (ms Exemplar) ValueType() ExemplarValueType { switch ms.orig.Value.(type) { - case *otlpmetrics.Exemplar_AsDouble: + case *internal.Exemplar_AsDouble: return ExemplarValueTypeDouble - case *otlpmetrics.Exemplar_AsInt: + case *internal.Exemplar_AsInt: return ExemplarValueTypeInt } return ExemplarValueTypeEmpty @@ -89,11 +87,11 @@ func (ms Exemplar) DoubleValue() float64 { // SetDoubleValue replaces the double associated with this Exemplar. func (ms Exemplar) SetDoubleValue(v float64) { ms.state.AssertMutable() - var ov *otlpmetrics.Exemplar_AsDouble + var ov *internal.Exemplar_AsDouble if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsDouble{} + ov = &internal.Exemplar_AsDouble{} } else { - ov = internal.ProtoPoolExemplar_AsDouble.Get().(*otlpmetrics.Exemplar_AsDouble) + ov = internal.ProtoPoolExemplar_AsDouble.Get().(*internal.Exemplar_AsDouble) } ov.AsDouble = v ms.orig.Value = ov @@ -107,27 +105,16 @@ func (ms Exemplar) IntValue() int64 { // SetIntValue replaces the int associated with this Exemplar. func (ms Exemplar) SetIntValue(v int64) { ms.state.AssertMutable() - var ov *otlpmetrics.Exemplar_AsInt + var ov *internal.Exemplar_AsInt if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Exemplar_AsInt{} + ov = &internal.Exemplar_AsInt{} } else { - ov = internal.ProtoPoolExemplar_AsInt.Get().(*otlpmetrics.Exemplar_AsInt) + ov = internal.ProtoPoolExemplar_AsInt.Get().(*internal.Exemplar_AsInt) } ov.AsInt = v ms.orig.Value = ov } -// SpanID returns the spanid associated with this Exemplar. -func (ms Exemplar) SpanID() pcommon.SpanID { - return pcommon.SpanID(ms.orig.SpanId) -} - -// SetSpanID replaces the spanid associated with this Exemplar. -func (ms Exemplar) SetSpanID(v pcommon.SpanID) { - ms.state.AssertMutable() - ms.orig.SpanId = data.SpanID(v) -} - // TraceID returns the traceid associated with this Exemplar. func (ms Exemplar) TraceID() pcommon.TraceID { return pcommon.TraceID(ms.orig.TraceId) @@ -136,11 +123,22 @@ func (ms Exemplar) TraceID() pcommon.TraceID { // SetTraceID replaces the traceid associated with this Exemplar. func (ms Exemplar) SetTraceID(v pcommon.TraceID) { ms.state.AssertMutable() - ms.orig.TraceId = data.TraceID(v) + ms.orig.TraceId = internal.TraceID(v) +} + +// SpanID returns the spanid associated with this Exemplar. +func (ms Exemplar) SpanID() pcommon.SpanID { + return pcommon.SpanID(ms.orig.SpanId) +} + +// SetSpanID replaces the spanid associated with this Exemplar. +func (ms Exemplar) SetSpanID(v pcommon.SpanID) { + ms.state.AssertMutable() + ms.orig.SpanId = internal.SpanID(v) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Exemplar) CopyTo(dest Exemplar) { dest.state.AssertMutable() - internal.CopyOrigExemplar(dest.orig, ms.orig) + internal.CopyExemplar(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_exemplar_test.go b/pdata/pmetric/generated_exemplar_test.go index 35878196331..fedeff3200f 100644 --- a/pdata/pmetric/generated_exemplar_test.go +++ b/pdata/pmetric/generated_exemplar_test.go @@ -12,8 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,8 +25,8 @@ func TestExemplar_MoveTo(t *testing.T) { assert.Equal(t, generateTestExemplar(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExemplar(internal.NewOrigExemplar(), sharedState)) }) - assert.Panics(t, func() { newExemplar(internal.NewOrigExemplar(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExemplar(internal.NewExemplar(), sharedState)) }) + assert.Panics(t, func() { newExemplar(internal.NewExemplar(), sharedState).MoveTo(dest) }) } func TestExemplar_CopyTo(t *testing.T) { @@ -41,14 +39,14 @@ func TestExemplar_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExemplar(internal.NewOrigExemplar(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExemplar(internal.NewExemplar(), sharedState)) }) } func TestExemplar_FilteredAttributes(t *testing.T) { ms := NewExemplar() assert.Equal(t, pcommon.NewMap(), ms.FilteredAttributes()) - ms.orig.FilteredAttributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.FilteredAttributes()) + ms.orig.FilteredAttributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.FilteredAttributes()) } func TestExemplar_Timestamp(t *testing.T) { @@ -72,7 +70,7 @@ func TestExemplar_DoubleValue(t *testing.T) { assert.Equal(t, ExemplarValueTypeDouble, ms.ValueType()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newExemplar(&otlpmetrics.Exemplar{}, sharedState).SetDoubleValue(float64(3.1415926)) }) + assert.Panics(t, func() { newExemplar(internal.NewExemplar(), sharedState).SetDoubleValue(float64(3.1415926)) }) } func TestExemplar_IntValue(t *testing.T) { @@ -83,26 +81,25 @@ func TestExemplar_IntValue(t *testing.T) { assert.Equal(t, ExemplarValueTypeInt, ms.ValueType()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newExemplar(&otlpmetrics.Exemplar{}, sharedState).SetIntValue(int64(13)) }) -} - -func TestExemplar_SpanID(t *testing.T) { - ms := NewExemplar() - assert.Equal(t, pcommon.SpanID(data.SpanID([8]byte{})), ms.SpanID()) - testValSpanID := pcommon.SpanID(data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) - ms.SetSpanID(testValSpanID) - assert.Equal(t, testValSpanID, ms.SpanID()) + assert.Panics(t, func() { newExemplar(internal.NewExemplar(), sharedState).SetIntValue(int64(13)) }) } func TestExemplar_TraceID(t *testing.T) { ms := NewExemplar() - assert.Equal(t, pcommon.TraceID(data.TraceID([16]byte{})), ms.TraceID()) - testValTraceID := pcommon.TraceID(data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.TraceID(internal.TraceID([16]byte{})), ms.TraceID()) + testValTraceID := pcommon.TraceID(internal.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) ms.SetTraceID(testValTraceID) assert.Equal(t, testValTraceID, ms.TraceID()) } +func TestExemplar_SpanID(t *testing.T) { + ms := NewExemplar() + assert.Equal(t, pcommon.SpanID(internal.SpanID([8]byte{})), ms.SpanID()) + testValSpanID := pcommon.SpanID(internal.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) + ms.SetSpanID(testValSpanID) + assert.Equal(t, testValSpanID, ms.SpanID()) +} + func generateTestExemplar() Exemplar { - ms := newExemplar(internal.GenTestOrigExemplar(), internal.NewState()) - return ms + return newExemplar(internal.GenTestExemplar(), internal.NewState()) } diff --git a/pdata/pmetric/generated_exemplarslice.go b/pdata/pmetric/generated_exemplarslice.go index 24f54d61d1b..77a93927b08 100644 --- a/pdata/pmetric/generated_exemplarslice.go +++ b/pdata/pmetric/generated_exemplarslice.go @@ -10,7 +10,6 @@ import ( "iter" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // ExemplarSlice logically represents a slice of Exemplar. @@ -21,18 +20,18 @@ import ( // Must use NewExemplarSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ExemplarSlice struct { - orig *[]otlpmetrics.Exemplar + orig *[]internal.Exemplar state *internal.State } -func newExemplarSlice(orig *[]otlpmetrics.Exemplar, state *internal.State) ExemplarSlice { +func newExemplarSlice(orig *[]internal.Exemplar, state *internal.State) ExemplarSlice { return ExemplarSlice{orig: orig, state: state} } // NewExemplarSlice creates a ExemplarSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewExemplarSlice() ExemplarSlice { - orig := []otlpmetrics.Exemplar(nil) + orig := []internal.Exemplar(nil) return newExemplarSlice(&orig, internal.NewState()) } @@ -89,7 +88,7 @@ func (es ExemplarSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]otlpmetrics.Exemplar, len(*es.orig), newCap) + newOrig := make([]internal.Exemplar, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -98,7 +97,7 @@ func (es ExemplarSlice) EnsureCapacity(newCap int) { // It returns the newly added Exemplar. func (es ExemplarSlice) AppendEmpty() Exemplar { es.state.AssertMutable() - *es.orig = append(*es.orig, otlpmetrics.Exemplar{}) + *es.orig = append(*es.orig, internal.Exemplar{}) return es.At(es.Len() - 1) } @@ -127,7 +126,7 @@ func (es ExemplarSlice) RemoveIf(f func(Exemplar) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigExemplar(&(*es.orig)[i], false) + internal.DeleteExemplar(&(*es.orig)[i], false) continue } if newLen == i { @@ -148,5 +147,5 @@ func (es ExemplarSlice) CopyTo(dest ExemplarSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigExemplarSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyExemplarSlice(*dest.orig, *es.orig) } diff --git a/pdata/pmetric/generated_exemplarslice_test.go b/pdata/pmetric/generated_exemplarslice_test.go index 264420d9e5f..20261f0f54b 100644 --- a/pdata/pmetric/generated_exemplarslice_test.go +++ b/pdata/pmetric/generated_exemplarslice_test.go @@ -12,13 +12,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestExemplarSlice(t *testing.T) { es := NewExemplarSlice() assert.Equal(t, 0, es.Len()) - es = newExemplarSlice(&[]otlpmetrics.Exemplar{}, internal.NewState()) + es = newExemplarSlice(&[]internal.Exemplar{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewExemplar() @@ -26,7 +25,7 @@ func TestExemplarSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = *internal.GenTestOrigExemplar() + (*es.orig)[i] = *internal.GenTestExemplar() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -35,7 +34,7 @@ func TestExemplarSlice(t *testing.T) { func TestExemplarSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newExemplarSlice(&[]otlpmetrics.Exemplar{}, sharedState) + es := newExemplarSlice(&[]internal.Exemplar{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -145,6 +144,6 @@ func TestExemplarSliceAll(t *testing.T) { func generateTestExemplarSlice() ExemplarSlice { ms := NewExemplarSlice() - *ms.orig = internal.GenerateOrigTestExemplarSlice() + *ms.orig = internal.GenTestExemplarSlice() return ms } diff --git a/pdata/pmetric/generated_exponentialhistogram.go b/pdata/pmetric/generated_exponentialhistogram.go index 660360a9747..9970cb5878c 100644 --- a/pdata/pmetric/generated_exponentialhistogram.go +++ b/pdata/pmetric/generated_exponentialhistogram.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // ExponentialHistogram represents the type of a metric that is calculated by aggregating @@ -20,11 +19,11 @@ import ( // Must use NewExponentialHistogram function to create new instances. // Important: zero-initialized instance is not valid for use. type ExponentialHistogram struct { - orig *otlpmetrics.ExponentialHistogram + orig *internal.ExponentialHistogram state *internal.State } -func newExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, state *internal.State) ExponentialHistogram { +func newExponentialHistogram(orig *internal.ExponentialHistogram, state *internal.State) ExponentialHistogram { return ExponentialHistogram{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newExponentialHistogram(orig *otlpmetrics.ExponentialHistogram, state *inte // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExponentialHistogram() ExponentialHistogram { - return newExponentialHistogram(internal.NewOrigExponentialHistogram(), internal.NewState()) + return newExponentialHistogram(internal.NewExponentialHistogram(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms ExponentialHistogram) MoveTo(dest ExponentialHistogram) { if ms.orig == dest.orig { return } - internal.DeleteOrigExponentialHistogram(dest.orig, false) + internal.DeleteExponentialHistogram(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -62,11 +61,11 @@ func (ms ExponentialHistogram) AggregationTemporality() AggregationTemporality { // SetAggregationTemporality replaces the aggregationtemporality associated with this ExponentialHistogram. func (ms ExponentialHistogram) SetAggregationTemporality(v AggregationTemporality) { ms.state.AssertMutable() - ms.orig.AggregationTemporality = otlpmetrics.AggregationTemporality(v) + ms.orig.AggregationTemporality = internal.AggregationTemporality(v) } // CopyTo copies all properties from the current struct overriding the destination. func (ms ExponentialHistogram) CopyTo(dest ExponentialHistogram) { dest.state.AssertMutable() - internal.CopyOrigExponentialHistogram(dest.orig, ms.orig) + internal.CopyExponentialHistogram(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_exponentialhistogram_test.go b/pdata/pmetric/generated_exponentialhistogram_test.go index 53897f552a7..8b4cb8f90a5 100644 --- a/pdata/pmetric/generated_exponentialhistogram_test.go +++ b/pdata/pmetric/generated_exponentialhistogram_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestExponentialHistogram_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestExponentialHistogram_MoveTo(t *testing.T) { assert.Equal(t, generateTestExponentialHistogram(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExponentialHistogram(internal.NewOrigExponentialHistogram(), sharedState)) }) - assert.Panics(t, func() { newExponentialHistogram(internal.NewOrigExponentialHistogram(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExponentialHistogram(internal.NewExponentialHistogram(), sharedState)) }) + assert.Panics(t, func() { newExponentialHistogram(internal.NewExponentialHistogram(), sharedState).MoveTo(dest) }) } func TestExponentialHistogram_CopyTo(t *testing.T) { @@ -39,25 +38,24 @@ func TestExponentialHistogram_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExponentialHistogram(internal.NewOrigExponentialHistogram(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExponentialHistogram(internal.NewExponentialHistogram(), sharedState)) }) } func TestExponentialHistogram_DataPoints(t *testing.T) { ms := NewExponentialHistogram() assert.Equal(t, NewExponentialHistogramDataPointSlice(), ms.DataPoints()) - ms.orig.DataPoints = internal.GenerateOrigTestExponentialHistogramDataPointSlice() + ms.orig.DataPoints = internal.GenTestExponentialHistogramDataPointPtrSlice() assert.Equal(t, generateTestExponentialHistogramDataPointSlice(), ms.DataPoints()) } func TestExponentialHistogram_AggregationTemporality(t *testing.T) { ms := NewExponentialHistogram() - assert.Equal(t, AggregationTemporality(otlpmetrics.AggregationTemporality(0)), ms.AggregationTemporality()) - testValAggregationTemporality := AggregationTemporality(otlpmetrics.AggregationTemporality(1)) + assert.Equal(t, AggregationTemporality(internal.AggregationTemporality(0)), ms.AggregationTemporality()) + testValAggregationTemporality := AggregationTemporality(internal.AggregationTemporality(1)) ms.SetAggregationTemporality(testValAggregationTemporality) assert.Equal(t, testValAggregationTemporality, ms.AggregationTemporality()) } func generateTestExponentialHistogram() ExponentialHistogram { - ms := newExponentialHistogram(internal.GenTestOrigExponentialHistogram(), internal.NewState()) - return ms + return newExponentialHistogram(internal.GenTestExponentialHistogram(), internal.NewState()) } diff --git a/pdata/pmetric/generated_exponentialhistogramdatapoint.go b/pdata/pmetric/generated_exponentialhistogramdatapoint.go index 96de0fa493c..168fdebb97a 100644 --- a/pdata/pmetric/generated_exponentialhistogramdatapoint.go +++ b/pdata/pmetric/generated_exponentialhistogramdatapoint.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -23,11 +22,11 @@ import ( // Must use NewExponentialHistogramDataPoint function to create new instances. // Important: zero-initialized instance is not valid for use. type ExponentialHistogramDataPoint struct { - orig *otlpmetrics.ExponentialHistogramDataPoint + orig *internal.ExponentialHistogramDataPoint state *internal.State } -func newExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramDataPoint, state *internal.State) ExponentialHistogramDataPoint { +func newExponentialHistogramDataPoint(orig *internal.ExponentialHistogramDataPoint, state *internal.State) ExponentialHistogramDataPoint { return ExponentialHistogramDataPoint{orig: orig, state: state} } @@ -36,7 +35,7 @@ func newExponentialHistogramDataPoint(orig *otlpmetrics.ExponentialHistogramData // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExponentialHistogramDataPoint() ExponentialHistogramDataPoint { - return newExponentialHistogramDataPoint(internal.NewOrigExponentialHistogramDataPoint(), internal.NewState()) + return newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -48,13 +47,13 @@ func (ms ExponentialHistogramDataPoint) MoveTo(dest ExponentialHistogramDataPoin if ms.orig == dest.orig { return } - internal.DeleteOrigExponentialHistogramDataPoint(dest.orig, false) + internal.DeleteExponentialHistogramDataPoint(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Attributes returns the Attributes associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // StartTimestamp returns the starttimestamp associated with this ExponentialHistogramDataPoint. @@ -104,7 +103,7 @@ func (ms ExponentialHistogramDataPoint) HasSum() bool { // SetSum replaces the sum associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) SetSum(v float64) { ms.state.AssertMutable() - ms.orig.Sum_ = &otlpmetrics.ExponentialHistogramDataPoint_Sum{Sum: v} + ms.orig.Sum_ = &internal.ExponentialHistogramDataPoint_Sum{Sum: v} } // RemoveSum removes the sum associated with this ExponentialHistogramDataPoint. @@ -175,7 +174,7 @@ func (ms ExponentialHistogramDataPoint) HasMin() bool { // SetMin replaces the min associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) SetMin(v float64) { ms.state.AssertMutable() - ms.orig.Min_ = &otlpmetrics.ExponentialHistogramDataPoint_Min{Min: v} + ms.orig.Min_ = &internal.ExponentialHistogramDataPoint_Min{Min: v} } // RemoveMin removes the min associated with this ExponentialHistogramDataPoint. @@ -198,7 +197,7 @@ func (ms ExponentialHistogramDataPoint) HasMax() bool { // SetMax replaces the max associated with this ExponentialHistogramDataPoint. func (ms ExponentialHistogramDataPoint) SetMax(v float64) { ms.state.AssertMutable() - ms.orig.Max_ = &otlpmetrics.ExponentialHistogramDataPoint_Max{Max: v} + ms.orig.Max_ = &internal.ExponentialHistogramDataPoint_Max{Max: v} } // RemoveMax removes the max associated with this ExponentialHistogramDataPoint. @@ -221,5 +220,5 @@ func (ms ExponentialHistogramDataPoint) SetZeroThreshold(v float64) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExponentialHistogramDataPoint) CopyTo(dest ExponentialHistogramDataPoint) { dest.state.AssertMutable() - internal.CopyOrigExponentialHistogramDataPoint(dest.orig, ms.orig) + internal.CopyExponentialHistogramDataPoint(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_exponentialhistogramdatapoint_test.go b/pdata/pmetric/generated_exponentialhistogramdatapoint_test.go index 4536c763e4b..8b252e5a6cc 100644 --- a/pdata/pmetric/generated_exponentialhistogramdatapoint_test.go +++ b/pdata/pmetric/generated_exponentialhistogramdatapoint_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,10 +26,10 @@ func TestExponentialHistogramDataPoint_MoveTo(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - ms.MoveTo(newExponentialHistogramDataPoint(internal.NewOrigExponentialHistogramDataPoint(), sharedState)) + ms.MoveTo(newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState)) }) assert.Panics(t, func() { - newExponentialHistogramDataPoint(internal.NewOrigExponentialHistogramDataPoint(), sharedState).MoveTo(dest) + newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState).MoveTo(dest) }) } @@ -45,15 +44,15 @@ func TestExponentialHistogramDataPoint_CopyTo(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - ms.CopyTo(newExponentialHistogramDataPoint(internal.NewOrigExponentialHistogramDataPoint(), sharedState)) + ms.CopyTo(newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState)) }) } func TestExponentialHistogramDataPoint_Attributes(t *testing.T) { ms := NewExponentialHistogramDataPoint() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestExponentialHistogramDataPoint_StartTimestamp(t *testing.T) { @@ -80,7 +79,7 @@ func TestExponentialHistogramDataPoint_Count(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExponentialHistogramDataPoint(&otlpmetrics.ExponentialHistogramDataPoint{}, sharedState).SetCount(uint64(13)) + newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState).SetCount(uint64(13)) }) } @@ -106,7 +105,7 @@ func TestExponentialHistogramDataPoint_Scale(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExponentialHistogramDataPoint(&otlpmetrics.ExponentialHistogramDataPoint{}, sharedState).SetScale(int32(13)) + newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState).SetScale(int32(13)) }) } @@ -118,21 +117,21 @@ func TestExponentialHistogramDataPoint_ZeroCount(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExponentialHistogramDataPoint(&otlpmetrics.ExponentialHistogramDataPoint{}, sharedState).SetZeroCount(uint64(13)) + newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState).SetZeroCount(uint64(13)) }) } func TestExponentialHistogramDataPoint_Positive(t *testing.T) { ms := NewExponentialHistogramDataPoint() assert.Equal(t, NewExponentialHistogramDataPointBuckets(), ms.Positive()) - ms.orig.Positive = *internal.GenTestOrigExponentialHistogramDataPoint_Buckets() + ms.orig.Positive = *internal.GenTestExponentialHistogramDataPointBuckets() assert.Equal(t, generateTestExponentialHistogramDataPointBuckets(), ms.Positive()) } func TestExponentialHistogramDataPoint_Negative(t *testing.T) { ms := NewExponentialHistogramDataPoint() assert.Equal(t, NewExponentialHistogramDataPointBuckets(), ms.Negative()) - ms.orig.Negative = *internal.GenTestOrigExponentialHistogramDataPoint_Buckets() + ms.orig.Negative = *internal.GenTestExponentialHistogramDataPointBuckets() assert.Equal(t, generateTestExponentialHistogramDataPointBuckets(), ms.Negative()) } @@ -147,7 +146,7 @@ func TestExponentialHistogramDataPoint_Flags(t *testing.T) { func TestExponentialHistogramDataPoint_Exemplars(t *testing.T) { ms := NewExponentialHistogramDataPoint() assert.Equal(t, NewExemplarSlice(), ms.Exemplars()) - ms.orig.Exemplars = internal.GenerateOrigTestExemplarSlice() + ms.orig.Exemplars = internal.GenTestExemplarSlice() assert.Equal(t, generateTestExemplarSlice(), ms.Exemplars()) } @@ -187,11 +186,10 @@ func TestExponentialHistogramDataPoint_ZeroThreshold(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExponentialHistogramDataPoint(&otlpmetrics.ExponentialHistogramDataPoint{}, sharedState).SetZeroThreshold(float64(3.1415926)) + newExponentialHistogramDataPoint(internal.NewExponentialHistogramDataPoint(), sharedState).SetZeroThreshold(float64(3.1415926)) }) } func generateTestExponentialHistogramDataPoint() ExponentialHistogramDataPoint { - ms := newExponentialHistogramDataPoint(internal.GenTestOrigExponentialHistogramDataPoint(), internal.NewState()) - return ms + return newExponentialHistogramDataPoint(internal.GenTestExponentialHistogramDataPoint(), internal.NewState()) } diff --git a/pdata/pmetric/generated_exponentialhistogramdatapointbuckets.go b/pdata/pmetric/generated_exponentialhistogramdatapointbuckets.go index 54b6a6ee1b8..5864cd1a3d8 100644 --- a/pdata/pmetric/generated_exponentialhistogramdatapointbuckets.go +++ b/pdata/pmetric/generated_exponentialhistogramdatapointbuckets.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewExponentialHistogramDataPointBuckets function to create new instances. // Important: zero-initialized instance is not valid for use. type ExponentialHistogramDataPointBuckets struct { - orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets + orig *internal.ExponentialHistogramDataPointBuckets state *internal.State } -func newExponentialHistogramDataPointBuckets(orig *otlpmetrics.ExponentialHistogramDataPoint_Buckets, state *internal.State) ExponentialHistogramDataPointBuckets { +func newExponentialHistogramDataPointBuckets(orig *internal.ExponentialHistogramDataPointBuckets, state *internal.State) ExponentialHistogramDataPointBuckets { return ExponentialHistogramDataPointBuckets{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newExponentialHistogramDataPointBuckets(orig *otlpmetrics.ExponentialHistog // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExponentialHistogramDataPointBuckets() ExponentialHistogramDataPointBuckets { - return newExponentialHistogramDataPointBuckets(internal.NewOrigExponentialHistogramDataPoint_Buckets(), internal.NewState()) + return newExponentialHistogramDataPointBuckets(internal.NewExponentialHistogramDataPointBuckets(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms ExponentialHistogramDataPointBuckets) MoveTo(dest ExponentialHistogramD if ms.orig == dest.orig { return } - internal.DeleteOrigExponentialHistogramDataPoint_Buckets(dest.orig, false) + internal.DeleteExponentialHistogramDataPointBuckets(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -62,11 +61,11 @@ func (ms ExponentialHistogramDataPointBuckets) SetOffset(v int32) { // BucketCounts returns the BucketCounts associated with this ExponentialHistogramDataPointBuckets. func (ms ExponentialHistogramDataPointBuckets) BucketCounts() pcommon.UInt64Slice { - return pcommon.UInt64Slice(internal.NewUInt64Slice(&ms.orig.BucketCounts, ms.state)) + return pcommon.UInt64Slice(internal.NewUInt64SliceWrapper(&ms.orig.BucketCounts, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms ExponentialHistogramDataPointBuckets) CopyTo(dest ExponentialHistogramDataPointBuckets) { dest.state.AssertMutable() - internal.CopyOrigExponentialHistogramDataPoint_Buckets(dest.orig, ms.orig) + internal.CopyExponentialHistogramDataPointBuckets(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_exponentialhistogramdatapointbuckets_test.go b/pdata/pmetric/generated_exponentialhistogramdatapointbuckets_test.go index 06e1aac2707..abe365b0395 100644 --- a/pdata/pmetric/generated_exponentialhistogramdatapointbuckets_test.go +++ b/pdata/pmetric/generated_exponentialhistogramdatapointbuckets_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,10 +26,10 @@ func TestExponentialHistogramDataPointBuckets_MoveTo(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - ms.MoveTo(newExponentialHistogramDataPointBuckets(internal.NewOrigExponentialHistogramDataPoint_Buckets(), sharedState)) + ms.MoveTo(newExponentialHistogramDataPointBuckets(internal.NewExponentialHistogramDataPointBuckets(), sharedState)) }) assert.Panics(t, func() { - newExponentialHistogramDataPointBuckets(internal.NewOrigExponentialHistogramDataPoint_Buckets(), sharedState).MoveTo(dest) + newExponentialHistogramDataPointBuckets(internal.NewExponentialHistogramDataPointBuckets(), sharedState).MoveTo(dest) }) } @@ -45,7 +44,7 @@ func TestExponentialHistogramDataPointBuckets_CopyTo(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - ms.CopyTo(newExponentialHistogramDataPointBuckets(internal.NewOrigExponentialHistogramDataPoint_Buckets(), sharedState)) + ms.CopyTo(newExponentialHistogramDataPointBuckets(internal.NewExponentialHistogramDataPointBuckets(), sharedState)) }) } @@ -57,18 +56,17 @@ func TestExponentialHistogramDataPointBuckets_Offset(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExponentialHistogramDataPointBuckets(&otlpmetrics.ExponentialHistogramDataPoint_Buckets{}, sharedState).SetOffset(int32(13)) + newExponentialHistogramDataPointBuckets(internal.NewExponentialHistogramDataPointBuckets(), sharedState).SetOffset(int32(13)) }) } func TestExponentialHistogramDataPointBuckets_BucketCounts(t *testing.T) { ms := NewExponentialHistogramDataPointBuckets() assert.Equal(t, pcommon.NewUInt64Slice(), ms.BucketCounts()) - ms.orig.BucketCounts = internal.GenerateOrigTestUint64Slice() - assert.Equal(t, pcommon.UInt64Slice(internal.GenerateTestUInt64Slice()), ms.BucketCounts()) + ms.orig.BucketCounts = internal.GenTestUint64Slice() + assert.Equal(t, pcommon.UInt64Slice(internal.GenTestUInt64SliceWrapper()), ms.BucketCounts()) } func generateTestExponentialHistogramDataPointBuckets() ExponentialHistogramDataPointBuckets { - ms := newExponentialHistogramDataPointBuckets(internal.GenTestOrigExponentialHistogramDataPoint_Buckets(), internal.NewState()) - return ms + return newExponentialHistogramDataPointBuckets(internal.GenTestExponentialHistogramDataPointBuckets(), internal.NewState()) } diff --git a/pdata/pmetric/generated_exponentialhistogramdatapointslice.go b/pdata/pmetric/generated_exponentialhistogramdatapointslice.go index 819e783b356..6a343df5991 100644 --- a/pdata/pmetric/generated_exponentialhistogramdatapointslice.go +++ b/pdata/pmetric/generated_exponentialhistogramdatapointslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // ExponentialHistogramDataPointSlice logically represents a slice of ExponentialHistogramDataPoint. @@ -22,18 +21,18 @@ import ( // Must use NewExponentialHistogramDataPointSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ExponentialHistogramDataPointSlice struct { - orig *[]*otlpmetrics.ExponentialHistogramDataPoint + orig *[]*internal.ExponentialHistogramDataPoint state *internal.State } -func newExponentialHistogramDataPointSlice(orig *[]*otlpmetrics.ExponentialHistogramDataPoint, state *internal.State) ExponentialHistogramDataPointSlice { +func newExponentialHistogramDataPointSlice(orig *[]*internal.ExponentialHistogramDataPoint, state *internal.State) ExponentialHistogramDataPointSlice { return ExponentialHistogramDataPointSlice{orig: orig, state: state} } // NewExponentialHistogramDataPointSlice creates a ExponentialHistogramDataPointSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewExponentialHistogramDataPointSlice() ExponentialHistogramDataPointSlice { - orig := []*otlpmetrics.ExponentialHistogramDataPoint(nil) + orig := []*internal.ExponentialHistogramDataPoint(nil) return newExponentialHistogramDataPointSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ExponentialHistogramDataPointSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.ExponentialHistogramDataPoint, len(*es.orig), newCap) + newOrig := make([]*internal.ExponentialHistogramDataPoint, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ExponentialHistogramDataPointSlice) EnsureCapacity(newCap int) { // It returns the newly added ExponentialHistogramDataPoint. func (es ExponentialHistogramDataPointSlice) AppendEmpty() ExponentialHistogramDataPoint { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigExponentialHistogramDataPoint()) + *es.orig = append(*es.orig, internal.NewExponentialHistogramDataPoint()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ExponentialHistogramDataPointSlice) RemoveIf(f func(ExponentialHistogra newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigExponentialHistogramDataPoint((*es.orig)[i], true) + internal.DeleteExponentialHistogramDataPoint((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ExponentialHistogramDataPointSlice) CopyTo(dest ExponentialHistogramDat if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigExponentialHistogramDataPointSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyExponentialHistogramDataPointPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ExponentialHistogramDataPoint elements within ExponentialHistogramDataPointSlice given the diff --git a/pdata/pmetric/generated_exponentialhistogramdatapointslice_test.go b/pdata/pmetric/generated_exponentialhistogramdatapointslice_test.go index e32a33052f9..55682dc1c4f 100644 --- a/pdata/pmetric/generated_exponentialhistogramdatapointslice_test.go +++ b/pdata/pmetric/generated_exponentialhistogramdatapointslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestExponentialHistogramDataPointSlice(t *testing.T) { es := NewExponentialHistogramDataPointSlice() assert.Equal(t, 0, es.Len()) - es = newExponentialHistogramDataPointSlice(&[]*otlpmetrics.ExponentialHistogramDataPoint{}, internal.NewState()) + es = newExponentialHistogramDataPointSlice(&[]*internal.ExponentialHistogramDataPoint{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewExponentialHistogramDataPoint() @@ -27,7 +26,7 @@ func TestExponentialHistogramDataPointSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigExponentialHistogramDataPoint() + (*es.orig)[i] = internal.GenTestExponentialHistogramDataPoint() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestExponentialHistogramDataPointSlice(t *testing.T) { func TestExponentialHistogramDataPointSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newExponentialHistogramDataPointSlice(&[]*otlpmetrics.ExponentialHistogramDataPoint{}, sharedState) + es := newExponentialHistogramDataPointSlice(&[]*internal.ExponentialHistogramDataPoint{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestExponentialHistogramDataPointSlice_Sort(t *testing.T) { func generateTestExponentialHistogramDataPointSlice() ExponentialHistogramDataPointSlice { ms := NewExponentialHistogramDataPointSlice() - *ms.orig = internal.GenerateOrigTestExponentialHistogramDataPointSlice() + *ms.orig = internal.GenTestExponentialHistogramDataPointPtrSlice() return ms } diff --git a/pdata/pmetric/generated_gauge.go b/pdata/pmetric/generated_gauge.go index 35ae4bf3d1e..c05f403a6bc 100644 --- a/pdata/pmetric/generated_gauge.go +++ b/pdata/pmetric/generated_gauge.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // Gauge represents the type of a numeric metric that always exports the "current value" for every data point. @@ -19,11 +18,11 @@ import ( // Must use NewGauge function to create new instances. // Important: zero-initialized instance is not valid for use. type Gauge struct { - orig *otlpmetrics.Gauge + orig *internal.Gauge state *internal.State } -func newGauge(orig *otlpmetrics.Gauge, state *internal.State) Gauge { +func newGauge(orig *internal.Gauge, state *internal.State) Gauge { return Gauge{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newGauge(orig *otlpmetrics.Gauge, state *internal.State) Gauge { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewGauge() Gauge { - return newGauge(internal.NewOrigGauge(), internal.NewState()) + return newGauge(internal.NewGauge(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms Gauge) MoveTo(dest Gauge) { if ms.orig == dest.orig { return } - internal.DeleteOrigGauge(dest.orig, false) + internal.DeleteGauge(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -56,5 +55,5 @@ func (ms Gauge) DataPoints() NumberDataPointSlice { // CopyTo copies all properties from the current struct overriding the destination. func (ms Gauge) CopyTo(dest Gauge) { dest.state.AssertMutable() - internal.CopyOrigGauge(dest.orig, ms.orig) + internal.CopyGauge(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_gauge_test.go b/pdata/pmetric/generated_gauge_test.go index 8f1a913d748..4ded47df0cd 100644 --- a/pdata/pmetric/generated_gauge_test.go +++ b/pdata/pmetric/generated_gauge_test.go @@ -24,8 +24,8 @@ func TestGauge_MoveTo(t *testing.T) { assert.Equal(t, generateTestGauge(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newGauge(internal.NewOrigGauge(), sharedState)) }) - assert.Panics(t, func() { newGauge(internal.NewOrigGauge(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newGauge(internal.NewGauge(), sharedState)) }) + assert.Panics(t, func() { newGauge(internal.NewGauge(), sharedState).MoveTo(dest) }) } func TestGauge_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestGauge_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newGauge(internal.NewOrigGauge(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newGauge(internal.NewGauge(), sharedState)) }) } func TestGauge_DataPoints(t *testing.T) { ms := NewGauge() assert.Equal(t, NewNumberDataPointSlice(), ms.DataPoints()) - ms.orig.DataPoints = internal.GenerateOrigTestNumberDataPointSlice() + ms.orig.DataPoints = internal.GenTestNumberDataPointPtrSlice() assert.Equal(t, generateTestNumberDataPointSlice(), ms.DataPoints()) } func generateTestGauge() Gauge { - ms := newGauge(internal.GenTestOrigGauge(), internal.NewState()) - return ms + return newGauge(internal.GenTestGauge(), internal.NewState()) } diff --git a/pdata/pmetric/generated_histogram.go b/pdata/pmetric/generated_histogram.go index f96f70be290..924cd4f1d70 100644 --- a/pdata/pmetric/generated_histogram.go +++ b/pdata/pmetric/generated_histogram.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // Histogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported measurements over a time interval. @@ -19,11 +18,11 @@ import ( // Must use NewHistogram function to create new instances. // Important: zero-initialized instance is not valid for use. type Histogram struct { - orig *otlpmetrics.Histogram + orig *internal.Histogram state *internal.State } -func newHistogram(orig *otlpmetrics.Histogram, state *internal.State) Histogram { +func newHistogram(orig *internal.Histogram, state *internal.State) Histogram { return Histogram{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newHistogram(orig *otlpmetrics.Histogram, state *internal.State) Histogram // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewHistogram() Histogram { - return newHistogram(internal.NewOrigHistogram(), internal.NewState()) + return newHistogram(internal.NewHistogram(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms Histogram) MoveTo(dest Histogram) { if ms.orig == dest.orig { return } - internal.DeleteOrigHistogram(dest.orig, false) + internal.DeleteHistogram(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -61,11 +60,11 @@ func (ms Histogram) AggregationTemporality() AggregationTemporality { // SetAggregationTemporality replaces the aggregationtemporality associated with this Histogram. func (ms Histogram) SetAggregationTemporality(v AggregationTemporality) { ms.state.AssertMutable() - ms.orig.AggregationTemporality = otlpmetrics.AggregationTemporality(v) + ms.orig.AggregationTemporality = internal.AggregationTemporality(v) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Histogram) CopyTo(dest Histogram) { dest.state.AssertMutable() - internal.CopyOrigHistogram(dest.orig, ms.orig) + internal.CopyHistogram(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_histogram_test.go b/pdata/pmetric/generated_histogram_test.go index 532705bb287..95ddfdfdd69 100644 --- a/pdata/pmetric/generated_histogram_test.go +++ b/pdata/pmetric/generated_histogram_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestHistogram_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestHistogram_MoveTo(t *testing.T) { assert.Equal(t, generateTestHistogram(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newHistogram(internal.NewOrigHistogram(), sharedState)) }) - assert.Panics(t, func() { newHistogram(internal.NewOrigHistogram(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newHistogram(internal.NewHistogram(), sharedState)) }) + assert.Panics(t, func() { newHistogram(internal.NewHistogram(), sharedState).MoveTo(dest) }) } func TestHistogram_CopyTo(t *testing.T) { @@ -39,25 +38,24 @@ func TestHistogram_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newHistogram(internal.NewOrigHistogram(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newHistogram(internal.NewHistogram(), sharedState)) }) } func TestHistogram_DataPoints(t *testing.T) { ms := NewHistogram() assert.Equal(t, NewHistogramDataPointSlice(), ms.DataPoints()) - ms.orig.DataPoints = internal.GenerateOrigTestHistogramDataPointSlice() + ms.orig.DataPoints = internal.GenTestHistogramDataPointPtrSlice() assert.Equal(t, generateTestHistogramDataPointSlice(), ms.DataPoints()) } func TestHistogram_AggregationTemporality(t *testing.T) { ms := NewHistogram() - assert.Equal(t, AggregationTemporality(otlpmetrics.AggregationTemporality(0)), ms.AggregationTemporality()) - testValAggregationTemporality := AggregationTemporality(otlpmetrics.AggregationTemporality(1)) + assert.Equal(t, AggregationTemporality(internal.AggregationTemporality(0)), ms.AggregationTemporality()) + testValAggregationTemporality := AggregationTemporality(internal.AggregationTemporality(1)) ms.SetAggregationTemporality(testValAggregationTemporality) assert.Equal(t, testValAggregationTemporality, ms.AggregationTemporality()) } func generateTestHistogram() Histogram { - ms := newHistogram(internal.GenTestOrigHistogram(), internal.NewState()) - return ms + return newHistogram(internal.GenTestHistogram(), internal.NewState()) } diff --git a/pdata/pmetric/generated_histogramdatapoint.go b/pdata/pmetric/generated_histogramdatapoint.go index 3bbc2e18303..3ed9090a5c1 100644 --- a/pdata/pmetric/generated_histogramdatapoint.go +++ b/pdata/pmetric/generated_histogramdatapoint.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewHistogramDataPoint function to create new instances. // Important: zero-initialized instance is not valid for use. type HistogramDataPoint struct { - orig *otlpmetrics.HistogramDataPoint + orig *internal.HistogramDataPoint state *internal.State } -func newHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, state *internal.State) HistogramDataPoint { +func newHistogramDataPoint(orig *internal.HistogramDataPoint, state *internal.State) HistogramDataPoint { return HistogramDataPoint{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newHistogramDataPoint(orig *otlpmetrics.HistogramDataPoint, state *internal // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewHistogramDataPoint() HistogramDataPoint { - return newHistogramDataPoint(internal.NewOrigHistogramDataPoint(), internal.NewState()) + return newHistogramDataPoint(internal.NewHistogramDataPoint(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms HistogramDataPoint) MoveTo(dest HistogramDataPoint) { if ms.orig == dest.orig { return } - internal.DeleteOrigHistogramDataPoint(dest.orig, false) + internal.DeleteHistogramDataPoint(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Attributes returns the Attributes associated with this HistogramDataPoint. func (ms HistogramDataPoint) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // StartTimestamp returns the starttimestamp associated with this HistogramDataPoint. @@ -101,7 +100,7 @@ func (ms HistogramDataPoint) HasSum() bool { // SetSum replaces the sum associated with this HistogramDataPoint. func (ms HistogramDataPoint) SetSum(v float64) { ms.state.AssertMutable() - ms.orig.Sum_ = &otlpmetrics.HistogramDataPoint_Sum{Sum: v} + ms.orig.Sum_ = &internal.HistogramDataPoint_Sum{Sum: v} } // RemoveSum removes the sum associated with this HistogramDataPoint. @@ -112,12 +111,12 @@ func (ms HistogramDataPoint) RemoveSum() { // BucketCounts returns the BucketCounts associated with this HistogramDataPoint. func (ms HistogramDataPoint) BucketCounts() pcommon.UInt64Slice { - return pcommon.UInt64Slice(internal.NewUInt64Slice(&ms.orig.BucketCounts, ms.state)) + return pcommon.UInt64Slice(internal.NewUInt64SliceWrapper(&ms.orig.BucketCounts, ms.state)) } // ExplicitBounds returns the ExplicitBounds associated with this HistogramDataPoint. func (ms HistogramDataPoint) ExplicitBounds() pcommon.Float64Slice { - return pcommon.Float64Slice(internal.NewFloat64Slice(&ms.orig.ExplicitBounds, ms.state)) + return pcommon.Float64Slice(internal.NewFloat64SliceWrapper(&ms.orig.ExplicitBounds, ms.state)) } // Exemplars returns the Exemplars associated with this HistogramDataPoint. @@ -150,7 +149,7 @@ func (ms HistogramDataPoint) HasMin() bool { // SetMin replaces the min associated with this HistogramDataPoint. func (ms HistogramDataPoint) SetMin(v float64) { ms.state.AssertMutable() - ms.orig.Min_ = &otlpmetrics.HistogramDataPoint_Min{Min: v} + ms.orig.Min_ = &internal.HistogramDataPoint_Min{Min: v} } // RemoveMin removes the min associated with this HistogramDataPoint. @@ -173,7 +172,7 @@ func (ms HistogramDataPoint) HasMax() bool { // SetMax replaces the max associated with this HistogramDataPoint. func (ms HistogramDataPoint) SetMax(v float64) { ms.state.AssertMutable() - ms.orig.Max_ = &otlpmetrics.HistogramDataPoint_Max{Max: v} + ms.orig.Max_ = &internal.HistogramDataPoint_Max{Max: v} } // RemoveMax removes the max associated with this HistogramDataPoint. @@ -185,5 +184,5 @@ func (ms HistogramDataPoint) RemoveMax() { // CopyTo copies all properties from the current struct overriding the destination. func (ms HistogramDataPoint) CopyTo(dest HistogramDataPoint) { dest.state.AssertMutable() - internal.CopyOrigHistogramDataPoint(dest.orig, ms.orig) + internal.CopyHistogramDataPoint(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_histogramdatapoint_test.go b/pdata/pmetric/generated_histogramdatapoint_test.go index 4c00f647b7b..e4874ba07d6 100644 --- a/pdata/pmetric/generated_histogramdatapoint_test.go +++ b/pdata/pmetric/generated_histogramdatapoint_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestHistogramDataPoint_MoveTo(t *testing.T) { assert.Equal(t, generateTestHistogramDataPoint(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newHistogramDataPoint(internal.NewOrigHistogramDataPoint(), sharedState)) }) - assert.Panics(t, func() { newHistogramDataPoint(internal.NewOrigHistogramDataPoint(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newHistogramDataPoint(internal.NewHistogramDataPoint(), sharedState)) }) + assert.Panics(t, func() { newHistogramDataPoint(internal.NewHistogramDataPoint(), sharedState).MoveTo(dest) }) } func TestHistogramDataPoint_CopyTo(t *testing.T) { @@ -40,14 +39,14 @@ func TestHistogramDataPoint_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newHistogramDataPoint(internal.NewOrigHistogramDataPoint(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newHistogramDataPoint(internal.NewHistogramDataPoint(), sharedState)) }) } func TestHistogramDataPoint_Attributes(t *testing.T) { ms := NewHistogramDataPoint() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestHistogramDataPoint_StartTimestamp(t *testing.T) { @@ -73,7 +72,7 @@ func TestHistogramDataPoint_Count(t *testing.T) { assert.Equal(t, uint64(13), ms.Count()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newHistogramDataPoint(&otlpmetrics.HistogramDataPoint{}, sharedState).SetCount(uint64(13)) }) + assert.Panics(t, func() { newHistogramDataPoint(internal.NewHistogramDataPoint(), sharedState).SetCount(uint64(13)) }) } func TestHistogramDataPoint_Sum(t *testing.T) { @@ -93,21 +92,21 @@ func TestHistogramDataPoint_Sum(t *testing.T) { func TestHistogramDataPoint_BucketCounts(t *testing.T) { ms := NewHistogramDataPoint() assert.Equal(t, pcommon.NewUInt64Slice(), ms.BucketCounts()) - ms.orig.BucketCounts = internal.GenerateOrigTestUint64Slice() - assert.Equal(t, pcommon.UInt64Slice(internal.GenerateTestUInt64Slice()), ms.BucketCounts()) + ms.orig.BucketCounts = internal.GenTestUint64Slice() + assert.Equal(t, pcommon.UInt64Slice(internal.GenTestUInt64SliceWrapper()), ms.BucketCounts()) } func TestHistogramDataPoint_ExplicitBounds(t *testing.T) { ms := NewHistogramDataPoint() assert.Equal(t, pcommon.NewFloat64Slice(), ms.ExplicitBounds()) - ms.orig.ExplicitBounds = internal.GenerateOrigTestFloat64Slice() - assert.Equal(t, pcommon.Float64Slice(internal.GenerateTestFloat64Slice()), ms.ExplicitBounds()) + ms.orig.ExplicitBounds = internal.GenTestFloat64Slice() + assert.Equal(t, pcommon.Float64Slice(internal.GenTestFloat64SliceWrapper()), ms.ExplicitBounds()) } func TestHistogramDataPoint_Exemplars(t *testing.T) { ms := NewHistogramDataPoint() assert.Equal(t, NewExemplarSlice(), ms.Exemplars()) - ms.orig.Exemplars = internal.GenerateOrigTestExemplarSlice() + ms.orig.Exemplars = internal.GenTestExemplarSlice() assert.Equal(t, generateTestExemplarSlice(), ms.Exemplars()) } @@ -148,6 +147,5 @@ func TestHistogramDataPoint_Max(t *testing.T) { } func generateTestHistogramDataPoint() HistogramDataPoint { - ms := newHistogramDataPoint(internal.GenTestOrigHistogramDataPoint(), internal.NewState()) - return ms + return newHistogramDataPoint(internal.GenTestHistogramDataPoint(), internal.NewState()) } diff --git a/pdata/pmetric/generated_histogramdatapointslice.go b/pdata/pmetric/generated_histogramdatapointslice.go index 72f77725454..6761c447044 100644 --- a/pdata/pmetric/generated_histogramdatapointslice.go +++ b/pdata/pmetric/generated_histogramdatapointslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // HistogramDataPointSlice logically represents a slice of HistogramDataPoint. @@ -22,18 +21,18 @@ import ( // Must use NewHistogramDataPointSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type HistogramDataPointSlice struct { - orig *[]*otlpmetrics.HistogramDataPoint + orig *[]*internal.HistogramDataPoint state *internal.State } -func newHistogramDataPointSlice(orig *[]*otlpmetrics.HistogramDataPoint, state *internal.State) HistogramDataPointSlice { +func newHistogramDataPointSlice(orig *[]*internal.HistogramDataPoint, state *internal.State) HistogramDataPointSlice { return HistogramDataPointSlice{orig: orig, state: state} } // NewHistogramDataPointSlice creates a HistogramDataPointSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewHistogramDataPointSlice() HistogramDataPointSlice { - orig := []*otlpmetrics.HistogramDataPoint(nil) + orig := []*internal.HistogramDataPoint(nil) return newHistogramDataPointSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es HistogramDataPointSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.HistogramDataPoint, len(*es.orig), newCap) + newOrig := make([]*internal.HistogramDataPoint, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es HistogramDataPointSlice) EnsureCapacity(newCap int) { // It returns the newly added HistogramDataPoint. func (es HistogramDataPointSlice) AppendEmpty() HistogramDataPoint { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigHistogramDataPoint()) + *es.orig = append(*es.orig, internal.NewHistogramDataPoint()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es HistogramDataPointSlice) RemoveIf(f func(HistogramDataPoint) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigHistogramDataPoint((*es.orig)[i], true) + internal.DeleteHistogramDataPoint((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es HistogramDataPointSlice) CopyTo(dest HistogramDataPointSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigHistogramDataPointSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyHistogramDataPointPtrSlice(*dest.orig, *es.orig) } // Sort sorts the HistogramDataPoint elements within HistogramDataPointSlice given the diff --git a/pdata/pmetric/generated_histogramdatapointslice_test.go b/pdata/pmetric/generated_histogramdatapointslice_test.go index 5fa860b8d98..635f5e35f6a 100644 --- a/pdata/pmetric/generated_histogramdatapointslice_test.go +++ b/pdata/pmetric/generated_histogramdatapointslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestHistogramDataPointSlice(t *testing.T) { es := NewHistogramDataPointSlice() assert.Equal(t, 0, es.Len()) - es = newHistogramDataPointSlice(&[]*otlpmetrics.HistogramDataPoint{}, internal.NewState()) + es = newHistogramDataPointSlice(&[]*internal.HistogramDataPoint{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewHistogramDataPoint() @@ -27,7 +26,7 @@ func TestHistogramDataPointSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigHistogramDataPoint() + (*es.orig)[i] = internal.GenTestHistogramDataPoint() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestHistogramDataPointSlice(t *testing.T) { func TestHistogramDataPointSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newHistogramDataPointSlice(&[]*otlpmetrics.HistogramDataPoint{}, sharedState) + es := newHistogramDataPointSlice(&[]*internal.HistogramDataPoint{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestHistogramDataPointSlice_Sort(t *testing.T) { func generateTestHistogramDataPointSlice() HistogramDataPointSlice { ms := NewHistogramDataPointSlice() - *ms.orig = internal.GenerateOrigTestHistogramDataPointSlice() + *ms.orig = internal.GenTestHistogramDataPointPtrSlice() return ms } diff --git a/pdata/pmetric/generated_metric.go b/pdata/pmetric/generated_metric.go index cd54c71fca1..04eebe8e09a 100644 --- a/pdata/pmetric/generated_metric.go +++ b/pdata/pmetric/generated_metric.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -21,11 +20,11 @@ import ( // Must use NewMetric function to create new instances. // Important: zero-initialized instance is not valid for use. type Metric struct { - orig *otlpmetrics.Metric + orig *internal.Metric state *internal.State } -func newMetric(orig *otlpmetrics.Metric, state *internal.State) Metric { +func newMetric(orig *internal.Metric, state *internal.State) Metric { return Metric{orig: orig, state: state} } @@ -34,7 +33,7 @@ func newMetric(orig *otlpmetrics.Metric, state *internal.State) Metric { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewMetric() Metric { - return newMetric(internal.NewOrigMetric(), internal.NewState()) + return newMetric(internal.NewMetric(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -46,7 +45,7 @@ func (ms Metric) MoveTo(dest Metric) { if ms.orig == dest.orig { return } - internal.DeleteOrigMetric(dest.orig, false) + internal.DeleteMetric(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -87,15 +86,15 @@ func (ms Metric) SetUnit(v string) { // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) Type() MetricType { switch ms.orig.Data.(type) { - case *otlpmetrics.Metric_Gauge: + case *internal.Metric_Gauge: return MetricTypeGauge - case *otlpmetrics.Metric_Sum: + case *internal.Metric_Sum: return MetricTypeSum - case *otlpmetrics.Metric_Histogram: + case *internal.Metric_Histogram: return MetricTypeHistogram - case *otlpmetrics.Metric_ExponentialHistogram: + case *internal.Metric_ExponentialHistogram: return MetricTypeExponentialHistogram - case *otlpmetrics.Metric_Summary: + case *internal.Metric_Summary: return MetricTypeSummary } return MetricTypeEmpty @@ -108,7 +107,7 @@ func (ms Metric) Type() MetricType { // // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) Gauge() Gauge { - v, ok := ms.orig.GetData().(*otlpmetrics.Metric_Gauge) + v, ok := ms.orig.GetData().(*internal.Metric_Gauge) if !ok { return Gauge{} } @@ -122,13 +121,13 @@ func (ms Metric) Gauge() Gauge { // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) SetEmptyGauge() Gauge { ms.state.AssertMutable() - var ov *otlpmetrics.Metric_Gauge + var ov *internal.Metric_Gauge if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Gauge{} + ov = &internal.Metric_Gauge{} } else { - ov = internal.ProtoPoolMetric_Gauge.Get().(*otlpmetrics.Metric_Gauge) + ov = internal.ProtoPoolMetric_Gauge.Get().(*internal.Metric_Gauge) } - ov.Gauge = internal.NewOrigGauge() + ov.Gauge = internal.NewGauge() ms.orig.Data = ov return newGauge(ov.Gauge, ms.state) } @@ -140,7 +139,7 @@ func (ms Metric) SetEmptyGauge() Gauge { // // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) Sum() Sum { - v, ok := ms.orig.GetData().(*otlpmetrics.Metric_Sum) + v, ok := ms.orig.GetData().(*internal.Metric_Sum) if !ok { return Sum{} } @@ -154,13 +153,13 @@ func (ms Metric) Sum() Sum { // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) SetEmptySum() Sum { ms.state.AssertMutable() - var ov *otlpmetrics.Metric_Sum + var ov *internal.Metric_Sum if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Sum{} + ov = &internal.Metric_Sum{} } else { - ov = internal.ProtoPoolMetric_Sum.Get().(*otlpmetrics.Metric_Sum) + ov = internal.ProtoPoolMetric_Sum.Get().(*internal.Metric_Sum) } - ov.Sum = internal.NewOrigSum() + ov.Sum = internal.NewSum() ms.orig.Data = ov return newSum(ov.Sum, ms.state) } @@ -172,7 +171,7 @@ func (ms Metric) SetEmptySum() Sum { // // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) Histogram() Histogram { - v, ok := ms.orig.GetData().(*otlpmetrics.Metric_Histogram) + v, ok := ms.orig.GetData().(*internal.Metric_Histogram) if !ok { return Histogram{} } @@ -186,13 +185,13 @@ func (ms Metric) Histogram() Histogram { // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) SetEmptyHistogram() Histogram { ms.state.AssertMutable() - var ov *otlpmetrics.Metric_Histogram + var ov *internal.Metric_Histogram if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Histogram{} + ov = &internal.Metric_Histogram{} } else { - ov = internal.ProtoPoolMetric_Histogram.Get().(*otlpmetrics.Metric_Histogram) + ov = internal.ProtoPoolMetric_Histogram.Get().(*internal.Metric_Histogram) } - ov.Histogram = internal.NewOrigHistogram() + ov.Histogram = internal.NewHistogram() ms.orig.Data = ov return newHistogram(ov.Histogram, ms.state) } @@ -204,7 +203,7 @@ func (ms Metric) SetEmptyHistogram() Histogram { // // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) ExponentialHistogram() ExponentialHistogram { - v, ok := ms.orig.GetData().(*otlpmetrics.Metric_ExponentialHistogram) + v, ok := ms.orig.GetData().(*internal.Metric_ExponentialHistogram) if !ok { return ExponentialHistogram{} } @@ -218,13 +217,13 @@ func (ms Metric) ExponentialHistogram() ExponentialHistogram { // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) SetEmptyExponentialHistogram() ExponentialHistogram { ms.state.AssertMutable() - var ov *otlpmetrics.Metric_ExponentialHistogram + var ov *internal.Metric_ExponentialHistogram if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_ExponentialHistogram{} + ov = &internal.Metric_ExponentialHistogram{} } else { - ov = internal.ProtoPoolMetric_ExponentialHistogram.Get().(*otlpmetrics.Metric_ExponentialHistogram) + ov = internal.ProtoPoolMetric_ExponentialHistogram.Get().(*internal.Metric_ExponentialHistogram) } - ov.ExponentialHistogram = internal.NewOrigExponentialHistogram() + ov.ExponentialHistogram = internal.NewExponentialHistogram() ms.orig.Data = ov return newExponentialHistogram(ov.ExponentialHistogram, ms.state) } @@ -236,7 +235,7 @@ func (ms Metric) SetEmptyExponentialHistogram() ExponentialHistogram { // // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) Summary() Summary { - v, ok := ms.orig.GetData().(*otlpmetrics.Metric_Summary) + v, ok := ms.orig.GetData().(*internal.Metric_Summary) if !ok { return Summary{} } @@ -250,24 +249,24 @@ func (ms Metric) Summary() Summary { // Calling this function on zero-initialized Metric will cause a panic. func (ms Metric) SetEmptySummary() Summary { ms.state.AssertMutable() - var ov *otlpmetrics.Metric_Summary + var ov *internal.Metric_Summary if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.Metric_Summary{} + ov = &internal.Metric_Summary{} } else { - ov = internal.ProtoPoolMetric_Summary.Get().(*otlpmetrics.Metric_Summary) + ov = internal.ProtoPoolMetric_Summary.Get().(*internal.Metric_Summary) } - ov.Summary = internal.NewOrigSummary() + ov.Summary = internal.NewSummary() ms.orig.Data = ov return newSummary(ov.Summary, ms.state) } // Metadata returns the Metadata associated with this Metric. func (ms Metric) Metadata() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Metadata, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Metadata, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Metric) CopyTo(dest Metric) { dest.state.AssertMutable() - internal.CopyOrigMetric(dest.orig, ms.orig) + internal.CopyMetric(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_metric_test.go b/pdata/pmetric/generated_metric_test.go index edfb46e922c..70f91cb3dab 100644 --- a/pdata/pmetric/generated_metric_test.go +++ b/pdata/pmetric/generated_metric_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestMetric_MoveTo(t *testing.T) { assert.Equal(t, generateTestMetric(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newMetric(internal.NewOrigMetric(), sharedState)) }) - assert.Panics(t, func() { newMetric(internal.NewOrigMetric(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newMetric(internal.NewMetric(), sharedState)) }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).MoveTo(dest) }) } func TestMetric_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestMetric_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newMetric(internal.NewOrigMetric(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newMetric(internal.NewMetric(), sharedState)) }) } func TestMetric_Name(t *testing.T) { @@ -50,7 +49,7 @@ func TestMetric_Name(t *testing.T) { assert.Equal(t, "test_name", ms.Name()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetName("test_name") }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetName("test_name") }) } func TestMetric_Description(t *testing.T) { @@ -60,7 +59,7 @@ func TestMetric_Description(t *testing.T) { assert.Equal(t, "test_description", ms.Description()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetDescription("test_description") }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetDescription("test_description") }) } func TestMetric_Unit(t *testing.T) { @@ -70,7 +69,7 @@ func TestMetric_Unit(t *testing.T) { assert.Equal(t, "test_unit", ms.Unit()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetUnit("test_unit") }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetUnit("test_unit") }) } func TestMetric_Type(t *testing.T) { @@ -82,70 +81,69 @@ func TestMetric_Gauge(t *testing.T) { ms := NewMetric() ms.SetEmptyGauge() assert.Equal(t, NewGauge(), ms.Gauge()) - ms.orig.GetData().(*otlpmetrics.Metric_Gauge).Gauge = internal.GenTestOrigGauge() + ms.orig.GetData().(*internal.Metric_Gauge).Gauge = internal.GenTestGauge() assert.Equal(t, MetricTypeGauge, ms.Type()) assert.Equal(t, generateTestGauge(), ms.Gauge()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetEmptyGauge() }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetEmptyGauge() }) } func TestMetric_Sum(t *testing.T) { ms := NewMetric() ms.SetEmptySum() assert.Equal(t, NewSum(), ms.Sum()) - ms.orig.GetData().(*otlpmetrics.Metric_Sum).Sum = internal.GenTestOrigSum() + ms.orig.GetData().(*internal.Metric_Sum).Sum = internal.GenTestSum() assert.Equal(t, MetricTypeSum, ms.Type()) assert.Equal(t, generateTestSum(), ms.Sum()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetEmptySum() }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetEmptySum() }) } func TestMetric_Histogram(t *testing.T) { ms := NewMetric() ms.SetEmptyHistogram() assert.Equal(t, NewHistogram(), ms.Histogram()) - ms.orig.GetData().(*otlpmetrics.Metric_Histogram).Histogram = internal.GenTestOrigHistogram() + ms.orig.GetData().(*internal.Metric_Histogram).Histogram = internal.GenTestHistogram() assert.Equal(t, MetricTypeHistogram, ms.Type()) assert.Equal(t, generateTestHistogram(), ms.Histogram()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetEmptyHistogram() }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetEmptyHistogram() }) } func TestMetric_ExponentialHistogram(t *testing.T) { ms := NewMetric() ms.SetEmptyExponentialHistogram() assert.Equal(t, NewExponentialHistogram(), ms.ExponentialHistogram()) - ms.orig.GetData().(*otlpmetrics.Metric_ExponentialHistogram).ExponentialHistogram = internal.GenTestOrigExponentialHistogram() + ms.orig.GetData().(*internal.Metric_ExponentialHistogram).ExponentialHistogram = internal.GenTestExponentialHistogram() assert.Equal(t, MetricTypeExponentialHistogram, ms.Type()) assert.Equal(t, generateTestExponentialHistogram(), ms.ExponentialHistogram()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetEmptyExponentialHistogram() }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetEmptyExponentialHistogram() }) } func TestMetric_Summary(t *testing.T) { ms := NewMetric() ms.SetEmptySummary() assert.Equal(t, NewSummary(), ms.Summary()) - ms.orig.GetData().(*otlpmetrics.Metric_Summary).Summary = internal.GenTestOrigSummary() + ms.orig.GetData().(*internal.Metric_Summary).Summary = internal.GenTestSummary() assert.Equal(t, MetricTypeSummary, ms.Type()) assert.Equal(t, generateTestSummary(), ms.Summary()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMetric(&otlpmetrics.Metric{}, sharedState).SetEmptySummary() }) + assert.Panics(t, func() { newMetric(internal.NewMetric(), sharedState).SetEmptySummary() }) } func TestMetric_Metadata(t *testing.T) { ms := NewMetric() assert.Equal(t, pcommon.NewMap(), ms.Metadata()) - ms.orig.Metadata = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Metadata()) + ms.orig.Metadata = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Metadata()) } func generateTestMetric() Metric { - ms := newMetric(internal.GenTestOrigMetric(), internal.NewState()) - return ms + return newMetric(internal.GenTestMetric(), internal.NewState()) } diff --git a/pdata/pmetric/generated_metrics.go b/pdata/pmetric/generated_metrics.go index 09c6600ccd7..9d873d5ee0b 100644 --- a/pdata/pmetric/generated_metrics.go +++ b/pdata/pmetric/generated_metrics.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" ) // Metrics is the top-level struct that is propagated through the metrics pipeline. @@ -19,10 +18,10 @@ import ( // // Must use NewMetrics function to create new instances. // Important: zero-initialized instance is not valid for use. -type Metrics internal.Metrics +type Metrics internal.MetricsWrapper -func newMetrics(orig *otlpcollectormetrics.ExportMetricsServiceRequest, state *internal.State) Metrics { - return Metrics(internal.NewMetrics(orig, state)) +func newMetrics(orig *internal.ExportMetricsServiceRequest, state *internal.State) Metrics { + return Metrics(internal.NewMetricsWrapper(orig, state)) } // NewMetrics creates a new empty Metrics. @@ -30,7 +29,7 @@ func newMetrics(orig *otlpcollectormetrics.ExportMetricsServiceRequest, state *i // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewMetrics() Metrics { - return newMetrics(internal.NewOrigExportMetricsServiceRequest(), internal.NewState()) + return newMetrics(internal.NewExportMetricsServiceRequest(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -42,7 +41,7 @@ func (ms Metrics) MoveTo(dest Metrics) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigExportMetricsServiceRequest(dest.getOrig(), false) + internal.DeleteExportMetricsServiceRequest(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } @@ -54,13 +53,13 @@ func (ms Metrics) ResourceMetrics() ResourceMetricsSlice { // CopyTo copies all properties from the current struct overriding the destination. func (ms Metrics) CopyTo(dest Metrics) { dest.getState().AssertMutable() - internal.CopyOrigExportMetricsServiceRequest(dest.getOrig(), ms.getOrig()) + internal.CopyExportMetricsServiceRequest(dest.getOrig(), ms.getOrig()) } -func (ms Metrics) getOrig() *otlpcollectormetrics.ExportMetricsServiceRequest { - return internal.GetOrigMetrics(internal.Metrics(ms)) +func (ms Metrics) getOrig() *internal.ExportMetricsServiceRequest { + return internal.GetMetricsOrig(internal.MetricsWrapper(ms)) } func (ms Metrics) getState() *internal.State { - return internal.GetMetricsState(internal.Metrics(ms)) + return internal.GetMetricsState(internal.MetricsWrapper(ms)) } diff --git a/pdata/pmetric/generated_metrics_test.go b/pdata/pmetric/generated_metrics_test.go index c459574465d..ad8b634c79b 100644 --- a/pdata/pmetric/generated_metrics_test.go +++ b/pdata/pmetric/generated_metrics_test.go @@ -24,8 +24,8 @@ func TestMetrics_MoveTo(t *testing.T) { assert.Equal(t, generateTestMetrics(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newMetrics(internal.NewOrigExportMetricsServiceRequest(), sharedState)) }) - assert.Panics(t, func() { newMetrics(internal.NewOrigExportMetricsServiceRequest(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newMetrics(internal.NewExportMetricsServiceRequest(), sharedState)) }) + assert.Panics(t, func() { newMetrics(internal.NewExportMetricsServiceRequest(), sharedState).MoveTo(dest) }) } func TestMetrics_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestMetrics_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newMetrics(internal.NewOrigExportMetricsServiceRequest(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newMetrics(internal.NewExportMetricsServiceRequest(), sharedState)) }) } func TestMetrics_ResourceMetrics(t *testing.T) { ms := NewMetrics() assert.Equal(t, NewResourceMetricsSlice(), ms.ResourceMetrics()) - ms.getOrig().ResourceMetrics = internal.GenerateOrigTestResourceMetricsSlice() + ms.getOrig().ResourceMetrics = internal.GenTestResourceMetricsPtrSlice() assert.Equal(t, generateTestResourceMetricsSlice(), ms.ResourceMetrics()) } func generateTestMetrics() Metrics { - ms := newMetrics(internal.GenTestOrigExportMetricsServiceRequest(), internal.NewState()) - return ms + return newMetrics(internal.GenTestExportMetricsServiceRequest(), internal.NewState()) } diff --git a/pdata/pmetric/generated_metricslice.go b/pdata/pmetric/generated_metricslice.go index c74e7a451f5..a8745522d82 100644 --- a/pdata/pmetric/generated_metricslice.go +++ b/pdata/pmetric/generated_metricslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // MetricSlice logically represents a slice of Metric. @@ -22,18 +21,18 @@ import ( // Must use NewMetricSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type MetricSlice struct { - orig *[]*otlpmetrics.Metric + orig *[]*internal.Metric state *internal.State } -func newMetricSlice(orig *[]*otlpmetrics.Metric, state *internal.State) MetricSlice { +func newMetricSlice(orig *[]*internal.Metric, state *internal.State) MetricSlice { return MetricSlice{orig: orig, state: state} } // NewMetricSlice creates a MetricSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewMetricSlice() MetricSlice { - orig := []*otlpmetrics.Metric(nil) + orig := []*internal.Metric(nil) return newMetricSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es MetricSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.Metric, len(*es.orig), newCap) + newOrig := make([]*internal.Metric, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es MetricSlice) EnsureCapacity(newCap int) { // It returns the newly added Metric. func (es MetricSlice) AppendEmpty() Metric { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigMetric()) + *es.orig = append(*es.orig, internal.NewMetric()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es MetricSlice) RemoveIf(f func(Metric) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigMetric((*es.orig)[i], true) + internal.DeleteMetric((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es MetricSlice) CopyTo(dest MetricSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigMetricSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyMetricPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Metric elements within MetricSlice given the diff --git a/pdata/pmetric/generated_metricslice_test.go b/pdata/pmetric/generated_metricslice_test.go index 7ed538fab90..990e45f46e9 100644 --- a/pdata/pmetric/generated_metricslice_test.go +++ b/pdata/pmetric/generated_metricslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestMetricSlice(t *testing.T) { es := NewMetricSlice() assert.Equal(t, 0, es.Len()) - es = newMetricSlice(&[]*otlpmetrics.Metric{}, internal.NewState()) + es = newMetricSlice(&[]*internal.Metric{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewMetric() @@ -27,7 +26,7 @@ func TestMetricSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigMetric() + (*es.orig)[i] = internal.GenTestMetric() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestMetricSlice(t *testing.T) { func TestMetricSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newMetricSlice(&[]*otlpmetrics.Metric{}, sharedState) + es := newMetricSlice(&[]*internal.Metric{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestMetricSlice_Sort(t *testing.T) { func generateTestMetricSlice() MetricSlice { ms := NewMetricSlice() - *ms.orig = internal.GenerateOrigTestMetricSlice() + *ms.orig = internal.GenTestMetricPtrSlice() return ms } diff --git a/pdata/pmetric/generated_numberdatapoint.go b/pdata/pmetric/generated_numberdatapoint.go index 52a441ee8ba..e61eba8a8c5 100644 --- a/pdata/pmetric/generated_numberdatapoint.go +++ b/pdata/pmetric/generated_numberdatapoint.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewNumberDataPoint function to create new instances. // Important: zero-initialized instance is not valid for use. type NumberDataPoint struct { - orig *otlpmetrics.NumberDataPoint + orig *internal.NumberDataPoint state *internal.State } -func newNumberDataPoint(orig *otlpmetrics.NumberDataPoint, state *internal.State) NumberDataPoint { +func newNumberDataPoint(orig *internal.NumberDataPoint, state *internal.State) NumberDataPoint { return NumberDataPoint{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newNumberDataPoint(orig *otlpmetrics.NumberDataPoint, state *internal.State // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewNumberDataPoint() NumberDataPoint { - return newNumberDataPoint(internal.NewOrigNumberDataPoint(), internal.NewState()) + return newNumberDataPoint(internal.NewNumberDataPoint(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms NumberDataPoint) MoveTo(dest NumberDataPoint) { if ms.orig == dest.orig { return } - internal.DeleteOrigNumberDataPoint(dest.orig, false) + internal.DeleteNumberDataPoint(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Attributes returns the Attributes associated with this NumberDataPoint. func (ms NumberDataPoint) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // StartTimestamp returns the starttimestamp associated with this NumberDataPoint. @@ -80,9 +79,9 @@ func (ms NumberDataPoint) SetTimestamp(v pcommon.Timestamp) { // Calling this function on zero-initialized NumberDataPoint will cause a panic. func (ms NumberDataPoint) ValueType() NumberDataPointValueType { switch ms.orig.Value.(type) { - case *otlpmetrics.NumberDataPoint_AsDouble: + case *internal.NumberDataPoint_AsDouble: return NumberDataPointValueTypeDouble - case *otlpmetrics.NumberDataPoint_AsInt: + case *internal.NumberDataPoint_AsInt: return NumberDataPointValueTypeInt } return NumberDataPointValueTypeEmpty @@ -96,11 +95,11 @@ func (ms NumberDataPoint) DoubleValue() float64 { // SetDoubleValue replaces the double associated with this NumberDataPoint. func (ms NumberDataPoint) SetDoubleValue(v float64) { ms.state.AssertMutable() - var ov *otlpmetrics.NumberDataPoint_AsDouble + var ov *internal.NumberDataPoint_AsDouble if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsDouble{} + ov = &internal.NumberDataPoint_AsDouble{} } else { - ov = internal.ProtoPoolNumberDataPoint_AsDouble.Get().(*otlpmetrics.NumberDataPoint_AsDouble) + ov = internal.ProtoPoolNumberDataPoint_AsDouble.Get().(*internal.NumberDataPoint_AsDouble) } ov.AsDouble = v ms.orig.Value = ov @@ -114,11 +113,11 @@ func (ms NumberDataPoint) IntValue() int64 { // SetIntValue replaces the int associated with this NumberDataPoint. func (ms NumberDataPoint) SetIntValue(v int64) { ms.state.AssertMutable() - var ov *otlpmetrics.NumberDataPoint_AsInt + var ov *internal.NumberDataPoint_AsInt if !internal.UseProtoPooling.IsEnabled() { - ov = &otlpmetrics.NumberDataPoint_AsInt{} + ov = &internal.NumberDataPoint_AsInt{} } else { - ov = internal.ProtoPoolNumberDataPoint_AsInt.Get().(*otlpmetrics.NumberDataPoint_AsInt) + ov = internal.ProtoPoolNumberDataPoint_AsInt.Get().(*internal.NumberDataPoint_AsInt) } ov.AsInt = v ms.orig.Value = ov @@ -143,5 +142,5 @@ func (ms NumberDataPoint) SetFlags(v DataPointFlags) { // CopyTo copies all properties from the current struct overriding the destination. func (ms NumberDataPoint) CopyTo(dest NumberDataPoint) { dest.state.AssertMutable() - internal.CopyOrigNumberDataPoint(dest.orig, ms.orig) + internal.CopyNumberDataPoint(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_numberdatapoint_test.go b/pdata/pmetric/generated_numberdatapoint_test.go index b530d9d2560..e1c70248a19 100644 --- a/pdata/pmetric/generated_numberdatapoint_test.go +++ b/pdata/pmetric/generated_numberdatapoint_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestNumberDataPoint_MoveTo(t *testing.T) { assert.Equal(t, generateTestNumberDataPoint(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newNumberDataPoint(internal.NewOrigNumberDataPoint(), sharedState)) }) - assert.Panics(t, func() { newNumberDataPoint(internal.NewOrigNumberDataPoint(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newNumberDataPoint(internal.NewNumberDataPoint(), sharedState)) }) + assert.Panics(t, func() { newNumberDataPoint(internal.NewNumberDataPoint(), sharedState).MoveTo(dest) }) } func TestNumberDataPoint_CopyTo(t *testing.T) { @@ -40,14 +39,14 @@ func TestNumberDataPoint_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newNumberDataPoint(internal.NewOrigNumberDataPoint(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newNumberDataPoint(internal.NewNumberDataPoint(), sharedState)) }) } func TestNumberDataPoint_Attributes(t *testing.T) { ms := NewNumberDataPoint() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestNumberDataPoint_StartTimestamp(t *testing.T) { @@ -80,7 +79,7 @@ func TestNumberDataPoint_DoubleValue(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newNumberDataPoint(&otlpmetrics.NumberDataPoint{}, sharedState).SetDoubleValue(float64(3.1415926)) + newNumberDataPoint(internal.NewNumberDataPoint(), sharedState).SetDoubleValue(float64(3.1415926)) }) } @@ -92,13 +91,13 @@ func TestNumberDataPoint_IntValue(t *testing.T) { assert.Equal(t, NumberDataPointValueTypeInt, ms.ValueType()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newNumberDataPoint(&otlpmetrics.NumberDataPoint{}, sharedState).SetIntValue(int64(13)) }) + assert.Panics(t, func() { newNumberDataPoint(internal.NewNumberDataPoint(), sharedState).SetIntValue(int64(13)) }) } func TestNumberDataPoint_Exemplars(t *testing.T) { ms := NewNumberDataPoint() assert.Equal(t, NewExemplarSlice(), ms.Exemplars()) - ms.orig.Exemplars = internal.GenerateOrigTestExemplarSlice() + ms.orig.Exemplars = internal.GenTestExemplarSlice() assert.Equal(t, generateTestExemplarSlice(), ms.Exemplars()) } @@ -111,6 +110,5 @@ func TestNumberDataPoint_Flags(t *testing.T) { } func generateTestNumberDataPoint() NumberDataPoint { - ms := newNumberDataPoint(internal.GenTestOrigNumberDataPoint(), internal.NewState()) - return ms + return newNumberDataPoint(internal.GenTestNumberDataPoint(), internal.NewState()) } diff --git a/pdata/pmetric/generated_numberdatapointslice.go b/pdata/pmetric/generated_numberdatapointslice.go index a691f92026d..2491750b672 100644 --- a/pdata/pmetric/generated_numberdatapointslice.go +++ b/pdata/pmetric/generated_numberdatapointslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // NumberDataPointSlice logically represents a slice of NumberDataPoint. @@ -22,18 +21,18 @@ import ( // Must use NewNumberDataPointSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type NumberDataPointSlice struct { - orig *[]*otlpmetrics.NumberDataPoint + orig *[]*internal.NumberDataPoint state *internal.State } -func newNumberDataPointSlice(orig *[]*otlpmetrics.NumberDataPoint, state *internal.State) NumberDataPointSlice { +func newNumberDataPointSlice(orig *[]*internal.NumberDataPoint, state *internal.State) NumberDataPointSlice { return NumberDataPointSlice{orig: orig, state: state} } // NewNumberDataPointSlice creates a NumberDataPointSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewNumberDataPointSlice() NumberDataPointSlice { - orig := []*otlpmetrics.NumberDataPoint(nil) + orig := []*internal.NumberDataPoint(nil) return newNumberDataPointSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es NumberDataPointSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.NumberDataPoint, len(*es.orig), newCap) + newOrig := make([]*internal.NumberDataPoint, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es NumberDataPointSlice) EnsureCapacity(newCap int) { // It returns the newly added NumberDataPoint. func (es NumberDataPointSlice) AppendEmpty() NumberDataPoint { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigNumberDataPoint()) + *es.orig = append(*es.orig, internal.NewNumberDataPoint()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es NumberDataPointSlice) RemoveIf(f func(NumberDataPoint) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigNumberDataPoint((*es.orig)[i], true) + internal.DeleteNumberDataPoint((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es NumberDataPointSlice) CopyTo(dest NumberDataPointSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigNumberDataPointSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyNumberDataPointPtrSlice(*dest.orig, *es.orig) } // Sort sorts the NumberDataPoint elements within NumberDataPointSlice given the diff --git a/pdata/pmetric/generated_numberdatapointslice_test.go b/pdata/pmetric/generated_numberdatapointslice_test.go index 72de4e0b626..8e845336a12 100644 --- a/pdata/pmetric/generated_numberdatapointslice_test.go +++ b/pdata/pmetric/generated_numberdatapointslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestNumberDataPointSlice(t *testing.T) { es := NewNumberDataPointSlice() assert.Equal(t, 0, es.Len()) - es = newNumberDataPointSlice(&[]*otlpmetrics.NumberDataPoint{}, internal.NewState()) + es = newNumberDataPointSlice(&[]*internal.NumberDataPoint{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewNumberDataPoint() @@ -27,7 +26,7 @@ func TestNumberDataPointSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigNumberDataPoint() + (*es.orig)[i] = internal.GenTestNumberDataPoint() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestNumberDataPointSlice(t *testing.T) { func TestNumberDataPointSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newNumberDataPointSlice(&[]*otlpmetrics.NumberDataPoint{}, sharedState) + es := newNumberDataPointSlice(&[]*internal.NumberDataPoint{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestNumberDataPointSlice_Sort(t *testing.T) { func generateTestNumberDataPointSlice() NumberDataPointSlice { ms := NewNumberDataPointSlice() - *ms.orig = internal.GenerateOrigTestNumberDataPointSlice() + *ms.orig = internal.GenTestNumberDataPointPtrSlice() return ms } diff --git a/pdata/pmetric/generated_resourcemetrics.go b/pdata/pmetric/generated_resourcemetrics.go index 51cd24b74d3..a7c3dbc061e 100644 --- a/pdata/pmetric/generated_resourcemetrics.go +++ b/pdata/pmetric/generated_resourcemetrics.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewResourceMetrics function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceMetrics struct { - orig *otlpmetrics.ResourceMetrics + orig *internal.ResourceMetrics state *internal.State } -func newResourceMetrics(orig *otlpmetrics.ResourceMetrics, state *internal.State) ResourceMetrics { +func newResourceMetrics(orig *internal.ResourceMetrics, state *internal.State) ResourceMetrics { return ResourceMetrics{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newResourceMetrics(orig *otlpmetrics.ResourceMetrics, state *internal.State // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewResourceMetrics() ResourceMetrics { - return newResourceMetrics(internal.NewOrigResourceMetrics(), internal.NewState()) + return newResourceMetrics(internal.NewResourceMetrics(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ResourceMetrics) MoveTo(dest ResourceMetrics) { if ms.orig == dest.orig { return } - internal.DeleteOrigResourceMetrics(dest.orig, false) + internal.DeleteResourceMetrics(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Resource returns the resource associated with this ResourceMetrics. func (ms ResourceMetrics) Resource() pcommon.Resource { - return pcommon.Resource(internal.NewResource(&ms.orig.Resource, ms.state)) + return pcommon.Resource(internal.NewResourceWrapper(&ms.orig.Resource, ms.state)) } // ScopeMetrics returns the ScopeMetrics associated with this ResourceMetrics. @@ -73,5 +72,5 @@ func (ms ResourceMetrics) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ResourceMetrics) CopyTo(dest ResourceMetrics) { dest.state.AssertMutable() - internal.CopyOrigResourceMetrics(dest.orig, ms.orig) + internal.CopyResourceMetrics(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_resourcemetrics_test.go b/pdata/pmetric/generated_resourcemetrics_test.go index 6f1792377a9..9ee3e2dd2bb 100644 --- a/pdata/pmetric/generated_resourcemetrics_test.go +++ b/pdata/pmetric/generated_resourcemetrics_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestResourceMetrics_MoveTo(t *testing.T) { assert.Equal(t, generateTestResourceMetrics(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newResourceMetrics(internal.NewOrigResourceMetrics(), sharedState)) }) - assert.Panics(t, func() { newResourceMetrics(internal.NewOrigResourceMetrics(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newResourceMetrics(internal.NewResourceMetrics(), sharedState)) }) + assert.Panics(t, func() { newResourceMetrics(internal.NewResourceMetrics(), sharedState).MoveTo(dest) }) } func TestResourceMetrics_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestResourceMetrics_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newResourceMetrics(internal.NewOrigResourceMetrics(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newResourceMetrics(internal.NewResourceMetrics(), sharedState)) }) } func TestResourceMetrics_Resource(t *testing.T) { ms := NewResourceMetrics() assert.Equal(t, pcommon.NewResource(), ms.Resource()) - ms.orig.Resource = *internal.GenTestOrigResource() - assert.Equal(t, pcommon.Resource(internal.NewResource(internal.GenTestOrigResource(), ms.state)), ms.Resource()) + ms.orig.Resource = *internal.GenTestResource() + assert.Equal(t, pcommon.Resource(internal.GenTestResourceWrapper()), ms.Resource()) } func TestResourceMetrics_ScopeMetrics(t *testing.T) { ms := NewResourceMetrics() assert.Equal(t, NewScopeMetricsSlice(), ms.ScopeMetrics()) - ms.orig.ScopeMetrics = internal.GenerateOrigTestScopeMetricsSlice() + ms.orig.ScopeMetrics = internal.GenTestScopeMetricsPtrSlice() assert.Equal(t, generateTestScopeMetricsSlice(), ms.ScopeMetrics()) } @@ -64,10 +63,9 @@ func TestResourceMetrics_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newResourceMetrics(&otlpmetrics.ResourceMetrics{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newResourceMetrics(internal.NewResourceMetrics(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestResourceMetrics() ResourceMetrics { - ms := newResourceMetrics(internal.GenTestOrigResourceMetrics(), internal.NewState()) - return ms + return newResourceMetrics(internal.GenTestResourceMetrics(), internal.NewState()) } diff --git a/pdata/pmetric/generated_resourcemetricsslice.go b/pdata/pmetric/generated_resourcemetricsslice.go index 52103da495e..4b2829010e1 100644 --- a/pdata/pmetric/generated_resourcemetricsslice.go +++ b/pdata/pmetric/generated_resourcemetricsslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // ResourceMetricsSlice logically represents a slice of ResourceMetrics. @@ -22,18 +21,18 @@ import ( // Must use NewResourceMetricsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceMetricsSlice struct { - orig *[]*otlpmetrics.ResourceMetrics + orig *[]*internal.ResourceMetrics state *internal.State } -func newResourceMetricsSlice(orig *[]*otlpmetrics.ResourceMetrics, state *internal.State) ResourceMetricsSlice { +func newResourceMetricsSlice(orig *[]*internal.ResourceMetrics, state *internal.State) ResourceMetricsSlice { return ResourceMetricsSlice{orig: orig, state: state} } // NewResourceMetricsSlice creates a ResourceMetricsSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewResourceMetricsSlice() ResourceMetricsSlice { - orig := []*otlpmetrics.ResourceMetrics(nil) + orig := []*internal.ResourceMetrics(nil) return newResourceMetricsSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ResourceMetricsSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.ResourceMetrics, len(*es.orig), newCap) + newOrig := make([]*internal.ResourceMetrics, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ResourceMetricsSlice) EnsureCapacity(newCap int) { // It returns the newly added ResourceMetrics. func (es ResourceMetricsSlice) AppendEmpty() ResourceMetrics { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigResourceMetrics()) + *es.orig = append(*es.orig, internal.NewResourceMetrics()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ResourceMetricsSlice) RemoveIf(f func(ResourceMetrics) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigResourceMetrics((*es.orig)[i], true) + internal.DeleteResourceMetrics((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ResourceMetricsSlice) CopyTo(dest ResourceMetricsSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigResourceMetricsSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyResourceMetricsPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ResourceMetrics elements within ResourceMetricsSlice given the diff --git a/pdata/pmetric/generated_resourcemetricsslice_test.go b/pdata/pmetric/generated_resourcemetricsslice_test.go index a090587b06d..019abcda017 100644 --- a/pdata/pmetric/generated_resourcemetricsslice_test.go +++ b/pdata/pmetric/generated_resourcemetricsslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestResourceMetricsSlice(t *testing.T) { es := NewResourceMetricsSlice() assert.Equal(t, 0, es.Len()) - es = newResourceMetricsSlice(&[]*otlpmetrics.ResourceMetrics{}, internal.NewState()) + es = newResourceMetricsSlice(&[]*internal.ResourceMetrics{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewResourceMetrics() @@ -27,7 +26,7 @@ func TestResourceMetricsSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigResourceMetrics() + (*es.orig)[i] = internal.GenTestResourceMetrics() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestResourceMetricsSlice(t *testing.T) { func TestResourceMetricsSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newResourceMetricsSlice(&[]*otlpmetrics.ResourceMetrics{}, sharedState) + es := newResourceMetricsSlice(&[]*internal.ResourceMetrics{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestResourceMetricsSlice_Sort(t *testing.T) { func generateTestResourceMetricsSlice() ResourceMetricsSlice { ms := NewResourceMetricsSlice() - *ms.orig = internal.GenerateOrigTestResourceMetricsSlice() + *ms.orig = internal.GenTestResourceMetricsPtrSlice() return ms } diff --git a/pdata/pmetric/generated_scopemetrics.go b/pdata/pmetric/generated_scopemetrics.go index 0050ee5a602..563153a491f 100644 --- a/pdata/pmetric/generated_scopemetrics.go +++ b/pdata/pmetric/generated_scopemetrics.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewScopeMetrics function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeMetrics struct { - orig *otlpmetrics.ScopeMetrics + orig *internal.ScopeMetrics state *internal.State } -func newScopeMetrics(orig *otlpmetrics.ScopeMetrics, state *internal.State) ScopeMetrics { +func newScopeMetrics(orig *internal.ScopeMetrics, state *internal.State) ScopeMetrics { return ScopeMetrics{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newScopeMetrics(orig *otlpmetrics.ScopeMetrics, state *internal.State) Scop // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewScopeMetrics() ScopeMetrics { - return newScopeMetrics(internal.NewOrigScopeMetrics(), internal.NewState()) + return newScopeMetrics(internal.NewScopeMetrics(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ScopeMetrics) MoveTo(dest ScopeMetrics) { if ms.orig == dest.orig { return } - internal.DeleteOrigScopeMetrics(dest.orig, false) + internal.DeleteScopeMetrics(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Scope returns the scope associated with this ScopeMetrics. func (ms ScopeMetrics) Scope() pcommon.InstrumentationScope { - return pcommon.InstrumentationScope(internal.NewInstrumentationScope(&ms.orig.Scope, ms.state)) + return pcommon.InstrumentationScope(internal.NewInstrumentationScopeWrapper(&ms.orig.Scope, ms.state)) } // Metrics returns the Metrics associated with this ScopeMetrics. @@ -73,5 +72,5 @@ func (ms ScopeMetrics) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ScopeMetrics) CopyTo(dest ScopeMetrics) { dest.state.AssertMutable() - internal.CopyOrigScopeMetrics(dest.orig, ms.orig) + internal.CopyScopeMetrics(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_scopemetrics_test.go b/pdata/pmetric/generated_scopemetrics_test.go index 221c1abace2..ac666115b3a 100644 --- a/pdata/pmetric/generated_scopemetrics_test.go +++ b/pdata/pmetric/generated_scopemetrics_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestScopeMetrics_MoveTo(t *testing.T) { assert.Equal(t, generateTestScopeMetrics(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newScopeMetrics(internal.NewOrigScopeMetrics(), sharedState)) }) - assert.Panics(t, func() { newScopeMetrics(internal.NewOrigScopeMetrics(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newScopeMetrics(internal.NewScopeMetrics(), sharedState)) }) + assert.Panics(t, func() { newScopeMetrics(internal.NewScopeMetrics(), sharedState).MoveTo(dest) }) } func TestScopeMetrics_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestScopeMetrics_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newScopeMetrics(internal.NewOrigScopeMetrics(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newScopeMetrics(internal.NewScopeMetrics(), sharedState)) }) } func TestScopeMetrics_Scope(t *testing.T) { ms := NewScopeMetrics() assert.Equal(t, pcommon.NewInstrumentationScope(), ms.Scope()) - ms.orig.Scope = *internal.GenTestOrigInstrumentationScope() - assert.Equal(t, pcommon.InstrumentationScope(internal.NewInstrumentationScope(internal.GenTestOrigInstrumentationScope(), ms.state)), ms.Scope()) + ms.orig.Scope = *internal.GenTestInstrumentationScope() + assert.Equal(t, pcommon.InstrumentationScope(internal.GenTestInstrumentationScopeWrapper()), ms.Scope()) } func TestScopeMetrics_Metrics(t *testing.T) { ms := NewScopeMetrics() assert.Equal(t, NewMetricSlice(), ms.Metrics()) - ms.orig.Metrics = internal.GenerateOrigTestMetricSlice() + ms.orig.Metrics = internal.GenTestMetricPtrSlice() assert.Equal(t, generateTestMetricSlice(), ms.Metrics()) } @@ -64,10 +63,9 @@ func TestScopeMetrics_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newScopeMetrics(&otlpmetrics.ScopeMetrics{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newScopeMetrics(internal.NewScopeMetrics(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestScopeMetrics() ScopeMetrics { - ms := newScopeMetrics(internal.GenTestOrigScopeMetrics(), internal.NewState()) - return ms + return newScopeMetrics(internal.GenTestScopeMetrics(), internal.NewState()) } diff --git a/pdata/pmetric/generated_scopemetricsslice.go b/pdata/pmetric/generated_scopemetricsslice.go index 7850d9e7253..2fb0540288d 100644 --- a/pdata/pmetric/generated_scopemetricsslice.go +++ b/pdata/pmetric/generated_scopemetricsslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // ScopeMetricsSlice logically represents a slice of ScopeMetrics. @@ -22,18 +21,18 @@ import ( // Must use NewScopeMetricsSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeMetricsSlice struct { - orig *[]*otlpmetrics.ScopeMetrics + orig *[]*internal.ScopeMetrics state *internal.State } -func newScopeMetricsSlice(orig *[]*otlpmetrics.ScopeMetrics, state *internal.State) ScopeMetricsSlice { +func newScopeMetricsSlice(orig *[]*internal.ScopeMetrics, state *internal.State) ScopeMetricsSlice { return ScopeMetricsSlice{orig: orig, state: state} } // NewScopeMetricsSlice creates a ScopeMetricsSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewScopeMetricsSlice() ScopeMetricsSlice { - orig := []*otlpmetrics.ScopeMetrics(nil) + orig := []*internal.ScopeMetrics(nil) return newScopeMetricsSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ScopeMetricsSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.ScopeMetrics, len(*es.orig), newCap) + newOrig := make([]*internal.ScopeMetrics, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ScopeMetricsSlice) EnsureCapacity(newCap int) { // It returns the newly added ScopeMetrics. func (es ScopeMetricsSlice) AppendEmpty() ScopeMetrics { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigScopeMetrics()) + *es.orig = append(*es.orig, internal.NewScopeMetrics()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ScopeMetricsSlice) RemoveIf(f func(ScopeMetrics) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigScopeMetrics((*es.orig)[i], true) + internal.DeleteScopeMetrics((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ScopeMetricsSlice) CopyTo(dest ScopeMetricsSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigScopeMetricsSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyScopeMetricsPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ScopeMetrics elements within ScopeMetricsSlice given the diff --git a/pdata/pmetric/generated_scopemetricsslice_test.go b/pdata/pmetric/generated_scopemetricsslice_test.go index b4279557451..3bf75ed1686 100644 --- a/pdata/pmetric/generated_scopemetricsslice_test.go +++ b/pdata/pmetric/generated_scopemetricsslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestScopeMetricsSlice(t *testing.T) { es := NewScopeMetricsSlice() assert.Equal(t, 0, es.Len()) - es = newScopeMetricsSlice(&[]*otlpmetrics.ScopeMetrics{}, internal.NewState()) + es = newScopeMetricsSlice(&[]*internal.ScopeMetrics{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewScopeMetrics() @@ -27,7 +26,7 @@ func TestScopeMetricsSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigScopeMetrics() + (*es.orig)[i] = internal.GenTestScopeMetrics() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestScopeMetricsSlice(t *testing.T) { func TestScopeMetricsSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newScopeMetricsSlice(&[]*otlpmetrics.ScopeMetrics{}, sharedState) + es := newScopeMetricsSlice(&[]*internal.ScopeMetrics{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestScopeMetricsSlice_Sort(t *testing.T) { func generateTestScopeMetricsSlice() ScopeMetricsSlice { ms := NewScopeMetricsSlice() - *ms.orig = internal.GenerateOrigTestScopeMetricsSlice() + *ms.orig = internal.GenTestScopeMetricsPtrSlice() return ms } diff --git a/pdata/pmetric/generated_sum.go b/pdata/pmetric/generated_sum.go index 0f5b7f11323..a56ece7dc53 100644 --- a/pdata/pmetric/generated_sum.go +++ b/pdata/pmetric/generated_sum.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // Sum represents the type of a numeric metric that is calculated as a sum of all reported measurements over a time interval. @@ -19,11 +18,11 @@ import ( // Must use NewSum function to create new instances. // Important: zero-initialized instance is not valid for use. type Sum struct { - orig *otlpmetrics.Sum + orig *internal.Sum state *internal.State } -func newSum(orig *otlpmetrics.Sum, state *internal.State) Sum { +func newSum(orig *internal.Sum, state *internal.State) Sum { return Sum{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newSum(orig *otlpmetrics.Sum, state *internal.State) Sum { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSum() Sum { - return newSum(internal.NewOrigSum(), internal.NewState()) + return newSum(internal.NewSum(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms Sum) MoveTo(dest Sum) { if ms.orig == dest.orig { return } - internal.DeleteOrigSum(dest.orig, false) + internal.DeleteSum(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -61,7 +60,7 @@ func (ms Sum) AggregationTemporality() AggregationTemporality { // SetAggregationTemporality replaces the aggregationtemporality associated with this Sum. func (ms Sum) SetAggregationTemporality(v AggregationTemporality) { ms.state.AssertMutable() - ms.orig.AggregationTemporality = otlpmetrics.AggregationTemporality(v) + ms.orig.AggregationTemporality = internal.AggregationTemporality(v) } // IsMonotonic returns the ismonotonic associated with this Sum. @@ -78,5 +77,5 @@ func (ms Sum) SetIsMonotonic(v bool) { // CopyTo copies all properties from the current struct overriding the destination. func (ms Sum) CopyTo(dest Sum) { dest.state.AssertMutable() - internal.CopyOrigSum(dest.orig, ms.orig) + internal.CopySum(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_sum_test.go b/pdata/pmetric/generated_sum_test.go index f99c5e580a2..6782d031a2b 100644 --- a/pdata/pmetric/generated_sum_test.go +++ b/pdata/pmetric/generated_sum_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestSum_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestSum_MoveTo(t *testing.T) { assert.Equal(t, generateTestSum(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSum(internal.NewOrigSum(), sharedState)) }) - assert.Panics(t, func() { newSum(internal.NewOrigSum(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSum(internal.NewSum(), sharedState)) }) + assert.Panics(t, func() { newSum(internal.NewSum(), sharedState).MoveTo(dest) }) } func TestSum_CopyTo(t *testing.T) { @@ -39,20 +38,20 @@ func TestSum_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSum(internal.NewOrigSum(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSum(internal.NewSum(), sharedState)) }) } func TestSum_DataPoints(t *testing.T) { ms := NewSum() assert.Equal(t, NewNumberDataPointSlice(), ms.DataPoints()) - ms.orig.DataPoints = internal.GenerateOrigTestNumberDataPointSlice() + ms.orig.DataPoints = internal.GenTestNumberDataPointPtrSlice() assert.Equal(t, generateTestNumberDataPointSlice(), ms.DataPoints()) } func TestSum_AggregationTemporality(t *testing.T) { ms := NewSum() - assert.Equal(t, AggregationTemporality(otlpmetrics.AggregationTemporality(0)), ms.AggregationTemporality()) - testValAggregationTemporality := AggregationTemporality(otlpmetrics.AggregationTemporality(1)) + assert.Equal(t, AggregationTemporality(internal.AggregationTemporality(0)), ms.AggregationTemporality()) + testValAggregationTemporality := AggregationTemporality(internal.AggregationTemporality(1)) ms.SetAggregationTemporality(testValAggregationTemporality) assert.Equal(t, testValAggregationTemporality, ms.AggregationTemporality()) } @@ -64,10 +63,9 @@ func TestSum_IsMonotonic(t *testing.T) { assert.True(t, ms.IsMonotonic()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSum(&otlpmetrics.Sum{}, sharedState).SetIsMonotonic(true) }) + assert.Panics(t, func() { newSum(internal.NewSum(), sharedState).SetIsMonotonic(true) }) } func generateTestSum() Sum { - ms := newSum(internal.GenTestOrigSum(), internal.NewState()) - return ms + return newSum(internal.GenTestSum(), internal.NewState()) } diff --git a/pdata/pmetric/generated_summary.go b/pdata/pmetric/generated_summary.go index e247537dc20..c6ec844d4d6 100644 --- a/pdata/pmetric/generated_summary.go +++ b/pdata/pmetric/generated_summary.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // Summary represents the type of a metric that is calculated by aggregating as a Summary of all reported double measurements over a time interval. @@ -19,11 +18,11 @@ import ( // Must use NewSummary function to create new instances. // Important: zero-initialized instance is not valid for use. type Summary struct { - orig *otlpmetrics.Summary + orig *internal.Summary state *internal.State } -func newSummary(orig *otlpmetrics.Summary, state *internal.State) Summary { +func newSummary(orig *internal.Summary, state *internal.State) Summary { return Summary{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newSummary(orig *otlpmetrics.Summary, state *internal.State) Summary { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSummary() Summary { - return newSummary(internal.NewOrigSummary(), internal.NewState()) + return newSummary(internal.NewSummary(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms Summary) MoveTo(dest Summary) { if ms.orig == dest.orig { return } - internal.DeleteOrigSummary(dest.orig, false) + internal.DeleteSummary(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -56,5 +55,5 @@ func (ms Summary) DataPoints() SummaryDataPointSlice { // CopyTo copies all properties from the current struct overriding the destination. func (ms Summary) CopyTo(dest Summary) { dest.state.AssertMutable() - internal.CopyOrigSummary(dest.orig, ms.orig) + internal.CopySummary(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_summary_test.go b/pdata/pmetric/generated_summary_test.go index 9db5025a0b6..d2222a491b2 100644 --- a/pdata/pmetric/generated_summary_test.go +++ b/pdata/pmetric/generated_summary_test.go @@ -24,8 +24,8 @@ func TestSummary_MoveTo(t *testing.T) { assert.Equal(t, generateTestSummary(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSummary(internal.NewOrigSummary(), sharedState)) }) - assert.Panics(t, func() { newSummary(internal.NewOrigSummary(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSummary(internal.NewSummary(), sharedState)) }) + assert.Panics(t, func() { newSummary(internal.NewSummary(), sharedState).MoveTo(dest) }) } func TestSummary_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestSummary_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSummary(internal.NewOrigSummary(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSummary(internal.NewSummary(), sharedState)) }) } func TestSummary_DataPoints(t *testing.T) { ms := NewSummary() assert.Equal(t, NewSummaryDataPointSlice(), ms.DataPoints()) - ms.orig.DataPoints = internal.GenerateOrigTestSummaryDataPointSlice() + ms.orig.DataPoints = internal.GenTestSummaryDataPointPtrSlice() assert.Equal(t, generateTestSummaryDataPointSlice(), ms.DataPoints()) } func generateTestSummary() Summary { - ms := newSummary(internal.GenTestOrigSummary(), internal.NewState()) - return ms + return newSummary(internal.GenTestSummary(), internal.NewState()) } diff --git a/pdata/pmetric/generated_summarydatapoint.go b/pdata/pmetric/generated_summarydatapoint.go index 7d4fa34db0d..715ef7247d1 100644 --- a/pdata/pmetric/generated_summarydatapoint.go +++ b/pdata/pmetric/generated_summarydatapoint.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewSummaryDataPoint function to create new instances. // Important: zero-initialized instance is not valid for use. type SummaryDataPoint struct { - orig *otlpmetrics.SummaryDataPoint + orig *internal.SummaryDataPoint state *internal.State } -func newSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, state *internal.State) SummaryDataPoint { +func newSummaryDataPoint(orig *internal.SummaryDataPoint, state *internal.State) SummaryDataPoint { return SummaryDataPoint{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newSummaryDataPoint(orig *otlpmetrics.SummaryDataPoint, state *internal.Sta // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSummaryDataPoint() SummaryDataPoint { - return newSummaryDataPoint(internal.NewOrigSummaryDataPoint(), internal.NewState()) + return newSummaryDataPoint(internal.NewSummaryDataPoint(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms SummaryDataPoint) MoveTo(dest SummaryDataPoint) { if ms.orig == dest.orig { return } - internal.DeleteOrigSummaryDataPoint(dest.orig, false) + internal.DeleteSummaryDataPoint(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Attributes returns the Attributes associated with this SummaryDataPoint. func (ms SummaryDataPoint) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // StartTimestamp returns the starttimestamp associated with this SummaryDataPoint. @@ -117,5 +116,5 @@ func (ms SummaryDataPoint) SetFlags(v DataPointFlags) { // CopyTo copies all properties from the current struct overriding the destination. func (ms SummaryDataPoint) CopyTo(dest SummaryDataPoint) { dest.state.AssertMutable() - internal.CopyOrigSummaryDataPoint(dest.orig, ms.orig) + internal.CopySummaryDataPoint(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_summarydatapoint_test.go b/pdata/pmetric/generated_summarydatapoint_test.go index dc693e6d0f3..a5c2df023a5 100644 --- a/pdata/pmetric/generated_summarydatapoint_test.go +++ b/pdata/pmetric/generated_summarydatapoint_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestSummaryDataPoint_MoveTo(t *testing.T) { assert.Equal(t, generateTestSummaryDataPoint(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSummaryDataPoint(internal.NewOrigSummaryDataPoint(), sharedState)) }) - assert.Panics(t, func() { newSummaryDataPoint(internal.NewOrigSummaryDataPoint(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState)) }) + assert.Panics(t, func() { newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState).MoveTo(dest) }) } func TestSummaryDataPoint_CopyTo(t *testing.T) { @@ -40,14 +39,14 @@ func TestSummaryDataPoint_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSummaryDataPoint(internal.NewOrigSummaryDataPoint(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState)) }) } func TestSummaryDataPoint_Attributes(t *testing.T) { ms := NewSummaryDataPoint() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestSummaryDataPoint_StartTimestamp(t *testing.T) { @@ -73,7 +72,7 @@ func TestSummaryDataPoint_Count(t *testing.T) { assert.Equal(t, uint64(13), ms.Count()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSummaryDataPoint(&otlpmetrics.SummaryDataPoint{}, sharedState).SetCount(uint64(13)) }) + assert.Panics(t, func() { newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState).SetCount(uint64(13)) }) } func TestSummaryDataPoint_Sum(t *testing.T) { @@ -83,13 +82,13 @@ func TestSummaryDataPoint_Sum(t *testing.T) { assert.InDelta(t, float64(3.1415926), ms.Sum(), 0.01) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSummaryDataPoint(&otlpmetrics.SummaryDataPoint{}, sharedState).SetSum(float64(3.1415926)) }) + assert.Panics(t, func() { newSummaryDataPoint(internal.NewSummaryDataPoint(), sharedState).SetSum(float64(3.1415926)) }) } func TestSummaryDataPoint_QuantileValues(t *testing.T) { ms := NewSummaryDataPoint() assert.Equal(t, NewSummaryDataPointValueAtQuantileSlice(), ms.QuantileValues()) - ms.orig.QuantileValues = internal.GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice() + ms.orig.QuantileValues = internal.GenTestSummaryDataPointValueAtQuantilePtrSlice() assert.Equal(t, generateTestSummaryDataPointValueAtQuantileSlice(), ms.QuantileValues()) } @@ -102,6 +101,5 @@ func TestSummaryDataPoint_Flags(t *testing.T) { } func generateTestSummaryDataPoint() SummaryDataPoint { - ms := newSummaryDataPoint(internal.GenTestOrigSummaryDataPoint(), internal.NewState()) - return ms + return newSummaryDataPoint(internal.GenTestSummaryDataPoint(), internal.NewState()) } diff --git a/pdata/pmetric/generated_summarydatapointslice.go b/pdata/pmetric/generated_summarydatapointslice.go index 26b52e75fe9..a54e86d48a6 100644 --- a/pdata/pmetric/generated_summarydatapointslice.go +++ b/pdata/pmetric/generated_summarydatapointslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // SummaryDataPointSlice logically represents a slice of SummaryDataPoint. @@ -22,18 +21,18 @@ import ( // Must use NewSummaryDataPointSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SummaryDataPointSlice struct { - orig *[]*otlpmetrics.SummaryDataPoint + orig *[]*internal.SummaryDataPoint state *internal.State } -func newSummaryDataPointSlice(orig *[]*otlpmetrics.SummaryDataPoint, state *internal.State) SummaryDataPointSlice { +func newSummaryDataPointSlice(orig *[]*internal.SummaryDataPoint, state *internal.State) SummaryDataPointSlice { return SummaryDataPointSlice{orig: orig, state: state} } // NewSummaryDataPointSlice creates a SummaryDataPointSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSummaryDataPointSlice() SummaryDataPointSlice { - orig := []*otlpmetrics.SummaryDataPoint(nil) + orig := []*internal.SummaryDataPoint(nil) return newSummaryDataPointSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es SummaryDataPointSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.SummaryDataPoint, len(*es.orig), newCap) + newOrig := make([]*internal.SummaryDataPoint, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es SummaryDataPointSlice) EnsureCapacity(newCap int) { // It returns the newly added SummaryDataPoint. func (es SummaryDataPointSlice) AppendEmpty() SummaryDataPoint { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigSummaryDataPoint()) + *es.orig = append(*es.orig, internal.NewSummaryDataPoint()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es SummaryDataPointSlice) RemoveIf(f func(SummaryDataPoint) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigSummaryDataPoint((*es.orig)[i], true) + internal.DeleteSummaryDataPoint((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es SummaryDataPointSlice) CopyTo(dest SummaryDataPointSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigSummaryDataPointSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopySummaryDataPointPtrSlice(*dest.orig, *es.orig) } // Sort sorts the SummaryDataPoint elements within SummaryDataPointSlice given the diff --git a/pdata/pmetric/generated_summarydatapointslice_test.go b/pdata/pmetric/generated_summarydatapointslice_test.go index 3fe04001b78..36a26012cb7 100644 --- a/pdata/pmetric/generated_summarydatapointslice_test.go +++ b/pdata/pmetric/generated_summarydatapointslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestSummaryDataPointSlice(t *testing.T) { es := NewSummaryDataPointSlice() assert.Equal(t, 0, es.Len()) - es = newSummaryDataPointSlice(&[]*otlpmetrics.SummaryDataPoint{}, internal.NewState()) + es = newSummaryDataPointSlice(&[]*internal.SummaryDataPoint{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewSummaryDataPoint() @@ -27,7 +26,7 @@ func TestSummaryDataPointSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigSummaryDataPoint() + (*es.orig)[i] = internal.GenTestSummaryDataPoint() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestSummaryDataPointSlice(t *testing.T) { func TestSummaryDataPointSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSummaryDataPointSlice(&[]*otlpmetrics.SummaryDataPoint{}, sharedState) + es := newSummaryDataPointSlice(&[]*internal.SummaryDataPoint{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestSummaryDataPointSlice_Sort(t *testing.T) { func generateTestSummaryDataPointSlice() SummaryDataPointSlice { ms := NewSummaryDataPointSlice() - *ms.orig = internal.GenerateOrigTestSummaryDataPointSlice() + *ms.orig = internal.GenTestSummaryDataPointPtrSlice() return ms } diff --git a/pdata/pmetric/generated_summarydatapointvalueatquantile.go b/pdata/pmetric/generated_summarydatapointvalueatquantile.go index 093c1e45592..8275d2ecefa 100644 --- a/pdata/pmetric/generated_summarydatapointvalueatquantile.go +++ b/pdata/pmetric/generated_summarydatapointvalueatquantile.go @@ -8,7 +8,6 @@ package pmetric import ( "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // SummaryDataPointValueAtQuantile is a quantile value within a Summary data point. @@ -19,11 +18,11 @@ import ( // Must use NewSummaryDataPointValueAtQuantile function to create new instances. // Important: zero-initialized instance is not valid for use. type SummaryDataPointValueAtQuantile struct { - orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile + orig *internal.SummaryDataPointValueAtQuantile state *internal.State } -func newSummaryDataPointValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_ValueAtQuantile, state *internal.State) SummaryDataPointValueAtQuantile { +func newSummaryDataPointValueAtQuantile(orig *internal.SummaryDataPointValueAtQuantile, state *internal.State) SummaryDataPointValueAtQuantile { return SummaryDataPointValueAtQuantile{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newSummaryDataPointValueAtQuantile(orig *otlpmetrics.SummaryDataPoint_Value // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSummaryDataPointValueAtQuantile() SummaryDataPointValueAtQuantile { - return newSummaryDataPointValueAtQuantile(internal.NewOrigSummaryDataPoint_ValueAtQuantile(), internal.NewState()) + return newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms SummaryDataPointValueAtQuantile) MoveTo(dest SummaryDataPointValueAtQua if ms.orig == dest.orig { return } - internal.DeleteOrigSummaryDataPoint_ValueAtQuantile(dest.orig, false) + internal.DeleteSummaryDataPointValueAtQuantile(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -73,5 +72,5 @@ func (ms SummaryDataPointValueAtQuantile) SetValue(v float64) { // CopyTo copies all properties from the current struct overriding the destination. func (ms SummaryDataPointValueAtQuantile) CopyTo(dest SummaryDataPointValueAtQuantile) { dest.state.AssertMutable() - internal.CopyOrigSummaryDataPoint_ValueAtQuantile(dest.orig, ms.orig) + internal.CopySummaryDataPointValueAtQuantile(dest.orig, ms.orig) } diff --git a/pdata/pmetric/generated_summarydatapointvalueatquantile_test.go b/pdata/pmetric/generated_summarydatapointvalueatquantile_test.go index cf58f7dc072..ac9292cdb26 100644 --- a/pdata/pmetric/generated_summarydatapointvalueatquantile_test.go +++ b/pdata/pmetric/generated_summarydatapointvalueatquantile_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestSummaryDataPointValueAtQuantile_MoveTo(t *testing.T) { @@ -26,10 +25,10 @@ func TestSummaryDataPointValueAtQuantile_MoveTo(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - ms.MoveTo(newSummaryDataPointValueAtQuantile(internal.NewOrigSummaryDataPoint_ValueAtQuantile(), sharedState)) + ms.MoveTo(newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState)) }) assert.Panics(t, func() { - newSummaryDataPointValueAtQuantile(internal.NewOrigSummaryDataPoint_ValueAtQuantile(), sharedState).MoveTo(dest) + newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState).MoveTo(dest) }) } @@ -44,7 +43,7 @@ func TestSummaryDataPointValueAtQuantile_CopyTo(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - ms.CopyTo(newSummaryDataPointValueAtQuantile(internal.NewOrigSummaryDataPoint_ValueAtQuantile(), sharedState)) + ms.CopyTo(newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState)) }) } @@ -56,7 +55,7 @@ func TestSummaryDataPointValueAtQuantile_Quantile(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newSummaryDataPointValueAtQuantile(&otlpmetrics.SummaryDataPoint_ValueAtQuantile{}, sharedState).SetQuantile(float64(3.1415926)) + newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState).SetQuantile(float64(3.1415926)) }) } @@ -68,11 +67,10 @@ func TestSummaryDataPointValueAtQuantile_Value(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newSummaryDataPointValueAtQuantile(&otlpmetrics.SummaryDataPoint_ValueAtQuantile{}, sharedState).SetValue(float64(3.1415926)) + newSummaryDataPointValueAtQuantile(internal.NewSummaryDataPointValueAtQuantile(), sharedState).SetValue(float64(3.1415926)) }) } func generateTestSummaryDataPointValueAtQuantile() SummaryDataPointValueAtQuantile { - ms := newSummaryDataPointValueAtQuantile(internal.GenTestOrigSummaryDataPoint_ValueAtQuantile(), internal.NewState()) - return ms + return newSummaryDataPointValueAtQuantile(internal.GenTestSummaryDataPointValueAtQuantile(), internal.NewState()) } diff --git a/pdata/pmetric/generated_summarydatapointvalueatquantileslice.go b/pdata/pmetric/generated_summarydatapointvalueatquantileslice.go index 544bf5b125c..eb51c155135 100644 --- a/pdata/pmetric/generated_summarydatapointvalueatquantileslice.go +++ b/pdata/pmetric/generated_summarydatapointvalueatquantileslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) // SummaryDataPointValueAtQuantileSlice logically represents a slice of SummaryDataPointValueAtQuantile. @@ -22,18 +21,18 @@ import ( // Must use NewSummaryDataPointValueAtQuantileSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SummaryDataPointValueAtQuantileSlice struct { - orig *[]*otlpmetrics.SummaryDataPoint_ValueAtQuantile + orig *[]*internal.SummaryDataPointValueAtQuantile state *internal.State } -func newSummaryDataPointValueAtQuantileSlice(orig *[]*otlpmetrics.SummaryDataPoint_ValueAtQuantile, state *internal.State) SummaryDataPointValueAtQuantileSlice { +func newSummaryDataPointValueAtQuantileSlice(orig *[]*internal.SummaryDataPointValueAtQuantile, state *internal.State) SummaryDataPointValueAtQuantileSlice { return SummaryDataPointValueAtQuantileSlice{orig: orig, state: state} } // NewSummaryDataPointValueAtQuantileSlice creates a SummaryDataPointValueAtQuantileSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSummaryDataPointValueAtQuantileSlice() SummaryDataPointValueAtQuantileSlice { - orig := []*otlpmetrics.SummaryDataPoint_ValueAtQuantile(nil) + orig := []*internal.SummaryDataPointValueAtQuantile(nil) return newSummaryDataPointValueAtQuantileSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es SummaryDataPointValueAtQuantileSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpmetrics.SummaryDataPoint_ValueAtQuantile, len(*es.orig), newCap) + newOrig := make([]*internal.SummaryDataPointValueAtQuantile, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es SummaryDataPointValueAtQuantileSlice) EnsureCapacity(newCap int) { // It returns the newly added SummaryDataPointValueAtQuantile. func (es SummaryDataPointValueAtQuantileSlice) AppendEmpty() SummaryDataPointValueAtQuantile { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigSummaryDataPoint_ValueAtQuantile()) + *es.orig = append(*es.orig, internal.NewSummaryDataPointValueAtQuantile()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es SummaryDataPointValueAtQuantileSlice) RemoveIf(f func(SummaryDataPointV newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigSummaryDataPoint_ValueAtQuantile((*es.orig)[i], true) + internal.DeleteSummaryDataPointValueAtQuantile((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es SummaryDataPointValueAtQuantileSlice) CopyTo(dest SummaryDataPointValue if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigSummaryDataPoint_ValueAtQuantileSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopySummaryDataPointValueAtQuantilePtrSlice(*dest.orig, *es.orig) } // Sort sorts the SummaryDataPointValueAtQuantile elements within SummaryDataPointValueAtQuantileSlice given the diff --git a/pdata/pmetric/generated_summarydatapointvalueatquantileslice_test.go b/pdata/pmetric/generated_summarydatapointvalueatquantileslice_test.go index 5f2d0c3e4c0..e88632dc3a1 100644 --- a/pdata/pmetric/generated_summarydatapointvalueatquantileslice_test.go +++ b/pdata/pmetric/generated_summarydatapointvalueatquantileslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" ) func TestSummaryDataPointValueAtQuantileSlice(t *testing.T) { es := NewSummaryDataPointValueAtQuantileSlice() assert.Equal(t, 0, es.Len()) - es = newSummaryDataPointValueAtQuantileSlice(&[]*otlpmetrics.SummaryDataPoint_ValueAtQuantile{}, internal.NewState()) + es = newSummaryDataPointValueAtQuantileSlice(&[]*internal.SummaryDataPointValueAtQuantile{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewSummaryDataPointValueAtQuantile() @@ -27,7 +26,7 @@ func TestSummaryDataPointValueAtQuantileSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigSummaryDataPoint_ValueAtQuantile() + (*es.orig)[i] = internal.GenTestSummaryDataPointValueAtQuantile() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestSummaryDataPointValueAtQuantileSlice(t *testing.T) { func TestSummaryDataPointValueAtQuantileSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSummaryDataPointValueAtQuantileSlice(&[]*otlpmetrics.SummaryDataPoint_ValueAtQuantile{}, sharedState) + es := newSummaryDataPointValueAtQuantileSlice(&[]*internal.SummaryDataPointValueAtQuantile{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestSummaryDataPointValueAtQuantileSlice_Sort(t *testing.T) { func generateTestSummaryDataPointValueAtQuantileSlice() SummaryDataPointValueAtQuantileSlice { ms := NewSummaryDataPointValueAtQuantileSlice() - *ms.orig = internal.GenerateOrigTestSummaryDataPoint_ValueAtQuantileSlice() + *ms.orig = internal.GenTestSummaryDataPointValueAtQuantilePtrSlice() return ms } diff --git a/pdata/pmetric/json.go b/pdata/pmetric/json.go index 48913985974..cd3825f7f13 100644 --- a/pdata/pmetric/json.go +++ b/pdata/pmetric/json.go @@ -6,7 +6,6 @@ package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -20,7 +19,7 @@ type JSONMarshaler struct{} func (*JSONMarshaler) MarshalMetrics(md Metrics) ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportMetricsServiceRequest(md.getOrig(), dest) + md.getOrig().MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -35,7 +34,7 @@ func (*JSONUnmarshaler) UnmarshalMetrics(buf []byte) (Metrics, error) { iter := json.BorrowIterator(buf) defer json.ReturnIterator(iter) md := NewMetrics() - internal.UnmarshalJSONOrigExportMetricsServiceRequest(md.getOrig(), iter) + md.getOrig().UnmarshalJSON(iter) if iter.Error() != nil { return Metrics{}, iter.Error() } diff --git a/pdata/pmetric/metrics_test.go b/pdata/pmetric/metrics_test.go index b7475061e55..859ccfb2eb1 100644 --- a/pdata/pmetric/metrics_test.go +++ b/pdata/pmetric/metrics_test.go @@ -11,10 +11,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - otlpresource "go.opentelemetry.io/collector/pdata/internal/data/protogen/resource/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -149,14 +145,14 @@ func TestHistogramWithValidSum(t *testing.T) { } func TestOtlpToInternalReadOnly(t *testing.T) { - md := newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + md := newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, }, }, }, @@ -237,28 +233,28 @@ func TestOtlpToInternalReadOnly(t *testing.T) { } func TestOtlpToFromInternalReadOnly(t *testing.T) { - md := newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + md := newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, }, }, }, }, }, new(internal.State)) // Test that nothing changed - assert.EqualValues(t, &otlpmetrics.MetricsData{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + assert.EqualValues(t, &internal.MetricsData{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, }, }, }, @@ -269,14 +265,14 @@ func TestOtlpToFromInternalReadOnly(t *testing.T) { func TestOtlpToFromInternalGaugeMutating(t *testing.T) { newAttributes := map[string]any{"k": "v"} - md := newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + md := newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoGaugeMetric()}, + Metrics: []*internal.Metric{generateTestProtoGaugeMetric()}, }, }, }, @@ -308,31 +304,31 @@ func TestOtlpToFromInternalGaugeMutating(t *testing.T) { assert.Equal(t, newAttributes, gaugeDataPoints.At(0).Attributes().AsRaw()) // Test that everything is updated. - assert.EqualValues(t, &otlpmetrics.MetricsData{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + assert.EqualValues(t, &internal.MetricsData{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{ + Metrics: []*internal.Metric{ { Name: "new_my_metric_int", Description: "My new metric", Unit: "1", - Data: &otlpmetrics.Metric_Gauge{ - Gauge: &otlpmetrics.Gauge{ - DataPoints: []*otlpmetrics.NumberDataPoint{ + Data: &internal.Metric_Gauge{ + Gauge: &internal.Gauge{ + DataPoints: []*internal.NumberDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "k", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "v"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "v"}}, }, }, StartTimeUnixNano: startTime + 1, TimeUnixNano: endTime + 1, - Value: &otlpmetrics.NumberDataPoint_AsDouble{ + Value: &internal.NumberDataPoint_AsDouble{ AsDouble: 124.1, }, }, @@ -351,14 +347,14 @@ func TestOtlpToFromInternalGaugeMutating(t *testing.T) { func TestOtlpToFromInternalSumMutating(t *testing.T) { newAttributes := map[string]any{"k": "v"} - md := newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + md := newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoSumMetric()}, + Metrics: []*internal.Metric{generateTestProtoSumMetric()}, }, }, }, @@ -391,32 +387,32 @@ func TestOtlpToFromInternalSumMutating(t *testing.T) { assert.Equal(t, newAttributes, doubleDataPoints.At(0).Attributes().AsRaw()) // Test that everything is updated. - assert.EqualValues(t, &otlpmetrics.MetricsData{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + assert.EqualValues(t, &internal.MetricsData{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{ + Metrics: []*internal.Metric{ { Name: "new_my_metric_double", Description: "My new metric", Unit: "1", - Data: &otlpmetrics.Metric_Sum{ - Sum: &otlpmetrics.Sum{ - AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, - DataPoints: []*otlpmetrics.NumberDataPoint{ + Data: &internal.Metric_Sum{ + Sum: &internal.Sum{ + AggregationTemporality: internal.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, + DataPoints: []*internal.NumberDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "k", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "v"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "v"}}, }, }, StartTimeUnixNano: startTime + 1, TimeUnixNano: endTime + 1, - Value: &otlpmetrics.NumberDataPoint_AsDouble{ + Value: &internal.NumberDataPoint_AsDouble{ AsDouble: 124.1, }, }, @@ -435,14 +431,14 @@ func TestOtlpToFromInternalSumMutating(t *testing.T) { func TestOtlpToFromInternalHistogramMutating(t *testing.T) { newAttributes := map[string]any{"k": "v"} - md := newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + md := newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoHistogramMetric()}, }, }, }, @@ -475,27 +471,27 @@ func TestOtlpToFromInternalHistogramMutating(t *testing.T) { assert.Equal(t, []float64{1}, histogramDataPoints.At(0).ExplicitBounds().AsRaw()) histogramDataPoints.At(0).BucketCounts().FromRaw([]uint64{21, 32}) // Test that everything is updated. - assert.EqualValues(t, &otlpmetrics.MetricsData{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + assert.EqualValues(t, &internal.MetricsData{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{ + Metrics: []*internal.Metric{ { Name: "new_my_metric_histogram", Description: "My new metric", Unit: "1", - Data: &otlpmetrics.Metric_Histogram{ - Histogram: &otlpmetrics.Histogram{ - AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA, - DataPoints: []*otlpmetrics.HistogramDataPoint{ + Data: &internal.Metric_Histogram{ + Histogram: &internal.Histogram{ + AggregationTemporality: internal.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA, + DataPoints: []*internal.HistogramDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "k", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "v"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "v"}}, }, }, StartTimeUnixNano: startTime + 1, @@ -518,14 +514,14 @@ func TestOtlpToFromInternalHistogramMutating(t *testing.T) { func TestOtlpToFromInternalExponentialHistogramMutating(t *testing.T) { newAttributes := map[string]any{"k": "v"} - md := newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + md := newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoHistogramMetric()}, }, }, }, @@ -555,27 +551,27 @@ func TestOtlpToFromInternalExponentialHistogramMutating(t *testing.T) { histogramDataPoints.At(0).Attributes().PutStr("k", "v") assert.Equal(t, newAttributes, histogramDataPoints.At(0).Attributes().AsRaw()) // Test that everything is updated. - assert.EqualValues(t, &otlpmetrics.MetricsData{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + assert.EqualValues(t, &internal.MetricsData{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{ + Metrics: []*internal.Metric{ { Name: "new_my_metric_exponential_histogram", Description: "My new metric", Unit: "1", - Data: &otlpmetrics.Metric_ExponentialHistogram{ - ExponentialHistogram: &otlpmetrics.ExponentialHistogram{ - AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA, - DataPoints: []*otlpmetrics.ExponentialHistogramDataPoint{ + Data: &internal.Metric_ExponentialHistogram{ + ExponentialHistogram: &internal.ExponentialHistogram{ + AggregationTemporality: internal.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA, + DataPoints: []*internal.ExponentialHistogramDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "k", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "v"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "v"}}, }, }, StartTimeUnixNano: startTime + 1, @@ -611,14 +607,14 @@ func TestReadOnlyMetricsInvalidUsage(t *testing.T) { } func BenchmarkOtlpToFromInternal_PassThrough(b *testing.B) { - req := &otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + req := &internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoGaugeMetric(), generateTestProtoSumMetric(), generateTestProtoHistogramMetric()}, }, }, }, @@ -636,14 +632,14 @@ func BenchmarkOtlpToFromInternal_PassThrough(b *testing.B) { } func BenchmarkOtlpToFromInternal_Gauge_MutateOneLabel(b *testing.B) { - req := &otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + req := &internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoGaugeMetric()}, + Metrics: []*internal.Metric{generateTestProtoGaugeMetric()}, }, }, }, @@ -663,14 +659,14 @@ func BenchmarkOtlpToFromInternal_Gauge_MutateOneLabel(b *testing.B) { } func BenchmarkOtlpToFromInternal_Sum_MutateOneLabel(b *testing.B) { - req := &otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + req := &internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoSumMetric()}, + Metrics: []*internal.Metric{generateTestProtoSumMetric()}, }, }, }, @@ -690,14 +686,14 @@ func BenchmarkOtlpToFromInternal_Sum_MutateOneLabel(b *testing.B) { } func BenchmarkOtlpToFromInternal_HistogramPoints_MutateOneLabel(b *testing.B) { - req := &otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + req := &internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { Resource: generateTestProtoResource(), - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { Scope: generateTestProtoInstrumentationScope(), - Metrics: []*otlpmetrics.Metric{generateTestProtoHistogramMetric()}, + Metrics: []*internal.Metric{generateTestProtoHistogramMetric()}, }, }, }, @@ -716,55 +712,55 @@ func BenchmarkOtlpToFromInternal_HistogramPoints_MutateOneLabel(b *testing.B) { } } -func generateTestProtoResource() otlpresource.Resource { - return otlpresource.Resource{ - Attributes: []otlpcommon.KeyValue{ +func generateTestProtoResource() internal.Resource { + return internal.Resource{ + Attributes: []internal.KeyValue{ { Key: "string", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "string-resource"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "string-resource"}}, }, }, } } -func generateTestProtoInstrumentationScope() otlpcommon.InstrumentationScope { - return otlpcommon.InstrumentationScope{ +func generateTestProtoInstrumentationScope() internal.InstrumentationScope { + return internal.InstrumentationScope{ Name: "test", Version: "", } } -func generateTestProtoGaugeMetric() *otlpmetrics.Metric { - return &otlpmetrics.Metric{ +func generateTestProtoGaugeMetric() *internal.Metric { + return &internal.Metric{ Name: "my_metric_int", Description: "My metric", Unit: "ms", - Data: &otlpmetrics.Metric_Gauge{ - Gauge: &otlpmetrics.Gauge{ - DataPoints: []*otlpmetrics.NumberDataPoint{ + Data: &internal.Metric_Gauge{ + Gauge: &internal.Gauge{ + DataPoints: []*internal.NumberDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "key0", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "value0"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "value0"}}, }, }, StartTimeUnixNano: startTime, TimeUnixNano: endTime, - Value: &otlpmetrics.NumberDataPoint_AsDouble{ + Value: &internal.NumberDataPoint_AsDouble{ AsDouble: 123.1, }, }, { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "key1", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "value1"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "value1"}}, }, }, StartTimeUnixNano: startTime, TimeUnixNano: endTime, - Value: &otlpmetrics.NumberDataPoint_AsDouble{ + Value: &internal.NumberDataPoint_AsDouble{ AsDouble: 456.1, }, }, @@ -774,38 +770,38 @@ func generateTestProtoGaugeMetric() *otlpmetrics.Metric { } } -func generateTestProtoSumMetric() *otlpmetrics.Metric { - return &otlpmetrics.Metric{ +func generateTestProtoSumMetric() *internal.Metric { + return &internal.Metric{ Name: "my_metric_double", Description: "My metric", Unit: "ms", - Data: &otlpmetrics.Metric_Sum{ - Sum: &otlpmetrics.Sum{ - AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, - DataPoints: []*otlpmetrics.NumberDataPoint{ + Data: &internal.Metric_Sum{ + Sum: &internal.Sum{ + AggregationTemporality: internal.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, + DataPoints: []*internal.NumberDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "key0", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "value0"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "value0"}}, }, }, StartTimeUnixNano: startTime, TimeUnixNano: endTime, - Value: &otlpmetrics.NumberDataPoint_AsDouble{ + Value: &internal.NumberDataPoint_AsDouble{ AsDouble: 123.1, }, }, { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "key1", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "value1"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "value1"}}, }, }, StartTimeUnixNano: startTime, TimeUnixNano: endTime, - Value: &otlpmetrics.NumberDataPoint_AsDouble{ + Value: &internal.NumberDataPoint_AsDouble{ AsDouble: 456.1, }, }, @@ -815,20 +811,20 @@ func generateTestProtoSumMetric() *otlpmetrics.Metric { } } -func generateTestProtoHistogramMetric() *otlpmetrics.Metric { - return &otlpmetrics.Metric{ +func generateTestProtoHistogramMetric() *internal.Metric { + return &internal.Metric{ Name: "my_metric_histogram", Description: "My metric", Unit: "ms", - Data: &otlpmetrics.Metric_Histogram{ - Histogram: &otlpmetrics.Histogram{ - AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA, - DataPoints: []*otlpmetrics.HistogramDataPoint{ + Data: &internal.Metric_Histogram{ + Histogram: &internal.Histogram{ + AggregationTemporality: internal.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA, + DataPoints: []*internal.HistogramDataPoint{ { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "key0", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "value0"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "value0"}}, }, }, StartTimeUnixNano: startTime, @@ -837,10 +833,10 @@ func generateTestProtoHistogramMetric() *otlpmetrics.Metric { ExplicitBounds: []float64{1, 2}, }, { - Attributes: []otlpcommon.KeyValue{ + Attributes: []internal.KeyValue{ { Key: "key1", - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "value1"}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: "value1"}}, }, }, StartTimeUnixNano: startTime, @@ -855,28 +851,28 @@ func generateTestProtoHistogramMetric() *otlpmetrics.Metric { } func generateMetricsEmptyResource() Metrics { - return newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{{}}, + return newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{{}}, }, new(internal.State)) } func generateMetricsEmptyInstrumentation() Metrics { - return newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + return newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { - ScopeMetrics: []*otlpmetrics.ScopeMetrics{{}}, + ScopeMetrics: []*internal.ScopeMetrics{{}}, }, }, }, new(internal.State)) } func generateMetricsEmptyMetrics() Metrics { - return newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + return newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { - Metrics: []*otlpmetrics.Metric{{}}, + Metrics: []*internal.Metric{{}}, }, }, }, @@ -885,16 +881,16 @@ func generateMetricsEmptyMetrics() Metrics { } func generateMetricsEmptyDataPoints() Metrics { - return newMetrics(&otlpcollectormetrics.ExportMetricsServiceRequest{ - ResourceMetrics: []*otlpmetrics.ResourceMetrics{ + return newMetrics(&internal.ExportMetricsServiceRequest{ + ResourceMetrics: []*internal.ResourceMetrics{ { - ScopeMetrics: []*otlpmetrics.ScopeMetrics{ + ScopeMetrics: []*internal.ScopeMetrics{ { - Metrics: []*otlpmetrics.Metric{ + Metrics: []*internal.Metric{ { - Data: &otlpmetrics.Metric_Gauge{ - Gauge: &otlpmetrics.Gauge{ - DataPoints: []*otlpmetrics.NumberDataPoint{ + Data: &internal.Metric_Gauge{ + Gauge: &internal.Gauge{ + DataPoints: []*internal.NumberDataPoint{ {}, }, }, diff --git a/pdata/pmetric/pb.go b/pdata/pmetric/pb.go index b9a8564d2b8..bf703a764a7 100644 --- a/pdata/pmetric/pb.go +++ b/pdata/pmetric/pb.go @@ -3,58 +3,54 @@ package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric" -import ( - "go.opentelemetry.io/collector/pdata/internal" -) - var _ MarshalSizer = (*ProtoMarshaler)(nil) type ProtoMarshaler struct{} func (e *ProtoMarshaler) MarshalMetrics(md Metrics) ([]byte, error) { - size := internal.SizeProtoOrigExportMetricsServiceRequest(md.getOrig()) + size := md.getOrig().SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportMetricsServiceRequest(md.getOrig(), buf) + _ = md.getOrig().MarshalProto(buf) return buf, nil } func (e *ProtoMarshaler) MetricsSize(md Metrics) int { - return internal.SizeProtoOrigExportMetricsServiceRequest(md.getOrig()) + return md.getOrig().SizeProto() } func (e *ProtoMarshaler) ResourceMetricsSize(md ResourceMetrics) int { - return internal.SizeProtoOrigResourceMetrics(md.orig) + return md.orig.SizeProto() } func (e *ProtoMarshaler) ScopeMetricsSize(md ScopeMetrics) int { - return internal.SizeProtoOrigScopeMetrics(md.orig) + return md.orig.SizeProto() } func (e *ProtoMarshaler) MetricSize(md Metric) int { - return internal.SizeProtoOrigMetric(md.orig) + return md.orig.SizeProto() } func (e *ProtoMarshaler) NumberDataPointSize(md NumberDataPoint) int { - return internal.SizeProtoOrigNumberDataPoint(md.orig) + return md.orig.SizeProto() } func (e *ProtoMarshaler) SummaryDataPointSize(md SummaryDataPoint) int { - return internal.SizeProtoOrigSummaryDataPoint(md.orig) + return md.orig.SizeProto() } func (e *ProtoMarshaler) HistogramDataPointSize(md HistogramDataPoint) int { - return internal.SizeProtoOrigHistogramDataPoint(md.orig) + return md.orig.SizeProto() } func (e *ProtoMarshaler) ExponentialHistogramDataPointSize(md ExponentialHistogramDataPoint) int { - return internal.SizeProtoOrigExponentialHistogramDataPoint(md.orig) + return md.orig.SizeProto() } type ProtoUnmarshaler struct{} func (d *ProtoUnmarshaler) UnmarshalMetrics(buf []byte) (Metrics, error) { md := NewMetrics() - err := internal.UnmarshalProtoOrigExportMetricsServiceRequest(md.getOrig(), buf) + err := md.getOrig().UnmarshalProto(buf) if err != nil { return Metrics{}, err } diff --git a/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess.go b/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess.go index bebd88e32ce..df57abed3a8 100644 --- a/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess.go +++ b/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess.go @@ -8,7 +8,6 @@ package pmetricotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" ) // ExportPartialSuccess represents the details of a partially successful export request. @@ -19,11 +18,11 @@ import ( // Must use NewExportPartialSuccess function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportPartialSuccess struct { - orig *otlpcollectormetrics.ExportMetricsPartialSuccess + orig *internal.ExportMetricsPartialSuccess state *internal.State } -func newExportPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess, state *internal.State) ExportPartialSuccess { +func newExportPartialSuccess(orig *internal.ExportMetricsPartialSuccess, state *internal.State) ExportPartialSuccess { return ExportPartialSuccess{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSucc // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportPartialSuccess() ExportPartialSuccess { - return newExportPartialSuccess(internal.NewOrigExportMetricsPartialSuccess(), internal.NewState()) + return newExportPartialSuccess(internal.NewExportMetricsPartialSuccess(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportPartialSuccess) MoveTo(dest ExportPartialSuccess) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportMetricsPartialSuccess(dest.orig, false) + internal.DeleteExportMetricsPartialSuccess(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -73,5 +72,5 @@ func (ms ExportPartialSuccess) SetErrorMessage(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportPartialSuccess) CopyTo(dest ExportPartialSuccess) { dest.state.AssertMutable() - internal.CopyOrigExportMetricsPartialSuccess(dest.orig, ms.orig) + internal.CopyExportMetricsPartialSuccess(dest.orig, ms.orig) } diff --git a/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess_test.go b/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess_test.go index 09eb636589e..0ceb560d865 100644 --- a/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess_test.go +++ b/pdata/pmetric/pmetricotlp/generated_exportpartialsuccess_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" ) func TestExportPartialSuccess_MoveTo(t *testing.T) { @@ -25,10 +24,8 @@ func TestExportPartialSuccess_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportPartialSuccess(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewOrigExportMetricsPartialSuccess(), sharedState)) }) - assert.Panics(t, func() { - newExportPartialSuccess(internal.NewOrigExportMetricsPartialSuccess(), sharedState).MoveTo(dest) - }) + assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewExportMetricsPartialSuccess(), sharedState)) }) + assert.Panics(t, func() { newExportPartialSuccess(internal.NewExportMetricsPartialSuccess(), sharedState).MoveTo(dest) }) } func TestExportPartialSuccess_CopyTo(t *testing.T) { @@ -41,7 +38,7 @@ func TestExportPartialSuccess_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewOrigExportMetricsPartialSuccess(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewExportMetricsPartialSuccess(), sharedState)) }) } func TestExportPartialSuccess_RejectedDataPoints(t *testing.T) { @@ -52,7 +49,7 @@ func TestExportPartialSuccess_RejectedDataPoints(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectormetrics.ExportMetricsPartialSuccess{}, sharedState).SetRejectedDataPoints(int64(13)) + newExportPartialSuccess(internal.NewExportMetricsPartialSuccess(), sharedState).SetRejectedDataPoints(int64(13)) }) } @@ -64,11 +61,10 @@ func TestExportPartialSuccess_ErrorMessage(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectormetrics.ExportMetricsPartialSuccess{}, sharedState).SetErrorMessage("test_errormessage") + newExportPartialSuccess(internal.NewExportMetricsPartialSuccess(), sharedState).SetErrorMessage("test_errormessage") }) } func generateTestExportPartialSuccess() ExportPartialSuccess { - ms := newExportPartialSuccess(internal.GenTestOrigExportMetricsPartialSuccess(), internal.NewState()) - return ms + return newExportPartialSuccess(internal.GenTestExportMetricsPartialSuccess(), internal.NewState()) } diff --git a/pdata/pmetric/pmetricotlp/generated_exportresponse.go b/pdata/pmetric/pmetricotlp/generated_exportresponse.go index 5592ce857b3..53323987f1b 100644 --- a/pdata/pmetric/pmetricotlp/generated_exportresponse.go +++ b/pdata/pmetric/pmetricotlp/generated_exportresponse.go @@ -8,7 +8,6 @@ package pmetricotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" ) // ExportResponse represents the response for gRPC/HTTP client/server. @@ -19,11 +18,11 @@ import ( // Must use NewExportResponse function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportResponse struct { - orig *otlpcollectormetrics.ExportMetricsServiceResponse + orig *internal.ExportMetricsServiceResponse state *internal.State } -func newExportResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, state *internal.State) ExportResponse { +func newExportResponse(orig *internal.ExportMetricsServiceResponse, state *internal.State) ExportResponse { return ExportResponse{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportResponse(orig *otlpcollectormetrics.ExportMetricsServiceResponse, // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportResponse() ExportResponse { - return newExportResponse(internal.NewOrigExportMetricsServiceResponse(), internal.NewState()) + return newExportResponse(internal.NewExportMetricsServiceResponse(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportResponse) MoveTo(dest ExportResponse) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportMetricsServiceResponse(dest.orig, false) + internal.DeleteExportMetricsServiceResponse(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -56,5 +55,5 @@ func (ms ExportResponse) PartialSuccess() ExportPartialSuccess { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportResponse) CopyTo(dest ExportResponse) { dest.state.AssertMutable() - internal.CopyOrigExportMetricsServiceResponse(dest.orig, ms.orig) + internal.CopyExportMetricsServiceResponse(dest.orig, ms.orig) } diff --git a/pdata/pmetric/pmetricotlp/generated_exportresponse_test.go b/pdata/pmetric/pmetricotlp/generated_exportresponse_test.go index 238b7aa8240..4be9e213d0b 100644 --- a/pdata/pmetric/pmetricotlp/generated_exportresponse_test.go +++ b/pdata/pmetric/pmetricotlp/generated_exportresponse_test.go @@ -24,8 +24,8 @@ func TestExportResponse_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportResponse(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewOrigExportMetricsServiceResponse(), sharedState)) }) - assert.Panics(t, func() { newExportResponse(internal.NewOrigExportMetricsServiceResponse(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewExportMetricsServiceResponse(), sharedState)) }) + assert.Panics(t, func() { newExportResponse(internal.NewExportMetricsServiceResponse(), sharedState).MoveTo(dest) }) } func TestExportResponse_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestExportResponse_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewOrigExportMetricsServiceResponse(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewExportMetricsServiceResponse(), sharedState)) }) } func TestExportResponse_PartialSuccess(t *testing.T) { ms := NewExportResponse() assert.Equal(t, NewExportPartialSuccess(), ms.PartialSuccess()) - ms.orig.PartialSuccess = *internal.GenTestOrigExportMetricsPartialSuccess() + ms.orig.PartialSuccess = *internal.GenTestExportMetricsPartialSuccess() assert.Equal(t, generateTestExportPartialSuccess(), ms.PartialSuccess()) } func generateTestExportResponse() ExportResponse { - ms := newExportResponse(internal.GenTestOrigExportMetricsServiceResponse(), internal.NewState()) - return ms + return newExportResponse(internal.GenTestExportMetricsServiceResponse(), internal.NewState()) } diff --git a/pdata/pmetric/pmetricotlp/grpc.go b/pdata/pmetric/pmetricotlp/grpc.go index 105ac451bd3..656f0e17650 100644 --- a/pdata/pmetric/pmetricotlp/grpc.go +++ b/pdata/pmetric/pmetricotlp/grpc.go @@ -11,8 +11,7 @@ import ( "google.golang.org/grpc/status" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" - _ "go.opentelemetry.io/collector/pdata/internal/grpcencoding" // enforces custom gRPC encoding to be loaded. + "go.opentelemetry.io/collector/pdata/internal/otelgrpc" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -32,11 +31,11 @@ type GRPCClient interface { // NewGRPCClient returns a new GRPCClient connected using the given connection. func NewGRPCClient(cc *grpc.ClientConn) GRPCClient { - return &grpcClient{rawClient: otlpcollectormetrics.NewMetricsServiceClient(cc)} + return &grpcClient{rawClient: otelgrpc.NewMetricsServiceClient(cc)} } type grpcClient struct { - rawClient otlpcollectormetrics.MetricsServiceClient + rawClient otelgrpc.MetricsServiceClient } func (c *grpcClient) Export(ctx context.Context, request ExportRequest, opts ...grpc.CallOption) (ExportResponse, error) { @@ -75,14 +74,14 @@ func (*UnimplementedGRPCServer) unexported() {} // RegisterGRPCServer registers the GRPCServer to the grpc.Server. func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { - otlpcollectormetrics.RegisterMetricsServiceServer(s, &rawMetricsServer{srv: srv}) + otelgrpc.RegisterMetricsServiceServer(s, &rawMetricsServer{srv: srv}) } type rawMetricsServer struct { srv GRPCServer } -func (s rawMetricsServer) Export(ctx context.Context, request *otlpcollectormetrics.ExportMetricsServiceRequest) (*otlpcollectormetrics.ExportMetricsServiceResponse, error) { +func (s rawMetricsServer) Export(ctx context.Context, request *internal.ExportMetricsServiceRequest) (*internal.ExportMetricsServiceResponse, error) { otlp.MigrateMetrics(request.ResourceMetrics) rsp, err := s.srv.Export(ctx, ExportRequest{orig: request, state: internal.NewState()}) return rsp.orig, err diff --git a/pdata/pmetric/pmetricotlp/request.go b/pdata/pmetric/pmetricotlp/request.go index e8eb742a96b..895c0681834 100644 --- a/pdata/pmetric/pmetricotlp/request.go +++ b/pdata/pmetric/pmetricotlp/request.go @@ -7,7 +7,6 @@ import ( "slices" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/pmetric" @@ -16,14 +15,14 @@ import ( // ExportRequest represents the request for gRPC/HTTP client/server. // It's a wrapper for pmetric.Metrics data. type ExportRequest struct { - orig *otlpcollectormetrics.ExportMetricsServiceRequest + orig *internal.ExportMetricsServiceRequest state *internal.State } // NewExportRequest returns an empty ExportRequest. func NewExportRequest() ExportRequest { return ExportRequest{ - orig: &otlpcollectormetrics.ExportMetricsServiceRequest{}, + orig: &internal.ExportMetricsServiceRequest{}, state: internal.NewState(), } } @@ -33,22 +32,22 @@ func NewExportRequest() ExportRequest { // any changes to the provided Metrics struct will be reflected in the ExportRequest and vice versa. func NewExportRequestFromMetrics(md pmetric.Metrics) ExportRequest { return ExportRequest{ - orig: internal.GetOrigMetrics(internal.Metrics(md)), - state: internal.GetMetricsState(internal.Metrics(md)), + orig: internal.GetMetricsOrig(internal.MetricsWrapper(md)), + state: internal.GetMetricsState(internal.MetricsWrapper(md)), } } // MarshalProto marshals ExportRequest into proto bytes. func (ms ExportRequest) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportMetricsServiceRequest(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportMetricsServiceRequest(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportRequest from proto bytes. func (ms ExportRequest) UnmarshalProto(data []byte) error { - err := internal.UnmarshalProtoOrigExportMetricsServiceRequest(ms.orig, data) + err := ms.orig.UnmarshalProto(data) if err != nil { return err } @@ -60,7 +59,7 @@ func (ms ExportRequest) UnmarshalProto(data []byte) error { func (ms ExportRequest) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportMetricsServiceRequest(ms.orig, dest) + ms.orig.MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -71,10 +70,10 @@ func (ms ExportRequest) MarshalJSON() ([]byte, error) { func (ms ExportRequest) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportMetricsServiceRequest(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } func (ms ExportRequest) Metrics() pmetric.Metrics { - return pmetric.Metrics(internal.NewMetrics(ms.orig, ms.state)) + return pmetric.Metrics(internal.NewMetricsWrapper(ms.orig, ms.state)) } diff --git a/pdata/pmetric/pmetricotlp/request_test.go b/pdata/pmetric/pmetricotlp/request_test.go index 7607adbf234..d49f62d01f5 100644 --- a/pdata/pmetric/pmetricotlp/request_test.go +++ b/pdata/pmetric/pmetricotlp/request_test.go @@ -14,6 +14,7 @@ import ( goproto "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/pdata/internal" + "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/pmetric" ) @@ -64,7 +65,7 @@ func TestMetricsProtoWireCompatibility(t *testing.T) { // this repository are wire compatible. // Generate Metrics as pdata struct. - md := NewExportRequestFromMetrics(pmetric.Metrics(internal.NewMetrics(internal.GenTestOrigExportMetricsServiceRequest(), internal.NewState()))) + md := NewExportRequestFromMetrics(pmetric.Metrics(internal.GenTestMetricsWrapper())) // Marshal its underlying ProtoBuf to wire. wire1, err := md.MarshalProto() @@ -82,11 +83,13 @@ func TestMetricsProtoWireCompatibility(t *testing.T) { assert.NotNil(t, wire2) // Unmarshal from the wire into gogoproto's representation. - td2 := NewExportRequest() - err = td2.UnmarshalProto(wire2) + md2 := NewExportRequest() + err = md2.UnmarshalProto(wire2) require.NoError(t, err) // Now compare that the original and final ProtoBuf messages are the same. // This proves that goproto and gogoproto marshaling/unmarshaling are wire compatible. - assert.Equal(t, md, td2) + // Migration logic will run, so run it on the original message as well. + otlp.MigrateMetrics(md.orig.ResourceMetrics) + assert.Equal(t, md, md2) } diff --git a/pdata/pmetric/pmetricotlp/response.go b/pdata/pmetric/pmetricotlp/response.go index b34d5350f80..fe985edf2da 100644 --- a/pdata/pmetric/pmetricotlp/response.go +++ b/pdata/pmetric/pmetricotlp/response.go @@ -6,28 +6,27 @@ package pmetricotlp // import "go.opentelemetry.io/collector/pdata/pmetric/pmetr import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" ) // MarshalProto marshals ExportResponse into proto bytes. func (ms ExportResponse) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportMetricsServiceResponse(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportMetricsServiceResponse(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportResponse from proto bytes. func (ms ExportResponse) UnmarshalProto(data []byte) error { - return internal.UnmarshalProtoOrigExportMetricsServiceResponse(ms.orig, data) + return ms.orig.UnmarshalProto(data) } // MarshalJSON marshals ExportResponse into JSON bytes. func (ms ExportResponse) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportMetricsServiceResponse(ms.orig, dest) + ms.orig.MarshalJSON(dest) return slices.Clone(dest.Buffer()), dest.Error() } @@ -35,6 +34,6 @@ func (ms ExportResponse) MarshalJSON() ([]byte, error) { func (ms ExportResponse) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportMetricsServiceResponse(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } diff --git a/pdata/pprofile/aggregation_temporality.go b/pdata/pprofile/aggregation_temporality.go index b79f8b04097..ca4a52d84bf 100644 --- a/pdata/pprofile/aggregation_temporality.go +++ b/pdata/pprofile/aggregation_temporality.go @@ -4,7 +4,7 @@ package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile" import ( - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" + "go.opentelemetry.io/collector/pdata/internal" ) // AggregationTemporality specifies the method of aggregating metric values, @@ -14,11 +14,11 @@ type AggregationTemporality int32 const ( // AggregationTemporalityUnspecified is the default AggregationTemporality, it MUST NOT be used. - AggregationTemporalityUnspecified = AggregationTemporality(otlpprofiles.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED) + AggregationTemporalityUnspecified = AggregationTemporality(internal.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED) // AggregationTemporalityDelta is a AggregationTemporality for a metric aggregator which reports changes since last report time. - AggregationTemporalityDelta = AggregationTemporality(otlpprofiles.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA) + AggregationTemporalityDelta = AggregationTemporality(internal.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA) // AggregationTemporalityCumulative is a AggregationTemporality for a metric aggregator which reports changes since a fixed start time. - AggregationTemporalityCumulative = AggregationTemporality(otlpprofiles.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE) + AggregationTemporalityCumulative = AggregationTemporality(internal.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE) ) // String returns the string representation of the AggregationTemporality. diff --git a/pdata/pprofile/generated_function.go b/pdata/pprofile/generated_function.go index ecfb5893fad..a8d52b47958 100644 --- a/pdata/pprofile/generated_function.go +++ b/pdata/pprofile/generated_function.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // Function describes a function, including its human-readable name, system name, source file, and starting line number in the source. @@ -19,11 +18,11 @@ import ( // Must use NewFunction function to create new instances. // Important: zero-initialized instance is not valid for use. type Function struct { - orig *otlpprofiles.Function + orig *internal.Function state *internal.State } -func newFunction(orig *otlpprofiles.Function, state *internal.State) Function { +func newFunction(orig *internal.Function, state *internal.State) Function { return Function{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newFunction(orig *otlpprofiles.Function, state *internal.State) Function { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewFunction() Function { - return newFunction(internal.NewOrigFunction(), internal.NewState()) + return newFunction(internal.NewFunction(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms Function) MoveTo(dest Function) { if ms.orig == dest.orig { return } - internal.DeleteOrigFunction(dest.orig, false) + internal.DeleteFunction(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -95,5 +94,5 @@ func (ms Function) SetStartLine(v int64) { // CopyTo copies all properties from the current struct overriding the destination. func (ms Function) CopyTo(dest Function) { dest.state.AssertMutable() - internal.CopyOrigFunction(dest.orig, ms.orig) + internal.CopyFunction(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_function_test.go b/pdata/pprofile/generated_function_test.go index 3b2c3d557d0..809054534f5 100644 --- a/pdata/pprofile/generated_function_test.go +++ b/pdata/pprofile/generated_function_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestFunction_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestFunction_MoveTo(t *testing.T) { assert.Equal(t, generateTestFunction(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newFunction(internal.NewOrigFunction(), sharedState)) }) - assert.Panics(t, func() { newFunction(internal.NewOrigFunction(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newFunction(internal.NewFunction(), sharedState)) }) + assert.Panics(t, func() { newFunction(internal.NewFunction(), sharedState).MoveTo(dest) }) } func TestFunction_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestFunction_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newFunction(internal.NewOrigFunction(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newFunction(internal.NewFunction(), sharedState)) }) } func TestFunction_NameStrindex(t *testing.T) { @@ -49,7 +48,7 @@ func TestFunction_NameStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.NameStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newFunction(&otlpprofiles.Function{}, sharedState).SetNameStrindex(int32(13)) }) + assert.Panics(t, func() { newFunction(internal.NewFunction(), sharedState).SetNameStrindex(int32(13)) }) } func TestFunction_SystemNameStrindex(t *testing.T) { @@ -59,7 +58,7 @@ func TestFunction_SystemNameStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.SystemNameStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newFunction(&otlpprofiles.Function{}, sharedState).SetSystemNameStrindex(int32(13)) }) + assert.Panics(t, func() { newFunction(internal.NewFunction(), sharedState).SetSystemNameStrindex(int32(13)) }) } func TestFunction_FilenameStrindex(t *testing.T) { @@ -69,7 +68,7 @@ func TestFunction_FilenameStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.FilenameStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newFunction(&otlpprofiles.Function{}, sharedState).SetFilenameStrindex(int32(13)) }) + assert.Panics(t, func() { newFunction(internal.NewFunction(), sharedState).SetFilenameStrindex(int32(13)) }) } func TestFunction_StartLine(t *testing.T) { @@ -79,10 +78,9 @@ func TestFunction_StartLine(t *testing.T) { assert.Equal(t, int64(13), ms.StartLine()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newFunction(&otlpprofiles.Function{}, sharedState).SetStartLine(int64(13)) }) + assert.Panics(t, func() { newFunction(internal.NewFunction(), sharedState).SetStartLine(int64(13)) }) } func generateTestFunction() Function { - ms := newFunction(internal.GenTestOrigFunction(), internal.NewState()) - return ms + return newFunction(internal.GenTestFunction(), internal.NewState()) } diff --git a/pdata/pprofile/generated_functionslice.go b/pdata/pprofile/generated_functionslice.go index 054b7c21934..b584dc642ee 100644 --- a/pdata/pprofile/generated_functionslice.go +++ b/pdata/pprofile/generated_functionslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // FunctionSlice logically represents a slice of Function. @@ -22,18 +21,18 @@ import ( // Must use NewFunctionSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type FunctionSlice struct { - orig *[]*otlpprofiles.Function + orig *[]*internal.Function state *internal.State } -func newFunctionSlice(orig *[]*otlpprofiles.Function, state *internal.State) FunctionSlice { +func newFunctionSlice(orig *[]*internal.Function, state *internal.State) FunctionSlice { return FunctionSlice{orig: orig, state: state} } // NewFunctionSlice creates a FunctionSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewFunctionSlice() FunctionSlice { - orig := []*otlpprofiles.Function(nil) + orig := []*internal.Function(nil) return newFunctionSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es FunctionSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Function, len(*es.orig), newCap) + newOrig := make([]*internal.Function, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es FunctionSlice) EnsureCapacity(newCap int) { // It returns the newly added Function. func (es FunctionSlice) AppendEmpty() Function { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigFunction()) + *es.orig = append(*es.orig, internal.NewFunction()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es FunctionSlice) RemoveIf(f func(Function) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigFunction((*es.orig)[i], true) + internal.DeleteFunction((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es FunctionSlice) CopyTo(dest FunctionSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigFunctionSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyFunctionPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Function elements within FunctionSlice given the diff --git a/pdata/pprofile/generated_functionslice_test.go b/pdata/pprofile/generated_functionslice_test.go index d908771a06c..7d1189ace54 100644 --- a/pdata/pprofile/generated_functionslice_test.go +++ b/pdata/pprofile/generated_functionslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestFunctionSlice(t *testing.T) { es := NewFunctionSlice() assert.Equal(t, 0, es.Len()) - es = newFunctionSlice(&[]*otlpprofiles.Function{}, internal.NewState()) + es = newFunctionSlice(&[]*internal.Function{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewFunction() @@ -27,7 +26,7 @@ func TestFunctionSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigFunction() + (*es.orig)[i] = internal.GenTestFunction() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestFunctionSlice(t *testing.T) { func TestFunctionSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newFunctionSlice(&[]*otlpprofiles.Function{}, sharedState) + es := newFunctionSlice(&[]*internal.Function{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestFunctionSlice_Sort(t *testing.T) { func generateTestFunctionSlice() FunctionSlice { ms := NewFunctionSlice() - *ms.orig = internal.GenerateOrigTestFunctionSlice() + *ms.orig = internal.GenTestFunctionPtrSlice() return ms } diff --git a/pdata/pprofile/generated_keyvalueandunit.go b/pdata/pprofile/generated_keyvalueandunit.go index 052c844cd1d..15eac86a657 100644 --- a/pdata/pprofile/generated_keyvalueandunit.go +++ b/pdata/pprofile/generated_keyvalueandunit.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -22,11 +21,11 @@ import ( // Must use NewKeyValueAndUnit function to create new instances. // Important: zero-initialized instance is not valid for use. type KeyValueAndUnit struct { - orig *otlpprofiles.KeyValueAndUnit + orig *internal.KeyValueAndUnit state *internal.State } -func newKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, state *internal.State) KeyValueAndUnit { +func newKeyValueAndUnit(orig *internal.KeyValueAndUnit, state *internal.State) KeyValueAndUnit { return KeyValueAndUnit{orig: orig, state: state} } @@ -35,7 +34,7 @@ func newKeyValueAndUnit(orig *otlpprofiles.KeyValueAndUnit, state *internal.Stat // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewKeyValueAndUnit() KeyValueAndUnit { - return newKeyValueAndUnit(internal.NewOrigKeyValueAndUnit(), internal.NewState()) + return newKeyValueAndUnit(internal.NewKeyValueAndUnit(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -47,7 +46,7 @@ func (ms KeyValueAndUnit) MoveTo(dest KeyValueAndUnit) { if ms.orig == dest.orig { return } - internal.DeleteOrigKeyValueAndUnit(dest.orig, false) + internal.DeleteKeyValueAndUnit(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -64,7 +63,7 @@ func (ms KeyValueAndUnit) SetKeyStrindex(v int32) { // Value returns the value associated with this KeyValueAndUnit. func (ms KeyValueAndUnit) Value() pcommon.Value { - return pcommon.Value(internal.NewValue(&ms.orig.Value, ms.state)) + return pcommon.Value(internal.NewValueWrapper(&ms.orig.Value, ms.state)) } // UnitStrindex returns the unitstrindex associated with this KeyValueAndUnit. @@ -81,5 +80,5 @@ func (ms KeyValueAndUnit) SetUnitStrindex(v int32) { // CopyTo copies all properties from the current struct overriding the destination. func (ms KeyValueAndUnit) CopyTo(dest KeyValueAndUnit) { dest.state.AssertMutable() - internal.CopyOrigKeyValueAndUnit(dest.orig, ms.orig) + internal.CopyKeyValueAndUnit(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_keyvalueandunit_test.go b/pdata/pprofile/generated_keyvalueandunit_test.go index b1b06fcb118..33c347605e5 100644 --- a/pdata/pprofile/generated_keyvalueandunit_test.go +++ b/pdata/pprofile/generated_keyvalueandunit_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestKeyValueAndUnit_MoveTo(t *testing.T) { assert.Equal(t, generateTestKeyValueAndUnit(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newKeyValueAndUnit(internal.NewOrigKeyValueAndUnit(), sharedState)) }) - assert.Panics(t, func() { newKeyValueAndUnit(internal.NewOrigKeyValueAndUnit(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newKeyValueAndUnit(internal.NewKeyValueAndUnit(), sharedState)) }) + assert.Panics(t, func() { newKeyValueAndUnit(internal.NewKeyValueAndUnit(), sharedState).MoveTo(dest) }) } func TestKeyValueAndUnit_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestKeyValueAndUnit_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newKeyValueAndUnit(internal.NewOrigKeyValueAndUnit(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newKeyValueAndUnit(internal.NewKeyValueAndUnit(), sharedState)) }) } func TestKeyValueAndUnit_KeyStrindex(t *testing.T) { @@ -50,14 +49,14 @@ func TestKeyValueAndUnit_KeyStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.KeyStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newKeyValueAndUnit(&otlpprofiles.KeyValueAndUnit{}, sharedState).SetKeyStrindex(int32(13)) }) + assert.Panics(t, func() { newKeyValueAndUnit(internal.NewKeyValueAndUnit(), sharedState).SetKeyStrindex(int32(13)) }) } func TestKeyValueAndUnit_Value(t *testing.T) { ms := NewKeyValueAndUnit() assert.Equal(t, pcommon.NewValueEmpty(), ms.Value()) - ms.orig.Value = *internal.GenTestOrigAnyValue() - assert.Equal(t, pcommon.Value(internal.NewValue(internal.GenTestOrigAnyValue(), ms.state)), ms.Value()) + ms.orig.Value = *internal.GenTestAnyValue() + assert.Equal(t, pcommon.Value(internal.GenTestValueWrapper()), ms.Value()) } func TestKeyValueAndUnit_UnitStrindex(t *testing.T) { @@ -67,10 +66,9 @@ func TestKeyValueAndUnit_UnitStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.UnitStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newKeyValueAndUnit(&otlpprofiles.KeyValueAndUnit{}, sharedState).SetUnitStrindex(int32(13)) }) + assert.Panics(t, func() { newKeyValueAndUnit(internal.NewKeyValueAndUnit(), sharedState).SetUnitStrindex(int32(13)) }) } func generateTestKeyValueAndUnit() KeyValueAndUnit { - ms := newKeyValueAndUnit(internal.GenTestOrigKeyValueAndUnit(), internal.NewState()) - return ms + return newKeyValueAndUnit(internal.GenTestKeyValueAndUnit(), internal.NewState()) } diff --git a/pdata/pprofile/generated_keyvalueandunitslice.go b/pdata/pprofile/generated_keyvalueandunitslice.go index 4dfd60afe62..03c54bd4c37 100644 --- a/pdata/pprofile/generated_keyvalueandunitslice.go +++ b/pdata/pprofile/generated_keyvalueandunitslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // KeyValueAndUnitSlice logically represents a slice of KeyValueAndUnit. @@ -22,18 +21,18 @@ import ( // Must use NewKeyValueAndUnitSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type KeyValueAndUnitSlice struct { - orig *[]*otlpprofiles.KeyValueAndUnit + orig *[]*internal.KeyValueAndUnit state *internal.State } -func newKeyValueAndUnitSlice(orig *[]*otlpprofiles.KeyValueAndUnit, state *internal.State) KeyValueAndUnitSlice { +func newKeyValueAndUnitSlice(orig *[]*internal.KeyValueAndUnit, state *internal.State) KeyValueAndUnitSlice { return KeyValueAndUnitSlice{orig: orig, state: state} } // NewKeyValueAndUnitSlice creates a KeyValueAndUnitSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewKeyValueAndUnitSlice() KeyValueAndUnitSlice { - orig := []*otlpprofiles.KeyValueAndUnit(nil) + orig := []*internal.KeyValueAndUnit(nil) return newKeyValueAndUnitSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es KeyValueAndUnitSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.KeyValueAndUnit, len(*es.orig), newCap) + newOrig := make([]*internal.KeyValueAndUnit, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es KeyValueAndUnitSlice) EnsureCapacity(newCap int) { // It returns the newly added KeyValueAndUnit. func (es KeyValueAndUnitSlice) AppendEmpty() KeyValueAndUnit { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigKeyValueAndUnit()) + *es.orig = append(*es.orig, internal.NewKeyValueAndUnit()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es KeyValueAndUnitSlice) RemoveIf(f func(KeyValueAndUnit) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigKeyValueAndUnit((*es.orig)[i], true) + internal.DeleteKeyValueAndUnit((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es KeyValueAndUnitSlice) CopyTo(dest KeyValueAndUnitSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigKeyValueAndUnitSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyKeyValueAndUnitPtrSlice(*dest.orig, *es.orig) } // Sort sorts the KeyValueAndUnit elements within KeyValueAndUnitSlice given the diff --git a/pdata/pprofile/generated_keyvalueandunitslice_test.go b/pdata/pprofile/generated_keyvalueandunitslice_test.go index eab5a658dbb..e961cbcc18a 100644 --- a/pdata/pprofile/generated_keyvalueandunitslice_test.go +++ b/pdata/pprofile/generated_keyvalueandunitslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestKeyValueAndUnitSlice(t *testing.T) { es := NewKeyValueAndUnitSlice() assert.Equal(t, 0, es.Len()) - es = newKeyValueAndUnitSlice(&[]*otlpprofiles.KeyValueAndUnit{}, internal.NewState()) + es = newKeyValueAndUnitSlice(&[]*internal.KeyValueAndUnit{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewKeyValueAndUnit() @@ -27,7 +26,7 @@ func TestKeyValueAndUnitSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigKeyValueAndUnit() + (*es.orig)[i] = internal.GenTestKeyValueAndUnit() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestKeyValueAndUnitSlice(t *testing.T) { func TestKeyValueAndUnitSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newKeyValueAndUnitSlice(&[]*otlpprofiles.KeyValueAndUnit{}, sharedState) + es := newKeyValueAndUnitSlice(&[]*internal.KeyValueAndUnit{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestKeyValueAndUnitSlice_Sort(t *testing.T) { func generateTestKeyValueAndUnitSlice() KeyValueAndUnitSlice { ms := NewKeyValueAndUnitSlice() - *ms.orig = internal.GenerateOrigTestKeyValueAndUnitSlice() + *ms.orig = internal.GenTestKeyValueAndUnitPtrSlice() return ms } diff --git a/pdata/pprofile/generated_line.go b/pdata/pprofile/generated_line.go index 421cf1eb87d..724ce01ec23 100644 --- a/pdata/pprofile/generated_line.go +++ b/pdata/pprofile/generated_line.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // Line details a specific line in a source code, linked to a function. @@ -19,11 +18,11 @@ import ( // Must use NewLine function to create new instances. // Important: zero-initialized instance is not valid for use. type Line struct { - orig *otlpprofiles.Line + orig *internal.Line state *internal.State } -func newLine(orig *otlpprofiles.Line, state *internal.State) Line { +func newLine(orig *internal.Line, state *internal.State) Line { return Line{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newLine(orig *otlpprofiles.Line, state *internal.State) Line { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewLine() Line { - return newLine(internal.NewOrigLine(), internal.NewState()) + return newLine(internal.NewLine(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms Line) MoveTo(dest Line) { if ms.orig == dest.orig { return } - internal.DeleteOrigLine(dest.orig, false) + internal.DeleteLine(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -84,5 +83,5 @@ func (ms Line) SetColumn(v int64) { // CopyTo copies all properties from the current struct overriding the destination. func (ms Line) CopyTo(dest Line) { dest.state.AssertMutable() - internal.CopyOrigLine(dest.orig, ms.orig) + internal.CopyLine(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_line_test.go b/pdata/pprofile/generated_line_test.go index 159fddf7a51..6643e76c69a 100644 --- a/pdata/pprofile/generated_line_test.go +++ b/pdata/pprofile/generated_line_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestLine_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestLine_MoveTo(t *testing.T) { assert.Equal(t, generateTestLine(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newLine(internal.NewOrigLine(), sharedState)) }) - assert.Panics(t, func() { newLine(internal.NewOrigLine(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newLine(internal.NewLine(), sharedState)) }) + assert.Panics(t, func() { newLine(internal.NewLine(), sharedState).MoveTo(dest) }) } func TestLine_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestLine_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newLine(internal.NewOrigLine(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newLine(internal.NewLine(), sharedState)) }) } func TestLine_FunctionIndex(t *testing.T) { @@ -49,7 +48,7 @@ func TestLine_FunctionIndex(t *testing.T) { assert.Equal(t, int32(13), ms.FunctionIndex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLine(&otlpprofiles.Line{}, sharedState).SetFunctionIndex(int32(13)) }) + assert.Panics(t, func() { newLine(internal.NewLine(), sharedState).SetFunctionIndex(int32(13)) }) } func TestLine_Line(t *testing.T) { @@ -59,7 +58,7 @@ func TestLine_Line(t *testing.T) { assert.Equal(t, int64(13), ms.Line()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLine(&otlpprofiles.Line{}, sharedState).SetLine(int64(13)) }) + assert.Panics(t, func() { newLine(internal.NewLine(), sharedState).SetLine(int64(13)) }) } func TestLine_Column(t *testing.T) { @@ -69,10 +68,9 @@ func TestLine_Column(t *testing.T) { assert.Equal(t, int64(13), ms.Column()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLine(&otlpprofiles.Line{}, sharedState).SetColumn(int64(13)) }) + assert.Panics(t, func() { newLine(internal.NewLine(), sharedState).SetColumn(int64(13)) }) } func generateTestLine() Line { - ms := newLine(internal.GenTestOrigLine(), internal.NewState()) - return ms + return newLine(internal.GenTestLine(), internal.NewState()) } diff --git a/pdata/pprofile/generated_lineslice.go b/pdata/pprofile/generated_lineslice.go index 96051f11e58..b4f61db3798 100644 --- a/pdata/pprofile/generated_lineslice.go +++ b/pdata/pprofile/generated_lineslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // LineSlice logically represents a slice of Line. @@ -22,18 +21,18 @@ import ( // Must use NewLineSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LineSlice struct { - orig *[]*otlpprofiles.Line + orig *[]*internal.Line state *internal.State } -func newLineSlice(orig *[]*otlpprofiles.Line, state *internal.State) LineSlice { +func newLineSlice(orig *[]*internal.Line, state *internal.State) LineSlice { return LineSlice{orig: orig, state: state} } // NewLineSlice creates a LineSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLineSlice() LineSlice { - orig := []*otlpprofiles.Line(nil) + orig := []*internal.Line(nil) return newLineSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es LineSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Line, len(*es.orig), newCap) + newOrig := make([]*internal.Line, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es LineSlice) EnsureCapacity(newCap int) { // It returns the newly added Line. func (es LineSlice) AppendEmpty() Line { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigLine()) + *es.orig = append(*es.orig, internal.NewLine()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es LineSlice) RemoveIf(f func(Line) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigLine((*es.orig)[i], true) + internal.DeleteLine((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es LineSlice) CopyTo(dest LineSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigLineSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyLinePtrSlice(*dest.orig, *es.orig) } // Sort sorts the Line elements within LineSlice given the diff --git a/pdata/pprofile/generated_lineslice_test.go b/pdata/pprofile/generated_lineslice_test.go index 40f24afd7cc..ddbdd9cd0ab 100644 --- a/pdata/pprofile/generated_lineslice_test.go +++ b/pdata/pprofile/generated_lineslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestLineSlice(t *testing.T) { es := NewLineSlice() assert.Equal(t, 0, es.Len()) - es = newLineSlice(&[]*otlpprofiles.Line{}, internal.NewState()) + es = newLineSlice(&[]*internal.Line{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewLine() @@ -27,7 +26,7 @@ func TestLineSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigLine() + (*es.orig)[i] = internal.GenTestLine() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestLineSlice(t *testing.T) { func TestLineSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newLineSlice(&[]*otlpprofiles.Line{}, sharedState) + es := newLineSlice(&[]*internal.Line{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestLineSlice_Sort(t *testing.T) { func generateTestLineSlice() LineSlice { ms := NewLineSlice() - *ms.orig = internal.GenerateOrigTestLineSlice() + *ms.orig = internal.GenTestLinePtrSlice() return ms } diff --git a/pdata/pprofile/generated_link.go b/pdata/pprofile/generated_link.go index 8b2ae094fda..70f401edacd 100644 --- a/pdata/pprofile/generated_link.go +++ b/pdata/pprofile/generated_link.go @@ -8,8 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -21,11 +19,11 @@ import ( // Must use NewLink function to create new instances. // Important: zero-initialized instance is not valid for use. type Link struct { - orig *otlpprofiles.Link + orig *internal.Link state *internal.State } -func newLink(orig *otlpprofiles.Link, state *internal.State) Link { +func newLink(orig *internal.Link, state *internal.State) Link { return Link{orig: orig, state: state} } @@ -34,7 +32,7 @@ func newLink(orig *otlpprofiles.Link, state *internal.State) Link { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewLink() Link { - return newLink(internal.NewOrigLink(), internal.NewState()) + return newLink(internal.NewLink(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -46,7 +44,7 @@ func (ms Link) MoveTo(dest Link) { if ms.orig == dest.orig { return } - internal.DeleteOrigLink(dest.orig, false) + internal.DeleteLink(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -58,7 +56,7 @@ func (ms Link) TraceID() pcommon.TraceID { // SetTraceID replaces the traceid associated with this Link. func (ms Link) SetTraceID(v pcommon.TraceID) { ms.state.AssertMutable() - ms.orig.TraceId = data.TraceID(v) + ms.orig.TraceId = internal.TraceID(v) } // SpanID returns the spanid associated with this Link. @@ -69,11 +67,11 @@ func (ms Link) SpanID() pcommon.SpanID { // SetSpanID replaces the spanid associated with this Link. func (ms Link) SetSpanID(v pcommon.SpanID) { ms.state.AssertMutable() - ms.orig.SpanId = data.SpanID(v) + ms.orig.SpanId = internal.SpanID(v) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Link) CopyTo(dest Link) { dest.state.AssertMutable() - internal.CopyOrigLink(dest.orig, ms.orig) + internal.CopyLink(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_link_test.go b/pdata/pprofile/generated_link_test.go index d22025b3657..a49c44886d4 100644 --- a/pdata/pprofile/generated_link_test.go +++ b/pdata/pprofile/generated_link_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestLink_MoveTo(t *testing.T) { assert.Equal(t, generateTestLink(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newLink(internal.NewOrigLink(), sharedState)) }) - assert.Panics(t, func() { newLink(internal.NewOrigLink(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newLink(internal.NewLink(), sharedState)) }) + assert.Panics(t, func() { newLink(internal.NewLink(), sharedState).MoveTo(dest) }) } func TestLink_CopyTo(t *testing.T) { @@ -40,26 +39,25 @@ func TestLink_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newLink(internal.NewOrigLink(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newLink(internal.NewLink(), sharedState)) }) } func TestLink_TraceID(t *testing.T) { ms := NewLink() - assert.Equal(t, pcommon.TraceID(data.TraceID([16]byte{})), ms.TraceID()) - testValTraceID := pcommon.TraceID(data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.TraceID(internal.TraceID([16]byte{})), ms.TraceID()) + testValTraceID := pcommon.TraceID(internal.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) ms.SetTraceID(testValTraceID) assert.Equal(t, testValTraceID, ms.TraceID()) } func TestLink_SpanID(t *testing.T) { ms := NewLink() - assert.Equal(t, pcommon.SpanID(data.SpanID([8]byte{})), ms.SpanID()) - testValSpanID := pcommon.SpanID(data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.SpanID(internal.SpanID([8]byte{})), ms.SpanID()) + testValSpanID := pcommon.SpanID(internal.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) ms.SetSpanID(testValSpanID) assert.Equal(t, testValSpanID, ms.SpanID()) } func generateTestLink() Link { - ms := newLink(internal.GenTestOrigLink(), internal.NewState()) - return ms + return newLink(internal.GenTestLink(), internal.NewState()) } diff --git a/pdata/pprofile/generated_linkslice.go b/pdata/pprofile/generated_linkslice.go index 1f20423da2d..51908bc45e4 100644 --- a/pdata/pprofile/generated_linkslice.go +++ b/pdata/pprofile/generated_linkslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // LinkSlice logically represents a slice of Link. @@ -22,18 +21,18 @@ import ( // Must use NewLinkSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LinkSlice struct { - orig *[]*otlpprofiles.Link + orig *[]*internal.Link state *internal.State } -func newLinkSlice(orig *[]*otlpprofiles.Link, state *internal.State) LinkSlice { +func newLinkSlice(orig *[]*internal.Link, state *internal.State) LinkSlice { return LinkSlice{orig: orig, state: state} } // NewLinkSlice creates a LinkSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLinkSlice() LinkSlice { - orig := []*otlpprofiles.Link(nil) + orig := []*internal.Link(nil) return newLinkSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es LinkSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Link, len(*es.orig), newCap) + newOrig := make([]*internal.Link, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es LinkSlice) EnsureCapacity(newCap int) { // It returns the newly added Link. func (es LinkSlice) AppendEmpty() Link { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigLink()) + *es.orig = append(*es.orig, internal.NewLink()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es LinkSlice) RemoveIf(f func(Link) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigLink((*es.orig)[i], true) + internal.DeleteLink((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es LinkSlice) CopyTo(dest LinkSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigLinkSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyLinkPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Link elements within LinkSlice given the diff --git a/pdata/pprofile/generated_linkslice_test.go b/pdata/pprofile/generated_linkslice_test.go index 0e67941dbbb..fd76bf84da7 100644 --- a/pdata/pprofile/generated_linkslice_test.go +++ b/pdata/pprofile/generated_linkslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestLinkSlice(t *testing.T) { es := NewLinkSlice() assert.Equal(t, 0, es.Len()) - es = newLinkSlice(&[]*otlpprofiles.Link{}, internal.NewState()) + es = newLinkSlice(&[]*internal.Link{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewLink() @@ -27,7 +26,7 @@ func TestLinkSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigLink() + (*es.orig)[i] = internal.GenTestLink() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestLinkSlice(t *testing.T) { func TestLinkSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newLinkSlice(&[]*otlpprofiles.Link{}, sharedState) + es := newLinkSlice(&[]*internal.Link{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestLinkSlice_Sort(t *testing.T) { func generateTestLinkSlice() LinkSlice { ms := NewLinkSlice() - *ms.orig = internal.GenerateOrigTestLinkSlice() + *ms.orig = internal.GenTestLinkPtrSlice() return ms } diff --git a/pdata/pprofile/generated_location.go b/pdata/pprofile/generated_location.go index a53c5800953..b529b839cfb 100644 --- a/pdata/pprofile/generated_location.go +++ b/pdata/pprofile/generated_location.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewLocation function to create new instances. // Important: zero-initialized instance is not valid for use. type Location struct { - orig *otlpprofiles.Location + orig *internal.Location state *internal.State } -func newLocation(orig *otlpprofiles.Location, state *internal.State) Location { +func newLocation(orig *internal.Location, state *internal.State) Location { return Location{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newLocation(orig *otlpprofiles.Location, state *internal.State) Location { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewLocation() Location { - return newLocation(internal.NewOrigLocation(), internal.NewState()) + return newLocation(internal.NewLocation(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms Location) MoveTo(dest Location) { if ms.orig == dest.orig { return } - internal.DeleteOrigLocation(dest.orig, false) + internal.DeleteLocation(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -78,11 +77,11 @@ func (ms Location) Line() LineSlice { // AttributeIndices returns the AttributeIndices associated with this Location. func (ms Location) AttributeIndices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.AttributeIndices, ms.state)) + return pcommon.Int32Slice(internal.NewInt32SliceWrapper(&ms.orig.AttributeIndices, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Location) CopyTo(dest Location) { dest.state.AssertMutable() - internal.CopyOrigLocation(dest.orig, ms.orig) + internal.CopyLocation(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_location_test.go b/pdata/pprofile/generated_location_test.go index 8ff5cf4563a..cf8d8f605a3 100644 --- a/pdata/pprofile/generated_location_test.go +++ b/pdata/pprofile/generated_location_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestLocation_MoveTo(t *testing.T) { assert.Equal(t, generateTestLocation(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newLocation(internal.NewOrigLocation(), sharedState)) }) - assert.Panics(t, func() { newLocation(internal.NewOrigLocation(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newLocation(internal.NewLocation(), sharedState)) }) + assert.Panics(t, func() { newLocation(internal.NewLocation(), sharedState).MoveTo(dest) }) } func TestLocation_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestLocation_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newLocation(internal.NewOrigLocation(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newLocation(internal.NewLocation(), sharedState)) }) } func TestLocation_MappingIndex(t *testing.T) { @@ -50,7 +49,7 @@ func TestLocation_MappingIndex(t *testing.T) { assert.Equal(t, int32(13), ms.MappingIndex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLocation(&otlpprofiles.Location{}, sharedState).SetMappingIndex(int32(13)) }) + assert.Panics(t, func() { newLocation(internal.NewLocation(), sharedState).SetMappingIndex(int32(13)) }) } func TestLocation_Address(t *testing.T) { @@ -60,24 +59,23 @@ func TestLocation_Address(t *testing.T) { assert.Equal(t, uint64(13), ms.Address()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newLocation(&otlpprofiles.Location{}, sharedState).SetAddress(uint64(13)) }) + assert.Panics(t, func() { newLocation(internal.NewLocation(), sharedState).SetAddress(uint64(13)) }) } func TestLocation_Line(t *testing.T) { ms := NewLocation() assert.Equal(t, NewLineSlice(), ms.Line()) - ms.orig.Line = internal.GenerateOrigTestLineSlice() + ms.orig.Line = internal.GenTestLinePtrSlice() assert.Equal(t, generateTestLineSlice(), ms.Line()) } func TestLocation_AttributeIndices(t *testing.T) { ms := NewLocation() assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices()) - ms.orig.AttributeIndices = internal.GenerateOrigTestInt32Slice() - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.AttributeIndices()) + ms.orig.AttributeIndices = internal.GenTestInt32Slice() + assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.AttributeIndices()) } func generateTestLocation() Location { - ms := newLocation(internal.GenTestOrigLocation(), internal.NewState()) - return ms + return newLocation(internal.GenTestLocation(), internal.NewState()) } diff --git a/pdata/pprofile/generated_locationslice.go b/pdata/pprofile/generated_locationslice.go index 2cba74b954c..0cad6a0af79 100644 --- a/pdata/pprofile/generated_locationslice.go +++ b/pdata/pprofile/generated_locationslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // LocationSlice logically represents a slice of Location. @@ -22,18 +21,18 @@ import ( // Must use NewLocationSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type LocationSlice struct { - orig *[]*otlpprofiles.Location + orig *[]*internal.Location state *internal.State } -func newLocationSlice(orig *[]*otlpprofiles.Location, state *internal.State) LocationSlice { +func newLocationSlice(orig *[]*internal.Location, state *internal.State) LocationSlice { return LocationSlice{orig: orig, state: state} } // NewLocationSlice creates a LocationSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewLocationSlice() LocationSlice { - orig := []*otlpprofiles.Location(nil) + orig := []*internal.Location(nil) return newLocationSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es LocationSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Location, len(*es.orig), newCap) + newOrig := make([]*internal.Location, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es LocationSlice) EnsureCapacity(newCap int) { // It returns the newly added Location. func (es LocationSlice) AppendEmpty() Location { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigLocation()) + *es.orig = append(*es.orig, internal.NewLocation()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es LocationSlice) RemoveIf(f func(Location) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigLocation((*es.orig)[i], true) + internal.DeleteLocation((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es LocationSlice) CopyTo(dest LocationSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigLocationSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyLocationPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Location elements within LocationSlice given the diff --git a/pdata/pprofile/generated_locationslice_test.go b/pdata/pprofile/generated_locationslice_test.go index fb1995f91da..d6afbc784a9 100644 --- a/pdata/pprofile/generated_locationslice_test.go +++ b/pdata/pprofile/generated_locationslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestLocationSlice(t *testing.T) { es := NewLocationSlice() assert.Equal(t, 0, es.Len()) - es = newLocationSlice(&[]*otlpprofiles.Location{}, internal.NewState()) + es = newLocationSlice(&[]*internal.Location{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewLocation() @@ -27,7 +26,7 @@ func TestLocationSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigLocation() + (*es.orig)[i] = internal.GenTestLocation() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestLocationSlice(t *testing.T) { func TestLocationSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newLocationSlice(&[]*otlpprofiles.Location{}, sharedState) + es := newLocationSlice(&[]*internal.Location{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestLocationSlice_Sort(t *testing.T) { func generateTestLocationSlice() LocationSlice { ms := NewLocationSlice() - *ms.orig = internal.GenerateOrigTestLocationSlice() + *ms.orig = internal.GenTestLocationPtrSlice() return ms } diff --git a/pdata/pprofile/generated_mapping.go b/pdata/pprofile/generated_mapping.go index 24e1efe2930..8294acc5839 100644 --- a/pdata/pprofile/generated_mapping.go +++ b/pdata/pprofile/generated_mapping.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewMapping function to create new instances. // Important: zero-initialized instance is not valid for use. type Mapping struct { - orig *otlpprofiles.Mapping + orig *internal.Mapping state *internal.State } -func newMapping(orig *otlpprofiles.Mapping, state *internal.State) Mapping { +func newMapping(orig *internal.Mapping, state *internal.State) Mapping { return Mapping{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newMapping(orig *otlpprofiles.Mapping, state *internal.State) Mapping { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewMapping() Mapping { - return newMapping(internal.NewOrigMapping(), internal.NewState()) + return newMapping(internal.NewMapping(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms Mapping) MoveTo(dest Mapping) { if ms.orig == dest.orig { return } - internal.DeleteOrigMapping(dest.orig, false) + internal.DeleteMapping(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -95,11 +94,11 @@ func (ms Mapping) SetFilenameStrindex(v int32) { // AttributeIndices returns the AttributeIndices associated with this Mapping. func (ms Mapping) AttributeIndices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.AttributeIndices, ms.state)) + return pcommon.Int32Slice(internal.NewInt32SliceWrapper(&ms.orig.AttributeIndices, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Mapping) CopyTo(dest Mapping) { dest.state.AssertMutable() - internal.CopyOrigMapping(dest.orig, ms.orig) + internal.CopyMapping(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_mapping_test.go b/pdata/pprofile/generated_mapping_test.go index 935919cde68..e285bc9e8be 100644 --- a/pdata/pprofile/generated_mapping_test.go +++ b/pdata/pprofile/generated_mapping_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestMapping_MoveTo(t *testing.T) { assert.Equal(t, generateTestMapping(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newMapping(internal.NewOrigMapping(), sharedState)) }) - assert.Panics(t, func() { newMapping(internal.NewOrigMapping(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newMapping(internal.NewMapping(), sharedState)) }) + assert.Panics(t, func() { newMapping(internal.NewMapping(), sharedState).MoveTo(dest) }) } func TestMapping_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestMapping_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newMapping(internal.NewOrigMapping(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newMapping(internal.NewMapping(), sharedState)) }) } func TestMapping_MemoryStart(t *testing.T) { @@ -50,7 +49,7 @@ func TestMapping_MemoryStart(t *testing.T) { assert.Equal(t, uint64(13), ms.MemoryStart()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMapping(&otlpprofiles.Mapping{}, sharedState).SetMemoryStart(uint64(13)) }) + assert.Panics(t, func() { newMapping(internal.NewMapping(), sharedState).SetMemoryStart(uint64(13)) }) } func TestMapping_MemoryLimit(t *testing.T) { @@ -60,7 +59,7 @@ func TestMapping_MemoryLimit(t *testing.T) { assert.Equal(t, uint64(13), ms.MemoryLimit()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMapping(&otlpprofiles.Mapping{}, sharedState).SetMemoryLimit(uint64(13)) }) + assert.Panics(t, func() { newMapping(internal.NewMapping(), sharedState).SetMemoryLimit(uint64(13)) }) } func TestMapping_FileOffset(t *testing.T) { @@ -70,7 +69,7 @@ func TestMapping_FileOffset(t *testing.T) { assert.Equal(t, uint64(13), ms.FileOffset()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMapping(&otlpprofiles.Mapping{}, sharedState).SetFileOffset(uint64(13)) }) + assert.Panics(t, func() { newMapping(internal.NewMapping(), sharedState).SetFileOffset(uint64(13)) }) } func TestMapping_FilenameStrindex(t *testing.T) { @@ -80,17 +79,16 @@ func TestMapping_FilenameStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.FilenameStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newMapping(&otlpprofiles.Mapping{}, sharedState).SetFilenameStrindex(int32(13)) }) + assert.Panics(t, func() { newMapping(internal.NewMapping(), sharedState).SetFilenameStrindex(int32(13)) }) } func TestMapping_AttributeIndices(t *testing.T) { ms := NewMapping() assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices()) - ms.orig.AttributeIndices = internal.GenerateOrigTestInt32Slice() - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.AttributeIndices()) + ms.orig.AttributeIndices = internal.GenTestInt32Slice() + assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.AttributeIndices()) } func generateTestMapping() Mapping { - ms := newMapping(internal.GenTestOrigMapping(), internal.NewState()) - return ms + return newMapping(internal.GenTestMapping(), internal.NewState()) } diff --git a/pdata/pprofile/generated_mappingslice.go b/pdata/pprofile/generated_mappingslice.go index 2dd3a8ffe5d..45cb4823232 100644 --- a/pdata/pprofile/generated_mappingslice.go +++ b/pdata/pprofile/generated_mappingslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // MappingSlice logically represents a slice of Mapping. @@ -22,18 +21,18 @@ import ( // Must use NewMappingSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type MappingSlice struct { - orig *[]*otlpprofiles.Mapping + orig *[]*internal.Mapping state *internal.State } -func newMappingSlice(orig *[]*otlpprofiles.Mapping, state *internal.State) MappingSlice { +func newMappingSlice(orig *[]*internal.Mapping, state *internal.State) MappingSlice { return MappingSlice{orig: orig, state: state} } // NewMappingSlice creates a MappingSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewMappingSlice() MappingSlice { - orig := []*otlpprofiles.Mapping(nil) + orig := []*internal.Mapping(nil) return newMappingSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es MappingSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Mapping, len(*es.orig), newCap) + newOrig := make([]*internal.Mapping, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es MappingSlice) EnsureCapacity(newCap int) { // It returns the newly added Mapping. func (es MappingSlice) AppendEmpty() Mapping { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigMapping()) + *es.orig = append(*es.orig, internal.NewMapping()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es MappingSlice) RemoveIf(f func(Mapping) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigMapping((*es.orig)[i], true) + internal.DeleteMapping((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es MappingSlice) CopyTo(dest MappingSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigMappingSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyMappingPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Mapping elements within MappingSlice given the diff --git a/pdata/pprofile/generated_mappingslice_test.go b/pdata/pprofile/generated_mappingslice_test.go index db8edeffaed..5e2e622981e 100644 --- a/pdata/pprofile/generated_mappingslice_test.go +++ b/pdata/pprofile/generated_mappingslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestMappingSlice(t *testing.T) { es := NewMappingSlice() assert.Equal(t, 0, es.Len()) - es = newMappingSlice(&[]*otlpprofiles.Mapping{}, internal.NewState()) + es = newMappingSlice(&[]*internal.Mapping{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewMapping() @@ -27,7 +26,7 @@ func TestMappingSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigMapping() + (*es.orig)[i] = internal.GenTestMapping() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestMappingSlice(t *testing.T) { func TestMappingSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newMappingSlice(&[]*otlpprofiles.Mapping{}, sharedState) + es := newMappingSlice(&[]*internal.Mapping{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestMappingSlice_Sort(t *testing.T) { func generateTestMappingSlice() MappingSlice { ms := NewMappingSlice() - *ms.orig = internal.GenerateOrigTestMappingSlice() + *ms.orig = internal.GenTestMappingPtrSlice() return ms } diff --git a/pdata/pprofile/generated_profile.go b/pdata/pprofile/generated_profile.go index be0f6bf0b29..87c3c1128dc 100644 --- a/pdata/pprofile/generated_profile.go +++ b/pdata/pprofile/generated_profile.go @@ -8,8 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -21,11 +19,11 @@ import ( // Must use NewProfile function to create new instances. // Important: zero-initialized instance is not valid for use. type Profile struct { - orig *otlpprofiles.Profile + orig *internal.Profile state *internal.State } -func newProfile(orig *otlpprofiles.Profile, state *internal.State) Profile { +func newProfile(orig *internal.Profile, state *internal.State) Profile { return Profile{orig: orig, state: state} } @@ -34,7 +32,7 @@ func newProfile(orig *otlpprofiles.Profile, state *internal.State) Profile { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewProfile() Profile { - return newProfile(internal.NewOrigProfile(), internal.NewState()) + return newProfile(internal.NewProfile(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -46,7 +44,7 @@ func (ms Profile) MoveTo(dest Profile) { if ms.orig == dest.orig { return } - internal.DeleteOrigProfile(dest.orig, false) + internal.DeleteProfile(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -100,7 +98,7 @@ func (ms Profile) SetPeriod(v int64) { // CommentStrindices returns the CommentStrindices associated with this Profile. func (ms Profile) CommentStrindices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.CommentStrindices, ms.state)) + return pcommon.Int32Slice(internal.NewInt32SliceWrapper(&ms.orig.CommentStrindices, ms.state)) } // ProfileID returns the profileid associated with this Profile. @@ -111,7 +109,7 @@ func (ms Profile) ProfileID() ProfileID { // SetProfileID replaces the profileid associated with this Profile. func (ms Profile) SetProfileID(v ProfileID) { ms.state.AssertMutable() - ms.orig.ProfileId = data.ProfileID(v) + ms.orig.ProfileId = internal.ProfileID(v) } // DroppedAttributesCount returns the droppedattributescount associated with this Profile. @@ -138,16 +136,16 @@ func (ms Profile) SetOriginalPayloadFormat(v string) { // OriginalPayload returns the OriginalPayload associated with this Profile. func (ms Profile) OriginalPayload() pcommon.ByteSlice { - return pcommon.ByteSlice(internal.NewByteSlice(&ms.orig.OriginalPayload, ms.state)) + return pcommon.ByteSlice(internal.NewByteSliceWrapper(&ms.orig.OriginalPayload, ms.state)) } // AttributeIndices returns the AttributeIndices associated with this Profile. func (ms Profile) AttributeIndices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.AttributeIndices, ms.state)) + return pcommon.Int32Slice(internal.NewInt32SliceWrapper(&ms.orig.AttributeIndices, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Profile) CopyTo(dest Profile) { dest.state.AssertMutable() - internal.CopyOrigProfile(dest.orig, ms.orig) + internal.CopyProfile(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_profile_test.go b/pdata/pprofile/generated_profile_test.go index 67b7446542d..878a672e54f 100644 --- a/pdata/pprofile/generated_profile_test.go +++ b/pdata/pprofile/generated_profile_test.go @@ -12,8 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,8 +25,8 @@ func TestProfile_MoveTo(t *testing.T) { assert.Equal(t, generateTestProfile(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newProfile(internal.NewOrigProfile(), sharedState)) }) - assert.Panics(t, func() { newProfile(internal.NewOrigProfile(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newProfile(internal.NewProfile(), sharedState)) }) + assert.Panics(t, func() { newProfile(internal.NewProfile(), sharedState).MoveTo(dest) }) } func TestProfile_CopyTo(t *testing.T) { @@ -41,20 +39,20 @@ func TestProfile_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newProfile(internal.NewOrigProfile(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newProfile(internal.NewProfile(), sharedState)) }) } func TestProfile_SampleType(t *testing.T) { ms := NewProfile() assert.Equal(t, NewValueType(), ms.SampleType()) - ms.orig.SampleType = *internal.GenTestOrigValueType() + ms.orig.SampleType = *internal.GenTestValueType() assert.Equal(t, generateTestValueType(), ms.SampleType()) } func TestProfile_Sample(t *testing.T) { ms := NewProfile() assert.Equal(t, NewSampleSlice(), ms.Sample()) - ms.orig.Sample = internal.GenerateOrigTestSampleSlice() + ms.orig.Sample = internal.GenTestSamplePtrSlice() assert.Equal(t, generateTestSampleSlice(), ms.Sample()) } @@ -77,7 +75,7 @@ func TestProfile_Duration(t *testing.T) { func TestProfile_PeriodType(t *testing.T) { ms := NewProfile() assert.Equal(t, NewValueType(), ms.PeriodType()) - ms.orig.PeriodType = *internal.GenTestOrigValueType() + ms.orig.PeriodType = *internal.GenTestValueType() assert.Equal(t, generateTestValueType(), ms.PeriodType()) } @@ -88,20 +86,20 @@ func TestProfile_Period(t *testing.T) { assert.Equal(t, int64(13), ms.Period()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newProfile(&otlpprofiles.Profile{}, sharedState).SetPeriod(int64(13)) }) + assert.Panics(t, func() { newProfile(internal.NewProfile(), sharedState).SetPeriod(int64(13)) }) } func TestProfile_CommentStrindices(t *testing.T) { ms := NewProfile() assert.Equal(t, pcommon.NewInt32Slice(), ms.CommentStrindices()) - ms.orig.CommentStrindices = internal.GenerateOrigTestInt32Slice() - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.CommentStrindices()) + ms.orig.CommentStrindices = internal.GenTestInt32Slice() + assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.CommentStrindices()) } func TestProfile_ProfileID(t *testing.T) { ms := NewProfile() - assert.Equal(t, ProfileID(data.ProfileID([16]byte{})), ms.ProfileID()) - testValProfileID := ProfileID(data.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, ProfileID(internal.ProfileID([16]byte{})), ms.ProfileID()) + testValProfileID := ProfileID(internal.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) ms.SetProfileID(testValProfileID) assert.Equal(t, testValProfileID, ms.ProfileID()) } @@ -113,7 +111,7 @@ func TestProfile_DroppedAttributesCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newProfile(&otlpprofiles.Profile{}, sharedState).SetDroppedAttributesCount(uint32(13)) }) + assert.Panics(t, func() { newProfile(internal.NewProfile(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func TestProfile_OriginalPayloadFormat(t *testing.T) { @@ -124,25 +122,24 @@ func TestProfile_OriginalPayloadFormat(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newProfile(&otlpprofiles.Profile{}, sharedState).SetOriginalPayloadFormat("test_originalpayloadformat") + newProfile(internal.NewProfile(), sharedState).SetOriginalPayloadFormat("test_originalpayloadformat") }) } func TestProfile_OriginalPayload(t *testing.T) { ms := NewProfile() assert.Equal(t, pcommon.NewByteSlice(), ms.OriginalPayload()) - ms.orig.OriginalPayload = internal.GenerateOrigTestByteSlice() - assert.Equal(t, pcommon.ByteSlice(internal.GenerateTestByteSlice()), ms.OriginalPayload()) + ms.orig.OriginalPayload = internal.GenTestByteSlice() + assert.Equal(t, pcommon.ByteSlice(internal.GenTestByteSliceWrapper()), ms.OriginalPayload()) } func TestProfile_AttributeIndices(t *testing.T) { ms := NewProfile() assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices()) - ms.orig.AttributeIndices = internal.GenerateOrigTestInt32Slice() - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.AttributeIndices()) + ms.orig.AttributeIndices = internal.GenTestInt32Slice() + assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.AttributeIndices()) } func generateTestProfile() Profile { - ms := newProfile(internal.GenTestOrigProfile(), internal.NewState()) - return ms + return newProfile(internal.GenTestProfile(), internal.NewState()) } diff --git a/pdata/pprofile/generated_profiles.go b/pdata/pprofile/generated_profiles.go index bcf47932195..2dc85554293 100644 --- a/pdata/pprofile/generated_profiles.go +++ b/pdata/pprofile/generated_profiles.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" ) // Profiles is the top-level struct that is propagated through the profiles pipeline. @@ -19,10 +18,10 @@ import ( // // Must use NewProfiles function to create new instances. // Important: zero-initialized instance is not valid for use. -type Profiles internal.Profiles +type Profiles internal.ProfilesWrapper -func newProfiles(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, state *internal.State) Profiles { - return Profiles(internal.NewProfiles(orig, state)) +func newProfiles(orig *internal.ExportProfilesServiceRequest, state *internal.State) Profiles { + return Profiles(internal.NewProfilesWrapper(orig, state)) } // NewProfiles creates a new empty Profiles. @@ -30,7 +29,7 @@ func newProfiles(orig *otlpcollectorprofiles.ExportProfilesServiceRequest, state // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewProfiles() Profiles { - return newProfiles(internal.NewOrigExportProfilesServiceRequest(), internal.NewState()) + return newProfiles(internal.NewExportProfilesServiceRequest(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -42,7 +41,7 @@ func (ms Profiles) MoveTo(dest Profiles) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigExportProfilesServiceRequest(dest.getOrig(), false) + internal.DeleteExportProfilesServiceRequest(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } @@ -59,13 +58,13 @@ func (ms Profiles) Dictionary() ProfilesDictionary { // CopyTo copies all properties from the current struct overriding the destination. func (ms Profiles) CopyTo(dest Profiles) { dest.getState().AssertMutable() - internal.CopyOrigExportProfilesServiceRequest(dest.getOrig(), ms.getOrig()) + internal.CopyExportProfilesServiceRequest(dest.getOrig(), ms.getOrig()) } -func (ms Profiles) getOrig() *otlpcollectorprofiles.ExportProfilesServiceRequest { - return internal.GetOrigProfiles(internal.Profiles(ms)) +func (ms Profiles) getOrig() *internal.ExportProfilesServiceRequest { + return internal.GetProfilesOrig(internal.ProfilesWrapper(ms)) } func (ms Profiles) getState() *internal.State { - return internal.GetProfilesState(internal.Profiles(ms)) + return internal.GetProfilesState(internal.ProfilesWrapper(ms)) } diff --git a/pdata/pprofile/generated_profiles_test.go b/pdata/pprofile/generated_profiles_test.go index 96427303de0..18d42b18b0a 100644 --- a/pdata/pprofile/generated_profiles_test.go +++ b/pdata/pprofile/generated_profiles_test.go @@ -24,8 +24,8 @@ func TestProfiles_MoveTo(t *testing.T) { assert.Equal(t, generateTestProfiles(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newProfiles(internal.NewOrigExportProfilesServiceRequest(), sharedState)) }) - assert.Panics(t, func() { newProfiles(internal.NewOrigExportProfilesServiceRequest(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newProfiles(internal.NewExportProfilesServiceRequest(), sharedState)) }) + assert.Panics(t, func() { newProfiles(internal.NewExportProfilesServiceRequest(), sharedState).MoveTo(dest) }) } func TestProfiles_CopyTo(t *testing.T) { @@ -38,24 +38,23 @@ func TestProfiles_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newProfiles(internal.NewOrigExportProfilesServiceRequest(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newProfiles(internal.NewExportProfilesServiceRequest(), sharedState)) }) } func TestProfiles_ResourceProfiles(t *testing.T) { ms := NewProfiles() assert.Equal(t, NewResourceProfilesSlice(), ms.ResourceProfiles()) - ms.getOrig().ResourceProfiles = internal.GenerateOrigTestResourceProfilesSlice() + ms.getOrig().ResourceProfiles = internal.GenTestResourceProfilesPtrSlice() assert.Equal(t, generateTestResourceProfilesSlice(), ms.ResourceProfiles()) } func TestProfiles_Dictionary(t *testing.T) { ms := NewProfiles() assert.Equal(t, NewProfilesDictionary(), ms.Dictionary()) - ms.getOrig().Dictionary = *internal.GenTestOrigProfilesDictionary() + ms.getOrig().Dictionary = *internal.GenTestProfilesDictionary() assert.Equal(t, generateTestProfilesDictionary(), ms.Dictionary()) } func generateTestProfiles() Profiles { - ms := newProfiles(internal.GenTestOrigExportProfilesServiceRequest(), internal.NewState()) - return ms + return newProfiles(internal.GenTestExportProfilesServiceRequest(), internal.NewState()) } diff --git a/pdata/pprofile/generated_profilesdata.go b/pdata/pprofile/generated_profilesdata.go new file mode 100644 index 00000000000..dde7a05b6f4 --- /dev/null +++ b/pdata/pprofile/generated_profilesdata.go @@ -0,0 +1,71 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package pprofile + +import ( + "go.opentelemetry.io/collector/pdata/internal" +) + +// ProfilesData represents the profiles data that can be stored in persistent storage, +// OR can be embedded by other protocols that transfer OTLP profiles data but do not +// implement the OTLP protocol. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewProfilesData function to create new instances. +// Important: zero-initialized instance is not valid for use. +type ProfilesData internal.ProfilesDataWrapper + +func newProfilesData(orig *internal.ProfilesData, state *internal.State) ProfilesData { + return ProfilesData(internal.NewProfilesDataWrapper(orig, state)) +} + +// NewProfilesData creates a new empty ProfilesData. +// +// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, +// OR directly access the member if this is embedded in another struct. +func NewProfilesData() ProfilesData { + return newProfilesData(internal.NewProfilesData(), internal.NewState()) +} + +// MoveTo moves all properties from the current struct overriding the destination and +// resetting the current instance to its zero value +func (ms ProfilesData) MoveTo(dest ProfilesData) { + ms.getState().AssertMutable() + dest.getState().AssertMutable() + // If they point to the same data, they are the same, nothing to do. + if ms.getOrig() == dest.getOrig() { + return + } + internal.DeleteProfilesData(dest.getOrig(), false) + *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() +} + +// ResourceProfiles returns the ResourceProfiles associated with this ProfilesData. +func (ms ProfilesData) ResourceProfiles() ResourceProfilesSlice { + return newResourceProfilesSlice(&ms.getOrig().ResourceProfiles, ms.getState()) +} + +// Dictionary returns the dictionary associated with this ProfilesData. +func (ms ProfilesData) Dictionary() ProfilesDictionary { + return newProfilesDictionary(&ms.getOrig().Dictionary, ms.getState()) +} + +// CopyTo copies all properties from the current struct overriding the destination. +func (ms ProfilesData) CopyTo(dest ProfilesData) { + dest.getState().AssertMutable() + internal.CopyProfilesData(dest.getOrig(), ms.getOrig()) +} + +func (ms ProfilesData) getOrig() *internal.ProfilesData { + return internal.GetProfilesDataOrig(internal.ProfilesDataWrapper(ms)) +} + +func (ms ProfilesData) getState() *internal.State { + return internal.GetProfilesDataState(internal.ProfilesDataWrapper(ms)) +} diff --git a/pdata/pprofile/generated_profilesdata_test.go b/pdata/pprofile/generated_profilesdata_test.go new file mode 100644 index 00000000000..cc8f518b37a --- /dev/null +++ b/pdata/pprofile/generated_profilesdata_test.go @@ -0,0 +1,60 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "make genpdata". + +package pprofile + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/collector/pdata/internal" +) + +func TestProfilesData_MoveTo(t *testing.T) { + ms := generateTestProfilesData() + dest := NewProfilesData() + ms.MoveTo(dest) + assert.Equal(t, NewProfilesData(), ms) + assert.Equal(t, generateTestProfilesData(), dest) + dest.MoveTo(dest) + assert.Equal(t, generateTestProfilesData(), dest) + sharedState := internal.NewState() + sharedState.MarkReadOnly() + assert.Panics(t, func() { ms.MoveTo(newProfilesData(internal.NewProfilesData(), sharedState)) }) + assert.Panics(t, func() { newProfilesData(internal.NewProfilesData(), sharedState).MoveTo(dest) }) +} + +func TestProfilesData_CopyTo(t *testing.T) { + ms := NewProfilesData() + orig := NewProfilesData() + orig.CopyTo(ms) + assert.Equal(t, orig, ms) + orig = generateTestProfilesData() + orig.CopyTo(ms) + assert.Equal(t, orig, ms) + sharedState := internal.NewState() + sharedState.MarkReadOnly() + assert.Panics(t, func() { ms.CopyTo(newProfilesData(internal.NewProfilesData(), sharedState)) }) +} + +func TestProfilesData_ResourceProfiles(t *testing.T) { + ms := NewProfilesData() + assert.Equal(t, NewResourceProfilesSlice(), ms.ResourceProfiles()) + ms.getOrig().ResourceProfiles = internal.GenTestResourceProfilesPtrSlice() + assert.Equal(t, generateTestResourceProfilesSlice(), ms.ResourceProfiles()) +} + +func TestProfilesData_Dictionary(t *testing.T) { + ms := NewProfilesData() + assert.Equal(t, NewProfilesDictionary(), ms.Dictionary()) + ms.getOrig().Dictionary = *internal.GenTestProfilesDictionary() + assert.Equal(t, generateTestProfilesDictionary(), ms.Dictionary()) +} + +func generateTestProfilesData() ProfilesData { + return newProfilesData(internal.GenTestProfilesData(), internal.NewState()) +} diff --git a/pdata/pprofile/generated_profilesdictionary.go b/pdata/pprofile/generated_profilesdictionary.go index fe1f650f65c..673da6d84ef 100644 --- a/pdata/pprofile/generated_profilesdictionary.go +++ b/pdata/pprofile/generated_profilesdictionary.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewProfilesDictionary function to create new instances. // Important: zero-initialized instance is not valid for use. type ProfilesDictionary struct { - orig *otlpprofiles.ProfilesDictionary + orig *internal.ProfilesDictionary state *internal.State } -func newProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, state *internal.State) ProfilesDictionary { +func newProfilesDictionary(orig *internal.ProfilesDictionary, state *internal.State) ProfilesDictionary { return ProfilesDictionary{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newProfilesDictionary(orig *otlpprofiles.ProfilesDictionary, state *interna // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewProfilesDictionary() ProfilesDictionary { - return newProfilesDictionary(internal.NewOrigProfilesDictionary(), internal.NewState()) + return newProfilesDictionary(internal.NewProfilesDictionary(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms ProfilesDictionary) MoveTo(dest ProfilesDictionary) { if ms.orig == dest.orig { return } - internal.DeleteOrigProfilesDictionary(dest.orig, false) + internal.DeleteProfilesDictionary(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -71,7 +70,7 @@ func (ms ProfilesDictionary) LinkTable() LinkSlice { // StringTable returns the StringTable associated with this ProfilesDictionary. func (ms ProfilesDictionary) StringTable() pcommon.StringSlice { - return pcommon.StringSlice(internal.NewStringSlice(&ms.orig.StringTable, ms.state)) + return pcommon.StringSlice(internal.NewStringSliceWrapper(&ms.orig.StringTable, ms.state)) } // AttributeTable returns the AttributeTable associated with this ProfilesDictionary. @@ -87,5 +86,5 @@ func (ms ProfilesDictionary) StackTable() StackSlice { // CopyTo copies all properties from the current struct overriding the destination. func (ms ProfilesDictionary) CopyTo(dest ProfilesDictionary) { dest.state.AssertMutable() - internal.CopyOrigProfilesDictionary(dest.orig, ms.orig) + internal.CopyProfilesDictionary(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_profilesdictionary_test.go b/pdata/pprofile/generated_profilesdictionary_test.go index 2f414af449a..7971541a498 100644 --- a/pdata/pprofile/generated_profilesdictionary_test.go +++ b/pdata/pprofile/generated_profilesdictionary_test.go @@ -25,8 +25,8 @@ func TestProfilesDictionary_MoveTo(t *testing.T) { assert.Equal(t, generateTestProfilesDictionary(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newProfilesDictionary(internal.NewOrigProfilesDictionary(), sharedState)) }) - assert.Panics(t, func() { newProfilesDictionary(internal.NewOrigProfilesDictionary(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newProfilesDictionary(internal.NewProfilesDictionary(), sharedState)) }) + assert.Panics(t, func() { newProfilesDictionary(internal.NewProfilesDictionary(), sharedState).MoveTo(dest) }) } func TestProfilesDictionary_CopyTo(t *testing.T) { @@ -39,59 +39,58 @@ func TestProfilesDictionary_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newProfilesDictionary(internal.NewOrigProfilesDictionary(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newProfilesDictionary(internal.NewProfilesDictionary(), sharedState)) }) } func TestProfilesDictionary_MappingTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, NewMappingSlice(), ms.MappingTable()) - ms.orig.MappingTable = internal.GenerateOrigTestMappingSlice() + ms.orig.MappingTable = internal.GenTestMappingPtrSlice() assert.Equal(t, generateTestMappingSlice(), ms.MappingTable()) } func TestProfilesDictionary_LocationTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, NewLocationSlice(), ms.LocationTable()) - ms.orig.LocationTable = internal.GenerateOrigTestLocationSlice() + ms.orig.LocationTable = internal.GenTestLocationPtrSlice() assert.Equal(t, generateTestLocationSlice(), ms.LocationTable()) } func TestProfilesDictionary_FunctionTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, NewFunctionSlice(), ms.FunctionTable()) - ms.orig.FunctionTable = internal.GenerateOrigTestFunctionSlice() + ms.orig.FunctionTable = internal.GenTestFunctionPtrSlice() assert.Equal(t, generateTestFunctionSlice(), ms.FunctionTable()) } func TestProfilesDictionary_LinkTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, NewLinkSlice(), ms.LinkTable()) - ms.orig.LinkTable = internal.GenerateOrigTestLinkSlice() + ms.orig.LinkTable = internal.GenTestLinkPtrSlice() assert.Equal(t, generateTestLinkSlice(), ms.LinkTable()) } func TestProfilesDictionary_StringTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, pcommon.NewStringSlice(), ms.StringTable()) - ms.orig.StringTable = internal.GenerateOrigTestStringSlice() - assert.Equal(t, pcommon.StringSlice(internal.GenerateTestStringSlice()), ms.StringTable()) + ms.orig.StringTable = internal.GenTestStringSlice() + assert.Equal(t, pcommon.StringSlice(internal.GenTestStringSliceWrapper()), ms.StringTable()) } func TestProfilesDictionary_AttributeTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, NewKeyValueAndUnitSlice(), ms.AttributeTable()) - ms.orig.AttributeTable = internal.GenerateOrigTestKeyValueAndUnitSlice() + ms.orig.AttributeTable = internal.GenTestKeyValueAndUnitPtrSlice() assert.Equal(t, generateTestKeyValueAndUnitSlice(), ms.AttributeTable()) } func TestProfilesDictionary_StackTable(t *testing.T) { ms := NewProfilesDictionary() assert.Equal(t, NewStackSlice(), ms.StackTable()) - ms.orig.StackTable = internal.GenerateOrigTestStackSlice() + ms.orig.StackTable = internal.GenTestStackPtrSlice() assert.Equal(t, generateTestStackSlice(), ms.StackTable()) } func generateTestProfilesDictionary() ProfilesDictionary { - ms := newProfilesDictionary(internal.GenTestOrigProfilesDictionary(), internal.NewState()) - return ms + return newProfilesDictionary(internal.GenTestProfilesDictionary(), internal.NewState()) } diff --git a/pdata/pprofile/generated_profilesslice.go b/pdata/pprofile/generated_profilesslice.go index f1af93b8a7c..a09a5289e59 100644 --- a/pdata/pprofile/generated_profilesslice.go +++ b/pdata/pprofile/generated_profilesslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // ProfilesSlice logically represents a slice of Profile. @@ -22,18 +21,18 @@ import ( // Must use NewProfilesSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ProfilesSlice struct { - orig *[]*otlpprofiles.Profile + orig *[]*internal.Profile state *internal.State } -func newProfilesSlice(orig *[]*otlpprofiles.Profile, state *internal.State) ProfilesSlice { +func newProfilesSlice(orig *[]*internal.Profile, state *internal.State) ProfilesSlice { return ProfilesSlice{orig: orig, state: state} } // NewProfilesSlice creates a ProfilesSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewProfilesSlice() ProfilesSlice { - orig := []*otlpprofiles.Profile(nil) + orig := []*internal.Profile(nil) return newProfilesSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ProfilesSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Profile, len(*es.orig), newCap) + newOrig := make([]*internal.Profile, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ProfilesSlice) EnsureCapacity(newCap int) { // It returns the newly added Profile. func (es ProfilesSlice) AppendEmpty() Profile { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigProfile()) + *es.orig = append(*es.orig, internal.NewProfile()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ProfilesSlice) RemoveIf(f func(Profile) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigProfile((*es.orig)[i], true) + internal.DeleteProfile((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ProfilesSlice) CopyTo(dest ProfilesSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigProfileSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyProfilePtrSlice(*dest.orig, *es.orig) } // Sort sorts the Profile elements within ProfilesSlice given the diff --git a/pdata/pprofile/generated_profilesslice_test.go b/pdata/pprofile/generated_profilesslice_test.go index f3af10257cb..a79472ff23a 100644 --- a/pdata/pprofile/generated_profilesslice_test.go +++ b/pdata/pprofile/generated_profilesslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestProfilesSlice(t *testing.T) { es := NewProfilesSlice() assert.Equal(t, 0, es.Len()) - es = newProfilesSlice(&[]*otlpprofiles.Profile{}, internal.NewState()) + es = newProfilesSlice(&[]*internal.Profile{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewProfile() @@ -27,7 +26,7 @@ func TestProfilesSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigProfile() + (*es.orig)[i] = internal.GenTestProfile() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestProfilesSlice(t *testing.T) { func TestProfilesSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newProfilesSlice(&[]*otlpprofiles.Profile{}, sharedState) + es := newProfilesSlice(&[]*internal.Profile{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestProfilesSlice_Sort(t *testing.T) { func generateTestProfilesSlice() ProfilesSlice { ms := NewProfilesSlice() - *ms.orig = internal.GenerateOrigTestProfileSlice() + *ms.orig = internal.GenTestProfilePtrSlice() return ms } diff --git a/pdata/pprofile/generated_resourceprofiles.go b/pdata/pprofile/generated_resourceprofiles.go index 8762dfd00a7..cee70803fa6 100644 --- a/pdata/pprofile/generated_resourceprofiles.go +++ b/pdata/pprofile/generated_resourceprofiles.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewResourceProfiles function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceProfiles struct { - orig *otlpprofiles.ResourceProfiles + orig *internal.ResourceProfiles state *internal.State } -func newResourceProfiles(orig *otlpprofiles.ResourceProfiles, state *internal.State) ResourceProfiles { +func newResourceProfiles(orig *internal.ResourceProfiles, state *internal.State) ResourceProfiles { return ResourceProfiles{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newResourceProfiles(orig *otlpprofiles.ResourceProfiles, state *internal.St // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewResourceProfiles() ResourceProfiles { - return newResourceProfiles(internal.NewOrigResourceProfiles(), internal.NewState()) + return newResourceProfiles(internal.NewResourceProfiles(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ResourceProfiles) MoveTo(dest ResourceProfiles) { if ms.orig == dest.orig { return } - internal.DeleteOrigResourceProfiles(dest.orig, false) + internal.DeleteResourceProfiles(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Resource returns the resource associated with this ResourceProfiles. func (ms ResourceProfiles) Resource() pcommon.Resource { - return pcommon.Resource(internal.NewResource(&ms.orig.Resource, ms.state)) + return pcommon.Resource(internal.NewResourceWrapper(&ms.orig.Resource, ms.state)) } // ScopeProfiles returns the ScopeProfiles associated with this ResourceProfiles. @@ -73,5 +72,5 @@ func (ms ResourceProfiles) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ResourceProfiles) CopyTo(dest ResourceProfiles) { dest.state.AssertMutable() - internal.CopyOrigResourceProfiles(dest.orig, ms.orig) + internal.CopyResourceProfiles(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_resourceprofiles_test.go b/pdata/pprofile/generated_resourceprofiles_test.go index 989219e26d2..4ef50f754e8 100644 --- a/pdata/pprofile/generated_resourceprofiles_test.go +++ b/pdata/pprofile/generated_resourceprofiles_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestResourceProfiles_MoveTo(t *testing.T) { assert.Equal(t, generateTestResourceProfiles(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newResourceProfiles(internal.NewOrigResourceProfiles(), sharedState)) }) - assert.Panics(t, func() { newResourceProfiles(internal.NewOrigResourceProfiles(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newResourceProfiles(internal.NewResourceProfiles(), sharedState)) }) + assert.Panics(t, func() { newResourceProfiles(internal.NewResourceProfiles(), sharedState).MoveTo(dest) }) } func TestResourceProfiles_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestResourceProfiles_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newResourceProfiles(internal.NewOrigResourceProfiles(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newResourceProfiles(internal.NewResourceProfiles(), sharedState)) }) } func TestResourceProfiles_Resource(t *testing.T) { ms := NewResourceProfiles() assert.Equal(t, pcommon.NewResource(), ms.Resource()) - ms.orig.Resource = *internal.GenTestOrigResource() - assert.Equal(t, pcommon.Resource(internal.NewResource(internal.GenTestOrigResource(), ms.state)), ms.Resource()) + ms.orig.Resource = *internal.GenTestResource() + assert.Equal(t, pcommon.Resource(internal.GenTestResourceWrapper()), ms.Resource()) } func TestResourceProfiles_ScopeProfiles(t *testing.T) { ms := NewResourceProfiles() assert.Equal(t, NewScopeProfilesSlice(), ms.ScopeProfiles()) - ms.orig.ScopeProfiles = internal.GenerateOrigTestScopeProfilesSlice() + ms.orig.ScopeProfiles = internal.GenTestScopeProfilesPtrSlice() assert.Equal(t, generateTestScopeProfilesSlice(), ms.ScopeProfiles()) } @@ -65,11 +64,10 @@ func TestResourceProfiles_SchemaUrl(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newResourceProfiles(&otlpprofiles.ResourceProfiles{}, sharedState).SetSchemaUrl("test_schemaurl") + newResourceProfiles(internal.NewResourceProfiles(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestResourceProfiles() ResourceProfiles { - ms := newResourceProfiles(internal.GenTestOrigResourceProfiles(), internal.NewState()) - return ms + return newResourceProfiles(internal.GenTestResourceProfiles(), internal.NewState()) } diff --git a/pdata/pprofile/generated_resourceprofilesslice.go b/pdata/pprofile/generated_resourceprofilesslice.go index ee8f8236062..fcaa25d69e7 100644 --- a/pdata/pprofile/generated_resourceprofilesslice.go +++ b/pdata/pprofile/generated_resourceprofilesslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // ResourceProfilesSlice logically represents a slice of ResourceProfiles. @@ -22,18 +21,18 @@ import ( // Must use NewResourceProfilesSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceProfilesSlice struct { - orig *[]*otlpprofiles.ResourceProfiles + orig *[]*internal.ResourceProfiles state *internal.State } -func newResourceProfilesSlice(orig *[]*otlpprofiles.ResourceProfiles, state *internal.State) ResourceProfilesSlice { +func newResourceProfilesSlice(orig *[]*internal.ResourceProfiles, state *internal.State) ResourceProfilesSlice { return ResourceProfilesSlice{orig: orig, state: state} } // NewResourceProfilesSlice creates a ResourceProfilesSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewResourceProfilesSlice() ResourceProfilesSlice { - orig := []*otlpprofiles.ResourceProfiles(nil) + orig := []*internal.ResourceProfiles(nil) return newResourceProfilesSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ResourceProfilesSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.ResourceProfiles, len(*es.orig), newCap) + newOrig := make([]*internal.ResourceProfiles, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ResourceProfilesSlice) EnsureCapacity(newCap int) { // It returns the newly added ResourceProfiles. func (es ResourceProfilesSlice) AppendEmpty() ResourceProfiles { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigResourceProfiles()) + *es.orig = append(*es.orig, internal.NewResourceProfiles()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ResourceProfilesSlice) RemoveIf(f func(ResourceProfiles) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigResourceProfiles((*es.orig)[i], true) + internal.DeleteResourceProfiles((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ResourceProfilesSlice) CopyTo(dest ResourceProfilesSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigResourceProfilesSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyResourceProfilesPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ResourceProfiles elements within ResourceProfilesSlice given the diff --git a/pdata/pprofile/generated_resourceprofilesslice_test.go b/pdata/pprofile/generated_resourceprofilesslice_test.go index cdf54bfcc1f..7108d494de5 100644 --- a/pdata/pprofile/generated_resourceprofilesslice_test.go +++ b/pdata/pprofile/generated_resourceprofilesslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestResourceProfilesSlice(t *testing.T) { es := NewResourceProfilesSlice() assert.Equal(t, 0, es.Len()) - es = newResourceProfilesSlice(&[]*otlpprofiles.ResourceProfiles{}, internal.NewState()) + es = newResourceProfilesSlice(&[]*internal.ResourceProfiles{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewResourceProfiles() @@ -27,7 +26,7 @@ func TestResourceProfilesSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigResourceProfiles() + (*es.orig)[i] = internal.GenTestResourceProfiles() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestResourceProfilesSlice(t *testing.T) { func TestResourceProfilesSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newResourceProfilesSlice(&[]*otlpprofiles.ResourceProfiles{}, sharedState) + es := newResourceProfilesSlice(&[]*internal.ResourceProfiles{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestResourceProfilesSlice_Sort(t *testing.T) { func generateTestResourceProfilesSlice() ResourceProfilesSlice { ms := NewResourceProfilesSlice() - *ms.orig = internal.GenerateOrigTestResourceProfilesSlice() + *ms.orig = internal.GenTestResourceProfilesPtrSlice() return ms } diff --git a/pdata/pprofile/generated_sample.go b/pdata/pprofile/generated_sample.go index 36ec3f773b0..c50d09d7f4d 100644 --- a/pdata/pprofile/generated_sample.go +++ b/pdata/pprofile/generated_sample.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewSample function to create new instances. // Important: zero-initialized instance is not valid for use. type Sample struct { - orig *otlpprofiles.Sample + orig *internal.Sample state *internal.State } -func newSample(orig *otlpprofiles.Sample, state *internal.State) Sample { +func newSample(orig *internal.Sample, state *internal.State) Sample { return Sample{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newSample(orig *otlpprofiles.Sample, state *internal.State) Sample { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSample() Sample { - return newSample(internal.NewOrigSample(), internal.NewState()) + return newSample(internal.NewSample(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms Sample) MoveTo(dest Sample) { if ms.orig == dest.orig { return } - internal.DeleteOrigSample(dest.orig, false) + internal.DeleteSample(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -62,12 +61,12 @@ func (ms Sample) SetStackIndex(v int32) { // Values returns the Values associated with this Sample. func (ms Sample) Values() pcommon.Int64Slice { - return pcommon.Int64Slice(internal.NewInt64Slice(&ms.orig.Values, ms.state)) + return pcommon.Int64Slice(internal.NewInt64SliceWrapper(&ms.orig.Values, ms.state)) } // AttributeIndices returns the AttributeIndices associated with this Sample. func (ms Sample) AttributeIndices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.AttributeIndices, ms.state)) + return pcommon.Int32Slice(internal.NewInt32SliceWrapper(&ms.orig.AttributeIndices, ms.state)) } // LinkIndex returns the linkindex associated with this Sample. @@ -83,11 +82,11 @@ func (ms Sample) SetLinkIndex(v int32) { // TimestampsUnixNano returns the TimestampsUnixNano associated with this Sample. func (ms Sample) TimestampsUnixNano() pcommon.UInt64Slice { - return pcommon.UInt64Slice(internal.NewUInt64Slice(&ms.orig.TimestampsUnixNano, ms.state)) + return pcommon.UInt64Slice(internal.NewUInt64SliceWrapper(&ms.orig.TimestampsUnixNano, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Sample) CopyTo(dest Sample) { dest.state.AssertMutable() - internal.CopyOrigSample(dest.orig, ms.orig) + internal.CopySample(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_sample_test.go b/pdata/pprofile/generated_sample_test.go index fc95befe70d..6be62676ba4 100644 --- a/pdata/pprofile/generated_sample_test.go +++ b/pdata/pprofile/generated_sample_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestSample_MoveTo(t *testing.T) { assert.Equal(t, generateTestSample(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSample(internal.NewOrigSample(), sharedState)) }) - assert.Panics(t, func() { newSample(internal.NewOrigSample(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSample(internal.NewSample(), sharedState)) }) + assert.Panics(t, func() { newSample(internal.NewSample(), sharedState).MoveTo(dest) }) } func TestSample_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestSample_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSample(internal.NewOrigSample(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSample(internal.NewSample(), sharedState)) }) } func TestSample_StackIndex(t *testing.T) { @@ -50,21 +49,21 @@ func TestSample_StackIndex(t *testing.T) { assert.Equal(t, int32(13), ms.StackIndex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSample(&otlpprofiles.Sample{}, sharedState).SetStackIndex(int32(13)) }) + assert.Panics(t, func() { newSample(internal.NewSample(), sharedState).SetStackIndex(int32(13)) }) } func TestSample_Values(t *testing.T) { ms := NewSample() assert.Equal(t, pcommon.NewInt64Slice(), ms.Values()) - ms.orig.Values = internal.GenerateOrigTestInt64Slice() - assert.Equal(t, pcommon.Int64Slice(internal.GenerateTestInt64Slice()), ms.Values()) + ms.orig.Values = internal.GenTestInt64Slice() + assert.Equal(t, pcommon.Int64Slice(internal.GenTestInt64SliceWrapper()), ms.Values()) } func TestSample_AttributeIndices(t *testing.T) { ms := NewSample() assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices()) - ms.orig.AttributeIndices = internal.GenerateOrigTestInt32Slice() - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.AttributeIndices()) + ms.orig.AttributeIndices = internal.GenTestInt32Slice() + assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.AttributeIndices()) } func TestSample_LinkIndex(t *testing.T) { @@ -74,17 +73,16 @@ func TestSample_LinkIndex(t *testing.T) { assert.Equal(t, int32(13), ms.LinkIndex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSample(&otlpprofiles.Sample{}, sharedState).SetLinkIndex(int32(13)) }) + assert.Panics(t, func() { newSample(internal.NewSample(), sharedState).SetLinkIndex(int32(13)) }) } func TestSample_TimestampsUnixNano(t *testing.T) { ms := NewSample() assert.Equal(t, pcommon.NewUInt64Slice(), ms.TimestampsUnixNano()) - ms.orig.TimestampsUnixNano = internal.GenerateOrigTestUint64Slice() - assert.Equal(t, pcommon.UInt64Slice(internal.GenerateTestUInt64Slice()), ms.TimestampsUnixNano()) + ms.orig.TimestampsUnixNano = internal.GenTestUint64Slice() + assert.Equal(t, pcommon.UInt64Slice(internal.GenTestUInt64SliceWrapper()), ms.TimestampsUnixNano()) } func generateTestSample() Sample { - ms := newSample(internal.GenTestOrigSample(), internal.NewState()) - return ms + return newSample(internal.GenTestSample(), internal.NewState()) } diff --git a/pdata/pprofile/generated_sampleslice.go b/pdata/pprofile/generated_sampleslice.go index e645899dbbf..399468f0aa1 100644 --- a/pdata/pprofile/generated_sampleslice.go +++ b/pdata/pprofile/generated_sampleslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // SampleSlice logically represents a slice of Sample. @@ -22,18 +21,18 @@ import ( // Must use NewSampleSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SampleSlice struct { - orig *[]*otlpprofiles.Sample + orig *[]*internal.Sample state *internal.State } -func newSampleSlice(orig *[]*otlpprofiles.Sample, state *internal.State) SampleSlice { +func newSampleSlice(orig *[]*internal.Sample, state *internal.State) SampleSlice { return SampleSlice{orig: orig, state: state} } // NewSampleSlice creates a SampleSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSampleSlice() SampleSlice { - orig := []*otlpprofiles.Sample(nil) + orig := []*internal.Sample(nil) return newSampleSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es SampleSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Sample, len(*es.orig), newCap) + newOrig := make([]*internal.Sample, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es SampleSlice) EnsureCapacity(newCap int) { // It returns the newly added Sample. func (es SampleSlice) AppendEmpty() Sample { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigSample()) + *es.orig = append(*es.orig, internal.NewSample()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es SampleSlice) RemoveIf(f func(Sample) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigSample((*es.orig)[i], true) + internal.DeleteSample((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es SampleSlice) CopyTo(dest SampleSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigSampleSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopySamplePtrSlice(*dest.orig, *es.orig) } // Sort sorts the Sample elements within SampleSlice given the diff --git a/pdata/pprofile/generated_sampleslice_test.go b/pdata/pprofile/generated_sampleslice_test.go index eb31ec0f64d..80d3bd902aa 100644 --- a/pdata/pprofile/generated_sampleslice_test.go +++ b/pdata/pprofile/generated_sampleslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestSampleSlice(t *testing.T) { es := NewSampleSlice() assert.Equal(t, 0, es.Len()) - es = newSampleSlice(&[]*otlpprofiles.Sample{}, internal.NewState()) + es = newSampleSlice(&[]*internal.Sample{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewSample() @@ -27,7 +26,7 @@ func TestSampleSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigSample() + (*es.orig)[i] = internal.GenTestSample() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestSampleSlice(t *testing.T) { func TestSampleSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSampleSlice(&[]*otlpprofiles.Sample{}, sharedState) + es := newSampleSlice(&[]*internal.Sample{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestSampleSlice_Sort(t *testing.T) { func generateTestSampleSlice() SampleSlice { ms := NewSampleSlice() - *ms.orig = internal.GenerateOrigTestSampleSlice() + *ms.orig = internal.GenTestSamplePtrSlice() return ms } diff --git a/pdata/pprofile/generated_scopeprofiles.go b/pdata/pprofile/generated_scopeprofiles.go index d51491d2582..01456ceccf4 100644 --- a/pdata/pprofile/generated_scopeprofiles.go +++ b/pdata/pprofile/generated_scopeprofiles.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewScopeProfiles function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeProfiles struct { - orig *otlpprofiles.ScopeProfiles + orig *internal.ScopeProfiles state *internal.State } -func newScopeProfiles(orig *otlpprofiles.ScopeProfiles, state *internal.State) ScopeProfiles { +func newScopeProfiles(orig *internal.ScopeProfiles, state *internal.State) ScopeProfiles { return ScopeProfiles{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newScopeProfiles(orig *otlpprofiles.ScopeProfiles, state *internal.State) S // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewScopeProfiles() ScopeProfiles { - return newScopeProfiles(internal.NewOrigScopeProfiles(), internal.NewState()) + return newScopeProfiles(internal.NewScopeProfiles(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ScopeProfiles) MoveTo(dest ScopeProfiles) { if ms.orig == dest.orig { return } - internal.DeleteOrigScopeProfiles(dest.orig, false) + internal.DeleteScopeProfiles(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Scope returns the scope associated with this ScopeProfiles. func (ms ScopeProfiles) Scope() pcommon.InstrumentationScope { - return pcommon.InstrumentationScope(internal.NewInstrumentationScope(&ms.orig.Scope, ms.state)) + return pcommon.InstrumentationScope(internal.NewInstrumentationScopeWrapper(&ms.orig.Scope, ms.state)) } // Profiles returns the Profiles associated with this ScopeProfiles. @@ -73,5 +72,5 @@ func (ms ScopeProfiles) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ScopeProfiles) CopyTo(dest ScopeProfiles) { dest.state.AssertMutable() - internal.CopyOrigScopeProfiles(dest.orig, ms.orig) + internal.CopyScopeProfiles(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_scopeprofiles_test.go b/pdata/pprofile/generated_scopeprofiles_test.go index 42b0a8d964c..0fecd9f58a9 100644 --- a/pdata/pprofile/generated_scopeprofiles_test.go +++ b/pdata/pprofile/generated_scopeprofiles_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestScopeProfiles_MoveTo(t *testing.T) { assert.Equal(t, generateTestScopeProfiles(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newScopeProfiles(internal.NewOrigScopeProfiles(), sharedState)) }) - assert.Panics(t, func() { newScopeProfiles(internal.NewOrigScopeProfiles(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newScopeProfiles(internal.NewScopeProfiles(), sharedState)) }) + assert.Panics(t, func() { newScopeProfiles(internal.NewScopeProfiles(), sharedState).MoveTo(dest) }) } func TestScopeProfiles_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestScopeProfiles_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newScopeProfiles(internal.NewOrigScopeProfiles(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newScopeProfiles(internal.NewScopeProfiles(), sharedState)) }) } func TestScopeProfiles_Scope(t *testing.T) { ms := NewScopeProfiles() assert.Equal(t, pcommon.NewInstrumentationScope(), ms.Scope()) - ms.orig.Scope = *internal.GenTestOrigInstrumentationScope() - assert.Equal(t, pcommon.InstrumentationScope(internal.NewInstrumentationScope(internal.GenTestOrigInstrumentationScope(), ms.state)), ms.Scope()) + ms.orig.Scope = *internal.GenTestInstrumentationScope() + assert.Equal(t, pcommon.InstrumentationScope(internal.GenTestInstrumentationScopeWrapper()), ms.Scope()) } func TestScopeProfiles_Profiles(t *testing.T) { ms := NewScopeProfiles() assert.Equal(t, NewProfilesSlice(), ms.Profiles()) - ms.orig.Profiles = internal.GenerateOrigTestProfileSlice() + ms.orig.Profiles = internal.GenTestProfilePtrSlice() assert.Equal(t, generateTestProfilesSlice(), ms.Profiles()) } @@ -64,10 +63,9 @@ func TestScopeProfiles_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newScopeProfiles(&otlpprofiles.ScopeProfiles{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newScopeProfiles(internal.NewScopeProfiles(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestScopeProfiles() ScopeProfiles { - ms := newScopeProfiles(internal.GenTestOrigScopeProfiles(), internal.NewState()) - return ms + return newScopeProfiles(internal.GenTestScopeProfiles(), internal.NewState()) } diff --git a/pdata/pprofile/generated_scopeprofilesslice.go b/pdata/pprofile/generated_scopeprofilesslice.go index c14c8993874..5fbbc4b5f25 100644 --- a/pdata/pprofile/generated_scopeprofilesslice.go +++ b/pdata/pprofile/generated_scopeprofilesslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // ScopeProfilesSlice logically represents a slice of ScopeProfiles. @@ -22,18 +21,18 @@ import ( // Must use NewScopeProfilesSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeProfilesSlice struct { - orig *[]*otlpprofiles.ScopeProfiles + orig *[]*internal.ScopeProfiles state *internal.State } -func newScopeProfilesSlice(orig *[]*otlpprofiles.ScopeProfiles, state *internal.State) ScopeProfilesSlice { +func newScopeProfilesSlice(orig *[]*internal.ScopeProfiles, state *internal.State) ScopeProfilesSlice { return ScopeProfilesSlice{orig: orig, state: state} } // NewScopeProfilesSlice creates a ScopeProfilesSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewScopeProfilesSlice() ScopeProfilesSlice { - orig := []*otlpprofiles.ScopeProfiles(nil) + orig := []*internal.ScopeProfiles(nil) return newScopeProfilesSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ScopeProfilesSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.ScopeProfiles, len(*es.orig), newCap) + newOrig := make([]*internal.ScopeProfiles, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ScopeProfilesSlice) EnsureCapacity(newCap int) { // It returns the newly added ScopeProfiles. func (es ScopeProfilesSlice) AppendEmpty() ScopeProfiles { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigScopeProfiles()) + *es.orig = append(*es.orig, internal.NewScopeProfiles()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ScopeProfilesSlice) RemoveIf(f func(ScopeProfiles) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigScopeProfiles((*es.orig)[i], true) + internal.DeleteScopeProfiles((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ScopeProfilesSlice) CopyTo(dest ScopeProfilesSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigScopeProfilesSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyScopeProfilesPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ScopeProfiles elements within ScopeProfilesSlice given the diff --git a/pdata/pprofile/generated_scopeprofilesslice_test.go b/pdata/pprofile/generated_scopeprofilesslice_test.go index de804535df3..bfcdc68545a 100644 --- a/pdata/pprofile/generated_scopeprofilesslice_test.go +++ b/pdata/pprofile/generated_scopeprofilesslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestScopeProfilesSlice(t *testing.T) { es := NewScopeProfilesSlice() assert.Equal(t, 0, es.Len()) - es = newScopeProfilesSlice(&[]*otlpprofiles.ScopeProfiles{}, internal.NewState()) + es = newScopeProfilesSlice(&[]*internal.ScopeProfiles{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewScopeProfiles() @@ -27,7 +26,7 @@ func TestScopeProfilesSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigScopeProfiles() + (*es.orig)[i] = internal.GenTestScopeProfiles() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestScopeProfilesSlice(t *testing.T) { func TestScopeProfilesSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newScopeProfilesSlice(&[]*otlpprofiles.ScopeProfiles{}, sharedState) + es := newScopeProfilesSlice(&[]*internal.ScopeProfiles{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestScopeProfilesSlice_Sort(t *testing.T) { func generateTestScopeProfilesSlice() ScopeProfilesSlice { ms := NewScopeProfilesSlice() - *ms.orig = internal.GenerateOrigTestScopeProfilesSlice() + *ms.orig = internal.GenTestScopeProfilesPtrSlice() return ms } diff --git a/pdata/pprofile/generated_stack.go b/pdata/pprofile/generated_stack.go index 025571b1282..53e4352c54f 100644 --- a/pdata/pprofile/generated_stack.go +++ b/pdata/pprofile/generated_stack.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewStack function to create new instances. // Important: zero-initialized instance is not valid for use. type Stack struct { - orig *otlpprofiles.Stack + orig *internal.Stack state *internal.State } -func newStack(orig *otlpprofiles.Stack, state *internal.State) Stack { +func newStack(orig *internal.Stack, state *internal.State) Stack { return Stack{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newStack(orig *otlpprofiles.Stack, state *internal.State) Stack { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewStack() Stack { - return newStack(internal.NewOrigStack(), internal.NewState()) + return newStack(internal.NewStack(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,17 +44,17 @@ func (ms Stack) MoveTo(dest Stack) { if ms.orig == dest.orig { return } - internal.DeleteOrigStack(dest.orig, false) + internal.DeleteStack(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // LocationIndices returns the LocationIndices associated with this Stack. func (ms Stack) LocationIndices() pcommon.Int32Slice { - return pcommon.Int32Slice(internal.NewInt32Slice(&ms.orig.LocationIndices, ms.state)) + return pcommon.Int32Slice(internal.NewInt32SliceWrapper(&ms.orig.LocationIndices, ms.state)) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Stack) CopyTo(dest Stack) { dest.state.AssertMutable() - internal.CopyOrigStack(dest.orig, ms.orig) + internal.CopyStack(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_stack_test.go b/pdata/pprofile/generated_stack_test.go index b47dc8f56b1..986d9e9788a 100644 --- a/pdata/pprofile/generated_stack_test.go +++ b/pdata/pprofile/generated_stack_test.go @@ -25,8 +25,8 @@ func TestStack_MoveTo(t *testing.T) { assert.Equal(t, generateTestStack(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newStack(internal.NewOrigStack(), sharedState)) }) - assert.Panics(t, func() { newStack(internal.NewOrigStack(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newStack(internal.NewStack(), sharedState)) }) + assert.Panics(t, func() { newStack(internal.NewStack(), sharedState).MoveTo(dest) }) } func TestStack_CopyTo(t *testing.T) { @@ -39,17 +39,16 @@ func TestStack_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newStack(internal.NewOrigStack(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newStack(internal.NewStack(), sharedState)) }) } func TestStack_LocationIndices(t *testing.T) { ms := NewStack() assert.Equal(t, pcommon.NewInt32Slice(), ms.LocationIndices()) - ms.orig.LocationIndices = internal.GenerateOrigTestInt32Slice() - assert.Equal(t, pcommon.Int32Slice(internal.GenerateTestInt32Slice()), ms.LocationIndices()) + ms.orig.LocationIndices = internal.GenTestInt32Slice() + assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.LocationIndices()) } func generateTestStack() Stack { - ms := newStack(internal.GenTestOrigStack(), internal.NewState()) - return ms + return newStack(internal.GenTestStack(), internal.NewState()) } diff --git a/pdata/pprofile/generated_stackslice.go b/pdata/pprofile/generated_stackslice.go index 41ecf5b7125..a33dcbec5c9 100644 --- a/pdata/pprofile/generated_stackslice.go +++ b/pdata/pprofile/generated_stackslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // StackSlice logically represents a slice of Stack. @@ -22,18 +21,18 @@ import ( // Must use NewStackSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type StackSlice struct { - orig *[]*otlpprofiles.Stack + orig *[]*internal.Stack state *internal.State } -func newStackSlice(orig *[]*otlpprofiles.Stack, state *internal.State) StackSlice { +func newStackSlice(orig *[]*internal.Stack, state *internal.State) StackSlice { return StackSlice{orig: orig, state: state} } // NewStackSlice creates a StackSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewStackSlice() StackSlice { - orig := []*otlpprofiles.Stack(nil) + orig := []*internal.Stack(nil) return newStackSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es StackSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.Stack, len(*es.orig), newCap) + newOrig := make([]*internal.Stack, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es StackSlice) EnsureCapacity(newCap int) { // It returns the newly added Stack. func (es StackSlice) AppendEmpty() Stack { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigStack()) + *es.orig = append(*es.orig, internal.NewStack()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es StackSlice) RemoveIf(f func(Stack) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigStack((*es.orig)[i], true) + internal.DeleteStack((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es StackSlice) CopyTo(dest StackSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigStackSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyStackPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Stack elements within StackSlice given the diff --git a/pdata/pprofile/generated_stackslice_test.go b/pdata/pprofile/generated_stackslice_test.go index e196472206d..7d5171a0862 100644 --- a/pdata/pprofile/generated_stackslice_test.go +++ b/pdata/pprofile/generated_stackslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestStackSlice(t *testing.T) { es := NewStackSlice() assert.Equal(t, 0, es.Len()) - es = newStackSlice(&[]*otlpprofiles.Stack{}, internal.NewState()) + es = newStackSlice(&[]*internal.Stack{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewStack() @@ -27,7 +26,7 @@ func TestStackSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigStack() + (*es.orig)[i] = internal.GenTestStack() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestStackSlice(t *testing.T) { func TestStackSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newStackSlice(&[]*otlpprofiles.Stack{}, sharedState) + es := newStackSlice(&[]*internal.Stack{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestStackSlice_Sort(t *testing.T) { func generateTestStackSlice() StackSlice { ms := NewStackSlice() - *ms.orig = internal.GenerateOrigTestStackSlice() + *ms.orig = internal.GenTestStackPtrSlice() return ms } diff --git a/pdata/pprofile/generated_valuetype.go b/pdata/pprofile/generated_valuetype.go index 54be666b0c9..8b05aa2fed9 100644 --- a/pdata/pprofile/generated_valuetype.go +++ b/pdata/pprofile/generated_valuetype.go @@ -8,7 +8,6 @@ package pprofile import ( "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // ValueType describes the type and units of a value, with an optional aggregation temporality. @@ -19,11 +18,11 @@ import ( // Must use NewValueType function to create new instances. // Important: zero-initialized instance is not valid for use. type ValueType struct { - orig *otlpprofiles.ValueType + orig *internal.ValueType state *internal.State } -func newValueType(orig *otlpprofiles.ValueType, state *internal.State) ValueType { +func newValueType(orig *internal.ValueType, state *internal.State) ValueType { return ValueType{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newValueType(orig *otlpprofiles.ValueType, state *internal.State) ValueType // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewValueType() ValueType { - return newValueType(internal.NewOrigValueType(), internal.NewState()) + return newValueType(internal.NewValueType(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ValueType) MoveTo(dest ValueType) { if ms.orig == dest.orig { return } - internal.DeleteOrigValueType(dest.orig, false) + internal.DeleteValueType(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -78,11 +77,11 @@ func (ms ValueType) AggregationTemporality() AggregationTemporality { // SetAggregationTemporality replaces the aggregationtemporality associated with this ValueType. func (ms ValueType) SetAggregationTemporality(v AggregationTemporality) { ms.state.AssertMutable() - ms.orig.AggregationTemporality = otlpprofiles.AggregationTemporality(v) + ms.orig.AggregationTemporality = internal.AggregationTemporality(v) } // CopyTo copies all properties from the current struct overriding the destination. func (ms ValueType) CopyTo(dest ValueType) { dest.state.AssertMutable() - internal.CopyOrigValueType(dest.orig, ms.orig) + internal.CopyValueType(dest.orig, ms.orig) } diff --git a/pdata/pprofile/generated_valuetype_test.go b/pdata/pprofile/generated_valuetype_test.go index c4bc495e71a..6b553fc4eb5 100644 --- a/pdata/pprofile/generated_valuetype_test.go +++ b/pdata/pprofile/generated_valuetype_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestValueType_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestValueType_MoveTo(t *testing.T) { assert.Equal(t, generateTestValueType(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newValueType(internal.NewOrigValueType(), sharedState)) }) - assert.Panics(t, func() { newValueType(internal.NewOrigValueType(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newValueType(internal.NewValueType(), sharedState)) }) + assert.Panics(t, func() { newValueType(internal.NewValueType(), sharedState).MoveTo(dest) }) } func TestValueType_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestValueType_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newValueType(internal.NewOrigValueType(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newValueType(internal.NewValueType(), sharedState)) }) } func TestValueType_TypeStrindex(t *testing.T) { @@ -49,7 +48,7 @@ func TestValueType_TypeStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.TypeStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newValueType(&otlpprofiles.ValueType{}, sharedState).SetTypeStrindex(int32(13)) }) + assert.Panics(t, func() { newValueType(internal.NewValueType(), sharedState).SetTypeStrindex(int32(13)) }) } func TestValueType_UnitStrindex(t *testing.T) { @@ -59,18 +58,17 @@ func TestValueType_UnitStrindex(t *testing.T) { assert.Equal(t, int32(13), ms.UnitStrindex()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newValueType(&otlpprofiles.ValueType{}, sharedState).SetUnitStrindex(int32(13)) }) + assert.Panics(t, func() { newValueType(internal.NewValueType(), sharedState).SetUnitStrindex(int32(13)) }) } func TestValueType_AggregationTemporality(t *testing.T) { ms := NewValueType() - assert.Equal(t, AggregationTemporality(otlpprofiles.AggregationTemporality(0)), ms.AggregationTemporality()) - testValAggregationTemporality := AggregationTemporality(otlpprofiles.AggregationTemporality(1)) + assert.Equal(t, AggregationTemporality(internal.AggregationTemporality(0)), ms.AggregationTemporality()) + testValAggregationTemporality := AggregationTemporality(internal.AggregationTemporality(1)) ms.SetAggregationTemporality(testValAggregationTemporality) assert.Equal(t, testValAggregationTemporality, ms.AggregationTemporality()) } func generateTestValueType() ValueType { - ms := newValueType(internal.GenTestOrigValueType(), internal.NewState()) - return ms + return newValueType(internal.GenTestValueType(), internal.NewState()) } diff --git a/pdata/pprofile/generated_valuetypeslice.go b/pdata/pprofile/generated_valuetypeslice.go index 16bda9d57c5..4b2c0eed55a 100644 --- a/pdata/pprofile/generated_valuetypeslice.go +++ b/pdata/pprofile/generated_valuetypeslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) // ValueTypeSlice logically represents a slice of ValueType. @@ -22,18 +21,18 @@ import ( // Must use NewValueTypeSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ValueTypeSlice struct { - orig *[]*otlpprofiles.ValueType + orig *[]*internal.ValueType state *internal.State } -func newValueTypeSlice(orig *[]*otlpprofiles.ValueType, state *internal.State) ValueTypeSlice { +func newValueTypeSlice(orig *[]*internal.ValueType, state *internal.State) ValueTypeSlice { return ValueTypeSlice{orig: orig, state: state} } // NewValueTypeSlice creates a ValueTypeSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewValueTypeSlice() ValueTypeSlice { - orig := []*otlpprofiles.ValueType(nil) + orig := []*internal.ValueType(nil) return newValueTypeSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ValueTypeSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpprofiles.ValueType, len(*es.orig), newCap) + newOrig := make([]*internal.ValueType, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ValueTypeSlice) EnsureCapacity(newCap int) { // It returns the newly added ValueType. func (es ValueTypeSlice) AppendEmpty() ValueType { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigValueType()) + *es.orig = append(*es.orig, internal.NewValueType()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ValueTypeSlice) RemoveIf(f func(ValueType) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigValueType((*es.orig)[i], true) + internal.DeleteValueType((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ValueTypeSlice) CopyTo(dest ValueTypeSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigValueTypeSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyValueTypePtrSlice(*dest.orig, *es.orig) } // Sort sorts the ValueType elements within ValueTypeSlice given the diff --git a/pdata/pprofile/generated_valuetypeslice_test.go b/pdata/pprofile/generated_valuetypeslice_test.go index bf332e1629c..4a932951346 100644 --- a/pdata/pprofile/generated_valuetypeslice_test.go +++ b/pdata/pprofile/generated_valuetypeslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" ) func TestValueTypeSlice(t *testing.T) { es := NewValueTypeSlice() assert.Equal(t, 0, es.Len()) - es = newValueTypeSlice(&[]*otlpprofiles.ValueType{}, internal.NewState()) + es = newValueTypeSlice(&[]*internal.ValueType{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewValueType() @@ -27,7 +26,7 @@ func TestValueTypeSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigValueType() + (*es.orig)[i] = internal.GenTestValueType() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestValueTypeSlice(t *testing.T) { func TestValueTypeSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newValueTypeSlice(&[]*otlpprofiles.ValueType{}, sharedState) + es := newValueTypeSlice(&[]*internal.ValueType{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestValueTypeSlice_Sort(t *testing.T) { func generateTestValueTypeSlice() ValueTypeSlice { ms := NewValueTypeSlice() - *ms.orig = internal.GenerateOrigTestValueTypeSlice() + *ms.orig = internal.GenTestValueTypePtrSlice() return ms } diff --git a/pdata/pprofile/go.mod b/pdata/pprofile/go.mod index d422c4e0e19..2362f4142a5 100644 --- a/pdata/pprofile/go.mod +++ b/pdata/pprofile/go.mod @@ -14,7 +14,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/pdata/pprofile/go.sum b/pdata/pprofile/go.sum index 37229a7ff62..7abd524e005 100644 --- a/pdata/pprofile/go.sum +++ b/pdata/pprofile/go.sum @@ -5,8 +5,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -18,8 +16,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,8 +34,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= @@ -62,37 +56,12 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= diff --git a/pdata/pprofile/json.go b/pdata/pprofile/json.go index 25ed17bfd90..8b3fa3fac85 100644 --- a/pdata/pprofile/json.go +++ b/pdata/pprofile/json.go @@ -6,7 +6,6 @@ package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile" import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -18,7 +17,7 @@ type JSONMarshaler struct{} func (*JSONMarshaler) MarshalProfiles(pd Profiles) ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportProfilesServiceRequest(pd.getOrig(), dest) + pd.getOrig().MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -33,7 +32,7 @@ func (*JSONUnmarshaler) UnmarshalProfiles(buf []byte) (Profiles, error) { iter := json.BorrowIterator(buf) defer json.ReturnIterator(iter) pd := NewProfiles() - internal.UnmarshalJSONOrigExportProfilesServiceRequest(pd.getOrig(), iter) + pd.getOrig().UnmarshalJSON(iter) if iter.Error() != nil { return Profiles{}, iter.Error() } diff --git a/pdata/pprofile/pb.go b/pdata/pprofile/pb.go index 66642501e65..58f4f179474 100644 --- a/pdata/pprofile/pb.go +++ b/pdata/pprofile/pb.go @@ -3,42 +3,38 @@ package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile" -import ( - "go.opentelemetry.io/collector/pdata/internal" -) - var _ MarshalSizer = (*ProtoMarshaler)(nil) type ProtoMarshaler struct{} func (e *ProtoMarshaler) MarshalProfiles(pd Profiles) ([]byte, error) { - size := internal.SizeProtoOrigExportProfilesServiceRequest(pd.getOrig()) + size := pd.getOrig().SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportProfilesServiceRequest(pd.getOrig(), buf) + _ = pd.getOrig().MarshalProto(buf) return buf, nil } func (e *ProtoMarshaler) ProfilesSize(pd Profiles) int { - return internal.SizeProtoOrigExportProfilesServiceRequest(pd.getOrig()) + return pd.getOrig().SizeProto() } func (e *ProtoMarshaler) ResourceProfilesSize(pd ResourceProfiles) int { - return internal.SizeProtoOrigResourceProfiles(pd.orig) + return pd.orig.SizeProto() } func (e *ProtoMarshaler) ScopeProfilesSize(pd ScopeProfiles) int { - return internal.SizeProtoOrigScopeProfiles(pd.orig) + return pd.orig.SizeProto() } func (e *ProtoMarshaler) ProfileSize(pd Profile) int { - return internal.SizeProtoOrigProfile(pd.orig) + return pd.orig.SizeProto() } type ProtoUnmarshaler struct{} func (d *ProtoUnmarshaler) UnmarshalProfiles(buf []byte) (Profiles, error) { pd := NewProfiles() - err := internal.UnmarshalProtoOrigExportProfilesServiceRequest(pd.getOrig(), buf) + err := pd.getOrig().UnmarshalProto(buf) if err != nil { return Profiles{}, err } diff --git a/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess.go b/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess.go index 3c3c90ed963..7927c7f4841 100644 --- a/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess.go +++ b/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess.go @@ -8,7 +8,6 @@ package pprofileotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" ) // ExportPartialSuccess represents the details of a partially successful export request. @@ -19,11 +18,11 @@ import ( // Must use NewExportPartialSuccess function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportPartialSuccess struct { - orig *otlpcollectorprofiles.ExportProfilesPartialSuccess + orig *internal.ExportProfilesPartialSuccess state *internal.State } -func newExportPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSuccess, state *internal.State) ExportPartialSuccess { +func newExportPartialSuccess(orig *internal.ExportProfilesPartialSuccess, state *internal.State) ExportPartialSuccess { return ExportPartialSuccess{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportPartialSuccess(orig *otlpcollectorprofiles.ExportProfilesPartialSu // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportPartialSuccess() ExportPartialSuccess { - return newExportPartialSuccess(internal.NewOrigExportProfilesPartialSuccess(), internal.NewState()) + return newExportPartialSuccess(internal.NewExportProfilesPartialSuccess(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportPartialSuccess) MoveTo(dest ExportPartialSuccess) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportProfilesPartialSuccess(dest.orig, false) + internal.DeleteExportProfilesPartialSuccess(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -73,5 +72,5 @@ func (ms ExportPartialSuccess) SetErrorMessage(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportPartialSuccess) CopyTo(dest ExportPartialSuccess) { dest.state.AssertMutable() - internal.CopyOrigExportProfilesPartialSuccess(dest.orig, ms.orig) + internal.CopyExportProfilesPartialSuccess(dest.orig, ms.orig) } diff --git a/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess_test.go b/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess_test.go index 0ee01a9fbc9..822845ef3ad 100644 --- a/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess_test.go +++ b/pdata/pprofile/pprofileotlp/generated_exportpartialsuccess_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" ) func TestExportPartialSuccess_MoveTo(t *testing.T) { @@ -25,12 +24,8 @@ func TestExportPartialSuccess_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportPartialSuccess(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { - ms.MoveTo(newExportPartialSuccess(internal.NewOrigExportProfilesPartialSuccess(), sharedState)) - }) - assert.Panics(t, func() { - newExportPartialSuccess(internal.NewOrigExportProfilesPartialSuccess(), sharedState).MoveTo(dest) - }) + assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewExportProfilesPartialSuccess(), sharedState)) }) + assert.Panics(t, func() { newExportPartialSuccess(internal.NewExportProfilesPartialSuccess(), sharedState).MoveTo(dest) }) } func TestExportPartialSuccess_CopyTo(t *testing.T) { @@ -43,9 +38,7 @@ func TestExportPartialSuccess_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { - ms.CopyTo(newExportPartialSuccess(internal.NewOrigExportProfilesPartialSuccess(), sharedState)) - }) + assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewExportProfilesPartialSuccess(), sharedState)) }) } func TestExportPartialSuccess_RejectedProfiles(t *testing.T) { @@ -56,7 +49,7 @@ func TestExportPartialSuccess_RejectedProfiles(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectorprofiles.ExportProfilesPartialSuccess{}, sharedState).SetRejectedProfiles(int64(13)) + newExportPartialSuccess(internal.NewExportProfilesPartialSuccess(), sharedState).SetRejectedProfiles(int64(13)) }) } @@ -68,11 +61,10 @@ func TestExportPartialSuccess_ErrorMessage(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectorprofiles.ExportProfilesPartialSuccess{}, sharedState).SetErrorMessage("test_errormessage") + newExportPartialSuccess(internal.NewExportProfilesPartialSuccess(), sharedState).SetErrorMessage("test_errormessage") }) } func generateTestExportPartialSuccess() ExportPartialSuccess { - ms := newExportPartialSuccess(internal.GenTestOrigExportProfilesPartialSuccess(), internal.NewState()) - return ms + return newExportPartialSuccess(internal.GenTestExportProfilesPartialSuccess(), internal.NewState()) } diff --git a/pdata/pprofile/pprofileotlp/generated_exportresponse.go b/pdata/pprofile/pprofileotlp/generated_exportresponse.go index 836104f0def..bfd8e7105b9 100644 --- a/pdata/pprofile/pprofileotlp/generated_exportresponse.go +++ b/pdata/pprofile/pprofileotlp/generated_exportresponse.go @@ -8,7 +8,6 @@ package pprofileotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorprofiles "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" ) // ExportResponse represents the response for gRPC/HTTP client/server. @@ -19,11 +18,11 @@ import ( // Must use NewExportResponse function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportResponse struct { - orig *otlpcollectorprofiles.ExportProfilesServiceResponse + orig *internal.ExportProfilesServiceResponse state *internal.State } -func newExportResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse, state *internal.State) ExportResponse { +func newExportResponse(orig *internal.ExportProfilesServiceResponse, state *internal.State) ExportResponse { return ExportResponse{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportResponse(orig *otlpcollectorprofiles.ExportProfilesServiceResponse // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportResponse() ExportResponse { - return newExportResponse(internal.NewOrigExportProfilesServiceResponse(), internal.NewState()) + return newExportResponse(internal.NewExportProfilesServiceResponse(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportResponse) MoveTo(dest ExportResponse) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportProfilesServiceResponse(dest.orig, false) + internal.DeleteExportProfilesServiceResponse(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -56,5 +55,5 @@ func (ms ExportResponse) PartialSuccess() ExportPartialSuccess { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportResponse) CopyTo(dest ExportResponse) { dest.state.AssertMutable() - internal.CopyOrigExportProfilesServiceResponse(dest.orig, ms.orig) + internal.CopyExportProfilesServiceResponse(dest.orig, ms.orig) } diff --git a/pdata/pprofile/pprofileotlp/generated_exportresponse_test.go b/pdata/pprofile/pprofileotlp/generated_exportresponse_test.go index f181181e5c4..31fcefb5517 100644 --- a/pdata/pprofile/pprofileotlp/generated_exportresponse_test.go +++ b/pdata/pprofile/pprofileotlp/generated_exportresponse_test.go @@ -24,8 +24,8 @@ func TestExportResponse_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportResponse(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewOrigExportProfilesServiceResponse(), sharedState)) }) - assert.Panics(t, func() { newExportResponse(internal.NewOrigExportProfilesServiceResponse(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewExportProfilesServiceResponse(), sharedState)) }) + assert.Panics(t, func() { newExportResponse(internal.NewExportProfilesServiceResponse(), sharedState).MoveTo(dest) }) } func TestExportResponse_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestExportResponse_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewOrigExportProfilesServiceResponse(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewExportProfilesServiceResponse(), sharedState)) }) } func TestExportResponse_PartialSuccess(t *testing.T) { ms := NewExportResponse() assert.Equal(t, NewExportPartialSuccess(), ms.PartialSuccess()) - ms.orig.PartialSuccess = *internal.GenTestOrigExportProfilesPartialSuccess() + ms.orig.PartialSuccess = *internal.GenTestExportProfilesPartialSuccess() assert.Equal(t, generateTestExportPartialSuccess(), ms.PartialSuccess()) } func generateTestExportResponse() ExportResponse { - ms := newExportResponse(internal.GenTestOrigExportProfilesServiceResponse(), internal.NewState()) - return ms + return newExportResponse(internal.GenTestExportProfilesServiceResponse(), internal.NewState()) } diff --git a/pdata/pprofile/pprofileotlp/grpc.go b/pdata/pprofile/pprofileotlp/grpc.go index 819df8f6854..fe50966e983 100644 --- a/pdata/pprofile/pprofileotlp/grpc.go +++ b/pdata/pprofile/pprofileotlp/grpc.go @@ -11,8 +11,7 @@ import ( "google.golang.org/grpc/status" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - _ "go.opentelemetry.io/collector/pdata/internal/grpcencoding" // enforces custom gRPC encoding to be loaded. + "go.opentelemetry.io/collector/pdata/internal/otelgrpc" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -32,11 +31,11 @@ type GRPCClient interface { // NewGRPCClient returns a new GRPCClient connected using the given connection. func NewGRPCClient(cc *grpc.ClientConn) GRPCClient { - return &grpcClient{rawClient: otlpcollectorprofile.NewProfilesServiceClient(cc)} + return &grpcClient{rawClient: otelgrpc.NewProfilesServiceClient(cc)} } type grpcClient struct { - rawClient otlpcollectorprofile.ProfilesServiceClient + rawClient otelgrpc.ProfilesServiceClient } // Export implements the Client interface. @@ -76,14 +75,14 @@ func (*UnimplementedGRPCServer) unexported() {} // RegisterGRPCServer registers the GRPCServer to the grpc.Server. func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { - otlpcollectorprofile.RegisterProfilesServiceServer(s, &rawProfilesServer{srv: srv}) + otelgrpc.RegisterProfilesServiceServer(s, &rawProfilesServer{srv: srv}) } type rawProfilesServer struct { srv GRPCServer } -func (s rawProfilesServer) Export(ctx context.Context, request *otlpcollectorprofile.ExportProfilesServiceRequest) (*otlpcollectorprofile.ExportProfilesServiceResponse, error) { +func (s rawProfilesServer) Export(ctx context.Context, request *internal.ExportProfilesServiceRequest) (*internal.ExportProfilesServiceResponse, error) { otlp.MigrateProfiles(request.ResourceProfiles) rsp, err := s.srv.Export(ctx, ExportRequest{orig: request, state: internal.NewState()}) return rsp.orig, err diff --git a/pdata/pprofile/pprofileotlp/request.go b/pdata/pprofile/pprofileotlp/request.go index 3821cc72aab..0e5359941f5 100644 --- a/pdata/pprofile/pprofileotlp/request.go +++ b/pdata/pprofile/pprofileotlp/request.go @@ -7,7 +7,6 @@ import ( "slices" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectorprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/pprofile" @@ -16,14 +15,14 @@ import ( // ExportRequest represents the request for gRPC/HTTP client/server. // It's a wrapper for pprofile.Profiles data. type ExportRequest struct { - orig *otlpcollectorprofile.ExportProfilesServiceRequest + orig *internal.ExportProfilesServiceRequest state *internal.State } // NewExportRequest returns an empty ExportRequest. func NewExportRequest() ExportRequest { return ExportRequest{ - orig: &otlpcollectorprofile.ExportProfilesServiceRequest{}, + orig: &internal.ExportProfilesServiceRequest{}, state: internal.NewState(), } } @@ -33,22 +32,22 @@ func NewExportRequest() ExportRequest { // any changes to the provided Profiles struct will be reflected in the ExportRequest and vice versa. func NewExportRequestFromProfiles(td pprofile.Profiles) ExportRequest { return ExportRequest{ - orig: internal.GetOrigProfiles(internal.Profiles(td)), - state: internal.GetProfilesState(internal.Profiles(td)), + orig: internal.GetProfilesOrig(internal.ProfilesWrapper(td)), + state: internal.GetProfilesState(internal.ProfilesWrapper(td)), } } // MarshalProto marshals ExportRequest into proto bytes. func (ms ExportRequest) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportProfilesServiceRequest(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportProfilesServiceRequest(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportRequest from proto bytes. func (ms ExportRequest) UnmarshalProto(data []byte) error { - err := internal.UnmarshalProtoOrigExportProfilesServiceRequest(ms.orig, data) + err := ms.orig.UnmarshalProto(data) if err != nil { return err } @@ -60,7 +59,7 @@ func (ms ExportRequest) UnmarshalProto(data []byte) error { func (ms ExportRequest) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportProfilesServiceRequest(ms.orig, dest) + ms.orig.MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -71,10 +70,10 @@ func (ms ExportRequest) MarshalJSON() ([]byte, error) { func (ms ExportRequest) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportProfilesServiceRequest(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } func (ms ExportRequest) Profiles() pprofile.Profiles { - return pprofile.Profiles(internal.NewProfiles(ms.orig, ms.state)) + return pprofile.Profiles(internal.NewProfilesWrapper(ms.orig, ms.state)) } diff --git a/pdata/pprofile/pprofileotlp/request_test.go b/pdata/pprofile/pprofileotlp/request_test.go index 14d91134a75..57d6c174228 100644 --- a/pdata/pprofile/pprofileotlp/request_test.go +++ b/pdata/pprofile/pprofileotlp/request_test.go @@ -14,6 +14,7 @@ import ( goproto "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/pdata/internal" + "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/pprofile" ) @@ -71,7 +72,7 @@ func TestProfilesProtoWireCompatibility(t *testing.T) { // this repository are wire compatible. // Generate Profiles as pdata struct. - pd := NewExportRequestFromProfiles(pprofile.Profiles(internal.NewProfiles(internal.GenTestOrigExportProfilesServiceRequest(), internal.NewState()))) + pd := NewExportRequestFromProfiles(pprofile.Profiles(internal.GenTestProfilesWrapper())) // Marshal its underlying ProtoBuf to wire. wire1, err := pd.MarshalProto() @@ -89,11 +90,13 @@ func TestProfilesProtoWireCompatibility(t *testing.T) { assert.NotNil(t, wire2) // Unmarshal from the wire into gogoproto's representation. - td2 := NewExportRequest() - err = td2.UnmarshalProto(wire2) + pd2 := NewExportRequest() + err = pd2.UnmarshalProto(wire2) require.NoError(t, err) // Now compare that the original and final ProtoBuf messages are the same. // This proves that goproto and gogoproto marshaling/unmarshaling are wire compatible. - assert.Equal(t, pd, td2) + // Migration logic will run, so run it on the original message as well. + otlp.MigrateProfiles(pd.orig.ResourceProfiles) + assert.Equal(t, pd, pd2) } diff --git a/pdata/pprofile/pprofileotlp/response.go b/pdata/pprofile/pprofileotlp/response.go index 2b88ef01c2f..4bd64cecd7c 100644 --- a/pdata/pprofile/pprofileotlp/response.go +++ b/pdata/pprofile/pprofileotlp/response.go @@ -6,28 +6,27 @@ package pprofileotlp // import "go.opentelemetry.io/collector/pdata/pprofile/ppr import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" ) // MarshalProto marshals ExportResponse into proto bytes. func (ms ExportResponse) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportProfilesServiceResponse(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportProfilesServiceResponse(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportResponse from proto bytes. func (ms ExportResponse) UnmarshalProto(data []byte) error { - return internal.UnmarshalProtoOrigExportProfilesServiceResponse(ms.orig, data) + return ms.orig.UnmarshalProto(data) } // MarshalJSON marshals ExportResponse into JSON bytes. func (ms ExportResponse) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportProfilesServiceResponse(ms.orig, dest) + ms.orig.MarshalJSON(dest) return slices.Clone(dest.Buffer()), dest.Error() } @@ -35,6 +34,6 @@ func (ms ExportResponse) MarshalJSON() ([]byte, error) { func (ms ExportResponse) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportProfilesServiceResponse(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } diff --git a/pdata/pprofile/profileid.go b/pdata/pprofile/profileid.go index 52ee2e812b6..35c411ea7fd 100644 --- a/pdata/pprofile/profileid.go +++ b/pdata/pprofile/profileid.go @@ -6,7 +6,7 @@ package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile" import ( "encoding/hex" - "go.opentelemetry.io/collector/pdata/internal/data" + "go.opentelemetry.io/collector/pdata/internal" ) var emptyProfileID = ProfileID([16]byte{}) @@ -33,5 +33,5 @@ func (ms ProfileID) String() string { // IsEmpty returns true if id doesn't contain at least one non-zero byte. func (ms ProfileID) IsEmpty() bool { - return data.ProfileID(ms).IsEmpty() + return internal.ProfileID(ms).IsEmpty() } diff --git a/pdata/pprofile/profiles_test.go b/pdata/pprofile/profiles_test.go index dede1dbf0d4..ff78a14dd87 100644 --- a/pdata/pprofile/profiles_test.go +++ b/pdata/pprofile/profiles_test.go @@ -11,9 +11,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlpcollectorprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/profiles/v1development" - otlpprofile "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -64,24 +61,24 @@ func TestSampleCount(t *testing.T) { } func TestSampleCountWithEmpty(t *testing.T) { - assert.Equal(t, 0, newProfiles(&otlpcollectorprofile.ExportProfilesServiceRequest{ - ResourceProfiles: []*otlpprofile.ResourceProfiles{{}}, + assert.Equal(t, 0, newProfiles(&internal.ExportProfilesServiceRequest{ + ResourceProfiles: []*internal.ResourceProfiles{{}}, }, new(internal.State)).SampleCount()) - assert.Equal(t, 0, newProfiles(&otlpcollectorprofile.ExportProfilesServiceRequest{ - ResourceProfiles: []*otlpprofile.ResourceProfiles{ + assert.Equal(t, 0, newProfiles(&internal.ExportProfilesServiceRequest{ + ResourceProfiles: []*internal.ResourceProfiles{ { - ScopeProfiles: []*otlpprofile.ScopeProfiles{{}}, + ScopeProfiles: []*internal.ScopeProfiles{{}}, }, }, }, new(internal.State)).SampleCount()) - assert.Equal(t, 1, newProfiles(&otlpcollectorprofile.ExportProfilesServiceRequest{ - ResourceProfiles: []*otlpprofile.ResourceProfiles{ + assert.Equal(t, 1, newProfiles(&internal.ExportProfilesServiceRequest{ + ResourceProfiles: []*internal.ResourceProfiles{ { - ScopeProfiles: []*otlpprofile.ScopeProfiles{ + ScopeProfiles: []*internal.ScopeProfiles{ { - Profiles: []*otlpprofile.Profile{ + Profiles: []*internal.Profile{ { - Sample: []*otlpprofile.Sample{ + Sample: []*internal.Sample{ {}, }, }, @@ -96,8 +93,8 @@ func TestSampleCountWithEmpty(t *testing.T) { func BenchmarkProfilesUsage(b *testing.B) { pd := generateTestProfiles() ts := pcommon.NewTimestampFromTime(time.Now()) - testValProfileID := ProfileID(data.ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) - testSecondValProfileID := ProfileID(data.ProfileID([16]byte{2, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + testValProfileID := ProfileID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) + testSecondValProfileID := ProfileID([16]byte{2, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1}) b.ReportAllocs() diff --git a/pdata/ptrace/generated_resourcespans.go b/pdata/ptrace/generated_resourcespans.go index 7db68c6ef75..c68406cadeb 100644 --- a/pdata/ptrace/generated_resourcespans.go +++ b/pdata/ptrace/generated_resourcespans.go @@ -8,7 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewResourceSpans function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceSpans struct { - orig *otlptrace.ResourceSpans + orig *internal.ResourceSpans state *internal.State } -func newResourceSpans(orig *otlptrace.ResourceSpans, state *internal.State) ResourceSpans { +func newResourceSpans(orig *internal.ResourceSpans, state *internal.State) ResourceSpans { return ResourceSpans{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newResourceSpans(orig *otlptrace.ResourceSpans, state *internal.State) Reso // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewResourceSpans() ResourceSpans { - return newResourceSpans(internal.NewOrigResourceSpans(), internal.NewState()) + return newResourceSpans(internal.NewResourceSpans(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ResourceSpans) MoveTo(dest ResourceSpans) { if ms.orig == dest.orig { return } - internal.DeleteOrigResourceSpans(dest.orig, false) + internal.DeleteResourceSpans(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Resource returns the resource associated with this ResourceSpans. func (ms ResourceSpans) Resource() pcommon.Resource { - return pcommon.Resource(internal.NewResource(&ms.orig.Resource, ms.state)) + return pcommon.Resource(internal.NewResourceWrapper(&ms.orig.Resource, ms.state)) } // ScopeSpans returns the ScopeSpans associated with this ResourceSpans. @@ -73,5 +72,5 @@ func (ms ResourceSpans) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ResourceSpans) CopyTo(dest ResourceSpans) { dest.state.AssertMutable() - internal.CopyOrigResourceSpans(dest.orig, ms.orig) + internal.CopyResourceSpans(dest.orig, ms.orig) } diff --git a/pdata/ptrace/generated_resourcespans_test.go b/pdata/ptrace/generated_resourcespans_test.go index 9ed1540ba19..8316c868942 100644 --- a/pdata/ptrace/generated_resourcespans_test.go +++ b/pdata/ptrace/generated_resourcespans_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestResourceSpans_MoveTo(t *testing.T) { assert.Equal(t, generateTestResourceSpans(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newResourceSpans(internal.NewOrigResourceSpans(), sharedState)) }) - assert.Panics(t, func() { newResourceSpans(internal.NewOrigResourceSpans(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newResourceSpans(internal.NewResourceSpans(), sharedState)) }) + assert.Panics(t, func() { newResourceSpans(internal.NewResourceSpans(), sharedState).MoveTo(dest) }) } func TestResourceSpans_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestResourceSpans_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newResourceSpans(internal.NewOrigResourceSpans(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newResourceSpans(internal.NewResourceSpans(), sharedState)) }) } func TestResourceSpans_Resource(t *testing.T) { ms := NewResourceSpans() assert.Equal(t, pcommon.NewResource(), ms.Resource()) - ms.orig.Resource = *internal.GenTestOrigResource() - assert.Equal(t, pcommon.Resource(internal.NewResource(internal.GenTestOrigResource(), ms.state)), ms.Resource()) + ms.orig.Resource = *internal.GenTestResource() + assert.Equal(t, pcommon.Resource(internal.GenTestResourceWrapper()), ms.Resource()) } func TestResourceSpans_ScopeSpans(t *testing.T) { ms := NewResourceSpans() assert.Equal(t, NewScopeSpansSlice(), ms.ScopeSpans()) - ms.orig.ScopeSpans = internal.GenerateOrigTestScopeSpansSlice() + ms.orig.ScopeSpans = internal.GenTestScopeSpansPtrSlice() assert.Equal(t, generateTestScopeSpansSlice(), ms.ScopeSpans()) } @@ -64,10 +63,9 @@ func TestResourceSpans_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newResourceSpans(&otlptrace.ResourceSpans{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newResourceSpans(internal.NewResourceSpans(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestResourceSpans() ResourceSpans { - ms := newResourceSpans(internal.GenTestOrigResourceSpans(), internal.NewState()) - return ms + return newResourceSpans(internal.GenTestResourceSpans(), internal.NewState()) } diff --git a/pdata/ptrace/generated_resourcespansslice.go b/pdata/ptrace/generated_resourcespansslice.go index 565f413dd90..3a7d3dec5e4 100644 --- a/pdata/ptrace/generated_resourcespansslice.go +++ b/pdata/ptrace/generated_resourcespansslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // ResourceSpansSlice logically represents a slice of ResourceSpans. @@ -22,18 +21,18 @@ import ( // Must use NewResourceSpansSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ResourceSpansSlice struct { - orig *[]*otlptrace.ResourceSpans + orig *[]*internal.ResourceSpans state *internal.State } -func newResourceSpansSlice(orig *[]*otlptrace.ResourceSpans, state *internal.State) ResourceSpansSlice { +func newResourceSpansSlice(orig *[]*internal.ResourceSpans, state *internal.State) ResourceSpansSlice { return ResourceSpansSlice{orig: orig, state: state} } // NewResourceSpansSlice creates a ResourceSpansSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewResourceSpansSlice() ResourceSpansSlice { - orig := []*otlptrace.ResourceSpans(nil) + orig := []*internal.ResourceSpans(nil) return newResourceSpansSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ResourceSpansSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlptrace.ResourceSpans, len(*es.orig), newCap) + newOrig := make([]*internal.ResourceSpans, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ResourceSpansSlice) EnsureCapacity(newCap int) { // It returns the newly added ResourceSpans. func (es ResourceSpansSlice) AppendEmpty() ResourceSpans { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigResourceSpans()) + *es.orig = append(*es.orig, internal.NewResourceSpans()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ResourceSpansSlice) RemoveIf(f func(ResourceSpans) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigResourceSpans((*es.orig)[i], true) + internal.DeleteResourceSpans((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ResourceSpansSlice) CopyTo(dest ResourceSpansSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigResourceSpansSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyResourceSpansPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ResourceSpans elements within ResourceSpansSlice given the diff --git a/pdata/ptrace/generated_resourcespansslice_test.go b/pdata/ptrace/generated_resourcespansslice_test.go index 1feb8c17ab2..7b93a3132ac 100644 --- a/pdata/ptrace/generated_resourcespansslice_test.go +++ b/pdata/ptrace/generated_resourcespansslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestResourceSpansSlice(t *testing.T) { es := NewResourceSpansSlice() assert.Equal(t, 0, es.Len()) - es = newResourceSpansSlice(&[]*otlptrace.ResourceSpans{}, internal.NewState()) + es = newResourceSpansSlice(&[]*internal.ResourceSpans{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewResourceSpans() @@ -27,7 +26,7 @@ func TestResourceSpansSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigResourceSpans() + (*es.orig)[i] = internal.GenTestResourceSpans() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestResourceSpansSlice(t *testing.T) { func TestResourceSpansSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newResourceSpansSlice(&[]*otlptrace.ResourceSpans{}, sharedState) + es := newResourceSpansSlice(&[]*internal.ResourceSpans{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestResourceSpansSlice_Sort(t *testing.T) { func generateTestResourceSpansSlice() ResourceSpansSlice { ms := NewResourceSpansSlice() - *ms.orig = internal.GenerateOrigTestResourceSpansSlice() + *ms.orig = internal.GenTestResourceSpansPtrSlice() return ms } diff --git a/pdata/ptrace/generated_scopespans.go b/pdata/ptrace/generated_scopespans.go index 5ea42e985a6..a06c1df34d9 100644 --- a/pdata/ptrace/generated_scopespans.go +++ b/pdata/ptrace/generated_scopespans.go @@ -8,7 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -20,11 +19,11 @@ import ( // Must use NewScopeSpans function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeSpans struct { - orig *otlptrace.ScopeSpans + orig *internal.ScopeSpans state *internal.State } -func newScopeSpans(orig *otlptrace.ScopeSpans, state *internal.State) ScopeSpans { +func newScopeSpans(orig *internal.ScopeSpans, state *internal.State) ScopeSpans { return ScopeSpans{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newScopeSpans(orig *otlptrace.ScopeSpans, state *internal.State) ScopeSpans // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewScopeSpans() ScopeSpans { - return newScopeSpans(internal.NewOrigScopeSpans(), internal.NewState()) + return newScopeSpans(internal.NewScopeSpans(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,13 +44,13 @@ func (ms ScopeSpans) MoveTo(dest ScopeSpans) { if ms.orig == dest.orig { return } - internal.DeleteOrigScopeSpans(dest.orig, false) + internal.DeleteScopeSpans(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } // Scope returns the scope associated with this ScopeSpans. func (ms ScopeSpans) Scope() pcommon.InstrumentationScope { - return pcommon.InstrumentationScope(internal.NewInstrumentationScope(&ms.orig.Scope, ms.state)) + return pcommon.InstrumentationScope(internal.NewInstrumentationScopeWrapper(&ms.orig.Scope, ms.state)) } // Spans returns the Spans associated with this ScopeSpans. @@ -73,5 +72,5 @@ func (ms ScopeSpans) SetSchemaUrl(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ScopeSpans) CopyTo(dest ScopeSpans) { dest.state.AssertMutable() - internal.CopyOrigScopeSpans(dest.orig, ms.orig) + internal.CopyScopeSpans(dest.orig, ms.orig) } diff --git a/pdata/ptrace/generated_scopespans_test.go b/pdata/ptrace/generated_scopespans_test.go index b767bba278c..de44df98ca0 100644 --- a/pdata/ptrace/generated_scopespans_test.go +++ b/pdata/ptrace/generated_scopespans_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestScopeSpans_MoveTo(t *testing.T) { assert.Equal(t, generateTestScopeSpans(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newScopeSpans(internal.NewOrigScopeSpans(), sharedState)) }) - assert.Panics(t, func() { newScopeSpans(internal.NewOrigScopeSpans(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newScopeSpans(internal.NewScopeSpans(), sharedState)) }) + assert.Panics(t, func() { newScopeSpans(internal.NewScopeSpans(), sharedState).MoveTo(dest) }) } func TestScopeSpans_CopyTo(t *testing.T) { @@ -40,20 +39,20 @@ func TestScopeSpans_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newScopeSpans(internal.NewOrigScopeSpans(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newScopeSpans(internal.NewScopeSpans(), sharedState)) }) } func TestScopeSpans_Scope(t *testing.T) { ms := NewScopeSpans() assert.Equal(t, pcommon.NewInstrumentationScope(), ms.Scope()) - ms.orig.Scope = *internal.GenTestOrigInstrumentationScope() - assert.Equal(t, pcommon.InstrumentationScope(internal.NewInstrumentationScope(internal.GenTestOrigInstrumentationScope(), ms.state)), ms.Scope()) + ms.orig.Scope = *internal.GenTestInstrumentationScope() + assert.Equal(t, pcommon.InstrumentationScope(internal.GenTestInstrumentationScopeWrapper()), ms.Scope()) } func TestScopeSpans_Spans(t *testing.T) { ms := NewScopeSpans() assert.Equal(t, NewSpanSlice(), ms.Spans()) - ms.orig.Spans = internal.GenerateOrigTestSpanSlice() + ms.orig.Spans = internal.GenTestSpanPtrSlice() assert.Equal(t, generateTestSpanSlice(), ms.Spans()) } @@ -64,10 +63,9 @@ func TestScopeSpans_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newScopeSpans(&otlptrace.ScopeSpans{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newScopeSpans(internal.NewScopeSpans(), sharedState).SetSchemaUrl("test_schemaurl") }) } func generateTestScopeSpans() ScopeSpans { - ms := newScopeSpans(internal.GenTestOrigScopeSpans(), internal.NewState()) - return ms + return newScopeSpans(internal.GenTestScopeSpans(), internal.NewState()) } diff --git a/pdata/ptrace/generated_scopespansslice.go b/pdata/ptrace/generated_scopespansslice.go index 8e2fbf65724..a6c731c758a 100644 --- a/pdata/ptrace/generated_scopespansslice.go +++ b/pdata/ptrace/generated_scopespansslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // ScopeSpansSlice logically represents a slice of ScopeSpans. @@ -22,18 +21,18 @@ import ( // Must use NewScopeSpansSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type ScopeSpansSlice struct { - orig *[]*otlptrace.ScopeSpans + orig *[]*internal.ScopeSpans state *internal.State } -func newScopeSpansSlice(orig *[]*otlptrace.ScopeSpans, state *internal.State) ScopeSpansSlice { +func newScopeSpansSlice(orig *[]*internal.ScopeSpans, state *internal.State) ScopeSpansSlice { return ScopeSpansSlice{orig: orig, state: state} } // NewScopeSpansSlice creates a ScopeSpansSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewScopeSpansSlice() ScopeSpansSlice { - orig := []*otlptrace.ScopeSpans(nil) + orig := []*internal.ScopeSpans(nil) return newScopeSpansSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es ScopeSpansSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlptrace.ScopeSpans, len(*es.orig), newCap) + newOrig := make([]*internal.ScopeSpans, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es ScopeSpansSlice) EnsureCapacity(newCap int) { // It returns the newly added ScopeSpans. func (es ScopeSpansSlice) AppendEmpty() ScopeSpans { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigScopeSpans()) + *es.orig = append(*es.orig, internal.NewScopeSpans()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es ScopeSpansSlice) RemoveIf(f func(ScopeSpans) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigScopeSpans((*es.orig)[i], true) + internal.DeleteScopeSpans((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es ScopeSpansSlice) CopyTo(dest ScopeSpansSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigScopeSpansSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopyScopeSpansPtrSlice(*dest.orig, *es.orig) } // Sort sorts the ScopeSpans elements within ScopeSpansSlice given the diff --git a/pdata/ptrace/generated_scopespansslice_test.go b/pdata/ptrace/generated_scopespansslice_test.go index 000cd5d89d2..f2d27917a7f 100644 --- a/pdata/ptrace/generated_scopespansslice_test.go +++ b/pdata/ptrace/generated_scopespansslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestScopeSpansSlice(t *testing.T) { es := NewScopeSpansSlice() assert.Equal(t, 0, es.Len()) - es = newScopeSpansSlice(&[]*otlptrace.ScopeSpans{}, internal.NewState()) + es = newScopeSpansSlice(&[]*internal.ScopeSpans{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewScopeSpans() @@ -27,7 +26,7 @@ func TestScopeSpansSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigScopeSpans() + (*es.orig)[i] = internal.GenTestScopeSpans() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestScopeSpansSlice(t *testing.T) { func TestScopeSpansSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newScopeSpansSlice(&[]*otlptrace.ScopeSpans{}, sharedState) + es := newScopeSpansSlice(&[]*internal.ScopeSpans{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestScopeSpansSlice_Sort(t *testing.T) { func generateTestScopeSpansSlice() ScopeSpansSlice { ms := NewScopeSpansSlice() - *ms.orig = internal.GenerateOrigTestScopeSpansSlice() + *ms.orig = internal.GenTestScopeSpansPtrSlice() return ms } diff --git a/pdata/ptrace/generated_span.go b/pdata/ptrace/generated_span.go index 433487d4197..238386c1798 100644 --- a/pdata/ptrace/generated_span.go +++ b/pdata/ptrace/generated_span.go @@ -8,8 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -22,11 +20,11 @@ import ( // Must use NewSpan function to create new instances. // Important: zero-initialized instance is not valid for use. type Span struct { - orig *otlptrace.Span + orig *internal.Span state *internal.State } -func newSpan(orig *otlptrace.Span, state *internal.State) Span { +func newSpan(orig *internal.Span, state *internal.State) Span { return Span{orig: orig, state: state} } @@ -35,7 +33,7 @@ func newSpan(orig *otlptrace.Span, state *internal.State) Span { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSpan() Span { - return newSpan(internal.NewOrigSpan(), internal.NewState()) + return newSpan(internal.NewSpan(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -47,7 +45,7 @@ func (ms Span) MoveTo(dest Span) { if ms.orig == dest.orig { return } - internal.DeleteOrigSpan(dest.orig, false) + internal.DeleteSpan(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -59,7 +57,7 @@ func (ms Span) TraceID() pcommon.TraceID { // SetTraceID replaces the traceid associated with this Span. func (ms Span) SetTraceID(v pcommon.TraceID) { ms.state.AssertMutable() - ms.orig.TraceId = data.TraceID(v) + ms.orig.TraceId = internal.TraceID(v) } // SpanID returns the spanid associated with this Span. @@ -70,12 +68,12 @@ func (ms Span) SpanID() pcommon.SpanID { // SetSpanID replaces the spanid associated with this Span. func (ms Span) SetSpanID(v pcommon.SpanID) { ms.state.AssertMutable() - ms.orig.SpanId = data.SpanID(v) + ms.orig.SpanId = internal.SpanID(v) } // TraceState returns the tracestate associated with this Span. func (ms Span) TraceState() pcommon.TraceState { - return pcommon.TraceState(internal.NewTraceState(&ms.orig.TraceState, ms.state)) + return pcommon.TraceState(internal.NewTraceStateWrapper(&ms.orig.TraceState, ms.state)) } // ParentSpanID returns the parentspanid associated with this Span. @@ -86,7 +84,7 @@ func (ms Span) ParentSpanID() pcommon.SpanID { // SetParentSpanID replaces the parentspanid associated with this Span. func (ms Span) SetParentSpanID(v pcommon.SpanID) { ms.state.AssertMutable() - ms.orig.ParentSpanId = data.SpanID(v) + ms.orig.ParentSpanId = internal.SpanID(v) } // Flags returns the flags associated with this Span. @@ -119,7 +117,7 @@ func (ms Span) Kind() SpanKind { // SetKind replaces the kind associated with this Span. func (ms Span) SetKind(v SpanKind) { ms.state.AssertMutable() - ms.orig.Kind = otlptrace.Span_SpanKind(v) + ms.orig.Kind = internal.SpanKind(v) } // StartTimestamp returns the starttimestamp associated with this Span. @@ -146,7 +144,7 @@ func (ms Span) SetEndTimestamp(v pcommon.Timestamp) { // Attributes returns the Attributes associated with this Span. func (ms Span) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // DroppedAttributesCount returns the droppedattributescount associated with this Span. @@ -200,5 +198,5 @@ func (ms Span) Status() Status { // CopyTo copies all properties from the current struct overriding the destination. func (ms Span) CopyTo(dest Span) { dest.state.AssertMutable() - internal.CopyOrigSpan(dest.orig, ms.orig) + internal.CopySpan(dest.orig, ms.orig) } diff --git a/pdata/ptrace/generated_span_test.go b/pdata/ptrace/generated_span_test.go index 70a64ae457e..3ec19caadc7 100644 --- a/pdata/ptrace/generated_span_test.go +++ b/pdata/ptrace/generated_span_test.go @@ -12,8 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,8 +25,8 @@ func TestSpan_MoveTo(t *testing.T) { assert.Equal(t, generateTestSpan(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSpan(internal.NewOrigSpan(), sharedState)) }) - assert.Panics(t, func() { newSpan(internal.NewOrigSpan(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSpan(internal.NewSpan(), sharedState)) }) + assert.Panics(t, func() { newSpan(internal.NewSpan(), sharedState).MoveTo(dest) }) } func TestSpan_CopyTo(t *testing.T) { @@ -41,21 +39,21 @@ func TestSpan_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSpan(internal.NewOrigSpan(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSpan(internal.NewSpan(), sharedState)) }) } func TestSpan_TraceID(t *testing.T) { ms := NewSpan() - assert.Equal(t, pcommon.TraceID(data.TraceID([16]byte{})), ms.TraceID()) - testValTraceID := pcommon.TraceID(data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.TraceID(internal.TraceID([16]byte{})), ms.TraceID()) + testValTraceID := pcommon.TraceID(internal.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) ms.SetTraceID(testValTraceID) assert.Equal(t, testValTraceID, ms.TraceID()) } func TestSpan_SpanID(t *testing.T) { ms := NewSpan() - assert.Equal(t, pcommon.SpanID(data.SpanID([8]byte{})), ms.SpanID()) - testValSpanID := pcommon.SpanID(data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.SpanID(internal.SpanID([8]byte{})), ms.SpanID()) + testValSpanID := pcommon.SpanID(internal.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) ms.SetSpanID(testValSpanID) assert.Equal(t, testValSpanID, ms.SpanID()) } @@ -63,14 +61,14 @@ func TestSpan_SpanID(t *testing.T) { func TestSpan_TraceState(t *testing.T) { ms := NewSpan() assert.Equal(t, pcommon.NewTraceState(), ms.TraceState()) - ms.orig.TraceState = *internal.GenTestOrigTraceState() - assert.Equal(t, pcommon.TraceState(internal.NewTraceState(internal.GenTestOrigTraceState(), ms.state)), ms.TraceState()) + ms.orig.TraceState = *internal.GenTestTraceState() + assert.Equal(t, pcommon.TraceState(internal.GenTestTraceStateWrapper()), ms.TraceState()) } func TestSpan_ParentSpanID(t *testing.T) { ms := NewSpan() - assert.Equal(t, pcommon.SpanID(data.SpanID([8]byte{})), ms.ParentSpanID()) - testValParentSpanID := pcommon.SpanID(data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.SpanID(internal.SpanID([8]byte{})), ms.ParentSpanID()) + testValParentSpanID := pcommon.SpanID(internal.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) ms.SetParentSpanID(testValParentSpanID) assert.Equal(t, testValParentSpanID, ms.ParentSpanID()) } @@ -82,7 +80,7 @@ func TestSpan_Flags(t *testing.T) { assert.Equal(t, uint32(13), ms.Flags()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpan(&otlptrace.Span{}, sharedState).SetFlags(uint32(13)) }) + assert.Panics(t, func() { newSpan(internal.NewSpan(), sharedState).SetFlags(uint32(13)) }) } func TestSpan_Name(t *testing.T) { @@ -92,13 +90,13 @@ func TestSpan_Name(t *testing.T) { assert.Equal(t, "test_name", ms.Name()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpan(&otlptrace.Span{}, sharedState).SetName("test_name") }) + assert.Panics(t, func() { newSpan(internal.NewSpan(), sharedState).SetName("test_name") }) } func TestSpan_Kind(t *testing.T) { ms := NewSpan() - assert.Equal(t, SpanKind(otlptrace.Span_SpanKind(0)), ms.Kind()) - testValKind := SpanKind(otlptrace.Span_SpanKind(3)) + assert.Equal(t, SpanKind(internal.SpanKind_SPAN_KIND_UNSPECIFIED), ms.Kind()) + testValKind := SpanKind(internal.SpanKind_SPAN_KIND_CLIENT) ms.SetKind(testValKind) assert.Equal(t, testValKind, ms.Kind()) } @@ -122,8 +120,8 @@ func TestSpan_EndTimestamp(t *testing.T) { func TestSpan_Attributes(t *testing.T) { ms := NewSpan() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestSpan_DroppedAttributesCount(t *testing.T) { @@ -133,13 +131,13 @@ func TestSpan_DroppedAttributesCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpan(&otlptrace.Span{}, sharedState).SetDroppedAttributesCount(uint32(13)) }) + assert.Panics(t, func() { newSpan(internal.NewSpan(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func TestSpan_Events(t *testing.T) { ms := NewSpan() assert.Equal(t, NewSpanEventSlice(), ms.Events()) - ms.orig.Events = internal.GenerateOrigTestSpan_EventSlice() + ms.orig.Events = internal.GenTestSpanEventPtrSlice() assert.Equal(t, generateTestSpanEventSlice(), ms.Events()) } @@ -150,13 +148,13 @@ func TestSpan_DroppedEventsCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedEventsCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpan(&otlptrace.Span{}, sharedState).SetDroppedEventsCount(uint32(13)) }) + assert.Panics(t, func() { newSpan(internal.NewSpan(), sharedState).SetDroppedEventsCount(uint32(13)) }) } func TestSpan_Links(t *testing.T) { ms := NewSpan() assert.Equal(t, NewSpanLinkSlice(), ms.Links()) - ms.orig.Links = internal.GenerateOrigTestSpan_LinkSlice() + ms.orig.Links = internal.GenTestSpanLinkPtrSlice() assert.Equal(t, generateTestSpanLinkSlice(), ms.Links()) } @@ -167,17 +165,16 @@ func TestSpan_DroppedLinksCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedLinksCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpan(&otlptrace.Span{}, sharedState).SetDroppedLinksCount(uint32(13)) }) + assert.Panics(t, func() { newSpan(internal.NewSpan(), sharedState).SetDroppedLinksCount(uint32(13)) }) } func TestSpan_Status(t *testing.T) { ms := NewSpan() assert.Equal(t, NewStatus(), ms.Status()) - ms.orig.Status = *internal.GenTestOrigStatus() + ms.orig.Status = *internal.GenTestStatus() assert.Equal(t, generateTestStatus(), ms.Status()) } func generateTestSpan() Span { - ms := newSpan(internal.GenTestOrigSpan(), internal.NewState()) - return ms + return newSpan(internal.GenTestSpan(), internal.NewState()) } diff --git a/pdata/ptrace/generated_spanevent.go b/pdata/ptrace/generated_spanevent.go index f474aca804f..333f5d47b4f 100644 --- a/pdata/ptrace/generated_spanevent.go +++ b/pdata/ptrace/generated_spanevent.go @@ -8,7 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -21,11 +20,11 @@ import ( // Must use NewSpanEvent function to create new instances. // Important: zero-initialized instance is not valid for use. type SpanEvent struct { - orig *otlptrace.Span_Event + orig *internal.SpanEvent state *internal.State } -func newSpanEvent(orig *otlptrace.Span_Event, state *internal.State) SpanEvent { +func newSpanEvent(orig *internal.SpanEvent, state *internal.State) SpanEvent { return SpanEvent{orig: orig, state: state} } @@ -34,7 +33,7 @@ func newSpanEvent(orig *otlptrace.Span_Event, state *internal.State) SpanEvent { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSpanEvent() SpanEvent { - return newSpanEvent(internal.NewOrigSpan_Event(), internal.NewState()) + return newSpanEvent(internal.NewSpanEvent(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -46,7 +45,7 @@ func (ms SpanEvent) MoveTo(dest SpanEvent) { if ms.orig == dest.orig { return } - internal.DeleteOrigSpan_Event(dest.orig, false) + internal.DeleteSpanEvent(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -74,7 +73,7 @@ func (ms SpanEvent) SetName(v string) { // Attributes returns the Attributes associated with this SpanEvent. func (ms SpanEvent) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // DroppedAttributesCount returns the droppedattributescount associated with this SpanEvent. @@ -91,5 +90,5 @@ func (ms SpanEvent) SetDroppedAttributesCount(v uint32) { // CopyTo copies all properties from the current struct overriding the destination. func (ms SpanEvent) CopyTo(dest SpanEvent) { dest.state.AssertMutable() - internal.CopyOrigSpan_Event(dest.orig, ms.orig) + internal.CopySpanEvent(dest.orig, ms.orig) } diff --git a/pdata/ptrace/generated_spanevent_test.go b/pdata/ptrace/generated_spanevent_test.go index 73ff89ab73a..746a7f65a95 100644 --- a/pdata/ptrace/generated_spanevent_test.go +++ b/pdata/ptrace/generated_spanevent_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestSpanEvent_MoveTo(t *testing.T) { assert.Equal(t, generateTestSpanEvent(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSpanEvent(internal.NewOrigSpan_Event(), sharedState)) }) - assert.Panics(t, func() { newSpanEvent(internal.NewOrigSpan_Event(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSpanEvent(internal.NewSpanEvent(), sharedState)) }) + assert.Panics(t, func() { newSpanEvent(internal.NewSpanEvent(), sharedState).MoveTo(dest) }) } func TestSpanEvent_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestSpanEvent_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSpanEvent(internal.NewOrigSpan_Event(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSpanEvent(internal.NewSpanEvent(), sharedState)) }) } func TestSpanEvent_Timestamp(t *testing.T) { @@ -58,14 +57,14 @@ func TestSpanEvent_Name(t *testing.T) { assert.Equal(t, "test_name", ms.Name()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpanEvent(&otlptrace.Span_Event{}, sharedState).SetName("test_name") }) + assert.Panics(t, func() { newSpanEvent(internal.NewSpanEvent(), sharedState).SetName("test_name") }) } func TestSpanEvent_Attributes(t *testing.T) { ms := NewSpanEvent() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestSpanEvent_DroppedAttributesCount(t *testing.T) { @@ -75,10 +74,9 @@ func TestSpanEvent_DroppedAttributesCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpanEvent(&otlptrace.Span_Event{}, sharedState).SetDroppedAttributesCount(uint32(13)) }) + assert.Panics(t, func() { newSpanEvent(internal.NewSpanEvent(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func generateTestSpanEvent() SpanEvent { - ms := newSpanEvent(internal.GenTestOrigSpan_Event(), internal.NewState()) - return ms + return newSpanEvent(internal.GenTestSpanEvent(), internal.NewState()) } diff --git a/pdata/ptrace/generated_spaneventslice.go b/pdata/ptrace/generated_spaneventslice.go index c0da19167d2..330b40f03bc 100644 --- a/pdata/ptrace/generated_spaneventslice.go +++ b/pdata/ptrace/generated_spaneventslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // SpanEventSlice logically represents a slice of SpanEvent. @@ -22,18 +21,18 @@ import ( // Must use NewSpanEventSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SpanEventSlice struct { - orig *[]*otlptrace.Span_Event + orig *[]*internal.SpanEvent state *internal.State } -func newSpanEventSlice(orig *[]*otlptrace.Span_Event, state *internal.State) SpanEventSlice { +func newSpanEventSlice(orig *[]*internal.SpanEvent, state *internal.State) SpanEventSlice { return SpanEventSlice{orig: orig, state: state} } // NewSpanEventSlice creates a SpanEventSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSpanEventSlice() SpanEventSlice { - orig := []*otlptrace.Span_Event(nil) + orig := []*internal.SpanEvent(nil) return newSpanEventSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es SpanEventSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlptrace.Span_Event, len(*es.orig), newCap) + newOrig := make([]*internal.SpanEvent, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es SpanEventSlice) EnsureCapacity(newCap int) { // It returns the newly added SpanEvent. func (es SpanEventSlice) AppendEmpty() SpanEvent { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigSpan_Event()) + *es.orig = append(*es.orig, internal.NewSpanEvent()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es SpanEventSlice) RemoveIf(f func(SpanEvent) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigSpan_Event((*es.orig)[i], true) + internal.DeleteSpanEvent((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es SpanEventSlice) CopyTo(dest SpanEventSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigSpan_EventSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopySpanEventPtrSlice(*dest.orig, *es.orig) } // Sort sorts the SpanEvent elements within SpanEventSlice given the diff --git a/pdata/ptrace/generated_spaneventslice_test.go b/pdata/ptrace/generated_spaneventslice_test.go index cee9923299a..bd082ddb363 100644 --- a/pdata/ptrace/generated_spaneventslice_test.go +++ b/pdata/ptrace/generated_spaneventslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestSpanEventSlice(t *testing.T) { es := NewSpanEventSlice() assert.Equal(t, 0, es.Len()) - es = newSpanEventSlice(&[]*otlptrace.Span_Event{}, internal.NewState()) + es = newSpanEventSlice(&[]*internal.SpanEvent{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewSpanEvent() @@ -27,7 +26,7 @@ func TestSpanEventSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigSpan_Event() + (*es.orig)[i] = internal.GenTestSpanEvent() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestSpanEventSlice(t *testing.T) { func TestSpanEventSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSpanEventSlice(&[]*otlptrace.Span_Event{}, sharedState) + es := newSpanEventSlice(&[]*internal.SpanEvent{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestSpanEventSlice_Sort(t *testing.T) { func generateTestSpanEventSlice() SpanEventSlice { ms := NewSpanEventSlice() - *ms.orig = internal.GenerateOrigTestSpan_EventSlice() + *ms.orig = internal.GenTestSpanEventPtrSlice() return ms } diff --git a/pdata/ptrace/generated_spanlink.go b/pdata/ptrace/generated_spanlink.go index cfe1caaaf39..ab585857a56 100644 --- a/pdata/ptrace/generated_spanlink.go +++ b/pdata/ptrace/generated_spanlink.go @@ -8,8 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -23,11 +21,11 @@ import ( // Must use NewSpanLink function to create new instances. // Important: zero-initialized instance is not valid for use. type SpanLink struct { - orig *otlptrace.Span_Link + orig *internal.SpanLink state *internal.State } -func newSpanLink(orig *otlptrace.Span_Link, state *internal.State) SpanLink { +func newSpanLink(orig *internal.SpanLink, state *internal.State) SpanLink { return SpanLink{orig: orig, state: state} } @@ -36,7 +34,7 @@ func newSpanLink(orig *otlptrace.Span_Link, state *internal.State) SpanLink { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewSpanLink() SpanLink { - return newSpanLink(internal.NewOrigSpan_Link(), internal.NewState()) + return newSpanLink(internal.NewSpanLink(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -48,7 +46,7 @@ func (ms SpanLink) MoveTo(dest SpanLink) { if ms.orig == dest.orig { return } - internal.DeleteOrigSpan_Link(dest.orig, false) + internal.DeleteSpanLink(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -60,7 +58,7 @@ func (ms SpanLink) TraceID() pcommon.TraceID { // SetTraceID replaces the traceid associated with this SpanLink. func (ms SpanLink) SetTraceID(v pcommon.TraceID) { ms.state.AssertMutable() - ms.orig.TraceId = data.TraceID(v) + ms.orig.TraceId = internal.TraceID(v) } // SpanID returns the spanid associated with this SpanLink. @@ -71,17 +69,17 @@ func (ms SpanLink) SpanID() pcommon.SpanID { // SetSpanID replaces the spanid associated with this SpanLink. func (ms SpanLink) SetSpanID(v pcommon.SpanID) { ms.state.AssertMutable() - ms.orig.SpanId = data.SpanID(v) + ms.orig.SpanId = internal.SpanID(v) } // TraceState returns the tracestate associated with this SpanLink. func (ms SpanLink) TraceState() pcommon.TraceState { - return pcommon.TraceState(internal.NewTraceState(&ms.orig.TraceState, ms.state)) + return pcommon.TraceState(internal.NewTraceStateWrapper(&ms.orig.TraceState, ms.state)) } // Attributes returns the Attributes associated with this SpanLink. func (ms SpanLink) Attributes() pcommon.Map { - return pcommon.Map(internal.NewMap(&ms.orig.Attributes, ms.state)) + return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) } // DroppedAttributesCount returns the droppedattributescount associated with this SpanLink. @@ -109,5 +107,5 @@ func (ms SpanLink) SetFlags(v uint32) { // CopyTo copies all properties from the current struct overriding the destination. func (ms SpanLink) CopyTo(dest SpanLink) { dest.state.AssertMutable() - internal.CopyOrigSpan_Link(dest.orig, ms.orig) + internal.CopySpanLink(dest.orig, ms.orig) } diff --git a/pdata/ptrace/generated_spanlink_test.go b/pdata/ptrace/generated_spanlink_test.go index de539d45ce5..ccb485273dd 100644 --- a/pdata/ptrace/generated_spanlink_test.go +++ b/pdata/ptrace/generated_spanlink_test.go @@ -12,8 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - "go.opentelemetry.io/collector/pdata/internal/data" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -27,8 +25,8 @@ func TestSpanLink_MoveTo(t *testing.T) { assert.Equal(t, generateTestSpanLink(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newSpanLink(internal.NewOrigSpan_Link(), sharedState)) }) - assert.Panics(t, func() { newSpanLink(internal.NewOrigSpan_Link(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newSpanLink(internal.NewSpanLink(), sharedState)) }) + assert.Panics(t, func() { newSpanLink(internal.NewSpanLink(), sharedState).MoveTo(dest) }) } func TestSpanLink_CopyTo(t *testing.T) { @@ -41,21 +39,21 @@ func TestSpanLink_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newSpanLink(internal.NewOrigSpan_Link(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newSpanLink(internal.NewSpanLink(), sharedState)) }) } func TestSpanLink_TraceID(t *testing.T) { ms := NewSpanLink() - assert.Equal(t, pcommon.TraceID(data.TraceID([16]byte{})), ms.TraceID()) - testValTraceID := pcommon.TraceID(data.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.TraceID(internal.TraceID([16]byte{})), ms.TraceID()) + testValTraceID := pcommon.TraceID(internal.TraceID([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})) ms.SetTraceID(testValTraceID) assert.Equal(t, testValTraceID, ms.TraceID()) } func TestSpanLink_SpanID(t *testing.T) { ms := NewSpanLink() - assert.Equal(t, pcommon.SpanID(data.SpanID([8]byte{})), ms.SpanID()) - testValSpanID := pcommon.SpanID(data.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) + assert.Equal(t, pcommon.SpanID(internal.SpanID([8]byte{})), ms.SpanID()) + testValSpanID := pcommon.SpanID(internal.SpanID([8]byte{8, 7, 6, 5, 4, 3, 2, 1})) ms.SetSpanID(testValSpanID) assert.Equal(t, testValSpanID, ms.SpanID()) } @@ -63,15 +61,15 @@ func TestSpanLink_SpanID(t *testing.T) { func TestSpanLink_TraceState(t *testing.T) { ms := NewSpanLink() assert.Equal(t, pcommon.NewTraceState(), ms.TraceState()) - ms.orig.TraceState = *internal.GenTestOrigTraceState() - assert.Equal(t, pcommon.TraceState(internal.NewTraceState(internal.GenTestOrigTraceState(), ms.state)), ms.TraceState()) + ms.orig.TraceState = *internal.GenTestTraceState() + assert.Equal(t, pcommon.TraceState(internal.GenTestTraceStateWrapper()), ms.TraceState()) } func TestSpanLink_Attributes(t *testing.T) { ms := NewSpanLink() assert.Equal(t, pcommon.NewMap(), ms.Attributes()) - ms.orig.Attributes = internal.GenerateOrigTestKeyValueSlice() - assert.Equal(t, pcommon.Map(internal.GenerateTestMap()), ms.Attributes()) + ms.orig.Attributes = internal.GenTestKeyValueSlice() + assert.Equal(t, pcommon.Map(internal.GenTestMapWrapper()), ms.Attributes()) } func TestSpanLink_DroppedAttributesCount(t *testing.T) { @@ -81,7 +79,7 @@ func TestSpanLink_DroppedAttributesCount(t *testing.T) { assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpanLink(&otlptrace.Span_Link{}, sharedState).SetDroppedAttributesCount(uint32(13)) }) + assert.Panics(t, func() { newSpanLink(internal.NewSpanLink(), sharedState).SetDroppedAttributesCount(uint32(13)) }) } func TestSpanLink_Flags(t *testing.T) { @@ -91,10 +89,9 @@ func TestSpanLink_Flags(t *testing.T) { assert.Equal(t, uint32(13), ms.Flags()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newSpanLink(&otlptrace.Span_Link{}, sharedState).SetFlags(uint32(13)) }) + assert.Panics(t, func() { newSpanLink(internal.NewSpanLink(), sharedState).SetFlags(uint32(13)) }) } func generateTestSpanLink() SpanLink { - ms := newSpanLink(internal.GenTestOrigSpan_Link(), internal.NewState()) - return ms + return newSpanLink(internal.GenTestSpanLink(), internal.NewState()) } diff --git a/pdata/ptrace/generated_spanlinkslice.go b/pdata/ptrace/generated_spanlinkslice.go index a4626b3f16f..d4f46fdc0a6 100644 --- a/pdata/ptrace/generated_spanlinkslice.go +++ b/pdata/ptrace/generated_spanlinkslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // SpanLinkSlice logically represents a slice of SpanLink. @@ -22,18 +21,18 @@ import ( // Must use NewSpanLinkSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SpanLinkSlice struct { - orig *[]*otlptrace.Span_Link + orig *[]*internal.SpanLink state *internal.State } -func newSpanLinkSlice(orig *[]*otlptrace.Span_Link, state *internal.State) SpanLinkSlice { +func newSpanLinkSlice(orig *[]*internal.SpanLink, state *internal.State) SpanLinkSlice { return SpanLinkSlice{orig: orig, state: state} } // NewSpanLinkSlice creates a SpanLinkSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSpanLinkSlice() SpanLinkSlice { - orig := []*otlptrace.Span_Link(nil) + orig := []*internal.SpanLink(nil) return newSpanLinkSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es SpanLinkSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlptrace.Span_Link, len(*es.orig), newCap) + newOrig := make([]*internal.SpanLink, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es SpanLinkSlice) EnsureCapacity(newCap int) { // It returns the newly added SpanLink. func (es SpanLinkSlice) AppendEmpty() SpanLink { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigSpan_Link()) + *es.orig = append(*es.orig, internal.NewSpanLink()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es SpanLinkSlice) RemoveIf(f func(SpanLink) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigSpan_Link((*es.orig)[i], true) + internal.DeleteSpanLink((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es SpanLinkSlice) CopyTo(dest SpanLinkSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigSpan_LinkSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopySpanLinkPtrSlice(*dest.orig, *es.orig) } // Sort sorts the SpanLink elements within SpanLinkSlice given the diff --git a/pdata/ptrace/generated_spanlinkslice_test.go b/pdata/ptrace/generated_spanlinkslice_test.go index 66960b38300..68793506f7e 100644 --- a/pdata/ptrace/generated_spanlinkslice_test.go +++ b/pdata/ptrace/generated_spanlinkslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestSpanLinkSlice(t *testing.T) { es := NewSpanLinkSlice() assert.Equal(t, 0, es.Len()) - es = newSpanLinkSlice(&[]*otlptrace.Span_Link{}, internal.NewState()) + es = newSpanLinkSlice(&[]*internal.SpanLink{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewSpanLink() @@ -27,7 +26,7 @@ func TestSpanLinkSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigSpan_Link() + (*es.orig)[i] = internal.GenTestSpanLink() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestSpanLinkSlice(t *testing.T) { func TestSpanLinkSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSpanLinkSlice(&[]*otlptrace.Span_Link{}, sharedState) + es := newSpanLinkSlice(&[]*internal.SpanLink{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestSpanLinkSlice_Sort(t *testing.T) { func generateTestSpanLinkSlice() SpanLinkSlice { ms := NewSpanLinkSlice() - *ms.orig = internal.GenerateOrigTestSpan_LinkSlice() + *ms.orig = internal.GenTestSpanLinkPtrSlice() return ms } diff --git a/pdata/ptrace/generated_spanslice.go b/pdata/ptrace/generated_spanslice.go index 7417966fddb..c0027971af5 100644 --- a/pdata/ptrace/generated_spanslice.go +++ b/pdata/ptrace/generated_spanslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // SpanSlice logically represents a slice of Span. @@ -22,18 +21,18 @@ import ( // Must use NewSpanSlice function to create new instances. // Important: zero-initialized instance is not valid for use. type SpanSlice struct { - orig *[]*otlptrace.Span + orig *[]*internal.Span state *internal.State } -func newSpanSlice(orig *[]*otlptrace.Span, state *internal.State) SpanSlice { +func newSpanSlice(orig *[]*internal.Span, state *internal.State) SpanSlice { return SpanSlice{orig: orig, state: state} } // NewSpanSlice creates a SpanSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewSpanSlice() SpanSlice { - orig := []*otlptrace.Span(nil) + orig := []*internal.Span(nil) return newSpanSlice(&orig, internal.NewState()) } @@ -90,7 +89,7 @@ func (es SpanSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlptrace.Span, len(*es.orig), newCap) + newOrig := make([]*internal.Span, len(*es.orig), newCap) copy(newOrig, *es.orig) *es.orig = newOrig } @@ -99,7 +98,7 @@ func (es SpanSlice) EnsureCapacity(newCap int) { // It returns the newly added Span. func (es SpanSlice) AppendEmpty() Span { es.state.AssertMutable() - *es.orig = append(*es.orig, internal.NewOrigSpan()) + *es.orig = append(*es.orig, internal.NewSpan()) return es.At(es.Len() - 1) } @@ -128,7 +127,7 @@ func (es SpanSlice) RemoveIf(f func(Span) bool) { newLen := 0 for i := 0; i < len(*es.orig); i++ { if f(es.At(i)) { - internal.DeleteOrigSpan((*es.orig)[i], true) + internal.DeleteSpan((*es.orig)[i], true) (*es.orig)[i] = nil continue @@ -152,7 +151,7 @@ func (es SpanSlice) CopyTo(dest SpanSlice) { if es.orig == dest.orig { return } - *dest.orig = internal.CopyOrigSpanSlice(*dest.orig, *es.orig) + *dest.orig = internal.CopySpanPtrSlice(*dest.orig, *es.orig) } // Sort sorts the Span elements within SpanSlice given the diff --git a/pdata/ptrace/generated_spanslice_test.go b/pdata/ptrace/generated_spanslice_test.go index d781be5378f..9d3417af34d 100644 --- a/pdata/ptrace/generated_spanslice_test.go +++ b/pdata/ptrace/generated_spanslice_test.go @@ -13,13 +13,12 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestSpanSlice(t *testing.T) { es := NewSpanSlice() assert.Equal(t, 0, es.Len()) - es = newSpanSlice(&[]*otlptrace.Span{}, internal.NewState()) + es = newSpanSlice(&[]*internal.Span{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewSpan() @@ -27,7 +26,7 @@ func TestSpanSlice(t *testing.T) { for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.orig)[i] = internal.GenTestOrigSpan() + (*es.orig)[i] = internal.GenTestSpan() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestSpanSlice(t *testing.T) { func TestSpanSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newSpanSlice(&[]*otlptrace.Span{}, sharedState) + es := newSpanSlice(&[]*internal.Span{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestSpanSlice_Sort(t *testing.T) { func generateTestSpanSlice() SpanSlice { ms := NewSpanSlice() - *ms.orig = internal.GenerateOrigTestSpanSlice() + *ms.orig = internal.GenTestSpanPtrSlice() return ms } diff --git a/pdata/ptrace/generated_status.go b/pdata/ptrace/generated_status.go index e46b45f31b4..da1a8272601 100644 --- a/pdata/ptrace/generated_status.go +++ b/pdata/ptrace/generated_status.go @@ -8,7 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) // Status is an optional final status for this span. Semantically, when Status was not @@ -20,11 +19,11 @@ import ( // Must use NewStatus function to create new instances. // Important: zero-initialized instance is not valid for use. type Status struct { - orig *otlptrace.Status + orig *internal.Status state *internal.State } -func newStatus(orig *otlptrace.Status, state *internal.State) Status { +func newStatus(orig *internal.Status, state *internal.State) Status { return Status{orig: orig, state: state} } @@ -33,7 +32,7 @@ func newStatus(orig *otlptrace.Status, state *internal.State) Status { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewStatus() Status { - return newStatus(internal.NewOrigStatus(), internal.NewState()) + return newStatus(internal.NewStatus(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -45,7 +44,7 @@ func (ms Status) MoveTo(dest Status) { if ms.orig == dest.orig { return } - internal.DeleteOrigStatus(dest.orig, false) + internal.DeleteStatus(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -68,11 +67,11 @@ func (ms Status) Code() StatusCode { // SetCode replaces the code associated with this Status. func (ms Status) SetCode(v StatusCode) { ms.state.AssertMutable() - ms.orig.Code = otlptrace.Status_StatusCode(v) + ms.orig.Code = internal.StatusCode(v) } // CopyTo copies all properties from the current struct overriding the destination. func (ms Status) CopyTo(dest Status) { dest.state.AssertMutable() - internal.CopyOrigStatus(dest.orig, ms.orig) + internal.CopyStatus(dest.orig, ms.orig) } diff --git a/pdata/ptrace/generated_status_test.go b/pdata/ptrace/generated_status_test.go index 67015534f64..f6cce8e877f 100644 --- a/pdata/ptrace/generated_status_test.go +++ b/pdata/ptrace/generated_status_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" ) func TestStatus_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestStatus_MoveTo(t *testing.T) { assert.Equal(t, generateTestStatus(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newStatus(internal.NewOrigStatus(), sharedState)) }) - assert.Panics(t, func() { newStatus(internal.NewOrigStatus(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newStatus(internal.NewStatus(), sharedState)) }) + assert.Panics(t, func() { newStatus(internal.NewStatus(), sharedState).MoveTo(dest) }) } func TestStatus_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestStatus_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newStatus(internal.NewOrigStatus(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newStatus(internal.NewStatus(), sharedState)) }) } func TestStatus_Message(t *testing.T) { @@ -49,18 +48,17 @@ func TestStatus_Message(t *testing.T) { assert.Equal(t, "test_message", ms.Message()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newStatus(&otlptrace.Status{}, sharedState).SetMessage("test_message") }) + assert.Panics(t, func() { newStatus(internal.NewStatus(), sharedState).SetMessage("test_message") }) } func TestStatus_Code(t *testing.T) { ms := NewStatus() - assert.Equal(t, StatusCode(otlptrace.Status_StatusCode(0)), ms.Code()) - testValCode := StatusCode(otlptrace.Status_StatusCode(1)) + assert.Equal(t, StatusCode(internal.StatusCode_STATUS_CODE_UNSET), ms.Code()) + testValCode := StatusCode(internal.StatusCode_STATUS_CODE_OK) ms.SetCode(testValCode) assert.Equal(t, testValCode, ms.Code()) } func generateTestStatus() Status { - ms := newStatus(internal.GenTestOrigStatus(), internal.NewState()) - return ms + return newStatus(internal.GenTestStatus(), internal.NewState()) } diff --git a/pdata/ptrace/generated_traces.go b/pdata/ptrace/generated_traces.go index 4334e8c79c0..5e69bc03f27 100644 --- a/pdata/ptrace/generated_traces.go +++ b/pdata/ptrace/generated_traces.go @@ -8,7 +8,6 @@ package ptrace import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" ) // Traces is the top-level struct that is propagated through the traces pipeline. @@ -19,10 +18,10 @@ import ( // // Must use NewTraces function to create new instances. // Important: zero-initialized instance is not valid for use. -type Traces internal.Traces +type Traces internal.TracesWrapper -func newTraces(orig *otlpcollectortrace.ExportTraceServiceRequest, state *internal.State) Traces { - return Traces(internal.NewTraces(orig, state)) +func newTraces(orig *internal.ExportTraceServiceRequest, state *internal.State) Traces { + return Traces(internal.NewTracesWrapper(orig, state)) } // NewTraces creates a new empty Traces. @@ -30,7 +29,7 @@ func newTraces(orig *otlpcollectortrace.ExportTraceServiceRequest, state *intern // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewTraces() Traces { - return newTraces(internal.NewOrigExportTraceServiceRequest(), internal.NewState()) + return newTraces(internal.NewExportTraceServiceRequest(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -42,7 +41,7 @@ func (ms Traces) MoveTo(dest Traces) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigExportTraceServiceRequest(dest.getOrig(), false) + internal.DeleteExportTraceServiceRequest(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } @@ -54,13 +53,13 @@ func (ms Traces) ResourceSpans() ResourceSpansSlice { // CopyTo copies all properties from the current struct overriding the destination. func (ms Traces) CopyTo(dest Traces) { dest.getState().AssertMutable() - internal.CopyOrigExportTraceServiceRequest(dest.getOrig(), ms.getOrig()) + internal.CopyExportTraceServiceRequest(dest.getOrig(), ms.getOrig()) } -func (ms Traces) getOrig() *otlpcollectortrace.ExportTraceServiceRequest { - return internal.GetOrigTraces(internal.Traces(ms)) +func (ms Traces) getOrig() *internal.ExportTraceServiceRequest { + return internal.GetTracesOrig(internal.TracesWrapper(ms)) } func (ms Traces) getState() *internal.State { - return internal.GetTracesState(internal.Traces(ms)) + return internal.GetTracesState(internal.TracesWrapper(ms)) } diff --git a/pdata/ptrace/generated_traces_test.go b/pdata/ptrace/generated_traces_test.go index 81435e5030c..2512f488295 100644 --- a/pdata/ptrace/generated_traces_test.go +++ b/pdata/ptrace/generated_traces_test.go @@ -24,8 +24,8 @@ func TestTraces_MoveTo(t *testing.T) { assert.Equal(t, generateTestTraces(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newTraces(internal.NewOrigExportTraceServiceRequest(), sharedState)) }) - assert.Panics(t, func() { newTraces(internal.NewOrigExportTraceServiceRequest(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newTraces(internal.NewExportTraceServiceRequest(), sharedState)) }) + assert.Panics(t, func() { newTraces(internal.NewExportTraceServiceRequest(), sharedState).MoveTo(dest) }) } func TestTraces_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestTraces_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newTraces(internal.NewOrigExportTraceServiceRequest(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newTraces(internal.NewExportTraceServiceRequest(), sharedState)) }) } func TestTraces_ResourceSpans(t *testing.T) { ms := NewTraces() assert.Equal(t, NewResourceSpansSlice(), ms.ResourceSpans()) - ms.getOrig().ResourceSpans = internal.GenerateOrigTestResourceSpansSlice() + ms.getOrig().ResourceSpans = internal.GenTestResourceSpansPtrSlice() assert.Equal(t, generateTestResourceSpansSlice(), ms.ResourceSpans()) } func generateTestTraces() Traces { - ms := newTraces(internal.GenTestOrigExportTraceServiceRequest(), internal.NewState()) - return ms + return newTraces(internal.GenTestExportTraceServiceRequest(), internal.NewState()) } diff --git a/pdata/ptrace/json.go b/pdata/ptrace/json.go index 1c1cab317dd..a6f0dd36f41 100644 --- a/pdata/ptrace/json.go +++ b/pdata/ptrace/json.go @@ -6,7 +6,6 @@ package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -18,7 +17,7 @@ type JSONMarshaler struct{} func (*JSONMarshaler) MarshalTraces(td Traces) ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportTraceServiceRequest(td.getOrig(), dest) + td.getOrig().MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -33,7 +32,7 @@ func (*JSONUnmarshaler) UnmarshalTraces(buf []byte) (Traces, error) { iter := json.BorrowIterator(buf) defer json.ReturnIterator(iter) td := NewTraces() - internal.UnmarshalJSONOrigExportTraceServiceRequest(td.getOrig(), iter) + td.getOrig().UnmarshalJSON(iter) if iter.Error() != nil { return Traces{}, iter.Error() } diff --git a/pdata/ptrace/pb.go b/pdata/ptrace/pb.go index 1502f818a96..c9a02b2899a 100644 --- a/pdata/ptrace/pb.go +++ b/pdata/ptrace/pb.go @@ -3,42 +3,38 @@ package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" -import ( - "go.opentelemetry.io/collector/pdata/internal" -) - var _ MarshalSizer = (*ProtoMarshaler)(nil) type ProtoMarshaler struct{} func (e *ProtoMarshaler) MarshalTraces(td Traces) ([]byte, error) { - size := internal.SizeProtoOrigExportTraceServiceRequest(td.getOrig()) + size := td.getOrig().SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportTraceServiceRequest(td.getOrig(), buf) + _ = td.getOrig().MarshalProto(buf) return buf, nil } func (e *ProtoMarshaler) TracesSize(td Traces) int { - return internal.SizeProtoOrigExportTraceServiceRequest(td.getOrig()) + return td.getOrig().SizeProto() } func (e *ProtoMarshaler) ResourceSpansSize(td ResourceSpans) int { - return internal.SizeProtoOrigResourceSpans(td.orig) + return td.orig.SizeProto() } func (e *ProtoMarshaler) ScopeSpansSize(td ScopeSpans) int { - return internal.SizeProtoOrigScopeSpans(td.orig) + return td.orig.SizeProto() } func (e *ProtoMarshaler) SpanSize(td Span) int { - return internal.SizeProtoOrigSpan(td.orig) + return td.orig.SizeProto() } type ProtoUnmarshaler struct{} func (d *ProtoUnmarshaler) UnmarshalTraces(buf []byte) (Traces, error) { td := NewTraces() - err := internal.UnmarshalProtoOrigExportTraceServiceRequest(td.getOrig(), buf) + err := td.getOrig().UnmarshalProto(buf) if err != nil { return Traces{}, err } diff --git a/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess.go b/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess.go index d5f58207052..092d23c8d7d 100644 --- a/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess.go +++ b/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess.go @@ -8,7 +8,6 @@ package ptraceotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" ) // ExportPartialSuccess represents the details of a partially successful export request. @@ -19,11 +18,11 @@ import ( // Must use NewExportPartialSuccess function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportPartialSuccess struct { - orig *otlpcollectortrace.ExportTracePartialSuccess + orig *internal.ExportTracePartialSuccess state *internal.State } -func newExportPartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, state *internal.State) ExportPartialSuccess { +func newExportPartialSuccess(orig *internal.ExportTracePartialSuccess, state *internal.State) ExportPartialSuccess { return ExportPartialSuccess{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportPartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess, // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportPartialSuccess() ExportPartialSuccess { - return newExportPartialSuccess(internal.NewOrigExportTracePartialSuccess(), internal.NewState()) + return newExportPartialSuccess(internal.NewExportTracePartialSuccess(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportPartialSuccess) MoveTo(dest ExportPartialSuccess) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportTracePartialSuccess(dest.orig, false) + internal.DeleteExportTracePartialSuccess(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -73,5 +72,5 @@ func (ms ExportPartialSuccess) SetErrorMessage(v string) { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportPartialSuccess) CopyTo(dest ExportPartialSuccess) { dest.state.AssertMutable() - internal.CopyOrigExportTracePartialSuccess(dest.orig, ms.orig) + internal.CopyExportTracePartialSuccess(dest.orig, ms.orig) } diff --git a/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess_test.go b/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess_test.go index 1647333db09..8bb1378843e 100644 --- a/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess_test.go +++ b/pdata/ptrace/ptraceotlp/generated_exportpartialsuccess_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" ) func TestExportPartialSuccess_MoveTo(t *testing.T) { @@ -25,8 +24,8 @@ func TestExportPartialSuccess_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportPartialSuccess(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewOrigExportTracePartialSuccess(), sharedState)) }) - assert.Panics(t, func() { newExportPartialSuccess(internal.NewOrigExportTracePartialSuccess(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExportPartialSuccess(internal.NewExportTracePartialSuccess(), sharedState)) }) + assert.Panics(t, func() { newExportPartialSuccess(internal.NewExportTracePartialSuccess(), sharedState).MoveTo(dest) }) } func TestExportPartialSuccess_CopyTo(t *testing.T) { @@ -39,7 +38,7 @@ func TestExportPartialSuccess_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewOrigExportTracePartialSuccess(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportPartialSuccess(internal.NewExportTracePartialSuccess(), sharedState)) }) } func TestExportPartialSuccess_RejectedSpans(t *testing.T) { @@ -50,7 +49,7 @@ func TestExportPartialSuccess_RejectedSpans(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectortrace.ExportTracePartialSuccess{}, sharedState).SetRejectedSpans(int64(13)) + newExportPartialSuccess(internal.NewExportTracePartialSuccess(), sharedState).SetRejectedSpans(int64(13)) }) } @@ -62,11 +61,10 @@ func TestExportPartialSuccess_ErrorMessage(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() assert.Panics(t, func() { - newExportPartialSuccess(&otlpcollectortrace.ExportTracePartialSuccess{}, sharedState).SetErrorMessage("test_errormessage") + newExportPartialSuccess(internal.NewExportTracePartialSuccess(), sharedState).SetErrorMessage("test_errormessage") }) } func generateTestExportPartialSuccess() ExportPartialSuccess { - ms := newExportPartialSuccess(internal.GenTestOrigExportTracePartialSuccess(), internal.NewState()) - return ms + return newExportPartialSuccess(internal.GenTestExportTracePartialSuccess(), internal.NewState()) } diff --git a/pdata/ptrace/ptraceotlp/generated_exportresponse.go b/pdata/ptrace/ptraceotlp/generated_exportresponse.go index be9d94eeafe..98e123c8e72 100644 --- a/pdata/ptrace/ptraceotlp/generated_exportresponse.go +++ b/pdata/ptrace/ptraceotlp/generated_exportresponse.go @@ -8,7 +8,6 @@ package ptraceotlp import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" ) // ExportResponse represents the response for gRPC/HTTP client/server. @@ -19,11 +18,11 @@ import ( // Must use NewExportResponse function to create new instances. // Important: zero-initialized instance is not valid for use. type ExportResponse struct { - orig *otlpcollectortrace.ExportTraceServiceResponse + orig *internal.ExportTraceServiceResponse state *internal.State } -func newExportResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, state *internal.State) ExportResponse { +func newExportResponse(orig *internal.ExportTraceServiceResponse, state *internal.State) ExportResponse { return ExportResponse{orig: orig, state: state} } @@ -32,7 +31,7 @@ func newExportResponse(orig *otlpcollectortrace.ExportTraceServiceResponse, stat // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewExportResponse() ExportResponse { - return newExportResponse(internal.NewOrigExportTraceServiceResponse(), internal.NewState()) + return newExportResponse(internal.NewExportTraceServiceResponse(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -44,7 +43,7 @@ func (ms ExportResponse) MoveTo(dest ExportResponse) { if ms.orig == dest.orig { return } - internal.DeleteOrigExportTraceServiceResponse(dest.orig, false) + internal.DeleteExportTraceServiceResponse(dest.orig, false) *dest.orig, *ms.orig = *ms.orig, *dest.orig } @@ -56,5 +55,5 @@ func (ms ExportResponse) PartialSuccess() ExportPartialSuccess { // CopyTo copies all properties from the current struct overriding the destination. func (ms ExportResponse) CopyTo(dest ExportResponse) { dest.state.AssertMutable() - internal.CopyOrigExportTraceServiceResponse(dest.orig, ms.orig) + internal.CopyExportTraceServiceResponse(dest.orig, ms.orig) } diff --git a/pdata/ptrace/ptraceotlp/generated_exportresponse_test.go b/pdata/ptrace/ptraceotlp/generated_exportresponse_test.go index 0a785dc4215..543c42ebb5f 100644 --- a/pdata/ptrace/ptraceotlp/generated_exportresponse_test.go +++ b/pdata/ptrace/ptraceotlp/generated_exportresponse_test.go @@ -24,8 +24,8 @@ func TestExportResponse_MoveTo(t *testing.T) { assert.Equal(t, generateTestExportResponse(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewOrigExportTraceServiceResponse(), sharedState)) }) - assert.Panics(t, func() { newExportResponse(internal.NewOrigExportTraceServiceResponse(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newExportResponse(internal.NewExportTraceServiceResponse(), sharedState)) }) + assert.Panics(t, func() { newExportResponse(internal.NewExportTraceServiceResponse(), sharedState).MoveTo(dest) }) } func TestExportResponse_CopyTo(t *testing.T) { @@ -38,17 +38,16 @@ func TestExportResponse_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewOrigExportTraceServiceResponse(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newExportResponse(internal.NewExportTraceServiceResponse(), sharedState)) }) } func TestExportResponse_PartialSuccess(t *testing.T) { ms := NewExportResponse() assert.Equal(t, NewExportPartialSuccess(), ms.PartialSuccess()) - ms.orig.PartialSuccess = *internal.GenTestOrigExportTracePartialSuccess() + ms.orig.PartialSuccess = *internal.GenTestExportTracePartialSuccess() assert.Equal(t, generateTestExportPartialSuccess(), ms.PartialSuccess()) } func generateTestExportResponse() ExportResponse { - ms := newExportResponse(internal.GenTestOrigExportTraceServiceResponse(), internal.NewState()) - return ms + return newExportResponse(internal.GenTestExportTraceServiceResponse(), internal.NewState()) } diff --git a/pdata/ptrace/ptraceotlp/grpc.go b/pdata/ptrace/ptraceotlp/grpc.go index 5479976abf6..1314a2e156f 100644 --- a/pdata/ptrace/ptraceotlp/grpc.go +++ b/pdata/ptrace/ptraceotlp/grpc.go @@ -11,8 +11,7 @@ import ( "google.golang.org/grpc/status" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - _ "go.opentelemetry.io/collector/pdata/internal/grpcencoding" // enforces custom gRPC encoding to be loaded. + "go.opentelemetry.io/collector/pdata/internal/otelgrpc" "go.opentelemetry.io/collector/pdata/internal/otlp" ) @@ -32,11 +31,11 @@ type GRPCClient interface { // NewGRPCClient returns a new GRPCClient connected using the given connection. func NewGRPCClient(cc *grpc.ClientConn) GRPCClient { - return &grpcClient{rawClient: otlpcollectortrace.NewTraceServiceClient(cc)} + return &grpcClient{rawClient: otelgrpc.NewTraceServiceClient(cc)} } type grpcClient struct { - rawClient otlpcollectortrace.TraceServiceClient + rawClient otelgrpc.TraceServiceClient } // Export implements the Client interface. @@ -76,14 +75,14 @@ func (*UnimplementedGRPCServer) unexported() {} // RegisterGRPCServer registers the GRPCServer to the grpc.Server. func RegisterGRPCServer(s *grpc.Server, srv GRPCServer) { - otlpcollectortrace.RegisterTraceServiceServer(s, &rawTracesServer{srv: srv}) + otelgrpc.RegisterTraceServiceServer(s, &rawTracesServer{srv: srv}) } type rawTracesServer struct { srv GRPCServer } -func (s rawTracesServer) Export(ctx context.Context, request *otlpcollectortrace.ExportTraceServiceRequest) (*otlpcollectortrace.ExportTraceServiceResponse, error) { +func (s rawTracesServer) Export(ctx context.Context, request *internal.ExportTraceServiceRequest) (*internal.ExportTraceServiceResponse, error) { otlp.MigrateTraces(request.ResourceSpans) rsp, err := s.srv.Export(ctx, ExportRequest{orig: request, state: internal.NewState()}) return rsp.orig, err diff --git a/pdata/ptrace/ptraceotlp/request.go b/pdata/ptrace/ptraceotlp/request.go index 0408713c57a..618c592584f 100644 --- a/pdata/ptrace/ptraceotlp/request.go +++ b/pdata/ptrace/ptraceotlp/request.go @@ -7,7 +7,6 @@ import ( "slices" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/ptrace" @@ -16,14 +15,14 @@ import ( // ExportRequest represents the request for gRPC/HTTP client/server. // It's a wrapper for ptrace.Traces data. type ExportRequest struct { - orig *otlpcollectortrace.ExportTraceServiceRequest + orig *internal.ExportTraceServiceRequest state *internal.State } // NewExportRequest returns an empty ExportRequest. func NewExportRequest() ExportRequest { return ExportRequest{ - orig: &otlpcollectortrace.ExportTraceServiceRequest{}, + orig: &internal.ExportTraceServiceRequest{}, state: internal.NewState(), } } @@ -33,22 +32,22 @@ func NewExportRequest() ExportRequest { // any changes to the provided Traces struct will be reflected in the ExportRequest and vice versa. func NewExportRequestFromTraces(td ptrace.Traces) ExportRequest { return ExportRequest{ - orig: internal.GetOrigTraces(internal.Traces(td)), - state: internal.GetTracesState(internal.Traces(td)), + orig: internal.GetTracesOrig(internal.TracesWrapper(td)), + state: internal.GetTracesState(internal.TracesWrapper(td)), } } // MarshalProto marshals ExportRequest into proto bytes. func (ms ExportRequest) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportTraceServiceRequest(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportTraceServiceRequest(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportRequest from proto bytes. func (ms ExportRequest) UnmarshalProto(data []byte) error { - err := internal.UnmarshalProtoOrigExportTraceServiceRequest(ms.orig, data) + err := ms.orig.UnmarshalProto(data) if err != nil { return err } @@ -60,7 +59,7 @@ func (ms ExportRequest) UnmarshalProto(data []byte) error { func (ms ExportRequest) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportTraceServiceRequest(ms.orig, dest) + ms.orig.MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -71,10 +70,10 @@ func (ms ExportRequest) MarshalJSON() ([]byte, error) { func (ms ExportRequest) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportTraceServiceRequest(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } func (ms ExportRequest) Traces() ptrace.Traces { - return ptrace.Traces(internal.NewTraces(ms.orig, ms.state)) + return ptrace.Traces(internal.NewTracesWrapper(ms.orig, ms.state)) } diff --git a/pdata/ptrace/ptraceotlp/request_test.go b/pdata/ptrace/ptraceotlp/request_test.go index d73e882b2e6..10502187729 100644 --- a/pdata/ptrace/ptraceotlp/request_test.go +++ b/pdata/ptrace/ptraceotlp/request_test.go @@ -14,6 +14,7 @@ import ( goproto "google.golang.org/protobuf/proto" "go.opentelemetry.io/collector/pdata/internal" + "go.opentelemetry.io/collector/pdata/internal/otlp" "go.opentelemetry.io/collector/pdata/ptrace" ) @@ -65,7 +66,7 @@ func TestTracesProtoWireCompatibility(t *testing.T) { // this repository are wire compatible. // Generate Traces as pdata struct. - td := NewExportRequestFromTraces(ptrace.Traces(internal.NewTraces(internal.GenTestOrigExportTraceServiceRequest(), internal.NewState()))) + td := NewExportRequestFromTraces(ptrace.Traces(internal.GenTestTracesWrapper())) // Marshal its underlying ProtoBuf to wire. wire1, err := td.MarshalProto() @@ -89,5 +90,7 @@ func TestTracesProtoWireCompatibility(t *testing.T) { // Now compare that the original and final ProtoBuf messages are the same. // This proves that goproto and gogoproto marshaling/unmarshaling are wire compatible. + // Migration logic will run, so run it on the original message as well. + otlp.MigrateTraces(td.orig.ResourceSpans) assert.Equal(t, td, td2) } diff --git a/pdata/ptrace/ptraceotlp/response.go b/pdata/ptrace/ptraceotlp/response.go index 7285a6346d0..46264725929 100644 --- a/pdata/ptrace/ptraceotlp/response.go +++ b/pdata/ptrace/ptraceotlp/response.go @@ -6,28 +6,27 @@ package ptraceotlp // import "go.opentelemetry.io/collector/pdata/ptrace/ptraceo import ( "slices" - "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/internal/json" ) // MarshalProto marshals ExportResponse into proto bytes. func (ms ExportResponse) MarshalProto() ([]byte, error) { - size := internal.SizeProtoOrigExportTraceServiceResponse(ms.orig) + size := ms.orig.SizeProto() buf := make([]byte, size) - _ = internal.MarshalProtoOrigExportTraceServiceResponse(ms.orig, buf) + _ = ms.orig.MarshalProto(buf) return buf, nil } // UnmarshalProto unmarshalls ExportResponse from proto bytes. func (ms ExportResponse) UnmarshalProto(data []byte) error { - return internal.UnmarshalProtoOrigExportTraceServiceResponse(ms.orig, data) + return ms.orig.UnmarshalProto(data) } // MarshalJSON marshals ExportResponse into JSON bytes. func (ms ExportResponse) MarshalJSON() ([]byte, error) { dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigExportTraceServiceResponse(ms.orig, dest) + ms.orig.MarshalJSON(dest) return slices.Clone(dest.Buffer()), dest.Error() } @@ -35,6 +34,6 @@ func (ms ExportResponse) MarshalJSON() ([]byte, error) { func (ms ExportResponse) UnmarshalJSON(data []byte) error { iter := json.BorrowIterator(data) defer json.ReturnIterator(iter) - internal.UnmarshalJSONOrigExportTraceServiceResponse(ms.orig, iter) + ms.orig.UnmarshalJSON(iter) return iter.Error() } diff --git a/pdata/ptrace/span_kind.go b/pdata/ptrace/span_kind.go index 561d82cfffa..bb1702ffe15 100644 --- a/pdata/ptrace/span_kind.go +++ b/pdata/ptrace/span_kind.go @@ -4,7 +4,7 @@ package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // SpanKind is the type of span. Can be used to specify additional relationships between spans @@ -13,25 +13,25 @@ type SpanKind int32 const ( // SpanKindUnspecified represents that the SpanKind is unspecified, it MUST NOT be used. - SpanKindUnspecified = SpanKind(otlptrace.Span_SPAN_KIND_UNSPECIFIED) + SpanKindUnspecified = SpanKind(internal.SpanKind_SPAN_KIND_UNSPECIFIED) // SpanKindInternal indicates that the span represents an internal operation within an application, // as opposed to an operation happening at the boundaries. Default value. - SpanKindInternal = SpanKind(otlptrace.Span_SPAN_KIND_INTERNAL) + SpanKindInternal = SpanKind(internal.SpanKind_SPAN_KIND_INTERNAL) // SpanKindServer indicates that the span covers server-side handling of an RPC or other // remote network request. - SpanKindServer = SpanKind(otlptrace.Span_SPAN_KIND_SERVER) + SpanKindServer = SpanKind(internal.SpanKind_SPAN_KIND_SERVER) // SpanKindClient indicates that the span describes a request to some remote service. - SpanKindClient = SpanKind(otlptrace.Span_SPAN_KIND_CLIENT) + SpanKindClient = SpanKind(internal.SpanKind_SPAN_KIND_CLIENT) // SpanKindProducer indicates that the span describes a producer sending a message to a broker. // Unlike CLIENT and SERVER, there is often no direct critical path latency relationship // between producer and consumer spans. // A PRODUCER span ends when the message was accepted by the broker while the logical processing of // the message might span a much longer time. - SpanKindProducer = SpanKind(otlptrace.Span_SPAN_KIND_PRODUCER) + SpanKindProducer = SpanKind(internal.SpanKind_SPAN_KIND_PRODUCER) // SpanKindConsumer indicates that the span describes consumer receiving a message from a broker. // Like the PRODUCER kind, there is often no direct critical path latency relationship between // producer and consumer spans. - SpanKindConsumer = SpanKind(otlptrace.Span_SPAN_KIND_CONSUMER) + SpanKindConsumer = SpanKind(internal.SpanKind_SPAN_KIND_CONSUMER) ) // String returns the string representation of the SpanKind. diff --git a/pdata/ptrace/status_code.go b/pdata/ptrace/status_code.go index 18a21f56ba8..d1da464363e 100644 --- a/pdata/ptrace/status_code.go +++ b/pdata/ptrace/status_code.go @@ -4,7 +4,7 @@ package ptrace // import "go.opentelemetry.io/collector/pdata/ptrace" import ( - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" + "go.opentelemetry.io/collector/pdata/internal" ) // StatusCode mirrors the codes defined at @@ -12,9 +12,9 @@ import ( type StatusCode int32 const ( - StatusCodeUnset = StatusCode(otlptrace.Status_STATUS_CODE_UNSET) - StatusCodeOk = StatusCode(otlptrace.Status_STATUS_CODE_OK) - StatusCodeError = StatusCode(otlptrace.Status_STATUS_CODE_ERROR) + StatusCodeUnset = StatusCode(internal.StatusCode_STATUS_CODE_UNSET) + StatusCodeOk = StatusCode(internal.StatusCode_STATUS_CODE_OK) + StatusCodeError = StatusCode(internal.StatusCode_STATUS_CODE_ERROR) ) // String returns the string representation of the StatusCode. diff --git a/pdata/ptrace/traces_test.go b/pdata/ptrace/traces_test.go index 2860bb2dae2..53a3a0c9e88 100644 --- a/pdata/ptrace/traces_test.go +++ b/pdata/ptrace/traces_test.go @@ -11,8 +11,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/internal" - otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" - otlptrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -41,22 +39,22 @@ func TestSpanCount(t *testing.T) { } func TestSpanCountWithEmpty(t *testing.T) { - assert.Equal(t, 0, newTraces(&otlpcollectortrace.ExportTraceServiceRequest{ - ResourceSpans: []*otlptrace.ResourceSpans{{}}, + assert.Equal(t, 0, newTraces(&internal.ExportTraceServiceRequest{ + ResourceSpans: []*internal.ResourceSpans{{}}, }, new(internal.State)).SpanCount()) - assert.Equal(t, 0, newTraces(&otlpcollectortrace.ExportTraceServiceRequest{ - ResourceSpans: []*otlptrace.ResourceSpans{ + assert.Equal(t, 0, newTraces(&internal.ExportTraceServiceRequest{ + ResourceSpans: []*internal.ResourceSpans{ { - ScopeSpans: []*otlptrace.ScopeSpans{{}}, + ScopeSpans: []*internal.ScopeSpans{{}}, }, }, }, new(internal.State)).SpanCount()) - assert.Equal(t, 1, newTraces(&otlpcollectortrace.ExportTraceServiceRequest{ - ResourceSpans: []*otlptrace.ResourceSpans{ + assert.Equal(t, 1, newTraces(&internal.ExportTraceServiceRequest{ + ResourceSpans: []*internal.ResourceSpans{ { - ScopeSpans: []*otlptrace.ScopeSpans{ + ScopeSpans: []*internal.ScopeSpans{ { - Spans: []*otlptrace.Span{{}}, + Spans: []*internal.Span{{}}, }, }, }, diff --git a/pdata/testdata/go.mod b/pdata/testdata/go.mod index f7358c0ab81..4cbee805566 100644 --- a/pdata/testdata/go.mod +++ b/pdata/testdata/go.mod @@ -8,19 +8,12 @@ require ( ) require ( - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect ) replace go.opentelemetry.io/collector/pdata => ../ diff --git a/pdata/testdata/go.sum b/pdata/testdata/go.sum index 252558d6fff..a40fe172bfc 100644 --- a/pdata/testdata/go.sum +++ b/pdata/testdata/go.sum @@ -1,25 +1,11 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -32,20 +18,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= go.opentelemetry.io/proto/slim/otlp v1.8.0/go.mod h1:Yaa5fjYm1SMCq0hG0x/87wV1MP9H5xDuG/1+AhvBcsI= go.opentelemetry.io/proto/slim/otlp/collector/profiles/v1development v0.1.0 h1:Uc+elixz922LHx5colXGi1ORbsW8DTIGM+gg+D9V7HE= @@ -56,43 +28,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pdata/xpdata/entity/generated_entityref.go b/pdata/xpdata/entity/generated_entityref.go index a56e7d93d8e..d3c1aa3d805 100644 --- a/pdata/xpdata/entity/generated_entityref.go +++ b/pdata/xpdata/entity/generated_entityref.go @@ -8,7 +8,6 @@ package entity import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -17,10 +16,10 @@ import ( // // Must use NewEntityRef function to create new instances. // Important: zero-initialized instance is not valid for use. -type EntityRef internal.EntityRef +type EntityRef internal.EntityRefWrapper -func newEntityRef(orig *otlpcommon.EntityRef, state *internal.State) EntityRef { - return EntityRef(internal.NewEntityRef(orig, state)) +func newEntityRef(orig *internal.EntityRef, state *internal.State) EntityRef { + return EntityRef(internal.NewEntityRefWrapper(orig, state)) } // NewEntityRef creates a new empty EntityRef. @@ -28,7 +27,7 @@ func newEntityRef(orig *otlpcommon.EntityRef, state *internal.State) EntityRef { // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, // OR directly access the member if this is embedded in another struct. func NewEntityRef() EntityRef { - return newEntityRef(internal.NewOrigEntityRef(), internal.NewState()) + return newEntityRef(internal.NewEntityRef(), internal.NewState()) } // MoveTo moves all properties from the current struct overriding the destination and @@ -40,7 +39,7 @@ func (ms EntityRef) MoveTo(dest EntityRef) { if ms.getOrig() == dest.getOrig() { return } - internal.DeleteOrigEntityRef(dest.getOrig(), false) + internal.DeleteEntityRef(dest.getOrig(), false) *dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() } @@ -68,24 +67,24 @@ func (ms EntityRef) SetType(v string) { // IdKeys returns the IdKeys associated with this EntityRef. func (ms EntityRef) IdKeys() pcommon.StringSlice { - return pcommon.StringSlice(internal.NewStringSlice(&ms.getOrig().IdKeys, ms.getState())) + return pcommon.StringSlice(internal.NewStringSliceWrapper(&ms.getOrig().IdKeys, ms.getState())) } // DescriptionKeys returns the DescriptionKeys associated with this EntityRef. func (ms EntityRef) DescriptionKeys() pcommon.StringSlice { - return pcommon.StringSlice(internal.NewStringSlice(&ms.getOrig().DescriptionKeys, ms.getState())) + return pcommon.StringSlice(internal.NewStringSliceWrapper(&ms.getOrig().DescriptionKeys, ms.getState())) } // CopyTo copies all properties from the current struct overriding the destination. func (ms EntityRef) CopyTo(dest EntityRef) { dest.getState().AssertMutable() - internal.CopyOrigEntityRef(dest.getOrig(), ms.getOrig()) + internal.CopyEntityRef(dest.getOrig(), ms.getOrig()) } -func (ms EntityRef) getOrig() *otlpcommon.EntityRef { - return internal.GetOrigEntityRef(internal.EntityRef(ms)) +func (ms EntityRef) getOrig() *internal.EntityRef { + return internal.GetEntityRefOrig(internal.EntityRefWrapper(ms)) } func (ms EntityRef) getState() *internal.State { - return internal.GetEntityRefState(internal.EntityRef(ms)) + return internal.GetEntityRefState(internal.EntityRefWrapper(ms)) } diff --git a/pdata/xpdata/entity/generated_entityref_test.go b/pdata/xpdata/entity/generated_entityref_test.go index 29822261d9f..0bfc58204aa 100644 --- a/pdata/xpdata/entity/generated_entityref_test.go +++ b/pdata/xpdata/entity/generated_entityref_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -26,8 +25,8 @@ func TestEntityRef_MoveTo(t *testing.T) { assert.Equal(t, generateTestEntityRef(), dest) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.MoveTo(newEntityRef(internal.NewOrigEntityRef(), sharedState)) }) - assert.Panics(t, func() { newEntityRef(internal.NewOrigEntityRef(), sharedState).MoveTo(dest) }) + assert.Panics(t, func() { ms.MoveTo(newEntityRef(internal.NewEntityRef(), sharedState)) }) + assert.Panics(t, func() { newEntityRef(internal.NewEntityRef(), sharedState).MoveTo(dest) }) } func TestEntityRef_CopyTo(t *testing.T) { @@ -40,7 +39,7 @@ func TestEntityRef_CopyTo(t *testing.T) { assert.Equal(t, orig, ms) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { ms.CopyTo(newEntityRef(internal.NewOrigEntityRef(), sharedState)) }) + assert.Panics(t, func() { ms.CopyTo(newEntityRef(internal.NewEntityRef(), sharedState)) }) } func TestEntityRef_SchemaUrl(t *testing.T) { @@ -50,7 +49,7 @@ func TestEntityRef_SchemaUrl(t *testing.T) { assert.Equal(t, "test_schemaurl", ms.SchemaUrl()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newEntityRef(&otlpcommon.EntityRef{}, sharedState).SetSchemaUrl("test_schemaurl") }) + assert.Panics(t, func() { newEntityRef(internal.NewEntityRef(), sharedState).SetSchemaUrl("test_schemaurl") }) } func TestEntityRef_Type(t *testing.T) { @@ -60,24 +59,23 @@ func TestEntityRef_Type(t *testing.T) { assert.Equal(t, "test_type", ms.Type()) sharedState := internal.NewState() sharedState.MarkReadOnly() - assert.Panics(t, func() { newEntityRef(&otlpcommon.EntityRef{}, sharedState).SetType("test_type") }) + assert.Panics(t, func() { newEntityRef(internal.NewEntityRef(), sharedState).SetType("test_type") }) } func TestEntityRef_IdKeys(t *testing.T) { ms := NewEntityRef() assert.Equal(t, pcommon.NewStringSlice(), ms.IdKeys()) - ms.getOrig().IdKeys = internal.GenerateOrigTestStringSlice() - assert.Equal(t, pcommon.StringSlice(internal.GenerateTestStringSlice()), ms.IdKeys()) + ms.getOrig().IdKeys = internal.GenTestStringSlice() + assert.Equal(t, pcommon.StringSlice(internal.GenTestStringSliceWrapper()), ms.IdKeys()) } func TestEntityRef_DescriptionKeys(t *testing.T) { ms := NewEntityRef() assert.Equal(t, pcommon.NewStringSlice(), ms.DescriptionKeys()) - ms.getOrig().DescriptionKeys = internal.GenerateOrigTestStringSlice() - assert.Equal(t, pcommon.StringSlice(internal.GenerateTestStringSlice()), ms.DescriptionKeys()) + ms.getOrig().DescriptionKeys = internal.GenTestStringSlice() + assert.Equal(t, pcommon.StringSlice(internal.GenTestStringSliceWrapper()), ms.DescriptionKeys()) } func generateTestEntityRef() EntityRef { - ms := newEntityRef(internal.GenTestOrigEntityRef(), internal.NewState()) - return ms + return newEntityRef(internal.GenTestEntityRef(), internal.NewState()) } diff --git a/pdata/xpdata/entity/generated_entityrefslice.go b/pdata/xpdata/entity/generated_entityrefslice.go index a5c4cc1ffcd..b1815e0339e 100644 --- a/pdata/xpdata/entity/generated_entityrefslice.go +++ b/pdata/xpdata/entity/generated_entityrefslice.go @@ -11,7 +11,6 @@ import ( "sort" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) // EntityRefSlice logically represents a slice of EntityRef. @@ -21,16 +20,16 @@ import ( // // Must use NewEntityRefSlice function to create new instances. // Important: zero-initialized instance is not valid for use. -type EntityRefSlice internal.EntityRefSlice +type EntityRefSlice internal.EntityRefSliceWrapper -func newEntityRefSlice(orig *[]*otlpcommon.EntityRef, state *internal.State) EntityRefSlice { - return EntityRefSlice(internal.NewEntityRefSlice(orig, state)) +func newEntityRefSlice(orig *[]*internal.EntityRef, state *internal.State) EntityRefSlice { + return EntityRefSlice(internal.NewEntityRefSliceWrapper(orig, state)) } // NewEntityRefSlice creates a EntityRefSlice with 0 elements. // Can use "EnsureCapacity" to initialize with a given capacity. func NewEntityRefSlice() EntityRefSlice { - orig := []*otlpcommon.EntityRef(nil) + orig := []*internal.EntityRef(nil) return newEntityRefSlice(&orig, internal.NewState()) } @@ -87,7 +86,7 @@ func (es EntityRefSlice) EnsureCapacity(newCap int) { return } - newOrig := make([]*otlpcommon.EntityRef, len(*es.getOrig()), newCap) + newOrig := make([]*internal.EntityRef, len(*es.getOrig()), newCap) copy(newOrig, *es.getOrig()) *es.getOrig() = newOrig } @@ -96,7 +95,7 @@ func (es EntityRefSlice) EnsureCapacity(newCap int) { // It returns the newly added EntityRef. func (es EntityRefSlice) AppendEmpty() EntityRef { es.getState().AssertMutable() - *es.getOrig() = append(*es.getOrig(), internal.NewOrigEntityRef()) + *es.getOrig() = append(*es.getOrig(), internal.NewEntityRef()) return es.At(es.Len() - 1) } @@ -125,7 +124,7 @@ func (es EntityRefSlice) RemoveIf(f func(EntityRef) bool) { newLen := 0 for i := 0; i < len(*es.getOrig()); i++ { if f(es.At(i)) { - internal.DeleteOrigEntityRef((*es.getOrig())[i], true) + internal.DeleteEntityRef((*es.getOrig())[i], true) (*es.getOrig())[i] = nil continue @@ -149,7 +148,7 @@ func (es EntityRefSlice) CopyTo(dest EntityRefSlice) { if es.getOrig() == dest.getOrig() { return } - *dest.getOrig() = internal.CopyOrigEntityRefSlice(*dest.getOrig(), *es.getOrig()) + *dest.getOrig() = internal.CopyEntityRefPtrSlice(*dest.getOrig(), *es.getOrig()) } // Sort sorts the EntityRef elements within EntityRefSlice given the @@ -160,10 +159,10 @@ func (es EntityRefSlice) Sort(less func(a, b EntityRef) bool) { sort.SliceStable(*es.getOrig(), func(i, j int) bool { return less(es.At(i), es.At(j)) }) } -func (ms EntityRefSlice) getOrig() *[]*otlpcommon.EntityRef { - return internal.GetOrigEntityRefSlice(internal.EntityRefSlice(ms)) +func (ms EntityRefSlice) getOrig() *[]*internal.EntityRef { + return internal.GetEntityRefSliceOrig(internal.EntityRefSliceWrapper(ms)) } func (ms EntityRefSlice) getState() *internal.State { - return internal.GetEntityRefSliceState(internal.EntityRefSlice(ms)) + return internal.GetEntityRefSliceState(internal.EntityRefSliceWrapper(ms)) } diff --git a/pdata/xpdata/entity/generated_entityrefslice_test.go b/pdata/xpdata/entity/generated_entityrefslice_test.go index 637cd0aea7d..87d1e2f8332 100644 --- a/pdata/xpdata/entity/generated_entityrefslice_test.go +++ b/pdata/xpdata/entity/generated_entityrefslice_test.go @@ -13,21 +13,20 @@ import ( "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" ) func TestEntityRefSlice(t *testing.T) { es := NewEntityRefSlice() assert.Equal(t, 0, es.Len()) - es = newEntityRefSlice(&[]*otlpcommon.EntityRef{}, internal.NewState()) + es = newEntityRefSlice(&[]*internal.EntityRef{}, internal.NewState()) assert.Equal(t, 0, es.Len()) emptyVal := NewEntityRef() - testVal := EntityRef(internal.NewEntityRef(internal.GenTestOrigEntityRef(), internal.NewState())) + testVal := EntityRef(internal.GenTestEntityRefWrapper()) for i := 0; i < 7; i++ { es.AppendEmpty() assert.Equal(t, emptyVal, es.At(i)) - (*es.getOrig())[i] = internal.GenTestOrigEntityRef() + (*es.getOrig())[i] = internal.GenTestEntityRef() assert.Equal(t, testVal, es.At(i)) } assert.Equal(t, 7, es.Len()) @@ -36,7 +35,7 @@ func TestEntityRefSlice(t *testing.T) { func TestEntityRefSliceReadOnly(t *testing.T) { sharedState := internal.NewState() sharedState.MarkReadOnly() - es := newEntityRefSlice(&[]*otlpcommon.EntityRef{}, sharedState) + es := newEntityRefSlice(&[]*internal.EntityRef{}, sharedState) assert.Equal(t, 0, es.Len()) assert.Panics(t, func() { es.AppendEmpty() }) assert.Panics(t, func() { es.EnsureCapacity(2) }) @@ -162,6 +161,6 @@ func TestEntityRefSlice_Sort(t *testing.T) { func generateTestEntityRefSlice() EntityRefSlice { ms := NewEntityRefSlice() - *ms.getOrig() = internal.GenerateOrigTestEntityRefSlice() + *ms.getOrig() = internal.GenTestEntityRefPtrSlice() return ms } diff --git a/pdata/xpdata/entity/resource_entities.go b/pdata/xpdata/entity/resource_entities.go index cabd37b8951..b29cb6a4607 100644 --- a/pdata/xpdata/entity/resource_entities.go +++ b/pdata/xpdata/entity/resource_entities.go @@ -12,8 +12,8 @@ import ( // Once EntityRefs is stabilized in the proto definition, // this function will be available in the pcommon package as part of a Resource method. func ResourceEntityRefs(res pcommon.Resource) EntityRefSlice { - ir := internal.Resource(res) - return newEntityRefSlice(&internal.GetOrigResource(ir).EntityRefs, internal.GetResourceState(ir)) + ir := internal.ResourceWrapper(res) + return newEntityRefSlice(&internal.GetResourceOrig(ir).EntityRefs, internal.GetResourceState(ir)) } // ResourceEntities returns the Entities associated with this Resource. diff --git a/pdata/xpdata/go.mod b/pdata/xpdata/go.mod index 88aa481f022..cb51590b359 100644 --- a/pdata/xpdata/go.mod +++ b/pdata/xpdata/go.mod @@ -3,7 +3,6 @@ module go.opentelemetry.io/collector/pdata/xpdata go 1.24.0 require ( - github.com/gogo/protobuf v1.3.2 github.com/stretchr/testify v1.11.1 go.opentelemetry.io/collector/client v1.44.0 go.opentelemetry.io/collector/featuregate v1.44.0 @@ -22,12 +21,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/pdata/xpdata/go.sum b/pdata/xpdata/go.sum index d66de34aab7..da25facee1f 100644 --- a/pdata/xpdata/go.sum +++ b/pdata/xpdata/go.sum @@ -1,25 +1,13 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +26,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= -go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= -go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= -go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= -go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc= -go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -62,43 +40,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pdata/xpdata/json.go b/pdata/xpdata/json.go index e40eabe8a77..865aa430bbe 100644 --- a/pdata/xpdata/json.go +++ b/pdata/xpdata/json.go @@ -7,7 +7,6 @@ import ( "slices" "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/internal/json" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -18,7 +17,7 @@ func (*JSONMarshaler) MarshalValue(value pcommon.Value) ([]byte, error) { av := internal.GetOrigValue(internal.Value(value)) dest := json.BorrowStream(nil) defer json.ReturnStream(dest) - internal.MarshalJSONOrigAnyValue(av, dest) + av.MarshalJSON(dest) if dest.Error() != nil { return nil, dest.Error() } @@ -30,10 +29,10 @@ type JSONUnmarshaler struct{} func (*JSONUnmarshaler) UnmarshalValue(buf []byte) (pcommon.Value, error) { iter := json.BorrowIterator(buf) defer json.ReturnIterator(iter) - value := &otlpcommon.AnyValue{} - internal.UnmarshalJSONOrigAnyValue(value, iter) + value := &internal.AnyValue{} + value.UnmarshalJSON(iter) if iter.Error() != nil { return pcommon.NewValueEmpty(), iter.Error() } - return pcommon.Value(internal.NewValue(value, internal.NewState())), nil + return pcommon.Value(internal.NewValueWrapper(value, internal.NewState())), nil } diff --git a/pdata/xpdata/map_builder.go b/pdata/xpdata/map_builder.go index 0a217237043..78a067c3015 100644 --- a/pdata/xpdata/map_builder.go +++ b/pdata/xpdata/map_builder.go @@ -5,7 +5,6 @@ package xpdata // import "go.opentelemetry.io/collector/pdata/xpdata" import ( "go.opentelemetry.io/collector/pdata/internal" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" "go.opentelemetry.io/collector/pdata/pcommon" ) @@ -15,7 +14,7 @@ import ( // A zero-initialized MapBuilder is ready for use. type MapBuilder struct { state internal.State - pairs []otlpcommon.KeyValue + pairs []internal.KeyValue } // EnsureCapacity increases the capacity of this MapBuilder instance, if necessary, @@ -25,27 +24,27 @@ func (mb *MapBuilder) EnsureCapacity(capacity int) { if capacity <= cap(oldValues) { return } - mb.pairs = make([]otlpcommon.KeyValue, len(oldValues), capacity) + mb.pairs = make([]internal.KeyValue, len(oldValues), capacity) copy(mb.pairs, oldValues) } func (mb *MapBuilder) getValue(i int) pcommon.Value { - return pcommon.Value(internal.NewValue(&mb.pairs[i].Value, &mb.state)) + return pcommon.Value(internal.NewValueWrapper(&mb.pairs[i].Value, &mb.state)) } // AppendEmpty appends a key/value pair to the MapBuilder and return the inserted value. // This method does not check for duplicate keys and has an amortized constant time complexity. func (mb *MapBuilder) AppendEmpty(k string) pcommon.Value { - mb.pairs = append(mb.pairs, otlpcommon.KeyValue{Key: k}) + mb.pairs = append(mb.pairs, internal.KeyValue{Key: k}) return mb.getValue(len(mb.pairs) - 1) } -// UnsafeIntoMap transfers the contents of a MapBuilder into a Map, without checking for duplicate keys. -// If the MapBuilder contains duplicate keys, the behavior of the resulting Map is unspecified. +// UnsafeIntoMap transfers the contents of a MapBuilder into a MapWrapper, without checking for duplicate keys. +// If the MapBuilder contains duplicate keys, the behavior of the resulting MapWrapper is unspecified. // This operation has constant time complexity and makes no allocations. // After this operation, the MapBuilder is reset to an empty state. func (mb *MapBuilder) UnsafeIntoMap(m pcommon.Map) { - internal.GetMapState(internal.Map(m)).AssertMutable() - *internal.GetOrigMap(internal.Map(m)) = mb.pairs + internal.GetMapState(internal.MapWrapper(m)).AssertMutable() + *internal.GetMapOrig(internal.MapWrapper(m)) = mb.pairs mb.pairs = nil } diff --git a/pdata/xpdata/pref/logs.go b/pdata/xpdata/pref/logs.go index 1b4f8202254..ef19e15be23 100644 --- a/pdata/xpdata/pref/logs.go +++ b/pdata/xpdata/pref/logs.go @@ -13,23 +13,23 @@ import ( // MarkPipelineOwnedLogs marks the plog.Logs data as owned by the pipeline, returns true if the data were // previously not owned by the pipeline, otherwise false. func MarkPipelineOwnedLogs(ld plog.Logs) bool { - return internal.GetLogsState(internal.Logs(ld)).MarkPipelineOwned() + return internal.GetLogsState(internal.LogsWrapper(ld)).MarkPipelineOwned() } func RefLogs(ld plog.Logs) { if EnableRefCounting.IsEnabled() { - internal.GetLogsState(internal.Logs(ld)).Ref() + internal.GetLogsState(internal.LogsWrapper(ld)).Ref() } } func UnrefLogs(ld plog.Logs) { if EnableRefCounting.IsEnabled() { - if !internal.GetLogsState(internal.Logs(ld)).Unref() { + if !internal.GetLogsState(internal.LogsWrapper(ld)).Unref() { return } - // Don't call DeleteOrigExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. + // Don't call DeleteExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. if internal.UseProtoPooling.IsEnabled() { - internal.DeleteOrigExportLogsServiceRequest(internal.GetOrigLogs(internal.Logs(ld)), true) + internal.DeleteExportLogsServiceRequest(internal.GetLogsOrig(internal.LogsWrapper(ld)), true) } } } @@ -37,5 +37,5 @@ func UnrefLogs(ld plog.Logs) { // TODO: Generate this in pdata. func EqualLogs(ld1, ld2 plog.Logs) bool { - return reflect.DeepEqual(internal.GetOrigLogs(internal.Logs(ld1)), internal.GetOrigLogs(internal.Logs(ld2))) + return reflect.DeepEqual(internal.GetLogsOrig(internal.LogsWrapper(ld1)), internal.GetLogsOrig(internal.LogsWrapper(ld2))) } diff --git a/pdata/xpdata/pref/metrics.go b/pdata/xpdata/pref/metrics.go index 1bc6c3921d9..02610780dca 100644 --- a/pdata/xpdata/pref/metrics.go +++ b/pdata/xpdata/pref/metrics.go @@ -13,23 +13,23 @@ import ( // MarkPipelineOwnedMetrics marks the pmetric.Metrics data as owned by the pipeline, returns true if the data were // previously not owned by the pipeline, otherwise false. func MarkPipelineOwnedMetrics(md pmetric.Metrics) bool { - return internal.GetMetricsState(internal.Metrics(md)).MarkPipelineOwned() + return internal.GetMetricsState(internal.MetricsWrapper(md)).MarkPipelineOwned() } func RefMetrics(md pmetric.Metrics) { if EnableRefCounting.IsEnabled() { - internal.GetMetricsState(internal.Metrics(md)).Ref() + internal.GetMetricsState(internal.MetricsWrapper(md)).Ref() } } func UnrefMetrics(md pmetric.Metrics) { if EnableRefCounting.IsEnabled() { - if !internal.GetMetricsState(internal.Metrics(md)).Unref() { + if !internal.GetMetricsState(internal.MetricsWrapper(md)).Unref() { return } - // Don't call DeleteOrigExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. + // Don't call DeleteExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. if internal.UseProtoPooling.IsEnabled() { - internal.DeleteOrigExportMetricsServiceRequest(internal.GetOrigMetrics(internal.Metrics(md)), true) + internal.DeleteExportMetricsServiceRequest(internal.GetMetricsOrig(internal.MetricsWrapper(md)), true) } } } @@ -37,5 +37,5 @@ func UnrefMetrics(md pmetric.Metrics) { // TODO: Generate this in pdata. func EqualMetrics(md1, md2 pmetric.Metrics) bool { - return reflect.DeepEqual(internal.GetOrigMetrics(internal.Metrics(md1)), internal.GetOrigMetrics(internal.Metrics(md2))) + return reflect.DeepEqual(internal.GetMetricsOrig(internal.MetricsWrapper(md1)), internal.GetMetricsOrig(internal.MetricsWrapper(md2))) } diff --git a/pdata/xpdata/pref/profiles.go b/pdata/xpdata/pref/profiles.go index 28e2d07f0dd..b4a6ad70877 100644 --- a/pdata/xpdata/pref/profiles.go +++ b/pdata/xpdata/pref/profiles.go @@ -13,23 +13,23 @@ import ( // MarkPipelineOwnedProfiles marks the pprofile.Profiles data as owned by the pipeline, returns true if the data were // previously not owned by the pipeline, otherwise false. func MarkPipelineOwnedProfiles(pd pprofile.Profiles) bool { - return internal.GetProfilesState(internal.Profiles(pd)).MarkPipelineOwned() + return internal.GetProfilesState(internal.ProfilesWrapper(pd)).MarkPipelineOwned() } func RefProfiles(pd pprofile.Profiles) { if EnableRefCounting.IsEnabled() { - internal.GetProfilesState(internal.Profiles(pd)).Ref() + internal.GetProfilesState(internal.ProfilesWrapper(pd)).Ref() } } func UnrefProfiles(pd pprofile.Profiles) { if EnableRefCounting.IsEnabled() { - if !internal.GetProfilesState(internal.Profiles(pd)).Unref() { + if !internal.GetProfilesState(internal.ProfilesWrapper(pd)).Unref() { return } - // Don't call DeleteOrigExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. + // Don't call DeleteExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. if internal.UseProtoPooling.IsEnabled() { - internal.DeleteOrigExportProfilesServiceRequest(internal.GetOrigProfiles(internal.Profiles(pd)), true) + internal.DeleteExportProfilesServiceRequest(internal.GetProfilesOrig(internal.ProfilesWrapper(pd)), true) } } } @@ -37,5 +37,5 @@ func UnrefProfiles(pd pprofile.Profiles) { // TODO: Generate this in pdata. func EqualProfiles(pd1, pd2 pprofile.Profiles) bool { - return reflect.DeepEqual(internal.GetOrigProfiles(internal.Profiles(pd1)), internal.GetOrigProfiles(internal.Profiles(pd2))) + return reflect.DeepEqual(internal.GetProfilesOrig(internal.ProfilesWrapper(pd1)), internal.GetProfilesOrig(internal.ProfilesWrapper(pd2))) } diff --git a/pdata/xpdata/pref/traces.go b/pdata/xpdata/pref/traces.go index 539951fcf7c..5f21b6a2e0f 100644 --- a/pdata/xpdata/pref/traces.go +++ b/pdata/xpdata/pref/traces.go @@ -13,21 +13,21 @@ import ( // MarkPipelineOwnedTraces marks the ptrace.Traces data as owned by the pipeline, returns true if the data were // previously not owned by the pipeline, otherwise false. func MarkPipelineOwnedTraces(td ptrace.Traces) bool { - return internal.GetTracesState(internal.Traces(td)).MarkPipelineOwned() + return internal.GetTracesState(internal.TracesWrapper(td)).MarkPipelineOwned() } func RefTraces(td ptrace.Traces) { - internal.GetTracesState(internal.Traces(td)).Ref() + internal.GetTracesState(internal.TracesWrapper(td)).Ref() } func UnrefTraces(td ptrace.Traces) { if EnableRefCounting.IsEnabled() { - if !internal.GetTracesState(internal.Traces(td)).Unref() { + if !internal.GetTracesState(internal.TracesWrapper(td)).Unref() { return } - // Don't call DeleteOrigExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. + // Don't call DeleteExportLogsServiceRequest without the gate because we reset the data and that may still cause issues. if internal.UseProtoPooling.IsEnabled() { - internal.DeleteOrigExportTraceServiceRequest(internal.GetOrigTraces(internal.Traces(td)), true) + internal.DeleteExportTraceServiceRequest(internal.GetTracesOrig(internal.TracesWrapper(td)), true) } } } @@ -35,5 +35,5 @@ func UnrefTraces(td ptrace.Traces) { // TODO: Generate this in pdata. func EqualTraces(td1, td2 ptrace.Traces) bool { - return reflect.DeepEqual(internal.GetOrigTraces(internal.Traces(td1)), internal.GetOrigTraces(internal.Traces(td2))) + return reflect.DeepEqual(internal.GetTracesOrig(internal.TracesWrapper(td1)), internal.GetTracesOrig(internal.TracesWrapper(td2))) } diff --git a/pdata/xpdata/request/context.go b/pdata/xpdata/request/context.go index 7ea1df2cfb7..eaa027bb685 100644 --- a/pdata/xpdata/request/context.go +++ b/pdata/xpdata/request/context.go @@ -10,17 +10,16 @@ import ( "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/collector/client" - otlpcommon "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - "go.opentelemetry.io/collector/pdata/xpdata/request/internal" + "go.opentelemetry.io/collector/pdata/internal" ) // encodeContext encodes the context into a map of strings. -func encodeContext(ctx context.Context) internal.RequestContext { +func encodeContext(ctx context.Context) *internal.RequestContext { rc := internal.RequestContext{} encodeSpanContext(ctx, &rc) encodeClientMetadata(ctx, &rc) encodeClientAddress(ctx, &rc) - return rc + return &rc } func encodeSpanContext(ctx context.Context, rc *internal.RequestContext) { @@ -28,11 +27,9 @@ func encodeSpanContext(ctx context.Context, rc *internal.RequestContext) { if !spanCtx.IsValid() { return } - traceID := spanCtx.TraceID() - spanID := spanCtx.SpanID() rc.SpanContext = &internal.SpanContext{ - TraceId: traceID[:], - SpanId: spanID[:], + TraceID: internal.TraceID(spanCtx.TraceID()), + SpanID: internal.SpanID(spanCtx.SpanID()), TraceFlags: uint32(spanCtx.TraceFlags()), TraceState: spanCtx.TraceState().String(), Remote: spanCtx.IsRemote(), @@ -45,18 +42,18 @@ func encodeClientMetadata(ctx context.Context, rc *internal.RequestContext) { vals := clientMetadata.Get(k) switch len(vals) { case 1: - rc.ClientMetadata = append(rc.ClientMetadata, otlpcommon.KeyValue{ + rc.ClientMetadata = append(rc.ClientMetadata, internal.KeyValue{ Key: k, - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: vals[0]}}, + Value: internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: vals[0]}}, }) default: - metadataArray := make([]otlpcommon.AnyValue, 0, len(vals)) + metadataArray := make([]internal.AnyValue, 0, len(vals)) for i := range vals { - metadataArray = append(metadataArray, otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: vals[i]}}) + metadataArray = append(metadataArray, internal.AnyValue{Value: &internal.AnyValue_StringValue{StringValue: vals[i]}}) } - rc.ClientMetadata = append(rc.ClientMetadata, otlpcommon.KeyValue{ + rc.ClientMetadata = append(rc.ClientMetadata, internal.KeyValue{ Key: k, - Value: otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: &otlpcommon.ArrayValue{Values: metadataArray}}}, + Value: internal.AnyValue{Value: &internal.AnyValue_ArrayValue{ArrayValue: &internal.ArrayValue{Values: metadataArray}}}, }) } } @@ -65,19 +62,19 @@ func encodeClientMetadata(ctx context.Context, rc *internal.RequestContext) { func encodeClientAddress(ctx context.Context, rc *internal.RequestContext) { switch a := client.FromContext(ctx).Addr.(type) { case *net.IPAddr: - rc.ClientAddress = &internal.RequestContext_Ip{Ip: &internal.IPAddr{ - Ip: a.IP, + rc.ClientAddress = &internal.RequestContext_IP{IP: &internal.IPAddr{ + IP: a.IP, Zone: a.Zone, }} case *net.TCPAddr: - rc.ClientAddress = &internal.RequestContext_Tcp{Tcp: &internal.TCPAddr{ - Ip: a.IP, + rc.ClientAddress = &internal.RequestContext_TCP{TCP: &internal.TCPAddr{ + IP: a.IP, Port: int64(a.Port), Zone: a.Zone, }} case *net.UDPAddr: - rc.ClientAddress = &internal.RequestContext_Udp{Udp: &internal.UDPAddr{ - Ip: a.IP, + rc.ClientAddress = &internal.RequestContext_UDP{UDP: &internal.UDPAddr{ + IP: a.IP, Port: int64(a.Port), Zone: a.Zone, }} @@ -110,10 +107,8 @@ func decodeSpanContext(ctx context.Context, sc *internal.SpanContext) context.Co if sc == nil { return ctx } - traceID := trace.TraceID{} - copy(traceID[:], sc.TraceId) - spanID := trace.SpanID{} - copy(spanID[:], sc.SpanId) + traceID := trace.TraceID(sc.TraceID) + spanID := trace.SpanID(sc.SpanID) traceState, _ := trace.ParseTraceState(sc.TraceState) return trace.ContextWithSpanContext(context.Background(), trace.NewSpanContext(trace.SpanContextConfig{ TraceID: traceID, @@ -124,17 +119,17 @@ func decodeSpanContext(ctx context.Context, sc *internal.SpanContext) context.Co })) } -func decodeClientMetadata(clientMetadata []otlpcommon.KeyValue) map[string][]string { +func decodeClientMetadata(clientMetadata []internal.KeyValue) map[string][]string { if len(clientMetadata) == 0 { return nil } metadataMap := make(map[string][]string, len(clientMetadata)) for _, kv := range clientMetadata { switch val := kv.Value.Value.(type) { - case *otlpcommon.AnyValue_StringValue: + case *internal.AnyValue_StringValue: metadataMap[kv.Key] = make([]string, 1) metadataMap[kv.Key][0] = val.StringValue - case *otlpcommon.AnyValue_ArrayValue: + case *internal.AnyValue_ArrayValue: metadataMap[kv.Key] = make([]string, len(val.ArrayValue.Values)) for i, v := range val.ArrayValue.Values { metadataMap[kv.Key][i] = v.GetStringValue() @@ -146,22 +141,22 @@ func decodeClientMetadata(clientMetadata []otlpcommon.KeyValue) map[string][]str func decodeClientAddress(rc *internal.RequestContext) net.Addr { switch a := rc.ClientAddress.(type) { - case *internal.RequestContext_Ip: + case *internal.RequestContext_IP: return &net.IPAddr{ - IP: a.Ip.Ip, - Zone: a.Ip.Zone, + IP: a.IP.IP, + Zone: a.IP.Zone, } - case *internal.RequestContext_Tcp: + case *internal.RequestContext_TCP: return &net.TCPAddr{ - IP: a.Tcp.Ip, - Port: int(a.Tcp.Port), - Zone: a.Tcp.Zone, + IP: a.TCP.IP, + Port: int(a.TCP.Port), + Zone: a.TCP.Zone, } - case *internal.RequestContext_Udp: + case *internal.RequestContext_UDP: return &net.UDPAddr{ - IP: a.Udp.Ip, - Port: int(a.Udp.Port), - Zone: a.Udp.Zone, + IP: a.UDP.IP, + Port: int(a.UDP.Port), + Zone: a.UDP.Zone, } case *internal.RequestContext_Unix: return &net.UnixAddr{ diff --git a/pdata/xpdata/request/context_test.go b/pdata/xpdata/request/context_test.go index 4ddfc1a5557..e0392731c00 100644 --- a/pdata/xpdata/request/context_test.go +++ b/pdata/xpdata/request/context_test.go @@ -13,7 +13,7 @@ import ( "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/collector/client" - "go.opentelemetry.io/collector/pdata/xpdata/request/internal" + "go.opentelemetry.io/collector/pdata/internal" ) func TestEncodeDecodeContext(t *testing.T) { @@ -77,13 +77,12 @@ func TestEncodeDecodeContext(t *testing.T) { ctx := trace.ContextWithSpanContext(context.Background(), spanCtx) ctx = client.NewContext(ctx, tt.clientInfo) reqCtx := encodeContext(ctx) - buf, err := reqCtx.Marshal() - require.NoError(t, err) + buf := make([]byte, reqCtx.SizeProto()) + reqCtx.MarshalProto(buf) // Decode the context gotReqCtx := internal.RequestContext{} - err = gotReqCtx.Unmarshal(buf) - require.NoError(t, err) + require.NoError(t, gotReqCtx.UnmarshalProto(buf)) gotCtx := decodeContext(context.Background(), &gotReqCtx) assert.Equal(t, spanCtx, trace.SpanContextFromContext(gotCtx)) assert.Equal(t, tt.clientInfo, client.FromContext(gotCtx)) diff --git a/pdata/xpdata/request/internal/request.pb.go b/pdata/xpdata/request/internal/request.pb.go deleted file mode 100644 index 524ffee0255..00000000000 --- a/pdata/xpdata/request/internal/request.pb.go +++ /dev/null @@ -1,3167 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pdata/xpdata/request/internal/request.proto - -package internal - -import ( - encoding_binary "encoding/binary" - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - - v1 "go.opentelemetry.io/collector/pdata/internal/data/protogen/common/v1" - v13 "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1" - v12 "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1" - v1development "go.opentelemetry.io/collector/pdata/internal/data/protogen/profiles/v1development" - v11 "go.opentelemetry.io/collector/pdata/internal/data/protogen/trace/v1" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// SpanContext represents a span context encoded associated with a telemetry export request. -type SpanContext struct { - TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` - SpanId []byte `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3" json:"span_id,omitempty"` - TraceFlags uint32 `protobuf:"fixed32,3,opt,name=trace_flags,json=traceFlags,proto3" json:"trace_flags,omitempty"` - TraceState string `protobuf:"bytes,4,opt,name=trace_state,json=traceState,proto3" json:"trace_state,omitempty"` - Remote bool `protobuf:"varint,5,opt,name=remote,proto3" json:"remote,omitempty"` -} - -func (m *SpanContext) Reset() { *m = SpanContext{} } -func (m *SpanContext) String() string { return proto.CompactTextString(m) } -func (*SpanContext) ProtoMessage() {} -func (*SpanContext) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{0} -} -func (m *SpanContext) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SpanContext) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SpanContext.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SpanContext) XXX_Merge(src proto.Message) { - xxx_messageInfo_SpanContext.Merge(m, src) -} -func (m *SpanContext) XXX_Size() int { - return m.Size() -} -func (m *SpanContext) XXX_DiscardUnknown() { - xxx_messageInfo_SpanContext.DiscardUnknown(m) -} - -var xxx_messageInfo_SpanContext proto.InternalMessageInfo - -func (m *SpanContext) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - -func (m *SpanContext) GetSpanId() []byte { - if m != nil { - return m.SpanId - } - return nil -} - -func (m *SpanContext) GetTraceFlags() uint32 { - if m != nil { - return m.TraceFlags - } - return 0 -} - -func (m *SpanContext) GetTraceState() string { - if m != nil { - return m.TraceState - } - return "" -} - -func (m *SpanContext) GetRemote() bool { - if m != nil { - return m.Remote - } - return false -} - -type IPAddr struct { - Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` - Zone string `protobuf:"bytes,2,opt,name=zone,proto3" json:"zone,omitempty"` -} - -func (m *IPAddr) Reset() { *m = IPAddr{} } -func (m *IPAddr) String() string { return proto.CompactTextString(m) } -func (*IPAddr) ProtoMessage() {} -func (*IPAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{1} -} -func (m *IPAddr) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *IPAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_IPAddr.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *IPAddr) XXX_Merge(src proto.Message) { - xxx_messageInfo_IPAddr.Merge(m, src) -} -func (m *IPAddr) XXX_Size() int { - return m.Size() -} -func (m *IPAddr) XXX_DiscardUnknown() { - xxx_messageInfo_IPAddr.DiscardUnknown(m) -} - -var xxx_messageInfo_IPAddr proto.InternalMessageInfo - -func (m *IPAddr) GetIp() []byte { - if m != nil { - return m.Ip - } - return nil -} - -func (m *IPAddr) GetZone() string { - if m != nil { - return m.Zone - } - return "" -} - -type TCPAddr struct { - Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` - Port int64 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` - Zone string `protobuf:"bytes,3,opt,name=zone,proto3" json:"zone,omitempty"` -} - -func (m *TCPAddr) Reset() { *m = TCPAddr{} } -func (m *TCPAddr) String() string { return proto.CompactTextString(m) } -func (*TCPAddr) ProtoMessage() {} -func (*TCPAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{2} -} -func (m *TCPAddr) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TCPAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TCPAddr.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TCPAddr) XXX_Merge(src proto.Message) { - xxx_messageInfo_TCPAddr.Merge(m, src) -} -func (m *TCPAddr) XXX_Size() int { - return m.Size() -} -func (m *TCPAddr) XXX_DiscardUnknown() { - xxx_messageInfo_TCPAddr.DiscardUnknown(m) -} - -var xxx_messageInfo_TCPAddr proto.InternalMessageInfo - -func (m *TCPAddr) GetIp() []byte { - if m != nil { - return m.Ip - } - return nil -} - -func (m *TCPAddr) GetPort() int64 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *TCPAddr) GetZone() string { - if m != nil { - return m.Zone - } - return "" -} - -type UDPAddr struct { - Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` - Port int64 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` - Zone string `protobuf:"bytes,3,opt,name=zone,proto3" json:"zone,omitempty"` -} - -func (m *UDPAddr) Reset() { *m = UDPAddr{} } -func (m *UDPAddr) String() string { return proto.CompactTextString(m) } -func (*UDPAddr) ProtoMessage() {} -func (*UDPAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{3} -} -func (m *UDPAddr) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UDPAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UDPAddr.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *UDPAddr) XXX_Merge(src proto.Message) { - xxx_messageInfo_UDPAddr.Merge(m, src) -} -func (m *UDPAddr) XXX_Size() int { - return m.Size() -} -func (m *UDPAddr) XXX_DiscardUnknown() { - xxx_messageInfo_UDPAddr.DiscardUnknown(m) -} - -var xxx_messageInfo_UDPAddr proto.InternalMessageInfo - -func (m *UDPAddr) GetIp() []byte { - if m != nil { - return m.Ip - } - return nil -} - -func (m *UDPAddr) GetPort() int64 { - if m != nil { - return m.Port - } - return 0 -} - -func (m *UDPAddr) GetZone() string { - if m != nil { - return m.Zone - } - return "" -} - -type UnixAddr struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Net string `protobuf:"bytes,2,opt,name=net,proto3" json:"net,omitempty"` -} - -func (m *UnixAddr) Reset() { *m = UnixAddr{} } -func (m *UnixAddr) String() string { return proto.CompactTextString(m) } -func (*UnixAddr) ProtoMessage() {} -func (*UnixAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{4} -} -func (m *UnixAddr) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UnixAddr) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UnixAddr.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *UnixAddr) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnixAddr.Merge(m, src) -} -func (m *UnixAddr) XXX_Size() int { - return m.Size() -} -func (m *UnixAddr) XXX_DiscardUnknown() { - xxx_messageInfo_UnixAddr.DiscardUnknown(m) -} - -var xxx_messageInfo_UnixAddr proto.InternalMessageInfo - -func (m *UnixAddr) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *UnixAddr) GetNet() string { - if m != nil { - return m.Net - } - return "" -} - -// RequestContext represents metadata associated with a telemetry export request. -type RequestContext struct { - SpanContext *SpanContext `protobuf:"bytes,1,opt,name=span_context,json=spanContext,proto3" json:"span_context,omitempty"` - // ClientMetadata contains additional metadata about the client making the request. - ClientMetadata []v1.KeyValue `protobuf:"bytes,2,rep,name=client_metadata,json=clientMetadata,proto3" json:"client_metadata"` - // ClientAddress contains the address of the client making the request. - // - // Types that are valid to be assigned to ClientAddress: - // *RequestContext_Ip - // *RequestContext_Tcp - // *RequestContext_Udp - // *RequestContext_Unix - ClientAddress isRequestContext_ClientAddress `protobuf_oneof:"client_address"` -} - -func (m *RequestContext) Reset() { *m = RequestContext{} } -func (m *RequestContext) String() string { return proto.CompactTextString(m) } -func (*RequestContext) ProtoMessage() {} -func (*RequestContext) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{5} -} -func (m *RequestContext) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestContext) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RequestContext.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RequestContext) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestContext.Merge(m, src) -} -func (m *RequestContext) XXX_Size() int { - return m.Size() -} -func (m *RequestContext) XXX_DiscardUnknown() { - xxx_messageInfo_RequestContext.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestContext proto.InternalMessageInfo - -type isRequestContext_ClientAddress interface { - isRequestContext_ClientAddress() - MarshalTo([]byte) (int, error) - Size() int -} - -type RequestContext_Ip struct { - Ip *IPAddr `protobuf:"bytes,3,opt,name=ip,proto3,oneof" json:"ip,omitempty"` -} -type RequestContext_Tcp struct { - Tcp *TCPAddr `protobuf:"bytes,4,opt,name=tcp,proto3,oneof" json:"tcp,omitempty"` -} -type RequestContext_Udp struct { - Udp *UDPAddr `protobuf:"bytes,5,opt,name=udp,proto3,oneof" json:"udp,omitempty"` -} -type RequestContext_Unix struct { - Unix *UnixAddr `protobuf:"bytes,6,opt,name=unix,proto3,oneof" json:"unix,omitempty"` -} - -func (*RequestContext_Ip) isRequestContext_ClientAddress() {} -func (*RequestContext_Tcp) isRequestContext_ClientAddress() {} -func (*RequestContext_Udp) isRequestContext_ClientAddress() {} -func (*RequestContext_Unix) isRequestContext_ClientAddress() {} - -func (m *RequestContext) GetClientAddress() isRequestContext_ClientAddress { - if m != nil { - return m.ClientAddress - } - return nil -} - -func (m *RequestContext) GetSpanContext() *SpanContext { - if m != nil { - return m.SpanContext - } - return nil -} - -func (m *RequestContext) GetClientMetadata() []v1.KeyValue { - if m != nil { - return m.ClientMetadata - } - return nil -} - -func (m *RequestContext) GetIp() *IPAddr { - if x, ok := m.GetClientAddress().(*RequestContext_Ip); ok { - return x.Ip - } - return nil -} - -func (m *RequestContext) GetTcp() *TCPAddr { - if x, ok := m.GetClientAddress().(*RequestContext_Tcp); ok { - return x.Tcp - } - return nil -} - -func (m *RequestContext) GetUdp() *UDPAddr { - if x, ok := m.GetClientAddress().(*RequestContext_Udp); ok { - return x.Udp - } - return nil -} - -func (m *RequestContext) GetUnix() *UnixAddr { - if x, ok := m.GetClientAddress().(*RequestContext_Unix); ok { - return x.Unix - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*RequestContext) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*RequestContext_Ip)(nil), - (*RequestContext_Tcp)(nil), - (*RequestContext_Udp)(nil), - (*RequestContext_Unix)(nil), - } -} - -type TracesRequest struct { - FormatVersion uint32 `protobuf:"fixed32,1,opt,name=format_version,json=formatVersion,proto3" json:"format_version,omitempty"` - RequestContext *RequestContext `protobuf:"bytes,2,opt,name=request_context,json=requestContext,proto3" json:"request_context,omitempty"` - TracesData *v11.TracesData `protobuf:"bytes,3,opt,name=traces_data,json=tracesData,proto3" json:"traces_data,omitempty"` -} - -func (m *TracesRequest) Reset() { *m = TracesRequest{} } -func (m *TracesRequest) String() string { return proto.CompactTextString(m) } -func (*TracesRequest) ProtoMessage() {} -func (*TracesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{6} -} -func (m *TracesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TracesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TracesRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TracesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_TracesRequest.Merge(m, src) -} -func (m *TracesRequest) XXX_Size() int { - return m.Size() -} -func (m *TracesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_TracesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_TracesRequest proto.InternalMessageInfo - -func (m *TracesRequest) GetFormatVersion() uint32 { - if m != nil { - return m.FormatVersion - } - return 0 -} - -func (m *TracesRequest) GetRequestContext() *RequestContext { - if m != nil { - return m.RequestContext - } - return nil -} - -func (m *TracesRequest) GetTracesData() *v11.TracesData { - if m != nil { - return m.TracesData - } - return nil -} - -type MetricsRequest struct { - FormatVersion uint32 `protobuf:"fixed32,1,opt,name=format_version,json=formatVersion,proto3" json:"format_version,omitempty"` - RequestContext *RequestContext `protobuf:"bytes,2,opt,name=request_context,json=requestContext,proto3" json:"request_context,omitempty"` - MetricsData *v12.MetricsData `protobuf:"bytes,3,opt,name=metrics_data,json=metricsData,proto3" json:"metrics_data,omitempty"` -} - -func (m *MetricsRequest) Reset() { *m = MetricsRequest{} } -func (m *MetricsRequest) String() string { return proto.CompactTextString(m) } -func (*MetricsRequest) ProtoMessage() {} -func (*MetricsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{7} -} -func (m *MetricsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MetricsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MetricsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MetricsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MetricsRequest.Merge(m, src) -} -func (m *MetricsRequest) XXX_Size() int { - return m.Size() -} -func (m *MetricsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MetricsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_MetricsRequest proto.InternalMessageInfo - -func (m *MetricsRequest) GetFormatVersion() uint32 { - if m != nil { - return m.FormatVersion - } - return 0 -} - -func (m *MetricsRequest) GetRequestContext() *RequestContext { - if m != nil { - return m.RequestContext - } - return nil -} - -func (m *MetricsRequest) GetMetricsData() *v12.MetricsData { - if m != nil { - return m.MetricsData - } - return nil -} - -type LogsRequest struct { - FormatVersion uint32 `protobuf:"fixed32,1,opt,name=format_version,json=formatVersion,proto3" json:"format_version,omitempty"` - RequestContext *RequestContext `protobuf:"bytes,2,opt,name=request_context,json=requestContext,proto3" json:"request_context,omitempty"` - LogsData *v13.LogsData `protobuf:"bytes,3,opt,name=logs_data,json=logsData,proto3" json:"logs_data,omitempty"` -} - -func (m *LogsRequest) Reset() { *m = LogsRequest{} } -func (m *LogsRequest) String() string { return proto.CompactTextString(m) } -func (*LogsRequest) ProtoMessage() {} -func (*LogsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{8} -} -func (m *LogsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LogsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LogsRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LogsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_LogsRequest.Merge(m, src) -} -func (m *LogsRequest) XXX_Size() int { - return m.Size() -} -func (m *LogsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_LogsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_LogsRequest proto.InternalMessageInfo - -func (m *LogsRequest) GetFormatVersion() uint32 { - if m != nil { - return m.FormatVersion - } - return 0 -} - -func (m *LogsRequest) GetRequestContext() *RequestContext { - if m != nil { - return m.RequestContext - } - return nil -} - -func (m *LogsRequest) GetLogsData() *v13.LogsData { - if m != nil { - return m.LogsData - } - return nil -} - -type ProfilesRequest struct { - FormatVersion uint32 `protobuf:"fixed32,1,opt,name=format_version,json=formatVersion,proto3" json:"format_version,omitempty"` - RequestContext *RequestContext `protobuf:"bytes,2,opt,name=request_context,json=requestContext,proto3" json:"request_context,omitempty"` - ProfilesData *v1development.ProfilesData `protobuf:"bytes,3,opt,name=profiles_data,json=profilesData,proto3" json:"profiles_data,omitempty"` -} - -func (m *ProfilesRequest) Reset() { *m = ProfilesRequest{} } -func (m *ProfilesRequest) String() string { return proto.CompactTextString(m) } -func (*ProfilesRequest) ProtoMessage() {} -func (*ProfilesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_b47c551a6764db21, []int{9} -} -func (m *ProfilesRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProfilesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProfilesRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ProfilesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProfilesRequest.Merge(m, src) -} -func (m *ProfilesRequest) XXX_Size() int { - return m.Size() -} -func (m *ProfilesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ProfilesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ProfilesRequest proto.InternalMessageInfo - -func (m *ProfilesRequest) GetFormatVersion() uint32 { - if m != nil { - return m.FormatVersion - } - return 0 -} - -func (m *ProfilesRequest) GetRequestContext() *RequestContext { - if m != nil { - return m.RequestContext - } - return nil -} - -func (m *ProfilesRequest) GetProfilesData() *v1development.ProfilesData { - if m != nil { - return m.ProfilesData - } - return nil -} - -func init() { - proto.RegisterType((*SpanContext)(nil), "opentelemetry.collector.pdata.xpdata.internal.SpanContext") - proto.RegisterType((*IPAddr)(nil), "opentelemetry.collector.pdata.xpdata.internal.IPAddr") - proto.RegisterType((*TCPAddr)(nil), "opentelemetry.collector.pdata.xpdata.internal.TCPAddr") - proto.RegisterType((*UDPAddr)(nil), "opentelemetry.collector.pdata.xpdata.internal.UDPAddr") - proto.RegisterType((*UnixAddr)(nil), "opentelemetry.collector.pdata.xpdata.internal.UnixAddr") - proto.RegisterType((*RequestContext)(nil), "opentelemetry.collector.pdata.xpdata.internal.RequestContext") - proto.RegisterType((*TracesRequest)(nil), "opentelemetry.collector.pdata.xpdata.internal.TracesRequest") - proto.RegisterType((*MetricsRequest)(nil), "opentelemetry.collector.pdata.xpdata.internal.MetricsRequest") - proto.RegisterType((*LogsRequest)(nil), "opentelemetry.collector.pdata.xpdata.internal.LogsRequest") - proto.RegisterType((*ProfilesRequest)(nil), "opentelemetry.collector.pdata.xpdata.internal.ProfilesRequest") -} - -func init() { - proto.RegisterFile("pdata/xpdata/request/internal/request.proto", fileDescriptor_b47c551a6764db21) -} - -var fileDescriptor_b47c551a6764db21 = []byte{ - // 783 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0x8d, 0x93, 0x90, 0x8f, 0x75, 0x9a, 0x56, 0x16, 0x82, 0xd0, 0x43, 0x1a, 0x59, 0x2a, 0x44, - 0xb4, 0x38, 0xa4, 0x15, 0x9f, 0x12, 0x87, 0xa6, 0x15, 0x34, 0x40, 0x50, 0xe5, 0x7e, 0x1c, 0x90, - 0xaa, 0x68, 0xb1, 0x37, 0x91, 0x25, 0x7b, 0xd7, 0xd8, 0x9b, 0x28, 0xe5, 0x1f, 0x70, 0xe3, 0xce, - 0x1f, 0xea, 0xb1, 0x47, 0x4e, 0xa8, 0x6a, 0x4f, 0x9c, 0xf8, 0x09, 0xa0, 0x9d, 0xdd, 0xa4, 0x49, - 0x65, 0x0e, 0x11, 0x97, 0x9e, 0x32, 0x3b, 0x7e, 0xf3, 0x3c, 0x6f, 0xf7, 0x79, 0x27, 0x68, 0x2d, - 0x74, 0x31, 0xc7, 0x8d, 0x91, 0xfc, 0x89, 0xc8, 0xe7, 0x01, 0x89, 0x79, 0xc3, 0xa3, 0x9c, 0x44, - 0x14, 0xfb, 0xe3, 0x84, 0x15, 0x46, 0x8c, 0x33, 0xe3, 0x11, 0x0b, 0x09, 0xe5, 0xc4, 0x27, 0x01, - 0xe1, 0xd1, 0x89, 0xe5, 0x30, 0xdf, 0x27, 0x0e, 0x67, 0x91, 0x05, 0xd5, 0x96, 0x24, 0xb1, 0xc6, - 0xc5, 0xcb, 0xb7, 0xfb, 0xac, 0xcf, 0xa0, 0xb2, 0x21, 0x22, 0x49, 0xb2, 0x5c, 0x9f, 0x21, 0x69, - 0xc8, 0xe7, 0x3c, 0xc2, 0x0e, 0x69, 0x0c, 0x9b, 0x32, 0x50, 0xc8, 0xf5, 0x24, 0xa4, 0x88, 0x3d, - 0x27, 0x16, 0x58, 0x15, 0x2a, 0xf4, 0xfd, 0x24, 0xb4, 0xcf, 0xfa, 0x00, 0x15, 0xbf, 0x0a, 0xf7, - 0x30, 0x09, 0xe7, 0xb0, 0x20, 0x60, 0x54, 0x20, 0x65, 0xa4, 0xb0, 0x2f, 0x92, 0xb0, 0x61, 0xc4, - 0x7a, 0x9e, 0x4f, 0x04, 0xaf, 0x4b, 0x86, 0xc4, 0x67, 0x61, 0x40, 0x28, 0x9f, 0xa4, 0x65, 0xa9, - 0xf9, 0x5d, 0x43, 0xfa, 0x7e, 0x88, 0xe9, 0x36, 0xa3, 0x9c, 0x8c, 0xb8, 0x71, 0x0f, 0x15, 0x40, - 0x5b, 0xd7, 0x73, 0x2b, 0x5a, 0x4d, 0xab, 0x97, 0xec, 0x3c, 0xac, 0xdb, 0xae, 0x71, 0x17, 0xe5, - 0xe3, 0x10, 0x53, 0xf1, 0x24, 0x0d, 0x4f, 0x72, 0x62, 0xd9, 0x76, 0x8d, 0x15, 0xa4, 0xcb, 0x9a, - 0x9e, 0x8f, 0xfb, 0x71, 0x25, 0x53, 0xd3, 0xea, 0x79, 0x1b, 0x41, 0xea, 0xb5, 0xc8, 0x5c, 0x01, - 0x62, 0x8e, 0x39, 0xa9, 0x64, 0x6b, 0x5a, 0xbd, 0xa8, 0x00, 0xfb, 0x22, 0x63, 0xdc, 0x41, 0xb9, - 0x88, 0x04, 0x8c, 0x93, 0xca, 0xad, 0x9a, 0x56, 0x2f, 0xd8, 0x6a, 0x65, 0xae, 0xa3, 0x5c, 0x7b, - 0x6f, 0xcb, 0x75, 0x23, 0xa3, 0x8c, 0xd2, 0x5e, 0xa8, 0x3a, 0x4a, 0x7b, 0xa1, 0x61, 0xa0, 0xec, - 0x17, 0x46, 0x09, 0x74, 0x52, 0xb4, 0x21, 0x36, 0xb7, 0x50, 0xfe, 0x60, 0xfb, 0x9f, 0xf0, 0x90, - 0x45, 0x1c, 0xe0, 0x19, 0x1b, 0xe2, 0x09, 0x45, 0x66, 0x96, 0xe2, 0x70, 0xe7, 0xff, 0x28, 0x1e, - 0xa3, 0xc2, 0x21, 0xf5, 0x46, 0xc0, 0x61, 0xa0, 0x2c, 0xc5, 0x01, 0x01, 0x96, 0xa2, 0x0d, 0xb1, - 0xb1, 0x84, 0x32, 0x94, 0x70, 0xd5, 0xb8, 0x08, 0xcd, 0xaf, 0x59, 0x54, 0xb6, 0xa5, 0x83, 0xc7, - 0xc7, 0x70, 0x8c, 0x4a, 0xb0, 0xd7, 0x8e, 0x5c, 0x03, 0x81, 0xbe, 0xf1, 0xd2, 0x9a, 0xcb, 0xd9, - 0xd6, 0xd4, 0xc1, 0xda, 0x7a, 0x3c, 0x75, 0xca, 0x47, 0x68, 0xd1, 0xf1, 0x3d, 0x42, 0x79, 0x37, - 0x20, 0x1c, 0x8b, 0xa2, 0x4a, 0xba, 0x96, 0xa9, 0xeb, 0x1b, 0x0f, 0xae, 0xbd, 0x01, 0x4c, 0x62, - 0x29, 0xb3, 0x0d, 0x9b, 0xd6, 0x3b, 0x72, 0x72, 0x84, 0xfd, 0x01, 0x69, 0x65, 0x4f, 0x7f, 0xae, - 0xa4, 0xec, 0xb2, 0x64, 0xe9, 0x28, 0x12, 0xe3, 0x0d, 0xec, 0x59, 0x06, 0x9a, 0x7d, 0x32, 0x67, - 0xb3, 0xf2, 0xa0, 0x77, 0x53, 0xb0, 0xd9, 0x6f, 0x51, 0x86, 0x3b, 0x21, 0x38, 0x45, 0xdf, 0x78, - 0x3a, 0x27, 0x93, 0x32, 0xc1, 0x6e, 0xca, 0x16, 0x24, 0x82, 0x6b, 0xe0, 0x86, 0xe0, 0xac, 0xf9, - 0xb9, 0x94, 0x1b, 0x04, 0xd7, 0xc0, 0x0d, 0x8d, 0x0e, 0xca, 0x0e, 0xa8, 0x37, 0xaa, 0xe4, 0x80, - 0xec, 0xd9, 0xbc, 0x64, 0xca, 0x17, 0xbb, 0x29, 0x1b, 0x68, 0x5a, 0x4b, 0x48, 0xed, 0x60, 0x17, - 0xbb, 0x6e, 0x44, 0xe2, 0xd8, 0xfc, 0xa5, 0xa1, 0x85, 0x03, 0xf1, 0x61, 0xc4, 0xca, 0x11, 0xc6, - 0x2a, 0x2a, 0xf7, 0x58, 0x14, 0x60, 0xde, 0x1d, 0x92, 0x28, 0xf6, 0x18, 0x05, 0x33, 0xe4, 0xed, - 0x05, 0x99, 0x3d, 0x92, 0x49, 0xa3, 0x87, 0x16, 0xd5, 0x2d, 0x38, 0x31, 0x4d, 0x1a, 0x9a, 0x7c, - 0x35, 0x67, 0x93, 0xb3, 0x4e, 0xb4, 0xcb, 0xd1, 0xac, 0x33, 0xdb, 0xea, 0x5b, 0x8e, 0xbb, 0x60, - 0x1b, 0x79, 0xd6, 0xf5, 0x44, 0xdb, 0xc8, 0x4b, 0x72, 0xd8, 0xb4, 0xa4, 0xa0, 0x1d, 0xcc, 0xb1, - 0xfa, 0xea, 0x21, 0x36, 0x7f, 0x6b, 0xa8, 0xdc, 0x91, 0x97, 0xe3, 0x0d, 0x15, 0xfb, 0x01, 0x95, - 0xd4, 0xed, 0x3d, 0xad, 0x76, 0x2d, 0x51, 0xed, 0xf8, 0x9a, 0x1f, 0x36, 0x2d, 0x25, 0x0a, 0x04, - 0xeb, 0xc1, 0xd5, 0xc2, 0x3c, 0xd7, 0x90, 0xfe, 0x9e, 0xf5, 0x6f, 0xaa, 0xdc, 0x16, 0x2a, 0x8a, - 0x09, 0x34, 0xad, 0x75, 0x35, 0x51, 0x2b, 0xcc, 0xa9, 0x61, 0xd3, 0x12, 0x5a, 0x40, 0x65, 0xc1, - 0x57, 0x91, 0xf9, 0x47, 0x43, 0x8b, 0x7b, 0x6a, 0xc6, 0xdc, 0x50, 0x99, 0xc7, 0x68, 0x61, 0x3c, - 0x05, 0xa7, 0xa5, 0x3e, 0x4f, 0x94, 0x3a, 0x99, 0x97, 0x33, 0x63, 0xd4, 0x1a, 0x4b, 0x04, 0xf5, - 0xa5, 0x70, 0x6a, 0xd5, 0xea, 0x9c, 0x5e, 0x54, 0xb5, 0xb3, 0x8b, 0xaa, 0x76, 0x7e, 0x51, 0xd5, - 0xbe, 0x5d, 0x56, 0x53, 0x67, 0x97, 0xd5, 0xd4, 0x8f, 0xcb, 0x6a, 0xea, 0xe3, 0x66, 0x9f, 0x5d, - 0x7b, 0x87, 0x27, 0x66, 0xba, 0x12, 0xd3, 0x98, 0xf9, 0x8f, 0x33, 0x16, 0xf3, 0x29, 0x07, 0x7d, - 0x6c, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x46, 0x4d, 0x98, 0x93, 0x03, 0x09, 0x00, 0x00, -} - -func (m *SpanContext) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SpanContext) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SpanContext) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Remote { - i-- - if m.Remote { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if len(m.TraceState) > 0 { - i -= len(m.TraceState) - copy(dAtA[i:], m.TraceState) - i = encodeVarintRequest(dAtA, i, uint64(len(m.TraceState))) - i-- - dAtA[i] = 0x22 - } - if m.TraceFlags != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.TraceFlags)) - i-- - dAtA[i] = 0x1d - } - if len(m.SpanId) > 0 { - i -= len(m.SpanId) - copy(dAtA[i:], m.SpanId) - i = encodeVarintRequest(dAtA, i, uint64(len(m.SpanId))) - i-- - dAtA[i] = 0x12 - } - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintRequest(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *IPAddr) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *IPAddr) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *IPAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Zone) > 0 { - i -= len(m.Zone) - copy(dAtA[i:], m.Zone) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Zone))) - i-- - dAtA[i] = 0x12 - } - if len(m.Ip) > 0 { - i -= len(m.Ip) - copy(dAtA[i:], m.Ip) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Ip))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *TCPAddr) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TCPAddr) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TCPAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Zone) > 0 { - i -= len(m.Zone) - copy(dAtA[i:], m.Zone) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Zone))) - i-- - dAtA[i] = 0x1a - } - if m.Port != 0 { - i = encodeVarintRequest(dAtA, i, uint64(m.Port)) - i-- - dAtA[i] = 0x10 - } - if len(m.Ip) > 0 { - i -= len(m.Ip) - copy(dAtA[i:], m.Ip) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Ip))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UDPAddr) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UDPAddr) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UDPAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Zone) > 0 { - i -= len(m.Zone) - copy(dAtA[i:], m.Zone) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Zone))) - i-- - dAtA[i] = 0x1a - } - if m.Port != 0 { - i = encodeVarintRequest(dAtA, i, uint64(m.Port)) - i-- - dAtA[i] = 0x10 - } - if len(m.Ip) > 0 { - i -= len(m.Ip) - copy(dAtA[i:], m.Ip) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Ip))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UnixAddr) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UnixAddr) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UnixAddr) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Net) > 0 { - i -= len(m.Net) - copy(dAtA[i:], m.Net) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Net))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintRequest(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RequestContext) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RequestContext) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestContext) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ClientAddress != nil { - { - size := m.ClientAddress.Size() - i -= size - if _, err := m.ClientAddress.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if len(m.ClientMetadata) > 0 { - for iNdEx := len(m.ClientMetadata) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ClientMetadata[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.SpanContext != nil { - { - size, err := m.SpanContext.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RequestContext_Ip) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestContext_Ip) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Ip != nil { - { - size, err := m.Ip.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *RequestContext_Tcp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestContext_Tcp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Tcp != nil { - { - size, err := m.Tcp.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *RequestContext_Udp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestContext_Udp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Udp != nil { - { - size, err := m.Udp.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - return len(dAtA) - i, nil -} -func (m *RequestContext_Unix) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestContext_Unix) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Unix != nil { - { - size, err := m.Unix.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - return len(dAtA) - i, nil -} -func (m *TracesRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TracesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TracesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TracesData != nil { - { - size, err := m.TracesData.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.RequestContext != nil { - { - size, err := m.RequestContext.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.FormatVersion != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.FormatVersion)) - i-- - dAtA[i] = 0xd - } - return len(dAtA) - i, nil -} - -func (m *MetricsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MetricsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MetricsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.MetricsData != nil { - { - size, err := m.MetricsData.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.RequestContext != nil { - { - size, err := m.RequestContext.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.FormatVersion != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.FormatVersion)) - i-- - dAtA[i] = 0xd - } - return len(dAtA) - i, nil -} - -func (m *LogsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LogsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LogsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LogsData != nil { - { - size, err := m.LogsData.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.RequestContext != nil { - { - size, err := m.RequestContext.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.FormatVersion != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.FormatVersion)) - i-- - dAtA[i] = 0xd - } - return len(dAtA) - i, nil -} - -func (m *ProfilesRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ProfilesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProfilesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ProfilesData != nil { - { - size, err := m.ProfilesData.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.RequestContext != nil { - { - size, err := m.RequestContext.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRequest(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.FormatVersion != 0 { - i -= 4 - encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.FormatVersion)) - i-- - dAtA[i] = 0xd - } - return len(dAtA) - i, nil -} - -func encodeVarintRequest(dAtA []byte, offset int, v uint64) int { - offset -= sovRequest(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *SpanContext) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - l = len(m.SpanId) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - if m.TraceFlags != 0 { - n += 5 - } - l = len(m.TraceState) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - if m.Remote { - n += 2 - } - return n -} - -func (m *IPAddr) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Ip) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - l = len(m.Zone) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *TCPAddr) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Ip) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - if m.Port != 0 { - n += 1 + sovRequest(uint64(m.Port)) - } - l = len(m.Zone) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *UDPAddr) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Ip) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - if m.Port != 0 { - n += 1 + sovRequest(uint64(m.Port)) - } - l = len(m.Zone) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *UnixAddr) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - l = len(m.Net) - if l > 0 { - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *RequestContext) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SpanContext != nil { - l = m.SpanContext.Size() - n += 1 + l + sovRequest(uint64(l)) - } - if len(m.ClientMetadata) > 0 { - for _, e := range m.ClientMetadata { - l = e.Size() - n += 1 + l + sovRequest(uint64(l)) - } - } - if m.ClientAddress != nil { - n += m.ClientAddress.Size() - } - return n -} - -func (m *RequestContext_Ip) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Ip != nil { - l = m.Ip.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} -func (m *RequestContext_Tcp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Tcp != nil { - l = m.Tcp.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} -func (m *RequestContext_Udp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Udp != nil { - l = m.Udp.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} -func (m *RequestContext_Unix) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Unix != nil { - l = m.Unix.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} -func (m *TracesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FormatVersion != 0 { - n += 5 - } - if m.RequestContext != nil { - l = m.RequestContext.Size() - n += 1 + l + sovRequest(uint64(l)) - } - if m.TracesData != nil { - l = m.TracesData.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *MetricsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FormatVersion != 0 { - n += 5 - } - if m.RequestContext != nil { - l = m.RequestContext.Size() - n += 1 + l + sovRequest(uint64(l)) - } - if m.MetricsData != nil { - l = m.MetricsData.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *LogsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FormatVersion != 0 { - n += 5 - } - if m.RequestContext != nil { - l = m.RequestContext.Size() - n += 1 + l + sovRequest(uint64(l)) - } - if m.LogsData != nil { - l = m.LogsData.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func (m *ProfilesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FormatVersion != 0 { - n += 5 - } - if m.RequestContext != nil { - l = m.RequestContext.Size() - n += 1 + l + sovRequest(uint64(l)) - } - if m.ProfilesData != nil { - l = m.ProfilesData.Size() - n += 1 + l + sovRequest(uint64(l)) - } - return n -} - -func sovRequest(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozRequest(x uint64) (n int) { - return sovRequest(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *SpanContext) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SpanContext: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SpanContext: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SpanId = append(m.SpanId[:0], dAtA[iNdEx:postIndex]...) - if m.SpanId == nil { - m.SpanId = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceFlags", wireType) - } - m.TraceFlags = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.TraceFlags = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceState", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TraceState = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Remote", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Remote = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *IPAddr) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: IPAddr: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IPAddr: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ip", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ip = append(m.Ip[:0], dAtA[iNdEx:postIndex]...) - if m.Ip == nil { - m.Ip = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Zone", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Zone = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TCPAddr) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TCPAddr: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TCPAddr: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ip", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ip = append(m.Ip[:0], dAtA[iNdEx:postIndex]...) - if m.Ip == nil { - m.Ip = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) - } - m.Port = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Port |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Zone", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Zone = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UDPAddr) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UDPAddr: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UDPAddr: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ip", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ip = append(m.Ip[:0], dAtA[iNdEx:postIndex]...) - if m.Ip == nil { - m.Ip = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Port", wireType) - } - m.Port = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Port |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Zone", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Zone = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UnixAddr) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UnixAddr: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnixAddr: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Net", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Net = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RequestContext) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RequestContext: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RequestContext: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SpanContext", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SpanContext == nil { - m.SpanContext = &SpanContext{} - } - if err := m.SpanContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientMetadata", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientMetadata = append(m.ClientMetadata, v1.KeyValue{}) - if err := m.ClientMetadata[len(m.ClientMetadata)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ip", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &IPAddr{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.ClientAddress = &RequestContext_Ip{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tcp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &TCPAddr{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.ClientAddress = &RequestContext_Tcp{v} - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Udp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &UDPAddr{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.ClientAddress = &RequestContext_Udp{v} - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Unix", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &UnixAddr{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.ClientAddress = &RequestContext_Unix{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TracesRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TracesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TracesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) - } - m.FormatVersion = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.FormatVersion = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RequestContext == nil { - m.RequestContext = &RequestContext{} - } - if err := m.RequestContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TracesData", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.TracesData == nil { - m.TracesData = &v11.TracesData{} - } - if err := m.TracesData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MetricsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MetricsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MetricsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) - } - m.FormatVersion = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.FormatVersion = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RequestContext == nil { - m.RequestContext = &RequestContext{} - } - if err := m.RequestContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MetricsData", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.MetricsData == nil { - m.MetricsData = &v12.MetricsData{} - } - if err := m.MetricsData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LogsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LogsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LogsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) - } - m.FormatVersion = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.FormatVersion = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RequestContext == nil { - m.RequestContext = &RequestContext{} - } - if err := m.RequestContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LogsData", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.LogsData == nil { - m.LogsData = &v13.LogsData{} - } - if err := m.LogsData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ProfilesRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ProfilesRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProfilesRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 5 { - return fmt.Errorf("proto: wrong wireType = %d for field FormatVersion", wireType) - } - m.FormatVersion = 0 - if (iNdEx + 4) > l { - return io.ErrUnexpectedEOF - } - m.FormatVersion = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) - iNdEx += 4 - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestContext", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RequestContext == nil { - m.RequestContext = &RequestContext{} - } - if err := m.RequestContext.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProfilesData", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRequest - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRequest - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRequest - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ProfilesData == nil { - m.ProfilesData = &v1development.ProfilesData{} - } - if err := m.ProfilesData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRequest(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRequest - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipRequest(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRequest - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRequest - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRequest - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthRequest - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupRequest - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthRequest - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthRequest = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowRequest = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupRequest = fmt.Errorf("proto: unexpected end of group") -) diff --git a/pdata/xpdata/request/logs_request.go b/pdata/xpdata/request/logs_request.go index a5483ce4872..5d4a20ff230 100644 --- a/pdata/xpdata/request/logs_request.go +++ b/pdata/xpdata/request/logs_request.go @@ -9,19 +9,18 @@ import ( "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/plog" - reqint "go.opentelemetry.io/collector/pdata/xpdata/request/internal" ) // MarshalLogs marshals plog.Logs along with the context into a byte slice. func MarshalLogs(ctx context.Context, ld plog.Logs) ([]byte, error) { - otlpLogs := internal.LogsToProto(internal.Logs(ld)) - rc := encodeContext(ctx) - lr := reqint.LogsRequest{ + lr := internal.LogsRequest{ FormatVersion: requestFormatVersion, - LogsData: &otlpLogs, - RequestContext: &rc, + LogsData: internal.LogsToProto(internal.LogsWrapper(ld)), + RequestContext: encodeContext(ctx), } - return lr.Marshal() + buf := make([]byte, lr.SizeProto()) + lr.MarshalProto(buf) + return buf, nil } // UnmarshalLogs unmarshals a byte slice into plog.Logs and the context. @@ -30,9 +29,9 @@ func UnmarshalLogs(buf []byte) (context.Context, plog.Logs, error) { if !isRequestPayloadV1(buf) { return ctx, plog.Logs{}, ErrInvalidFormat } - lr := reqint.LogsRequest{} - if err := lr.Unmarshal(buf); err != nil { + lr := internal.LogsRequest{} + if err := lr.UnmarshalProto(buf); err != nil { return ctx, plog.Logs{}, fmt.Errorf("failed to unmarshal logs request: %w", err) } - return decodeContext(ctx, lr.RequestContext), plog.Logs(internal.LogsFromProto(*lr.LogsData)), nil + return decodeContext(ctx, lr.RequestContext), plog.Logs(internal.LogsFromProto(lr.LogsData)), nil } diff --git a/pdata/xpdata/request/metrics_request.go b/pdata/xpdata/request/metrics_request.go index b4796da5243..38e59bf6893 100644 --- a/pdata/xpdata/request/metrics_request.go +++ b/pdata/xpdata/request/metrics_request.go @@ -9,19 +9,18 @@ import ( "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/pmetric" - reqint "go.opentelemetry.io/collector/pdata/xpdata/request/internal" ) // MarshalMetrics marshals pmetric.Metrics along with the context into a byte slice. func MarshalMetrics(ctx context.Context, ld pmetric.Metrics) ([]byte, error) { - otlpMetrics := internal.MetricsToProto(internal.Metrics(ld)) - rc := encodeContext(ctx) - mr := reqint.MetricsRequest{ + mr := internal.MetricsRequest{ FormatVersion: requestFormatVersion, - MetricsData: &otlpMetrics, - RequestContext: &rc, + MetricsData: internal.MetricsToProto(internal.MetricsWrapper(ld)), + RequestContext: encodeContext(ctx), } - return mr.Marshal() + buf := make([]byte, mr.SizeProto()) + mr.MarshalProto(buf) + return buf, nil } // UnmarshalMetrics unmarshals a byte slice into pmetric.Metrics and the context. @@ -30,9 +29,9 @@ func UnmarshalMetrics(buf []byte) (context.Context, pmetric.Metrics, error) { if !isRequestPayloadV1(buf) { return ctx, pmetric.Metrics{}, ErrInvalidFormat } - mr := reqint.MetricsRequest{} - if err := mr.Unmarshal(buf); err != nil { + mr := internal.MetricsRequest{} + if err := mr.UnmarshalProto(buf); err != nil { return ctx, pmetric.Metrics{}, fmt.Errorf("failed to unmarshal metrics request: %w", err) } - return decodeContext(ctx, mr.RequestContext), pmetric.Metrics(internal.MetricsFromProto(*mr.MetricsData)), nil + return decodeContext(ctx, mr.RequestContext), pmetric.Metrics(internal.MetricsFromProto(mr.MetricsData)), nil } diff --git a/pdata/xpdata/request/profiles_request.go b/pdata/xpdata/request/profiles_request.go index b13c065fe92..de099ea81cf 100644 --- a/pdata/xpdata/request/profiles_request.go +++ b/pdata/xpdata/request/profiles_request.go @@ -9,19 +9,18 @@ import ( "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/pprofile" - reqint "go.opentelemetry.io/collector/pdata/xpdata/request/internal" ) // MarshalProfiles marshals pprofile.Profiles along with the context into a byte slice. func MarshalProfiles(ctx context.Context, ld pprofile.Profiles) ([]byte, error) { - otlpProfiles := internal.ProfilesToProto(internal.Profiles(ld)) - rc := encodeContext(ctx) - pr := reqint.ProfilesRequest{ + pr := internal.ProfilesRequest{ FormatVersion: requestFormatVersion, - ProfilesData: &otlpProfiles, - RequestContext: &rc, + ProfilesData: internal.ProfilesToProto(internal.ProfilesWrapper(ld)), + RequestContext: encodeContext(ctx), } - return pr.Marshal() + buf := make([]byte, pr.SizeProto()) + pr.MarshalProto(buf) + return buf, nil } // UnmarshalProfiles unmarshals a byte slice into pprofile.Profiles and the context. @@ -30,9 +29,9 @@ func UnmarshalProfiles(buf []byte) (context.Context, pprofile.Profiles, error) { if !isRequestPayloadV1(buf) { return ctx, pprofile.Profiles{}, ErrInvalidFormat } - pr := reqint.ProfilesRequest{} - if err := pr.Unmarshal(buf); err != nil { + pr := internal.ProfilesRequest{} + if err := pr.UnmarshalProto(buf); err != nil { return ctx, pprofile.Profiles{}, fmt.Errorf("failed to unmarshal profiles request: %w", err) } - return decodeContext(ctx, pr.RequestContext), pprofile.Profiles(internal.ProfilesFromProto(*pr.ProfilesData)), nil + return decodeContext(ctx, pr.RequestContext), pprofile.Profiles(internal.ProfilesFromProto(pr.ProfilesData)), nil } diff --git a/pdata/xpdata/request/traces_request.go b/pdata/xpdata/request/traces_request.go index ff5312b1231..c427ccfc781 100644 --- a/pdata/xpdata/request/traces_request.go +++ b/pdata/xpdata/request/traces_request.go @@ -9,19 +9,18 @@ import ( "go.opentelemetry.io/collector/pdata/internal" "go.opentelemetry.io/collector/pdata/ptrace" - reqint "go.opentelemetry.io/collector/pdata/xpdata/request/internal" ) // MarshalTraces marshals ptrace.Traces along with the context into a byte slice. func MarshalTraces(ctx context.Context, ld ptrace.Traces) ([]byte, error) { - otlpTraces := internal.TracesToProto(internal.Traces(ld)) - rc := encodeContext(ctx) - tr := reqint.TracesRequest{ + tr := internal.TracesRequest{ FormatVersion: requestFormatVersion, - TracesData: &otlpTraces, - RequestContext: &rc, + TracesData: internal.TracesToProto(internal.TracesWrapper(ld)), + RequestContext: encodeContext(ctx), } - return tr.Marshal() + buf := make([]byte, tr.SizeProto()) + tr.MarshalProto(buf) + return buf, nil } // UnmarshalTraces unmarshals a byte slice into ptrace.Traces and the context. @@ -30,9 +29,9 @@ func UnmarshalTraces(buf []byte) (context.Context, ptrace.Traces, error) { if !isRequestPayloadV1(buf) { return ctx, ptrace.Traces{}, ErrInvalidFormat } - tr := reqint.TracesRequest{} - if err := tr.Unmarshal(buf); err != nil { + tr := internal.TracesRequest{} + if err := tr.UnmarshalProto(buf); err != nil { return ctx, ptrace.Traces{}, fmt.Errorf("failed to unmarshal traces request: %w", err) } - return decodeContext(ctx, tr.RequestContext), ptrace.Traces(internal.TracesFromProto(*tr.TracesData)), nil + return decodeContext(ctx, tr.RequestContext), ptrace.Traces(internal.TracesFromProto(tr.TracesData)), nil } diff --git a/processor/batchprocessor/go.mod b/processor/batchprocessor/go.mod index 8012582becc..16b1ba733a4 100644 --- a/processor/batchprocessor/go.mod +++ b/processor/batchprocessor/go.mod @@ -30,7 +30,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -52,9 +51,7 @@ require ( go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/processor/batchprocessor/go.sum b/processor/batchprocessor/go.sum index 0b7379d1cba..2947391620a 100644 --- a/processor/batchprocessor/go.sum +++ b/processor/batchprocessor/go.sum @@ -10,8 +10,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -23,8 +21,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -53,8 +49,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -81,39 +75,12 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/processor/go.mod b/processor/go.mod index 98e70ddcda9..266fbd6a759 100644 --- a/processor/go.mod +++ b/processor/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -25,16 +24,9 @@ require ( go.opentelemetry.io/collector/pdata/pprofile v0.138.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/processor/go.sum b/processor/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/processor/go.sum +++ b/processor/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/processor/memorylimiterprocessor/go.mod b/processor/memorylimiterprocessor/go.mod index 0b5cd7b75a3..a35c8b59f34 100644 --- a/processor/memorylimiterprocessor/go.mod +++ b/processor/memorylimiterprocessor/go.mod @@ -37,7 +37,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -63,9 +62,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/processor/memorylimiterprocessor/go.sum b/processor/memorylimiterprocessor/go.sum index 95f584033a8..3b79e8b7524 100644 --- a/processor/memorylimiterprocessor/go.sum +++ b/processor/memorylimiterprocessor/go.sum @@ -14,8 +14,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -28,8 +26,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -68,8 +64,6 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= @@ -98,41 +92,15 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/processor/processorhelper/go.mod b/processor/processorhelper/go.mod index 17a54ae1e15..688682c3b36 100644 --- a/processor/processorhelper/go.mod +++ b/processor/processorhelper/go.mod @@ -25,7 +25,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -42,12 +41,7 @@ require ( go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/processor/processorhelper/go.sum b/processor/processorhelper/go.sum index 1839d792534..f34047270f4 100644 --- a/processor/processorhelper/go.sum +++ b/processor/processorhelper/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/processor/processorhelper/xprocessorhelper/go.mod b/processor/processorhelper/xprocessorhelper/go.mod index 0e000dd94bf..66460803106 100644 --- a/processor/processorhelper/xprocessorhelper/go.mod +++ b/processor/processorhelper/xprocessorhelper/go.mod @@ -20,7 +20,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -40,12 +39,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/processor/processorhelper/xprocessorhelper/go.sum b/processor/processorhelper/xprocessorhelper/go.sum index 1839d792534..f34047270f4 100644 --- a/processor/processorhelper/xprocessorhelper/go.sum +++ b/processor/processorhelper/xprocessorhelper/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/processor/processortest/go.mod b/processor/processortest/go.mod index 3c31e1201a9..56ac6ac6cd0 100644 --- a/processor/processortest/go.mod +++ b/processor/processortest/go.mod @@ -23,7 +23,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -39,12 +38,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/processor/processortest/go.sum b/processor/processortest/go.sum index 1839d792534..f34047270f4 100644 --- a/processor/processortest/go.sum +++ b/processor/processortest/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/processor/xprocessor/go.mod b/processor/xprocessor/go.mod index 29bc963573a..a7560d377fa 100644 --- a/processor/xprocessor/go.mod +++ b/processor/xprocessor/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -28,12 +27,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/processor/xprocessor/go.sum b/processor/xprocessor/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/processor/xprocessor/go.sum +++ b/processor/xprocessor/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/proto_patch.sed b/proto_patch.sed deleted file mode 100644 index 6e5fc8c2572..00000000000 --- a/proto_patch.sed +++ /dev/null @@ -1,70 +0,0 @@ -s+go.opentelemetry.io/proto/otlp/+go.opentelemetry.io/collector/pdata/internal/data/protogen/+g - -s+package opentelemetry\.proto\.\(.*\)\.v\(.*\);+package opentelemetry.proto.\1.v\2;\ -\ -import "gogoproto/gogo.proto";+g - -s+bytes trace_id = \(.*\);+bytes trace_id = \1\ - [\ - // Use custom TraceId data type for this field.\ - (gogoproto.nullable) = false,\ - (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.TraceID"\ - ];+g - -s+bytes \(.*span_id\) = \(.*\);+bytes \1 = \2\ - [\ - // Use custom SpanId data type for this field.\ - (gogoproto.nullable) = false,\ - (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.SpanID"\ - ];+g - -s+repeated opentelemetry.proto.common.v1.KeyValue \(.*\);+repeated opentelemetry.proto.common.v1.KeyValue \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated KeyValue \(.*\);+repeated KeyValue \1\ - [ (gogoproto.nullable) = false ];+g - -s+AnyValue \(.*\);+AnyValue \1\ - [ (gogoproto.nullable) = false ];+g - -s+opentelemetry.proto.resource.v1.Resource resource = \(.*\);+opentelemetry.proto.resource.v1.Resource resource = \1\ - [ (gogoproto.nullable) = false ];+g - -s+opentelemetry.proto.common.v1.InstrumentationScope scope = \(.*\);+opentelemetry.proto.common.v1.InstrumentationScope scope = \1\ - [ (gogoproto.nullable) = false ];+g - -s+Status \(.*\);+Status \1\ - [ (gogoproto.nullable) = false ];+g - -s+repeated Exemplar exemplars = \(.*\);+repeated Exemplar exemplars = \1\ - [ (gogoproto.nullable) = false ];+g - -s+Buckets \(.*\)tive = \(.*\);+Buckets \1tive = \2\ - [ (gogoproto.nullable) = false ];+g - -# optional fixed64 foo = 1 -> oneof foo_ { fixed64 foo = 1;} -s+optional \(.*\) \(.*\) = \(.*\);+ oneof \2_ { \1 \2 = \3;}+g - -s+\(.*\)PartialSuccess partial_success = \(.*\);+\1PartialSuccess partial_success = \2\ - [ (gogoproto.nullable) = false ];+g - -# -# Profiles replacements -# -s+opentelemetry.proto.profiles.v1development.Profile \(.*\);+opentelemetry.proto.profiles.v1development.Profile \1\ - [ (gogoproto.nullable) = false ];+g - -s+ProfilesDictionary \(.*\);+ProfilesDictionary \1\ - [ (gogoproto.nullable) = false ];+g - -s+bytes profile_id = \(.*\);+bytes profile_id = \1\ - [\ - // Use custom ProfileId data type for this field.\ - (gogoproto.nullable) = false,\ - (gogoproto.customtype) = "go.opentelemetry.io/collector/pdata/internal/data.ProfileID"\ - ];+g - -s+ValueType sample_type \(.*\);+ValueType sample_type \1\ - [ (gogoproto.nullable) = false ];+g -s+ValueType period_type \(.*\);+ValueType period_type \1\ - [ (gogoproto.nullable) = false ];+g diff --git a/receiver/go.mod b/receiver/go.mod index 2985cccc62b..32e88dfff40 100644 --- a/receiver/go.mod +++ b/receiver/go.mod @@ -14,7 +14,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -25,16 +24,9 @@ require ( go.opentelemetry.io/collector/pdata/pprofile v0.138.0 // indirect go.opentelemetry.io/otel v1.38.0 // indirect go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/receiver/go.sum b/receiver/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/receiver/go.sum +++ b/receiver/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/receiver/nopreceiver/go.mod b/receiver/nopreceiver/go.mod index 60be425d1ee..aae889d90ba 100644 --- a/receiver/nopreceiver/go.mod +++ b/receiver/nopreceiver/go.mod @@ -22,7 +22,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -48,9 +47,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/receiver/nopreceiver/go.sum b/receiver/nopreceiver/go.sum index 0b7379d1cba..2947391620a 100644 --- a/receiver/nopreceiver/go.sum +++ b/receiver/nopreceiver/go.sum @@ -10,8 +10,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -23,8 +21,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= github.com/knadh/koanf/maps v0.1.2/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= github.com/knadh/koanf/providers/confmap v1.0.0 h1:mHKLJTE7iXEys6deO5p6olAiZdG5zwp8Aebir+/EaRE= @@ -53,8 +49,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -81,39 +75,12 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/receiver/otlpreceiver/go.mod b/receiver/otlpreceiver/go.mod index 527f0679f20..1474c89b3da 100644 --- a/receiver/otlpreceiver/go.mod +++ b/receiver/otlpreceiver/go.mod @@ -49,7 +49,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v1.0.0 // indirect github.com/google/go-tpm v0.9.6 // indirect github.com/google/uuid v1.6.0 // indirect diff --git a/receiver/otlpreceiver/go.sum b/receiver/otlpreceiver/go.sum index 93d53e4eae8..0f8f89bb16e 100644 --- a/receiver/otlpreceiver/go.sum +++ b/receiver/otlpreceiver/go.sum @@ -18,8 +18,6 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= @@ -37,8 +35,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -75,8 +71,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 h1:YH4g8lQroajqUwWbq/tr2QX1JFmEXaDLgG+ew9bLMWo= @@ -107,39 +101,14 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= diff --git a/receiver/receiverhelper/go.mod b/receiver/receiverhelper/go.mod index 9711321afd1..04ba3adfe73 100644 --- a/receiver/receiverhelper/go.mod +++ b/receiver/receiverhelper/go.mod @@ -21,7 +21,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -35,9 +34,7 @@ require ( go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/receiver/receiverhelper/go.sum b/receiver/receiverhelper/go.sum index 1839d792534..c457f291806 100644 --- a/receiver/receiverhelper/go.sum +++ b/receiver/receiverhelper/go.sum @@ -6,8 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -19,8 +17,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +35,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,39 +59,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/receiver/receivertest/go.mod b/receiver/receivertest/go.mod index 1dbe444b040..5cc2fc3d680 100644 --- a/receiver/receivertest/go.mod +++ b/receiver/receivertest/go.mod @@ -22,7 +22,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -38,9 +37,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/receiver/receivertest/go.sum b/receiver/receivertest/go.sum index 1839d792534..c457f291806 100644 --- a/receiver/receivertest/go.sum +++ b/receiver/receivertest/go.sum @@ -6,8 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -19,8 +17,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +35,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,39 +59,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/receiver/xreceiver/go.mod b/receiver/xreceiver/go.mod index e518c946e56..528a2a386cd 100644 --- a/receiver/xreceiver/go.mod +++ b/receiver/xreceiver/go.mod @@ -13,7 +13,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -28,12 +27,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/receiver/xreceiver/go.sum b/receiver/xreceiver/go.sum index e57ea2a3cda..8953e68cd37 100644 --- a/receiver/xreceiver/go.sum +++ b/receiver/xreceiver/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -38,18 +30,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -64,43 +50,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/scraper/go.mod b/scraper/go.mod index 2fcbb6ce32f..ef0512b3935 100644 --- a/scraper/go.mod +++ b/scraper/go.mod @@ -16,7 +16,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -31,12 +30,7 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/scraper/go.sum b/scraper/go.sum index 1839d792534..f34047270f4 100644 --- a/scraper/go.sum +++ b/scraper/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +33,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,43 +57,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/scraper/scraperhelper/go.mod b/scraper/scraperhelper/go.mod index b0122901281..3ff424d65e4 100644 --- a/scraper/scraperhelper/go.mod +++ b/scraper/scraperhelper/go.mod @@ -29,7 +29,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -42,9 +41,7 @@ require ( go.opentelemetry.io/collector/featuregate v1.44.0 // indirect go.opentelemetry.io/collector/pdata/pprofile v0.138.0 // indirect go.opentelemetry.io/collector/receiver/xreceiver v0.138.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.76.0 // indirect google.golang.org/protobuf v1.36.10 // indirect diff --git a/scraper/scraperhelper/go.sum b/scraper/scraperhelper/go.sum index 1839d792534..c457f291806 100644 --- a/scraper/scraperhelper/go.sum +++ b/scraper/scraperhelper/go.sum @@ -6,8 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -19,8 +17,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -39,8 +35,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -65,39 +59,12 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= diff --git a/scraper/scrapertest/go.mod b/scraper/scrapertest/go.mod index 151501ba3f4..6a97869cefb 100644 --- a/scraper/scrapertest/go.mod +++ b/scraper/scrapertest/go.mod @@ -12,7 +12,6 @@ require ( require ( github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -28,12 +27,7 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.42.0 // indirect golang.org/x/sys v0.35.0 // indirect - golang.org/x/text v0.27.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect ) replace go.opentelemetry.io/collector/component/componenttest => ../../component/componenttest diff --git a/scraper/scrapertest/go.sum b/scraper/scrapertest/go.sum index 47b806f453c..2aecac0e1a4 100644 --- a/scraper/scrapertest/go.sum +++ b/scraper/scrapertest/go.sum @@ -6,10 +6,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -19,8 +15,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -33,8 +27,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= @@ -59,43 +51,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/service/go.mod b/service/go.mod index b9ecfe794e8..63682cac60f 100644 --- a/service/go.mod +++ b/service/go.mod @@ -77,7 +77,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v1.0.0 // indirect github.com/google/go-tpm v0.9.6 // indirect github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect diff --git a/service/go.sum b/service/go.sum index 8cefd0b0316..d00b6935178 100644 --- a/service/go.sum +++ b/service/go.sum @@ -55,8 +55,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo= @@ -120,8 +118,6 @@ github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8O github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= @@ -194,43 +190,19 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI= golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY= diff --git a/service/hostcapabilities/go.mod b/service/hostcapabilities/go.mod index 388dbeb9db4..dad6f8d8692 100644 --- a/service/hostcapabilities/go.mod +++ b/service/hostcapabilities/go.mod @@ -9,7 +9,6 @@ require ( ) require ( - github.com/gogo/protobuf v1.3.2 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -21,12 +20,6 @@ require ( go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.44.0 // indirect - golang.org/x/sys v0.36.0 // indirect - golang.org/x/text v0.29.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect - google.golang.org/grpc v1.76.0 // indirect - google.golang.org/protobuf v1.36.10 // indirect ) replace ( diff --git a/service/hostcapabilities/go.sum b/service/hostcapabilities/go.sum index cf41f097c02..cb8fb07c43b 100644 --- a/service/hostcapabilities/go.sum +++ b/service/hostcapabilities/go.sum @@ -5,21 +5,13 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -32,18 +24,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= go.opentelemetry.io/proto/slim/otlp v1.8.0 h1:afcLwp2XOeCbGrjufT1qWyruFt+6C9g5SOuymrSPUXQ= @@ -58,43 +44,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= -golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= -golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= -golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc= -google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= -google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/service/telemetry/telemetrytest/go.mod b/service/telemetry/telemetrytest/go.mod index f53ebf99d28..6d5007970e5 100644 --- a/service/telemetry/telemetrytest/go.mod +++ b/service/telemetry/telemetrytest/go.mod @@ -19,7 +19,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect diff --git a/service/telemetry/telemetrytest/go.sum b/service/telemetry/telemetrytest/go.sum index 63d4814bdbd..c6a94f9c9e1 100644 --- a/service/telemetry/telemetrytest/go.sum +++ b/service/telemetry/telemetrytest/go.sum @@ -12,8 +12,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -29,8 +27,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -65,8 +61,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/otelconf v0.18.0 h1:ciF2Gf00BWs0DnexKFZXcxg9kJ8r3SUW1LOzW3CsKA8= @@ -127,37 +121,12 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I= golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 h1:BIRfGDEjiHRrk0QKZe3Xv2ieMhtgRGeLcZQ0mIVn4EY=