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-4469] introduce a plugin system #2809

Merged
merged 6 commits into from
Jun 17, 2024

Conversation

BenoitZugmeyer
Copy link
Member

Motivation

Experiment with a plugin system to provide custom integrations.

This is experimental: the plugin interface might change in any version, be warned!

Changes

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2024

Codecov Report

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

Project coverage is 93.66%. Comparing base (9b21a36) to head (5c5e461).
Report is 1 commits behind head on main.

Files Patch % Lines
packages/rum-core/src/domain/plugins.ts 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2809      +/-   ##
==========================================
- Coverage   93.66%   93.66%   -0.01%     
==========================================
  Files         244      245       +1     
  Lines        7168     7181      +13     
  Branches     1605     1611       +6     
==========================================
+ Hits         6714     6726      +12     
- Misses        454      455       +1     

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

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/react-plugin--1-plugin-concept branch from d61e27d to 08465c3 Compare June 13, 2024 16:34
@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review June 13, 2024 16:37
@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner June 13, 2024 16:37
Copy link

cit-pr-commenter bot commented Jun 14, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 160.07 KiB 160.44 KiB 379 B +0.23%
Logs 58.07 KiB 58.09 KiB 20 B +0.03%
Rum Slim 108.65 KiB 109.02 KiB 379 B +0.34%
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.000
addaction 0.035 0.038 0.002
adderror 0.038 0.033 -0.006
addtiming 0.001 0.001 -0.000
startview 1.354 1.069 -0.285
startstopsessionreplayrecording 0.989 1.106 0.117
logmessage 0.020 0.023 0.003
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 20.64 KiB 18.83 KiB -1855 B
addaction 69.28 KiB 69.23 KiB -50 B
adderror 84.99 KiB 84.92 KiB -64 B
addtiming 17.99 KiB 15.84 KiB -2201 B
startview 314.13 KiB 320.54 KiB 6.41 KiB
startstopsessionreplayrecording 13.31 KiB 13.57 KiB 262 B
logmessage 69.38 KiB 67.67 KiB -1748 B

🔗 RealWorld

Comment on lines +18 to +20
if (!plugins) {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

💭 thought: ‏ What about also checking for a new experimental feature like plugins? That would be a clear sign for customers that this is not stable, especially in the case a 3rd party releases a plugin, they would have to instruct people to add enableExperimentalFeatures: ['plugins'] to their init config.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, let's do it for now.

@@ -296,6 +305,7 @@ export function serializeRumConfiguration(configuration: RumInitConfiguration) {
track_user_interactions: configuration.trackUserInteractions,
track_resources: configuration.trackResources,
track_long_task: configuration.trackLongTasks,
plugins: configuration.plugins?.map((plugin) => assign({ name: plugin.name }, plugin.serializeConfiguration?.())),
Copy link
Collaborator

Choose a reason for hiding this comment

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

💭 thought: ‏ What about doing the serialization within rum instead of the plugin? This way we can control how the serialization is done and might avoid duplicating serialization logic across multiple plugins

Copy link
Member Author

Choose a reason for hiding this comment

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

Hum, 'serialization' might not be the best term for it. We don't serialize anything per-se, we transform the configuration before sending it as telemetry event. We need to ensure that we don't leak PII (ex: we avoid sending URLs specified in the configuration, ex: configuration.proxy = 'https://...' becomes use_proxy: true). It's not possible to define a generic way to do it.

Maybe we could rename serializeConfiguration() to something like getConfigurationTelemetry()?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, I didn't understood it was for telemetry. getConfigurationTelemetry sounds good, even though it's a bit weird to expose this to public plugins, but I guess that's fine for now and we can revisit if needed when we go GA with plugins

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's a bit weird to expose this to public plugins

There is no plan to support public plugins any time soon though. We'll go GA with the react plugin, but this doesn't imply supporting third-party plugins.


export interface RumPlugin {
name: string
serializeConfiguration?(): Record<string, unknown>
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ question: ‏What is the serializeConfiguration meant for? Is it only to be passed in the telemetry config?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I agree the name isn't great, see #2809 (comment)

@@ -140,6 +141,8 @@ export function createPreStartStrategy(
return
}

callHook(initConfiguration.plugins, 'onInit', { initConfiguration, publicApi })
Copy link
Contributor

@amortemousque amortemousque Jun 14, 2024

Choose a reason for hiding this comment

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

💬 suggestion: ‏To anticipate a bit future hooks, it could be nice to have

Suggested change
callHook(initConfiguration.plugins, 'onInit', { initConfiguration, publicApi })
registerPlugins(initConfiguration.plugins) // At some point we could have some checks like ensuring no duplicated plugins
callHook('onInit', { initConfiguration, publicApi })

Copy link
Member Author

@BenoitZugmeyer BenoitZugmeyer Jun 14, 2024

Choose a reason for hiding this comment

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

What registerPlugins would do? I don't want to anticipate too much, because we don't know what we'll need in future plugins :) even callHook is a bit too much. Maybe I could remove this 'hook' concept and just move the code here:

initConfiguration.plugins?.forEach(plugin => plugin?.onInit({ initConfiguration, publicApi }))

Copy link
Contributor

@amortemousque amortemousque Jun 14, 2024

Choose a reason for hiding this comment

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

Make sense, let's keep it like this for now :)

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/react-plugin--1-plugin-concept branch from 3b14f17 to 5c5e461 Compare June 14, 2024 10:16
import type { RumInitConfiguration } from './configuration'

export interface RumPlugin {
name: string
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 thought: ‏Maybe adding the plugin version, for telemetry and maybe checking compatibility with the SDK.

Copy link
Member Author

Choose a reason for hiding this comment

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

For now installing a plugin with a different version than the SDK won't be supported. Plugins and SDK need to be updated at the same time.

@BenoitZugmeyer BenoitZugmeyer merged commit c1a4aa2 into main Jun 17, 2024
20 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/react-plugin--1-plugin-concept branch June 17, 2024 09:01
cy-moi added a commit that referenced this pull request Jun 18, 2024
) into staging-25

 pm_trace_id: 37003110
 feature_branch_pipeline_id: 37003110
 source: to-staging

* commit '50503639a46a42efa486a4f72a30b9fc76e12ab5':
  fix type
  Add files parameter in karma local
  Fix event format
  👷Skip safari and ie for extension unit tests
  ✨⚗️ [RUM-4469] introduce a plugin system  (#2809)
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.

6 participants