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-4780] Remote configuration #2799

Merged
merged 7 commits into from
Jun 13, 2024
Merged

Conversation

amortemousque
Copy link
Contributor

@amortemousque amortemousque commented Jun 7, 2024

Motivation

Add remote configuration capability

Changes

  • Add new init parameter remoteConfigurationId
  • Wait for the remote configuration in the preStart module
  • Overrides the static init configuration with the remote configuration values

How to test

window.DD_RUM.init({
    remoteConfigurationId: "50d8ba4b-2ac1-481f-b16e-f110699ecf66", // only config available
    enableExperimentalFeatures: ['remote_configuration'],
    ...
})

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@amortemousque amortemousque changed the title Aymeric/remote configuration ⚗️[RUM-4780] Remote configuration Jun 7, 2024
@@ -452,6 +502,22 @@ describe('preStartRum', () => {

expect(strategy.initConfiguration).toEqual(initConfiguration)
})

it('returns the initConfiguration with the remote configuration when a remoteConfigurationId is provided', (done) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about this behaviour. Basically DD_RUM.getInitConfiguration() will also have the remote configuration values. It has the advantage to make the browser extension reflect the remote config without any change.
Wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

💭 thought: ‏ Currently DD_RUM.getInitConfiguration() returns exactly what the customer called init() with. I wouldn't mind it to return what the SDK was actually initialised with, this means the combination of what the customer called init() with, the remote config if applicable and the defaults.

I think it would be useful information to debug rum, both for customers, for us through telemetry and even for support.

I'm not sure if it is safe to do that or if this will be a breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

We could review our usages of getInitConfiguration https://github.com/search?q=repo%3ADataDog%2Fsynthetics-worker%20getInitConfiguration&type=code

To me it doesn't matter much, but we'll maybe need a onInitConfigurationReady(cb) API in the future if we have use-cases where we need to access the resolved config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I identifyed in Datadog repos, we use the API for

Clearly if we get one of fields applicationId, service, env or version, from the RC we will have some issues. But luckily for now they won't be available in RC :). So the question is, should we anticipate by introducing a new API right away and defining the getInitConfiguration() has only returning whats passed to the init() API
I'll create an RFC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seen with @BenoitZugmeyer, since the feature is under FF, lets keep the behaviour as is and revisite later when needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

perfect! Sounds good!

import { display, addEventListener, assign } from '@datadog/browser-core'
import type { RumInitConfiguration } from './configuration'

export const REMOTE_CONFIGURATION_URL = 'https://www.datad0g-browser-agent.com/configuration'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For testing purposes, I hosted the RC in the same CDN as the bundles but it will change once the Remote config provides their CDN

@amortemousque amortemousque marked this pull request as ready for review June 7, 2024 15:50
@amortemousque amortemousque requested a review from a team as a code owner June 7, 2024 15:50
Copy link

cit-pr-commenter bot commented Jun 10, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 159.49 KiB 160.06 KiB 578 B +0.35%
Logs 58.02 KiB 58.07 KiB 46 B +0.08%
Rum Slim 108.07 KiB 108.64 KiB 578 B +0.52%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.002 0.002 0.001
addaction 0.050 0.053 0.004
adderror 0.052 0.041 -0.011
addtiming 0.001 0.001 -0.000
startview 1.427 1.185 -0.242
startstopsessionreplayrecording 1.077 1.090 0.013
logmessage 0.007 0.023 0.016
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 19.58 KiB 19.47 KiB -116 B
addaction 68.97 KiB 68.50 KiB -486 B
adderror 83.18 KiB 83.93 KiB 762 B
addtiming 17.24 KiB 17.73 KiB 501 B
startview 313.58 KiB 320.50 KiB 6.92 KiB
startstopsessionreplayrecording 11.51 KiB 11.99 KiB 499 B
logmessage 64.11 KiB 66.83 KiB 2.72 KiB

packages/core/src/browser/addEventListener.ts Show resolved Hide resolved
packages/core/src/transport/eventBridge.ts Outdated Show resolved Hide resolved
@@ -452,6 +502,22 @@ describe('preStartRum', () => {

expect(strategy.initConfiguration).toEqual(initConfiguration)
})

it('returns the initConfiguration with the remote configuration when a remoteConfigurationId is provided', (done) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

💭 thought: ‏ Currently DD_RUM.getInitConfiguration() returns exactly what the customer called init() with. I wouldn't mind it to return what the SDK was actually initialised with, this means the combination of what the customer called init() with, the remote config if applicable and the defaults.

I think it would be useful information to debug rum, both for customers, for us through telemetry and even for support.

I'm not sure if it is safe to do that or if this will be a breaking change.

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2024

Codecov Report

Attention: Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.66%. Comparing base (b839f8c) to head (3ad4673).

Files Patch % Lines
...re/src/domain/configuration/remoteConfiguration.ts 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2799      +/-   ##
==========================================
+ Coverage   93.65%   93.66%   +0.01%     
==========================================
  Files         243      244       +1     
  Lines        7140     7168      +28     
  Branches     1599     1603       +4     
==========================================
+ Hits         6687     6714      +27     
- Misses        453      454       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@amortemousque
Copy link
Contributor Author

/to-staging

@dd-devflow
Copy link

dd-devflow bot commented Jun 11, 2024

🚂 Branch Integration: starting soon, median merge time is 10m

Commit 10bc671246 will soon be integrated into staging-24.

Use /to-staging -c to cancel this operation!

dd-mergequeue bot added a commit that referenced this pull request Jun 11, 2024
Integrated commit sha: 10bc671

Co-authored-by: Aymeric Mortemousque <[email protected]>
@dd-devflow
Copy link

dd-devflow bot commented Jun 11, 2024

🚂 Branch Integration: This commit was successfully integrated

Commit 10bc671246 has been merged into staging-24 in merge commit 4e239e6834.

Check out the triggered pipeline on Gitlab 🦊

packages/rum-core/src/boot/preStartRum.spec.ts Outdated Show resolved Hide resolved
@@ -452,6 +502,22 @@ describe('preStartRum', () => {

expect(strategy.initConfiguration).toEqual(initConfiguration)
})

it('returns the initConfiguration with the remote configuration when a remoteConfigurationId is provided', (done) => {
Copy link
Member

Choose a reason for hiding this comment

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

We could review our usages of getInitConfiguration https://github.com/search?q=repo%3ADataDog%2Fsynthetics-worker%20getInitConfiguration&type=code

To me it doesn't matter much, but we'll maybe need a onInitConfigurationReady(cb) API in the future if we have use-cases where we need to access the resolved config.

@amortemousque amortemousque merged commit e13a109 into main Jun 13, 2024
20 checks passed
@amortemousque amortemousque deleted the aymeric/remote-configuration branch June 13, 2024 07:54
nulrich added a commit that referenced this pull request Jun 13, 2024
) into staging-24

 pm_trace_id: 36652155
 feature_branch_pipeline_id: 36652155
 source: to-staging

* commit '040eb5094590ebb77f1f26c154eefd69b1d81306':
  Improve callback naming
  Remove `custom` field.
  ⚗️[RUM-4780] Remote configuration (#2799)
  Use assign polyfill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants