Skip to content

Commit e00886f

Browse files
Python: Getting Started socket (#7859)
* 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>
1 parent be9c297 commit e00886f

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/platforms/python/common/configuration/integrations/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If you don't want integrations to be enabled automatically, set the `default_int
4646
- [Cloud Resource Context](cloudresourcecontext/)
4747
- [Enhanced Locals](pure_eval/)
4848
- [GNU Backtrace](gnu_backtrace/)
49-
- [SOCKET](socket/)
49+
- [Socket](socket/)
5050
- [WSGI](wsgi/)
5151

5252
## Web Frameworks

src/platforms/python/common/configuration/integrations/socket.mdx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
2-
title: SOCKET
2+
title: Socket
33
description: "Learn about the Socket integration and how it adds support network actions."
44
sidebar_order: 90
55
---
66

7-
Use this integration to create spans for dns resolves and connection creations.
7+
Use this integration to create spans for DNS resolves and socket connection creations.
88

99
## Install
1010

11-
`socket` is included by default in CPython
11+
Install `sentry-sdk`` from PyPI.
12+
13+
```bash
14+
pip install --upgrade 'sentry-sdk'
15+
```
1216

1317
## Configure
1418

@@ -22,12 +26,33 @@ from sentry_sdk.integrations.socket import SocketIntegration
2226

2327
sentry_sdk.init(
2428
dsn="___PUBLIC_DSN___",
29+
# Set traces_sample_rate to 1.0 to capture 100%
30+
# of transactions for performance monitoring.
31+
traces_sample_rate=1.0,
2532
integrations=[
2633
SocketIntegration(),
2734
],
2835
)
2936
```
3037

38+
## Verify
39+
40+
```python
41+
import socket
42+
43+
def main():
44+
sentry_init(...) # same as above
45+
with sentry_sdk.start_transaction(name="testing_sentry"):
46+
timeout = 10
47+
socket.getaddrinfo("sentry.io", 443)
48+
socket.create_connection(("sentry.io", 443), timeout, None)
49+
main()
50+
```
51+
52+
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.
53+
54+
It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).
55+
3156
## Supported Versions
3257

3358
- Python: 2.7+

0 commit comments

Comments
 (0)