コード例 #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)
コード例 #2
0
 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
コード例 #3
0
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'
コード例 #4
0
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]
コード例 #5
0
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]
コード例 #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()
コード例 #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)
コード例 #8
0
ファイル: main.py プロジェクト: Appdynamics/FastAPI-Example
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}