-
Notifications
You must be signed in to change notification settings - Fork 188
👷📝 Move some internal doc inside the repo #4362
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| **/dist/** | ||
| yarn.lock | ||
| .yarn/releases | ||
| docs | ||
| generated-docs | ||
|
|
||
| # code import | ||
| packages/worker/src/domain/deflate.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # Architecture | ||
|
|
||
| Describes architecture patterns with examples — detailed component documentation lives as JSDoc on the files themselves. | ||
|
|
||
| ## Package dependencies | ||
|
|
||
| The [monorepo](https://github.com/DataDog/browser-sdk) contains several packages: | ||
|
|
||
| ```mermaid | ||
| graph TD | ||
| core["@datadog/browser-core\n(shared utilities)"] | ||
| rum-core["@datadog/browser-rum-core\n(core RUM)"] | ||
| rum["@datadog/browser-rum\n(full RUM)"] | ||
| rum-slim["@datadog/browser-rum-slim\n(lightweight RUM)"] | ||
| rum-react["@datadog/browser-rum-react\n(React integration)"] | ||
| logs["@datadog/browser-logs"] | ||
| worker["@datadog/browser-worker"] | ||
|
|
||
| core --> rum-core | ||
| core --> logs | ||
| rum-core --> rum | ||
| rum-core --> rum-slim | ||
| rum --> rum-react | ||
| ``` | ||
|
|
||
| ## Data processing | ||
|
|
||
| High-level view of RUM SDK data processing. Each box represents a module: | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| startRum["startRum\n(boot)"] | ||
| collections["collections\n(views, actions, resources, errors…)"] | ||
| assembly["assembly\n(adds common attributes)"] | ||
| batch["batch\n(in-memory buffer)"] | ||
|
|
||
| startRum --> collections | ||
| collections -->|"raw RUM events"| assembly | ||
| assembly -->|"enriched events"| batch | ||
| ``` | ||
|
|
||
| ### startRum [[code](https://github.com/DataDog/browser-sdk/blob/32ffe4bb7e50a37a43794773bbbc57aabb373468/packages/rum-core/src/boot/startRum.ts)] | ||
|
|
||
| Called at SDK initialization. Starts all event data collection. | ||
|
|
||
| ### collection [[code](https://github.com/DataDog/browser-sdk/blob/32ffe4bb7e50a37a43794773bbbc57aabb373468/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.ts)] | ||
|
|
||
| Creates raw RUM events (`views`, `actions`, `resources`, …) by listening to or instrumenting various web APIs, then notifies the assembly. | ||
|
|
||
| ### assembly [[code](https://github.com/DataDog/browser-sdk/blob/32ffe4bb7e50a37a43794773bbbc57aabb373468/packages/rum-core/src/domain/assembly.ts)] | ||
|
|
||
| Enriches each event with common attributes (`applicationId`, `service`, `version`, view context, customer context, …) then forwards it to the batch. | ||
|
|
||
| ## Data transfer | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| batch["batch\n(in-memory buffer)"] | ||
| httpRetry["httpRetry\n(retry & throttle)"] | ||
| httpRequest["httpRequest\n(fetch / XHR)"] | ||
| intake["Datadog intake"] | ||
|
|
||
| batch -->|"flush"| httpRetry | ||
| httpRetry -->|"send"| httpRequest | ||
| httpRequest --> intake | ||
| ``` | ||
|
|
||
| ### batch [[code](https://github.com/DataDog/browser-sdk/blob/32ffe4bb7e50a37a43794773bbbc57aabb373468/packages/core/src/transport/batch.ts)] | ||
|
|
||
| Collects events into an in-memory batch. Flushed: | ||
|
|
||
| - Periodically, every `configuration.flushTimeout` (30s by default) | ||
| - When the buffer size reaches `configuration.batchBytesLimit` | ||
| - When the number of events reaches `configuration.maxBatchSize` | ||
| - On `visibilitychange` when the document becomes hidden | ||
| - On `beforeunload` | ||
|
|
||
| ### httpRetry | ||
|
|
||
| Buffers and retries failed requests (`network failure`, `intake unavailable`, `no connectivity`, …). Also throttles requests when too many are in progress. | ||
|
|
||
| The SDK buffers at most 3MB of requests; older requests are dropped beyond that limit. The buffer is in-memory — requests are lost if the tab is closed. | ||
|
|
||
| ### httpRequest [[code](https://github.com/DataDog/browser-sdk/blob/32ffe4bb7e50a37a43794773bbbc57aabb373468/packages/core/src/transport/httpRequest.ts)] | ||
|
|
||
| Sends events using `fetch` with `keepAlive`, falling back to `XMLHttpRequest`. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.