Skip to content

Commit eec95f4

Browse files
committed
Add tasks
1 parent b1b6e27 commit eec95f4

File tree

5 files changed

+28
-54
lines changed

5 files changed

+28
-54
lines changed

.gitlab-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,20 @@ bump-chrome-version-scheduled-failure:
587587
dependencies:
588588
- bump-chrome-version-scheduled
589589

590+
########################################################################################################################
591+
# Performance benchmark
592+
########################################################################################################################
593+
594+
performance-benchmark:
595+
stage: task
596+
extends: .base-configuration
597+
only:
598+
variables:
599+
- $TARGET_TASK_NAME == "performance-benchmark-scheduled"
600+
script:
601+
- yarn
602+
- yarn test:performance
603+
590604
########################################################################################################################
591605
# Check expired telemetry
592606
########################################################################################################################

benchmark/createBenchmarkTest.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { test } from '@playwright/test'
22
import type { Page } from '@playwright/test'
33
import type { RumInitConfiguration } from '@datadog/browser-rum-core'
4-
import type { Site } from '@datadog/browser-core'
54
import type { BrowserWindow, Metrics } from './profiling.type'
65
import { startProfiling } from './profilers'
76
import { reportToConsole } from './reporters/reportToConsole'
@@ -10,9 +9,9 @@ import { isContinuousIntegration } from './environment'
109

1110
const testAppUrl = 'https://df1fyr56hap9d.cloudfront.net/'
1211
const sdkBundleUrl = 'https://df1fyr56hap9d.cloudfront.net/datadog-rum.js'
13-
const applicationId = 'a81f40b8-e9bd-4805-9b66-4e4edc529a14'
14-
const clientToken = 'pubfe2e138a54296da76dd66f6b0b5f3d98'
15-
const datadogSite = 'datad0g.com' as Site
12+
const applicationId = '9fa62a5b-8a7e-429d-8466-8b111a4d4693'
13+
const clientToken = 'pubab31fd1ab9d01d2b385a8aa3dd403b1d'
14+
const datadogSite = 'datadoghq.com'
1615
const scenarioConfigurations = ['none', 'rum', 'rum_replay', 'rum_profiling', 'none_with_headers'] as const
1716

1817
type ScenarioConfiguration = (typeof scenarioConfigurations)[number]
@@ -64,12 +63,11 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
6463
applicationId,
6564
site: datadogSite,
6665
profilingSampleRate: scenarioConfiguration === 'rum_profiling' ? 100 : 0,
67-
trackBfcacheViews: true,
68-
allowUntrustedEvents: true,
66+
sessionReplaySampleRate: scenarioConfiguration === 'rum_replay' ? 100 : 0,
6967
}
7068

7169
await page.addInitScript(
72-
(parameters: PageInitScriptParameters) => {
70+
({ sdkBundleUrl, scenarioConfiguration, scenarioName, configuration }: PageInitScriptParameters) => {
7371
function loadSDK() {
7472
;(function (h: any, o: Document, u: string, n: string, d: string) {
7573
h = h[d] = h[d] || {
@@ -83,13 +81,13 @@ async function injectSDK(page: Page, scenarioConfiguration: ScenarioConfiguratio
8381
s.async = true
8482
s.src = n
8583
o.head.appendChild(s)
86-
})(window, document, 'script', parameters.sdkBundleUrl, 'DD_RUM')
84+
})(window, document, 'script', sdkBundleUrl, 'DD_RUM')
8785
;(window as BrowserWindow).DD_RUM?.onReady(function () {
8886
;(window as BrowserWindow).DD_RUM!.setGlobalContextProperty('scenario', {
8987
configuration: scenarioConfiguration,
9088
name: scenarioName,
9189
})
92-
;(window as BrowserWindow).DD_RUM!.init(parameters.configuration as RumInitConfiguration)
90+
;(window as BrowserWindow).DD_RUM!.init(configuration as RumInitConfiguration)
9391
})
9492
}
9593

@@ -124,7 +122,9 @@ function buildAppUrl(scenarioConfiguration: ScenarioConfiguration): string {
124122
async function flushEvents(page: Page) {
125123
await page.evaluate(() => {
126124
Object.defineProperty(document, 'visibilityState', { configurable: true, get: () => 'hidden' })
127-
document.dispatchEvent(new Event('visibilitychange'))
125+
const hiddenEvent = new Event('visibilitychange', { bubbles: true })
126+
;(hiddenEvent as unknown as { __ddIsTrusted: boolean }).__ddIsTrusted = true
127+
document.dispatchEvent(hiddenEvent)
128128
})
129129
}
130130

benchmark/reporters/reportToDatadog.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import type { Metrics } from '../profiling.type'
22
import { fetchHandlingError } from '../../scripts/lib/executionUtils'
33

44

5-
65
interface DatadogSeries {
76
metric: string
87
points: Array<[number, Array<[number]>]>
98
tags?: string[]
109
}
1110

12-
const METRIC_PREFIX = 'browser_sdk.benchmark.new'
11+
const METRIC_PREFIX = 'browser_sdk.benchmark'
1312
const DATADOG_SITE = 'datad0g.com'
1413

1514
export async function reportToDatadog(
@@ -50,7 +49,7 @@ function convertMetricsToSeries(
5049
}
5150

5251
async function sendToDatadog(series: DatadogSeries[]) {
53-
const apiKey = ''
52+
const apiKey = '72fb11061240d4492be4e50e294048bd'
5453
const payload = { series }
5554
const apiUrl = `https://api.${DATADOG_SITE}/api/v1/distribution_points`
5655

@@ -65,7 +64,7 @@ async function sendToDatadog(series: DatadogSeries[]) {
6564
})
6665
return response
6766
} catch (error) {
68-
console.error('Error:', error)
67+
console.error('Error', error, payload)
6968
throw error
7069
}
7170
}

benchmark/scenarios/light.scenario.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
"test:e2e:ci:bs": "yarn build && yarn build:apps && yarn test:e2e:bs",
3333
"test:compat:tsc": "node scripts/check-typescript-compatibility.ts",
3434
"test:compat:ssr": "scripts/cli check_server_side_rendering_compatibility",
35-
"test:performance": "playwright test --config benchmark/playwright.config.ts heavy.scenario.ts",
36-
"test:performance:all": "playwright test --config benchmark/playwright.config.ts --repeat-each=15",
35+
"test:performance": "playwright test --config benchmark/playwright.config.ts",
3736
"test:performance:debug": "playwright test --config benchmark/playwright.config.ts --debug",
3837
"test:performance:ui": "playwright test --config benchmark/playwright.config.ts --ui",
3938
"json-schemas:sync": "scripts/cli update_submodule && yarn json-schemas:generate",

0 commit comments

Comments
 (0)