This example is for Python, check our docs for the simple REST API and for other languages.
Step One - Install the hawkflow pip package
# install the hawkflow pip package from your terminal pip install hawkflow
Step Two - Try timing some code with start and end
Save this code to a .py file and run it. You will see how easy it is to time any part of your code and then see the results
You can see the data you send on the Dashboard and on the Timed Data page
import time from hawkflowclient.hawkflow_api import * # authenticate with your API key, you only need to do this once in your app hf = HawkflowAPI("") # start timing your code - pass through process (required) and meta (optional) parameters hf.start("your_process_name", "your_meta_data") # you would not normally add a sleep, this is just for the example time.sleep(5) # end timing this piece of code - process (required) and meta (optional) parameters should match the start hf.end("your_process_name", "your_meta_data")
Step Three - Try timing some code by using a decorator
Save this code to a .py file and run it. You will see how easy it is to time any part of your code and then see the results
You can see the data you send on the Dashboard and on the Timed Data page
import time from hawkflowclient.hawkflow_decorators import * # use a decorator instead of HawkFLow start and end API calls # the hawkflow_meta parameter is optional, include it if you would like to send more information @HawkflowTimed(api_key="") def my_example_function(hawkflow_meta="your_meta_data"): # put any code in this function, here we are sleeping just for an example time.sleep(5) # run the code by calling your function my_example_function(hawkflow_meta="example meta data")
Step Four - Try sending some metrics
Save this code to a .py file and run it. You will see how easy it is to send any number through to HawkFlow and then see the results
You can see the metrics you send on the Dashboard and on the Metric Data page
from hawkflowclient.hawkflow_api import * # authenticate with your API key, you only need to do this once in your app hf = HawkflowAPI("") # create a dictionary with some metrics my_metrics = { "kurtosis": 1441, "mean": 0.845, "users_count": 5465 } # sending the metrics data to hawkflow hf.metrics("your_process_name", "your_meta_data", my_metrics)
Step Five - Try sending an exception
Save this code to a .py file and run it. You will see how easy it is to send an exception through to HawkFlow and then see the results
You can see the exception you send on the Exceptions page
import traceback from hawkflowclient.hawkflow_api import * # authenticate with your API key, you only need to do this once in your app hf = HawkflowAPI("") try: # cause a divide by zero exception 1/0 except Exception as err: # sending the exception through to hawkflow # we are using traceback here, but you can use any technique you choose to capture your exception message hf.exception("your_process_name", "your_meta_data", traceback.format_exc())