Reduce deprecation log noise from DateIntervalWrapper (#52655)

Converts the deprecations to `deprecatedAndMaybeLog` to reduce the
number of times we log deprecations, since some of these could be called
at a high frequency (due to unconverted queries, aggs, etc)
This commit is contained in:
Zachary Tong 2020-03-03 17:07:40 -05:00 committed by Zachary Tong
parent c610e0893d
commit 3fcf598b92
1 changed files with 4 additions and 4 deletions

View File

@ -137,7 +137,7 @@ public class DateIntervalWrapper implements ToXContentFragment, Writeable {
/** Get the current interval in milliseconds that is set on this builder. */
@Deprecated
public long interval() {
DEPRECATION_LOGGER.deprecated(DEPRECATION_TEXT);
DEPRECATION_LOGGER.deprecatedAndMaybeLog("date-interval-getter", DEPRECATION_TEXT);
if (intervalType.equals(IntervalTypeEnum.LEGACY_INTERVAL)) {
return TimeValue.parseTimeValue(dateHistogramInterval.toString(), "interval").getMillis();
}
@ -158,14 +158,14 @@ public class DateIntervalWrapper implements ToXContentFragment, Writeable {
throw new IllegalArgumentException("[interval] must be 1 or greater for aggregation [date_histogram]");
}
setIntervalType(IntervalTypeEnum.LEGACY_INTERVAL);
DEPRECATION_LOGGER.deprecated(DEPRECATION_TEXT);
DEPRECATION_LOGGER.deprecatedAndMaybeLog("date-interval-setter", DEPRECATION_TEXT);
this.dateHistogramInterval = new DateHistogramInterval(interval + "ms");
}
/** Get the current date interval that is set on this builder. */
@Deprecated
public DateHistogramInterval dateHistogramInterval() {
DEPRECATION_LOGGER.deprecated(DEPRECATION_TEXT);
DEPRECATION_LOGGER.deprecatedAndMaybeLog("date-histogram-interval-getter", DEPRECATION_TEXT);
if (intervalType.equals(IntervalTypeEnum.LEGACY_DATE_HISTO)) {
return dateHistogramInterval;
}
@ -186,7 +186,7 @@ public class DateIntervalWrapper implements ToXContentFragment, Writeable {
throw new IllegalArgumentException("[dateHistogramInterval] must not be null: [date_histogram]");
}
setIntervalType(IntervalTypeEnum.LEGACY_DATE_HISTO);
DEPRECATION_LOGGER.deprecated(DEPRECATION_TEXT);
DEPRECATION_LOGGER.deprecatedAndMaybeLog("date-histogram-interval-setter", DEPRECATION_TEXT);
this.dateHistogramInterval = dateHistogramInterval;
}