Skip to content

Commit 59711be

Browse files
committed
Added the option to ignore missing segments
1 parent 8a82e4b commit 59711be

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

aws_xray_sdk/core/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
log = logging.getLogger(__name__)
1111

1212
MISSING_SEGMENT_MSG = 'cannot find the current segment/subsegment, please make sure you have a segment open'
13-
SUPPORTED_CONTEXT_MISSING = ('RUNTIME_ERROR', 'LOG_ERROR')
13+
SUPPORTED_CONTEXT_MISSING = ('RUNTIME_ERROR', 'LOG_ERROR', 'IGNORE')
1414
CXT_MISSING_STRATEGY_KEY = 'AWS_XRAY_CONTEXT_MISSING'
1515

1616

@@ -121,7 +121,7 @@ def handle_context_missing(self):
121121
"""
122122
if self.context_missing == 'RUNTIME_ERROR':
123123
raise SegmentNotFoundException(MISSING_SEGMENT_MSG)
124-
else:
124+
elif self.context_missing == 'LOG_ERROR':
125125
log.error(MISSING_SEGMENT_MSG)
126126

127127
def _is_subsegment(self, entity):

aws_xray_sdk/core/recorder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def configure(self, sampling=None, plugins=None,
112112
RUNTIME_ERROR means the recorder will raise an exception.
113113
LOG_ERROR means the recorder will only log the error and
114114
do nothing.
115+
IGNORE means the recorder will do nothing
115116
:param str daemon_address: The X-Ray daemon address where the recorder
116117
sends data to.
117118
:param str service: default segment name if creating a segment without

docs/configurations.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Supported strategies are:
9292

9393
* RUNTIME_ERROR: throw an SegmentNotFoundException
9494
* LOG_ERROR: log an error and continue
95+
* IGNORE: will do nothing
9596

9697
Segment Dynamic Naming
9798
----------------------

0 commit comments

Comments
 (0)