PHP 8.2.30
Preview: tracing_utils_py3.py Size: 2.10 KB
//opt/cloudlinux/venv/lib/python3.11/site-packages/sentry_sdk/tracing_utils_py3.py

import inspect
from functools import wraps

import sentry_sdk
from sentry_sdk import get_current_span
from sentry_sdk._types import TYPE_CHECKING
from sentry_sdk.consts import OP
from sentry_sdk.utils import logger, qualname_from_function


if TYPE_CHECKING:
    from typing import Any


def start_child_span_decorator(func):
    # type: (Any) -> Any
    """
    Decorator to add child spans for functions.

    This is the Python 3 compatible version of the decorator.
    For Python 2 there is duplicated code here: ``sentry_sdk.tracing_utils_python2.start_child_span_decorator()``.

    See also ``sentry_sdk.tracing.trace()``.
    """

    # Asynchronous case
    if inspect.iscoroutinefunction(func):

        @wraps(func)
        async def func_with_tracing(*args, **kwargs):
            # type: (*Any, **Any) -> Any

            span = get_current_span(sentry_sdk.Hub.current)

            if span is None:
                logger.warning(
                    "Can not create a child span for %s. "
                    "Please start a Sentry transaction before calling this function.",
                    qualname_from_function(func),
                )
                return await func(*args, **kwargs)

            with span.start_child(
                op=OP.FUNCTION,
                description=qualname_from_function(func),
            ):
                return await func(*args, **kwargs)

    # Synchronous case
    else:

        @wraps(func)
        def func_with_tracing(*args, **kwargs):
            # type: (*Any, **Any) -> Any

            span = get_current_span(sentry_sdk.Hub.current)

            if span is None:
                logger.warning(
                    "Can not create a child span for %s. "
                    "Please start a Sentry transaction before calling this function.",
                    qualname_from_function(func),
                )
                return func(*args, **kwargs)

            with span.start_child(
                op=OP.FUNCTION,
                description=qualname_from_function(func),
            ):
                return func(*args, **kwargs)

    return func_with_tracing

Directory Contents

Dirs: 3 × Files: 29

Name Size Perms Modified Actions
crons DIR
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
- drwxr-xr-x 2026-02-06 08:07:29
Edit Download
6.05 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.77 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
22.35 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
8.49 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.11 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
9.37 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
26.42 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
2.97 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
33.18 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
0 B lrw-r--r-- 2026-01-20 13:01:48
Edit Download
24.26 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
3.80 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
12.97 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
5.43 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
5.76 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
29.04 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
12.00 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.21 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
2.10 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
18.13 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
45.58 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
4.15 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
2.73 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
4.84 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
5.26 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
11.00 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
2.19 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
3.70 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.03 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).