diff --git a/aws_xray_sdk/ext/django/apps.py b/aws_xray_sdk/ext/django/apps.py index 1abf72ee..c582a09f 100644 --- a/aws_xray_sdk/ext/django/apps.py +++ b/aws_xray_sdk/ext/django/apps.py @@ -30,6 +30,7 @@ def ready(self): daemon_address=settings.AWS_XRAY_DAEMON_ADDRESS, sampling=settings.SAMPLING, sampling_rules=settings.SAMPLING_RULES, + sampler=settings.SAMPLER, context_missing=settings.AWS_XRAY_CONTEXT_MISSING, plugins=settings.PLUGINS, service=settings.AWS_XRAY_TRACING_NAME, diff --git a/aws_xray_sdk/ext/django/conf.py b/aws_xray_sdk/ext/django/conf.py index 6313ab3c..a1b51c0a 100644 --- a/aws_xray_sdk/ext/django/conf.py +++ b/aws_xray_sdk/ext/django/conf.py @@ -10,6 +10,7 @@ 'PLUGINS': (), 'SAMPLING': True, 'SAMPLING_RULES': None, + 'SAMPLER': None, 'AWS_XRAY_TRACING_NAME': None, 'DYNAMIC_NAMING': None, 'STREAMING_THRESHOLD': None, diff --git a/tests/ext/django/app/settings.py b/tests/ext/django/app/settings.py index 3d33737d..6b1ff137 100644 --- a/tests/ext/django/app/settings.py +++ b/tests/ext/django/app/settings.py @@ -2,6 +2,7 @@ Config file for a django app used by django testing client """ import os +from aws_xray_sdk.core.sampling.sampler import LocalSampler BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -60,6 +61,7 @@ XRAY_RECORDER = { 'AWS_XRAY_TRACING_NAME': 'django', 'SAMPLING': False, + 'SAMPLER': LocalSampler(), } LANGUAGE_CODE = 'en-us' diff --git a/tests/ext/django/test_settings.py b/tests/ext/django/test_settings.py new file mode 100644 index 00000000..94870fd7 --- /dev/null +++ b/tests/ext/django/test_settings.py @@ -0,0 +1,16 @@ +from unittest import mock + +import django +from aws_xray_sdk import global_sdk_config +from django.test import TestCase, override_settings +from django.conf import settings +from django.apps import apps + +from aws_xray_sdk.core import xray_recorder +from aws_xray_sdk.core.sampling.sampler import LocalSampler + + +class XRayConfigurationTestCase(TestCase): + def test_sampler_can_be_configured(self): + assert isinstance(settings.XRAY_RECORDER['SAMPLER'], LocalSampler) + assert isinstance(xray_recorder.sampler, LocalSampler) \ No newline at end of file