log4j spring boot 4 autoinstrumentation#5403
Conversation
📲 Install BuildsAndroid
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| eb95ded | 317.51 ms | 369.08 ms | 51.57 ms |
| 2124a46 | 319.19 ms | 415.04 ms | 95.85 ms |
| c3ee041 | 310.64 ms | 361.90 ms | 51.26 ms |
| dcc6bbf | 382.58 ms | 462.13 ms | 79.54 ms |
| 7a19fee | 315.46 ms | 368.62 ms | 53.16 ms |
| 9054d65 | 330.94 ms | 403.24 ms | 72.30 ms |
| d500866 | 326.13 ms | 378.70 ms | 52.58 ms |
| ad8da22 | 365.86 ms | 427.00 ms | 61.14 ms |
| ed33deb | 337.52 ms | 484.06 ms | 146.54 ms |
| d15471f | 310.26 ms | 377.04 ms | 66.78 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| eb95ded | 0 B | 0 B | 0 B |
| 2124a46 | 1.58 MiB | 2.12 MiB | 551.51 KiB |
| c3ee041 | 0 B | 0 B | 0 B |
| dcc6bbf | 1.58 MiB | 2.12 MiB | 553.10 KiB |
| 7a19fee | 0 B | 0 B | 0 B |
| 9054d65 | 1.58 MiB | 2.29 MiB | 723.38 KiB |
| d500866 | 0 B | 0 B | 0 B |
| ad8da22 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| ed33deb | 1.58 MiB | 2.13 MiB | 559.52 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
Previous results on branch: feat/log4j-autoinstrumentation
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c488aa4 | 392.38 ms | 468.44 ms | 76.06 ms |
| e13dc15 | 377.54 ms | 433.90 ms | 56.36 ms |
| 6f3172f | 504.00 ms | 585.84 ms | 81.84 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c488aa4 | 0 B | 0 B | 0 B |
| e13dc15 | 0 B | 0 B | 0 B |
| 6f3172f | 0 B | 0 B | 0 B |
… loggers to attach to
|
@sentry review |
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7d76aa5. Configure here.
|
@adinauer should we add a separate spring-boot-log4j sample for e2e tets? |
adinauer
left a comment
There was a problem hiding this comment.
Mostly LGTM, just needs to be opt-in for now, to not break manual setups on upgrade. Separate sample + E2E tests sounds good
Co-authored-by: Alexander Dinauer <adinauer@users.noreply.github.com>
| private boolean isSentryAppenderRegistered(final @NotNull LoggerConfig loggerConfig) { | ||
| return loggerConfig.getAppenders().values().stream() | ||
| .anyMatch(appender -> appender.getClass().equals(SentryAppender.class)); | ||
| } |
There was a problem hiding this comment.
Incomplete existing appender check
Medium Severity
isSentryAppenderRegistered only looks at the target logger and requires an exact SentryAppender class match. A manually configured appender on another logger, or a subclass, does not block auto-registration, so a second appender can still be added. That conflicts with the changelog claim that existing manual SentryAppender setup takes precedence.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 53f53f6. Configure here.
…move log4j dependencies in spring-boot-4 sample
| ISpan currentSpan = Sentry.getSpan(); | ||
| ISpan sentrySpan = currentSpan.startChild("spanCreatedThroughSentryApi"); | ||
| try { |
There was a problem hiding this comment.
Bug: The result of Sentry.getSpan() is used without a null check. This can cause a NullPointerException as the method is annotated with @Nullable.
Severity: MEDIUM
Suggested Fix
Add a null check after calling Sentry.getSpan() and before calling .startChild() on the result. Only proceed to create a child span if the currentSpan is not null. For example: if (currentSpan != null) { ISpan sentrySpan = currentSpan.startChild("..."); }.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
sentry-samples/sentry-samples-spring-boot-4-log4j2/src/main/java/io/sentry/samples/spring/boot4/PersonController.java#L27-L29
Potential issue: The `Sentry.getSpan()` method is annotated with `@Nullable`, indicating
it can return `null`. However, the code in `PersonController.java` directly calls
`.startChild()` on the returned `ISpan` object without a null check. This will cause a
`NullPointerException` if no active Sentry transaction is present. This can occur under
realistic conditions, such as when tracing is disabled (e.g.,
`sentry.traces-sample-rate=0`), the Sentry DSN is missing, or if the
`SentryTracingFilter` fails to initialize.
Also affects:
sentry-samples/sentry-samples-spring-boot-4-log4j2/src/main/java/io/sentry/samples/spring/boot4/PersonController.java:47~48
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4362c07. Configure here.
|
|
||
| final LoggerConfig newLoggerConfig = new LoggerConfig(loggerName, null, true); | ||
| newLoggerConfig.setParent(loggerConfig); | ||
| configuration.addLogger(loggerName, newLoggerConfig); |
There was a problem hiding this comment.
Duplicate events with nested loggers
Medium Severity
Newly created logger configs always use additive=true. When both ROOT and a child logger are listed—as in the changelog example—and the child config does not already exist, the same log event is delivered to SentryAppender on the child and again on ROOT via additivity, producing duplicate events, breadcrumbs, and structured logs.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4362c07. Configure here.
|
@adinauer added the sample and e2e tests |


📜 Description
💡 Motivation and Context
resolves: #5035
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps