Ejemplo n.º 1
0
def get():
    bt = appd.start_bt("Get Product")
    try:
        r = requests.get("http://localhost:3000/products")
        print(r.json())
    except:
        pass

    appd.end_bt(bt)
 def wrapper(*args, **kwargs):
     global APPD_BT_HANDLE
     correlation_header = None
     bt_handle = appd.start_bt(transaction_name, correlation_header=correlation_header)
     APPD_BT_HANDLE = bt_handle
     
     ret = func(*args, **kwargs)
     appd.end_bt(bt_handle)
     APPD_BT_HANDLE = None
     return ret
def application(environ, start_response):
    custom_bt = appd.start_bt('Custom BT example app')
    e = None
    try:
        start_response('200 OK', [('Content-Type', 'text/html')])
    except Exception as e:
        raise
    finally:
        appd.end_bt(custom_bt, e)

    yield 'Hello '.encode('utf-8')
    yield b'World\n'
def application(environ, start_response):
    custom_bt = appd.start_bt('Custom BT')
    body_str = 'Hello world!\n'
    body_str_byte = bytes(body_str, 'utf-8')
    status = '200 OK'
    headers = [('Content-type', 'text/plain')]

    e = None
    try:
        start_response(status, headers)
    except Exception as e:
        raise
    finally:
        appd.end_bt(custom_bt, e)

    return [body_str_byte]
def my_orders(environ, start_response):
    custom_bt = appd.start_bt('My orders BT')
    body_str = 'My orders\n'
    body_str_byte = bytes(body_str, 'utf-8')
    status = '200 OK'
    headers = [('Content-type', 'text/text')]

    e = None
    try:
        start_response(status, headers)
    except Exception as e:
        raise
    finally:
        appd.end_bt(custom_bt, e)

    return [body_str_byte]
Ejemplo n.º 6
0
def execute_long_work(model):
    appd.init(appd_env, 100000)

    mybt = appd.start_bt('/test_py')

    print('Starting long execution')

    time.sleep(5)
    print('almost there')

    time.sleep(5)

    test2.delay()
    print('Done')

    appd.end_bt(mybt)
    appd.shutdown()
Ejemplo n.º 7
0
def post():
    bt = appd.start_bt("Post Product")
    products = [
        "apple", "orange", "mac", "keyboard", "mouse", "car", "tv", "human",
        "sex", "noidea", "maybe", "product", "thing", "legs", "shorts",
        "window", "sky"
    ]

    try:
        data = {
            "name": random.choice(products),
            "price": float(random.uniform(15.0, 999.99))
        }

        r = requests.post("http://localhost:3000/products", data=data)
        print(r.json())
    except:
        pass

    appd.end_bt(bt)
Ejemplo n.º 8
0
def update_item(item_id: int, item: Item):
    mybt = appd.start_bt('/items_put')
    do_something()
    appd.end_bt(mybt)
    return {"item_name": item.name, "item_id": item_id}