forked from open-telemetry/opentelemetry-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat(lambda): Refactor Extension to a Unified Collector-Based Layer #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
bd6a26f
feat(lambda): Refactor extension to embedded collector model
bardabun 80ff2a7
Refactor Extension to a Unified Collector-Based Layer
bardabun 70b9d69
Update e2e-python.yml
bardabun 558b2a6
Update e2e-python.yml
bardabun 1560004
Update e2e-python.yml
bardabun a72a86a
Update e2e-python.yml
bardabun 029dddc
Update e2e-python.yml
bardabun 7cca554
Update e2e-python.yml
bardabun 9eb9007
Update e2e-python.yml
bardabun d50817c
Update e2e-python.yml
bardabun df85242
Update e2e-python.yml
bardabun 97cae59
Update e2e-python.yml
bardabun 341599f
Update e2e-python.yml
bardabun 5b20d38
Update e2e-python.yml
bardabun 4667d47
Update e2e-python.yml
bardabun b8b4c51
Update e2e-python.yml
bardabun 61ad34f
Update e2e-python.yml
bardabun 2496fea
Update e2e-python.yml
bardabun a2811cf
upload tests files
bardabun c321e65
Update e2e_log_test.go
bardabun d2445dc
Update e2e_log_test.go
bardabun b607aab
update queries
bardabun ea2f345
Update queries
bardabun bdc381c
Update queries
bardabun 032b331
Update e2e_helpers_test.go
bardabun 220502e
Update e2e_helpers_test.go
bardabun 2ee9a21
Update test
bardabun 02ae293
Update e2e_trace_test.go
bardabun c788b54
Update e2e_trace_test.go
bardabun 6d1760b
Update e2e_trace_test.go
bardabun ee79d60
Update e2e_metric_test.go
bardabun 273f31f
Update e2e_metric_test.go
bardabun 9627c4b
Update e2e_runner_test.go
bardabun 72212ed
Update e2e_helpers_test.go
bardabun 87c66bb
Update e2e_metric_test.go
bardabun 799996f
Update tests
bardabun 8e18be3
Update config.e2e.yaml
bardabun 8b270f6
Update config.e2e.yaml
bardabun 60c3e2e
Update config
bardabun bca8899
revert config
bardabun 5c3c229
Add label tests
bardabun 7eb8d0e
Update metrics tests
bardabun 8a17d04
Update e2e-python.yml
bardabun 178d63c
Add e2e nodejs
bardabun 510a2f2
Update e2e-nodejs.yml
bardabun a5e1db8
Update e2e-nodejs.yml
bardabun 1d79c7d
Update e2e-nodejs.yml
bardabun 6b2c926
Added java e2e test
bardabun b3bf5b3
Update e2e-java.yml
bardabun d4cf8b6
Update e2e-java.yml
bardabun 589434a
Update e2e-java.yml
bardabun 1bfa161
Update tests
bardabun 257c7f2
Add ruby tests
bardabun 82abc6c
Trim the Ruby layer and adjusted the workflow
bardabun 1f2210e
Update Ruby path
bardabun 5a4da61
Update tests
bardabun 61b0e3d
Update ruby layer files
bardabun 94ccd30
Update ruby tests
bardabun d99057b
Add go e2e tests
bardabun 50a3926
Update e2e_trace_test.go
bardabun f94fabf
Fix shellcheck
bardabun 1be451a
Update instrumentation-layer-manager.sh
bardabun 2d1e1d1
Update e2e-ruby.yml
bardabun 3078208
Add release combined workflows
bardabun b54d311
Update NodeJS combined release workflow to Nodejs 20
bardabun 1da4b3e
Update release-combined-layer-java.yml
bardabun ff2a407
Add readme
bardabun 9a6e141
Delete test-combined-layers.sh
bardabun 8763d86
Code review changes
bardabun 508c756
Revert manager
bardabun 2fe5fe1
Update e2e-python.yml
bardabun 690823c
Update README
bardabun 5b230c3
remove on push python e2e
bardabun 4495812
Update README and RELEASE
bardabun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,217 @@ | ||
| name: E2E - Go Layer | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| logzio_api_url: | ||
| description: "Logz.io API base URL (default https://api.logz.io)" | ||
| required: false | ||
| default: "https://api.logz.io" | ||
| aws_region: | ||
| description: "AWS Region" | ||
| required: false | ||
| default: "us-east-1" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| AWS_REGION: ${{ inputs.aws_region || 'us-east-1' }} | ||
| AWS_DEFAULT_REGION: ${{ inputs.aws_region || 'us-east-1' }} | ||
| ARCHITECTURE: amd64 | ||
| FUNCTION_NAME: one-layer-e2e-test-go | ||
| LAYER_BASE_NAME: otel-go-extension-e2e | ||
| SERVICE_NAME: logzio-e2e-go-service | ||
| LOGZIO_REGION: us | ||
|
|
||
| jobs: | ||
| build-layer: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Go (for Collector) | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: collector/go.mod | ||
|
|
||
| - name: Build combined Go layer (amd64) | ||
| run: | | ||
| cd go | ||
| ARCHITECTURE=${ARCHITECTURE} ./build-combined.sh | ||
|
|
||
| - name: Upload layer artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: otel-go-extension-layer.zip | ||
| path: go/build/otel-go-extension-layer.zip | ||
|
|
||
| publish-update-invoke: | ||
| runs-on: ubuntu-latest | ||
| needs: build-layer | ||
| outputs: | ||
| layer_arn: ${{ steps.publish.outputs.layer_arn }} | ||
| e2e_label: ${{ steps.vars.outputs.e2e_label }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Download layer artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: otel-go-extension-layer.zip | ||
|
|
||
| - name: Configure AWS (User Credentials) | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Publish layer version | ||
| id: publish | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| LAYER_NAME="${LAYER_BASE_NAME}-amd64" | ||
| ARN=$(aws lambda publish-layer-version \ | ||
| --layer-name "$LAYER_NAME" \ | ||
| --license-info "Apache-2.0" \ | ||
| --compatible-architectures x86_64 \ | ||
| --compatible-runtimes provided provided.al2 \ | ||
| --zip-file fileb://otel-go-extension-layer.zip \ | ||
| --query 'LayerVersionArn' --output text) | ||
| echo "layer_arn=$ARN" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Prepare variables | ||
| id: vars | ||
| run: | | ||
| echo "e2e_label=go-e2e-${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Check function exists and get current config | ||
| run: | | ||
| echo "Checking if function exists and its current configuration..." | ||
| aws lambda get-function-configuration --function-name "${FUNCTION_NAME}" --query '{Role:Role,KMSKeyArn:KMSKeyArn,State:State,LastUpdateStatus:LastUpdateStatus}' --output table || { | ||
| echo "❌ Function ${FUNCTION_NAME} does not exist or is not accessible." | ||
| exit 1 | ||
| } | ||
|
|
||
| echo "Current environment variables:" | ||
| aws lambda get-function-configuration --function-name "${FUNCTION_NAME}" --query 'Environment.Variables' --output json || echo "No environment variables set" | ||
|
|
||
| - name: Update Lambda configuration with current run's layer and env vars | ||
| run: | | ||
| echo "Updating function configuration with this run's published layer and environment variables..." | ||
| aws lambda update-function-configuration \ | ||
| --function-name "${FUNCTION_NAME}" \ | ||
| --layers "${{ steps.publish.outputs.layer_arn }}" \ | ||
| --environment "Variables={OPENTELEMETRY_COLLECTOR_CONFIG_URI=/opt/collector-config/config.e2e.yaml,OTEL_SERVICE_NAME=${SERVICE_NAME},OTEL_TRACES_SAMPLER=always_on,OTEL_RESOURCE_ATTRIBUTES=deployment.environment=${{ steps.vars.outputs.e2e_label }},ENVIRONMENT=${{ steps.vars.outputs.e2e_label }},LOGZIO_REGION=${LOGZIO_REGION},LOGZIO_LOGS_TOKEN=${{ secrets.LOGZIO_LOGS_TOKEN }},LOGZIO_TRACES_TOKEN=${{ secrets.LOGZIO_TRACES_TOKEN }},LOGZIO_METRICS_TOKEN=${{ secrets.LOGZIO_METRICS_TOKEN }}}" | ||
|
|
||
| echo "Waiting for function update to complete..." | ||
| aws lambda wait function-updated --function-name "${FUNCTION_NAME}" | ||
|
|
||
| echo "Updated configuration (layers and environment variables):" | ||
| aws lambda get-function-configuration --function-name "${FUNCTION_NAME}" --query '{Layers:Layers[].Arn,Environment:Environment.Variables}' --output json | ||
|
|
||
| - name: Invoke function multiple times | ||
| run: | | ||
| echo "Invoking function first time..." | ||
| aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response1.json | ||
| echo "First invocation response:" | ||
| cat response1.json | ||
| echo "" | ||
|
|
||
| echo "Invoking function second time..." | ||
| aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response2.json | ||
| echo "Second invocation response:" | ||
| cat response2.json | ||
| echo "" | ||
|
|
||
| echo "Sleeping for 5 seconds before additional invocations..." | ||
| sleep 5 | ||
|
|
||
| echo "Invoking function third time..." | ||
| aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response3.json | ||
| echo "Third invocation response:" | ||
| cat response3.json | ||
| echo "" | ||
|
|
||
| echo "Invoking function fourth time..." | ||
| aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response4.json | ||
| echo "Fourth invocation response:" | ||
| cat response4.json | ||
| echo "" | ||
|
|
||
| echo "Invoking function fifth time..." | ||
| aws lambda invoke --function-name "${FUNCTION_NAME}" --payload '{}' --cli-binary-format raw-in-base64-out response5.json | ||
| echo "Fifth invocation response:" | ||
| cat response5.json | ||
| echo "" | ||
|
|
||
| - name: Check CloudWatch logs | ||
| run: | | ||
| echo "Checking recent CloudWatch logs for the function..." | ||
| LOG_GROUP_NAME="/aws/lambda/${FUNCTION_NAME}" | ||
|
|
||
| # Get recent log events (last 5 minutes) | ||
| aws logs filter-log-events \ | ||
| --log-group-name "$LOG_GROUP_NAME" \ | ||
| --start-time $(date -d '5 minutes ago' +%s)000 \ | ||
| --query 'events[].message' \ | ||
| --output text || { | ||
| echo "❌ Could not fetch CloudWatch logs. Log group might not exist or no recent logs." | ||
| echo "Checking if log group exists..." | ||
| aws logs describe-log-groups --log-group-name-prefix "$LOG_GROUP_NAME" --query 'logGroups[].logGroupName' --output text | ||
| } | ||
|
|
||
| verify-e2e: | ||
| runs-on: ubuntu-latest | ||
| needs: publish-update-invoke | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.21' | ||
|
|
||
| - name: Run E2E verification tests | ||
| working-directory: e2e_tests | ||
| env: | ||
| LOGZIO_API_KEY: ${{ secrets.LOGZIO_API_KEY }} | ||
| LOGZIO_API_URL: ${{ inputs.logzio_api_url || 'https://api.logz.io' }} | ||
| LOGZIO_API_METRICS_KEY: ${{ secrets.LOGZIO_API_METRICS_KEY }} | ||
| LOGZIO_METRICS_QUERY_URL: ${{ inputs.logzio_api_url || 'https://api.logz.io' }} | ||
| LOGZIO_API_TRACES_KEY: ${{ secrets.LOGZIO_API_TRACES_KEY }} | ||
| E2E_TEST_ENVIRONMENT_LABEL: ${{ needs.publish-update-invoke.outputs.e2e_label }} | ||
| EXPECTED_LAMBDA_FUNCTION_NAME: one-layer-e2e-test-go | ||
| EXPECTED_SERVICE_NAME: ${{ env.SERVICE_NAME }} | ||
| GITHUB_RUN_ID: ${{ github.run_id }} | ||
| AWS_REGION: ${{ env.AWS_REGION }} | ||
| run: | | ||
| go mod tidy | ||
| go test ./... -v -tags=e2e -run TestE2ERunner | ||
|
|
||
| cleanup: | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| needs: [publish-update-invoke, verify-e2e] | ||
| steps: | ||
| - name: Configure AWS (User Credentials) | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: ${{ inputs.aws_region || 'us-east-1' }} | ||
| - name: Delete published layer version | ||
| if: ${{ needs.publish-update-invoke.outputs.layer_arn != '' }} | ||
| shell: bash | ||
| run: | | ||
| ARN="${{ needs.publish-update-invoke.outputs.layer_arn }}" | ||
| LAYER_NAME=$(echo "$ARN" | cut -d: -f7) | ||
| LAYER_VERSION=$(echo "$ARN" | cut -d: -f8) | ||
| aws lambda delete-layer-version --layer-name "$LAYER_NAME" --version-number "$LAYER_VERSION" || echo "Failed to delete layer version." | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.