Created
June 29, 2012 18:01
-
-
Save dkuebric/3019643 to your computer and use it in GitHub Desktop.
djangoware sampling patch diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
xtr_hdr = request.META.get("HTTP_X-Trace", request.META.get("HTTP_X_TRACE")) | |
tracing_mode = oboe.config.get('tracing_mode') | |
+ sample_rate = oboe.config.get('sample_rate') | |
if not oboe.Context.isValid() and xtr_hdr and tracing_mode in ['always', 'through']: | |
oboe.Context.fromString(xtr_hdr) | |
- if not oboe.Context.isValid() and tracing_mode == "always": | |
+ if not oboe.Context.isValid() and tracing_mode == "always" and random.random() < sample_rate: | |
evt = oboe.Context.startTrace() | |
elif oboe.Context.isValid() and tracing_mode != 'never': | |
evt = oboe.Context.createEvent() | |
dan@ponderous:~/code/oboeware $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment