From 33d86327cea22133eb32747902194ef8e49fa9b4 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 22 Jun 2023 12:51:26 -0700 Subject: [PATCH] add auto-generated configuration code (#7679) This is generated from the opentelemetry-configuration repository using gojsonschema. Updated makefile to support this w/ `make genjsonschema` Follow up to https://github.com/open-telemetry/opentelemetry-collector/pull/7678 --------- Signed-off-by: Alex Boten --- .github/workflows/perf.yml | 29 ++++ .gitignore | 3 + Makefile | 24 ++++ Makefile.Common | 31 +++-- internal/tools/go.mod | 10 +- internal/tools/go.sum | 20 ++- internal/tools/tools.go | 1 + service/telemetry/generated_config.go | 192 ++++++++++++++++++++++++++ 8 files changed, 289 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/perf.yml create mode 100644 service/telemetry/generated_config.go diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml new file mode 100644 index 00000000000..bed7e48ff3e --- /dev/null +++ b/.github/workflows/perf.yml @@ -0,0 +1,29 @@ +name: Automation - Performance + +on: + push: + branches: [main] + +jobs: + runperf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ~1.19.10 + + - name: Run benchmark + run: make gobenchmark + + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + tool: 'go' + output-file-path: benchmarks.txt + gh-pages-branch: gh-pages + auto-push: true + github-token: ${{ secrets.GITHUB_TOKEN }} + benchmark-data-dir-path: "docs/dev/bench" diff --git a/.gitignore b/.gitignore index bd37d3da0cd..dc953359570 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,9 @@ dist/ coverage/* coverage.txt +# Benchmarks +benchmarks.txt + # Wix *.wixobj *.wixpdb diff --git a/Makefile b/Makefile index 7be68dbac92..bf25204283c 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ gotest: .PHONY: gobenchmark gobenchmark: @$(MAKE) for-all-target TARGET="benchmark" + cat `find . -name benchmark.txt` > benchmarks.txt .PHONY: gotest-with-cover gotest-with-cover: @@ -258,6 +259,29 @@ genpdata: $(GOCMD) run pdata/internal/cmd/pdatagen/main.go $(MAKE) fmt +# The source directory for configuration schema. +OPENTELEMETRY_JSONSCHEMA_SRC_DIR=service/internal/proctelemetry/opentelememetry-configuration + +# The SHA matching the current version of the configuration schema to use +OPENTELEMETRY_JSONSCHEMA_VERSION=main + +# Cleanup temporary directory +genjsonschema-cleanup: + rm -Rf ${OPENTELEMETRY_JSONSCHEMA_SRC_DIR} + +# Generate structs for configuration from configuration schema +genjsonschema: genjsonschema-cleanup $(GOJSONSCHEMA) + mkdir -p ${OPENTELEMETRY_JSONSCHEMA_SRC_DIR} + curl -sSL https://api.github.com/repos/open-telemetry/opentelemetry-configuration/tarball/${OPENTELEMETRY_JSONSCHEMA_VERSION} | tar xz --strip 1 -C ${OPENTELEMETRY_JSONSCHEMA_SRC_DIR} + $(GOJSONSCHEMA) \ + --package telemetry \ + --tags mapstructure \ + --output ./service/telemetry/generated_config.go \ + --schema-package=https://opentelemetry.io/otelconfig/opentelemetry_configuration.json=github.com/open-telemetry/opentelemetry-collector/schema \ + ${OPENTELEMETRY_JSONSCHEMA_SRC_DIR}/schema/opentelemetry_configuration.json + $(MAKE) fmt + $(MAKE) genjsonschema-cleanup + # Generate semantic convention constants. Requires a clone of the opentelemetry-specification repo gensemconv: @[ "${SPECPATH}" ] || ( echo ">> env var SPECPATH is not set"; exit 1 ) diff --git a/Makefile.Common b/Makefile.Common index 9a10afbb751..bb4dfb8d859 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -15,20 +15,21 @@ TOOLS_MOD_REGEX := "\s+_\s+\".*\"" TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"" | grep -vE '/v[0-9]+$$') TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES)))) -ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense -APIDIFF := $(TOOLS_BIN_DIR)/apidiff -CHECKDOC := $(TOOLS_BIN_DIR)/checkdoc -CHLOG := $(TOOLS_BIN_DIR)/chloggen -CROSSLINK := $(TOOLS_BIN_DIR)/crosslink -ENVSUBST := $(TOOLS_BIN_DIR)/envsubst -GOIMPORTS := $(TOOLS_BIN_DIR)/goimports -GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck -LINT := $(TOOLS_BIN_DIR)/golangci-lint -IMPI := $(TOOLS_BIN_DIR)/impi -MISSPELL := $(TOOLS_BIN_DIR)/misspell -MULTIMOD := $(TOOLS_BIN_DIR)/multimod -PORTO := $(TOOLS_BIN_DIR)/porto -YQ := $(TOOLS_BIN_DIR)/yq +ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense +APIDIFF := $(TOOLS_BIN_DIR)/apidiff +CHECKDOC := $(TOOLS_BIN_DIR)/checkdoc +CHLOG := $(TOOLS_BIN_DIR)/chloggen +CROSSLINK := $(TOOLS_BIN_DIR)/crosslink +ENVSUBST := $(TOOLS_BIN_DIR)/envsubst +GOIMPORTS := $(TOOLS_BIN_DIR)/goimports +GOJSONSCHEMA := $(TOOLS_BIN_DIR)/gojsonschema +GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck +LINT := $(TOOLS_BIN_DIR)/golangci-lint +IMPI := $(TOOLS_BIN_DIR)/impi +MISSPELL := $(TOOLS_BIN_DIR)/misspell +MULTIMOD := $(TOOLS_BIN_DIR)/multimod +PORTO := $(TOOLS_BIN_DIR)/porto +YQ := $(TOOLS_BIN_DIR)/yq GH := $(shell which gh) @@ -55,7 +56,7 @@ test-with-cover: $(GO_ACC) .PHONY: benchmark benchmark: - $(GOTEST) -bench=. -run=notests ./... + $(GOTEST) -bench=. -run=notests ./... | tee benchmark.txt .PHONY: fmt fmt: $(GOIMPORTS) diff --git a/internal/tools/go.mod b/internal/tools/go.mod index daaa922383f..fcb0cee51dd 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( github.com/a8m/envsubst v1.4.2 + github.com/atombender/go-jsonschema v0.11.0 github.com/client9/misspell v0.3.4 github.com/golangci/golangci-lint v1.53.3 github.com/google/addlicense v1.1.1 @@ -15,7 +16,7 @@ require ( go.opentelemetry.io/build-tools/crosslink v0.8.0 go.opentelemetry.io/build-tools/multimod v0.8.0 go.opentelemetry.io/build-tools/semconvgen v0.8.0 - golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/tools v0.10.0 golang.org/x/vuln v0.1.0 ) @@ -41,7 +42,6 @@ require ( github.com/alingse/asasalint v0.0.11 // indirect github.com/ashanbrown/forbidigo v1.5.3 // indirect github.com/ashanbrown/makezero v1.1.1 // indirect - github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bkielbasa/cyclop v1.2.1 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect @@ -137,6 +137,7 @@ require ( github.com/mbilski/exhaustivestruct v1.2.0 // indirect github.com/mgechev/revive v1.3.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moricho/tparallel v0.3.1 // indirect github.com/nakabonne/nestif v0.3.1 // indirect @@ -147,6 +148,7 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.4.2 // indirect github.com/prometheus/client_golang v1.16.0 // indirect @@ -159,6 +161,7 @@ require ( github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/ryancurrah/gomodguard v1.3.0 // indirect github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect + github.com/sanity-io/litter v1.5.5 // indirect github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.23.0 // indirect @@ -229,3 +232,6 @@ retract ( v0.57.1 // Release failed, use v0.57.2 v0.57.0 // Release failed, use v0.57.2 ) + +// work around until https://github.com/omissis/go-jsonschema/pull/80 is merged +replace github.com/atombender/go-jsonschema v0.11.0 => github.com/codeboten/go-jsonschema v0.0.0-20230622190031-76e0cafc4ced diff --git a/internal/tools/go.sum b/internal/tools/go.sum index 82808f37d98..ea0b3332ed6 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -89,8 +89,7 @@ github.com/ashanbrown/forbidigo v1.5.3 h1:jfg+fkm/snMx+V9FBwsl1d340BV/99kZGv5jN9 github.com/ashanbrown/forbidigo v1.5.3/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -132,12 +131,15 @@ github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUK github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/codeboten/go-jsonschema v0.0.0-20230622190031-76e0cafc4ced h1:wZe0sCnIxs39oMjxSrZFZDq6ZPxByIcALMGk5nE5nvA= +github.com/codeboten/go-jsonschema v0.0.0-20230622190031-76e0cafc4ced/go.mod h1:6WyhPNbz6H8M3IzlAd1DMENTh/QUHBYoFe8na6yl1FE= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= github.com/daixiang0/gci v0.10.1 h1:eheNA3ljF6SxnPD/vE4lCBusVHmV3Rs3dkKvFrJ7MR0= github.com/daixiang0/gci v0.10.1/go.mod h1:xtHP9N7AHdNvtRNfcx9gwTDfw7FRJx4bZUsiEfiNNAI= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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= @@ -191,6 +193,9 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-toolsmith/astcast v1.1.0 h1:+JN9xZV1A+Re+95pgnMgDboWNVnIMMQXwfBwLRPgSC8= @@ -396,6 +401,7 @@ github.com/ldez/gomoddirectives v0.2.3 h1:y7MBaisZVDYmKvt9/l1mjNCiSA1BVn34U0ObUc github.com/ldez/gomoddirectives v0.2.3/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leonklingele/grouper v1.1.1 h1:suWXRU57D4/Enn6pXR0QVqqWWrnJ9Osrz+5rjt8ivzU= github.com/leonklingele/grouper v1.1.1/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= github.com/lufeee/execinquery v1.2.1 h1:hf0Ems4SHcUGBxpGN7Jz78z1ppVkP/837ZlETPCEtOM= @@ -429,6 +435,8 @@ github.com/mikefarah/yq/v4 v4.34.1 h1:7W+SZXvu1yOxpVXS7Hi5a34nU/gdYPjWMNQqoSlfbx github.com/mikefarah/yq/v4 v4.34.1/go.mod h1:B2JxXiGKqEaU+GTcNwOZ/RQFelq9e6TFIDLRVVFHAu4= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -473,6 +481,7 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v1.4.2 h1:CU+O4181IxFDdPH6t/HT7IiDj1I7zxNi1RIUxYwn8d0= @@ -518,6 +527,8 @@ github.com/ryancurrah/gomodguard v1.3.0 h1:q15RT/pd6UggBXVBuLps8BXRvl5GPBcwVA7BJ github.com/ryancurrah/gomodguard v1.3.0/go.mod h1:ggBxb3luypPEzqVtq33ee7YSN35V28XeGnid8dnni50= github.com/ryanrolds/sqlclosecheck v0.4.0 h1:i8SX60Rppc1wRuyQjMciLqIzV3xnoHB7/tXbr6RGYNI= github.com/ryanrolds/sqlclosecheck v0.4.0/go.mod h1:TBRRjzL31JONc9i4XMinicuo+s+E8yKZ5FN8X3G6CKQ= +github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= +github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= github.com/sanposhiho/wastedassign/v2 v2.0.7 h1:J+6nrY4VW+gC9xFzUc+XjPD3g3wF3je/NsJFwFK7Uxc= github.com/sanposhiho/wastedassign/v2 v2.0.7/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= @@ -571,6 +582,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -681,8 +693,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= -golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 h1:J74nGeMgeFnYQJN59eFwh06jX/V8g0lB7LWpjSLxtgU= diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 1b83f78fe01..ed51ce04472 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -13,6 +13,7 @@ package tools // import "go.opentelemetry.io/collector/internal/tools" import ( _ "github.com/a8m/envsubst/cmd/envsubst" + _ "github.com/atombender/go-jsonschema/cmd/gojsonschema" _ "github.com/client9/misspell/cmd/misspell" _ "github.com/golangci/golangci-lint/cmd/golangci-lint" _ "github.com/google/addlicense" diff --git a/service/telemetry/generated_config.go b/service/telemetry/generated_config.go new file mode 100644 index 00000000000..0606978bf88 --- /dev/null +++ b/service/telemetry/generated_config.go @@ -0,0 +1,192 @@ +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. + +package telemetry + +import ( + "encoding/json" + "fmt" +) + +type Attributes struct { + // ServiceName corresponds to the JSON schema field "service.name". + ServiceName *string `mapstructure:"service.name,omitempty"` +} + +type CommonJson map[string]interface{} + +type Console map[string]interface{} + +type Headers map[string]interface{} + +type LoggerProviderJson struct { + // LogrecordLimits corresponds to the JSON schema field "logrecord_limits". + LogrecordLimits *LoggerProviderJsonLogrecordLimits `mapstructure:"logrecord_limits,omitempty"` +} + +type LoggerProviderJsonLogrecordLimits struct { + // AttributeCountLimit corresponds to the JSON schema field + // "attribute_count_limit". + AttributeCountLimit *int `mapstructure:"attribute_count_limit,omitempty"` + + // AttributeValueLengthLimit corresponds to the JSON schema field + // "attribute_value_length_limit". + AttributeValueLengthLimit *int `mapstructure:"attribute_value_length_limit,omitempty"` +} + +type MeterProviderJson struct { + // MetricReaders corresponds to the JSON schema field "metric_readers". + MetricReaders MeterProviderJsonMetricReaders `mapstructure:"metric_readers,omitempty"` +} + +type MeterProviderJsonMetricReaders map[string]interface{} + +type MetricExporter map[string]interface{} + +type Otlp struct { + // Certificate corresponds to the JSON schema field "certificate". + Certificate *string `mapstructure:"certificate,omitempty"` + + // ClientCertificate corresponds to the JSON schema field "client_certificate". + ClientCertificate *string `mapstructure:"client_certificate,omitempty"` + + // ClientKey corresponds to the JSON schema field "client_key". + ClientKey *string `mapstructure:"client_key,omitempty"` + + // Compression corresponds to the JSON schema field "compression". + Compression *string `mapstructure:"compression,omitempty"` + + // DefaultHistogramAggregation corresponds to the JSON schema field + // "default_histogram_aggregation". + DefaultHistogramAggregation *string `mapstructure:"default_histogram_aggregation,omitempty"` + + // Endpoint corresponds to the JSON schema field "endpoint". + Endpoint string `mapstructure:"endpoint"` + + // Headers corresponds to the JSON schema field "headers". + Headers Headers `mapstructure:"headers,omitempty"` + + // Protocol corresponds to the JSON schema field "protocol". + Protocol string `mapstructure:"protocol"` + + // TemporalityPreference corresponds to the JSON schema field + // "temporality_preference". + TemporalityPreference *string `mapstructure:"temporality_preference,omitempty"` + + // Timeout corresponds to the JSON schema field "timeout". + Timeout *int `mapstructure:"timeout,omitempty"` +} + +type PeriodicMetricReader struct { + // Exporter corresponds to the JSON schema field "exporter". + Exporter MetricExporter `mapstructure:"exporter"` + + // Interval corresponds to the JSON schema field "interval". + Interval *int `mapstructure:"interval,omitempty"` + + // Timeout corresponds to the JSON schema field "timeout". + Timeout *int `mapstructure:"timeout,omitempty"` +} + +type PullMetricReader struct { + // Exporter corresponds to the JSON schema field "exporter". + Exporter MetricExporter `mapstructure:"exporter"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *PullMetricReader) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["exporter"]; !ok || v == nil { + return fmt.Errorf("field exporter in PullMetricReader: required") + } + type Plain PullMetricReader + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = PullMetricReader(plain) + return nil +} + +type Prometheus struct { + // Host corresponds to the JSON schema field "host". + Host *string `mapstructure:"host,omitempty"` + + // Port corresponds to the JSON schema field "port". + Port *int `mapstructure:"port,omitempty"` +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *PeriodicMetricReader) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["exporter"]; !ok || v == nil { + return fmt.Errorf("field exporter in PeriodicMetricReader: required") + } + type Plain PeriodicMetricReader + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = PeriodicMetricReader(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *Otlp) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["endpoint"]; !ok || v == nil { + return fmt.Errorf("field endpoint in Otlp: required") + } + if v, ok := raw["protocol"]; !ok || v == nil { + return fmt.Errorf("field protocol in Otlp: required") + } + type Plain Otlp + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = Otlp(plain) + return nil +} + +type ResourceJson struct { + // Attributes corresponds to the JSON schema field "attributes". + Attributes *Attributes `mapstructure:"attributes,omitempty"` +} + +type TracerProviderJson struct { + // SpanLimits corresponds to the JSON schema field "span_limits". + SpanLimits *TracerProviderJsonSpanLimits `mapstructure:"span_limits,omitempty"` +} + +type TracerProviderJsonSpanLimits struct { + // AttributeCountLimit corresponds to the JSON schema field + // "attribute_count_limit". + AttributeCountLimit *int `mapstructure:"attribute_count_limit,omitempty"` + + // AttributeValueLengthLimit corresponds to the JSON schema field + // "attribute_value_length_limit". + AttributeValueLengthLimit *int `mapstructure:"attribute_value_length_limit,omitempty"` + + // EventAttributeCountLimit corresponds to the JSON schema field + // "event_attribute_count_limit". + EventAttributeCountLimit *int `mapstructure:"event_attribute_count_limit,omitempty"` + + // EventCountLimit corresponds to the JSON schema field "event_count_limit". + EventCountLimit *int `mapstructure:"event_count_limit,omitempty"` + + // LinkAttributeCountLimit corresponds to the JSON schema field + // "link_attribute_count_limit". + LinkAttributeCountLimit *int `mapstructure:"link_attribute_count_limit,omitempty"` + + // LinkCountLimit corresponds to the JSON schema field "link_count_limit". + LinkCountLimit *int `mapstructure:"link_count_limit,omitempty"` +}