def change_context(span: Optional[AbstractSpan]) -> Generator:
    """Execute this block inside the given context and restore it afterwards.

    This does not start and ends the span, but just make sure all code is executed within
    that span.

    If span is None, no-op.

    :param span: A span
    :type span: AbstractSpan
    :rtype: contextmanager
    :return: A context manager that will run the given span in the new context
    """
    span_impl_type: Optional[Type[AbstractSpan]] = settings.tracing_implementation()
    if span_impl_type is None or span is None:
        yield
    else:
        try:
            with span_impl_type.change_context(span):
                yield
        except AttributeError:
            # This plugin does not support "change_context"
            warnings.warn(
                'Your tracing plugin should be updated to support "change_context"',
                DeprecationWarning,
            )
            original_span = span_impl_type.get_current_span()
            try:
                span_impl_type.set_current_span(span)
                yield
            finally:
                span_impl_type.set_current_span(original_span)
Execute this block inside the given context and restore it afterwards.

    This does not start and ends the span, but just make sure all code is executed within
    that span.

    If span is None, no-op.

    :param span: A span
    :type span: AbstractSpan
    :rtype: contextmanager
    :return: A context manager that will run the given span in the new context
    
Solutions/CyberArkAudit/Data Connectors/.python_packages/lib/site-packages/azure/core/tracing/common.py