Skip to content

ericofusco/swag-api

 
 

Repository files navigation

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__().

About

REST API and UI for SWAG data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 55.7%
  • JavaScript 42.7%
  • HTML 1.3%
  • CSS 0.3%