-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
160 lines (134 loc) Β· 5.3 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#: install dependencies; set dev_only for only development dependencies or use the install_dev target
install:
ifeq ($(dev_only),) # dev_only not set
poetry install
else
poetry install --only dev
endif
#: install only development dependencies
install_dev:
poetry install --only dev
#: build a release package
build: install
poetry build --no-cache -v
#: build and publish a package
publish: install
poetry publish
#: cleans up smoke test output
clean-smoke-tests:
rm -rf ./smoke-tests/collector/data.json
rm -rf ./smoke-tests/collector/data-results/*.json
rm -rf ./smoke-tests/report.*
#: clean all the caches and any dist
clean-cache:
rm -rf dist/*
rm -rf hyperdx/opentelemetry/__pycache__/
rm -rf src/hyperdx/opentelemetry/__pycache__/
rm -rf examples/hello-world-flask/__pycache__
rm -rf examples/hello-world-flask/dist/*
rm -rf examples/hello-world/__pycache__
rm -rf examples/hello-world/dist/*
#: clean smoke test output, caches, builds
clean: clean-smoke-tests clean-cache
#: run the unit tests with a clean environment, create coverage report html
test: build
mkdir -p test-results
unset ${OUR_CONFIG_ENV_VARS} && poetry run coverage run -m pytest tests --junitxml=test-results/junit.xml
poetry run coverage html
#: nitpick lint
lint: install_dev
poetry run pylint src
#: nitpick style
style: install_dev
poetry run pycodestyle src
#: clear data from smoke tests
smoke-tests/collector/data.json:
@echo ""
@echo "+++ Zhuzhing smoke test's Collector data.json"
@touch $@ && chmod o+w $@
#: smoke test the hello-world app using grpc protocol and configure_opentelemetry()
smoke-sdk-grpc: smoke-tests/collector/data.json
@echo ""
@echo "+++ Running gRPC smoke tests on configure_opentelemetry()"
@echo ""
cd smoke-tests && bats ./smoke-sdk-grpc.bats --report-formatter junit --output ./
#: smoke test the hello-world app using http/protobuf protocol and configure_opentelemetry()
smoke-sdk-http: smoke-tests/collector/data.json
@echo ""
@echo "+++ Running HTTP smoke tests on configure_opentelemetry()"
@echo ""
cd smoke-tests && bats ./smoke-sdk-http.bats --report-formatter junit --output ./
#: smoke test the flask app using grpc protocol and opentelemetry_instrument
smoke-sdk-grpc-flask: smoke-tests/collector/data.json
@echo ""
@echo "+++ Running GRPC Flask smoke tests on opentelemetry_instrument"
@echo ""
cd smoke-tests && bats ./smoke-sdk-grpc-flask.bats --report-formatter junit --output ./
#: smoke test the flask app using http protocol and opentelemetry_instrument
smoke-sdk-http-flask: smoke-tests/collector/data.json
@echo ""
@echo "+++ Running HTTP Flask smoke tests on opentelemetry_instrument"
@echo ""
cd smoke-tests && bats ./smoke-sdk-http-flask.bats --report-formatter junit --output ./
#: smoke test both example apps using grpc and then http/protobuf protocols
smoke-sdk: smoke-sdk-grpc smoke-sdk-http smoke-sdk-grpc-flask smoke-sdk-http-flask
#: placeholder for smoke tests, simply build the app
smoke:
@echo ""
@echo "+++ Temporary Placeholder."
@echo ""
cd smoke-tests && docker compose up --build app-sdk-grpc
#: placeholder for smoke tests, tear down the app
unsmoke:
@echo ""
@echo "+++ Spinning down the smokers."
@echo ""
cd smoke-tests && docker compose down --volumes
EXAMPLE_SERVICE_NAME ?= otel-python-example
run_example: export OTEL_SERVICE_NAME := $(EXAMPLE_SERVICE_NAME)
#: fire up an instrumented Python web service; set HYPERDX_API_KEY to send data for real
run_example:
cd examples/hello-world-flask && \
poetry install && \
poetry run opentelemetry-instrument flask run
JOB ?= test-3.10
#: run a CI job in docker locally, set JOB to override default 'run_tests'
local_ci_exec: local_ci_prereqs
circleci local execute \
--config .circleci/process.yml \
--job $(JOB)
.PHONY: install build test lint run_example forbidden_in_real_ci
### Utilities
# ^(a_|b_|c_) :: name starts with any of 'a_', 'b_', or 'c_'
# [^=] :: [^ ] is inverted set, so any character that isn't '='
# + :: + is 1-or-more of previous thing
#
# So the match the prefixes, then chars up-to-but-excluding the first '='.
# example: OTEL_VAR=HEY -> OTEL_VAR
#
# egrep to get the extended regex syntax support.
# --only-matching to output only what matches, not the whole line.
OUR_CONFIG_ENV_VARS := $(shell env | egrep --only-matching "^(HYPERDX_|OTEL_)[^=]+")
# To use the circleci CLI to run jobs on your laptop.
circle_cli_docs_url = https://circleci.com/docs/local-cli/
local_ci_prereqs: forbidden_in_real_ci circle_cli_available .circleci/process.yml
# the config must be processed to do things like expand matrix jobs.
.circleci/process.yml: circle_cli_available .circleci/config.yml
circleci config process .circleci/config.yml > .circleci/process.yml
circle_cli_available:
ifneq (, $(shell which circleci))
@echo "π:β
circleci CLI available"
else
@echo "π:π₯ circleci CLI command not available for local run."
@echo ""
@echo " β Is it installed? For more info: ${circle_cli_docs_url}\n\n" && exit 1
endif
forbidden_in_real_ci:
ifeq ($(CIRCLECI),) # if not set, safe to assume not running in CircleCI compute
@echo "π:β
not running in real CI"
else
@echo "π:π CIRCLECI environment variable is present, a sign that we're running in real CircleCI compute."
@echo ""
@echo " π circleci CLI can't local execute in Circle. That'd be πππ."
@echo "" && exit 1
endif