diff --git a/src/platforms/python/common/configuration/integrations/index.mdx b/src/platforms/python/common/configuration/integrations/index.mdx index 3787c103b76f4..46c3882134202 100644 --- a/src/platforms/python/common/configuration/integrations/index.mdx +++ b/src/platforms/python/common/configuration/integrations/index.mdx @@ -46,7 +46,7 @@ If you don't want integrations to be enabled automatically, set the `default_int - [Cloud Resource Context](cloudresourcecontext/) - [Enhanced Locals](pure_eval/) - [GNU Backtrace](gnu_backtrace/) -- [SOCKET](socket/) +- [Socket](socket/) - [WSGI](wsgi/) ## Web Frameworks diff --git a/src/platforms/python/common/configuration/integrations/socket.mdx b/src/platforms/python/common/configuration/integrations/socket.mdx index a830ab15f369e..be5795b68a08d 100644 --- a/src/platforms/python/common/configuration/integrations/socket.mdx +++ b/src/platforms/python/common/configuration/integrations/socket.mdx @@ -1,14 +1,18 @@ --- -title: SOCKET +title: Socket description: "Learn about the Socket integration and how it adds support network actions." sidebar_order: 90 --- -Use this integration to create spans for dns resolves and connection creations. +Use this integration to create spans for DNS resolves and socket connection creations. ## Install -`socket` is included by default in CPython +Install `sentry-sdk`` from PyPI. + +```bash +pip install --upgrade 'sentry-sdk' +``` ## Configure @@ -22,12 +26,33 @@ from sentry_sdk.integrations.socket import SocketIntegration sentry_sdk.init( dsn="___PUBLIC_DSN___", + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + traces_sample_rate=1.0, integrations=[ SocketIntegration(), ], ) ``` +## Verify + +```python +import socket + +def main(): + sentry_init(...) # same as above + with sentry_sdk.start_transaction(name="testing_sentry"): + timeout = 10 + socket.getaddrinfo("sentry.io", 443) + socket.create_connection(("sentry.io", 443), timeout, None) +main() +``` + +This example will create a transaction called `testing_sentry` in the Performance section of [sentry.io](https://sentry.io), and create spans for the socket commands. + +It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io). + ## Supported Versions - Python: 2.7+