This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e5549c9e37c0ef7461ba18d0551df68107fe1c56 Author: Benoit Tellier <[email protected]> AuthorDate: Fri Jun 4 21:31:34 2021 +0700 [PERFORMANCE] MetricFactory: avoid needlessly Flux.from wrapping --- .../org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java | 4 ++-- .../java/org/apache/james/metrics/logger/DefaultMetricFactory.java | 4 ++-- .../java/org/apache/james/metrics/tests/RecordingMetricFactory.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java b/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java index 55ce523..2daf91a 100644 --- a/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java +++ b/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java @@ -65,14 +65,14 @@ public class DropWizardMetricFactory implements MetricFactory, Startable { @Override public <T> Publisher<T> decoratePublisherWithTimerMetric(String name, Publisher<T> publisher) { return Flux.using(() -> timer(name), - any -> Flux.from(publisher), + any -> publisher, DropWizardTimeMetric::stopAndPublish); } @Override public <T> Publisher<T> decoratePublisherWithTimerMetricLogP99(String name, Publisher<T> publisher) { return Flux.using(() -> timer(name), - any -> Flux.from(publisher), + any -> publisher, timer -> timer.stopAndPublish().logWhenExceedP99(DEFAULT_100_MS_THRESHOLD)); } diff --git a/metrics/metrics-logger/src/main/java/org/apache/james/metrics/logger/DefaultMetricFactory.java b/metrics/metrics-logger/src/main/java/org/apache/james/metrics/logger/DefaultMetricFactory.java index b253392..e81376b 100644 --- a/metrics/metrics-logger/src/main/java/org/apache/james/metrics/logger/DefaultMetricFactory.java +++ b/metrics/metrics-logger/src/main/java/org/apache/james/metrics/logger/DefaultMetricFactory.java @@ -46,14 +46,14 @@ public class DefaultMetricFactory implements MetricFactory { @Override public <T> Publisher<T> decoratePublisherWithTimerMetric(String name, Publisher<T> publisher) { return Flux.using(() -> timer(name), - any -> Flux.from(publisher), + any -> publisher, TimeMetric::stopAndPublish); } @Override public <T> Publisher<T> decoratePublisherWithTimerMetricLogP99(String name, Publisher<T> publisher) { return Flux.using(() -> timer(name), - any -> Flux.from(publisher), + any -> publisher, timer -> timer.stopAndPublish().logWhenExceedP99(DEFAULT_100_MS_THRESHOLD)); } } diff --git a/metrics/metrics-tests/src/main/java/org/apache/james/metrics/tests/RecordingMetricFactory.java b/metrics/metrics-tests/src/main/java/org/apache/james/metrics/tests/RecordingMetricFactory.java index f355e56..27303b0 100644 --- a/metrics/metrics-tests/src/main/java/org/apache/james/metrics/tests/RecordingMetricFactory.java +++ b/metrics/metrics-tests/src/main/java/org/apache/james/metrics/tests/RecordingMetricFactory.java @@ -64,14 +64,14 @@ public class RecordingMetricFactory implements MetricFactory { @Override public <T> Publisher<T> decoratePublisherWithTimerMetric(String name, Publisher<T> publisher) { return Flux.using(() -> timer(name), - any -> Flux.from(publisher), + any -> publisher, TimeMetric::stopAndPublish); } @Override public <T> Publisher<T> decoratePublisherWithTimerMetricLogP99(String name, Publisher<T> publisher) { return Flux.using(() -> timer(name), - any -> Flux.from(publisher), + any -> publisher, timer -> timer.stopAndPublish().logWhenExceedP99(DEFAULT_100_MS_THRESHOLD)); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
