Giter VIP home page Giter VIP logo

python-demo-app's Introduction

Python Demo App

A trivial Flask web app that can be used to demo performance monitoring features. The app has routes that do things like:

  1. Sleep in a way that draws a pretty response time graph.
  2. Raise uncaught exceptions in application code.
  3. Simulate slow database calls in MySQL and PostgreSQL.
  4. Make external HTTP calls.
  5. Return HTTP errors (5xx and 4xx).

NOTE: To use the AppDynamics Python Agent, you must have a compatible (4.0+) AppDynamics controller in SAAS or On Premise and a license provisioned for Python agents.

Installation

Python 2.6 or 2.7 are required. MacOS X and recent Linux distributions should have these preinstalled. Older Linux distributions (like CentOS 5) may come with a version of Python is too old, but you should be able to easily find packages for Python 2.7.

You must have pip and virtualenv installed. These may already be installed for you. If not, install pip with:

sudo easy_install pip

And then use pip to install virtualenv:

sudo pip install virtualenv

Create a virtualenv:

virtualenv env
env/bin/pip install -r requirements.txt

Install and configure MySQL and/or PostgreSQL. They both are configured in demo/config.py to be running on localhost with the default port, a user named test, with password test, and a database named test. There do not need to be any tables or anything in the test database.

The web server runs on port 9000.

To run the development server:

env/bin/python demo/app.py

To run in production:

env/bin/gunicorn -w 4 -b 0.0.0.0:9000 demo.app:app

Running with the agent

If your version of pip is older than 1.5, upgrade pip with:

pip install -U pip

Then install the agent into your virtualenv:

env/bin/pip install --pre appdynamics

Run the agent with the pyagent command and a configuration file (there's a sample configuration file included in this repository, appdynamics.cfg):

env/bin/pyagent run -c appdynamics.cfg - env/bin/gunicorn -w 4 -b 0.0.0.0:9000 demo.app:app

Generating load

Install siege through your package manager (yum install siege on Red Hat, apt-get install siege on Debian, or brew install siege on Mac). Edit the siege.txt (or copy it and edit the copy) and edit the variables defined at the top to specify the exit calls you wish to make, then run:

siege -d 1 -f siege.txt

Run with Docker

In Docker directory, add configuration value to CONTR_HOST, ACCOUNT_NAME, ACCESS_KEY, APP_NAME, TIER_NAME, NODE_NAME in startPython.sh.

Run docker with

./startPython.sh

HTTP Exit Call / Distributed Correlation Testing

The AppDynamics Python agent supports distributed correlation across tiers. The agent supports both being the originating tier and the continuing tier. To demonstrate this and test it out, you can use the /http endpoint to cause an HTTP exit call with a correlation header. This is useful for testing cross-tier correlation (as of 4.0.0, the Python agent does not support cross-app correlation). For example, if you have a .NET instrumented tier at 192.168.0.1, you can cause correlation by going to http://127.0.0.1/http?url=http://192.168.0.1/.

python-demo-app's People

Contributors

jmorgan415 avatar dkoepke avatar

Watchers

SahanaJSJ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.