Skip to content

Instantly share code, notes, and snippets.

View dkuebric's full-sized avatar

Dan Kuebrich dkuebric

View GitHub Profile
@dkuebric
dkuebric / gist:1529242
Created December 28, 2011 19:16
multi-mechanize/reddit: forms, cookies, and comments
import mechanize
import urllib
BASE_URL = 'http://my-reddit'
THREAD = BASE_URL + '/r/reddit/particular-thread'
class Transaction(object):
def __init__(self):
self.user = 'redditor'
self.pass = 'password'
@dkuebric
dkuebric / gist:1649955
Created January 20, 2012 22:21
tracing arbitrary process
# init trace
evt = oboe.Context.startTrace()
evt.addInfo('Layer', func.__module__)
evt.addInfo('Label', 'entry')
evt.addInfo('HTTP-Host', socket.gethostname())
evt.addInfo('URL', '/%s/%s' % (func.__module__.replace('.', '/'), func.__name__))
evt.addInfo('Layer-Type', 'lang')
oboe.reporter().sendReport(evt)
try:
@dkuebric
dkuebric / gist:2589976
Created May 3, 2012 22:23
testing foresight
(venv)dan@dev1:~/code/oboe/test[master]$ cat !$
cat test_python.py
""" Tests for Python high-level API.
No stack needed!
"""
from test import TestWebInstrumentation
from udplisten import get_events, get_trace, get_events_and_response
import oboe
@dkuebric
dkuebric / gist:2590667
Created May 4, 2012 00:26
python worker tracing example
import oboe
from oboeware import loader
# load monkey-patched instrumentation for supported modules
loader.load_inst_modules()
# trace every unit of work done by decorated method
# (use fractional sample rate to trace a fraction of calls to decorated method)
oboe.config['tracing_mode'] = 'always'
oboe.config['sample_rate'] = 1.0
@dkuebric
dkuebric / gist:2931652
Created June 14, 2012 17:35
selenium test output
(venv)dan@dev1:~/code/tracelons/tracelytics/selenium[master]$ time SELENIUM_INI=../selenium-prod.ini SELENIUM_DOMAIN=tracelytics.com SELENIUM_CUSTOMER=internal ./run.py test_onboarding.py
Test load for step one. ... ok
Test load for welcome page. ... ok
Test load for step three. ... ok
Test load and ajax for onboarding step 1, no hosts. ... FAIL
Test load for step two. ... ok
Test load and ajax for onboarding step 2, no layers ... FAIL
Test load and ajax for onboarding step 2, with layers. ... FAIL
Test load and ajax for onboarding step 1, with hosts. ... FAIL
Test load and ajax for onboarding step 3, with fewer than 5 traces. ... FAIL
@dkuebric
dkuebric / gist:3019643
Created June 29, 2012 18:01
djangoware sampling patch diff
dan@ponderous:~/code/oboeware $ git diff
diff --git a/oboeware/djangoware.py b/oboeware/djangoware.py
index ae1d0aa..2c56c02 100644
--- a/oboeware/djangoware.py
+++ b/oboeware/djangoware.py
@@ -41,13 +41,15 @@ class OboeDjangoMiddleware(object):
def process_request(self, request):
import oboe
+ import random
@dkuebric
dkuebric / gist:3026788
Created July 1, 2012 04:09
leap second fix
$ date; sudo date `date +"%m%d%H%M%C%y.%S"`; date;
""" Tests for rails.
Setup and start information in rails3-stack/run.py.
"""
from test import TestWebInstrumentation
from udplisten import get_events, get_trace
class TestRails(TestWebInstrumentation):
def test_index(self):
import eventlet as e
import oboe
s = e.greenthread.spawn
s = oboe.log_method(s, 'spawn', entry_kvs={'Async': True}) # or possible None for layer
e.greenthread.spawn = s
@dkuebric
dkuebric / gist:3937272
Created October 23, 2012 06:43
iterate over n choose k
(venv)dan@dev1:~/$ python
Python 2.7.2 (default, Apr 20 2012, 16:27:51)
[GCC 4.6.1] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import itertools
>>> s = [1,2,3,4,5,6]
>>> combos = itertools.combinations(s, 3)
>>> for c in combos
... print c
...