Skip to content

Commit 5e0548f

Browse files
committed
test
1 parent 845c1de commit 5e0548f

File tree

3 files changed

+43
-25
lines changed

3 files changed

+43
-25
lines changed

.github/workflows/python-ec2-genai-test.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
caller-workflow-name:
1313
required: true
1414
type: string
15+
python-version:
16+
description: "Currently support version 3.9, 3.10, 3.11, 3.12, 3.13"
17+
required: false
18+
type: string
19+
default: '3.12'
1520
cpu-architecture:
1621
description: "Permitted values: x86_64 or arm64"
1722
required: false
@@ -31,6 +36,7 @@ env:
3136
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}
3237
E2E_TEST_ROLE_NAME: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME }}
3338
ADOT_WHEEL_NAME: ${{ inputs.staging-wheel-name }}
39+
PYTHON_VERSION: ${{ inputs.python-version }}
3440
METRIC_NAMESPACE: genesis
3541
LOG_GROUP_NAME: test/genesis
3642
TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE}
@@ -44,18 +50,18 @@ jobs:
4450
- uses: actions/checkout@v4
4551

4652
- name: Set Get ADOT Wheel command environment variable
47-
run: echo GET_ADOT_WHEEL_COMMAND="aws s3 cp s3://adot-main-build-staging-jar/${{ env.ADOT_WHEEL_NAME }} ./${{ env.ADOT_WHEEL_NAME }} && sudo python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
48-
# if [ "${{ github.event.repository.name }}" = "aws-otel-python-instrumentation" ]; then
49-
# # Reusing the adot-main-build-staging-jar bucket to store the python wheel file
50-
# echo GET_ADOT_WHEEL_COMMAND="aws s3 cp s3://adot-main-build-staging-jar/${{ env.ADOT_WHEEL_NAME }} ./${{ env.ADOT_WHEEL_NAME }} && sudo python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
51-
# elif [ "${{ env.OTEL_SOURCE }}" == "pypi" ]; then
52-
# echo GET_ADOT_WHEEL_COMMAND="sudo python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
53-
# else
54-
# latest_release_version=$(curl -sL https://github.com/aws-observability/aws-otel-python-instrumentation/releases/latest | grep -oP '/releases/tag/v\K[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
55-
# echo "The latest version is $latest_release_version"
56-
# echo GET_ADOT_WHEEL_COMMAND="wget -O ${{ env.ADOT_WHEEL_NAME }} https://github.com/aws-observability/aws-otel-python-instrumentation/releases/latest/download/aws_opentelemetry_distro-$latest_release_version-py3-none-any.whl \
57-
# && sudo python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
58-
# fi
53+
run: |
54+
if [ "${{ github.event.repository.name }}" = "aws-otel-python-instrumentation" ]; then
55+
# Reusing the adot-main-build-staging-jar bucket to store the python wheel file
56+
echo GET_ADOT_WHEEL_COMMAND="aws s3 cp s3://adot-main-build-staging-jar/${{ env.ADOT_WHEEL_NAME }} ./${{ env.ADOT_WHEEL_NAME }} && python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
57+
elif [ "${{ env.OTEL_SOURCE }}" == "pypi" ]; then
58+
echo GET_ADOT_WHEEL_COMMAND="python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
59+
else
60+
latest_release_version=$(curl -sL https://github.com/aws-observability/aws-otel-python-instrumentation/releases/latest | grep -oP '/releases/tag/v\K[0-9]+\.[0-9]+\.[0-9]+' | head -n 1)
61+
echo "The latest version is $latest_release_version"
62+
echo GET_ADOT_WHEEL_COMMAND="wget -O ${{ env.ADOT_WHEEL_NAME }} https://github.com/aws-observability/aws-otel-python-instrumentation/releases/latest/download/aws_opentelemetry_distro-$latest_release_version-py3-none-any.whl \
63+
&& python${{ env.PYTHON_VERSION }} -m pip install ${{ env.ADOT_WHEEL_NAME }}" >> $GITHUB_ENV
64+
fi
5965
6066
- name: Initiate Gradlew Daemon
6167
uses: ./.github/workflows/actions/execute_and_retry
@@ -75,10 +81,14 @@ jobs:
7581
ID_2="$(openssl rand -hex 12)"
7682
W3C_TRACE_ID="${ID_1}${ID_2}"
7783
XRAY_TRACE_ID="1-${ID_1}-${ID_2}"
84+
PARENT_ID="$(openssl rand -hex 8)"
85+
TRACE_ID_HEADER="Root=${XRAY_TRACE_ID};Parent=${PARENT_ID};Sampled=1"
7886
echo "XRAY_TRACE_ID=${XRAY_TRACE_ID}" >> $GITHUB_ENV
7987
echo "W3C_TRACE_ID=${W3C_TRACE_ID}" >> $GITHUB_ENV
88+
echo "TRACE_ID_HEADER=${TRACE_ID_HEADER}" >> $GITHUB_ENV
8089
echo "Generated XRay Trace ID: ${XRAY_TRACE_ID}"
8190
echo "Generated W3C Trace ID: ${W3C_TRACE_ID}"
91+
echo "Generated Trace ID Header: ${TRACE_ID_HEADER}"
8292
8393
- name: Configure AWS Credentials
8494
uses: aws-actions/configure-aws-credentials@v4
@@ -107,15 +117,17 @@ jobs:
107117
-var="aws_region=${{ env.E2E_TEST_AWS_REGION }}" \
108118
-var="test_id=${{ env.TESTING_ID }}" \
109119
-var="service_zip_url=${{ env.SAMPLE_APP_ZIP }}" \
110-
-var="trace_id=Root=${{ env.XRAY_TRACE_ID }};Parent=$(openssl rand -hex 8);Sampled=1"
120+
-var="trace_id=${{ env.TRACE_ID_HEADER }}" \
121+
-var="get_adot_wheel_command=${{ env.GET_ADOT_WHEEL_COMMAND }}" \
122+
-var="python_version=${{ env.PYTHON_VERSION }}"
111123
112124
- name: Get deployment info
113125
working-directory: terraform/python/ec2/adot-genai
114126
run: |
115127
echo "INSTANCE_IP=$(terraform output langchain_service_public_ip)" >> $GITHUB_ENV
116128
echo "INSTANCE_ID=$(terraform output langchain_service_instance_id)" >> $GITHUB_ENV
117129
118-
- name: Wait for Gen AI service to be ready and emit logs, traces, and metrics
130+
- name: Waiting 5 Minutes for Gen AI service to be ready and emit logs, traces, and metrics
119131
run: sleep 300
120132

121133
- name: Validate generated logs
@@ -166,5 +178,5 @@ jobs:
166178
-var="aws_region=${{ env.E2E_TEST_AWS_REGION }}" \
167179
-var="test_id=${{ env.TESTING_ID }}" \
168180
-var="service_zip_url=${{ env.SAMPLE_APP_ZIP }}" \
169-
-var="trace_id=Root=${{ env.XRAY_TRACE_ID }};Parent=53995c3f42cd8ad8;Sampled=1"
170-
181+
-var="trace_id=${{ env.TRACE_ID_HEADER }}" \
182+
-var="get_adot_wheel_command=${{ env.GET_ADOT_WHEEL_COMMAND }}"

terraform/python/ec2/adot-genai/main.tf

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,21 @@ resource "aws_instance" "main_service_instance" {
7373
user_data = base64encode(<<-EOF
7474
#!/bin/bash
7575
yum update -y
76-
yum install -y python3.12 python3.12-pip unzip bc
76+
yum install -y python${var.python_version} python${var.python_version}-pip unzip bc
7777
7878
mkdir -p /app
7979
cd /app
8080
aws s3 cp ${var.service_zip_url} genai-service.zip
8181
unzip genai-service.zip
8282
8383
# Having issues installing dependencies from ec2-requirements.txt as these dependencies are quite large and cause timeouts/memory issues on EC2, manually installing instead
84-
python3.12 -m pip install fastapi uvicorn[standard] --no-cache-dir
85-
python3.12 -m pip install boto3 botocore setuptools --no-cache-dir
86-
python3.12 -m pip install opentelemetry-api opentelemetry-sdk opentelemetry-semantic-conventions --no-cache-dir
87-
python3.12 -m pip install langchain langchain-community langchain_aws --no-cache-dir
88-
python3.12 -m pip install python-dotenv openlit --no-cache-dir
89-
python3.12 -m pip install openinference-instrumentation-langchain aws_opentelemetry_distro_genai_beta --no-cache-dir
84+
python${var.python_version} -m pip install fastapi uvicorn[standard] --no-cache-dir
85+
python${var.python_version} -m pip install boto3 botocore setuptools --no-cache-dir
86+
python${var.python_version} -m pip install opentelemetry-api opentelemetry-sdk opentelemetry-semantic-conventions --no-cache-dir
87+
python${var.python_version} -m pip install langchain langchain-community langchain_aws --no-cache-dir
88+
python${var.python_version} -m pip install python-dotenv openlit --no-cache-dir
89+
python${var.python_version} -m pip install openinference-instrumentation-langchain --no-cache-dir
90+
${var.get_adot_wheel_command}
9091
9192
export AWS_REGION=${var.aws_region}
9293
export OTEL_PROPAGATORS=tracecontext,xray,baggage
@@ -96,7 +97,7 @@ export OTEL_EXPORTER_OTLP_LOGS_HEADERS="x-aws-log-group=test/genesis,x-aws-log-s
9697
export OTEL_RESOURCE_ATTRIBUTES="service.name=langchain-traceloop-app"
9798
export AGENT_OBSERVABILITY_ENABLED="true"
9899
99-
nohup opentelemetry-instrument python3.12 server.py > /var/log/langchain-service.log 2>&1 &
100+
nohup opentelemetry-instrument python${var.python_version} server.py > /var/log/langchain-service.log 2>&1 &
100101
101102
# Wait for service to be ready
102103
echo "Waiting for service to be ready..."

terraform/python/ec2/adot-genai/variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ variable "service_zip_url" {
2525
description = "S3 URL for the service zip file"
2626
}
2727

28-
variable "language_version" {
28+
variable "python_version" {
2929
default = "3.12"
3030
}
3131

@@ -40,4 +40,9 @@ variable "user" {
4040
variable "trace_id" {
4141
description = "Trace ID for X-Ray tracing"
4242
default = "Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1"
43+
}
44+
45+
variable "get_adot_wheel_command" {
46+
description = "Command to get and install ADOT wheel"
47+
default = "python3.12 -m pip install aws-opentelemetry-distro"
4348
}

0 commit comments

Comments
 (0)