Skip to content

test: datadog performance tracking poc [LW-12806] #1937

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,19 @@ jobs:
needs: smokeTests
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests

- name: Download all smoke tests artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -428,11 +441,19 @@ jobs:
with:
name: test-artifacts
path: |
./packages/e2e-tests/screenshots
./packages/e2e-tests/logs
./packages/e2e-tests/reports
./screenshots
./logs
./reports
./metrics
retention-days: 5

- name: Push performance metrics to Datadog
working-directory: ./packages/e2e-tests/tools
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_SITE: us5.datadoghq.com
run: python push_to_datadog.py ../../../metrics

- run: |
if [[ ${{ needs.smokeTests.result }} == "success" ]]; then
exit 0
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"allure:generate": "yarn allure generate -c ./reports/allure/results -o ./reports/allure/report",
"allure:open": "allure open ./reports/allure/report/",
"build": "yarn exec echo 'No build required'",
"cleanup": "rm -rf logs node_modules reports screenshots",
"cleanup": "rm -rf logs node_modules reports screenshots metrics",
"lint": "run -T eslint -c .eslintrc.cjs .",
"lint:fix": "run -T eslint -c .eslintrc.cjs . --fix",
"pack-chrome-extension": "node ./src/utils/packExtension.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/src/support/PidMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Logger } from './logger';
const execAsync = promisify(exec);

interface UsageData {
timestamp: string;
timestamp: number;
cpu: number;
memory: number;
}
Expand Down Expand Up @@ -81,7 +81,7 @@ class PidMonitor {
try {
const stats = await pidusage(this.pid);
this._data.push({
timestamp: new Date().toISOString(),
timestamp: Date.now(),
cpu: stats.cpu,
memory: stats.memory
});
Expand Down
54 changes: 54 additions & 0 deletions packages/e2e-tests/tools/push_to_datadog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import json
import sys
import requests

DATADOG_API_KEY = os.getenv("DATADOG_API_KEY")
DD_SITE = os.getenv("DD_SITE", "us5.datadoghq.com")
headers = {
"Content-Type": "application/json",
"DD-API-KEY": DATADOG_API_KEY
}

if len(sys.argv) < 2:
print("Usage: python push_to_datadog.py <metrics_dir>")
sys.exit(1)

METRICS_DIR = sys.argv[1]

def send_to_datadog(series_batch):
url = f"https://api.{DD_SITE}/api/v1/series"
res = requests.post(url, headers=headers, data=json.dumps({"series": series_batch}))
print(f"→ Sent {len(series_batch)} points. Status: {res.status_code}")
if res.status_code >= 300:
print(res.text)

series = []

for filename in os.listdir(METRICS_DIR):
if filename.endswith(".json"):
path = os.path.join(METRICS_DIR, filename)
with open(path) as f:
content = json.load(f)
scenario = content["scenarioName"]
for point in content["data"]:
ts = int(point["timestamp"] / 1000)
series.append({
"metric": "e2e.cpu_seconds_total",
"points": [[ts, point["cpu"]]],
"tags": [f"scenario:{scenario}", f"source_file:{filename}"],
"type": "gauge"
})
series.append({
"metric": "e2e.memory_rss_bytes",
"points": [[ts, point["memory"]]],
"tags": [f"scenario:{scenario}", f"source_file:{filename}"],
"type": "gauge"
})

print(f"Uploading {len(series)} points to Datadog in chunks...")

CHUNK_SIZE = 400
for i in range(0, len(series), CHUNK_SIZE):
chunk = series[i:i + CHUNK_SIZE]
send_to_datadog(chunk)