From cc9aa49664c02c97a2ebaf225dd1685a5ebe06f2 Mon Sep 17 00:00:00 2001 From: Marcus Mann Date: Thu, 11 Dec 2025 13:46:59 -0500 Subject: [PATCH 1/3] Add script to update OTel dependencies and simplify GitHub Action - Add scripts/update-otel-deps.sh to update all amazon-contributing/opentelemetry-collector-contrib dependencies to latest commit from aws-cwa-dev branch - Add make update-otel-deps target - Update .github/workflows/otel-fork-replace.yml to use the new script - Use regex to ensure only amazon-contributing dependencies are updated --- .github/workflows/otel-fork-replace.yml | 33 +------------------------ Makefile | 5 +++- scripts/update-otel-deps.sh | 13 ++++++++++ 3 files changed, 18 insertions(+), 33 deletions(-) create mode 100755 scripts/update-otel-deps.sh diff --git a/.github/workflows/otel-fork-replace.yml b/.github/workflows/otel-fork-replace.yml index 60499ef2f5..edcda4e390 100644 --- a/.github/workflows/otel-fork-replace.yml +++ b/.github/workflows/otel-fork-replace.yml @@ -38,38 +38,7 @@ jobs: git config --global user.name 'Github Action' git config --global user.email 'action@github.com' git checkout -b otel-fork-replace-${{ steps.get-latest-commit.outputs.sha }} - go mod edit -replace go.opentelemetry.io/collector/config/confighttp=github.com/amazon-contributing/opentelemetry-collector-contrib/config/confighttp@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor=github.com/amazon-contributing/opentelemetry-collector-contrib/processor/resourcedetectionprocessor@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter=github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsemfexporter@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter=github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awsxrayexporter@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/xray=github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/xray@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil=github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/awsutil@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight=github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/containerinsight@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/k8s=github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/k8s@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver=github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver=github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/prometheusreceiver@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus=github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/translator/prometheus@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs=github.com/amazon-contributing/opentelemetry-collector-contrib/internal/aws/cwlogs@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter=github.com/amazon-contributing/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver=github.com/amazon-contributing/opentelemetry-collector-contrib/receiver/awsxrayreceiver@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws=github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy - go mod edit -replace github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/stanza=github.com/amazon-contributing/opentelemetry-collector-contrib/pkg/stanza@${{ steps.get-latest-commit.outputs.sha }} - go mod tidy + scripts/update-otel-deps.sh git commit -am "Update OTel fork components to https://github.com/amazon-contributing/opentelemetry-collector-contrib/commit/${{ steps.get-latest-commit.outputs.sha }}" git push -u origin HEAD git config --global --unset user.name diff --git a/Makefile b/Makefile index 0bcaa0c00d..70ca913d68 100644 --- a/Makefile +++ b/Makefile @@ -356,7 +356,10 @@ package-darwin: package-prepare-darwin-tar ARCH=amd64 TARGET_SUPPORTED_ARCH=x86_64 PREPKGPATH="$(BUILD_SPACE)/private/darwin/amd64/tar/amazon-cloudwatch-agent-pre-pkg" $(BUILD_SPACE)/Tools/src/create_darwin.sh ARCH=arm64 TARGET_SUPPORTED_ARCH=aarch64 PREPKGPATH="$(BUILD_SPACE)/private/darwin/arm64/tar/amazon-cloudwatch-agent-pre-pkg" $(BUILD_SPACE)/Tools/src/create_darwin.sh -.PHONY: fmt fmt-sh build test clean +update-otel-deps: + scripts/update-otel-deps.sh + +.PHONY: fmt fmt-sh build test clean update-otel-deps .PHONY: dockerized-build dockerized-build-vendor dockerized-build: diff --git a/scripts/update-otel-deps.sh b/scripts/update-otel-deps.sh new file mode 100755 index 0000000000..69fa96ac04 --- /dev/null +++ b/scripts/update-otel-deps.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Get latest commit SHA from aws-cwa-dev branch +LATEST_SHA=$(git ls-remote https://github.com/amazon-contributing/opentelemetry-collector-contrib.git aws-cwa-dev | awk '{print $1}') + +echo "Updating to commit: $LATEST_SHA" + +# Update only amazon-contributing references in replace directives +sed -i '' "s|=> github\.com/amazon-contributing/opentelemetry-collector-contrib/\([^@]*\) v0\.0\.0-[0-9]*-[a-f0-9]*|=> github.com/amazon-contributing/opentelemetry-collector-contrib/\1 $LATEST_SHA|g" go.mod + +go mod tidy + +echo "Updated all OTel dependencies to $LATEST_SHA" From 197990d924caad782d01001f42642740ceb5ac2f Mon Sep 17 00:00:00 2001 From: Marcus Mann Date: Mon, 15 Dec 2025 11:51:41 -0500 Subject: [PATCH 2/3] Improve OTel deps update script with parameter support and better error handling - Accept commit SHA as parameter in update-otel-deps.sh script - Pass SHA from workflow step output to script for consistency - Add error handling and progress messages - Make go mod tidy verbose to show what it's doing - Check for go.mod existence before attempting updates --- .github/workflows/otel-fork-replace.yml | 2 +- scripts/update-otel-deps.sh | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/otel-fork-replace.yml b/.github/workflows/otel-fork-replace.yml index edcda4e390..30d5beb99d 100644 --- a/.github/workflows/otel-fork-replace.yml +++ b/.github/workflows/otel-fork-replace.yml @@ -38,7 +38,7 @@ jobs: git config --global user.name 'Github Action' git config --global user.email 'action@github.com' git checkout -b otel-fork-replace-${{ steps.get-latest-commit.outputs.sha }} - scripts/update-otel-deps.sh + scripts/update-otel-deps.sh ${{ steps.get-latest-commit.outputs.sha }} git commit -am "Update OTel fork components to https://github.com/amazon-contributing/opentelemetry-collector-contrib/commit/${{ steps.get-latest-commit.outputs.sha }}" git push -u origin HEAD git config --global --unset user.name diff --git a/scripts/update-otel-deps.sh b/scripts/update-otel-deps.sh index 69fa96ac04..b3ca2c8529 100755 --- a/scripts/update-otel-deps.sh +++ b/scripts/update-otel-deps.sh @@ -1,13 +1,27 @@ #!/bin/bash -# Get latest commit SHA from aws-cwa-dev branch -LATEST_SHA=$(git ls-remote https://github.com/amazon-contributing/opentelemetry-collector-contrib.git aws-cwa-dev | awk '{print $1}') +# Accept commit SHA as parameter, or get latest if not provided +if [ -n "$1" ]; then + LATEST_SHA="$1" + echo "Using provided commit SHA: $LATEST_SHA" +else + # Get latest commit SHA from aws-cwa-dev branch + LATEST_SHA=$(git ls-remote https://github.com/amazon-contributing/opentelemetry-collector-contrib.git aws-cwa-dev | awk '{print $1}') + echo "Fetched latest commit SHA: $LATEST_SHA" +fi -echo "Updating to commit: $LATEST_SHA" +# Check if go.mod exists before proceeding +if [ ! -f "go.mod" ]; then + echo "Error: go.mod not found in current directory" + exit 1 +fi + +echo "Updating go.mod with SHA: $LATEST_SHA" # Update only amazon-contributing references in replace directives sed -i '' "s|=> github\.com/amazon-contributing/opentelemetry-collector-contrib/\([^@]*\) v0\.0\.0-[0-9]*-[a-f0-9]*|=> github.com/amazon-contributing/opentelemetry-collector-contrib/\1 $LATEST_SHA|g" go.mod -go mod tidy +echo "Running go mod tidy..." +GOPROXY=direct go mod tidy echo "Updated all OTel dependencies to $LATEST_SHA" From edb36c6c61080743b91d67e06c8f6ea54ab72169 Mon Sep 17 00:00:00 2001 From: Marcus Mann Date: Mon, 15 Dec 2025 12:04:39 -0500 Subject: [PATCH 3/3] Update otel deps script --- scripts/update-otel-deps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/update-otel-deps.sh b/scripts/update-otel-deps.sh index b3ca2c8529..d8529b87a0 100755 --- a/scripts/update-otel-deps.sh +++ b/scripts/update-otel-deps.sh @@ -2,18 +2,18 @@ # Accept commit SHA as parameter, or get latest if not provided if [ -n "$1" ]; then - LATEST_SHA="$1" - echo "Using provided commit SHA: $LATEST_SHA" + LATEST_SHA="$1" + echo "Using provided commit SHA: $LATEST_SHA" else - # Get latest commit SHA from aws-cwa-dev branch - LATEST_SHA=$(git ls-remote https://github.com/amazon-contributing/opentelemetry-collector-contrib.git aws-cwa-dev | awk '{print $1}') - echo "Fetched latest commit SHA: $LATEST_SHA" + # Get latest commit SHA from aws-cwa-dev branch + LATEST_SHA=$(git ls-remote https://github.com/amazon-contributing/opentelemetry-collector-contrib.git aws-cwa-dev | awk '{print $1}') + echo "Fetched latest commit SHA: $LATEST_SHA" fi # Check if go.mod exists before proceeding if [ ! -f "go.mod" ]; then - echo "Error: go.mod not found in current directory" - exit 1 + echo "Error: go.mod not found in current directory" + exit 1 fi echo "Updating go.mod with SHA: $LATEST_SHA"