Skip to content

Instantly share code, notes, and snippets.

View dkuebric's full-sized avatar

Dan Kuebrich dkuebric

View GitHub Profile
@dkuebric
dkuebric / client.py
Created January 22, 2016 18:19
AppNeta TraceView - Tracing Example - ZeroMQ Client
import oboe
import pickle
import time
import zmq
def instrumented_rpc(socket, message):
""" Example instrumented RPC method."""
keys = {'IsService': True, 'RemoteURL': 'tcp://localhost:5556'}
oboe.log_entry('RPC-Client', keys=keys)
@dkuebric
dkuebric / server.py
Created January 22, 2016 18:19
AppNeta TraceView - Tracing Example - ZeroMQ Server
import oboe
import pickle
import time
import zmq
def run_server():
print('Distributed tracing server: receive request, sleep, reply')
zmq_context = zmq.Context()
socket = zmq_context.socket(zmq.REP)
@dkuebric
dkuebric / example2.java
Created May 21, 2015 01:43
Java API Example 2: Starting a trace
// Sample for a trace in the queue consumer
TraceEvent event = Trace.startTrace("BackendWorkerName");
// Because TraceView's UI like web applications, we'll use HTTP server KV pairs to leverage the UI fully
// source: https://docs.appneta.com/extending-traceview-customizing
event.addInfo("HTTP-Host", QUEUE_WORKER_HOSTNAME);
event.addInfo("URL", QUEUE_WORKER_HOSTNAME + "/" + TASK_NAME); // example for if there is a specific task type you'd like to segment on
// optional: use other KVs Controller, Action, Status, and Method to convey other data for the UI
event.report();
@dkuebric
dkuebric / example.java
Created May 21, 2015 01:37
TraceView Java API Example
// Create an entry event
TraceEvent event = Trace.createEntryEvent("ActiveMQ");
// Add a little data to give it special treatment in the UI, per https://docs.appneta.com/extending-traceview-customizing specs
event.addInfo("IsService", true);
event.addInfo("RemoteHost", QUEUE_HOST);
event.addInfo("RemoteProtocol", "AMQP"); // or similar
event.addInfo("RemoteController", QUEUE_NAME); // this is best with low cardinality of unique queues names; if there are a lot of queues, you may want to instead use a class of queue here
// report the event
@dkuebric
dkuebric / gist:145dc1b8638d5d574cbf
Created July 30, 2014 04:55
blotto zombies weighted
dan@ponderous:~/code/blotto $ git diff
diff --git a/blotto.c b/blotto.c
index e900988..41ec57c 100644
--- a/blotto.c
+++ b/blotto.c
@@ -196,8 +196,19 @@ int main(int argc, char **argv) {
/* fight! */
for(i = 0; i < battlefields; i++) {
- if(player[p1].soldiers[i] > player[p2].soldiers[i]) score++;
dan@ponderous:~/code/blotto $ time ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5
Pos Name W D L Pts Soldiers
1 team1 9999 0 0 19998 12 13 7 7 5 13 9 11 16 7
2 team2 9998 0 1 19996 9 16 11 16 7 8 13 2 7 11
3 team3 9997 0 2 19994 17 10 12 13 6 9 9 5 8 11
4 team4 9996 0 3 19992 11 9 8 13 10 8 8 13 8 12
real 0m3.111s
user 0m3.117s
sys 0m0.011s
dan@ponderous:~/code/blotto $ time ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5
Pos Name W D L Pts Soldiers
1 team6326 7404 1766 829 16574 7 14 2 13 11 13 12 12 14 2
2 team8345 6667 2033 1299 15367 11 2 12 12 7 12 10 11 11 12
3 team202 6671 2015 1313 15357 10 12 12 11 11 4 14 12 3 11
4 team6897 6534 2073 1392 15141 13 3 5 11 12 11 12 11 10 12
real 0m2.844s
user 0m2.842s
sys 0m0.010s
https://support.tv.appneta.com/solution/categories/89579/folders/146748/articles/installation-overview via https://support.tv.appneta.com/solution/categories/89579/folders/146748/articles/86362-installing-base-packages-on-redhat-and-centos
https://support.tv.appneta.com/support/solutions/articles/configuring-java-instrumentation via https://support.tv.appneta.com/support/solutions/articles/113899-installing-java-instrumentation-on
https://support.tv.appneta.com/support/solutions/articles/java-instrumentation-support-matrix via https://support.tv.appneta.com/support/solutions/articles/113899-installing-java-instrumentation-on
https://support.tv.appneta.com/support/solutions/articles/java-custom-layers-and-profiling via https://support.tv.appneta.com/support/solutions/articles/113899-installing-java-instrumentation-on
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=534978 via https://support.tv.appneta.com/support/solutions/articles/86332-time-granularity-and-vm-slash-cloud
http://www.archived-mails.
@dkuebric
dkuebric / solarium patch.php
Last active December 19, 2015 01:48
quick patch to provide tracing coverage to Solarium
<?php
public function execute($request, $endpoint)
{
if (is_callable('oboe_log')) {
oboe_log('Solarium', 'entry', array('IsService'=>'1'));
}
$client = $this->getZendHttp();
$client->resetParameters();
@dkuebric
dkuebric / trace.py
Created May 13, 2013 18:49
starting tracing in python code
import oboe
from oboeware import loader
# load monkey-patched instrumentation for supported modules
loader.load_inst_modules()
# say this is the entry point for your mod_python code
def handle_request(headers, **other_stuff):
# start a trace based on incoming X-Trace HTTP header from Apache/nginx if available
oboe.start_trace('mod_python', xtr=headers['X-Trace'])