Skip to main content
Version: Next

Open telemetry

OpenTelemetry is an open-source observability framework that provides a set of APIs, SDKs, and tools to instrument, generate, collect, and export telemetry data (such as metrics, logs, and traces). It helps developers gain deep visibility into their applications by standardizing how telemetry data is collected and transmitted to observability backends like Prometheus, Jaeger, Honeycomb, and others. OpenTelemetry is a vendor-neutral standard supported by the Cloud Native Computing Foundation (CNCF), making it a preferred choice for monitoring distributed systems and microservices.

SimpleIdServer can be easily configured to support OpenTelemetry. To get started, install the NuGet package:

cmd.exe
dotnet add package SimpleIdServer.IdServer.OpenTelemetry

Then, update your Program.cs file by invoking the EnableOpenTelemetry() method from the fluent API. This method accepts two callbacks:

  • One for configuring metrics
  • One for configuring traces
Program.cs
EnableOpenTelemetry(m =>
{
m.AddConsoleExporter();
m.AddOtlpExporter(o =>
{
o.Endpoint = new Uri("");
o.Headers = "";
o.Protocol = OtlpExportProtocol.HttpProtobuf;
});
}, t =>
{
t.AddEntityFrameworkCoreInstrumentation(o =>
{
o.EnrichWithIDbCommand = (activity, command) =>
{
var stateDisplayName = $"{command.CommandType} main";
activity.DisplayName = stateDisplayName;
activity.SetTag("db.name", stateDisplayName);
activity.SetTag("db.text", command.CommandText);
};
});
t.AddConsoleExporter();
t.AddOtlpExporter(o =>
{
o.Endpoint = new Uri("");
o.Headers = "";
o.Protocol = OtlpExportProtocol.HttpProtobuf;
});
});

Default Instrumentation

By default, the following OpenTelemetry instruments are enabled:

  • AddAspNetCoreInstrumentation: Monitors incoming HTTP requests to the Identity Server API.
  • AddHttpClientInstrumentation: Monitors outgoing HTTP requests from the Identity Server to other APIs.

These provide valuable insights into both internal and external communication.

Built-in Trace Categories

The Identity Server defines three types of traces:

  • Basic: Tracks internal logic processing, such as grant type handling.
  • Store: Tracks operations involving database access, such as retrieving user data.
  • Cache: Tracks operations interacting with the cache, like storing authorization codes.

All these trace categories are enabled by default but can be configured based on your needs.

Metrics Provided by the Identity Server

Here’s a summary of the built-in metrics you can monitor:

Metric NameDescriptionTags
user.countTotal number of users
auth.requests.countTotal authentication requestsrealm, client
auth.success.countSuccessful authenticationsrealm, client
auth.failure.countFailed authenticationsrealm, client
logout.countLogout eventsrealm
consent.prompt.countConsent prompts shownrealm, client
consent.accepted.countConsents acceptedrealm, client
consent.rejected.countConsents rejectedrealm, client
token.issued.countTokens issuedrealm, client, grant_type
id_token.issued.countID tokens issuedrealm, client, grant_type
refresh_token.issued.countRefresh tokens issuedrealm, client, grant_type
access_token.issued.countAccess tokens issuedrealm, client, grant_type
authorization_code.issued.countAuthorization codes issuedrealm, client
token.failed.countFailed grant typesrealm, client
token.rejected.countRejected tokensrealm, client

These metrics allow you to understand usage patterns, detect anomalies, and improve system reliability and performance.

Next Steps

To configure exporters and customize telemetry further, refer to the official .NET observability documentation. With just a few lines of code, you can start observing your Identity Server like never before—unlocking insights that help diagnose issues faster and optimize user experience.

Authenticate