Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /pydantic_logfire /logfire /_internal /integrations /django.py
| from __future__ import annotations | |
| from collections.abc import Callable | |
| from typing import Any | |
| from django.http import HttpRequest, HttpResponse | |
| from opentelemetry.trace import Span | |
| from logfire._internal.utils import maybe_capture_server_headers | |
| try: | |
| from opentelemetry.instrumentation.django import DjangoInstrumentor | |
| except ImportError: | |
| raise RuntimeError( | |
| '`logfire.instrument_django()` requires the `opentelemetry-instrumentation-django` package.\n' | |
| 'You can install this with:\n' | |
| " pip install 'logfire[django]'" | |
| ) | |
| def instrument_django( | |
| *, | |
| capture_headers: bool, | |
| is_sql_commentor_enabled: bool | None, | |
| excluded_urls: str | None, | |
| request_hook: Callable[[Span, HttpRequest], None] | None, | |
| response_hook: Callable[[Span, HttpRequest, HttpResponse], None] | None, | |
| **kwargs: Any, | |
| ) -> None: | |
| """Instrument the `django` module so that spans are automatically created for each web request. | |
| See the `Logfire.instrument_django` method for details. | |
| """ | |
| maybe_capture_server_headers(capture_headers) | |
| DjangoInstrumentor().instrument( | |
| excluded_urls=excluded_urls, | |
| is_sql_commentor_enabled=is_sql_commentor_enabled, | |
| request_hook=request_hook, | |
| response_hook=response_hook, | |
| **kwargs, | |
| ) | |
Xet Storage Details
- Size:
- 1.31 kB
- Xet hash:
- bfca53414e2f616bdbd5f39e24b8f73878f0038a5ae65229221f2a7e7114add9
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.