Exemple #1
0
        def test():
            with async_tracer.start_active_span('test'):
                msg1 = asynqp.Message({'consume': 'this'})
                self.exchange.publish(msg1, 'routing.key')

                self.consumer = yield from self.queue.consume(handle_message)
                yield from asyncio.sleep(0.5)
Exemple #2
0
async def test():
    while True:
        await asyncio.sleep(2)
        with async_tracer.start_active_span('JobRunner'):
            async with aiohttp.ClientSession() as session:
                    # aioserver exposes /, /401, /500 & /publish (via asynqp)
                    async with session.get("http://localhost:5102/publish?secret=iloveyou") as response:
                        print(response.status)
        async def test():
            headers = {
                'X-INSTANA-SYNTHETIC': '1'
            }

            with async_tracer.start_active_span('test'):
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session, testenv["aiohttp_server"] + "/", headers=headers)
Exemple #4
0
        async def test():
            headers = {'X-Instana-Synthetic': '1'}

            with async_tracer.start_active_span('test'):
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session,
                                            testenv["tornado_server"] + "/",
                                            headers=headers)
Exemple #5
0
        async def test():
            with async_tracer.start_active_span('test'):
                async with aiohttp.ClientSession() as session:
                    # Hack together a manual custom headers list
                    agent.extra_headers = [u'X-Capture-This', u'X-Capture-That']

                    headers = dict()
                    headers['X-Capture-This'] = 'this'
                    headers['X-Capture-That'] = 'that'

                    return await self.fetch(session, testenv["tornado_server"] + "/?secret=iloveyou", headers=headers)
Exemple #6
0
        async def run_later(msg):
            # Extract the context from the message (if there is any)
            ctx = async_tracer.extract(opentracing.Format.HTTP_HEADERS, dict(msg.headers))

            # Start a new span to track work that is done processing this message
            with async_tracer.start_active_span("run_later", child_of=ctx) as scope:
                scope.span.set_tag("exchange", msg.exchange_name)
                # print("")
                # print("run_later active scope: %s" % async_tracer.scope_manager.active)
                # print("")
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session, testenv["wsgi_server"] + "/")
Exemple #7
0
        def test():
            @asyncio.coroutine
            def publish_a_bunch(msg):
                for _ in range(20):
                    self.exchange.publish(msg, 'routing.key')

            with async_tracer.start_active_span('test'):
                msg = asynqp.Message({'hello': 'world'})
                yield from publish_a_bunch(msg)

                for _ in range(10):
                    msg = yield from self.queue.get()
                    self.assertIsNotNone(msg)
async def launch_async_calls(parent_span):
    """
    Method to launch a series (1 currently) of asynchronous http calls
    using uvloop and aiohttp.  This method is run inside of an event loop
    with `asyncio.run`, `run_until_complete` or `gather`
    """

    # Now that we are inside of the event loop, first thing to do is to initialize
    # the tracing context using <parent_span> _and_ the asynchronous tracer <async_tracer>
    with async_tracer.start_active_span('launch_async_calls', child_of=parent_span):
        async with aiohttp.ClientSession() as session:
            session.get("http://127.0.0.1/api/v2/endpoint/1")
            session.get("http://127.0.0.1/api/v2/endpoint/2")
            session.get("http://127.0.0.1/api/v2/endpoint/3")
Exemple #9
0
 def publish():
     with async_tracer.start_active_span('test'):
         msg1 = asynqp.Message({'consume': 'this'})
         self.exchange.publish(msg1, 'routing.key')
         msg = yield from self.queue.get()
         self.assertIsNotNone(msg)
 async def test():
     with async_tracer.start_active_span('test'):
         asyncio.create_task(run_later("Hello"))
     await asyncio.sleep(0.5)
 async def test():
     with async_tracer.start_active_span('test'):
         asyncio.ensure_future(run_later("Hello"))
     await asyncio.sleep(0.5)
Exemple #12
0
 async def test():
     with async_tracer.start_active_span('test'):
         async with aiohttp.ClientSession() as session:
             return await self.fetch(session,
                                     testenv["wsgi_server"] + "/301")
Exemple #13
0
 async def test():
     with async_tracer.start_active_span('test'):
         async with aiohttp.ClientSession() as session:
             return await self.fetch(session, 'http://doesnotexist:10/')
Exemple #14
0
 async def test():
     with async_tracer.start_active_span('test'):
         async with aiohttp.ClientSession() as session:
             return await self.post(session,
                                    testenv["tornado_server"] + "/")
Exemple #15
0
 def test():
     with async_tracer.start_active_span('test'):
         msg = asynqp.Message({'hello': 'world'})
         self.exchange.publish(msg, 'routing.key')
Exemple #16
0
 def test():
     with async_tracer.start_active_span('test'):
         msg = asynqp.Message({'hello': 'world'}, content_type='application/json')
         self.exchange.publish(msg, 'routing.key')
Exemple #17
0
 async def test():
     with async_tracer.start_active_span('test'):
         async with aiohttp.ClientSession() as session:
             return await self.fetch(
                 session,
                 testenv["aiohttp_server"] + "/?secret=iloveyou")