Skip to main content

Iron Leap Django SDK

Project description

Django Middleware

Send Iron Leap API call data.

How to install

pip install ironleapdjango

How to use

In your settings.py file in your Django project directory, please add ironleap.middleware.ironleap_middleware to the MIDDLEWARE array. For example:

MIDDLEWARE = [
    ...
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'ironleapdjango.middleware.ironleap_middleware'
    ...
]

Configuration options

APP_KEY

(required), string, provided by Iron Leap.

IRONLEAP_URL

(required), string, target url collecting events

Options specific to incoming API calls

SKIP

(optional) (request, response) => boolean, a function that takes a request and a response, and returns true if you want to skip this particular event.

IDENTIFY_COMPANY

(optional) (request, response) => string, a function that takes a request and a response, and returns a string that is the company id for this event.

GET_METADATA

(optional) (request, response) => dictionary, getMetadata is a function that returns an object that allows you to add custom metadata that will be associated with the event. The metadata must be a dictionary that can be converted to JSON. For example, you may want to save a VM instance_id, a trace_id, or a tenant_id with the request.

LOG_BODY

(optional) boolean, default True, Set to False to remove the HTTP body before sending. If you want more control over which fields are included or not included look at the individual mask method below.

MASK_EVENT_MODEL

(optional) (APIEvent) => APIEvent, a function that takes an APIEvent and returns another APIEvent. Use this if you prefer to write your own mask function than use the string based filter options: REQUEST_BODY_MASKS, REQUEST_HEADER_MASKS, RESPONSE_BODY_MASKS, & RESPONSE_HEADER_MASKS.

BATCH_SIZE

(optional) int, default 25, Batch size with which events get sent to Iron Leap.

EVENT_QUEUE_SIZE

(optional) int, default 2500, Maximum number of events to hold in queue before sending.

BATCH_SEND_INTERVAL

(optional) int, default 2, Number of seconds between sends of batch.

Example

def identify_company(req, res):
    # Your custom code that returns a company id string
    return "67890"

def should_skip(req, res):
    # Your custom code that returns true to skip logging
    return "health/probe" in req.path

def mask_event(eventmodel):
    # Your custom code to change or remove any sensitive fields
    if 'password' in eventmodel.response.body:
        eventmodel.response.body['password'] = None
    return eventmodel

def get_metadata(req, res):
    return {
        'datacenter': 'westus',
        'deployment_version': 'v1.2.3',
    }


IRONLEAP_MIDDLEWARE = {
    'APP_KEY': 'app key',
    'IRONLEAP_URL': 'https://analytics.ironleap.io/api/collect'
    'DEBUG': False,
    'LOG_BODY': True,
    'IDENTIFY_COMPANY': identify_company,
    'SKIP': should_skip,
    'MASK_EVENT_MODEL': mask_event,
    'GET_METADATA': get_metadata,
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ironleapdjango-1.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ironleapdjango-1.1.1-py2.py3-none-any.whl (10.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ironleapdjango-1.1.1.tar.gz.

File metadata

  • Download URL: ironleapdjango-1.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for ironleapdjango-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f424e398f4683fd18c16b41f2e30c80d1292dcdc6db86bc72f1c9c2a86305389
MD5 96ecc186051494ac4eba3189b946b84b
BLAKE2b-256 170da984bd27f33c6d401a3915c5bb81f84b0ecbde4aff45ccc094756949cbc2

See more details on using hashes here.

File details

Details for the file ironleapdjango-1.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: ironleapdjango-1.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for ironleapdjango-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 69c394e42eac6886d4937ec7330f5bfd69855f68d3a489183149b62fc2d33f12
MD5 9d776f00d4a23af38ce8c8eda1afaf47
BLAKE2b-256 8e38fb8442c1eaeff2fb636d60ad32d4abfe067effee7357551d5dd17f7e2d8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page