Skip to main content

API service for SWAG data

Project description

swag-api

Build Status

codecov

OSS Status

This is the API for the swag-client account metadata service.

Quickstart

Frontend

  • Change directories to the static directory and run npm install
  • npm start

Backend

  • pip install -e .
  • swag-api run

Metrics Plugins

To create a custom metrics plugin, you will need to do the following:

  1. Create the following directory structure under swag_api/plugins/metrics:

    swag_api/plugins/metrics/
        ├── ...
        └── your_plugin_here
            ├── __init__.py
            └── module.py
    
  2. A sample plugin is provided in swag_api/plugins/metrics/sample. You can enable the sample plugin by setting the Flask configuration ENABLE_SAMPLE_METRICS_PLUGIN set to True.

  3. In your module.py you will need to write your plugin to subclass the MetricsPlugin found in swag_api/plugins/metrics/__init__.py.

    The base class has 2 functions that you need to overwrite: send_counter_metric, and send_latency_metric. The counter_metric is a metric for counting how many times an API is hit. The latency_metric is used to gauge the total time it takes to process a given API call.

  4. Once you have implemented the module.py, in your package's __init__.py, you will need to import your plugin as MetricsPlugin. See the sample plugin's __init__.py for an example.

  5. You can have multiple metrics plugins enabled should you want! swag-api will look for them on startup and initialize them. Feel free to add any initialization code you need in your class's __init__().

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

swag-api-0.0.1.tar.gz (18.2 kB view details)

Uploaded Source

File details

Details for the file swag-api-0.0.1.tar.gz.

File metadata

  • Download URL: swag-api-0.0.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5

File hashes

Hashes for swag-api-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e0090f52142df6c2aab00dc3b741a16666f3017b945b9cd427b5eea902096112
MD5 ae26b731ef88dde3e65f75bc4d6c109a
BLAKE2b-256 40ddab4f07c7453e0fe753e2bf0c94945d0f3f5b1143e2e30a6851166e97ac7f

See more details on using hashes here.

Supported by

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