Observability
Arconia Multitenancy integrates with logging and observability tools to provide tenant-aware telemetry data. Both MDC logging enrichment and Micrometer observation enrichment are enabled by default.
MDC Logging
The current tenant identifier is automatically added to the SLF4J MDC (Mapped Diagnostic Context) for every request, and for the asynchronous tasks the tenant context is propagated to. This allows you to filter and correlate log entries by tenant.
When you bind a tenant yourself with TenantContext.where(), for example, in a scheduled job, the MDC is not set for you. Add the identifier to it around the work, for example, with SLF4J’s MDC.putCloseable(…), using the configured key name.
By default, the MDC key is tenantId. You can include it in your log pattern:
logging:
pattern:
console: "%d{HH:mm:ss.SSS} [%thread] [%X{tenantId}] %-5level %logger{36} - %msg%n"
Log output will include the tenant identifier:
14:32:01.123 [http-nio-8080-exec-1] [acme] INFO c.e.GreetingController - Processing request
14:32:01.456 [http-nio-8080-exec-2] [beans] INFO c.e.GreetingController - Processing request
Micrometer Observations
Arconia Multitenancy uses a Micrometer ObservationFilter to automatically enrich all observations with the current tenant identifier. Any observation that completes while a tenant context is active will include the tenant information, covering service calls, repository queries, cache operations, and other instrumented components.
By default, the tenant identifier appears only in traces. This is the recommended approach for tenants with many possible values, as including high-cardinality attributes in metrics can cause cardinality explosion.
If you have a small, bounded number of tenants and want the identifier in metrics as well, set the cardinality to low:
arconia:
multitenancy:
observations:
cardinality: low
|
What bounds the number of metric series is not the number of tenants you have, but the number of distinct identifiers that can reach the tenant context. Every identifier that gets bound becomes a metric series when the cardinality is With a |
Configuration Properties
| Property | Default | Description |
|---|---|---|
|
|
Whether observations are enhanced with tenant information. |
|
|
Name of the key to use for the tenant identifier in observations. |
|
|
The cardinality of the tenant identifier key value. |