How to use the instana.singletons.async_tracer.start_active_span function in instana

To help you get started, we’ve selected a few instana examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instana / python-sensor / tests / clients / test_asynqp.py View on Github external
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)
github instana / python-sensor / tests / frameworks / test_tornado_server.py View on Github external
async def test():
            with async_tracer.start_active_span('test'):
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session, testenv["tornado_server"] + "/301")
github instana / python-sensor / tests / frameworks / test_asyncio.py View on Github external
async def test():
            with async_tracer.start_active_span('test'):
                asyncio.ensure_future(run_later("Hello"))
            await asyncio.sleep(0.5)
github instana / python-sensor / tests / frameworks / test_aiohttp.py View on Github external
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["aiohttp_server"] + "/?secret=iloveyou", headers=headers)
github instana / python-sensor / tests / frameworks / test_aiohttp.py View on Github external
async def test():
            with async_tracer.start_active_span('test'):
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session, testenv["wsgi_server"] + "/?secret=yeah")
github instana / python-sensor / tests / frameworks / test_aiohttp.py View on Github external
async def test():
            with async_tracer.start_active_span('test'):
                async with aiohttp.ClientSession() as session:
                    return await self.fetch(session, testenv["wsgi_server"] + "/504")
github instana / python-sensor / instana / instrumentation / aiohttp / client.py View on Github external
async def stan_request_start(session, trace_config_ctx, params):
        try:
            parent_span = async_tracer.active_span

            # If we're not tracing, just return
            if parent_span is None:
                trace_config_ctx.scope = None
                return

            scope = async_tracer.start_active_span("aiohttp-client", child_of=parent_span)
            trace_config_ctx.scope = scope

            async_tracer.inject(scope.span.context, opentracing.Format.HTTP_HEADERS, params.headers)

            parts = str(params.url).split('?')
            if len(parts) > 1:
                cleaned_qp = strip_secrets(parts[1], agent.secrets_matcher, agent.secrets_list)
                scope.span.set_tag("http.params", cleaned_qp)
            scope.span.set_tag("http.url", parts[0])
            scope.span.set_tag('http.method', params.method)
        except Exception:
            logger.debug("stan_request_start", exc_info=True)
github instana / python-sensor / instana / instrumentation / asynqp.py View on Github external
def publish_with_instana(wrapped, instance, argv, kwargs):
        parent_span = async_tracer.active_span

        # If we're not tracing, just return
        if parent_span is None:
            return wrapped(*argv, **kwargs)

        with async_tracer.start_active_span("rabbitmq", child_of=parent_span) as scope:
            host, port = instance.sender.protocol.transport._sock.getsockname()

            msg = argv[0]
            if msg.headers is None:
                msg.headers = {}
            async_tracer.inject(scope.span.context, opentracing.Format.TEXT_MAP, msg.headers)

            try:
                scope.span.set_tag("exchange", instance.name)
                scope.span.set_tag("sort", "publish")
                scope.span.set_tag("address", host + ":" + str(port) )

                if 'routing_key' in kwargs:
                    scope.span.set_tag("key", kwargs['routing_key'])
                elif len(argv) > 1 and argv[1] is not None:
                    scope.span.set_tag("key", argv[1])