How to setup async logging
Lytix supports sending log events without being on the critical path. We use Traceloop to power this feature.
Prerequisite Please see here to get and set your API Key environment variable.
To get started first download the relevant SDK for your language of choice.
Now you can initialize the logger with your API key.
Note: If you are in the EU you have to update the baseURL
on the LytixAsyncLogger
to https://eu.api.lytix.co/v2/metrics/async
.
Now you can call OpenAI as you normally would, and logs will automatically get sent to the Lytix platform.
You can also add metadata to your logs. This can be useful for tracking things like user id’s, session id’s, or other metadata.
To do this, you just need to first set the parameters on the logger:
You can set the following metadata fields:
userId
: The user id of the user making the requestsessionId
: The session id of the user making the requestworkflowName
: The name of the workflow the request was made inlytix-metadata-*
: Any additional metadata you would like to track, e.g. lytix-metadata-env
: dev
will add the metadata key env
with the value dev