Skip to content

Conversation

lcian
Copy link
Member

@lcian lcian commented Oct 7, 2025

📜 Description

  • Attach properties from MDC to logs as attributes.
  • Consider the options.contextTags property as an allow-list for which properties to attach.
  • Refactor the duplicate logic to apply MDC to events and logs into a LoggerPropertiesUtil class.

💡 Motivation and Context

Close #4783
Close JAVA-197

💚 How did you test it?

Unit tests.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

@lcian lcian force-pushed the lcian/feat/mdc-logs branch from 4fa3eaf to b10a3b4 Compare October 7, 2025 08:25
Copy link
Contributor

github-actions bot commented Oct 7, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 357.20 ms 424.81 ms 67.61 ms
Size 1.58 MiB 2.11 MiB 539.76 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ee747ae 374.71 ms 455.18 ms 80.47 ms
9fbb112 401.87 ms 515.87 ms 114.00 ms
c8125f3 397.65 ms 485.14 ms 87.49 ms
c8125f3 383.82 ms 441.66 ms 57.84 ms
ee747ae 357.79 ms 421.84 ms 64.05 ms
ce0a49e 532.00 ms 609.96 ms 77.96 ms
b3d8889 371.69 ms 432.96 ms 61.26 ms
889ecea 367.58 ms 437.52 ms 69.94 ms
b750b96 421.25 ms 444.09 ms 22.84 ms
3d205d0 352.15 ms 432.53 ms 80.38 ms

App size

Revision Plain With Sentry Diff
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
c8125f3 1.58 MiB 2.10 MiB 532.32 KiB
c8125f3 1.58 MiB 2.10 MiB 532.32 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
ce0a49e 1.58 MiB 2.10 MiB 532.94 KiB
b3d8889 1.58 MiB 2.10 MiB 535.06 KiB
889ecea 1.58 MiB 2.11 MiB 539.75 KiB
b750b96 1.58 MiB 2.10 MiB 533.20 KiB
3d205d0 1.58 MiB 2.10 MiB 532.97 KiB

Previous results on branch: lcian/feat/mdc-logs

Startup times

Revision Plain With Sentry Diff
9b37b7e 474.85 ms 539.58 ms 64.73 ms
60b38dd 371.02 ms 439.54 ms 68.52 ms
8eb9638 352.96 ms 433.26 ms 80.30 ms
0751889 371.21 ms 442.88 ms 71.67 ms
f9e3924 351.51 ms 447.96 ms 96.45 ms
18fec33 381.39 ms 464.69 ms 83.30 ms
4fd0d5d 422.43 ms 473.47 ms 51.04 ms
0cfa2ae 427.47 ms 507.46 ms 79.99 ms
b0d6d12 381.21 ms 410.46 ms 29.25 ms
6a3a87d 370.96 ms 433.26 ms 62.30 ms

App size

Revision Plain With Sentry Diff
9b37b7e 1.58 MiB 2.11 MiB 539.70 KiB
60b38dd 1.58 MiB 2.11 MiB 538.89 KiB
8eb9638 1.58 MiB 2.11 MiB 539.17 KiB
0751889 1.58 MiB 2.11 MiB 538.88 KiB
f9e3924 1.58 MiB 2.11 MiB 538.89 KiB
18fec33 1.58 MiB 2.11 MiB 539.17 KiB
4fd0d5d 1.58 MiB 2.11 MiB 539.18 KiB
0cfa2ae 1.58 MiB 2.11 MiB 539.70 KiB
b0d6d12 1.58 MiB 2.11 MiB 538.89 KiB
6a3a87d 1.58 MiB 2.11 MiB 539.70 KiB

Copy link

linear bot commented Oct 7, 2025

@adinauer
Copy link
Member

adinauer commented Oct 8, 2025

I would prefer if we also use options.contextTags for log attributes since that way it's consistent with what we do for events. Also starting to send it without opt-in would be something for a major version.

As a first step, I'd just add all MDC values according to options.contextTags.
We could then add support for regex to contextTags and in the next major default contextTags to a regex that simply matches everything.

@lcian lcian force-pushed the lcian/feat/mdc-logs branch from 381701f to 38b07b7 Compare October 8, 2025 07:52
@lcian
Copy link
Member Author

lcian commented Oct 8, 2025

I would prefer if we also use options.contextTags for log attributes since that way it's consistent with what we do for events. Also starting to send it without opt-in would be something for a major version.

As a first step, I'd just add all MDC values according to options.contextTags. We could then add support for regex to contextTags and in the next major default contextTags to a regex that simply matches everything.

Yeah that makes sense, changed it.

@lcian lcian marked this pull request as ready for review October 8, 2025 09:03
cursor[bot]

This comment was marked as outdated.

Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

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

Looking good, I've left two comments

lcian and others added 2 commits October 8, 2025 14:54
Co-authored-by: Markus Hintersteiner <markus.hintersteiner@sentry.io>
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@lcian lcian requested review from adinauer and removed request for adinauer October 14, 2025 11:26
cursor[bot]

This comment was marked as outdated.

@lcian lcian requested a review from adinauer October 15, 2025 13:24
Copy link
Member

@adinauer adinauer left a comment

Choose a reason for hiding this comment

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

LGTM

@lcian lcian disabled auto-merge October 17, 2025 09:28
@lcian lcian enabled auto-merge (squash) October 17, 2025 09:28
@lcian lcian merged commit d364ace into main Oct 17, 2025
60 of 61 checks passed
@lcian lcian deleted the lcian/feat/mdc-logs branch October 17, 2025 09:44
@lcian lcian mentioned this pull request Oct 17, 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.

MDC tag information not added to logs.

4 participants