示例#1
0
def getRequestURL( testUrl ):
    status_code = 0
    startTime = datetime.datetime.now()
    appd.bt("Getting URL metrics")
    try:
        r = requests.get( testUrl )
        statusCode = r.status_code
    except Exception as e:
        print( "E ", e )
        statusCode = 503 # 503 Service Unavailable
    responseTime = int((datetime.datetime.now() - startTime).total_seconds() * 1000)
    print( "Testing URL-> ", testUrl, statusCode )
    return int( statusCode ), responseTime, testUrl
示例#2
0
def read_item(item_id: int, request: Request, q: Optional[str] = None):
    with appd.bt('/items_get') as bt_handle:
        do_something()
        optional_properties = {}
        optional_properties['client_host'] = request.client.host
        # Set the identifying properties (required to mark exit call)
        FINANCIALS_ID_PROPS = {
            'Host': 'financials-lb',
            'Port': 3456,
            'Vendor': 'custom db'
        }
        with appd.exit_call(bt_handle,
                            appd.EXIT_CUSTOM,
                            'Faked_Exit',
                            FINANCIALS_ID_PROPS,
                            optional_properties=optional_properties):
            print('in exit call')
            time.sleep(1)
    return {"item_id": item_id, "q": q}
def read_item(item_id: int, q: Optional[str] = None):
    with appd.bt('/items_get') as bt_handle:
        do_something()
        optional_properties = {}
        optional_properties['http_code'] = 200
        # Set the identifying properties
        FINANCIALS_ID_PROPS = {'Host': 'financials-lb',
                               'Port': 3456, 'Vendor': 'custom db'}
        # with appd.exit_call(bt_handle, appd.EXIT_CUSTOM, 'Faked_Exit', identifying_properties=None, optional_properties=optional_properties):
        exit_handle = appd.start_exit_call(bt_handle, appd.EXIT_CUSTOM, 'Faked_Exit',
                                           identifying_properties=FINANCIALS_ID_PROPS, optional_properties=optional_properties)
        exc = None
        try:
            print('in exit call')
            time.sleep(1)
        except Exception as exc:
            raise
        finally:
            appd.end_exit_call(exit_handle, exc)
    return {"item_id": item_id, "q": q}
示例#4
0
        hostname = "google.com"  #example
        response = os.system("ping -c 1 " + hostname)


def teardown():
    print("This is it")


# Start of main program

# Endless loop around 2 BT that are simulated

while (True):
    setup()
    while (True):
        with appd.bt('Simple BT'):
            transaction_simulation()
            print('Simple BT sent to AppD')
            time.sleep(1)
            break
    teardown()

    setup()
    while (True):
        with appd.bt('Ping BT'):
            transaction_ping()
            print('Simple Ping BT sent to AppD')
            time.sleep(1)
            break
    teardown()
示例#5
0
elif cmd == "createSchema": # createSchema <schema name>
    auth['schemaName'] = sys.argv[2]
    print (sys.argv[2])
    print (auth['schemaName'])
    createCustomSchema(auth=auth)

elif cmd == "deleteSchema": # deleteSchema <schema name>
    auth['schemaName'] = sys.argv[2]
    deleteCustomSchema(auth=auth)
#
elif cmd == "query1": # createSchema <schema name>
    auth['schemaName'] = sys.argv[2]
    postQuery(auth=auth)

elif cmd == "query2": # createSchema <schema name>
    auth['schemaName'] = sys.argv[2]
    queryCustomAnalyticsMetric(auth=auth)

else:
    print( "Commands: runtest1, createSchema, deleteSchema")

# Main Program Starts here    
print( "main runTestCase1")    
#runTestCase1( auth, random.choice(urlList) )
appdSetup()
while (True):
    with appd.bt('Sending data to Analytics API'):
        runTestCase1( auth, random.choice(urlList) ) 
    time.sleep(1)

示例#6
0
文件: loop.py 项目: svrnm/python-sqs
        ]):
            # Get the custom author message attribute if it was set
            author_text = ''
            correlation_header = None
            if message.message_attributes is not None:
                author_name = message.message_attributes.get('Author').get(
                    'StringValue')
                correlation_header = message.message_attributes.get(
                    'AppDynamicsCorrelationHeader').get('StringValue')
                if author_name:
                    author_text = ' ({0})'.format(author_name)

            # Print out the body and author (if set)
            # APPDYNAMICS: Create BT handle manually
            print('process message...')
            with appd.bt('process message', correlation_header) as bt_handle:
                time.sleep(0.5)
                print(correlation_header)
                print('Hello, {0}!{1}'.format(message.body, author_text))
                appd.add_snapshot_data(bt_handle, 'body', message.body)
                exit_call_handle = appd.start_exit_call(
                    bt_handle, appd.EXIT_QUEUE, 'sqs-queue-next', {
                        'VENDOR': 'AWS',
                        'SERVERPOOL': 'appd-test-queue-next'
                    })
                print(appd.make_correlation_header(bt_handle,
                                                   exit_call_handle))
                time.sleep(0.5)
                appd.end_exit_call(exit_call_handle)

            # Let the queue know that the message is processed