Skip to content

RUM-3068 Add support for global attributes on logs#1900

Merged
fuzzybinary merged 5 commits into
developfrom
jward/RUM-3068-global-log-attributes
Mar 11, 2024
Merged

RUM-3068 Add support for global attributes on logs#1900
fuzzybinary merged 5 commits into
developfrom
jward/RUM-3068-global-log-attributes

Conversation

@fuzzybinary

Copy link
Copy Markdown
Member

What does this PR do?

Add a Logs.addAttribute and Logs.removeAttribute function to add attributes to all logs generated by Loggers created from a specific Core. Individual loggers and log events override global attributes.

These log attributes are also sent on unhandled exceptions and added to errors forwarded to RUM.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@fuzzybinary

Copy link
Copy Markdown
Member Author

Creating as Draft while I work on getting the NDK to report the global attributes.

@fuzzybinary
fuzzybinary force-pushed the jward/RUM-3068-global-log-attributes branch from 4abc7fb to e007dd8 Compare March 5, 2024 15:11
@fuzzybinary
fuzzybinary marked this pull request as ready for review March 5, 2024 15:11
@fuzzybinary
fuzzybinary requested review from a team as code owners March 5, 2024 15:11

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice job! I added a few comments, but overall lgtm.

Comment thread features/dd-sdk-android-logs/src/main/kotlin/com/datadog/android/log/Logs.kt Outdated
Comment thread features/dd-sdk-android-logs/src/main/kotlin/com/datadog/android/log/Logs.kt Outdated
Comment thread features/dd-sdk-android-logs/src/main/kotlin/com/datadog/android/log/Logs.kt Outdated
Comment thread features/dd-sdk-android-logs/src/test/kotlin/com/datadog/android/log/LogsTest.kt Outdated
Comment thread features/dd-sdk-android-logs/src/test/kotlin/com/datadog/android/log/LogsTest.kt Outdated
fuzzybinary and others added 3 commits March 5, 2024 10:50
Add a `Logs.addAttribute` and `Logs.removeAttribute` function to add attributes to all logs generated by Loggers created from a specific Core.  Individual loggers and log events override global attributes.

These log attributes are also sent on unhandled exceptions and added to errors forwarded to RUM.

Still need to add attributes to NDK crash logs.
Co-authored-by: Nikita Ogorodnikov <[email protected]>
@fuzzybinary
fuzzybinary force-pushed the jward/RUM-3068-global-log-attributes branch 2 times, most recently from 04ecc2c to 5fe9530 Compare March 5, 2024 15:51
@fuzzybinary
fuzzybinary force-pushed the jward/RUM-3068-global-log-attributes branch from 5fe9530 to 7606c1c Compare March 5, 2024 16:16

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm! I added one comment. Let's wait for the iOS counterpart review before the merge to be aligned.

Suppress unchecked cast warnings in tests.
@fuzzybinary
fuzzybinary force-pushed the jward/RUM-3068-global-log-attributes branch from 1ca5984 to 4562a27 Compare March 5, 2024 21:01
@codecov-commenter

codecov-commenter commented Mar 5, 2024

Copy link
Copy Markdown

Codecov Report

Merging #1900 (4562a27) into develop (0e3a8b0) will decrease coverage by 0.08%.
Report is 2 commits behind head on develop.
The diff coverage is 87.80%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1900      +/-   ##
===========================================
- Coverage    83.44%   83.36%   -0.08%     
===========================================
  Files          477      477              
  Lines        16911    16943      +32     
  Branches      2512     2520       +8     
===========================================
+ Hits         14110    14123      +13     
- Misses        2113     2133      +20     
+ Partials       688      687       -1     
Files Coverage Δ
...in/com/datadog/android/log/internal/LogsFeature.kt 86.23% <88.89%> (+1.86%) ⬆️
...gs/src/main/kotlin/com/datadog/android/log/Logs.kt 84.62% <88.89%> (+9.62%) ⬆️
...g/android/log/internal/logger/DatadogLogHandler.kt 77.31% <85.71%> (-0.17%) ⬇️

... and 29 files with indirect coverage changes

*/
@JvmOverloads
@JvmStatic
fun addAttribute(key: String, value: Any?, sdkCore: SdkCore = Datadog.getInstance()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we accept Any? or just Any ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I kept it in line with Logger's interface which accepts Any?

@fuzzybinary
fuzzybinary merged commit 889d903 into develop Mar 11, 2024
@fuzzybinary
fuzzybinary deleted the jward/RUM-3068-global-log-attributes branch March 11, 2024 20:47
@xgouchet xgouchet added this to the 2.7.0 milestone Apr 5, 2024
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.

5 participants