Skip to content

Commit 87f8167

Browse files
authored
feat(sumolambda): initial commit (#1)
* feat(lambda): init * feat(otlambda): add ot lambda repo
1 parent 9540144 commit 87f8167

File tree

95 files changed

+4098
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+4098
-1
lines changed

.github/.mlc_config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"ignorePatterns": [
3+
{"pattern": "^http://localhost:8080"},
4+
{"pattern": "^https://calendar.google.com/calendar"}
5+
],
6+
"replacementPatterns": [
7+
{
8+
"pattern": "^/",
9+
"replacement": "/github/workspace/"
10+
}
11+
],
12+
"aliveStatusCodes": [
13+
200,
14+
429
15+
]
16+
}

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Learn about CODEOWNERS file format:
2+
# https://help.github.com/en/articles/about-code-owners
3+
4+
* @SumoLogic/open-source-collection-team

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/pull_request_template.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
**Description:** <Describe what has changed.>
2+
Ex. Fixing a bug - Describe the bug and how this fixes the issue.
3+
Ex. Adding a feature - Explain what this achieves.>
4+
5+
**Link to tracking Issue:** <Issue number if applicable>
6+
7+
**Testing:** < Describe what testing was performed and which tests were added.>
8+
9+
**Documentation:** < Describe the documentation added.>
10+
11+
<!-- DO NOT DELETE -->
12+
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Build and upload artifacts
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
BUILD_COMMAND:
7+
required: true
8+
type: string
9+
LANGUAGE:
10+
required: true
11+
type: string
12+
ARTIFACT_ARCHIVE_BASE_NAME:
13+
required: true
14+
type: string
15+
ARTIFACT_NAME:
16+
required: true
17+
type: string
18+
19+
jobs:
20+
build-and-upload-artifacts:
21+
strategy:
22+
matrix:
23+
architecture: [ amd64, arm64 ]
24+
env:
25+
BUILD_COMMAND: ${{ inputs.BUILD_COMMAND }}
26+
LANGUAGE: ${{ inputs.LANGUAGE }}
27+
ARTIFACT_ARCHIVE_BASE_NAME: ${{ inputs.ARTIFACT_ARCHIVE_BASE_NAME }}
28+
ARTIFACT_NAME: ${{ inputs.ARTIFACT_NAME }}
29+
ARCHITECTURE: ${{ matrix.architecture }}
30+
GOARCH: ${{ matrix.architecture }}
31+
name: Build and upload artifacts
32+
runs-on: ubuntu-22.04
33+
steps:
34+
- uses: actions/checkout@v3
35+
with:
36+
submodules: true
37+
- uses: actions/setup-go@v4
38+
with:
39+
go-version: '^1.19.3'
40+
- uses: actions/setup-java@v3
41+
if: env.LANGUAGE == 'java'
42+
with:
43+
distribution: adopt
44+
java-version: '11'
45+
- name: Cache (Java)
46+
if: env.LANGUAGE == 'java'
47+
uses: actions/cache@v3
48+
with:
49+
path: |
50+
~/go/pkg/mod
51+
~/.gradle/caches
52+
~/.gradle/wrapper
53+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-go-${{ hashFiles('**/go.sum') }}
54+
restore-keys: |
55+
${{ runner.os }}-gradle-
56+
- uses: actions/setup-node@v3
57+
if: env.LANGUAGE == 'nodejs'
58+
with:
59+
node-version: '14'
60+
- name: Cache (NodeJS)
61+
if: env.LANGUAGE == 'nodejs'
62+
uses: actions/cache@v3
63+
with:
64+
path: |
65+
~/go/pkg/mod
66+
~/.npm
67+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}-go-${{ hashFiles('**/go.sum') }}
68+
restore-keys: |
69+
${{ runner.os }}-node-
70+
- uses: actions/setup-python@v4
71+
if: env.LANGUAGE == 'python'
72+
with:
73+
python-version: '3.9'
74+
- name: Cache (Python)
75+
if: env.LANGUAGE == 'python'
76+
uses: actions/cache@v3
77+
with:
78+
path: |
79+
~/go/pkg/mod
80+
~/.cache/pip
81+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-go-${{ hashFiles('**/go.sum') }}
82+
restore-keys: |
83+
${{ runner.os }}-pip-
84+
- name: Build artifacts - ${{ matrix.architecture }}
85+
run: ${{ env.BUILD_COMMAND }}
86+
- name: Upload artifacts - java
87+
if: env.LANGUAGE == 'java' && success()
88+
uses: actions/upload-artifact@v3
89+
with:
90+
name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
91+
path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip
92+
if-no-files-found: error
93+
- name: Rename sample-app java artifact
94+
if: env.LANGUAGE == 'java' && success()
95+
run: |
96+
mv opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/aws-sdk-all.jar \
97+
opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/java-sample-app.jar
98+
- name: Upload artifacts - java sample-app
99+
if: env.LANGUAGE == 'java' && success()
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
103+
path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/libs/java-sample-app.jar
104+
if-no-files-found: error
105+
- name: Upload artifacts - nodejs
106+
if: env.LANGUAGE == 'nodejs' && success()
107+
uses: actions/upload-artifact@v3
108+
with:
109+
name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
110+
path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip
111+
if-no-files-found: error
112+
- name: Rename sample-app nodejs artifact
113+
if: env.LANGUAGE == 'nodejs' && success()
114+
run: |
115+
mv opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/function.zip \
116+
opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/nodejs-sample-app.zip
117+
- name: Upload artifacts - nodejs sample-app
118+
if: env.LANGUAGE == 'nodejs' && success()
119+
uses: actions/upload-artifact@v3
120+
with:
121+
name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
122+
path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/aws-sdk/build/nodejs-sample-app.zip
123+
if-no-files-found: error
124+
- name: Upload artifacts - python layer
125+
if: env.LANGUAGE == 'python' && success()
126+
uses: actions/upload-artifact@v3
127+
with:
128+
name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
129+
path: ${{ env.LANGUAGE }}/${{ env.ARTIFACT_ARCHIVE_BASE_NAME }}-${{ matrix.architecture }}.zip
130+
if-no-files-found: error
131+
- name: Rename sample-app python artifact
132+
if: env.LANGUAGE == 'python' && success()
133+
run: |
134+
mv opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/function.zip \
135+
opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/python-sample-app.zip
136+
- name: Upload artifacts - python sample-app
137+
if: env.LANGUAGE == 'python' && success()
138+
uses: actions/upload-artifact@v3
139+
with:
140+
name: sample-app-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
141+
path: opentelemetry-lambda/${{ env.LANGUAGE }}/sample-apps/build/python-sample-app.zip
142+
if-no-files-found: error
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Pull Request Build - Java
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'java/**'
7+
- '.github/workflows/*-java.yml'
8+
- '.github/workflows/tests.yml'
9+
- '!java/**.md'
10+
- '!java/sample-apps/template.yaml'
11+
12+
jobs:
13+
build-artifacts:
14+
uses: ./.github/workflows/build-artifacts.yml
15+
with:
16+
BUILD_COMMAND: make build-java
17+
LANGUAGE: java
18+
ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-java-wrapper
19+
ARTIFACT_NAME: ${{ github.head_ref }}
20+
21+
create-dev-lambda-layer:
22+
needs: build-artifacts
23+
uses: ./.github/workflows/publish-dev-layer.yml
24+
with:
25+
ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-java-wrapper
26+
ARTIFACT_NAME: ${{ github.head_ref }}
27+
LANGUAGE: java
28+
29+
run-tests:
30+
needs: create-dev-lambda-layer
31+
uses: ./.github/workflows/tests.yml
32+
with:
33+
LANGUAGE: java
34+
LAYER_ARN_AMD64: ${{ needs.create-dev-lambda-layer.outputs.lambdalayeramd64 }}
35+
LAYER_ARN_ARM64: ${{ needs.create-dev-lambda-layer.outputs.lambdalayerarm64 }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Pull Request Build - NodeJS
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'nodejs/**'
7+
- '.github/workflows/*-nodejs.yml'
8+
- '.github/workflows/tests.yml'
9+
- '!nodejs/**.md'
10+
- '!nodejs/sample-apps/template.yaml'
11+
12+
jobs:
13+
build-artifacts:
14+
uses: ./.github/workflows/build-artifacts.yml
15+
with:
16+
BUILD_COMMAND: make build-nodejs
17+
LANGUAGE: nodejs
18+
ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-nodejs
19+
ARTIFACT_NAME: ${{ github.head_ref }}
20+
21+
create-dev-lambda-layer:
22+
needs: build-artifacts
23+
uses: ./.github/workflows/publish-dev-layer.yml
24+
with:
25+
ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-nodejs
26+
ARTIFACT_NAME: ${{ github.head_ref }}
27+
LANGUAGE: nodejs
28+
29+
run-tests:
30+
needs: create-dev-lambda-layer
31+
uses: ./.github/workflows/tests.yml
32+
with:
33+
LANGUAGE: nodejs
34+
LAYER_ARN_AMD64: ${{ needs.create-dev-lambda-layer.outputs.lambdalayeramd64 }}
35+
LAYER_ARN_ARM64: ${{ needs.create-dev-lambda-layer.outputs.lambdalayerarm64 }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Pull Request Build - Python
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'python/**'
7+
- '.github/workflows/*-python.yml'
8+
- '.github/workflows/tests.yml'
9+
- '!python/**.md'
10+
- '!python/sample-apps/template.yaml'
11+
12+
jobs:
13+
build-artifacts:
14+
uses: ./.github/workflows/build-artifacts.yml
15+
with:
16+
BUILD_COMMAND: make build-python
17+
LANGUAGE: python
18+
ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-python
19+
ARTIFACT_NAME: ${{ github.head_ref }}
20+
21+
create-dev-lambda-layer:
22+
needs: build-artifacts
23+
uses: ./.github/workflows/publish-dev-layer.yml
24+
with:
25+
ARTIFACT_ARCHIVE_BASE_NAME: opentelemetry-python
26+
ARTIFACT_NAME: ${{ github.head_ref }}
27+
LANGUAGE: python
28+
29+
run-tests:
30+
needs: create-dev-lambda-layer
31+
uses: ./.github/workflows/tests.yml
32+
with:
33+
LANGUAGE: python
34+
LAYER_ARN_AMD64: ${{ needs.create-dev-lambda-layer.outputs.lambdalayeramd64 }}
35+
LAYER_ARN_ARM64: ${{ needs.create-dev-lambda-layer.outputs.lambdalayerarm64 }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Create Dev Lambda Layer
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
lambdalayeramd64:
7+
description: "Created x86_64 lambda layer arn"
8+
value: ${{ jobs.create-lambda-layer.outputs.lambdalayeramd64 }}
9+
lambdalayerarm64:
10+
description: "Created lambda layer arn"
11+
value: ${{ jobs.create-lambda-layer.outputs.lambdalayerarm64 }}
12+
inputs:
13+
LANGUAGE:
14+
required: true
15+
type: string
16+
ARTIFACT_ARCHIVE_BASE_NAME:
17+
required: true
18+
type: string
19+
ARTIFACT_NAME:
20+
required: true
21+
type: string
22+
23+
jobs:
24+
create-lambda-layer:
25+
name: Create Dev Lambda Layer
26+
runs-on: ubuntu-22.04
27+
permissions:
28+
id-token: write
29+
contents: read
30+
strategy:
31+
matrix:
32+
architecture: [ amd64, arm64 ]
33+
aws_region: [ eu-central-1 ]
34+
env:
35+
LANGUAGE: ${{ inputs.LANGUAGE }}
36+
LAYER_NAME: ${{ github.head_ref }}-${{ inputs.LANGUAGE }}-${{ matrix.architecture }}
37+
ARCHITECTURE: ${{ matrix.architecture }}
38+
ARTIFACT_ARCHIVE_BASE_NAME: ${{ inputs.ARTIFACT_ARCHIVE_BASE_NAME }}
39+
ARTIFACT_NAME: ${{ inputs.ARTIFACT_NAME }}
40+
BUCKET_NAME: ${{ github.head_ref }}-${{ inputs.LANGUAGE }}-${{ matrix.architecture }}-${{ github.run_id }}
41+
BUCKET_KEY: layer-${{ matrix.architecture }}-${{ matrix.aws_region }}-.zip
42+
DIRECTORY: ${{ inputs.LANGUAGE }}
43+
REGION: ${{ matrix.aws_region }}
44+
outputs:
45+
lambdalayeramd64: ${{ steps.get-latest-lambda-layer-arn-amd64.outputs.layeramd64 }}
46+
lambdalayerarm64: ${{ steps.get-latest-lambda-layer-arn-arm64.outputs.layerarm64 }}
47+
steps:
48+
- uses: actions/checkout@v3
49+
with:
50+
submodules: true
51+
- uses: actions/setup-python@v4
52+
with:
53+
python-version: '3.9'
54+
- name: Download artifacts
55+
uses: actions/download-artifact@v3
56+
with:
57+
name: ${{ env.ARTIFACT_NAME }}-${{ env.LANGUAGE }}-${{ matrix.architecture }}-artifacts
58+
path: ~/artifact
59+
- name: Configure AWS credentials
60+
uses: aws-actions/configure-aws-credentials@v2
61+
env:
62+
AWS_OPENID_ROLE_ARN: arn:aws:iam::663229565520:role/osc-team-sumo-opentelemetry-lambda-openid-connect
63+
with:
64+
role-to-assume: ${{ env.AWS_OPENID_ROLE_ARN }}
65+
aws-region: ${{ matrix.aws_region }}
66+
mask-aws-account-id: false
67+
- name: Install AWS CLI
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install awscli
71+
- name: Create S3 Bucket
72+
run: make create-bucket
73+
- name: Copy Collector and SDK archive to S3 bucket
74+
run: make copy-content-to-bucket
75+
- name: Create Lambda Layer
76+
run: make create-dev-lambda-layer
77+
- name: Get latest Lambda Layer arn amd64
78+
if: ${{ matrix.architecture == 'amd64' }}
79+
id: get-latest-lambda-layer-arn-amd64
80+
run: echo "layeramd64=$(make get-dev-latest-lambda-layer-arn)" >> $GITHUB_OUTPUT
81+
- name: Get latest Lambda Layer arn arm64
82+
if: ${{ matrix.architecture == 'arm64' }}
83+
id: get-latest-lambda-layer-arn-arm64
84+
run: echo "layerarm64=$(make get-dev-latest-lambda-layer-arn)" >> $GITHUB_OUTPUT
85+
- name: Clean s3
86+
if: always()
87+
run: make clean-s3

0 commit comments

Comments
 (0)