Diagnostics

SSR Diagnostics

By enabling SSR tracing on the Next.js server you can observe the rendering of the widgets and the sequence of requests, their count and duration and verify any performance hits that could occur when rendering your the pages.

We provide @progress/sitefinity-nextjs-sdk/diagnostics/dev module with sample implementation for tracing widget performance utilizing the Next.js experimental implementation and OpenTelemetry.

By default the module that is required in the nextjs-sdk is the @progress/sitefinity-nextjs-sdk/diagnostics/empty which is an API mock with no dependencies that does not carry and side effects when deployed in production.

IMPORTANT: The Next.js instrumentation implementation is at an experimental stage at the moment and both their and our API can be subject to changes.

IMPORTANT: The OpenTelemetry implementation is currently only supported for SSR components and server code. For performance analytics on the Front end, please refer to the Next.JS usage of useReportWebVitals

Enabling tracing in your development application

  1. Install the needed OpenTelemetry npm packages to your local development setup:
  2. Enable tracing for Next.js in the next.config.js and change the module resolution in the webpack config:

    npm i @opentelemetry/api @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/sdk-node @opentelemetry/sdk-trace-node @opentelemetry/semantic-conventions --save-dev

  3. Include the intrumentation.ts and instrumentation.node.ts to your project.

For more information, see Next.js' documentaion on Manual OpenTelemetry configuration.

Consuming and reading the trace data

We suggest using the dev Docker setup provided by Next.js in the following repository: OpenTelemetry Collector Demo.

Filtering the precise page requests can be achieved in Jaeger and Zipkin by the http.route, http.target, next.route tags assigned to the traces by Next.js.

SSR Widget tracing

Import the @progress/sitefinity-nextjs-sdk/diagnostics/empty package to make sure that your widget works and is not reporting data if you disable the tracing and remove the module alias in the webpack config.

Other tracing

Tracing server-to-server http requests

await RestClient.sendRequest({url, traceContext});

await RestClient.getItems({/*... getAllArgs*/, traceContext})

Obtaining trace context

You can obtain an optional trace context in several ways. Not providing such context logs the request in the root of the Next.js route render span.

  • First method:


  • Second method:

  • Third method:

Furthermore, you can use any functionality that the NodeSDK for Open Telemetry provides.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?