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 baed661
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
run: |
pip install tox
tox
- uses: actions/setup-go@v2
with:
go-version: '^1.17'
- name: Build layer
working-directory: python/src
run: ./run.sh -b

2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OpenTelemetry Lambda Python
# OpenTelemetry Lambda Python TEST

Scripts and files used to build AWS Lambda Layers for running OpenTelemetry on AWS Lambda for Python.

Expand Down
14 changes: 2 additions & 12 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 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,7 @@ 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)/extensions/collector
cp -r $(AOC)/extensions/collector $(ARTIFACTS_DIR)/extensions/collector
mkdir -p $(ARTIFACTS_DIR)/collector-config
cp $(AOC)/config* $(ARTIFACTS_DIR)/collector-config/
19 changes: 19 additions & 0 deletions utils/sam/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ main() {
rm -rf otel/otel_collector
mkdir -p otel/otel_collector
cp -r "$collectorPath"/* otel/otel_collector

echo "run.sh: building the collector..."
cd otel/otel_collector
mkdir -p ./extensions
GO111MODULE=on \
CGO_ENABLED=0 \
installsuffix=cgo \
go build -trimpath \
-ldflags "
-s
-w
-X main.GitHash=$(git rev-parse HEAD)
-X main.Version=$(cat ./VERSION)
-X github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter.collectorDistribution=aws-otel-collector-lambda
" \
-o ./extensions/collector .
cd ../../

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

Expand Down

0 comments on commit baed661

Please sign in to comment.