Skip to content

Commit 9878627

Browse files
authored
Merge branch 'main' into add-checksum
2 parents e560415 + 82a2e1c commit 9878627

File tree

33 files changed

+1525
-170
lines changed

33 files changed

+1525
-170
lines changed

.github/workflows/application-signals-e2e-test.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ jobs:
7575
shortsha="$(git rev-parse --short HEAD)"
7676
echo "SHORT_SHA=$shortsha" >> $GITHUB_OUTPUT
7777
shell: bash
78-
78+
7979
- name: Configure AWS credentials for private ECR
8080
uses: aws-actions/configure-aws-credentials@v4
8181
with:
8282
role-to-assume: arn:aws:iam::${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}:role/${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ROLE_NAME}}
8383
aws-region: us-east-1
84-
84+
8585
- name: Login to Amazon private ECR
8686
id: login-ecr
8787
run: |
@@ -163,3 +163,44 @@ jobs:
163163
aws-region: us-east-1
164164
test-cluster-name: 'eks-windows-manual'
165165
caller-workflow-name: 'main-build'
166+
167+
build-lambda-staging-sample-app:
168+
runs-on: ubuntu-latest
169+
steps:
170+
- uses: actions/checkout@v3
171+
172+
- name: Configure AWS Credentials
173+
uses: aws-actions/configure-aws-credentials@v4
174+
with:
175+
role-to-assume: ${{ secrets.STAING_ARTIFACTS_ACCESS_ROLE }}
176+
role-external-id: ApplicationSignalsDotnet
177+
aws-region: us-east-1
178+
179+
- name: Setup .NET
180+
uses: actions/setup-dotnet@v2
181+
with:
182+
dotnet-version: '8.0.x'
183+
184+
- name: Setup .NET Lambda Tools
185+
shell: bash
186+
run: dotnet tool install -g Amazon.Lambda.Tools
187+
working-directory: sample-applications/lambda-test-apps/SimpleLambdaFunction
188+
189+
- name: Build Lambda Sample App
190+
shell: bash
191+
run: dotnet lambda package -pl ./src/SimpleLambdaFunction
192+
working-directory: sample-applications/lambda-test-apps/SimpleLambdaFunction
193+
194+
- name: Upload Sample App to S3
195+
shell: bash
196+
run: |
197+
aws s3 cp ./src/SimpleLambdaFunction/bin/Release/net8.0/SimpleLambdaFunction.zip s3://adot-autoinstrumentation-dotnet-staging/function-${{ github.run_id }}.zip
198+
working-directory: sample-applications/lambda-test-apps/SimpleLambdaFunction
199+
200+
dotnet-lambda-test:
201+
needs: [ build-lambda-staging-sample-app ]
202+
uses: aws-observability/aws-application-signals-test-framework/.github/workflows/dotnet-lambda-test.yml@main
203+
secrets: inherit
204+
with:
205+
aws-region: us-east-1
206+
caller-workflow-name: 'main-build'

.github/workflows/release_build.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ jobs:
8080
with:
8181
name: AWS.Otel.DotNet.Auto.psm1
8282
path: ./installationScripts
83-
84-
- name: Download nuget package
85-
uses: actions/download-artifact@v3
86-
with:
87-
name: nuget-packages.zip
88-
path: ./artifacts/nuget
8983

9084
- name: Configure AWS credentials for Private S3 Bucket
9185
uses: aws-actions/configure-aws-credentials@v4
@@ -103,7 +97,6 @@ jobs:
10397
done
10498
aws s3 cp ./installationScripts/aws-otel-dotnet-install.sh "${{ env.RELEASE_PRIVATE_S3 }}/$PREFIX/aws-otel-dotnet-install.sh"
10599
aws s3 cp ./installationScripts/AWS.Otel.DotNet.Auto.psm1 "${{ env.RELEASE_PRIVATE_S3 }}/$PREFIX/AWS.Otel.DotNet.Auto.psm1"
106-
aws s3 cp ./artifacts/nuget/nuget-packages.zip "${{ env.RELEASE_PRIVATE_S3 }}/$PREFIX/nuget-packages.zip"
107100
108101
# Publish to GitHub releases
109102
- name: Create GH release
@@ -141,9 +134,6 @@ jobs:
141134
./installationScripts/AWS.Otel.DotNet.Auto.psm1 \
142135
AWS.Otel.DotNet.Auto.psm1.sha256 \
143136
--clobber
144-
gh release upload "v${{ github.event.inputs.version }}" \
145-
./artifacts/nuget/nuget-packages.zip \
146-
--clobber
147137
148138
release-image:
149139
# We want to build and release nuget first so that if it fails, it fails before publishing to private ECR
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Release Lambda layer
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: The version to tag the lambda release with, e.g., 1.2.0
8+
required: true
9+
aws_region:
10+
description: 'Deploy to aws regions'
11+
required: true
12+
default: 'us-east-1, us-east-2, us-west-1, us-west-2, ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1, af-south-1, ap-east-1, ap-south-2, ap-southeast-3, ap-southeast-4, eu-central-2, eu-south-1, eu-south-2, il-central-1, me-central-1, me-south-1'
13+
14+
env:
15+
COMMERCIAL_REGIONS: us-east-1, us-east-2, us-west-1, us-west-2, ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1
16+
LAYER_NAME: AWSOpenTelemetryDistroDotNet
17+
18+
permissions:
19+
id-token: write
20+
contents: write
21+
22+
jobs:
23+
build-and-upload:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
aws-region: [ 'us-east-1' ]
28+
uses: ./.github/workflows/main_build.yml
29+
secrets: inherit
30+
with:
31+
caller-workflow-name: 'release_lambda_workflow'
32+
33+
setup-regions-matrix:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
aws_regions_json: ${{ steps.set-matrix.outputs.aws_regions_json }}
37+
steps:
38+
- name: Set up regions matrix
39+
id: set-matrix
40+
run: |
41+
IFS=',' read -ra REGIONS <<< "${{ github.event.inputs.aws_region }}"
42+
MATRIX="["
43+
for region in "${REGIONS[@]}"; do
44+
trimmed_region=$(echo "$region" | xargs)
45+
MATRIX+="\"$trimmed_region\","
46+
done
47+
MATRIX="${MATRIX%,}]"
48+
echo ${MATRIX}
49+
echo "aws_regions_json=${MATRIX}" >> $GITHUB_OUTPUT
50+
- name: Checkout Repo @ SHA - ${{ github.sha }}
51+
uses: actions/checkout@v4
52+
53+
publish-prod:
54+
runs-on: ubuntu-latest
55+
needs: [build-and-upload, setup-regions-matrix]
56+
strategy:
57+
matrix:
58+
aws_region: ${{ fromJson(needs.setup-regions-matrix.outputs.aws_regions_json) }}
59+
steps:
60+
- name: role arn
61+
env:
62+
COMMERCIAL_REGIONS: ${{ env.COMMERCIAL_REGIONS }}
63+
run: |
64+
COMMERCIAL_REGIONS_ARRAY=(${COMMERCIAL_REGIONS//,/ })
65+
FOUND=false
66+
for REGION in "${COMMERCIAL_REGIONS_ARRAY[@]}"; do
67+
if [[ "$REGION" == "${{ matrix.aws_region }}" ]]; then
68+
FOUND=true
69+
break
70+
fi
71+
done
72+
if [ "$FOUND" = true ]; then
73+
echo "Found ${{ matrix.aws_region }} in COMMERCIAL_REGIONS"
74+
SECRET_KEY="LAMBDA_LAYER_RELEASE"
75+
else
76+
echo "Not found ${{ matrix.aws_region }} in COMMERCIAL_REGIONS"
77+
SECRET_KEY="${{ matrix.aws_region }}_LAMBDA_LAYER_RELEASE"
78+
fi
79+
SECRET_KEY=${SECRET_KEY//-/_}
80+
echo "SECRET_KEY=${SECRET_KEY}" >> $GITHUB_ENV
81+
- uses: aws-actions/[email protected]
82+
with:
83+
role-to-assume: ${{ secrets[env.SECRET_KEY] }}
84+
role-duration-seconds: 1200
85+
aws-region: ${{ matrix.aws_region }}
86+
- name: Get s3 bucket name for release
87+
run: |
88+
echo BUCKET_NAME=dotnet-lambda-layer-${{ github.run_id }}-${{ matrix.aws_region }} | tee --append $GITHUB_ENV
89+
- name: Download Linux x64 Artifact
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: aws-distro-opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip
93+
- name: publish
94+
run: |
95+
aws s3 mb s3://${{ env.BUCKET_NAME }}
96+
aws s3 cp aws-distro-opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip s3://${{ env.BUCKET_NAME }}
97+
layerARN=$(
98+
aws lambda publish-layer-version \
99+
--layer-name ${{ env.LAYER_NAME }} \
100+
--content S3Bucket=${{ env.BUCKET_NAME }},S3Key=aws-distro-opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip \
101+
--compatible-runtimes dotnet6 dotnet8 \
102+
--compatible-architectures "x86_64" \
103+
--license-info "Apache-2.0" \
104+
--description "AWS Distro of OpenTelemetry Lambda Layer for .Net Runtime v${{ github.event.inputs.version }}" \
105+
--query 'LayerVersionArn' \
106+
--output text
107+
)
108+
echo $layerARN
109+
echo "LAYER_ARN=${layerARN}" >> $GITHUB_ENV
110+
mkdir ${{ env.LAYER_NAME }}
111+
echo $layerARN > ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
112+
cat ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
113+
- name: public layer
114+
run: |
115+
layerVersion=$(
116+
aws lambda list-layer-versions \
117+
--layer-name ${{ env.LAYER_NAME }} \
118+
--query 'max_by(LayerVersions, &Version).Version'
119+
)
120+
aws lambda add-layer-version-permission \
121+
--layer-name ${{ env.LAYER_NAME }} \
122+
--version-number $layerVersion \
123+
--principal "*" \
124+
--statement-id publish \
125+
--action lambda:GetLayerVersion
126+
- name: upload layer arn artifact
127+
if: ${{ success() }}
128+
uses: actions/upload-artifact@v3
129+
with:
130+
name: ${{ env.LAYER_NAME }}
131+
path: ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
132+
- name: clean s3
133+
if: always()
134+
run: |
135+
aws s3 rb --force s3://${{ env.BUCKET_NAME }}
136+
generate-release-note:
137+
runs-on: ubuntu-latest
138+
needs: publish-prod
139+
steps:
140+
- name: Checkout Repo @ SHA - ${{ github.sha }}
141+
uses: actions/checkout@v4
142+
- uses: hashicorp/setup-terraform@v2
143+
- name: download layerARNs
144+
uses: actions/download-artifact@v3
145+
with:
146+
name: ${{ env.LAYER_NAME }}
147+
path: ${{ env.LAYER_NAME }}
148+
- name: show layerARNs
149+
run: |
150+
for file in ${{ env.LAYER_NAME }}/*
151+
do
152+
echo $file
153+
cat $file
154+
done
155+
- name: generate layer-note
156+
working-directory: ${{ env.LAYER_NAME }}
157+
run: |
158+
echo "| Region | Layer ARN |" >> ../layer-note
159+
echo "| ---- | ---- |" >> ../layer-note
160+
for file in *
161+
do
162+
read arn < $file
163+
echo "| " $file " | " $arn " |" >> ../layer-note
164+
done
165+
cd ..
166+
cat layer-note
167+
- name: generate tf layer
168+
working-directory: ${{ env.LAYER_NAME }}
169+
run: |
170+
echo "locals {" >> ../layer.tf
171+
echo " sdk_layer_arns = {" >> ../layer.tf
172+
for file in *
173+
do
174+
read arn < $file
175+
echo " \""$file"\" = \""$arn"\"" >> ../layer.tf
176+
done
177+
cd ..
178+
echo " }" >> layer.tf
179+
echo "}" >> layer.tf
180+
terraform fmt layer.tf
181+
cat layer.tf
182+
- name: upload layer tf file
183+
uses: actions/upload-artifact@v3
184+
with:
185+
name: layer.tf
186+
path: layer.tf
187+
# do we want this as part of the release build or alone as it's own release?
188+
- name: Create GH release
189+
id: create_release
190+
env:
191+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
192+
run: |
193+
gh release create --target "$GITHUB_REF_NAME" \
194+
--title "Release lambda-v${{ github.event.inputs.version }}" \
195+
--draft \
196+
"lambda-v${{ github.event.inputs.version }}" \
197+
layer.tf

build/Build.InstallationScripts.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
internal partial class Build : NukeBuild
99
{
1010
private readonly AbsolutePath installationScriptsFolder = RootDirectory / "bin" / "InstallationScripts";
11-
private readonly string version = "1.4.0.dev0";
11+
private readonly string version = "1.5.0.dev0";
1212

1313
public Target BuildInstallationScripts => _ => _
1414
.After(this.Clean)

build/Build.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
internal partial class Build : NukeBuild
1414
{
15-
private const string OpenTelemetryAutoInstrumentationDefaultVersion = "v1.7.0";
15+
private const string OpenTelemetryAutoInstrumentationDefaultVersion = "v1.9.0";
1616
private static readonly AbsolutePath TestNuGetPackageApps = NukeBuild.RootDirectory / "test" / "test-applications" / "nuget-package";
1717

1818
[Solution("AWS.Distro.OpenTelemetry.AutoInstrumentation.sln")]
@@ -144,6 +144,10 @@ private static string GetOTelAutoInstrumentationFileName()
144144
var source = RootDirectory / "instrument.sh";
145145
var dest = this.openTelemetryDistributionFolder;
146146
FileSystemTasks.CopyFileToDirectory(source, dest, FileExistsPolicy.Overwrite);
147+
148+
var otelInstrumentSource = RootDirectory / "otel-instrument";
149+
var otelInstrumentDest = this.openTelemetryDistributionFolder;
150+
FileSystemTasks.CopyFileToDirectory(otelInstrumentSource, otelInstrumentDest, FileExistsPolicy.Overwrite);
147151
});
148152

149153
private Target CopyConfiguration => _ => _

instrument.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,13 @@ if [ "$ENABLE_PROFILING" = "true" ]; then
214214
export OTEL_TRACES_EXPORTER="none";
215215
fi
216216

217-
# TODO: need to disable all instrumentations except aws sdk and lambda.
217+
if [ -z "${OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED}" ]; then
218+
export OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED="false";
219+
fi
220+
221+
if [ -z "${OTEL_DOTNET_AUTO_METRICS_INSTRUMENTATION_ENABLED}" ]; then
222+
export OTEL_DOTNET_AUTO_METRICS_INSTRUMENTATION_ENABLED="false";
223+
fi
218224

219225
else
220226
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"

otel-instrument

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
. $(dirname "$0")/instrument.sh "$@"

sample-applications/lambda-test-apps/SimpleLambdaFunction/terraform/lambda/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module "test-function" {
2727
layers = compact([aws_lambda_layer_version.sdk_layer.arn])
2828

2929
environment_variables = {
30-
AWS_LAMBDA_EXEC_WRAPPER = "/opt/instrument.sh"
30+
AWS_LAMBDA_EXEC_WRAPPER = "/opt/otel-instrument"
3131
}
3232

3333
tracing_mode = var.tracing_mode

src/AWS.Distro.OpenTelemetry.AutoInstrumentation/AwsAttributeKeys.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ internal sealed class AwsAttributeKeys
1414
internal static readonly string AttributeAWSRemoteOperation = "aws.remote.operation";
1515

1616
internal static readonly string AttributeAWSRemoteResourceIdentifier = "aws.remote.resource.identifier";
17+
internal static readonly string AttributeAWSCloudformationPrimaryIdentifier = "aws.remote.resource.cfn.primary.identifier";
1718
internal static readonly string AttributeAWSRemoteResourceType = "aws.remote.resource.type";
1819
internal static readonly string AttributeAWSSdkDescendant = "aws.sdk.descendant";
1920
internal static readonly string AttributeAWSConsumerParentSpanKind = "aws.consumer.parent.span.kind";
@@ -47,7 +48,12 @@ internal sealed class AwsAttributeKeys
4748
internal static readonly string AttributeAWSDynamoTableName = "aws.table_name";
4849
internal static readonly string AttributeAWSSQSQueueUrl = "aws.queue_url";
4950

51+
internal static readonly string AttributeAWSLambdaResourceMappingId = "aws.lambda.resource_mapping.id";
5052
internal static readonly string AttributeAWSS3Bucket = "aws.s3.bucket";
53+
internal static readonly string AttributeAWSSecretsManagerSecretArn = "aws.secretsmanager.secret.arn";
54+
internal static readonly string AttributeAWSSNSTopicArn = "aws.sns.topic.arn";
55+
internal static readonly string AttributeAWSStepFunctionsActivityArn = "aws.stepfunctions.activity.arn";
56+
internal static readonly string AttributeAWSStepFunctionsStateMachineArn = "aws.stepfunctions.state_machine.arn";
5157

5258
internal static readonly string AttributeAWSBedrockGuardrailId = "aws.bedrock.guardrail.id";
5359
internal static readonly string AttributeAWSBedrockAgentId = "aws.bedrock.agent.id";

0 commit comments

Comments
 (0)