Boto3

Learn how to set up Sentry's Boto3 integration and how to capture requests as spans.

The Boto3 integration instruments requests made to Amazon Web Services done with Boto3 (or the low level botocore library that Boto3 uses under the hood).

You need:

  • A Sentry account and project
  • Your application up and running
  • botocore 1.12+
  • Python 3.6+

Follow our quick start guide to set up Sentry in your Python application (make sure to enable tracing). Sentry's Boto3 integration is enabled automatically if you have the boto3 package in your dependencies.

To verify that Sentry captures your Boto3 requests to Amazon Web Services, add this code to your app, which will create a transaction called testing_sentry in the Traces section:

Copied
import sentry_sdk
import boto3

def main():
    # same as in the Python quick start guide (https://docs.sentry.io/platforms/python)
    sentry_sdk.init(...)

    s3 = boto3.resource('s3')

    # or sentry_sdk.traces.start_span(name="testing_sentry", parent_span=None) in stream mode
    with sentry_sdk.start_transaction(name="testing_sentry"):
        # make a request to the service and print out bucket names
        for bucket in s3.buckets.all():
            print(bucket.name)

main()

At this point, you should have integrated Sentry into your application and should already be sending data to your Sentry project.

Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:

Are you having problems setting up the SDK or integration?
Was this helpful?
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").