Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Latest commit

 

History

History
53 lines (33 loc) · 1.4 KB

File metadata and controls

53 lines (33 loc) · 1.4 KB

OpenCensus requests Integration

pypi

OpenCensus can trace asynchronous HTTP requests made with the aiohttp package. The request URL, method, and status will be collected.

You can enable aiohttp integration by specifying 'aiohttp' to trace_integrations.

It's possible to configure a list of URL you don't want traced, anf it's configurable by giving an array of hostname/port to the attribute excludelist_hostnames in OpenCensus context's attributes:

Installation

pip install opencensus-ext-requests

Usage

import asyncio
from aiohttp import ClientSession
from opencensus.trace import config_integration
from opencensus.trace.tracer import Tracer


config_integration.trace_integrations(['aiohttp'])

async def main():
    tracer = Tracer()
    with tracer.span(name='parent'):
        client_session = ClientSession()
        async with client_session.get(url='https://www.wikipedia.org/wiki/Rabbit') as response:
            await response.read()


asyncio.run(main())

References