Skip to main content

ReadMe API Metrics WSGI SDK

Project description

readme-metrics

Track your API metrics within ReadMe.

PyPi Build

Installation

pip install readme-metrics

Usage

Just include the MetricsMiddleware into your API!

from readme_metrics import MetricsApiConfig, MetricsMiddleware

app = Flask(__name__)

app.wsgi_app = MetricsMiddleware(
    app.wsgi_app,
    MetricsApiConfig(
        README_API_KEY,
        lambda req: {
            'id': 'unique id of user making call',
            'label': 'label for us to show for this user (ie email, project name, user name, etc)',
            'email': 'email address for user'
        },
    )
)

Configuration Options

There are a few options you can pass in to change how the logs are sent to ReadMe. These can be passed in MetricsApiConfig.

Ex)

MetricsApiConfig(
    README_API_KEY,
    lambda req: {
        'id': 'unique id of user making call',
        'label': 'label for us to show for this user (ie email, project name, user name, etc)',
        'email': 'email address for user'
    },
    buffer_length=1,
    blacklist=['credit_card'] # Prevents credit_card in the request from being sent to readme
)
Option Use
development_mode default: false If true, the log will be separate from normal production logs. This is great for separating staging or test data from data coming from customers
blacklist optional An array of keys from your API requests and responses headers and bodies that you wish to blacklist from sending to ReadMe.

If you configure a blacklist, it will override any whitelist configuration.
whitelist optional An array of keys from your API requests and responses headers and bodies that you only wish to send to ReadMe.
buffer_length default: 10 Sets the number of API calls that should be recieved before the requests are sent to ReadMe
allowed_http_hosts A list of allowed http hosts for sending data to the ReadMe API.

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

readme-metrics-1.0.5.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distribution

readme_metrics-1.0.5-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

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