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

Refactor some JsonProviders for use with both logging and access events #663

Merged
merged 12 commits into from
Sep 29, 2021

Conversation

brenuart
Copy link
Collaborator

This PR addresses issues #660 , #661 and #662.

@brenuart
Copy link
Collaborator Author

brenuart commented Sep 23, 2021

@philsttr Please have a first look at this PR when you have time...

The documentation lists the available providers in two sections: one with the providers applicable to ILoggingEvent and a second for IAccessEvent. I think it can be clearer if we move the providers applicable to both in a third section that would appear before the two other.

Also the documentation says provider named message is available for access event... Isn't it rather accessMessage (cfr https://github.com/logstash/logstash-logback-encoder/blob/gh662-refactor-providers-for-logging-and-access/src/main/java/net/logstash/logback/composite/accessevent/AccessEventJsonProviders.java#L45-L47) ?

@philsttr
Copy link
Collaborator

The documentation lists the available providers in two sections: one with the providers applicable to ILoggingEvent and a second for IAccessEvent. I think it can be clearer if we move the providers applicable to both in a third section that would appear before the two other.

Sounds good. Make sure to link to the common section from both of the logging/access event specific sections

Also the documentation says provider named message is available for access event... Isn't it rather accessMessage (cfr https://github.com/logstash/logstash-logback-encoder/blob/gh662-refactor-providers-for-logging-and-access/src/main/java/net/logstash/logback/composite/accessevent/AccessEventJsonProviders.java#L45-L47) ?

Yes, you are correct

@philsttr philsttr added the warn/api-change Breaking change with compilation or xml configuration errors label Sep 24, 2021
@philsttr
Copy link
Collaborator

Added the not-backward-compatible label since this change is not binary compatible (it looks like it should be source-compatible though)

@brenuart
Copy link
Collaborator Author

brenuart commented Sep 24, 2021

Conventions in the code base seems to prefix abstract classes with "Abstract" (I quite like it - this make it obvious it is an intermediate base class that cannot be used directly).

To follow that convention, I renamed FormattedTimestampJsonProvider into AbstractFormattedTimestampJsonProvider but kept and deprecated the original for backward compatibility until next major version.

@philsttr Question: should I repeat the static fields in the now deprecated class (eg AbstractFormattedTimestampJsonProvider.java#L40)? IMHO it is not strictly required...

CompositeJsonFormatter is another candidate... Should I rename it as well? And keep a deprecated version of it?

@brenuart
Copy link
Collaborator Author

Also the documentation says provider named message is available for access event... Isn't it rather accessMessage...

message is probably a better name than accessMessage...:

  • it better represents the actual purpose of the provider
  • the default field name for this provider is message
  • LogstashFieldNames also use message
  • the documentation also refers to message

... only AccessEventJsonProviders uses a different name. Instead of changing the documentation, I would instead modify the AccessEventJsonProviders to align it with the rest.

@brenuart brenuart marked this pull request as ready for review September 25, 2021 09:55
Copy link
Collaborator

@philsttr philsttr left a comment

Choose a reason for hiding this comment

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

Question: should I repeat the static fields in the now deprecated class (eg AbstractFormattedTimestampJsonProvider.java#L40)? IMHO it is not strictly required...

To be binary-compatible, they would need to remain. To be source-compatible, they can be removed. I have tried to keep logstash-logback-encoder as-compatible-as-possible in the past, since that is best for its users. But for 7.0 we've already broken compatibility a lot, so I'm ok with just keeping source-compatibility here. We need to keep an eye on binary and source compatibility in future releases. I don't want logstash-logback-encoder to get into the habit of breaking compatibility in lots of places all the time.

CompositeJsonFormatter is another candidate... Should I rename it as well? And keep a deprecated version of it?

In a non-major release, I would say no (unless we kept full binary compatibility). But you can rename it and keep source-compatibility only since 7.0 is a major release.

README.md Outdated
Comment on lines 1980 to 1981
The table below lists the available providers for _LoggingEvents_, and their configuration properties (defaults in parentheses).
The provider name is the xml element name to use when configuring.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mention and provide a link to the common providers section somewhere in this paragraph.

Perhaps:

Suggested change
The table below lists the available providers for _LoggingEvents_, and their configuration properties (defaults in parentheses).
The provider name is the xml element name to use when configuring.
The [common providers mentioned above](#providers-common-to-loggingevents-and-accessevents), and the providers listed in the table below, are available for _LoggingEvents_.
The provider name is the xml element name to use when configuring. Each provider's configuration properties are shown, with default configuration values in parenthesis.

README.md Outdated
Comment on lines 2155 to 2156
The table below lists the available providers for _AccessEvents_, and their configuration properties (defaults in parentheses).
The provider name is the xml element name to use when configuring.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mention and provide a link to the common providers section somewhere in this paragraph.

Perhaps:

Suggested change
The table below lists the available providers for _AccessEvents_, and their configuration properties (defaults in parentheses).
The provider name is the xml element name to use when configuring.
The [common providers mentioned above](#providers-common-to-loggingevents-and-accessevents), and the providers listed in the table below, are available for _AccessEvents_.
The provider name is the xml element name to use when configuring. Each provider's configuration properties are shown, with default configuration values in parenthesis.

Refactor UuidProvider and associate utility classes to make them usable for both ILoggingEvent and IAccessEvent:
- create a new UuidJsonProvider by making a copy of the existing UuidProvider (restricted to ILoggingEvent)
- deprecate the existing UuidProvider in favour of the common UuidJsonProvider
- move the LoggingEventJsonProviders#addUuid() method into the common JsonProviders class

Closes #662
…vent

Refactor SequenceJsonProvider and associate utility classes to make them usable for both ILoggingEvent and IAccessEvent:
- create a new SequenceJsonProvider by making a copy of the existing SequenceJsonProvider (restricted to ILoggingEvent)
- deprecate the existing SequenceJsonProvider in favour of the new common SequenceJsonProvider
- move LoggingEventJsonProviders#addSequence() method into the common JsonProviders class

Closes #661
…sEvent

Refactor the existing ThreadNameJsonProvider and associate utility classes to make them usable for both ILoggingEvent and IAccessEvent.

Closes #660
Keep and deprecate existing `FormattedTimestampJsonProvider` class until next major version
These classes are now deprecated. Emit a WARN status if ever they are used in a XML configuration.
Rename `CompositeJsonFormatter` into `AbstractCompositeJsonFormatter` to comply with the "abstract" naming convention.
@brenuart brenuart force-pushed the gh662-refactor-providers-for-logging-and-access branch from e5ff137 to 2a25705 Compare September 29, 2021 11:52
@brenuart brenuart merged commit c87a732 into main Sep 29, 2021
@brenuart brenuart deleted the gh662-refactor-providers-for-logging-and-access branch September 29, 2021 11:59
@philsttr philsttr added this to the 7.0 milestone Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement warn/api-change Breaking change with compilation or xml configuration errors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants