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

RUM-984 feat: Add sample rate for WebView Log events #1515

Merged
merged 3 commits into from
Oct 13, 2023

Conversation

ncreated
Copy link
Member

@ncreated ncreated commented Oct 12, 2023

What and why?

📦 This PR adds logsSampleRate option to DatadogWebViewTracking. Now, it is possible to set custom sample rate that will be applied to logs received from Browser SDK that runs in a WebView.

Counterpart of Android's DataDog/dd-sdk-android#1629

     public static func enable(
         webView: WKWebView,
         hosts: Set<String> = [],
+        logsSampleRate: Float = 100,
         in core: DatadogCoreProtocol = CoreRegistry.default
     ) {

How?

  • New parameter (logsSampleRate) is added in DatadogWebViewTracking public API.
  • Log events are sampled right before forwarding them to DatadogLogs.

🎁 As an extra task, I enhanced tests for MessageEmitter by separating two concerns:

  • parsing the message - now moved to WebViewMessageTests,
  • forwarding the message to RUM or Logs - tested in MessageEmitterTests.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes

Custom CI job configuration (optional)

  • Run unit tests for Core, RUM, Trace, Logs, CR and WVT
  • Run unit tests for Session Replay
  • Run integration tests
  • Run smoke tests
  • Run tests for tools/

- changed tests to cover internal API, not private one
- separate message parsing and message routing tests
@ncreated ncreated self-assigned this Oct 12, 2023
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Oct 12, 2023

Datadog Report

Branch report: ncreated/RUM-984/sample-webview-log-events
Commit report: c3f2314

dd-sdk-ios: 0 Failed, 0 New Flaky, 2620 Passed, 0 Skipped, 12m 1.65s Wall Time

@ncreated ncreated marked this pull request as ready for review October 12, 2023 11:56
@ncreated ncreated requested a review from a team as a code owner October 12, 2023 11:56
Copy link
Member

@maxep maxep left a comment

Choose a reason for hiding this comment

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

nit 👌

@ncreated ncreated merged commit 42cfe80 into develop Oct 13, 2023
7 checks passed
@ncreated ncreated deleted the ncreated/RUM-984/sample-webview-log-events branch October 13, 2023 13:06
This was referenced Oct 13, 2023
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