Skip to content

Commit

Permalink
Use TryAdd for traceId in ProblemDetails.Extensions (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva authored Sep 24, 2024
2 parents 96aad75 + a8530d7 commit b2d0f66
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static IServiceCollection AddDefaultProblemDetails(this IServiceCollectio
context.ProblemDetails.Type ??= $"https://httpstatuses.io/{statusCode}";
context.ProblemDetails.Title ??= ReasonPhrases.GetReasonPhrase(statusCode);
context.ProblemDetails.Instance ??= context.HttpContext.Request.Path;
context.ProblemDetails.Extensions["traceId"] = Activity.Current?.Id ?? context.HttpContext.TraceIdentifier;
context.ProblemDetails.Extensions.TryAdd("traceId", Activity.Current?.Id ?? context.HttpContext.TraceIdentifier);
};
});

Expand Down

0 comments on commit b2d0f66

Please sign in to comment.