diff --git a/.github/workflows/main-build-nodejs.yml b/.github/workflows/main-build-nodejs.yml new file mode 100644 index 000000000..ff9450579 --- /dev/null +++ b/.github/workflows/main-build-nodejs.yml @@ -0,0 +1,122 @@ +name: NodeJS Layer Integration Test +on: + workflow_call: + inputs: + caller-workflow-name: + required: true + type: string + workflow_dispatch: + +concurrency: + group: main-build-nodejs-${{ github.ref_name }} + cancel-in-progress: true + +permissions: + id-token: write + contents: read + +jobs: + integration-test: + runs-on: ubuntu-22.04 + name: nodejs-wrapper-${{ matrix.architecture }} + strategy: + fail-fast: false + matrix: + architecture: [ amd64, arm64 ] + runtime: [nodejs16.x, nodejs18.x] + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: actions/setup-go@v5 + with: + go-version: '~1.21.10' + check-latest: true + - uses: actions/setup-node@v4 + with: + node-version: '16' + - name: Cache (NodeJS) + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-node- + - uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + role-to-assume: ${{ secrets.INTEG_TEST_LAMBDA_ROLE_ARN }} + role-duration-seconds: 7200 + aws-region: us-east-1 + - name: Generate UUID + id: generate-uuid + run: | + UUID=$(uuidgen | cut -c1-4) + echo "uuid=$UUID" >> $GITHUB_OUTPUT + - name: Patch ADOT + run: ./patch-upstream.sh + - name: Login to Public ECR + uses: docker/login-action@v3 + with: + registry: public.ecr.aws + - name: Build layers / functions + run: GOARCH=${{ matrix.architecture }} ./build.sh ${{ matrix.architecture }} + working-directory: nodejs + - name: Get Lambda Layer amd64 architecture value + if: ${{ matrix.architecture == 'amd64' }} + run: echo LAMBDA_FUNCTION_ARCH=x86_64 | tee --append $GITHUB_ENV + - name: Get Lambda Layer arm64 architecture value + if: ${{ matrix.architecture == 'arm64' }} + run: echo LAMBDA_FUNCTION_ARCH=arm64 | tee --append $GITHUB_ENV + - name: Get terraform directory + run: | + echo TERRAFORM_DIRECTORY=nodejs/integration-tests/aws-sdk/wrapper | + tee --append $GITHUB_ENV + - uses: hashicorp/setup-terraform@v2 + - name: Initialize terraform + run: terraform init + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + - name: Get terraform Lambda function name + run: | + echo TERRAFORM_LAMBDA_FUNCTION_NAME=lambda-nodejs-${{ matrix.architecture }}-${{ steps.generate-uuid.outputs.uuid }} | + tee --append $GITHUB_ENV + - name: Apply terraform + run: terraform apply -auto-approve + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + env: + TF_VAR_sdk_layer_name: otel-nodejs-aws-sdk-wrapper-${{ matrix.architecture }} + TF_VAR_function_name: ${{ env.TERRAFORM_LAMBDA_FUNCTION_NAME }} + TF_VAR_architecture: ${{ env.LAMBDA_FUNCTION_ARCH }} + TF_VAR_runtime: ${{ matrix.runtime }} + - name: Extract endpoint + id: extract-endpoint + run: terraform output -raw api-gateway-url + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + - name: Extract SDK layer arn + id: extract-sdk-layer-arn + run: terraform output -raw sdk_layer_arn + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + - name: Output annotations + run: | + echo "::warning::Function: ${{ env.TERRAFORM_LAMBDA_FUNCTION_NAME }}" + echo "::warning::SDK Layer ARN: ${{ steps.extract-sdk-layer-arn.outputs.stdout }}" + - name: Send request to endpoint + run: curl -sS ${{ steps.extract-endpoint.outputs.stdout }} + - name: Checkout test framework + uses: actions/checkout@v4 + with: + repository: aws-observability/aws-otel-test-framework + path: test-framework + - name: validate trace sample + run: | + cp adot/utils/expected-templates/nodejs-aws-sdk-wrapper.json \ + test-framework/validator/src/main/resources/expected-data-template/lambdaExpectedTrace.mustache + cd test-framework + ./gradlew :validator:run --args="-c default-lambda-validation.yml --endpoint ${{ steps.extract-endpoint.outputs.stdout }} --region $AWS_REGION" + - name: Destroy terraform + if: always() + run: terraform destroy -auto-approve + working-directory: ${{ env.TERRAFORM_DIRECTORY }} + env: + TF_VAR_architecture: ${{ env.LAMBDA_FUNCTION_ARCH }} diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 60ef46473..54296ca59 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -10,6 +10,7 @@ on: - '!.github/workflows/main-build.yml' - '!.github/workflows/main-build-python.yml' - '!.github/workflows/main-build-java.yml' + - '!.github/workflows/main-build-nodejs.yml' - '**.md' workflow_dispatch: @@ -29,7 +30,7 @@ jobs: fail-fast: false matrix: architecture: [ amd64, arm64 ] - language: [ dotnet, go, nodejs ] + language: [ dotnet, go ] sample-app: [ aws-sdk ] instrumentation-type: [ wrapper ] @@ -41,20 +42,6 @@ jobs: with: go-version: '~1.21.10' check-latest: true - - uses: actions/setup-node@v4 - if: ${{ matrix.language == 'nodejs' }} - with: - node-version: '16' - - name: Cache (NodeJS) - uses: actions/cache@v4 - if: ${{ matrix.language == 'nodejs' }} - with: - path: | - ~/go/pkg/mod - ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-node- - uses: actions/setup-dotnet@v4 if: ${{ matrix.language == 'dotnet' }} with: @@ -146,8 +133,17 @@ jobs: with: caller-workflow-name: 'main-build' + nodejs-runtime-test: + concurrency: + group: nodejs-runtime-test + cancel-in-progress: false + uses: ./.github/workflows/main-build-nodejs.yml + secrets: inherit + with: + caller-workflow-name: 'main-build' + publish-build-status: - needs: [integration-test, python-runtime-test, java-runtime-test] + needs: [integration-test, python-runtime-test, java-runtime-test, nodejs-runtime-test] if: ${{ always() }} uses: ./.github/workflows/publish-status.yml with: @@ -155,7 +151,7 @@ jobs: repository: ${{ github.repository }} branch: ${{ github.ref_name }} workflow: main-build - success: ${{ needs.integration-test.result == 'success' && needs.python-runtime-test.result == 'success' && needs.java-runtime-test.result == 'success' }} + success: ${{ needs.integration-test.result == 'success' && needs.python-runtime-test.result == 'success' && needs.java-runtime-test.result == 'success' && needs.nodejs-runtime-test == 'success' }} region: us-west-2 secrets: roleArn: ${{ secrets.METRICS_ROLE_ARN }} diff --git a/go/build.sh b/go/build.sh index d6ae655a8..cc0fc0ed3 100755 --- a/go/build.sh +++ b/go/build.sh @@ -9,4 +9,5 @@ popd || exit # Build sample app cd ../opentelemetry-lambda/go/sample-apps/function || exit +go mod tidy CGO_ENABLED=0 ./build.sh diff --git a/java/integration-tests/aws-sdk/agent-confmap/main.tf b/java/integration-tests/aws-sdk/agent-confmap/main.tf index 16ae8f8fe..2c341b138 100644 --- a/java/integration-tests/aws-sdk/agent-confmap/main.tf +++ b/java/integration-tests/aws-sdk/agent-confmap/main.tf @@ -16,7 +16,7 @@ resource "aws_lambda_layer_version" "collector_layer" { count = var.enable_collector_layer ? 1 : 0 layer_name = var.collector_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip" - compatible_runtimes = ["nodejs14.x", "nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip") } @@ -82,7 +82,7 @@ receivers: http: endpoint: "localhost:4318" exporters: - logging: + debug: awsxray: prometheusremotewrite: $${${module.remote_configuration.configuration_uri}} @@ -95,7 +95,7 @@ service: exporters: [awsxray] metrics: receivers: [otlp] - exporters: [logging, prometheusremotewrite] + exporters: [debug, prometheusremotewrite] telemetry: metrics: address: localhost:8888 diff --git a/java/integration-tests/aws-sdk/agent/main.tf b/java/integration-tests/aws-sdk/agent/main.tf index ead635918..51c913f1e 100644 --- a/java/integration-tests/aws-sdk/agent/main.tf +++ b/java/integration-tests/aws-sdk/agent/main.tf @@ -14,7 +14,7 @@ resource "aws_lambda_layer_version" "collector_layer" { count = var.enable_collector_layer ? 1 : 0 layer_name = var.collector_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip" - compatible_runtimes = ["nodejs14.x", "nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip") } @@ -62,7 +62,7 @@ receivers: http: endpoint: "localhost:4318" exporters: - logging: + debug: awsxray: prometheusremotewrite: endpoint: "${aws_prometheus_workspace.test_amp_workspace[0].prometheus_endpoint}api/v1/remote_write" @@ -78,7 +78,7 @@ service: exporters: [awsxray] metrics: receivers: [otlp] - exporters: [logging, prometheusremotewrite] + exporters: [debug, prometheusremotewrite] telemetry: metrics: address: localhost:8888 diff --git a/java/integration-tests/aws-sdk/wrapper/main.tf b/java/integration-tests/aws-sdk/wrapper/main.tf index ef2689d14..fec717ae0 100644 --- a/java/integration-tests/aws-sdk/wrapper/main.tf +++ b/java/integration-tests/aws-sdk/wrapper/main.tf @@ -14,7 +14,7 @@ resource "aws_lambda_layer_version" "collector_layer" { count = var.enable_collector_layer ? 1 : 0 layer_name = var.collector_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip" - compatible_runtimes = ["nodejs14.x", "nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip") } diff --git a/java/integration-tests/okhttp/wrapper/main.tf b/java/integration-tests/okhttp/wrapper/main.tf index df942607f..3d41ee853 100644 --- a/java/integration-tests/okhttp/wrapper/main.tf +++ b/java/integration-tests/okhttp/wrapper/main.tf @@ -14,7 +14,7 @@ resource "aws_lambda_layer_version" "collector_layer" { count = var.enable_collector_layer ? 1 : 0 layer_name = var.collector_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip" - compatible_runtimes = ["nodejs14.x", "nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip") } diff --git a/nodejs/integration-tests/aws-sdk/wrapper/main.tf b/nodejs/integration-tests/aws-sdk/wrapper/main.tf index 2077d4f8b..b54dfe988 100644 --- a/nodejs/integration-tests/aws-sdk/wrapper/main.tf +++ b/nodejs/integration-tests/aws-sdk/wrapper/main.tf @@ -5,7 +5,7 @@ locals { resource "aws_lambda_layer_version" "sdk_layer" { layer_name = var.sdk_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/nodejs/packages/layer/build/layer.zip" - compatible_runtimes = ["nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/nodejs/packages/layer/build/layer.zip") } @@ -14,7 +14,7 @@ resource "aws_lambda_layer_version" "collector_layer" { count = var.enable_collector_layer ? 1 : 0 layer_name = var.collector_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip" - compatible_runtimes = ["nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip") } diff --git a/python/integration-tests/aws-sdk/wrapper/main.tf b/python/integration-tests/aws-sdk/wrapper/main.tf index d37cc2624..97777902f 100644 --- a/python/integration-tests/aws-sdk/wrapper/main.tf +++ b/python/integration-tests/aws-sdk/wrapper/main.tf @@ -14,7 +14,7 @@ resource "aws_lambda_layer_version" "collector_layer" { count = var.enable_collector_layer ? 1 : 0 layer_name = var.collector_layer_name filename = "${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip" - compatible_runtimes = ["nodejs14.x", "nodejs16.x", "nodejs18.x"] + compatible_runtimes = ["nodejs16.x", "nodejs18.x", "nodejs20.x", "nodejs22.x"] license_info = "Apache-2.0" source_code_hash = filebase64sha256("${path.module}/../../../../opentelemetry-lambda/collector/build/opentelemetry-collector-layer-${local.architecture}.zip") } diff --git a/python/scripts/otel-instrument b/python/scripts/otel-instrument index 3c6d6b8a3..e77d47cb5 100755 --- a/python/scripts/otel-instrument +++ b/python/scripts/otel-instrument @@ -19,7 +19,7 @@ END_DOCUMENTATION # - Set `OTEL_PROPAGATORS` if not yet set, and include the xray propagator if [ -z ${OTEL_PROPAGATORS} ]; then - export OTEL_PROPAGATORS="tracecontext,baggage,xray"; + export OTEL_PROPAGATORS="tracecontext,baggage,xray-lambda"; fi # - Call the upstream configure OTel script