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 370.96 ms 433.26 ms 62.30 ms
Size 1.58 MiB 2.11 MiB 539.70 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
23d6b12 354.10 ms 408.38 ms 54.28 ms
96449e8 361.30 ms 423.39 ms 62.09 ms
9fbb112 404.51 ms 475.65 ms 71.14 ms
ee747ae 396.82 ms 441.67 ms 44.86 ms
f634d01 375.06 ms 420.04 ms 44.98 ms
14ff5ee 419.75 ms 495.73 ms 75.98 ms
ee747ae 400.46 ms 423.61 ms 23.15 ms
806307f 357.85 ms 424.64 ms 66.79 ms
b750b96 421.25 ms 444.09 ms 22.84 ms
c8125f3 383.82 ms 441.66 ms 57.84 ms

App size

Revision Plain With Sentry Diff
23d6b12 1.58 MiB 2.10 MiB 532.31 KiB
96449e8 1.58 MiB 2.11 MiB 539.35 KiB
9fbb112 1.58 MiB 2.11 MiB 539.18 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
f634d01 1.58 MiB 2.10 MiB 533.40 KiB
14ff5ee 1.58 MiB 2.10 MiB 535.08 KiB
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
806307f 1.58 MiB 2.10 MiB 533.42 KiB
b750b96 1.58 MiB 2.10 MiB 533.20 KiB
c8125f3 1.58 MiB 2.10 MiB 532.32 KiB

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

Startup times

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

App size

Revision Plain With Sentry Diff
b0d6d12 1.58 MiB 2.11 MiB 538.89 KiB
18fec33 1.58 MiB 2.11 MiB 539.17 KiB
f9e3924 1.58 MiB 2.11 MiB 538.89 KiB
8eb9638 1.58 MiB 2.11 MiB 539.17 KiB
60b38dd 1.58 MiB 2.11 MiB 538.89 KiB
0751889 1.58 MiB 2.11 MiB 538.88 KiB
4fd0d5d 1.58 MiB 2.11 MiB 539.18 KiB
9b37b7e 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
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
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.

3 participants