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 1000, 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.0.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.0-py2.py3-none-any.whl (10.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: ironleapdjango-1.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 3c7c3381f40f6e3cca6383ad53db8d16f1fe874a39a91001eb33e9548086ddd2
MD5 5f8511524d3632c17385474c850d1251
BLAKE2b-256 bb2cff8ddf9936c45c58576d43b2520f5ef538f69f21fd37d40e43b64977af27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ironleapdjango-1.1.0-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.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 44256c662264482241ae7f8b4d14ccdea65293815c97b9b4966daf233a327072
MD5 4d6c5193c3c219b5000b0ea7a9c8af98
BLAKE2b-256 341c2a8b1cacce9ac6ce970393f729b33e6dca51c19a8bcbf12a193b6e33d57e

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