OwlCyberSecurity - MANAGER
Edit File: metrics.cpython-312.pyc
� G��g�t � � � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl m Z mZ d dlm Z d dlmZmZ d dlmZmZ d dlZd dlmZmZmZmZmZmZ d dlmZmZ d dlmZ d d l m!Z! e!rxd d l m"Z" d dl m#Z# d dl m$Z$ d d l m%Z% d dl m&Z& d dl m'Z' d dl m(Z( d dl m)Z) d dl m*Z* d dl m+Z+ d dl,m-Z- d dl,m.Z. d dl,m/Z/ d dl,m0Z0 d dl,m1Z1 d dl,m2Z2 d dl,m3Z3 d dl,m4Z4 d dl,m5Z5 d dl,m6Z6 ejn de8d� � ed!d"�#� Z9e:Z; e<ejz ej| ej~ ej� g� ZA e ej� d$� j� d%� ZD e ej� d&� j� d'� ZE e ej� d(� j� d%� ZFd)� ZGd*� ZHe d+� � ZId,� ZJ G d-� d.e � ZK G d/� d0eK� ZL G d1� d2eK� ZM G d3� d4eK� ZN G d5� d6eK� ZOd7� ZPd8� ZQeLeMeNeOd9�ZRed:� d;� ed<� d=� d>� d?� d@�ZS G dA� dB� ZT G dC� dD� ZUdE� ZVdF� ZWdG� ZXdH� ZY dPdI�ZZeZZ[ G dJ� dK� Z\ dQdL�Z] dRdM�Z^ dRdN�Z: dRdO�Z_y)S� N)�ABC�abstractmethod)�contextmanager)�datetime�timezone)�wraps�partial)� ContextVar�now�nanosecond_time�to_timestamp�serialize_frame� json_dumps)�Envelope�Item)�TransactionSource)� TYPE_CHECKING)�Any)�Callable)�Dict)� Generator)�Iterable)�List)�Optional)�Set)�Tuple)�Union)� BucketKey)�DurationUnit)�FlushedMetricValue)�MeasurementUnit)� MetricMetaKey)�MetricTagValue)� MetricTags)�MetricTagsInternal)� MetricType)�MetricValuez�The sentry_sdk.metrics module is deprecated and will be removed in the next major release. Sentry will reject all metrics sent after October 7, 2024. Learn more: https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics� )� stacklevel� in_metricsF)�defaultz[^a-zA-Z0-9_]+� z[^a-zA-Z0-9_\-.]+�_z[^a-zA-Z0-9_\-.\/]+c �\ � t j ddddddd�� }| j |� S )Nz\nz\rz\tz\\z\u{7c}z\u{2c})� � � �\�|�,)�str� maketrans� translate)�value�tables �A/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/metrics.py�_sanitize_tag_valuer; N s8 � ��M�M������� � �E� �?�?�5�!�!� c �h � t j | � }t |dd�� S # t $ r Y y w xY w)NFT)�include_local_variables�include_source_context)�sys� _getframe� Exceptionr )r) �frms r: �get_code_locationrD ] s? � ���m�m�J�'�� ��U�4�� �� � ���s �% � 1�1c # �� K � t j � } t j d� | �� t j | � y# t j | � w xY w�w)z5Enters recursion protection and returns the old flag.TN)�_in_metrics�get�set)�old_in_metricss r: �recursion_protectionrJ i sC � �� � !�_�_�&�N��O�O�D��(�������'������'�s �*A!�A �A!�A�A!c �. � � t � � � fd�� }|S )zYConvenient decorator that uses `recursion_protection` to make a function a noop. c �l �� t � 5 }|s �| i |��cd d d � S d d d � y # 1 sw Y y xY w�N)rJ )�args�kwargsr* �funcs �r: �new_funczmetrics_noop.<locals>.new_func{ s4 �� � "� #�z���T�,�V�,� $� #�� $� #� #�s � *�3)r )rP rQ s ` r: �metrics_nooprR u s"