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

Introduce IBufferedLogger #103138

Merged
merged 7 commits into from
Jul 18, 2024
Merged

Introduce IBufferedLogger #103138

merged 7 commits into from
Jul 18, 2024

Conversation

geeknoid
Copy link
Member

@geeknoid geeknoid commented Jun 6, 2024

Fixes #104129

@geeknoid geeknoid requested a review from tarekgh June 6, 2024 19:21
@geeknoid geeknoid requested a review from noahfalk June 6, 2024 19:24
@tarekgh tarekgh marked this pull request as draft June 6, 2024 20:08
@tarekgh
Copy link
Member

tarekgh commented Jun 6, 2024

@geeknoid LGTM. Thanks for getting this that fast. I left a minor comment there.

@noahfalk @samsp-msft any feedback?

@noahfalk
Copy link
Member

noahfalk commented Jun 7, 2024

@noahfalk @samsp-msft any feedback?

I think we should do the transform you suggested so that we can extend this in the future if needed, but otherwise LGTM!

EDIT: We also need to figure out what we're doing with EventSourceLoggerProvider and OpenTelemetry. At minimum we should make sure OTel folks are on-board with the design and its implications for their logger prior to taking this for review.

@tarekgh
Copy link
Member

tarekgh commented Jun 7, 2024

At minimum we should make sure OTel folks are on-board with the design and its implications for their logger prior to taking this for review.

@CodeBlanch was in the meeting. Will be good to understand the plan for any OTel logger for that though.

@samsp-msft
Copy link
Member

samsp-msft commented Jun 7, 2024

@kalyanaj for FYI,
and open-telemetry/opentelemetry-specification#4044 for this group

@geeknoid geeknoid changed the title Introduce IBufferedLogRecordMetadata Introduce IBufferedLogRecord Jun 7, 2024
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.

LGTM

@geeknoid geeknoid marked this pull request as ready for review June 25, 2024 12:23
@@ -155,6 +155,23 @@ public enum LogLevel
Critical = 5,
None = 6,
}
public abstract class BufferedLogRecord
Copy link
Contributor

@CodeBlanch CodeBlanch Jun 25, 2024

Choose a reason for hiding this comment

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

@geeknoid

A few comments...

    public sealed class BufferedLogRecord
    {
        public required System.DateTimeOffset Timestamp { get; init; }
        public required Microsoft.Extensions.Logging.LogLevel LogLevel { get; init; }
        public required Microsoft.Extensions.Logging.EventId EventId { get; init; }
        public string? Exception { get; init; }
        public System.Diagnostics.ActivitySpanId? ActivitySpanId { get; init; }
        public System.Diagnostics.ActivityTraceId? ActivityTraceId { get; init;  }
        public int? ManagedThreadId { get; init; }
        public string? FormattedMessage { get; init; }
        public string? MessageTemplate { get; init; }
        public System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object?>> Attributes { get; init; }
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

@noahfalk Should we add trace flags? Just another prop, not a big deal...

I thought it's fine to have the attributes non-nullable, it would just point to an empty attribute list if there is nothing there.

As for the virtual/abstract duality, that was a result of refactoring and not paying attention. This is now all abstract. This means whomever implements this abstraction gets to decide how to manage the underlying storage of each property.

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy to add trace flags if Blanch believes they would be useful.

Copy link
Member

Choose a reason for hiding this comment

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

The abstract and virtual stuff feels a bit odd. For really a DTO could we do...

The design goal behind this type currently is that it isn't an intermediate DTO, it is likely the type that was used for backing storage. If you guys want to change this into a DTO and copy all the property values in from some private implementation type that does the storage I'm fine with that too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: Introducing Log buffering abstraction
8 participants