Diagnostics API
The presentation manager provides a way to gather diagnostics (performance metrics, logs, etc.) on a per-request basis. The APIs that should be used to get the diagnostics depend on the requirements and whether diagnostics are needed on the backend or the frontend.
In all cases getting diagnostics consists of two pieces:
- Options - what kind of diagnostics are requested.
- Handler - a function that accepts the diagnostics after the request is fulfilled.
Getting request diagnostics on the frontend
On the frontend side diagnostics can be requested on a per request basis, by supplying diagnostics options through diagnostics
attribute to PresentationManager requests. Resulting diagnostics are then passed to the given handler.
Getting request diagnostics on the backend
There are two ways to retrieve diagnostics on the backend - through request parameters or through PresentationManager.
Getting diagnostics on a per-request basis
To get diagnostics on a per request basis, diagnostics options can be supplied through diagnostics
attribute to PresentationManager requests. Resulting diagnostics are then passed to the given handler.
Getting diagnostics for all requests
It's also possible to set up PresentationManager to retrieve diagnostics of every request made through it. This can be done by supplying diagnostics options, including the handler, when calling Presentation.initialize.
This approach also allows the backend to use request diagnostics for telemetry and logging, e.g. in combination with OpenTelemetry. See the Diagnostics and OpenTelemetry section for more details.
Diagnostics and OpenTelemetry
OpenTelemetry is a vendor-neutral standard to collect telemetry data - metrics, logs and traces. The @itwin/presentation-opentelemetry
package provides APIs to easily convert presentation diagnostics objects to OpenTelemetry objects, which makes collecting Presentation-related telemetry much easier.
Last Updated: 30 November, 2023