def main() -> None: """Run administrative tasks.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangogirls.ettings") DjangoInstrumentor().instrument() try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?") from exc execute_from_command_line(sys.argv)
def main(): # This call is what makes the Django application be instrumented DjangoInstrumentor().instrument() os.environ.setdefault("DJANGO_SETTINGS_MODULE", "instrumentation_example.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?") from exc execute_from_command_line(sys.argv)
}, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' DjangoInstrumentor().instrument()
async_traced, async_traced_template, ) DJANGO_3_1 = VERSION >= (3, 1) urlpatterns = [ re_path(r"^traced/", async_traced), re_path(r"^route/(?P<year>[0-9]{4})/template/$", async_traced_template), re_path(r"^error/", async_error), re_path(r"^excluded_arg/", async_excluded), re_path(r"^excluded_noarg/", async_excluded_noarg), re_path(r"^excluded_noarg2/", async_excluded_noarg2), re_path(r"^span_name/([0-9]{4})/$", async_route_span_name), ] _django_instrumentor = DjangoInstrumentor() @pytest.mark.skipif(not DJANGO_3_1, reason="AsyncClient implemented since Django 3.1") class TestMiddlewareAsgi(SimpleTestCase, TestBase): @classmethod def setUpClass(cls): conf.settings.configure(ROOT_URLCONF=modules[__name__]) super().setUpClass() def setUp(self): super().setUp() setup_test_environment() _django_instrumentor.instrument() self.env_patch = patch.dict(
def instrument(self): """configure django instrumentor w hooks""" DjangoInstrumentor().instrument(request_hook=self.request_hook, response_hook=self.response_hook)
def instrumentDjango(): from opentelemetry.instrumentation.django import DjangoInstrumentor DjangoInstrumentor().instrument()