Skip to content

Commit

Permalink
Python: Getting Started socket (#7859)
Browse files Browse the repository at this point in the history
* Getting Started: socket

* style(lint): Auto commit lint changes

* Made socket title caps

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
antonpirker and getsantry[bot] committed Sep 20, 2023
1 parent be9c297 commit e00886f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 28 additions & 3 deletions src/platforms/python/common/configuration/integrations/socket.mdx
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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+

0 comments on commit e00886f

Please sign in to comment.