-
Notifications
You must be signed in to change notification settings - Fork 391
Feature request: Add Activity.Current.Id to ErrorMessage (and maybe Events) #1478
Description
Which version of Duende IdentityServer are you using?
6.3.5
Which version of .NET are you using?
net6.0
Describe the bug feature request
Instrumentation for ActivitySources was added in Version 6.0 of IdentityServer with DuendeArchive/Support#698. When IdentityServer creates an ErrorMessage and redirects to our Error-Controller the current ActivityID is sadly not persisted, which means it is hard to find the correct trace/logs to diagnose the issue. Only the request id is pulled from the HttpContext and saved [0]. It would be really nice if Activity.Current?.Id was saved inside the ErrorMessage, so we can diagnose issues more easily.
Events have the same behavior [1]. But they save the request id in a property named ActivityId, which makes them lot more confusing. In the case of events I could understand if backwards compatibility makes it hard to change this though.
The best solution for me would be to make both of these classes behave like the following:
public partial abstract class Event {
public string? RequestId { get; set; } = HttpContext.TraceIdentifier;
public string? ActivtityId { get; set; } = Activity.Current?.Id;
}
public partial abstract class ErrorMessage{
public string? RequestId { get; set; } = HttpContext.TraceIdentifier;
public string? ActivtityId { get; set; } = Activity.Current?.Id;
}[0] https://github.com/DuendeSoftware/IdentityServer/blob/ef64ef16e84881b1eba4b2cf2ffef39e20eb640b/src/IdentityServer/Endpoints/Results/AuthorizeResult.cs#L225
[1] https://github.com/DuendeSoftware/IdentityServer/blob/ef64ef16e84881b1eba4b2cf2ffef39e20eb640b/src/IdentityServer/Services/Default/DefaultEventService.cs#L114