Skip to content

Conversation

@pugnascotia
Copy link
Contributor

Closes #64824. Introduce the concept of categories to deprecation logging. Every location where we log a deprecation message must now include a deprecation category.

See also #67266.

All opinions welcome on the categories I've used here. I'd be very happy to shrink the number here, but I also don't want the categories to be so broad as to be meaningless.

Note that I probably won't directly backport this - instead, I expect I'll have to reapply the DeprecationMessage change and then go through all the call sites again.

@pugnascotia pugnascotia requested a review from rjernst January 13, 2021 14:51
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jan 13, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@jdconrad jdconrad left a comment

Choose a reason for hiding this comment

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

@pugnascotia I wonder if we should add more categories such as "plugin" or "parsing" since those would cover a lot of the "other" category if we consider most of the date deprecations as parsing issues.

Copy link
Contributor

@pgomulka pgomulka left a comment

Choose a reason for hiding this comment

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

I left one comment, but it looks good to me

*/
public DeprecationLoggerBuilder deprecate(final String key, final String msg, final Object... params) {
return new DeprecationLoggerBuilder().withDeprecation(key, msg, params);
public DeprecationLoggerBuilder deprecate(
Copy link
Contributor

Choose a reason for hiding this comment

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

btw do you think it would be worthy to make this method work in a "fluent" way?
I initialliy thought that deprecation logger could be used like

deprecationLogger.deprecate("msg")
.compatibleWarning("msg2")

The compatible logger is still not merged (going to be soon I hope), but maybe we could use the builder here?
I am worried about the performance and we won't be creating too much objects here though..
WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow - deprecationLogger.deprecate(...) already returns a DeprecationLoggerBuilder, so isn't it already fluent?

/**
* Deprecation log messages are categorised so that consumers of the logs can easily aggregate them.
*/
public enum DeprecationCategory {
Copy link
Contributor

Choose a reason for hiding this comment

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

would would it make any sense for this to be an interface and some of the categories to be defined in server and some in plugins/xpack?
We will be using deprecations a lot in x-pack/rest-compatible plugin and I wonder if we should be adding all the categories from plugins here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about doing that, as the categories ought to be reasonable general and not too fine-grained. We could change the implementation later if we feel that we do need more flexibility.

@pugnascotia
Copy link
Contributor Author

Thanks @jdconrad, I've added the categories that you suggested.

@rjernst are you at all interested in checking over this?

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM, one minor question

.field("ecs.version", ECS_VERSION)
.field("key", key);
.field("key", key)
.field("elasticsearch.event.category", category.name().toLowerCase(Locale.ROOT));
Copy link
Member

Choose a reason for hiding this comment

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

Why not just category? Is this ECS related?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the broader change is in #67266.

@pugnascotia pugnascotia merged commit 1a05a5a into elastic:master Jan 18, 2021
@pugnascotia pugnascotia deleted the 64824-deprecation-category branch January 18, 2021 16:16
pugnascotia added a commit to pugnascotia/elasticsearch that referenced this pull request Jan 27, 2021
Sort-of backport of elastic#67443.

Closes elastic#64824. Introduce the concept of categories to deprecation
logging. Every location where we log a deprecation message must now
include a deprecation category.
pugnascotia added a commit that referenced this pull request Jan 29, 2021
Sort-of backport of #67443.

Closes #64824. Introduce the concept of categories to deprecation
logging. Every location where we log a deprecation message must now
include a deprecation category.
pgomulka added a commit that referenced this pull request Oct 18, 2021
Deprecation logs in 7.x are using ESJsonLayout and it requires
additional fields to be declared in a log4j config in order to emit
values to logs.
This commit adds category field to deprecation log pattern

context: in 8.0 we use ECSLayout which do not require to declare additional fields upfront. In 7.x we have to declare them in the logging config. The PR introducing categories in master #67443. A backport to 7.x which missed this field #68061
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Logging Log management and logging utilities >enhancement Team:Core/Infra Meta label for core/infra team v7.12.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should we include a category with deprecation messages?

6 participants