Skip to content

Commit 0b52730

Browse files
authored
Merge pull request #951 from DuendeSoftware/mb/bff-otel
BFF v4 - OpenTelemetry docs
2 parents 588509f + ce01cef commit 0b52730

File tree

7 files changed

+90
-12
lines changed

7 files changed

+90
-12
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
label: "Diagnostics"
2+
collapsed: true
3+
order: 5
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: "Diagnostics"
3+
description: Overview of Duende Backend for Frontend (BFF) diagnostic capabilities including logging and OpenTelemetry integration to assist with monitoring and troubleshooting
4+
date: 2025-11-27T08:20:20+02:00
5+
sidebar:
6+
label: Overview
7+
order: 1
8+
---
9+
10+
## Logging
11+
12+
Duende Backend for Frontend (BFF) offers several diagnostics possibilities. It uses the standard logging facilities
13+
provided by ASP.NET Core, so you don't need to do any extra configuration to benefit from rich logging functionality,
14+
including support for multiple logging providers. See the Microsoft [documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging) for a good introduction on logging.
15+
16+
BFF follows the standard logging levels defined by the .NET logging framework, and uses the Microsoft guidelines for
17+
when certain log levels are used, similar to [how Duende IdentityServer uses log levels](/identityserver/diagnostics/logging.md).
18+
19+
Logs are typically written under the `Duende.Bff` category, with more concrete categories for specific components.
20+
21+
:::note[Multiple frontends]
22+
When using [multiple frontends and the `FrontendSelectionMiddleware`](/bff/architecture/multi-frontend.md),
23+
log messages are written in a log scope that contains a `frontend` property with the name of the frontend for which the
24+
log message was emitted.
25+
:::
26+
27+
## OpenTelemetry :badge[v4.0]
28+
29+
OpenTelemetry provides a single standard for collecting and exporting telemetry data, such as metrics, logs, and traces.
30+
31+
To start emitting OpenTelemetry data in Duende Backend for Frontend (BFF), you need to:
32+
33+
* add the OpenTelemetry libraries to your BFF host and client applications
34+
* start collecting traces and metrics from the various BFF sources (and other sources such as ASP.NET Core, the `HttpClient`, etc.)
35+
36+
The following configuration adds the OpenTelemetry configuration to your service setup, and exports data to an [OTLP exporter](https://learn.microsoft.com/en-us/dotnet/core/diagnostics/observability-with-otel):
37+
38+
```cs
39+
// Program.cs
40+
var openTelemetry = builder.Services.AddOpenTelemetry();
41+
42+
openTelemetry.ConfigureResource(r => r
43+
.AddService(builder.Environment.ApplicationName));
44+
45+
openTelemetry.WithMetrics(metrics =>
46+
{
47+
metrics.AddAspNetCoreInstrumentation()
48+
.AddHttpClientInstrumentation()
49+
.AddRuntimeInstrumentation()
50+
.AddMeter(BffMetrics.MeterName);
51+
});
52+
53+
openTelemetry.WithTracing(tracing =>
54+
{
55+
tracing.AddSource(builder.Environment.ApplicationName)
56+
.AddAspNetCoreInstrumentation()
57+
// Uncomment the following line to enable gRPC instrumentation
58+
// (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
59+
//.AddGrpcClientInstrumentation()
60+
.AddHttpClientInstrumentation();
61+
});
62+
63+
openTelemetry.UseOtlpExporter();
64+
```
65+
66+
## Metrics
67+
68+
OpenTelemetry metrics are run-time measurements are typically used to show graphs on a dashboard, to inspect overall
69+
application health, or to set up monitoring rules.
70+
71+
The BFF host emits metrics from several sources, and collects these through the `Duende.Bff` meter:
72+
73+
* `session.started` - a counter that communicates the number of sessions started
74+
* `session.ended` - a counter that communicates the number of sessions ended
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
label: "Samples"
2-
order: 5
2+
order: 6
33
collapsed: true

src/content/docs/general/licensing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ economical option that is a good fit for organizations with basic needs. It's al
3333
choice if you have an aging IdentityServer4 implementation that needs to be updated and
3434
licensed. The Starter edition includes all the features that were part of
3535
IdentityServer4, along with support for the latest .NET releases, improved observability
36-
through OTEL support, and years of bug fixes and enhancements.
36+
through OpenTelemetry support, and years of bug fixes and enhancements.
3737

3838
### Business Edition
3939

src/content/docs/identityserver/diagnostics/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ to the UI/client are very brief - the logs always have all the details of what w
1919

2020
[Read More](/identityserver/diagnostics/logging.md)
2121

22-
## Open Telemetry
22+
## OpenTelemetry
2323

24-
Open Telemetry is the new standard way of emitting diagnostics information from a process and
24+
OpenTelemetry is a standard way of emitting diagnostics information from a process and
2525
IdentityServer supports Traces (.NET Activities), Metrics and Logs.
2626

2727
[Read More](/identityserver/diagnostics/otel.md)
@@ -30,7 +30,7 @@ IdentityServer supports Traces (.NET Activities), Metrics and Logs.
3030

3131
The eventing system was created as an extension point to integrate with application monitoring
3232
systems (APM). They used to have their own different APIs so IdentityServer only provided events
33-
that could be used to call the APM's APIs. Thanks to Open Telemetry there is now a standardized
33+
that could be used to call the APM's APIs. Thanks to OpenTelemetry there is now a standardized
3434
way to emit diagnostic information from a process. The events may eventually be deprecated and removed.
3535

3636
[Read More](/identityserver/diagnostics/events.md)

src/content/docs/identityserver/diagnostics/otel.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Added in Duende IdentityServer v6.1 and expanded in v7.0
2323
telemetry data (metrics, logs, and traces). This is very useful for analyzing software performance and behavior,
2424
especially in highly distributed systems.
2525

26-
.NET 8 comes with first class support for Open Telemetry. IdentityServer emits traces, metrics, and logs.
26+
.NET 8 comes with first class support for OpenTelemetry. IdentityServer emits traces, metrics, and logs.
2727

2828
### Metrics
2929

@@ -47,15 +47,15 @@ url and then gets the keys from jwks endpoint.
4747

4848
## Setup
4949

50-
To start emitting Otel tracing and metrics information you need
50+
To start emitting OpenTelemetry tracing and metrics information you need to:
5151

52-
* add the Otel libraries to your IdentityServer and client applications
52+
* add the OpenTelemetry libraries to your IdentityServer and client applications
5353
* start collecting traces and Metrics from the various IdentityServer sources (and other sources e.g. ASP.NET Core)
5454

5555
For development a simple option is to export the tracing information to the console and use the Prometheus
5656
exporter to create a human-readable `/metrics` endpoint for the metrics.
5757

58-
Add the Open Telemetry configuration to your service setup.
58+
Add the OpenTelemetry configuration to your service setup.
5959

6060
```cs
6161
// Program.cs
@@ -83,7 +83,7 @@ Add the Prometheus exporter to the pipeline
8383

8484
```cs
8585
// Program.cs
86-
// Map /metrics that displays Otel data in human-readable form.
86+
// Map /metrics that displays OpenTelemetry data in human-readable form.
8787
app.UseOpenTelemetryPrometheusScrapingEndpoint();
8888
```
8989

@@ -97,7 +97,7 @@ Added in Duende IdentityServer v7.0
9797

9898
OpenTelemetry metrics are run-time measurements that are intended to provide an indication
9999
of overall health and are typically used to show graphs on a dashboard or to set up monitoring rules.
100-
When that monitoring reveals issues, traces and logs are used to investigate further. Open Telemetry monitoring
100+
When that monitoring reveals issues, traces and logs are used to investigate further. OpenTelemetry monitoring
101101
tools often provide features to find the traces and logs corresponding to certain metrics.
102102

103103
IdentityServer emits metrics from the IdentityServer middleware and services. Our quick start for the UI also
@@ -391,7 +391,7 @@ Here's e.g. the output for a request to the discovery endpoint:
391391

392392
![Honeycomb UI showing traces for discovery document endpoint](images/otel_disco.png)
393393

394-
When multiple applications send their traces to the same OTel server, this becomes super useful for following e.g.
394+
When multiple applications send their traces to the same OpenTelemetry server, this becomes super useful for following e.g.
395395
authentication flows over service boundaries.
396396

397397
The following screenshot shows the ASP.NET Core OpenID Connect authentication handler redeeming the authorization code:

0 commit comments

Comments
 (0)