Skip to content

Commit

Permalink
add auto-generated configuration code
Browse files Browse the repository at this point in the history
This is generated from the opentelemetry-configuration repository using gojsonschema.

Signed-off-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
Alex Boten committed May 15, 2023
1 parent c244900 commit 66dae37
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 56 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,26 @@ 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 $(GO_JSONSCHEMA)
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}
$(GO_JSONSCHEMA) --package telemetry \
--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) 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 )
Expand Down
31 changes: 16 additions & 15 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ 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
GO_ACC := $(TOOLS_BIN_DIR)/go-acc
GOCOVMERGE := $(TOOLS_BIN_DIR)/gocovmerge
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
GO_ACC := $(TOOLS_BIN_DIR)/go-acc
GOCOVMERGE := $(TOOLS_BIN_DIR)/gocovmerge
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)

Expand Down
28 changes: 15 additions & 13 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module go.opentelemetry.io/collector/internal/tools
go 1.19

require (
github.com/atombender/go-jsonschema v0.11.0
github.com/client9/misspell v0.3.4
github.com/golangci/golangci-lint v1.52.2
github.com/google/addlicense v1.1.1
Expand All @@ -16,7 +17,7 @@ require (
go.opentelemetry.io/build-tools/crosslink v0.7.0
go.opentelemetry.io/build-tools/multimod v0.7.0
go.opentelemetry.io/build-tools/semconvgen v0.7.0
golang.org/x/exp v0.0.0-20221004215720-b9f4876ce741
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc
golang.org/x/tools v0.9.1
golang.org/x/vuln v0.1.0
)
Expand All @@ -41,7 +42,6 @@ require (
github.com/alingse/asasalint v0.0.11 // indirect
github.com/ashanbrown/forbidigo v1.5.1 // 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.0 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
Expand All @@ -51,10 +51,10 @@ require (
github.com/breml/errchkjson v0.3.1 // indirect
github.com/butuzov/ireturn v0.1.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/daixiang0/gci v0.10.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -74,7 +74,6 @@ require (
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.4.1 // indirect
github.com/go-git/go-git/v5 v5.6.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
github.com/go-toolsmith/astequal v1.1.0 // indirect
Expand All @@ -87,7 +86,7 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-yaml v1.11.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect
Expand Down Expand Up @@ -136,10 +135,11 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
github.com/mgechev/revive v1.3.1 // 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
Expand All @@ -153,18 +153,20 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // 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.0 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.43.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/quasilyte/go-ruleguard v0.3.19 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
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
Expand Down Expand Up @@ -204,7 +206,7 @@ require (
github.com/yeya24/promlinter v0.2.0 // indirect
gitlab.com/bosi/decorder v0.2.3 // indirect
go.opentelemetry.io/build-tools v0.7.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
Expand All @@ -215,7 +217,7 @@ require (
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading

0 comments on commit 66dae37

Please sign in to comment.