Atatus APM supports most of the standard libraries out of the box. However you might need to know how long a specific function took. Using capture span, you can measure the timing of specific function or set of lines of code.

Compatibility

Compatible with all Python agent versions.

Syntax

Option 1: Using decorator

When used as a decorator, the function name will be captured as span name.

copy
icon/buttons/copy
import atatus

@atatus.capture_span()
def generate_pdf_report():
    # your code to generate PDF.

Option 2: Using context manager

When used as a context manager, a name has to be provided.

copy
icon/buttons/copy
import atatus

def send_email():
    with atatus.capture_span("Send email using mailgun"):
        # your code to send email.

Parameter

Parameter Type Description
span_name String(Required) Name of the span.
span_type String(Optional) The type of the span. Default is custom. Possible values are db, external, template, custom
span_subtype String(Optional) It can be a database name or service name. Default is None

Example

copy
icon/buttons/copy
def get_user_comments():

    with atatus.capture_span('SELECT * from comments WHERE user_id=546',
                 span_type='db', span_subtype='cockroachdb'):
        # your code here