Tracing Reference

New in version 3.0.

A reference for client tracing API.

See also

Client Tracing for tracing usage instructions.

TraceConfig

class aiohttp.TraceConfig(trace_config_ctx_factory=SimpleNamespace)[source]

Trace config is the configuration object used to trace requests launched by a ClientSession object using different events related to different parts of the request flow.

Parameters:trace_config_ctx_factory – factory used to create trace contexts, default class used types.SimpleNamespace
trace_config_ctx(trace_request_ctx=None)[source]
Parameters:trace_request_ctx – Will be used to pass as a kw for the trace_config_ctx_factory.

Build a new trace context from the config.

Every signal handler should have the following signature:

async def on_signal(session, context, params): ...

where session is ClientSession instance, context is an object returned by trace_config_ctx() call and params is a data class with signal parameters. The type of params depends on subscribed signal and described below.

on_request_start

Property that gives access to the signals that will be executed when a request starts.

params is aiohttp.TraceRequestStartParams instance.

on_request_redirect

Property that gives access to the signals that will be executed when a redirect happens during a request flow.

params is aiohttp.TraceRequestRedirectParams instance.

on_request_end

Property that gives access to the signals that will be executed when a request ends.

params is aiohttp.TraceRequestEndParams instance.

on_request_exception

Property that gives access to the signals that will be executed when a request finishes with an exception.

params is aiohttp.TraceRequestExceptionParams instance.

on_connection_queued_start

Property that gives access to the signals that will be executed when a request has been queued waiting for an available connection.

params is aiohttp.TraceConnectionQueuedStartParams instance.

on_connection_queued_end

Property that gives access to the signals that will be executed when a request that was queued already has an available connection.

params is aiohttp.TraceConnectionQueuedEndParams instance.

on_connection_create_start

Property that gives access to the signals that will be executed when a request creates a new connection.

params is aiohttp.TraceConnectionCreateStartParams instance.

on_connection_create_end

Property that gives access to the signals that will be executed when a request that created a new connection finishes its creation.

params is aiohttp.TraceConnectionCreateEndParams instance.

on_connection_reuseconn

Property that gives access to the signals that will be executed when a request reuses a connection.

params is aiohttp.TraceConnectionReuseconnParams instance.

on_dns_resolvehost_start

Property that gives access to the signals that will be executed when a request starts to resolve the domain related with the request.

params is aiohttp.TraceDnsResolveHostStartParams instance.

on_dns_resolvehost_end

Property that gives access to the signals that will be executed when a request finishes to resolve the domain related with the request.

params is aiohttp.TraceDnsResolveHostEndParams instance.

on_dns_cache_hit

Property that gives access to the signals that will be executed when a request was able to use a cached DNS resolution for the domain related with the request.

params is aiohttp.TraceDnsCacheHitParams instance.

on_dns_cache_miss

Property that gives access to the signals that will be executed when a request was not able to use a cached DNS resolution for the domain related with the request.

params is aiohttp.TraceDnsCacheMissParams instance.

TraceRequestStartParams

class aiohttp.TraceRequestStartParams[source]

See TraceConfig.on_request_start for details.

method

Method that will be used to make the request.

url

URL that will be used for the request.

headers

Headers that will be used for the request, can be mutated.

TraceRequestEndParams

class aiohttp.TraceRequestEndParams[source]

See TraceConfig.on_request_end for details.

method

Method used to make the request.

url

URL used for the request.

headers

Headers used for the request.

response

Response ClientResponse.

TraceRequestExceptionParams

class aiohttp.TraceRequestExceptionParams[source]

See TraceConfig.on_request_exception for details.

method

Method used to make the request.

url

URL used for the request.

headers

Headers used for the request.

exception

Exception raised during the request.

TraceRequestRedirectParams

class aiohttp.TraceRequestRedirectParams[source]

See TraceConfig.on_request_redirect for details.

method

Method used to get this redirect request.

url

URL used for this redirect request.

headers

Headers used for this redirect.

response

Response ClientResponse got from the redirect.

TraceConnectionQueuedStartParams

class aiohttp.TraceConnectionQueuedStartParams[source]

See TraceConfig.on_connection_queued_start for details.

There are no attributes right now.

TraceConnectionQueuedEndParams

class aiohttp.TraceConnectionQueuedEndParams[source]

See TraceConfig.on_connection_queued_end for details.

There are no attributes right now.

TraceConnectionCreateStartParams

class aiohttp.TraceConnectionCreateStartParams[source]

See TraceConfig.on_connection_create_start for details.

There are no attributes right now.

TraceConnectionCreateEndParams

class aiohttp.TraceConnectionCreateEndParams[source]

See TraceConfig.on_connection_create_end for details.

There are no attributes right now.

TraceConnectionReuseconnParams

class aiohttp.TraceConnectionReuseconnParams[source]

See TraceConfig.on_connection_reuseconn for details.

There are no attributes right now.

TraceDnsResolveHostStartParams

class aiohttp.TraceDnsResolveHostStartParams[source]

See TraceConfig.on_dns_resolvehost_start for details.

Host

Host that will be resolved.

TraceDnsResolveHostEndParams

class aiohttp.TraceDnsResolveHostEndParams[source]

See TraceConfig.on_dns_resolvehost_end for details.

Host

Host that has been resolved.

TraceDnsCacheHitParams

class aiohttp.TraceDnsCacheHitParams[source]

See TraceConfig.on_dns_cache_hit for details.

Host

Host found in the cache.

TraceDnsCacheMissParams

class aiohttp.TraceDnsCacheMissParams[source]

See TraceConfig.on_dns_cache_miss for details.

Host

Host didn’t find the cache.