Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Getting Started socket #7859

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
antonpirker marked this conversation as resolved.
Show resolved Hide resolved
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+
Loading