Skip to content

Commit

Permalink
base for discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
col-panic committed Oct 9, 2023
1 parent 229beea commit 226f97e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<JfrDiEvent> EVENT = new ThreadLocal<>() {
@Override
protected JfrDiEvent initialValue() {
return new JfrDiEvent();
}
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +55,12 @@ public Object execute() throws InjectionException {
primarySupplier.pauseRecording();
pausedRecording = true;
}
ThreadLocal<JfrDiEvent> 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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 226f97e

Please sign in to comment.