Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUMM-1153: Possibility to attach custom attributes to automatically collected RUM Resource events #520

Conversation

0xnm
Copy link
Member

@0xnm 0xnm commented Mar 9, 2021

What does this PR do?

This change gives user a possibility to attach custom attributes to automatically collected RUM Resource events: either in the OkHttp flow, or in the WebView flow.

Attributes are collected after the resource call is completed (with either success or error outcome)

Additional Notes

Resources are also automatically collected here, but this part is not covered by this PR, because this class is low level and not sure if it is needed. Can be addressed in another PR if needed though.

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)

@0xnm 0xnm requested a review from a team as a code owner March 9, 2021 15:04
@xgouchet xgouchet added the size-medium This PR is medium sized label Mar 9, 2021
*/
open class DatadogInterceptor
internal constructor(
tracedHosts: List<String>,
tracedRequestListener: TracedRequestListener,
firstPartyHostDetector: FirstPartyHostDetector,
private val rumResourceAttributesProvider: RumResourceAttributesProvider =
Copy link
Member Author

Choose a reason for hiding this comment

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

it is not last in the argument list to keep lambda last to still have ctor() { lambda } syntax

.substringBeforeLast('.')
val noOpReturnType = ClassName(packageName, "NoOp${returnTypeDef.simpleName}")
funSpecBuilder.addStatement("return %T()", noOpReturnType)
val returnTypeElement = returnTypeDef as TypeElement
Copy link
Member

Choose a reason for hiding this comment

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

Nicely done

@codecov-io
Copy link

codecov-io commented Mar 9, 2021

Codecov Report

Merging #520 (6b40763) into master (5339f14) will decrease coverage by 0.09%.
The diff coverage is 65.22%.

@@             Coverage Diff              @@
##             master     #520      +/-   ##
============================================
- Coverage     89.49%   89.40%   -0.09%     
+ Complexity     1455     1451       -4     
============================================
  Files           167      167              
  Lines          5015     5030      +15     
  Branches        583      583              
============================================
+ Hits           4488     4497       +9     
- Misses          336      341       +5     
- Partials        191      192       +1     
Impacted Files Coverage Δ Complexity Δ
...n/kotlin/com/datadog/android/rum/RumInterceptor.kt 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../com/datadog/android/tracing/TracingInterceptor.kt 76.19% <0.00%> (ø) 33.00 <2.00> (ø)
...n/kotlin/com/datadog/android/DatadogInterceptor.kt 70.59% <60.00%> (-1.72%) 14.00 <0.00> (ø)
.../main/kotlin/com/datadog/android/rum/RumMonitor.kt 73.91% <100.00%> (+1.19%) 0.00 <0.00> (ø)
...g/android/rum/internal/domain/scope/RumRawEvent.kt 95.31% <100.00%> (+0.04%) 0.00 <0.00> (ø)
...roid/rum/internal/domain/scope/RumResourceScope.kt 93.92% <100.00%> (+0.04%) 44.00 <0.00> (ø)
.../android/rum/internal/monitor/DatadogRumMonitor.kt 96.12% <100.00%> (+0.24%) 42.00 <0.00> (ø)
...om/datadog/android/rum/webview/RumWebViewClient.kt 100.00% <100.00%> (ø) 18.00 <1.00> (+1.00)
...oid/src/main/kotlin/com/datadog/android/Datadog.kt 87.65% <0.00%> (-2.47%) 30.00% <0.00%> (-2.00%)
...dog/android/core/internal/data/file/FileHandler.kt 93.44% <0.00%> (-1.64%) 14.00% <0.00%> (-1.00%)
... and 8 more

@0xnm 0xnm force-pushed the nogorodnikov/rumm-1153/possibility-to-attach-custom-attributes-to-automatic-rum-resources branch from 6b40763 to d84e2a8 Compare March 10, 2021 15:34

@RunWith(AndroidJUnit4::class)
@LargeTest
internal class ResourceTrackingTest {
Copy link
Member

Choose a reason for hiding this comment

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

very nice !!

@0xnm 0xnm force-pushed the nogorodnikov/rumm-1153/possibility-to-attach-custom-attributes-to-automatic-rum-resources branch from 419136d to 889f8c6 Compare March 11, 2021 08:57
@0xnm 0xnm merged commit 29b6efe into master Mar 11, 2021
@0xnm 0xnm deleted the nogorodnikov/rumm-1153/possibility-to-attach-custom-attributes-to-automatic-rum-resources branch March 11, 2021 15:23
@xgouchet xgouchet added this to the 1.9.0 milestone May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size-medium This PR is medium sized
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants