Skip to content

Commit 003f5f6

Browse files
authored
Adding Lambda Container example (#13)
* Adding Lambda Container example * add direct auto instrument example * adding example to use otel js directly
1 parent e70969f commit 003f5f6

File tree

15 files changed

+12304
-249
lines changed

15 files changed

+12304
-249
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ This repo contains various example on how to integrate with CodeSee
99
`serverless-al2-example` - Show you example Serverless + Golang + Amazon Linux 2 + CodeSee Lambda Layer
1010

1111
`serverless-lambda-otel-example` - Show you example Serverless + Lambda + Open Telemetry integration
12+
13+
`serverless-lambda-container-otel-example` - Show you example Serverless + Lambda Container + Open Telemetry integration
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Serverless directories
2+
.serverless
3+
lambda-layer/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM public.ecr.aws/lambda/nodejs:12
2+
3+
COPY lambda-layer/ /opt
4+
COPY app.js ./
5+
COPY collector.yaml ./
6+
7+
CMD ["app.handler"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# serverless-lambda-container-otel-example
2+
3+
Example Serverless + Lambda Container + Open Telemetry integration
4+
5+
## Install packages
6+
7+
```
8+
npm i
9+
```
10+
11+
## Copy the public Open Telemetry Lamda Layer
12+
13+
Note: change the `arm64` to `amd64` in the ARN below based on your Lambda architecture.
14+
The Lambda ARN is located here: https://aws-otel.github.io/docs/getting-started/lambda/lambda-js
15+
16+
```
17+
# download the public
18+
curl $(aws lambda get-layer-version-by-arn --arn arn:aws:lambda:us-east-2:901920570463:layer:aws-otel-nodejs-arm64-ver-1-12-0:1 --query 'Content.Location' --output text) --output layer.zip
19+
20+
# unzip the content into lambda-layer directory
21+
unzip layer.zip -d lambda-layer/
22+
```
23+
24+
## Deploy Lambda
25+
26+
```
27+
sls deploy
28+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
module.exports.handler = async (event) => {
4+
return {
5+
statusCode: 200,
6+
body: JSON.stringify(
7+
{
8+
message: `Hello, world! Your function executed successfully!`,
9+
},
10+
null,
11+
2
12+
),
13+
};
14+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports.handler = async (event) => {
2+
3+
return {
4+
statusCode: 200,
5+
body: JSON.stringify(
6+
{
7+
message: "hello from serverless-lambda-container-otel-example lambda",
8+
input: event,
9+
},
10+
null,
11+
2
12+
),
13+
};
14+
};

0 commit comments

Comments
 (0)