관리-도구
편집 파일: caching.cpython-38.pyc
U �Mg0 � @ s� d dl Z d dlmZ d dlmZmZ d dlmZ d dl m Z d dlm Z d dlZd dlmZmZ d dlmZmZ er�d d lmZ d d lmZ d dlmZ dd ddgZdd� Zdd� Zddd�Zdd� Zdd� ZdS )� N)� TYPE_CHECKING)� _get_safe_key�_key_as_string)� parse_url)�VERSION)�CacheHandler)�OP�SPANDATA)�capture_internal_exceptions�ensure_integration_enabled)�Any)�Callable)�Optional�setZset_many�getZget_manyc C s t t| ||��S �N)r r )�method_name�args�kwargs� r �T/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/django/caching.py�_get_span_description s r c s\ ddl m� t����t� ��� fdd���t���������fdd��}t��|� d S )Nr ��DjangoIntegrationc sR |� d�}| }|rtjntj} t|||�} tj| | � jd���}|||�}t� �� |d k rj|� t j|� |d k r�|� t j|� t |||�} | d k r�|� t j| � d }|r�|r�tt|��}|� t jd� n|� t jd� n<ztt|d ��}W n& tk �r tt|d ��}Y nX |d k �r.|� t j|� W 5 Q R X |W 5 Q R � S Q R X d S )Nr )�op�name�originTF� r )� startswithr Z CACHE_PUTZ CACHE_GETr � sentry_sdkZ start_spanr r �set_datar ZNETWORK_PEER_ADDRESSZNETWORK_PEER_PORTr Z CACHE_KEY�len�strZ CACHE_HIT� IndexErrorZCACHE_ITEM_SIZE)�cacher �original_methodr r �address�portZis_set_operationZis_get_operationr �description�span�value�keyZ item_sizer r r �_instrument_call* s@ � z-_patch_cache_method.<locals>._instrument_callc s � ���| |���S r r )r r )r, r&