Skip to content

Commit 558efbf

Browse files
committed
Update readme
1 parent da38be6 commit 558efbf

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ let s3_span = AwsSpanBuilder::client(
104104

105105
## AWS Lambda instrumentation
106106

107+
### Generic layer
108+
109+
Generic lambda layer could be created using either `OtelLambdaLayer::new` or `OtelLambdaLayer::other` factory function.
110+
107111
```rust
108112
#[tokio::main]
109113
async fn main() -> Result<(), lambda_runtime::Error> {
@@ -125,3 +129,74 @@ async fn main() -> Result<(), lambda_runtime::Error> {
125129
Ok(())
126130
}
127131
```
132+
133+
Generic layer could be used for multi-purpose lambdas, but it is recommended to use a dedicated layer when possible.
134+
135+
### PubSub layer
136+
137+
This layer could be used when the lambda is triggered by some event like Kinesis Data Streams or DynamoDB Streams.
138+
139+
```rust
140+
let pubsub_telemetry_layer = OtelLambdaLayer::pubsub(
141+
provider,
142+
// The messaging system
143+
"AmazonKinesis",
144+
// The message destination arn or unique name
145+
Some("arn:aws:kinesis:us-east-2:123456789012:stream/mystream"),
146+
);
147+
```
148+
149+
SQS and SNS layers could be created using their own factory functions for convenience:
150+
151+
```rust
152+
let sqs_telemetry_layer = OtelLambdaLayer::sqs(
153+
provider,
154+
"arn:aws:sqs:us-east-2:444455556666:queue1",
155+
);
156+
let sns_telemetry_layer = OtelLambdaLayer::sns(
157+
provider,
158+
"arn:aws:sns:us-east-2:123456789012:MyTopic",
159+
);
160+
```
161+
162+
### Datasource layer
163+
164+
This layer could be used when the lambda is invoked in response to some data source operation such as a database or filesystem read/write.
165+
166+
It's recommended to use Datasource layer when processing Amazon Simple Storage Service event notifications.
167+
168+
```rust
169+
let s3_telemetry_layer = OtelLambdaLayer::datasource(
170+
provider,
171+
// The name of the source on which the triggering operation was performed
172+
"myBucketName",
173+
// The type of the operation that was performed on the data (usually "insert", "edit" or "delete")
174+
"edit",
175+
// The document name/table subjected to the operation
176+
Some("/myFolder/myFile.txt"),
177+
);
178+
```
179+
180+
Even though DynamoDB is a data source, it's recommended to use a `pubsub` layer when processing DynamoDB Streams events.
181+
182+
### Timer layer
183+
184+
This layer could be used when the lambda is invoked periodically by the Amazon EventBridge Scheduler.
185+
186+
```rust
187+
let cron_telemetry_layer = OtelLambdaLayer::timer(
188+
provider,
189+
// The schedule period as Cron Expression
190+
Some("0/5 * * * ? *"),
191+
);
192+
```
193+
194+
### HTTP layer
195+
196+
Tracing for API Gateway events is not fully supported since that would require extracting tracking metadata from the event payload, but parsing event body is not supported by the `OtelLambdaLayer` implementation.
197+
198+
Though it's still possible to create a simple HTTP layer to set the correct trigger type:
199+
200+
```rust
201+
let http_telemetry_layer = OtelLambdaLayer::http(provider);
202+
```

0 commit comments

Comments
 (0)