Skip to content

Commit 3f016ce

Browse files
committed
Add settings variable to opt-in for import-time parent segment
1 parent f3f6f83 commit 3f016ce

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ XRAY_RECORDER = {
315315
...
316316
}
317317
```
318+
If `AUTO_PATCH_PARENT_SEGMENT_NAME` is also specified, then a segment parent will be created
319+
with the supplied name, wrapping the automatic patching so that it captures any dangling
320+
subsegments created on the import patching.
318321

319322
### Add Flask middleware
320323

aws_xray_sdk/ext/django/apps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def ready(self):
3939
)
4040

4141
if settings.PATCH_MODULES:
42-
with xray_recorder.in_segment('startup'):
42+
if settings.AUTO_PATCH_PARENT_SEGMENT_NAME is not None:
43+
with xray_recorder.in_segment(settings.AUTO_PATCH_PARENT_SEGMENT_NAME):
44+
patch(settings.PATCH_MODULES, ignore_module_patterns=settings.IGNORE_MODULE_PATTERNS)
45+
else:
4346
patch(settings.PATCH_MODULES, ignore_module_patterns=settings.IGNORE_MODULE_PATTERNS)
4447

4548
# if turned on subsegment will be generated on

aws_xray_sdk/ext/django/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'STREAMING_THRESHOLD': None,
1616
'MAX_TRACE_BACK': None,
1717
'PATCH_MODULES': [],
18+
'AUTO_PATCH_PARENT_SEGMENT_NAME': None,
1819
'IGNORE_MODULE_PATTERNS': [],
1920
}
2021

0 commit comments

Comments
 (0)