File tree 3 files changed +17
-4
lines changed
lambda-runtime-api-client/src 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const DEFAULT_LOG_LEVEL: &str = "INFO";
23
23
/// if they're configured for your function.
24
24
///
25
25
/// This subscriber sets the logging level based on environment variables:
26
- /// - if `AWS_LAMBDA_LOG_LEVEL` is set, it takes predecence over any other environment variables.
26
+ /// - if `AWS_LAMBDA_LOG_LEVEL` is set, it takes precedence over any other environment variables.
27
27
/// - if `AWS_LAMBDA_LOG_LEVEL` is not set, check if `RUST_LOG` is set.
28
28
/// - if none of those two variables are set, use `INFO` as the logging level.
29
29
///
@@ -44,7 +44,7 @@ pub fn init_default_subscriber() {
44
44
. from_env_lossy ( ) ,
45
45
) ;
46
46
47
- if log_format. eq_ignore_ascii_case ( "json" ) {
47
+ if log_format. to_lowercase ( ) . contains ( "json" ) {
48
48
collector. json ( ) . init ( )
49
49
} else {
50
50
collector. init ( )
Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ impl TracingLayer {
14
14
pub fn new ( ) -> Self {
15
15
Self :: default ( )
16
16
}
17
+
18
+ /// Returns true if the tracing span provided by this service should be included in the log output.
19
+ /// The span is enabled by default,
20
+ /// but can be disabled by adding `no-span` to the `AWS_LAMBDA_LOG_FORMAT` environment variable.
21
+ /// E.g. AWS_LAMBDA_LOG_FORMAT=no-span or =json,no-span.
22
+ pub fn is_enabled ( ) -> bool {
23
+ !matches ! ( std:: env:: var( "AWS_LAMBDA_LOG_FORMAT" ) , Ok ( v) if v. to_lowercase( ) . contains( "no-span" ) )
24
+ }
17
25
}
18
26
19
27
impl < S > Layer < S > for TracingLayer {
Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ where
120
120
D : Into < bytes:: Bytes > + Send ,
121
121
E : Into < Error > + Send + Debug ,
122
122
{
123
- let runtime = Runtime :: new ( handler) . layer ( layers:: TracingLayer :: new ( ) ) ;
124
- runtime. run ( ) . await
123
+ if layers:: TracingLayer :: is_enabled ( ) {
124
+ let runtime = Runtime :: new ( handler) . layer ( layers:: TracingLayer :: new ( ) ) ;
125
+ runtime. run ( ) . await
126
+ } else {
127
+ let runtime = Runtime :: new ( handler) ;
128
+ runtime. run ( ) . await
129
+ }
125
130
}
You can’t perform that action at this time.
0 commit comments