Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /pydantic_logfire /logfire /_internal /integrations /pymongo.py
| from __future__ import annotations | |
| from collections.abc import Callable | |
| from typing import Any | |
| from opentelemetry.sdk.trace import Span | |
| from pymongo.monitoring import CommandFailedEvent, CommandStartedEvent, CommandSucceededEvent | |
| try: | |
| from opentelemetry.instrumentation.pymongo import ( | |
| PymongoInstrumentor, | |
| dummy_callback, | |
| ) | |
| except ImportError: | |
| raise RuntimeError( | |
| '`logfire.instrument_pymongo()` requires the `opentelemetry-instrumentation-pymongo` package.\n' | |
| 'You can install this with:\n' | |
| " pip install 'logfire[pymongo]'" | |
| ) | |
| def instrument_pymongo( | |
| *, | |
| capture_statement: bool, | |
| request_hook: Callable[[Span, CommandStartedEvent], None] | None = None, | |
| response_hook: Callable[[Span, CommandSucceededEvent], None] | None = None, | |
| failed_hook: Callable[[Span, CommandFailedEvent], None] | None = None, | |
| **kwargs: Any, | |
| ) -> None: | |
| """Instrument the `pymongo` module so that spans are automatically created for each operation. | |
| See the `Logfire.instrument_pymongo` method for details. | |
| """ | |
| PymongoInstrumentor().instrument( | |
| request_hook=request_hook or dummy_callback, | |
| response_hook=response_hook or dummy_callback, | |
| failed_hook=failed_hook or dummy_callback, | |
| capture_statement=capture_statement, | |
| **kwargs, | |
| ) | |
Xet Storage Details
- Size:
- 1.35 kB
- Xet hash:
- f9856186d22766329671e90377c53ea9bd965c8ada07fb1b32300f5c6a906e17
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.