Skip to content

Commit

Permalink
Build collector before we use SAM Docker Container
Browse files Browse the repository at this point in the history
* The recent v0.39.0 collector introduced a change that required go 1.17
* We can't download go 1.17 in the Docker Container used by SAM
* We build the collector outside the Docker Container and just copy over later
  • Loading branch information
NathanielRN committed Nov 24, 2021
1 parent f6aadfd commit 5b2c852
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/pr-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- name: Checkout this repo
uses: actions/checkout@v2
- name: Setup Python
- name: Setup Python for OTel Python SDK
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
Expand All @@ -31,7 +31,10 @@ jobs:
run: |
pip install tox
tox
- name: Build layer
- name: Set up Go for ADOT Collector
uses: actions/setup-go@v2
with:
go-version: '1.15'
- name: Build Python Layer which includes ADOT Collector
working-directory: python/src
run: ./run.sh -b

17 changes: 2 additions & 15 deletions python/src/otel/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
export AOC=$(shell pwd)/otel_collector
export AOC_BUILD_DIR=$(shell pwd)/collector_build
export SDK=$(shell pwd)/otel_sdk

VERSION=$(shell cat $(AOC)/VERSION)
GIT_SHA=$(shell git rev-parse HEAD)
GOBUILD=GO111MODULE=on CGO_ENABLED=0 installsuffix=cgo go build -trimpath
BUILD_INFO_IMPORT_PATH=main

LDFLAGS=-ldflags "-s -w -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA) -X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION) \
-X github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter.collectorDistribution=aws-otel-collector-lambda"

build-OTelLayer:
mkdir -p $(ARTIFACTS_DIR)/python
python3 -m pip install -r $(SDK)/requirements.txt -t $(ARTIFACTS_DIR)/python
Expand All @@ -20,9 +12,4 @@ build-OTelLayer:
rm -rf $(ARTIFACTS_DIR)/python/boto*
rm -rf $(ARTIFACTS_DIR)/python/urllib3*

rpm --rebuilddb
yum install -y go
mkdir -p $(ARTIFACTS_DIR)/extensions
cd $(AOC) && $(GOBUILD) $(LDFLAGS) -o $(ARTIFACTS_DIR)/extensions/collector .
mkdir -p $(ARTIFACTS_DIR)/collector-config
cp $(AOC)/config* $(ARTIFACTS_DIR)/collector-config/
cp -r $(AOC_BUILD_DIR)/* $(ARTIFACTS_DIR)/
14 changes: 10 additions & 4 deletions utils/sam/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ main() {

if [[ $build == true ]]; then
echo "sam building..."
rm -rf .aws-sam
rm -rf otel/otel_collector
mkdir -p otel/otel_collector
cp -r "$collectorPath"/* otel/otel_collector

echo "run.sh: building the collector..."
pushd $collectorPath || exit
make package
rm build/collector-extension.zip
popd || exit
rm -rf otel/collector_build/
cp -r $collectorPath/build/ otel/collector_build/

echo "run.sh: Starting sam build."
sam build -u -t $template
fi

Expand Down

0 comments on commit 5b2c852

Please sign in to comment.