Skip to content

Commit 5bfeba6

Browse files
kien-csjleven
andauthored
Add / update 4 examples for Lambda + OpenTelemetry (#14)
* simple sdk * update * Adding 4 examples * doc * Update README.md Co-authored-by: Joshua Leven <josh@codesee.io> * Update README.md Co-authored-by: Joshua Leven <josh@codesee.io> * Update README.md Co-authored-by: Joshua Leven <josh@codesee.io> * Update README.md Co-authored-by: Joshua Leven <josh@codesee.io> * Update serverless-lambda-container-otel-layer-example/README.md Co-authored-by: Joshua Leven <josh@codesee.io> * showing multi-stage docker build --------- Co-authored-by: Joshua Leven <josh@codesee.io>
1 parent 003f5f6 commit 5bfeba6

File tree

37 files changed

+34497
-182
lines changed

37 files changed

+34497
-182
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
This repo contains various example on how to integrate with CodeSee
44

5-
`cdk-lambda-layer-example` - Show you example CDK to integrate with CodeSee Lambda Layer
65

7-
`sst-cdk-lambda-layer-example` - Show you example Serverless Stack + CDK to integrate with CodeSee Lambda Layer
6+
## Integrate with CodeSee via Datadog
7+
[`cdk-lambda-layer-example`](sst-cdk-lambda-layer-example/) - Example CDK to integrate with CodeSee Lambda Layer
88

9-
`serverless-al2-example` - Show you example Serverless + Golang + Amazon Linux 2 + CodeSee Lambda Layer
9+
[`sst-cdk-lambda-layer-example`](sst-cdk-lambda-layer-example/) - Example Serverless Stack + CDK to integrate with CodeSee Lambda Layer
1010

11-
`serverless-lambda-otel-example` - Show you example Serverless + Lambda + Open Telemetry integration
11+
[`serverless-al2-example`](serverless-al2-example/) - Example Serverless + Golang + Amazon Linux 2 + CodeSee Lambda Layer
1212

13-
`serverless-lambda-container-otel-example` - Show you example Serverless + Lambda Container + Open Telemetry integration
13+
## Integrate with CodeSee via OpenTelemetry
14+
[`serverless-lambda-layer-otel-example`](serverless-lambda-layer-otel-example/) - Example Serverless + Lambda + OpenTelemetry Lambda Layer instrumentation
15+
16+
[`serverless-lambda-otel-nodejs-lib-example`](serverless-lambda-otel-nodejs-lib-example/) - Example Serverless + Lambda + OpenTelemetry NodeSDK instrumentation
17+
18+
[`serverless-lambda-container-otel-layer-example`](serverless-lambda-container-otel-layer-example/) - Example Serverless + Lambda Container + OpenTelemetry Lambda Layer instrumentation
19+
20+
[`serverless-lambda-container-otel-nodejs-lib-example`](serverless-lambda-container-otel-nodejs-lib-example/) - Example Serverless + Lambda Container + OpenTelemetry NodeSDK instrumentation

serverless-lambda-container-otel-example/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

serverless-lambda-container-otel-example/app.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

serverless-lambda-container-otel-example/index.js

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM node:18-alpine AS build
2+
3+
# example Docker multi-stage build that requires system packages
4+
RUN apk add --no-cache \
5+
# Needed to build the example package: node-libcurl
6+
g++ make py3-pip curl-dev
7+
8+
COPY package.json .
9+
RUN npm i --omit=dev
10+
11+
# 2nd stage, only included built artifacts
12+
FROM public.ecr.aws/lambda/nodejs:18
13+
14+
COPY --from=build /node_modules .
15+
COPY lambda-layer/ /opt
16+
17+
COPY index.js .
18+
COPY collector.yaml .
19+
20+
CMD ["index.handler"]

serverless-lambda-container-otel-example/README.md renamed to serverless-lambda-container-otel-layer-example/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# serverless-lambda-container-otel-example
1+
# serverless-lambda-container-otel-layer-example
22

3-
Example Serverless + Lambda Container + Open Telemetry integration
3+
Example Serverless + Lambda Container + OpenTelemetry Lambda Layer instrumentation
44

55
## Install packages
66

77
```
88
npm i
99
```
1010

11-
## Copy the public Open Telemetry Lamda Layer
11+
## Copy the public OpenTelemetry Lamda Layer
1212

1313
Note: change the `arm64` to `amd64` in the ARN below based on your Lambda architecture.
1414
The Lambda ARN is located here: https://aws-otel.github.io/docs/getting-started/lambda/lambda-js
1515

1616
```
17-
# download the public
17+
# download the public AWS otel Lambda Layer
1818
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
1919
2020
# unzip the content into lambda-layer directory

serverless-lambda-container-otel-example/collector.yaml renamed to serverless-lambda-container-otel-layer-example/collector.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exporters:
1010
otlp/codesee:
1111
endpoint: "in-otel.codesee.io:443"
1212
headers:
13-
Authorization: "Bearer XXX"
13+
Authorization: "Bearer <REPLACE WITH CODESEE TOKEN>" # !! Set your CodeSee token here. Ex: Bearer CodeSee:123...
1414

1515
service:
1616
pipelines:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const bunyan = require('bunyan');
2+
// Lambda comes with aws-sdk v3, this example shows if you need v2, you can override it in package.json
3+
const AWS = require('aws-sdk');
4+
const log = bunyan.createLogger({name: "serverless-lambda-container-otel-layer-example"});
5+
6+
log.info("about to start handler");
7+
8+
module.exports.handler = async (event) => {
9+
log.info("inside lambda handler");
10+
log.info(`using AWS version: ${AWS.VERSION}`); // example to show override Lambda included aws-sdk with older version
11+
12+
return {
13+
statusCode: 200,
14+
body: JSON.stringify(
15+
{
16+
message: "hello from serverless-lambda-container-otel-layer-example lambda",
17+
input: event,
18+
},
19+
null,
20+
2
21+
),
22+
};
23+
};

0 commit comments

Comments
 (0)