Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

web: initial Datadog RUM integration #34063

Merged
merged 5 commits into from
Apr 22, 2022
Merged

Conversation

valerybugakov
Copy link
Member

@valerybugakov valerybugakov commented Apr 19, 2022

Context

This PR integrates Datadog RUM SDK into the web application.

Closes https://github.com/sourcegraph/sourcegraph/issues/33992
Related to: https://github.com/sourcegraph/sourcegraph/issues/29651 and RFC 575 APPROVED: Cloud Observability tooling

Changes

  • Datadog RUM SDK is initialized via async script along with Sentry SDK.
  • Datadog RUM configuration is added to the site-config under the observability.logging key.
  • @datadog/browser-rum-slim is added to devDependencies to allow usage of Typescript types, and it's not added to the application bundle.

Notes integration trade-offs

Since we didn't decide which solution we would want to use for the observability OKR set for the Frontend Platform team next quarter, it's essential to integrate the Datadog RUM SDK as a POC without hurting our performance metrics on production.

The best strategy for POC is to load it via async script to avoid hurting our bundle size. This way, we keep Sentry in place and see how they compare.

Production

Merging this PR won't enable Datadog RUM on any production instance automatically. To enable it, the Datadog RUM configuration should be added to the site configuration via site-admin.

Test plan

Local development

Datadog is initialized only if:

  1. The SDK script is included in the index.html template (app.html). Meaning that SourcegraphDotComMode == true.
  2. Datadog RUM is configured using Sourcegraph site configuration.
  3. process.env.ENABLE_MONITORING || process.env.NODE_ENV === 'production' to prevent log spam in the development environment.

Based on the requirements above to test Datadog RUM locally run: ENABLE_MONITORING=true sg start dotcom

Datadog access

Datadog RUM application logs are available here. If the link is inaccessible for you, check if Datadog is added to your Okta profile. If it's not there — reach out to #it-tech-ops

Testing

  1. Run ENABLE_MONITORING=true sg start dotcom
  2. Add Dagadog configuration to the site config.
  3. Check out the network tab:
    • The Datadog SDK should be loaded.
    • Pageviews should be logged to Datadog servers.

@valerybugakov valerybugakov added frontend-platform Issues related to our frontend platform, owned collectively by our frontend crew. observability labels Apr 19, 2022
@valerybugakov valerybugakov self-assigned this Apr 19, 2022
@cla-bot cla-bot bot added the cla-signed label Apr 19, 2022
package.json Outdated Show resolved Hide resolved
}

/**
* Datadog is initialized only if:
Copy link
Contributor

Choose a reason for hiding this comment

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

loving these comments!

@valerybugakov valerybugakov marked this pull request as ready for review April 21, 2022 07:50
client/web/src/jscontext.ts Outdated Show resolved Hide resolved
client/web/src/monitoring/datadog/datadogClient.ts Outdated Show resolved Hide resolved
@valerybugakov valerybugakov enabled auto-merge (squash) April 22, 2022 05:57
@valerybugakov valerybugakov merged commit b553e2d into main Apr 22, 2022
@valerybugakov valerybugakov deleted the vb/datadog-initial-integration branch April 22, 2022 06:09
@daxmc99 daxmc99 mentioned this pull request Jun 22, 2022
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed frontend-platform Issues related to our frontend platform, owned collectively by our frontend crew. observability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

web: Datadog RUM integration
4 participants