GeezerVison is showing github.com — Fix suspend Kotlin methods instrumentation by jpbempel · Pull Request #8080 · DataDog/dd-trace-java
Fix suspend Kotlin methods instrumentation
#8080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter
Filter by extension
.java
(5)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
add config for local var hoisting
enable only hoisting for java language
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit f86bd77ed804ac5c6b2450e9aadf9ff8328ebe2e
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -396,7 +396,11 @@ private void instrumentMethodEnter() {
if (methodNode.tryCatchBlocks.size() > 0) {
throwableListVar = declareThrowableList(insnList);
}
unscopedLocalVars = initAndHoistLocalVars(insnList);
unscopedLocalVars = Collections.emptyList();
if (Config.get().isDebuggerHoistLocalVarsEnabled() && language == JvmLanguage.JAVA) {
// for now, only hoist local vars for Java
unscopedLocalVars = initAndHoistLocalVars(insnList);
}
insnList.add(contextInitLabel);
if (definition instanceof SpanDecorationProbe
&& definition.getEvaluateAt() == MethodLocation.EXIT) {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -46,6 +46,7 @@ public abstract class Instrumentor {
protected int localVarBaseOffset;
protected int argOffset;
protected final LocalVariableNode[] localVarsBySlotArray;
protected final JvmLanguage language;
protected LabelNode returnHandlerLabel;
protected final List<CapturedContextInstrumentor.FinallyBlock> finallyBlocks = new ArrayList<>();
Expand All
@@ -69,6 +70,7 @@ public Instrumentor(
argOffset += t.getSize();
}
localVarsBySlotArray = extractLocalVariables(argTypes);
this.language = JvmLanguage.of(classNode);
}
public abstract InstrumentationResult.Status instrument();
Expand Down
Expand Up
@@ -294,4 +296,31 @@ public FinallyBlock(LabelNode startLabel, LabelNode endLabel, LabelNode handlerL
this.handlerLabel = handlerLabel;
}
}
protected enum JvmLanguage {
JAVA,
KOTLIN,
SCALA,
GROOVY,
UNKNOWN;
public static JvmLanguage of(ClassNode classNode) {
if (classNode.sourceFile == null) {
return UNKNOWN;
}
if (classNode.sourceFile.endsWith(".java")) {
return JAVA;
}
if (classNode.sourceFile.endsWith(".kt")) {
return KOTLIN;
}
if (classNode.sourceFile.endsWith(".scala")) {
return SCALA;
}
if (classNode.sourceFile.endsWith(".groovy")) {
return GROOVY;
}
return UNKNOWN;
}
}
}
Original file line number
Diff line number
Diff line change
Expand Up
@@ -179,6 +179,7 @@ public final class ConfigDefaults {
static final boolean DEFAULT_DEBUGGER_VERIFY_BYTECODE = true;
static final boolean DEFAULT_DEBUGGER_INSTRUMENT_THE_WORLD = false;
static final int DEFAULT_DEBUGGER_CAPTURE_TIMEOUT = 100; // milliseconds
static final boolean DEFAULT_DEBUGGER_HOIST_LOCALVARS_ENABLED = true;
static final boolean DEFAULT_DEBUGGER_SYMBOL_ENABLED = true;
static final boolean DEFAULT_DEBUGGER_SYMBOL_FORCE_UPLOAD = false;
static final int DEFAULT_DEBUGGER_SYMBOL_FLUSH_THRESHOLD = 100; // nb of classes
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -28,6 +28,8 @@ public final class DebuggerConfig {
public static final String DEBUGGER_REDACTION_EXCLUDED_IDENTIFIERS =
"dynamic.instrumentation.redaction.excluded.identifiers";
public static final String DEBUGGER_REDACTED_TYPES = "dynamic.instrumentation.redacted.types";
public static final String DEBUGGER_HOIST_LOCALVARS_ENABLED =
"dynamic.instrumentation.hoist.localvars.enabled";
public static final String DEBUGGER_SYMBOL_ENABLED = "symbol.database.upload.enabled";
public static final String DEBUGGER_SYMBOL_FORCE_UPLOAD = "internal.force.symbol.database.upload";
public static final String DEBUGGER_SYMBOL_INCLUDES = "symbol.database.includes";
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -394,6 +394,7 @@ public static String getHostName() {
private final String debuggerRedactedIdentifiers;
private final Set<String> debuggerRedactionExcludedIdentifiers;
private final String debuggerRedactedTypes;
private final boolean debuggerHoistLocalVarsEnabled;
private final boolean debuggerSymbolEnabled;
private final boolean debuggerSymbolForceUpload;
private final String debuggerSymbolIncludes;
Expand Down
Expand Up
@@ -1526,6 +1527,9 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
debuggerRedactionExcludedIdentifiers =
tryMakeImmutableSet(configProvider.getList(DEBUGGER_REDACTION_EXCLUDED_IDENTIFIERS));
debuggerRedactedTypes = configProvider.getString(DEBUGGER_REDACTED_TYPES, null);
debuggerHoistLocalVarsEnabled =
configProvider.getBoolean(
DEBUGGER_HOIST_LOCALVARS_ENABLED, DEFAULT_DEBUGGER_HOIST_LOCALVARS_ENABLED);
debuggerSymbolEnabled =
configProvider.getBoolean(DEBUGGER_SYMBOL_ENABLED, DEFAULT_DEBUGGER_SYMBOL_ENABLED);
debuggerSymbolForceUpload =
Expand Down
Expand Up
@@ -3042,6 +3046,10 @@ public String getDebuggerRedactedTypes() {
return debuggerRedactedTypes;
}
public boolean isDebuggerHoistLocalVarsEnabled() {
return debuggerHoistLocalVarsEnabled;
}
public boolean isAwsPropagationEnabled() {
return awsPropagationEnabled;
}
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.