Socket

Use this integration to create spans for DNS resolves and socket connection creations.

Install `sentry-sdk`` from PyPI.

Copied
pip install --upgrade 'sentry-sdk'

Add SocketIntegration() to your integrations list:

Copied
import sentry_sdk
from sentry_sdk.integrations.socket import SocketIntegration

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    enable_tracing=True,
    integrations=[
        SocketIntegration(),
    ],
)

Copied
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, and create spans for the socket commands.

It takes a couple of moments for the data to appear in sentry.io.

  • Python: 2.7+
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").