Skip to content

Conversation

@markushi
Copy link
Member

📜 Description

Add another test to verify that #4484 should be working as expected. Also ran it locally against the Timber 5.0.1 and still can not reproduce the issue.

#skip-changelog

Comment on lines +143 to 153
fun `Tree captures an event with TimberTag tag for debug events`() {
val sut = fixture.getSut(minEventLevel = SentryLevel.INFO)
Timber.plant(sut)
// only available thru static class
Timber.tag("infoTag").i("message")
verify(fixture.scopes).captureEvent(check { assertEquals("infoTag", it.getTag("TimberTag")) })
}

@Test
fun `Tree captures an event without TimberTag tag`() {
val sut = fixture.getSut()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: SentryTimberTree.log() fails to capture events when Timber's chained API is used, only setting pendingTag.
Severity: HIGH | Confidence: 1.00

🔍 Detailed Analysis

When Timber's chained API, such as Timber.tag("tag").i("message"), is used, the SentryTimberTree.log(priority: Int, tag: String?, message: String, t: Throwable?) method is invoked. This method only sets the pendingTag in a ThreadLocal but does not proceed with the actual logging by calling super.log() or logWithSentry(). Consequently, no event is captured by Sentry for these chained logging calls, leading to missing log data.

💡 Suggested Fix

Modify SentryTimberTree.log() to invoke the actual logging logic (e.g., logWithSentry()) after setting the pendingTag when Timber's chained API is used.

🤖 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-android-timber/src/test/java/io/sentry/android/timber/SentryTimberTreeTest.kt#L139-L153

Potential issue: When Timber's chained API, such as `Timber.tag("tag").i("message")`, is
used, the `SentryTimberTree.log(priority: Int, tag: String?, message: String, t:
Throwable?)` method is invoked. This method only sets the `pendingTag` in a ThreadLocal
but does not proceed with the actual logging by calling `super.log()` or
`logWithSentry()`. Consequently, no event is captured by Sentry for these chained
logging calls, leading to missing log data.

Did we get this right? 👍 / 👎 to inform future reviews.

@markushi
Copy link
Member Author

Closing in favor of #4844

@markushi markushi closed this Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants