Inspector
BlogTry for free
  • Concepts
    • Introduction
    • Metrics
    • Notification Channels
      • Email
      • Slack
      • Telegram
      • Microsoft Teams
      • Google Chat
      • Webhook
      • Discord
      • Pushover
      • PagerDuty
      • Twilio - SMS
    • Filtering Syntax
    • Alerts
    • Grouping Patterns
    • Custom Segments
    • Billing
    • AI Bug Fixer
  • Security and access
    • Access control
    • Two-factor authentication
    • Connected Devices
  • SDK
    • PHP
      • Installation & Set Up
      • Custom Segments
      • Exceptions Monitoring
      • Configuration
    • Laravel / Lumen
      • Upgrade Guide
      • Installation & Set-up
      • Http Requests Monitoring
      • Configuration
      • Exception Monitoring
      • Laravel Vapor
      • Laravel Octane
      • Laravel Nova Tool
      • Group by service name
    • Symfony
      • Installation
      • Configuration
      • Exception Monitoring
    • CodeIgniter
      • Installation
      • Configuration
      • Exception Monitoring
    • Drupal
    • Spring Boot
    • Slim
    • NodeJS
      • Configurations
      • Custom Segments
      • Exception monitoring
      • Autowiring
    • ExpressJs
    • Fastify
    • Python
    • Django
      • Installation & Set Up
      • Custom Segments
      • Error Monitoring
  • REST API
    • Authentication
    • Apps
    • Platforms
    • Transactions
    • Segments
    • Analytics
Powered by GitBook
On this page
  • Requirements
  • Install
  • Configure the Ingestion Key
  • Activate the module
  • Register the middleware
  • Ignore URLs
  • Custom ignore logic
  1. SDK
  2. Django

Installation & Set Up

Connect your Django application to Inspector

PreviousDjangoNextCustom Segments

Last updated 2 years ago

Requirements

  • Python >= 3.x

  • Django >= 3.x

Install

Install the latest version of the package from :

pip install inspector-django

Configure the Ingestion Key

In settings.py add the ingestion key of your project:

INSPECTOR_INGESTION_KEY = "xxxxxxxxx"

Get a new Ingestion Key

You can get a new key creating a new project in your .

Activate the module

Add inspector_django to installed apps:

INSTALLED_APPS = [
    ....,
 	
    'inspector_django',
]

Register the middleware

To monitor the incoming HTTP traffic you need to register the middleware.

In order to start the transaction as soon as possible, we suggest adding the middleware to the top of the list:

MIDDLEWARE = [
    'inspector_django.InspectorMiddleware',
	
    ....
]

Ignore URLs

It could be needed to exclude some parts of your application from your monitoring data. It could be something that doesn't impact your user experience, or if you prefer to focus your attention on a small part of your system.

The INSPECTOR_IGNORE_URL also support wildcards:

INSPECTOR_IGNORE_URL = [
     'static*',
     'media*'
     'assets*',
     'js*',
     'css*',
]

This is the default array. You have to copy this property in your settings.py file and then add your custom entries.

Custom ignore logic

The InspectorMiddleware class provides a simple hook to implement a cusom logic to determine if the current request should be reported or not.

You can extend the original middleware and override the shouldRecorded method:

class MonitoringMiddleware(InspectorMiddleware):
    def should_recorded(self, request):
        return True

Remeber to register this new middleware instead of the original InspectorMiddleware:

MIDDLEWARE = [
    # 'inspector_django.InspectorMiddleware',
    'your_app.path.MonitoringMiddleware',
	
    ....
]
PyPI
Inspector dashboard