Development guide
How do I use HawkFlow.ai in my code?
To make sending data to HawkFlow.ai easy for you, we have provided packages in multiple languages. See below for how to install the packages.
If you do not see your language here, you can send data to our API using HTTP POST requests. See the REST API docs for examples.
Authentication
HawkFlow.ai uses an API key to authenticate to our API. You receive an API after making an account. There are two ways that you can use the API key to authenticate.
Authentication using an environment variable
Set the api key value in an environment variable named "HAWKFLOW_API_KEY". You can do this using the command:
export HAWKFLOW_API_KEY=your-api-key-here
Authentication using code
If you do not have access to the machine to be able to set an environment variable, you can send the api key through in your code when you create the HawkFlowAPI object. See the code example below on how to do this.
Timed API - Monitor code performance
What is the Timed API endpoint used for?
The Timed API endpoint is used to time any part of your code.
See below on how to use it. See the [concepts](../concepts/index.md) page for all the benefits and features
that you receive by using the Timed API endpoint.
There is a start endpoint to use when a process is starting, and another endpoint to use when the process is ending.
Both endpoints take the same paramters.
** Timed API parameters **
Parameter | Type | size | format | Required | Description |
---|---|---|---|---|---|
process |
string | max length 250 | string, ',",% will be stripped | required | The Process name |
meta |
string | max length 500 | string, ',",% will be stripped | optional | The meta details about your process |
uid |
uuid | max length 50 | allowed a-z, 0-9, -_ | optional | Unique process identifier. If you would like to send multiple processes that run at the same time using the same values for process and meta, then you can use this parameter to identify their uniqueness |
Metrics API - Monitor numerical values
What is the Metrics API endpoint used for?
The Metrics API endpoint is used to send HawkFlow any numerical value.
See below on how to use it. See the [concepts](../concepts/index.md#metrics) page for all the benefits and features
that you receive by using the Metrics API endpoint.
Parameter | Type | size | format | Required | Description |
---|---|---|---|---|---|
process |
string | max length 250 | string, ',",% will be stripped | required | The Process name |
meta |
string | max length 500 | string, ',",% will be stripped | optional | The meta details about your process |
items |
dictionary, see curl example below for more details | max length 50 items | dict key: string, ',",% are not allowed. Value: any numerical | required | You can send multiple metrics at once in a dictionary. |
Exception API - Monitor exceptions
What is the Exception API endpoint used for?
The Exception API endpoint is used to send HawkFlow exceptions that occur in your code.
See below on how to use it. See the [concepts](../concepts/index.md#exceptions) page for all the benefits and features
that you receive by using the Exception API endpoint.
Parameter | Type | size | format | Required | Description |
---|---|---|---|---|---|
process |
string | max length 250 | string, ',",% will be stripped | required | The Process name |
meta |
string | max length 500 | string, ',",% will be stripped | optional | The meta details about your process |
exception |
string | max length 15000 | any string | required | The text of the exception |
package main
import "github.com/hawkflow/hawkflow-go"
func main() {
hf := hawkflow.New("YOUR_API_KEY")
err := userFunction()
if err != nil {
// catch and send error through to hawkflow
_ = hf.Exception("hawkflow_examples", "your_meta_data", err.Error())
}
}
func userFunction() error {
// your code that may return an error
}
API Response Codes
Code | Status | Meaning |
---|---|---|
201 |
created | Successful use of the API |
500 |
error | Please check the response for the error details |
401 |
unauthorized | Failed to authenticate using your api key |
422 |
incorrect data | Incorrect JSON data sent to the endpoint. Please check the response for the error details |