X7ROOT File Manager
Current Path:
/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations
opt
/
hc_python
/
lib
/
python3.12
/
site-packages
/
sentry_sdk
/
integrations
/
??
..
??
__init__.py
(12.51 KB)
??
__pycache__
??
_asgi_common.py
(4 KB)
??
_wsgi_common.py
(7.28 KB)
??
aiohttp.py
(19.28 KB)
??
aiomysql.py
(9.09 KB)
??
anthropic.py
(39 KB)
??
argv.py
(876 B)
??
ariadne.py
(5.7 KB)
??
arq.py
(9.23 KB)
??
asgi.py
(20.06 KB)
??
asyncio.py
(9.28 KB)
??
asyncpg.py
(9.68 KB)
??
atexit.py
(1.51 KB)
??
aws_lambda.py
(17.41 KB)
??
beam.py
(4.91 KB)
??
boto3.py
(6.2 KB)
??
bottle.py
(7.21 KB)
??
celery
??
chalice.py
(4.51 KB)
??
clickhouse_driver.py
(5.85 KB)
??
cloud_resource_context.py
(7.49 KB)
??
cohere.py
(10.44 KB)
??
dedupe.py
(1.86 KB)
??
django
??
dramatiq.py
(8.02 KB)
??
excepthook.py
(2.25 KB)
??
executing.py
(1.93 KB)
??
falcon.py
(9.04 KB)
??
fastapi.py
(5.28 KB)
??
flask.py
(8.27 KB)
??
gcp.py
(10.57 KB)
??
gnu_backtrace.py
(2.72 KB)
??
google_genai
??
gql.py
(4.93 KB)
??
graphene.py
(5.71 KB)
??
grpc
??
httpx.py
(9.79 KB)
??
httpx2.py
(9.8 KB)
??
huey.py
(8.19 KB)
??
huggingface_hub.py
(15.28 KB)
??
langchain.py
(48.31 KB)
??
langgraph.py
(18.13 KB)
??
launchdarkly.py
(1.87 KB)
??
litellm.py
(13.03 KB)
??
litestar.py
(11.46 KB)
??
logging.py
(15.69 KB)
??
loguru.py
(6.35 KB)
??
mcp.py
(23.12 KB)
??
modules.py
(787 B)
??
openai.py
(53.38 KB)
??
openai_agents
??
openfeature.py
(1.08 KB)
??
opentelemetry
??
otlp.py
(7.99 KB)
??
pure_eval.py
(4.41 KB)
??
pydantic_ai
??
pymongo.py
(8.21 KB)
??
pyramid.py
(7.42 KB)
??
pyreqwest.py
(6.82 KB)
??
quart.py
(7.32 KB)
??
ray.py
(5.75 KB)
??
redis
??
rq.py
(7.81 KB)
??
rust_tracing.py
(9.44 KB)
??
sanic.py
(15.25 KB)
??
serverless.py
(1.58 KB)
??
socket.py
(5.02 KB)
??
spark
??
sqlalchemy.py
(5.24 KB)
??
starlette.py
(27.93 KB)
??
starlite.py
(11.04 KB)
??
statsig.py
(1.19 KB)
??
stdlib.py
(14.01 KB)
??
strawberry.py
(17.39 KB)
??
sys_exit.py
(2.35 KB)
??
threading.py
(6.88 KB)
??
tornado.py
(10.79 KB)
??
trytond.py
(1.67 KB)
??
typer.py
(1.72 KB)
??
unleash.py
(1.02 KB)
??
unraisablehook.py
(1.65 KB)
??
wsgi.py
(15.03 KB)
Editing: gql.py
import sentry_sdk from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version from sentry_sdk.scope import should_send_default_pii from sentry_sdk.utils import ( ensure_integration_enabled, event_from_exception, parse_version, ) try: import gql # type: ignore[import-not-found] from gql.transport import ( # type: ignore[import-not-found] AsyncTransport, Transport, ) from gql.transport.exceptions import ( # type: ignore[import-not-found] TransportQueryError, ) from graphql import ( DocumentNode, VariableDefinitionNode, get_operation_ast, print_ast, ) try: # gql 4.0+ from gql import GraphQLRequest except ImportError: GraphQLRequest = None except ImportError: raise DidNotEnable("gql is not installed") from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Any, Dict, Tuple, Union from sentry_sdk._types import Event, EventProcessor EventDataType = Dict[str, Union[str, Tuple[VariableDefinitionNode, ...]]] class GQLIntegration(Integration): identifier = "gql" @staticmethod def setup_once() -> None: gql_version = parse_version(gql.__version__) _check_minimum_version(GQLIntegration, gql_version) _patch_execute() def _data_from_document(document: "DocumentNode") -> "EventDataType": try: operation_ast = get_operation_ast(document) data: "EventDataType" = {"query": print_ast(document)} if operation_ast is not None: data["variables"] = operation_ast.variable_definitions if operation_ast.name is not None: data["operationName"] = operation_ast.name.value return data except (AttributeError, TypeError): return dict() def _transport_method(transport: "Union[Transport, AsyncTransport]") -> str: """ The RequestsHTTPTransport allows defining the HTTP method; all other transports use POST. """ try: return transport.method except AttributeError: return "POST" def _request_info_from_transport( transport: "Union[Transport, AsyncTransport, None]", ) -> "Dict[str, str]": if transport is None: return {} request_info = { "method": _transport_method(transport), } try: request_info["url"] = transport.url except AttributeError: pass return request_info def _patch_execute() -> None: real_execute = gql.Client.execute # Maintain signature for backwards compatibility. # gql.Client.execute() accepts a positional-only "request" # parameter with version 4.0.0. @ensure_integration_enabled(GQLIntegration, real_execute) def sentry_patched_execute( self: "gql.Client", document: "DocumentNode", *args: "Any", **kwargs: "Any", ) -> "Any": scope = sentry_sdk.get_isolation_scope() # document is a gql.GraphQLRequest with gql v4.0.0. scope.add_event_processor(_make_gql_event_processor(self, document)) try: # document is a gql.GraphQLRequest with gql v4.0.0. return real_execute(self, document, *args, **kwargs) except TransportQueryError as e: event, hint = event_from_exception( e, client_options=sentry_sdk.get_client().options, mechanism={"type": "gql", "handled": False}, ) sentry_sdk.capture_event(event, hint) raise e gql.Client.execute = sentry_patched_execute def _make_gql_event_processor( client: "gql.Client", document_or_request: "Union[DocumentNode, gql.GraphQLRequest]" ) -> "EventProcessor": def processor(event: "Event", hint: "dict[str, Any]") -> "Event": try: errors = hint["exc_info"][1].errors except (AttributeError, KeyError): errors = None request = event.setdefault("request", {}) request.update( { "api_target": "graphql", **_request_info_from_transport(client.transport), } ) if should_send_default_pii(): if GraphQLRequest is not None and isinstance( document_or_request, GraphQLRequest ): # In v4.0.0, gql moved to using GraphQLRequest instead of # DocumentNode in execute # https://github.com/graphql-python/gql/pull/556 document = document_or_request.document else: document = document_or_request request["data"] = _data_from_document(document) contexts = event.setdefault("contexts", {}) response = contexts.setdefault("response", {}) response.update( { "data": {"errors": errors}, "type": response, } ) return event return processor
Upload File
Create Folder