diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/JfrDiEvent.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/JfrDiEvent.java new file mode 100644 index 00000000000..54d81b25c4e --- /dev/null +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/JfrDiEvent.java @@ -0,0 +1,28 @@ +package org.eclipse.e4.core.internal.di; + +import jdk.jfr.Category; +import jdk.jfr.Event; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.StackTrace; + +@Name("DIEvent") +@Label("Inject") +@Category({ "Eclipse", "Platform", "DI" }) +@StackTrace(false) +public class JfrDiEvent extends Event { + + @Label("target") + String target; + + @Label("arguments") + String arguments; + + public static final ThreadLocal EVENT = new ThreadLocal<>() { + @Override + protected JfrDiEvent initialValue() { + return new JfrDiEvent(); + } + }; + +} diff --git a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java index 49d906f319d..60f7566e112 100644 --- a/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java +++ b/runtime/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/MethodRequestor.java @@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; +import java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; @@ -54,6 +55,12 @@ public Object execute() throws InjectionException { primarySupplier.pauseRecording(); pausedRecording = true; } + ThreadLocal jfrDIEvent = JfrDiEvent.EVENT; + if (jfrDIEvent.get().isEnabled()) { + jfrDIEvent.get().target = this.toString(); + jfrDIEvent.get().arguments = Arrays.toString(actualArgs); + jfrDIEvent.get().begin(); + } try { result = location.invoke(userObject, actualArgs); } catch (IllegalArgumentException | IllegalAccessException e) { @@ -70,6 +77,10 @@ public Object execute() throws InjectionException { if (pausedRecording) primarySupplier.resumeRecording(); clearResolvedArgs(); + if (jfrDIEvent.get().isEnabled()) { + jfrDIEvent.get().end(); + jfrDIEvent.get().commit(); + } } return result; }