Skip to content

Diagnostics

Duende Backend for Frontend (BFF) offers several diagnostics possibilities. It uses the standard logging facilities provided by ASP.NET Core, so you don’t need to do any extra configuration to benefit from rich logging functionality, including support for multiple logging providers. See the Microsoft documentation for a good introduction on logging.

BFF follows the standard logging levels defined by the .NET logging framework, and uses the Microsoft guidelines for when certain log levels are used, similar to how Duende IdentityServer uses log levels.

Logs are typically written under the Duende.Bff category, with more concrete categories for specific components.

OpenTelemetry provides a single standard for collecting and exporting telemetry data, such as metrics, logs, and traces.

To start emitting OpenTelemetry data in Duende Backend for Frontend (BFF), you need to:

  • add the OpenTelemetry libraries to your BFF host and client applications
  • start collecting traces and metrics from the various BFF sources (and other sources such as ASP.NET Core, the HttpClient, etc.)

The following configuration adds the OpenTelemetry configuration to your service setup, and exports data to an OTLP exporter:

Program.cs
var openTelemetry = builder.Services.AddOpenTelemetry();
openTelemetry.ConfigureResource(r => r
.AddService(builder.Environment.ApplicationName));
openTelemetry.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation()
.AddMeter(BffMetrics.MeterName);
});
openTelemetry.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation()
// Uncomment the following line to enable gRPC instrumentation
// (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});
openTelemetry.UseOtlpExporter();

OpenTelemetry metrics are run-time measurements are typically used to show graphs on a dashboard, to inspect overall application health, or to set up monitoring rules.

The BFF host emits metrics from several sources, and collects these through the Duende.Bff meter:

  • session.started - a counter that communicates the number of sessions started
  • session.ended - a counter that communicates the number of sessions ended