-
Notifications
You must be signed in to change notification settings - Fork 337
🪞 9979 - Record detailed instrumentation errors during tests #10300
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
372bb59
ExceptionHandlers: Fix code in bytecode comment
deejgregor 7dfea07
InstrumentationContext: be more explicit about the reasons for failure
deejgregor 2ab845d
Add instrumentation error details on test failures
deejgregor 4f536b7
Check for blocked instrumentation in tests
deejgregor ca324ef
Fail fast on muzzle or instrumentation errors
deejgregor 18644fc
revert asserting muzzle failures in instrumentation tests
amarziali b406b8c
Avoid allocating a stack argument if errors are not recorded
amarziali e62fb2a
Merge branch 'master' into community-pr-9979
mcculls b8b926b
Merge branch 'master' into community-pr-9979
mcculls 6a3c897
Merge branch 'master' into community-pr-9979
mcculls 32bb9fa
Rework recording of detailed instrumentation errors
mcculls 8832e44
Merge remote-tracking branch 'origin/master' into community-pr-9979
mcculls 25f0c47
Update comment
mcculls 0239cff
Update ClassFileTransformerListener to use InstrumentationErrors
mcculls 40eae5d
Clean-up reporting of instrumentation errors (installation vs per-test)
mcculls 83b1043
Enable detailed instrumentation errors for AbstractInstrumentationTest
mcculls 8666b1a
Fix metadata/supported-configurations.json
mcculls 8089ad5
Reset InstrumentationErrors before setupSpec
mcculls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 45 additions & 5 deletions
50
...va-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/InstrumentationErrors.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,61 @@ | ||
| package datadog.trace.bootstrap; | ||
|
|
||
| import java.io.PrintWriter; | ||
| import java.io.StringWriter; | ||
| import java.util.List; | ||
| import java.util.concurrent.CopyOnWriteArrayList; | ||
| import java.util.concurrent.atomic.AtomicLong; | ||
|
|
||
| public class InstrumentationErrors { | ||
| private static final AtomicLong COUNTER = new AtomicLong(); | ||
|
|
||
| public static long getErrorCount() { | ||
| return COUNTER.get(); | ||
| private static final class Detailed { | ||
| static final List<String> ERRORS = new CopyOnWriteArrayList<>(); | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static void incrementErrorCount() { | ||
| private static volatile boolean detailed; | ||
|
|
||
| /** Record an error occurred without any detail about it. */ | ||
| public static void recordError() { | ||
| COUNTER.incrementAndGet(); | ||
| } | ||
|
|
||
| /** Record an error occurred, including its stack trace. */ | ||
| public static Throwable recordError(Throwable error) { | ||
| COUNTER.incrementAndGet(); | ||
| StringWriter detail = new StringWriter(); | ||
| error.printStackTrace(new PrintWriter(detail)); | ||
| Detailed.ERRORS.add(detail.toString()); | ||
| detailed = true; | ||
| return error; // keep throwable at top of the stack | ||
| } | ||
|
|
||
| // Visible for testing | ||
| public static void resetErrorCount() { | ||
| public static void resetErrors() { | ||
| COUNTER.set(0); | ||
| if (detailed) { | ||
| Detailed.ERRORS.clear(); | ||
| detailed = false; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @return {@code true} if no errors were recorded; otherwise {@code false} | ||
| */ | ||
| public static boolean noErrors() { | ||
| return COUNTER.get() == 0; | ||
| } | ||
|
|
||
| /** | ||
| * @return a human-readable description of the errors recorded so far | ||
| */ | ||
| public static String describeErrors() { | ||
| StringBuilder buf = new StringBuilder().append(COUNTER.get()).append(" instrumentation errors"); | ||
|
mcculls marked this conversation as resolved.
|
||
| if (detailed) { | ||
| for (String error : Detailed.ERRORS) { | ||
| buf.append("\n---\n").append(error); | ||
| } | ||
| } | ||
| return buf.toString(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.