Skip to main content

Python DSL for setting up Flask app CDC

Project description

This is a helper module to allow you to capture all the request/response which comes to your Flask app.

pip install aws_ssm-devlibx

How to use

from flask_cdc import cdc

# We expect you already have the flask app 
app = "Existing flask"


# Recorder is called everytime you get request response. You can do anything you want
# In this example we have logged data with a helper function provided by cdc. You can change
# this method to do anything else
def recorder(state):
    cdc.log_results(state)


# Wrap app to your session record MW    
app.wsgi_app = cdc.SessionRecorderMiddleware(app.wsgi_app, recorder)

How to enable CDC

Set following env variable:
export CDC_KAFKA=<your kafka broker>
export CDC_TOPIC=<your kafka topic for CDC>

You can use the pre-defined recorder to send data to kafka:

app.wsgi_app = cdc.SessionRecorderMiddleware(app.wsgi_app, cdc.publish_result_to_kafka)

Once it is defined then you can see the following data in your topic

{
  "request": {
    "body": {
      "archive_existing_versions": true,
      "name": "harish",
      "stage": "Staging",
      "version": "2"
    },
    "method": "POST",
    "url": "/ajax-api/2.0/preview/mlflow/model-versions/transition-stage"
  },
  "response": {
    "status": "200 OK"
  }
}

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

aws-ssm-devlibx-0.0.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

aws_ssm_devlibx-0.0.3-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file aws-ssm-devlibx-0.0.3.tar.gz.

File metadata

  • Download URL: aws-ssm-devlibx-0.0.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for aws-ssm-devlibx-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9ae2aff19c7b75b226bdb16f630974e30d9e2103c55b41b866156cb567444983
MD5 7e3f8985042efaec025ee21833f312ab
BLAKE2b-256 9736e91f4ea1f8de02914c80b1839bc5c544967ce720046769f72f5909e56aac

See more details on using hashes here.

File details

Details for the file aws_ssm_devlibx-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_ssm_devlibx-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 367291fe1d909c6a02a2c664309cafdc0e51ea70db525a351ce83e1144877f02
MD5 f358024f52cea745bd8ed1ee7b43145c
BLAKE2b-256 9688f6fc65987c52c8dbb13a3b3fcb342a62afbe4ff8a681e8797e1dbd76a31b

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