Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
84dced9
Organize crate into modules.
calavera Jan 22, 2022
dd9f1d0
Initial logs processor implementation
calavera Jan 23, 2022
b67432d
Fix value returned by the register function.
calavera Jan 23, 2022
dfcbb9a
Add logs subcription call
calavera Jan 25, 2022
2dd14c7
Clean logs file.
calavera Jan 25, 2022
677099b
feat(lambda-extension): log processor server (DOES NOT WORK)
nmoutschen Feb 1, 2022
6b6e71f
feat(lambda-extension): use MakeService for log processor (DOES NOT W…
nmoutschen Feb 9, 2022
4d2ff7a
feat(lambda-extension): restrict trait bounds for Identity/MakeIdentity
nmoutschen Feb 15, 2022
037432d
feat(lambda-extension): deserialize Vec<LambdaLog>
nmoutschen Feb 16, 2022
2ee1bf5
test: add integration tests for Logs API handler
nmoutschen Feb 16, 2022
4fb308c
chore: cargo fmt
nmoutschen Feb 16, 2022
eafc1eb
feat(lambda-extension): add tracing and customizable port number for …
nmoutschen Feb 16, 2022
f8e5180
feat(lambda-extension): implement LambdaLogRecord enum
nmoutschen Feb 16, 2022
5222868
fix(lambda-extension): fix bounds for with_logs_processor()
nmoutschen Feb 16, 2022
a2efc30
feat(lambda-extension): use chrono::DateTime for LambdaLog time
nmoutschen Feb 16, 2022
b2be9bc
feat(lambda-extension): add combined example
nmoutschen Feb 16, 2022
4728bd5
docs(lambda-extension): add example for logs processor
nmoutschen Feb 16, 2022
02a3f6f
Merge branch 'master' into logs_api_connection
nmoutschen Feb 16, 2022
8731f6f
feat(lambda-integration-tests): update log processor
nmoutschen Feb 16, 2022
142996a
Merge branch 'logs_api_connection' of github.com:awslabs/aws-lambda-r…
nmoutschen Feb 16, 2022
44bf723
fix(lambda-integration-tests): add tracing config to logs-trait
nmoutschen Feb 16, 2022
ece3576
chore: cargo fmt
nmoutschen Feb 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions lambda-extension/examples/combined.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use lambda_extension::{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another great example! 😻

service_fn, Error, Extension, LambdaEvent, LambdaLog, LambdaLogRecord, NextEvent, SharedService,
};
use tracing::info;

async fn my_extension(event: LambdaEvent) -> Result<(), Error> {
match event.next {
NextEvent::Shutdown(_e) => {
// do something with the shutdown event
}
NextEvent::Invoke(_e) => {
// do something with the invoke event
}
}
Ok(())
}

async fn my_log_processor(logs: Vec<LambdaLog>) -> Result<(), Error> {
for log in logs {
match log.record {
LambdaLogRecord::Function(record) => info!("[logs] [function] {}", record),
LambdaLogRecord::Extension(record) => info!("[logs] [extension] {}", record),
_ => (),
}
}

Ok(())
}

#[tokio::main]
async fn main() -> Result<(), Error> {
// The runtime logging can be enabled here by initializing `tracing` with `tracing-subscriber`
// While `tracing` is used internally, `log` can be used as well if preferred.
tracing_subscriber::fmt()
.with_max_level(tracing::Level::INFO)
// this needs to be set to false, otherwise ANSI color codes will
// show up in a confusing manner in CloudWatch logs.
.with_ansi(false)
// disabling time is handy because CloudWatch will add the ingestion time.
.without_time()
.init();

let func = service_fn(my_extension);
let logs_processor = SharedService::new(service_fn(my_log_processor));

Extension::new()
.with_events_processor(func)
.with_logs_processor(logs_processor)
.run()
.await
}
2 changes: 1 addition & 1 deletion lambda-extension/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ where

#[cfg(test)]
mod tests {
use chrono::TimeZone;
use super::*;
use chrono::TimeZone;

#[test]
fn deserialize_full() {
Expand Down