From 304a53f931a781a5140538c00350d11798187cc3 Mon Sep 17 00:00:00 2001 From: skerdudou Date: Thu, 6 Jun 2024 15:30:09 +0200 Subject: [PATCH] Update TracerProviderUtil.java fr > en --- .../analytics/trace/TracerProviderUtil.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/vertigo-core/src/main/java/io/vertigo/core/impl/analytics/trace/TracerProviderUtil.java b/vertigo-core/src/main/java/io/vertigo/core/impl/analytics/trace/TracerProviderUtil.java index a93f219ab..09d485e05 100644 --- a/vertigo-core/src/main/java/io/vertigo/core/impl/analytics/trace/TracerProviderUtil.java +++ b/vertigo-core/src/main/java/io/vertigo/core/impl/analytics/trace/TracerProviderUtil.java @@ -26,6 +26,9 @@ import io.vertigo.core.analytics.trace.Tracer; import io.vertigo.core.lang.Assertion; +/** + * Utility class for providing Tracer instances. + */ public final class TracerProviderUtil { private TracerProviderUtil() { @@ -33,11 +36,19 @@ private TracerProviderUtil() { } /** - * Processus binde sur le thread courant. Le processus , recoit les notifications des sondes placees dans le code de - * l'application pendant le traitement d'une requete (thread). + * Process bound to the current thread. The process receives notifications from probes placed in the application code + * during the processing of a request (thread). */ private static final ThreadLocal> THREAD_LOCAL_PROCESS = new ThreadLocal<>(); + /** + * Traces the execution of a block of code. + * + * @param category the category of the trace + * @param name the name of the trace + * @param consumer the block of code to trace + * @param onCloseConsumer the action to perform when the trace is closed + */ public static void trace(final String category, final String name, final Consumer consumer, final Consumer onCloseConsumer) { try (TracerImpl tracer = createTracer(category, name, onCloseConsumer)) { try { @@ -50,6 +61,15 @@ public static void trace(final String category, final String name, final Consume } } + /** + * Traces the execution of a block of code and returns a result. + * + * @param category the category of the trace + * @param name the name of the trace + * @param function the block of code to trace + * @param onCloseConsumer the action to perform when the trace is closed + * @return the result of the function + */ public static O traceWithReturn(final String category, final String name, final Function function, final Consumer onCloseConsumer) { try (final TracerImpl tracer = createTracer(category, name, onCloseConsumer)) { try { @@ -63,6 +83,11 @@ public static O traceWithReturn(final String category, final String name, fi } } + /** + * Returns the current Tracer instance, if one exists. + * + * @return an Optional containing the current Tracer, or an empty Optional if none exists + */ public static Optional getCurrentTracer() { // When collect feature is enabled return doGetCurrentTracer().map(Function.identity()); // convert impl to api