File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
src/AWS.Lambda.Powertools.Tracing/Internal
tests/AWS.Lambda.Powertools.Tracing.Tests Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -242,9 +242,6 @@ private bool TracingDisabled()
242
242
/// <returns><c>true</c> if tracing should capture responses, <c>false</c> otherwise.</returns>
243
243
private bool CaptureResponse ( )
244
244
{
245
- if ( TracingDisabled ( ) )
246
- return false ;
247
-
248
245
switch ( _captureMode )
249
246
{
250
247
case TracingCaptureMode . EnvironmentVariable :
Original file line number Diff line number Diff line change @@ -542,6 +542,29 @@ public void OnException_WhenTracerCaptureModeIsError_CapturesError_Inner_Excepti
542
542
Assert . NotNull ( exception . InnerException ) ;
543
543
Assert . Equal ( "Inner Exception!!" , exception . InnerException . Message ) ;
544
544
}
545
+
546
+ [ Fact ]
547
+ public void OnException_When_Tracing_Disabled_Does_Not_CapturesError ( )
548
+ {
549
+ // Arrange
550
+ Environment . SetEnvironmentVariable ( "LAMBDA_TASK_ROOT" , "AWS" ) ;
551
+ Environment . SetEnvironmentVariable ( "POWERTOOLS_SERVICE_NAME" , "POWERTOOLS" ) ;
552
+ Environment . SetEnvironmentVariable ( "POWERTOOLS_TRACE_DISABLED" , "true" ) ;
553
+
554
+ // Act
555
+ var segment = AWSXRayRecorder . Instance . TraceContext . GetEntity ( ) ;
556
+
557
+ var exception = Record . Exception ( ( ) =>
558
+ {
559
+ _handler . HandleWithCaptureModeError ( true ) ;
560
+ } ) ;
561
+
562
+ // Assert
563
+ Assert . NotNull ( exception ) ;
564
+ Assert . False ( segment . IsSubsegmentsAdded ) ;
565
+ Assert . Empty ( segment . Subsegments ) ;
566
+ Assert . False ( segment . IsMetadataAdded ) ;
567
+ }
545
568
546
569
[ Fact ]
547
570
public void OnException_WhenTracerCaptureModeIsResponseAndError_CapturesError ( )
You can’t perform that action at this time.
0 commit comments