Skip to content

Instantly share code, notes, and snippets.

@davidmlentz
Created April 9, 2018 16:35
Show Gist options
  • Save davidmlentz/c93986bd53a08960e597a7b4eb4294f1 to your computer and use it in GitHub Desktop.
Save davidmlentz/c93986bd53a08960e597a7b4eb4294f1 to your computer and use it in GitHub Desktop.
# Adapted from http://webpy.org/docs/0.3/tutorial
import redis, random, web
urls = (
'/', 'index'
)
from ddtrace import patch, Pin
# Patch the Redis library to automatically enable tracing:
patch(redis=True)
class index:
def GET(self):
client = redis.StrictRedis(host="127.0.0.1", port=6379)
# Give this service a name and a tag:
Pin.override(client, service='myredis', app_type='test', tags={'env':'myenv'})
client.set('randomnumber', random.randint(1,9999))
# Send a response with some content:
return str(client.get('randomnumber'))
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment