Example #1
0
def makeService(config):
    s = MultiService()

    # ZipkinTracer(
    #     scribe_client,
    #     category=None,
    #     end_annotations=None,
    #     max_traces=50,
    #     max_idle_time=10,
    #     _reactor=None)
    push_tracer(
        ZipkinTracer(ScribeClient(clientFromString(reactor, config['scribe'])),
                     'zipkin', None, 10, 10, None))

    root = RootResource()

    # if config['rproxy']:
    #     root = RProxyWrapper(root)

    site = server.Site(root)
    site.displayTracebacks = False

    api_service = strports.service(config['port'], site)
    api_service.setServiceParent(s)

    return s
Example #2
0
def makeService(config):
    s = MultiService()


    # ZipkinTracer(
    #     scribe_client,
    #     category=None,
    #     end_annotations=None,
    #     max_traces=50,
    #     max_idle_time=10,
    #     _reactor=None)
    push_tracer(
        ZipkinTracer(
            ScribeClient(clientFromString(reactor, config['scribe'])), 'zipkin', None, 10, 10, None))

    root = RootResource()

    # if config['rproxy']:
    #     root = RProxyWrapper(root)

    site = server.Site(root)
    site.displayTracebacks = False

    api_service = strports.service(config['port'], site)
    api_service.setServiceParent(s)

    return s
Example #3
0
 def prepare(self):
     if options.enable_trace:
         push_tracer(EndAnnotationTracer(
                 RESTkinHTTPTracer(Agent(reactor),
                         trace_url='http://localhost:6956/v1.0/22/trace', 
                         max_traces=1,
                         max_idle_time=0)))
     
     super(FallbackHandler, self).prepare()
Example #4
0
    def test_push_tracer(self):
        dummy_tracer = object()
        dummy_tracer2 = object()

        push_tracer(dummy_tracer)
        self.assertEqual(get_tracers(), [dummy_tracer])

        push_tracer(dummy_tracer2)

        self.assertEqual(get_tracers(), [dummy_tracer, dummy_tracer2])
Example #5
0
    def test_push_tracer(self):
        dummy_tracer = object()
        dummy_tracer2 = object()

        push_tracer(dummy_tracer)
        self.assertEqual(get_tracers(), [dummy_tracer])

        push_tracer(dummy_tracer2)

        self.assertEqual(get_tracers(), [dummy_tracer, dummy_tracer2])
Example #6
0
def makeService(config):
    s = MultiService()

    push_tracer(
        ZipkinTracer(
            ScribeClient(
                clientFromString(reactor, config['scribe']))))

    root = RootResource()

    if config['rproxy']:
        root = RProxyWrapper(root)

    site = server.Site(root)
    site.displayTracebacks = False

    api_service = strports.service(config['port'], site)
    api_service.setServiceParent(s)

    return s
Example #7
0
def makeService(config):
    s = MultiService()

    scribe_client = ScribeClient(clientFromString(reactor, config['scribe']))
    if len(config['trace'].split(':')) == 2 :
        max_traces, max_idle_time = config['trace'].split(':')
    else:
        print "error in trace parameters"
        exit()

    # ZipkinTracer(
    #     scribe_client,
    #     category=None,
    #     end_annotations=None,
    #     max_traces=50,
    #     max_idle_time=10,
    #     _reactor=None)

    push_tracer(
        ZipkinTracer(
            scribe_client, 'zipkin', None, int(max_traces), int(max_idle_time), None
        )
    )

    root = RootResource()

    # if config['rproxy']:
    #     root = RProxyWrapper(root)

    site = server.Site(root)
    site.displayTracebacks = False

    api_service = strports.service(config['port'], site)
    api_service.setServiceParent(s)

    return s
from tryfer.trace import Endpoint

from tryfer.http import TracingAgent


if __name__ == '__main__':
    # Set up twisted's logging.
    log.startLogging(sys.stdout)

    # Set up our RESTkinHTTPTracer to send JSON to a RESTkin instance
    # If you're not running RESTkin locally (defaults to 6956), change
    # the URL to https://trace.k1k.me/v1.0/22/trace .... and add authentication
    # with the python twisted keystone agent
    # https://github.com/racker/python-twisted-keystone-agent
    push_tracer(EndAnnotationTracer(
                    RESTkinHTTPTracer(Agent(reactor),
                                      'http://localhost:6956/v1.0/22/trace',
                                      max_idle_time=0)))

    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        # to used with zipkin ui, endpoint must be set
        endpoint = Endpoint(ipv4='127.0.0.1', port=1582, service_name="tryfer-example")
        a = TracingAgent(Agent(reactor), endpoint=endpoint)
        d = a.request('GET', 'http://google.com')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
Example #9
0
import sys

from twisted.internet import reactor
from twisted.web.client import Agent
from twisted.python import log
from tryfer.tracers import push_tracer, DebugTracer, EndAnnotationTracer

from tryfer.http import TracingAgent


if __name__ == '__main__':
    # Set up twisted's logging.
    log.startLogging(sys.stdout)

    # Set up our DebugTracer to print json to stdout.
    push_tracer(EndAnnotationTracer(DebugTracer(sys.stdout)))

    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        a = TracingAgent(Agent(reactor))
        d = a.request('GET', 'http://localhost:8080/README.rst')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
        d.addBoth(lambda _: reactor.callLater(1, reactor.stop))

    reactor.callLater(1, _do)
Example #10
0
from tryfer.trace import Endpoint

from tryfer.http import TracingAgent

if __name__ == '__main__':
    # Set up twisted's logging.
    log.startLogging(sys.stdout)

    # Set up our RESTkinHTTPTracer to send JSON to a RESTkin instance
    # If you're not running RESTkin locally (defaults to 6956), change
    # the URL to https://trace.k1k.me/v1.0/22/trace .... and add authentication
    # with the python twisted keystone agent
    # https://github.com/racker/python-twisted-keystone-agent
    push_tracer(
        EndAnnotationTracer(
            RESTkinHTTPTracer(Agent(reactor),
                              'http://localhost:6956/v1.0/22/trace',
                              max_idle_time=0)))

    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        # to used with zipkin ui, endpoint must be set
        endpoint = Endpoint(ipv4='127.0.0.1',
                            port=1582,
                            service_name="tryfer-example")
        a = TracingAgent(Agent(reactor), endpoint=endpoint)
        d = a.request('GET', 'http://google.com')

        # Print the response code when receive the response.
Example #11
0
from twisted.web.client import Agent
from twisted.python import log
from tryfer.tracers import push_tracer, RawZipkinTracer, ZipkinTracer, DebugTracer, EndAnnotationTracer

from tryfer.http import TracingAgent
from twisted.internet.endpoints import TCP4ClientEndpoint
from scrivener import ScribeClient


if __name__ == '__main__':
    # Set up twisted's logging.
    log.startLogging(sys.stdout)

    # Set up our DebugTracer to print json to stdout.
    client = ScribeClient(TCP4ClientEndpoint(reactor, '127.0.0.1', 9410))
    push_tracer(EndAnnotationTracer(ZipkinTracer(client)))

    def _do():
        # The Agent API is composable so we wrap an Agent in a TracingAgent
        # and every call to TracingAgent.request will result in a client_send,
        # client_receive, and http.uri annotations.
        a = TracingAgent(Agent(reactor))
        d = a.request('GET', 'http://localhost:8088/README.rst')

        # Print the response code when receive the response.
        d.addCallback(lambda r: print("Received {0} response.".format(r.code)))

        # stop the reactor.
        d.addBoth(lambda _: reactor.callLater(1, reactor.stop))

    reactor.callLater(1, _do)