Skip to content

Commit 28d5712

Browse files
author
Paulo Janotti
authored
Organize make files (#50)
Move common parts of Makefile to Makefile.Common. Opportunistically add a Makefile to sapmreceiver and fix two staticcheck issues. Fix #36
1 parent e9cdcd5 commit 28d5712

File tree

6 files changed

+18
-116
lines changed

6 files changed

+18
-116
lines changed

Makefile

+2-104
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
1-
# More exclusions can be added similar with: -not -path './testbed/*'
2-
ALL_SRC := $(shell find . -name '*.go' \
3-
-not -path './testbed/*' \
4-
-type f | sort)
1+
include ./Makefile.Common
52

6-
# All source code and documents. Used in spell check.
7-
ALL_SRC_AND_DOC := $(shell find . \( -name "*.md" -o -name "*.go" -o -name "*.yaml" \) \
8-
-type f | sort)
9-
10-
# ALL_PKGS is used with 'go cover'
11-
ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))
12-
13-
GOTEST_OPT?= -race -timeout 30s
14-
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
15-
GOTEST=go test
16-
GOFMT=gofmt
17-
GOIMPORTS=goimports
18-
GOLINT=golint
19-
GOVET=go vet
20-
GOOS=$(shell go env GOOS)
21-
ADDLICENCESE= addlicense
22-
MISSPELL=misspell -error
23-
MISSPELL_CORRECTION=misspell -w
24-
STATICCHECK=staticcheck
25-
IMPI=impi
263
RUN_CONFIG=local/config.yaml
274

285
GIT_SHA=$(shell git rev-parse --short HEAD)
@@ -33,24 +10,10 @@ BUILD_X2=-X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION)
3310
endif
3411
BUILD_INFO=-ldflags "${BUILD_X1} ${BUILD_X2}"
3512

36-
all-pkgs:
37-
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
38-
39-
all-srcs:
40-
@echo $(ALL_SRC) | tr ' ' '\n' | sort
41-
4213
.DEFAULT_GOAL := all
4314

4415
.PHONY: all
45-
all: addlicense fmt impi vet lint goimports misspell staticcheck test otelcontribcol
46-
47-
.PHONY: test
48-
test:
49-
$(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)
50-
51-
.PHONY: benchmark
52-
benchmark:
53-
$(GOTEST) -bench=. -run=notests $(ALL_PKGS)
16+
all: common otelcontribcol
5417

5518
.PHONY: ci
5619
ci: all test-with-cover
@@ -64,71 +27,6 @@ test-with-cover:
6427
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS)
6528
go tool cover -html=coverage.txt -o coverage.html
6629

67-
.PHONY: addlicense
68-
addlicense:
69-
@ADDLICENCESEOUT=`$(ADDLICENCESE) -y 2019 -c 'OpenTelemetry Authors' $(ALL_SRC) 2>&1`; \
70-
if [ "$$ADDLICENCESEOUT" ]; then \
71-
echo "$(ADDLICENCESE) FAILED => add License errors:\n"; \
72-
echo "$$ADDLICENCESEOUT\n"; \
73-
exit 1; \
74-
else \
75-
echo "Add License finished successfully"; \
76-
fi
77-
78-
.PHONY: fmt
79-
fmt:
80-
@FMTOUT=`$(GOFMT) -s -l $(ALL_SRC) 2>&1`; \
81-
if [ "$$FMTOUT" ]; then \
82-
echo "$(GOFMT) FAILED => gofmt the following files:\n"; \
83-
echo "$$FMTOUT\n"; \
84-
exit 1; \
85-
else \
86-
echo "Fmt finished successfully"; \
87-
fi
88-
89-
.PHONY: lint
90-
lint:
91-
@LINTOUT=`$(GOLINT) $(ALL_PKGS) 2>&1`; \
92-
if [ "$$LINTOUT" ]; then \
93-
echo "$(GOLINT) FAILED => clean the following lint errors:\n"; \
94-
echo "$$LINTOUT\n"; \
95-
exit 1; \
96-
else \
97-
echo "Lint finished successfully"; \
98-
fi
99-
100-
.PHONY: goimports
101-
goimports:
102-
@IMPORTSOUT=`$(GOIMPORTS) -local github.com/open-telemetry/opentelemetry-collector-contrib -d . 2>&1`; \
103-
if [ "$$IMPORTSOUT" ]; then \
104-
echo "$(GOIMPORTS) FAILED => fix the following goimports errors:\n"; \
105-
echo "$$IMPORTSOUT\n"; \
106-
exit 1; \
107-
else \
108-
echo "Goimports finished successfully"; \
109-
fi
110-
111-
.PHONY: misspell
112-
misspell:
113-
$(MISSPELL) $(ALL_SRC_AND_DOC)
114-
115-
.PHONY: misspell-correction
116-
misspell-correction:
117-
$(MISSPELL_CORRECTION) $(ALL_SRC_AND_DOC)
118-
119-
.PHONY: staticcheck
120-
staticcheck:
121-
$(STATICCHECK) ./...
122-
123-
.PHONY: vet
124-
vet:
125-
@$(GOVET) ./...
126-
@echo "Vet finished successfully"
127-
128-
.PHONY: impi
129-
impi:
130-
@$(IMPI) --local github.com/open-telemetry/opentelemetry-collector-contrib --scheme stdThirdPartyLocal ./...
131-
13230
.PHONY: install-tools
13331
install-tools:
13432
GO111MODULE=on go install \

Makefile.Common

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# More exclusions can be added similar with: -not -path './vendor/*'
21
ALL_SRC := $(shell find . -name '*.go' \
3-
-not -path './vendor/*' \
42
-type f | sort)
53

64
# All source code and documents. Used in spell check.
75
ALL_SRC_AND_DOC := $(shell find . \( -name "*.md" -o -name "*.go" -o -name "*.yaml" \) \
8-
-not -path './vendor/*' \
96
-type f | sort)
107

118
# ALL_PKGS is used with 'go cover'
@@ -23,22 +20,27 @@ ADDLICENCESE= addlicense
2320
MISSPELL=misspell -error
2421
MISSPELL_CORRECTION=misspell -w
2522
STATICCHECK=staticcheck
23+
IMPI=impi
2624

2725
all-pkgs:
2826
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
2927

3028
all-srcs:
3129
@echo $(ALL_SRC) | tr ' ' '\n' | sort
3230

33-
.DEFAULT_GOAL := addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test
31+
.DEFAULT_GOAL := common
3432

35-
.PHONY: addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test
36-
addlicense-fmt-vet-lint-goimports-misspell-staticcheck-test: addlicense fmt vet lint goimports misspell staticcheck test
33+
.PHONY: common
34+
common: addlicense fmt impi vet lint goimports misspell staticcheck test
3735

3836
.PHONY: test
3937
test:
4038
$(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)
4139

40+
.PHONY: benchmark
41+
benchmark:
42+
$(GOTEST) -bench=. -run=notests $(ALL_PKGS)
43+
4244
.PHONY: addlicense
4345
addlicense:
4446
@ADDLICENCESEOUT=`$(ADDLICENCESE) -y 2019 -c 'OpenTelemetry Authors' $(ALL_SRC) 2>&1`; \
@@ -74,7 +76,7 @@ lint:
7476

7577
.PHONY: goimports
7678
goimports:
77-
@IMPORTSOUT=`$(GOIMPORTS) -d . 2>&1`; \
79+
@IMPORTSOUT=`$(GOIMPORTS) -local github.com/open-telemetry/opentelemetry-collector-contrib -d . 2>&1`; \
7880
if [ "$$IMPORTSOUT" ]; then \
7981
echo "$(GOIMPORTS) FAILED => fix the following goimports errors:\n"; \
8082
echo "$$IMPORTSOUT\n"; \
@@ -99,3 +101,7 @@ staticcheck:
99101
vet:
100102
@$(GOVET) ./...
101103
@echo "Vet finished successfully"
104+
105+
.PHONY: impi
106+
impi:
107+
@$(IMPI) --local github.com/open-telemetry/opentelemetry-collector-contrib --scheme stdThirdPartyLocal ./...

receiver/collectdreceiver/collectd.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,7 @@ func labelsFromName(val *string) (instanceName string, toAddDims map[string]stri
234234
}
235235
piece := dimensions[prev:cindex]
236236
tindex := strings.Index(piece, "=")
237-
//lint:ignore S1004 staticcheck wants us to use strings.Contains instead of Index but we need to use
238-
// the index later in the function in addition to checking for existence of char.
239-
if tindex == -1 || strings.Index(piece[tindex+1:], "=") > -1 {
237+
if tindex == -1 || strings.Contains(piece[tindex+1:], "=") {
240238
return
241239
}
242240
working[piece[:tindex]] = piece[tindex+1:]

receiver/sapmreceiver/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.Common

receiver/sapmreceiver/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/optelemetry-collector-contrib/receiver/sapmreceiver
1+
module github.com/openlemetry-collector-contrib/receiver/sapmreceiver
22

33
go 1.12
44

receiver/sapmreceiver/trace_receiver.go

-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ func (sr *sapmReceiver) HTTPHandlerFunc(rw http.ResponseWriter, req *http.Reques
159159
// write the successfully gzipped payload
160160
rw.Header().Set(sapmprotocol.ContentEncodingHeaderName, sapmprotocol.GZipEncodingHeaderValue)
161161
rw.Write(gzipBuffer.Bytes())
162-
return
163162
}
164163

165164
// TraceSource implements receiver.TraceReceiver.TraceSource() and returns a tag describing the source format

0 commit comments

Comments
 (0)