コード例 #1
0
def checkout():

    order = json.loads(request.data)
    email = order["email"]
    customer_type = order["customerType"]

    with sentry_sdk.configure_scope() as scope:
        scope.user = {"email": email}
        scope.set_tag("session-id", request.headers.get('X-Session-ID'))
        scope.set_tag("customer-type", customer_type)
        scope.set_extra("inventory", Inventory)

    print "Processing order for: " + email
    cart = order["cart"]

    with sentry_sdk.start_span(op="db function: get inventory"):
        try:
            rows = get_inventory()
        except Exception as err:
            sentry_sdk.capture_exception(err)
            raise (err)

    with sentry_sdk.start_span(op="process order"):
        process_order(cart)

    with sentry_sdk.start_span(op="db function: update inventory"):
        try:
            rows = update_inventory()
        except Exception as err:
            sentry_sdk.capture_exception(err)
            raise (err)

    return 'Success'
コード例 #2
0
ファイル: app.py プロジェクト: kathlam/tracing
def checkout():

    order = json.loads(request.data)
    print "Processing order for: " + request.headers.get('email')
    cart = order["cart"]
    
    with sentry_sdk.start_span(op="db function: get inventory"):
        try:
            rows = get_inventory()
        except Exception as err:
            sentry_sdk.capture_exception(err)
            raise(err)

    with sentry_sdk.start_span(op="process order"):
        process_order(cart)

    with sentry_sdk.start_span(op="db function: update inventory"):
        try:
            rows = update_inventory()
        except Exception as err:
            sentry_sdk.capture_exception(err)
            raise(err)

    return 'Success'