Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer enrichment & redaction on top of HttpLogging #4056

Closed
wants to merge 5 commits into from

Conversation

Tratcher
Copy link
Member

@Tratcher Tratcher commented Jun 8, 2023

This is a proof of concept that re-layers onto the new extensibility in dotnet/aspnetcore#48679.

In theory this replaces the local logging middleware.

Doesn't compile until the aspnetcore PR gets merged

Microsoft Reviewers: Open in CodeFlow

@Tratcher Tratcher self-assigned this Jun 8, 2023
@Tratcher Tratcher force-pushed the tratcher/httplogging branch from 609da5d to b37e1ce Compare June 8, 2023 21:54
Copy link
Member

@geeknoid geeknoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty clean.

[Required]
[SuppressMessage("Usage", "CA2227:Collection properties should be read only",
Justification = "Options pattern.")]
public ISet<string> ExcludePathStartsWith { get; set; } = new HashSet<string>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality doesn't seem like it belongs on RedactionOptions in an ideal world. Filtering (in whatever form we think is most appropriate) feels like something that would be available in the base layer without having opted into any redaction. Should I think of this as refactoring is still in progress or we believe this needs to stay here because of various time or design constraints?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's certainly a design point that needs to be resolved. For now it's here because it's an option that the extensions middleware has and the aspnetcore one doesn't. I wouldn't move it to aspnetcore as is, this is an anti-pattern that ends up duplicating routing. I do understand it was done this way because it's easy and config compatible.

We will revisit this detail once we agree on the larger design.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be a config-friendly way of doing this which is not an anti-pattern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet/aspnetcore#43642 would allow you to apply metadata (like the logging attribute) to arbitrary route paths and be more config friendly. I'll ping them to see how that's coming along.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice to me 👍

if (logContext.TryOverride(HttpLoggingFields.RequestHeaders))
{
// TODO: HttpLoggingOptions.Request/ResponseHeaders are ignored which could be confusing.
// Do we try to reconcile that with LoggingRedactionOptions.RequestHeadersDataClasses?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this behavior as-is seems pretty reasonable and we'd document something like "Invoking AddHttpLoggingRedaction() offers more sophisticated redaction customization options for path and headers. The basic header configuration settings in HttpLoggingOptions will no longer be used when this is enabled."

@geeknoid
Copy link
Member

I presume a bunch of stuff would still need to be deleted when enabling this stuff right? Some extension methods, the option type, etc?

/// <remarks>
/// Default set to <see cref="HttpRouteParameterRedactionMode.Strict"/>.
/// </remarks>
[Experimental]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole type needs to be marked [Experimental]

/// <param name="services">The service collection.</param>
/// <param name="configureRedaction">Configures the redaction options.</param>
/// <returns>The original service collection.</returns>
public static IServiceCollection AddHttpLoggingRedaction(this IServiceCollection services, Action<LoggingRedactionOptions> configureRedaction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark any new functions with [Experimental]

@Tratcher
Copy link
Member Author

I presume a bunch of stuff would still need to be deleted when enabling this stuff right? Some extension methods, the option type, etc?

Yeah, I haven't purged the old code yet, I'll do that before undrafting. For now I want to keep it focused on the new design.

@Tratcher
Copy link
Member Author

Making a new PR for release/8.0

@Tratcher Tratcher closed this Aug 23, 2023
@Tratcher Tratcher deleted the tratcher/httplogging branch August 23, 2023 23:01
@ghost ghost locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants