You can specify a correlation ID when you make a set of LUSID API calls.
LUSID automatically records the correlation ID in the logs for those API calls, so you can use Insights (LUSID's built-in troubleshooting and audit application) to quickly track and group (that is, correlate) all the API calls made during a particular session. This might be useful to understand which call in a set was causing a performance lag, for example.
Note: The correlation ID is set as a header in the HTTP request. The correlation ID value can consist of up to 256 case-insensitive alphanumeric characters, and also the following: -
_
.
#
:
Using the REST API
To specify a correlation ID when calling the REST API directly, set a request header explicitly each time:
$ curl -X POST https://<your-domain>.lusid.com/api/api/instruments/$get?identifierType=Figi -H "CorrelationId: track-this-in-the-logs" -H "Authorization: Bearer <your-API-access-token>" -d "[ \"BBG000PG2GZ0\",]"
Using the Python SDK
To specify a correlation ID when using the Python SDK, pass a suitable value in as a parameter when you create an ApiClientFactory
object:
# Perform standard authentication using ApiClientFactory
secrets_file_path = "secrets.json"
config = ApiConfigurationLoader.load(secrets_file_path)
api_factory = lusid.utilities.ApiClientFactory(
token=lusid.utilities.RefreshingToken(config),
api_secrets_filename=secrets_file_path,
correlation_id="track-this-in-the-logs"
)
# Build the instruments API
instruments_api = api_factory.build(lusid.api.InstrumentsApi)
# Call the ListInstruments API endpoint to list instruments
instruments_api.list_instruments(limit=10)
# Call the GetInstruments API endpoint to retrieve a particular instrument
instruments_api.get_instruments('Figi', ['BBG000PG2GZ0'])
Tracking and grouping API calls using Insights
- Sign in to the LUSID web app using the credentials of a LUSID administrator.
- Navigate to the Insights > Request Logs dashboard.
- Enter your correlation ID in the Correlation Requests column to correlate API calls (you may need to reorder columns in this dashboard to see them as they are here):