123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- include ./Makefile.Common
- RUN_CONFIG?=local/config.yaml
- CMD?=
- OTEL_VERSION=main
- OTEL_RC_VERSION=main
- OTEL_STABLE_VERSION=main
- VERSION=$(shell git describe --always --match "v[0-9]*" HEAD)
- COMP_REL_PATH=cmd/otelcontribcol/components.go
- MOD_NAME=github.com/open-telemetry/opentelemetry-collector-contrib
- GROUP ?= all
- FOR_GROUP_TARGET=for-$(GROUP)-target
- FIND_MOD_ARGS=-type f -name "go.mod"
- TO_MOD_DIR=dirname {} \; | sort | grep -E '^./'
- EX_COMPONENTS=-not -path "./receiver/*" -not -path "./processor/*" -not -path "./exporter/*" -not -path "./extension/*" -not -path "./connector/*"
- EX_INTERNAL=-not -path "./internal/*"
- EX_PKG=-not -path "./pkg/*"
- EX_CMD=-not -path "./cmd/*"
- # NONROOT_MODS includes ./* dirs (excludes . dir)
- NONROOT_MODS := $(shell find . $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- RECEIVER_MODS_0 := $(shell find ./receiver/[a-k]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- RECEIVER_MODS_1 := $(shell find ./receiver/[l-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- RECEIVER_MODS := $(RECEIVER_MODS_0) $(RECEIVER_MODS_1)
- PROCESSOR_MODS := $(shell find ./processor/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- EXPORTER_MODS := $(shell find ./exporter/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- EXTENSION_MODS := $(shell find ./extension/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- CONNECTOR_MODS := $(shell find ./connector/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- INTERNAL_MODS := $(shell find ./internal/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- PKG_MODS := $(shell find ./pkg/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- CMD_MODS := $(shell find ./cmd/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
- OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD)
- ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS)
- # find -exec dirname cannot be used to process multiple matching patterns
- FIND_INTEGRATION_TEST_MODS={ find . -type f -name "*integration_test.go" & find . -type f -name "*e2e_test.go" -not -path "./testbed/*"; }
- INTEGRATION_MODS := $(shell $(FIND_INTEGRATION_TEST_MODS) | xargs $(TO_MOD_DIR) | uniq)
- ifeq ($(GOOS),windows)
- EXTENSION := .exe
- endif
- .DEFAULT_GOAL := all
- all-modules:
- @echo $(NONROOT_MODS) | tr ' ' '\n' | sort
- all-groups:
- @echo "receiver-0: $(RECEIVER_MODS_0)"
- @echo "\nreceiver-1: $(RECEIVER_MODS_1)"
- @echo "\nreceiver: $(RECEIVER_MODS)"
- @echo "\nprocessor: $(PROCESSOR_MODS)"
- @echo "\nexporter: $(EXPORTER_MODS)"
- @echo "\nextension: $(EXTENSION_MODS)"
- @echo "\nconnector: $(CONNECTOR_MODS)"
- @echo "\ninternal: $(INTERNAL_MODS)"
- @echo "\npkg: $(PKG_MODS)"
- @echo "\ncmd: $(CMD_MODS)"
- @echo "\nother: $(OTHER_MODS)"
- .PHONY: all
- all: install-tools all-common goporto multimod-verify gotest otelcontribcol
- .PHONY: all-common
- all-common:
- @$(MAKE) $(FOR_GROUP_TARGET) TARGET="common"
- .PHONY: e2e-test
- e2e-test: otelcontribcol oteltestbedcol
- $(MAKE) -C testbed run-tests
- .PHONY: integration-test
- integration-test:
- @$(MAKE) for-integration-target TARGET="mod-integration-test"
- .PHONY: integration-tests-with-cover
- integration-tests-with-cover:
- @$(MAKE) for-integration-target TARGET="do-integration-tests-with-cover"
- # Long-running e2e tests
- .PHONY: stability-tests
- stability-tests: otelcontribcol
- @echo Stability tests are disabled until we have a stable performance environment.
- @echo To enable the tests replace this echo by $(MAKE) -C testbed run-stability-tests
- .PHONY: gogci
- gogci:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="gci"
- .PHONY: gotidy
- gotidy:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="tidy"
- .PHONY: gomoddownload
- gomoddownload:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="moddownload"
- .PHONY: gotest
- gotest:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="test"
- .PHONY: gotest-with-cover
- gotest-with-cover:
- @$(MAKE) $(FOR_GROUP_TARGET) TARGET="test-with-cover"
- $(GOCMD) tool covdata textfmt -i=./coverage/unit -o ./$(GROUP)-coverage.txt
- .PHONY: gofmt
- gofmt:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="fmt"
- .PHONY: golint
- golint:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="lint"
- .PHONY: gogovulncheck
- gogovulncheck:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="govulncheck"
- .PHONY: goporto
- goporto: $(PORTO)
- $(PORTO) -w --include-internal --skip-dirs "^cmd$$" ./
- .PHONY: for-all
- for-all:
- @echo "running $${CMD} in root"
- @$${CMD}
- @set -e; for dir in $(NONROOT_MODS); do \
- (cd "$${dir}" && \
- echo "running $${CMD} in $${dir}" && \
- $${CMD} ); \
- done
- COMMIT?=HEAD
- MODSET?=contrib-core
- REMOTE?=git@github.com:open-telemetry/opentelemetry-collector-contrib.git
- .PHONY: push-tags
- push-tags: $(MULTIMOD)
- $(MULTIMOD) verify
- set -e; for tag in `$(MULTIMOD) tag -m ${MODSET} -c ${COMMIT} --print-tags | grep -v "Using" `; do \
- echo "pushing tag $${tag}"; \
- git push ${REMOTE} $${tag}; \
- done;
- # Define a delegation target for each module
- .PHONY: $(ALL_MODS)
- $(ALL_MODS):
- @echo "Running target '$(TARGET)' in module '$@' as part of group '$(GROUP)'"
- $(MAKE) -C $@ $(TARGET)
- # Trigger each module's delegation target
- .PHONY: for-all-target
- for-all-target: $(ALL_MODS)
- .PHONY: for-receiver-target
- for-receiver-target: $(RECEIVER_MODS)
- .PHONY: for-receiver-0-target
- for-receiver-0-target: $(RECEIVER_MODS_0)
- .PHONY: for-receiver-1-target
- for-receiver-1-target: $(RECEIVER_MODS_1)
- .PHONY: for-processor-target
- for-processor-target: $(PROCESSOR_MODS)
- .PHONY: for-exporter-target
- for-exporter-target: $(EXPORTER_MODS)
- .PHONY: for-extension-target
- for-extension-target: $(EXTENSION_MODS)
- .PHONY: for-connector-target
- for-connector-target: $(CONNECTOR_MODS)
- .PHONY: for-internal-target
- for-internal-target: $(INTERNAL_MODS)
- .PHONY: for-pkg-target
- for-pkg-target: $(PKG_MODS)
- .PHONY: for-cmd-target
- for-cmd-target: $(CMD_MODS)
- .PHONY: for-other-target
- for-other-target: $(OTHER_MODS)
- .PHONY: for-integration-target
- for-integration-target: $(INTEGRATION_MODS)
- # Debugging target, which helps to quickly determine whether for-all-target is working or not.
- .PHONY: all-pwd
- all-pwd:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="pwd"
- .PHONY: run
- run:
- cd ./cmd/otelcontribcol && GO111MODULE=on $(GOCMD) run --race . --config ../../${RUN_CONFIG} ${RUN_ARGS}
- .PHONY: docker-component # Not intended to be used directly
- docker-component: check-component
- GOOS=linux GOARCH=amd64 $(MAKE) $(COMPONENT)
- cp ./bin/$(COMPONENT)_linux_amd64 ./cmd/$(COMPONENT)/$(COMPONENT)
- docker build -t $(COMPONENT) ./cmd/$(COMPONENT)/
- rm ./cmd/$(COMPONENT)/$(COMPONENT)
- .PHONY: check-component
- check-component:
- ifndef COMPONENT
- $(error COMPONENT variable was not defined)
- endif
- .PHONY: docker-otelcontribcol
- docker-otelcontribcol:
- COMPONENT=otelcontribcol $(MAKE) docker-component
- docker-obcol:
- COMPONENT=obcol $(MAKE) docker-component
- docker-push: docker-obcol
- docker tag obcol:latest reg.cestong.com.cn/cecf/obcol:latest
- docker push reg.cestong.com.cn/cecf/obcol:latest
- .PHONY: docker-telemetrygen
- docker-telemetrygen:
- COMPONENT=telemetrygen $(MAKE) docker-component
- .PHONY: generate
- generate: install-tools
- cd cmd/mdatagen && $(GOCMD) install .
- $(MAKE) for-all CMD="$(GOCMD) generate ./..."
- .PHONY: mdatagen-test
- mdatagen-test:
- cd cmd/mdatagen && $(GOCMD) install .
- cd cmd/mdatagen && $(GOCMD) generate ./...
- cd cmd/mdatagen && $(GOCMD) test ./...
- .PHONY: gengithub
- gengithub:
- cd cmd/githubgen && $(GOCMD) install .
- githubgen
- .PHONY: update-codeowners
- update-codeowners: gengithub generate
- FILENAME?=$(shell git branch --show-current)
- .PHONY: chlog-new
- chlog-new: $(CHLOGGEN)
- $(CHLOGGEN) new --config $(CHLOGGEN_CONFIG) --filename $(FILENAME)
- .PHONY: chlog-validate
- chlog-validate: $(CHLOGGEN)
- $(CHLOGGEN) validate --config $(CHLOGGEN_CONFIG)
- .PHONY: chlog-preview
- chlog-preview: $(CHLOGGEN)
- $(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --dry
- .PHONY: chlog-update
- chlog-update: $(CHLOGGEN)
- $(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --version $(VERSION)
- .PHONY: genotelcontribcol
- genotelcontribcol: $(BUILDER)
- $(BUILDER) --skip-compilation --config cmd/otelcontribcol/builder-config.yaml --output-path cmd/otelcontribcol
- $(MAKE) -C cmd/otelcontribcol fmt
- .PHONY: genobcol
- genobcol: $(BUILDER)
- $(BUILDER) --skip-compilation --config cmd/obcol/builder-config.yaml --output-path cmd/obcol
- $(MAKE) -C cmd/obcol fmt
- # Build the Collector executable.
- .PHONY: otelcontribcol
- otelcontribcol:
- cd ./cmd/otelcontribcol && GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/otelcontribcol_$(GOOS)_$(GOARCH)$(EXTENSION) \
- -tags $(GO_BUILD_TAGS) .
- # Build the Collector executable.
- .PHONY: otelcontribcol
- obcol:
- cd ./cmd/obcol && GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/obcol_$(GOOS)_$(GOARCH)$(EXTENSION) \
- -tags $(GO_BUILD_TAGS) .
- .PHONY: genoteltestbedcol
- genoteltestbedcol: $(BUILDER)
- $(BUILDER) --skip-compilation --config cmd/oteltestbedcol/builder-config.yaml --output-path cmd/oteltestbedcol
- $(MAKE) -C cmd/oteltestbedcol fmt
- # Build the Collector executable, with only components used in testbed.
- .PHONY: oteltestbedcol
- oteltestbedcol:
- cd ./cmd/oteltestbedcol && GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/oteltestbedcol_$(GOOS)_$(GOARCH)$(EXTENSION) \
- -tags $(GO_BUILD_TAGS) .
- # Build the telemetrygen executable.
- .PHONY: telemetrygen
- telemetrygen:
- cd ./cmd/telemetrygen && GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -trimpath -o ../../bin/telemetrygen_$(GOOS)_$(GOARCH)$(EXTENSION) \
- -tags $(GO_BUILD_TAGS) .
- .PHONY: update-dep
- update-dep:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="updatedep"
- $(MAKE) otelcontribcol
- .PHONY: update-otel
- update-otel:
- $(MAKE) update-dep MODULE=go.opentelemetry.io/collector VERSION=$(OTEL_VERSION) RC_VERSION=$(OTEL_RC_VERSION) STABLE_VERSION=$(OTEL_STABLE_VERSION)
- .PHONY: otel-from-tree
- otel-from-tree:
- # This command allows you to make changes to your local checkout of otel core and build
- # contrib against those changes without having to push to github and update a bunch of
- # references. The workflow is:
- #
- # 1. Hack on changes in core (assumed to be checked out in ../opentelemetry-collector from this directory)
- # 2. Run `make otel-from-tree` (only need to run it once to remap go modules)
- # 3. You can now build contrib and it will use your local otel core changes.
- # 4. Before committing/pushing your contrib changes, undo by running `make otel-from-lib`.
- $(MAKE) for-all CMD="$(GOCMD) mod edit -replace go.opentelemetry.io/collector=$(SRC_ROOT)/../opentelemetry-collector"
- .PHONY: otel-from-lib
- otel-from-lib:
- # Sets opentelemetry core to be not be pulled from local source tree. (Undoes otel-from-tree.)
- $(MAKE) for-all CMD="$(GOCMD) mod edit -dropreplace go.opentelemetry.io/collector"
- .PHONY: build-examples
- build-examples:
- docker-compose -f examples/demo/docker-compose.yaml build
- docker-compose -f exporter/splunkhecexporter/example/docker-compose.yml build
- .PHONY: deb-rpm-package
- %-package: ARCH ?= amd64
- %-package:
- GOOS=linux GOARCH=$(ARCH) $(MAKE) otelcontribcol
- docker build -t otelcontribcol-fpm internal/buildscripts/packaging/fpm
- docker run --rm -v $(CURDIR):/repo -e PACKAGE=$* -e VERSION=$(VERSION) -e ARCH=$(ARCH) otelcontribcol-fpm
- # Verify existence of READMEs for components specified as default components in the collector.
- .PHONY: checkdoc
- checkdoc: $(CHECKFILE)
- $(CHECKFILE) --project-path $(CURDIR) --component-rel-path $(COMP_REL_PATH) --module-name $(MOD_NAME) --file-name "README.md"
- # Verify existence of metadata.yaml for components specified as default components in the collector.
- .PHONY: checkmetadata
- checkmetadata: $(CHECKFILE)
- $(CHECKFILE) --project-path $(CURDIR) --component-rel-path $(COMP_REL_PATH) --module-name $(MOD_NAME) --file-name "metadata.yaml"
- .PHONY: checkapi
- checkapi:
- $(GOCMD) run cmd/checkapi/main.go .
- .PHONY: all-checklinks
- all-checklinks:
- $(MAKE) $(FOR_GROUP_TARGET) TARGET="checklinks"
- # Function to execute a command. Note the empty line before endef to make sure each command
- # gets executed separately instead of concatenated with previous one.
- # Accepts command to execute as first parameter.
- define exec-command
- $(1)
- endef
- # List of directories where certificates are stored for unit tests.
- CERT_DIRS := receiver/sapmreceiver/testdata \
- receiver/signalfxreceiver/testdata \
- receiver/splunkhecreceiver/testdata \
- receiver/mongodbatlasreceiver/testdata/alerts/cert \
- receiver/mongodbreceiver/testdata/certs \
- receiver/cloudflarereceiver/testdata/cert
- # Generate certificates for unit tests relying on certificates.
- .PHONY: certs
- certs:
- $(foreach dir, $(CERT_DIRS), $(call exec-command, @internal/buildscripts/gen-certs.sh -o $(dir)))
- .PHONY: multimod-verify
- multimod-verify: $(MULTIMOD)
- @echo "Validating versions.yaml"
- $(MULTIMOD) verify
- .PHONY: multimod-prerelease
- multimod-prerelease: $(MULTIMOD)
- $(MULTIMOD) prerelease -s=true -b=false -v ./versions.yaml -m contrib-base
- $(MAKE) gotidy
- .PHONY: multimod-sync
- multimod-sync: $(MULTIMOD)
- $(MULTIMOD) sync -a=true -s=true -o ../opentelemetry-collector
- $(MAKE) gotidy
- .PHONY: crosslink
- crosslink: $(CROSSLINK)
- @echo "Executing crosslink"
- $(CROSSLINK) --root=$(shell pwd) --prune
- .PHONY: clean
- clean:
- @echo "Removing coverage files"
- find . -type f -name 'coverage.txt' -delete
- find . -type f -name 'coverage.html' -delete
- find . -type f -name 'coverage.out' -delete
- find . -type f -name 'integration-coverage.txt' -delete
- find . -type f -name 'integration-coverage.html' -delete
- .PHONY: genconfigdocs
- genconfigdocs:
- cd cmd/configschema && $(GOCMD) run ./docsgen all
- .PHONY: generate-gh-issue-templates
- generate-gh-issue-templates:
- cd cmd/githubgen && $(GOCMD) install .
- githubgen issue-templates
|