You've already forked mariadb-columnstore-engine
							
							
				mirror of
				https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
				synced 2025-11-03 17:13:17 +03:00 
			
		
		
		
	Added mirroring of spans into Sentry Tracer is a facade that redirects actions to tracing backends
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
"""Async sibling of TracedSession."""
 | 
						|
from typing import Any
 | 
						|
 | 
						|
import aiohttp
 | 
						|
 | 
						|
from tracing.tracer import get_tracer
 | 
						|
 | 
						|
 | 
						|
class TracedAsyncSession(aiohttp.ClientSession):
 | 
						|
    async def _request(
 | 
						|
        self, method: str, str_or_url: Any, *args: Any, **kwargs: Any
 | 
						|
    ) -> aiohttp.ClientResponse:
 | 
						|
        tracer = get_tracer()
 | 
						|
 | 
						|
        headers = kwargs.get("headers") or {}
 | 
						|
        if headers is None:
 | 
						|
            headers = {}
 | 
						|
        kwargs["headers"] = headers
 | 
						|
 | 
						|
        url_text = str(str_or_url)
 | 
						|
        span_name = f"HTTP {method} {url_text}"
 | 
						|
        with tracer.start_as_current_span(span_name, kind="CLIENT") as span:
 | 
						|
            span.set_attribute("http.method", method)
 | 
						|
            span.set_attribute("http.url", url_text)
 | 
						|
            tracer.inject_outbound_headers(headers)
 | 
						|
            try:
 | 
						|
                response = await super()._request(method, str_or_url, *args, **kwargs)
 | 
						|
            except Exception as exc:
 | 
						|
                span.set_status("ERROR", str(exc))
 | 
						|
                raise
 | 
						|
            else:
 | 
						|
                span.set_attribute("http.status_code", response.status)
 | 
						|
                return response
 | 
						|
 | 
						|
 | 
						|
def create_traced_async_session(**kwargs: Any) -> TracedAsyncSession:
 | 
						|
    return TracedAsyncSession(**kwargs)
 | 
						|
 | 
						|
 | 
						|
 |