Skip to content

Instantly share code, notes, and snippets.

@alq666

alq666/gae.md Secret

Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alq666/56e6098916a84cb568cf to your computer and use it in GitHub Desktop.
Save alq666/56e6098916a84cb568cf to your computer and use it in GitHub Desktop.
Datadog on GAE

How to use Datadog on Google App Engine

Installation

We will use the dogapi module to instrument your code. There are a lot of ways to ship libraries to Google AppEngin using virtualenvs, symlinks, etc. If you already have that, just add to your stack the latest version of dogapi from PyPi.

If not, here is an easy way to use dogapi:

cd $MY_GAE_PROJECT
echo "dogapi" >> requirements.txt
pip install -r requirements.txt -t lib/

Then in your application initalization (appengine_config.py) make sure to the libraries to your Python path:

import sys
import os.path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))

Also the dogapi module sends metrics and events through a secure TLS connection, so you need to enable the ssl module in your app.yaml

libraries:
  - name: ssl
    version: "latest"

Instrumentation

  1. set your API key from datadog when initializing dogapi.
from dogapi import dog_stats_api as dog
dog.start(
    api_key=PUT_YOUR_API_KEY_HERE,
    flush_in_thread=False
)
  1. start sending your own metrics
@app.route('/datadog')
def datadog():
dog.increment('myapp.requests', tags=['controller:datadog'])
return 'Datadog'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment