Skip to main content

No project description provided

Project description

Vigil - SDK

SDK for API monitoring, Job monitoring and Error monitoring.

Installation

pip

pip install -i https://test.pypi.org/simple/ foxsenseinnovations.vigil

Usage

Django Application:

Declare the below statements in main application view file

# import Vigil to initialize the API KEY
from foxsenseinnovations.vigil import Vigil
from foxsenseinnovations.vigil.vigil_types.vigil_options_types import VigilOptions

# Define API_KEY (mandatory) , INSTANCE_URL (optional) and CLIENT_VERSION (optional) in settings.py file
# Access the API_KEY from settings.py file
api_key = django_settings.API_KEY

# Define the VigilOptions instance with the desired values
options = VigilOptions(api_key=api_key)

# Initialize the Vigil class with the provided options
Vigil.initialize(options)

Optional parameters for VigilOptions:
version and instance_url

# Access the INSTANCE_URL, CLIENT_VERSION from settings.py file
instance_url = django_settings.INSTANCE_URL
cient_version = django_settings.CLIENT_VERSION

# Initialize the Vigil class along with the optional parameters
options = VigilOptions(api_key=api_key, version=cient_version, instance_url=instance_url)

API Monitoring

Django Application:

Declare the below statements in settings file

from foxsenseinnovations.vigil.vigil_types.api_monitoring_types import ApiMonitoringOptions, ExcludeOptions

# In MIDDLEWARE of settings.py file add the below line
'foxsenseinnovations.vigil.api_manager_django.ApiMonitoringMiddleware'

Options

Options are not mandatory

Options Mandatory Default Values
exclude FALSE ExcludeOptions() ExcludeOptions(GET: [], POST: [], PATCH: [], DELETE: [])

Exclude

  • Excludes the given API path's for each method. These API are not monitored.

Django Application:

from foxsenseinnovations.vigil.vigil_types.api_monitoring_types import ApiMonitoringOptions, ExcludeOptions

# In MIDDLEWARE list of settings.py file add the below line
'foxsenseinnovations.vigil.api_manager_django.ApiMonitoringMiddleware'

# After MIDDLEWARE list add the below lines
exclude_options = ApiMonitoringOptions(exclude=ExcludeOptions(GET=['/'],POST=['/health']))

# '/' GET method and '/health' POST method APIs are not monitored
API_MONITORING_OPTIONS = exclude_options

Job Monitoring

Django Application:

# import JobManager to monitor the Jobs in the application
from foxsenseinnovations.vigil.job_manager import JobManager
from foxsenseinnovations.vigil.vigil_types.job_monitoring_types import JobDetail

# Job function
def job_func():
    try:
        // log that the job triggered with a start message
        start_job_detail = {'job_id': "<job-id>", 'message': "<job-start-message>"}
        JobManager.capture_job_start(JobDetail(**start_job_detail))
        ...
        ...
        // log that the job has completed its execution with a success message
        stop_job_detail = {'job_id': "<job-id>", 'message': "<job-end-message>"}
        JobManager.capture_job_end(JobDetail(**stop_job_detail))
    except Exception as error:
        fail_job_detail = {'job_id'="<job-id>", message=f"<job-failure-message>: {str(error)}"}
        JobManager.capture_job_failure(JobDetail(**fail_job_detail))

Error Monitoring

Django Application:

# import ErrorManager to capture any exceptions/errors that occur in the application
from foxsenseinnovations.vigil.error_manager import ErrorManager

def function():
    try:
        ...
        ...
    except Exception as error:
        // capture the exception from the error object
        ErrorManager.capture_exception(error)

Options

Options are not mandatory

Options Mandatory Default Values
tags FALSE [] Array of strings
context FALSE {} An object

Tags and Context

  • Gives extra information about the exception that occurred
# import ErrorManager to capture any exceptions/errors that occur in the application
from foxsenseinnovations.vigil.error_manager import ErrorManager

def function():
    try:
        ...
        ...
    except Exception as error:
        options = {
            tags: ['tag1','tag2'],
            context: {
                <key1>: <value1>,
                <key2>: <value2>
            }
        }
        // capture the exception from the error object
        // and pass extra information about the exception in options
        ErrorManager.capture_exception(error, options)

Keywords

none

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

foxsenseinnovations.vigil-1.0.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

foxsenseinnovations.vigil-1.0.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file foxsenseinnovations.vigil-1.0.0.tar.gz.

File metadata

File hashes

Hashes for foxsenseinnovations.vigil-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3f8ad7f4179209e3eb2a9c5c8e0fc8c89d67f16cc34c88b9164a7c9ae0aa99b9
MD5 beab68887d113772f13119f91dfd4349
BLAKE2b-256 50c4f141968006524ac4debb13c4ad78d5b327f3a65916734ce3aec6d5b265c2

See more details on using hashes here.

File details

Details for the file foxsenseinnovations.vigil-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for foxsenseinnovations.vigil-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9995b372bda344936e7788fb034d8e2e6c06c42b3817e771ddc47d42e105b49
MD5 1a2da215743c4e1f42fc6ba2d085d36c
BLAKE2b-256 d2689ea9a5ae894ec8c3495216e6a06673c492f1a84d26bc95317ba56f309cbb

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