Getting and setting correlation and tenant data
To further propagate correlation and tenant information to subsequent requests or processes you can extract them from the request context.
Table of contents
Correlation ID
In order to get the correlation_id
of a request you can use the following method:
var id = req.logger.getCorrelationId();
It is also possible to change the correlation_id
to a valid UUIDv4:
req.logger.setCorrelationId("cbc2654f-1c35-45d0-96fc-f32efac20986");
Tenant ID
In order to get the tenant_id
of a request you can call the following method:
var tenantId = req.logger.getTenantId();
It is also possible to change the tenant_id
to any string value:
req.logger.setTenantId("cbc2654f-1c35-45d0-96fc-f32efac20986");
Be aware that changing the tenant_id
for a logger will also affect ancestor and descendant loggers within the same request context, especially the network log for this request will contain the new tenant_id
.
Tenant Subdomain
The tenant_subdomain
does not get determined automatically. However, you can set it per request as follows:
req.logger.setTenantSubdomain("my-subdomain");
Be aware that changing the tenant_subdomain for a logger will also affect ancestor and descendant loggers within the same request context, especially the network log for this request will contain the new tenant_subdomain.