You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lambda-runtime-api-client/src/tracing.rs
+33-2Lines changed: 33 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -14,12 +14,16 @@ pub use tracing::*;
14
14
15
15
/// Re-export the `tracing-subscriber` crate to build your own subscribers.
16
16
pubuse tracing_subscriber as subscriber;
17
+
use tracing_subscriber::fmt::MakeWriter;
17
18
18
19
constDEFAULT_LOG_LEVEL:&str = "INFO";
19
20
20
21
/// Initialize `tracing-subscriber` with default logging options.
21
22
///
22
-
/// This function uses environment variables set with [Lambda's advance logging controls](https://aws.amazon.com/blogs/compute/introducing-advanced-logging-controls-for-aws-lambda-functions/)
23
+
/// The default subscriber writes logs to STDOUT in the current context.
24
+
/// If you want to customize the writer, see [`init_default_subscriber_with_writer()`].
25
+
///
26
+
/// This function uses environment variables set with [Lambda's advanced logging controls](https://aws.amazon.com/blogs/compute/introducing-advanced-logging-controls-for-aws-lambda-functions/)
23
27
/// if they're configured for your function.
24
28
///
25
29
/// This subscriber sets the logging level based on environment variables:
/// Initialize `tracing-subscriber` with default logging options, and a custom writer.
42
+
///
43
+
/// You might want to avoid writing to STDOUT in the local context via [`init_default_subscriber()`], if you have a high-throughput Lambdas that involve
44
+
/// a lot of async concurrency. Since, writing to STDOUT can briefly block your tokio runtime - ref [tracing #2653](https://github.com/tokio-rs/tracing/issues/2653).
45
+
/// In that case, you might prefer to use [tracing_appender::NonBlocking] instead - particularly if your Lambda is fairly long-running and stays warm.
46
+
/// Though, note that you are then responsible
47
+
/// for ensuring gracefuls shutdown. See [`examples/graceful-shutdown`] for a complete example.
48
+
///
49
+
/// This function uses environment variables set with [Lambda's advanced logging controls](https://aws.amazon.com/blogs/compute/introducing-advanced-logging-controls-for-aws-lambda-functions/)
50
+
/// if they're configured for your function.
51
+
///
52
+
/// This subscriber sets the logging level based on environment variables:
53
+
/// - if `AWS_LAMBDA_LOG_LEVEL` is set, it takes precedence over any other environment variables.
54
+
/// - if `AWS_LAMBDA_LOG_LEVEL` is not set, check if `RUST_LOG` is set.
55
+
/// - if none of those two variables are set, use `INFO` as the logging level.
56
+
///
57
+
/// The logging format can also be changed based on Lambda's advanced logging controls.
58
+
/// If the `AWS_LAMBDA_LOG_FORMAT` environment variable is set to `JSON`, the log lines will be formatted as json objects,
59
+
/// otherwise they will be formatted with the default tracing format.
0 commit comments