Skip to content

Package Size Analyzer Improvements (AI-5309) #20330

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

Merged
merged 117 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
c39ed1a
basic status reporting
luciasanchezbella01 Mar 12, 2025
a9c824d
integration into ddev
luciasanchezbella01 Mar 20, 2025
b4d0f5f
clean commented code
luciasanchezbella01 Mar 20, 2025
79b0fa8
add diff mode
luciasanchezbella01 Mar 25, 2025
fefd6a3
add diff mode
luciasanchezbella01 Mar 25, 2025
76c1f09
final diff version
luciasanchezbella01 Mar 27, 2025
5aa1f49
final diff version
luciasanchezbella01 Mar 27, 2025
c64d2f9
Added timeline mode and uncompressed sizes (#5025)
luciasanchezbella01 Apr 15, 2025
846886d
Test ddev size status in GHA (by hijacking the slapr workflow)
nubtron Apr 15, 2025
a3aafc5
Timeline mode
luciasanchezbella01 Apr 15, 2025
09c7a05
Merge remote-tracking branch 'origin/luciaSanchez/package_size_analyz…
nubtron Apr 15, 2025
5a4e5d3
Try to fix job summaries
nubtron Apr 15, 2025
a4a00dd
Try fixing the job summaries again
nubtron Apr 15, 2025
ed1e372
CI size status integration on master
luciasanchezbella01 Apr 16, 2025
9cc7e5b
types added
luciasanchezbella01 Apr 21, 2025
0f7b09c
change --help
luciasanchezbella01 Apr 21, 2025
7064fd9
fix
luciasanchezbella01 Apr 21, 2025
8cc7710
fix typing
luciasanchezbella01 Apr 21, 2025
f1711cc
fix typing
luciasanchezbella01 Apr 21, 2025
b33a1fd
fix types
luciasanchezbella01 Apr 21, 2025
f16938b
fix types
luciasanchezbella01 Apr 21, 2025
4d2c8e9
fix typing
luciasanchezbella01 Apr 21, 2025
3d6a228
fix typing
luciasanchezbella01 Apr 21, 2025
d97854b
fix typing
luciasanchezbella01 Apr 21, 2025
f713097
fix typing
luciasanchezbella01 Apr 21, 2025
0d750b3
fix tests for Windows
luciasanchezbella01 Apr 22, 2025
06a2b5f
Fix tests
luciasanchezbella01 Apr 22, 2025
63137be
fix windows tests
luciasanchezbella01 Apr 22, 2025
1791728
Fix tests
luciasanchezbella01 Apr 22, 2025
c232868
Fix tests
luciasanchezbella01 Apr 22, 2025
b02658d
fix windows tests
luciasanchezbella01 Apr 22, 2025
0fcf162
Final visualizations
luciasanchezbella01 Apr 23, 2025
dc6a9db
Changelog
luciasanchezbella01 Apr 23, 2025
90d10e7
CI images integration and fixed typing
luciasanchezbella01 Apr 23, 2025
c97eaad
user errors and dep and int versions
luciasanchezbella01 Apr 25, 2025
6c4390d
user errors and dep and int versions
luciasanchezbella01 Apr 25, 2025
7f587e1
user errors and dep and int versions
luciasanchezbella01 Apr 25, 2025
d556d04
fix timeline error
luciasanchezbella01 Apr 28, 2025
91b68c9
Adding version, and json and markdown formats
luciasanchezbella01 May 5, 2025
192b718
Fix test
luciasanchezbella01 May 5, 2025
929adca
simplify code
luciasanchezbella01 May 9, 2025
837e9be
final fixes
luciasanchezbella01 May 9, 2025
40a0f8c
fix ddev windows
luciasanchezbella01 May 12, 2025
e941a1a
fix lint
luciasanchezbella01 May 12, 2025
5cd0a35
testing ddev tests on windows
luciasanchezbella01 May 12, 2025
588e011
initialize create_dashboard command
luciasanchezbella01 May 12, 2025
e3964d7
test
luciasanchezbella01 May 12, 2025
f5c66f8
test
luciasanchezbella01 May 12, 2025
3e5b26b
test
luciasanchezbella01 May 12, 2025
cf51e8e
test
luciasanchezbella01 May 12, 2025
06563cd
test
luciasanchezbella01 May 12, 2025
da01a1f
test
luciasanchezbella01 May 12, 2025
6a8df22
test
luciasanchezbella01 May 12, 2025
d863e62
test
luciasanchezbella01 May 12, 2025
ea855e3
test
luciasanchezbella01 May 12, 2025
b7a145b
test
luciasanchezbella01 May 12, 2025
c0c92d1
test
luciasanchezbella01 May 12, 2025
5864501
test
luciasanchezbella01 May 12, 2025
3dd2a3b
send metrics to dd
luciasanchezbella01 May 12, 2025
7cb499a
send metrics to dd
luciasanchezbella01 May 13, 2025
5817680
Merge branch 'lucia/package_size_analyzer_extras' of github.com:DataD…
luciasanchezbella01 May 13, 2025
6700ff9
create-dashboard command
luciasanchezbella01 May 14, 2025
2561a83
fixes
luciasanchezbella01 May 14, 2025
3f6a040
test gha
luciasanchezbella01 May 14, 2025
1399bff
test gha
luciasanchezbella01 May 14, 2025
b1990f7
test gha
luciasanchezbella01 May 14, 2025
d18e593
fixes
luciasanchezbella01 May 14, 2025
71a3c9f
fixes
luciasanchezbella01 May 14, 2025
adcdca2
fixes
luciasanchezbella01 May 14, 2025
c5794b6
fix
luciasanchezbella01 May 14, 2025
6684eb0
getting commit timestamp
luciasanchezbella01 May 14, 2025
17dbade
getting commit timestamp
luciasanchezbella01 May 14, 2025
4b58aec
Add commit timestamp
luciasanchezbella01 May 16, 2025
47af6df
correct comments
luciasanchezbella01 May 16, 2025
a695625
correct comments
luciasanchezbella01 May 16, 2025
464d0e6
Change comments
luciasanchezbella01 May 16, 2025
c22b8d7
Change number to constant
luciasanchezbella01 May 19, 2025
f71cab5
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
70afe8e
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
5cc636b
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
5817c69
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
96ce13a
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
1997d06
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
06e8320
Committing to test the send metrics
luciasanchezbella01 May 19, 2025
01e272a
Fix a comment
luciasanchezbella01 May 19, 2025
522df30
Change number to constant
luciasanchezbella01 May 19, 2025
c93901f
Change number to constant
luciasanchezbella01 May 19, 2025
44be19d
Typing
luciasanchezbella01 May 20, 2025
b02dd89
Change format flags
luciasanchezbella01 May 21, 2025
85b7199
change format input
luciasanchezbella01 May 22, 2025
777aee5
Correct test-common
luciasanchezbella01 May 22, 2025
e46b963
wip: Work in Progress
luciasanchezbella01 May 22, 2025
8c224d5
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
abbb7e0
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
03bbcff
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
d626e20
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
ab211f8
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
2fba629
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
48d3ecb
Commiting to test send-metrics
luciasanchezbella01 May 23, 2025
abd3db9
Fix typing
luciasanchezbella01 May 23, 2025
47b11d3
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
8295c23
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
7242fe9
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
3bad4a7
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
9033a45
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
d11c778
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
c6817a2
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
a5c5ee4
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
f88d255
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
6bd87b8
Committing to test the send metrics
luciasanchezbella01 May 26, 2025
1a7eb79
pull from master
luciasanchezbella01 May 26, 2025
365a767
Lints
luciasanchezbella01 May 26, 2025
1272379
Fix tests
luciasanchezbella01 May 26, 2025
a8f0d8b
Changelog
luciasanchezbella01 May 26, 2025
0c4d2a1
Merge remote-tracking branch 'origin/master' into lucia/package_size_…
luciasanchezbella01 May 26, 2025
d53e026
Change create-dashboard help
luciasanchezbella01 May 27, 2025
28f0055
Simplify output formats
luciasanchezbella01 May 27, 2025
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
2 changes: 2 additions & 0 deletions ddev/changelog.d/20330.added
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added `ddev size create-dashboard` to visualize size metrics on the Datadog platform
- Added `--to-dd-org` option to `ddev size status` to send metrics to Datadog
1 change: 1 addition & 0 deletions ddev/changelog.d/20330.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced multiple format flags with a single `--format` option in the `ddev size` command.
3 changes: 2 additions & 1 deletion ddev/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ dependencies = [
"tqdm",
"requests",
"matplotlib",
"squarify"
"squarify",
"datadog",
]
dynamic = ["version"]

Expand Down
2 changes: 2 additions & 0 deletions ddev/src/ddev/cli/size/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import click

from ddev.cli.size.create_dashboard import create_dashboard
from ddev.cli.size.diff import diff
from ddev.cli.size.status import status
from ddev.cli.size.timeline import timeline
Expand All @@ -25,6 +26,7 @@ def size():
size.add_command(status)
size.add_command(diff)
size.add_command(timeline)
size.add_command(create_dashboard)

if __name__ == "__main__":
size()
144 changes: 144 additions & 0 deletions ddev/src/ddev/cli/size/create_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import json
from typing import Any

import click
import requests

from ddev.cli.application import Application
from ddev.cli.size.utils.common_funcs import get_org, get_valid_platforms


@click.command()
@click.option(
"--dd-org",
type=str,
required=True,
help="Datadog organization name taken from your config file e.g. 'default'",
)
@click.pass_obj
def create_dashboard(
app: Application,
dd_org: str,
) -> None:
"""
Creates a Datadog dashboard to visualize size metrics for integrations and dependencies.
A new dashboard is created on each run. This command does not send data to Datadog.
To send metrics, use: `ddev size status --to-dd-org <org>`.
"""
try:
config_file_info = get_org(app, dd_org)
if 'api_key' not in config_file_info:
raise RuntimeError("No API key found in config file")
if 'app_key' not in config_file_info:
raise RuntimeError("No APP key found in config file")
if 'site' not in config_file_info:
raise RuntimeError("No site found in config file")
headers = {
"DD-API-KEY": config_file_info["api_key"],
"DD-APPLICATION-KEY": config_file_info["app_key"],
"Content-Type": "application/json",
}

payload = {
"title": "Disk Usage Status for Integrations and Dependencies",
"layout_type": "ordered",
"widgets": create_json(app),
}

response = requests.post(
f"https://api.{config_file_info['site']}/api/v1/dashboard",
headers=headers,
data=json.dumps(payload),
)

resp_json = response.json()
if "Forbidden" in str(resp_json.get("errors", [])):
raise PermissionError("Access denied: your APP key doesn't have permission to create dashboards.")
print(f"Dashboard URL: https://app.{config_file_info['site']}{resp_json['url']}")
except Exception as e:
app.abort(str(e))


def create_json(app: Application) -> list[dict[str, Any]]:
valid_platforms = get_valid_platforms(app.repo.path)
widgets: list[dict[str, Any]] = []

for size_type in ["compressed", "uncompressed"]:
for platform in valid_platforms:
# Treemap widget
widgets.append(
{
"definition": {
"type": "treemap",
"title": f"{size_type.capitalize()} sizes in {platform}",
"requests": [
{
"queries": [
{
"data_source": "metrics",
"name": "query2",
"query": f"avg:datadog.agent_integrations.size_analyzer.{size_type}"
f"{{platform:{platform}}} by {{name_type,name}}",
"aggregator": "last",
}
],
"response_format": "scalar",
"style": {"palette": "classic"},
"formulas": [
{
"formula": "query2",
"number_format": {
"unit": {
"type": "canonical_unit",
"unit_name": "byte_in_binary_bytes_family",
}
},
}
],
}
],
}
}
)
# Timeseries widget
widgets.append(
{
"definition": {
"title": f"Timeline of {size_type} sizes in {platform}",
"type": "timeseries",
"requests": [
{
"response_format": "timeseries",
"queries": [
{
"name": "query1",
"data_source": "metrics",
"query": f"sum:datadog.agent_integrations.size_analyzer.{size_type}"
f"{{platform:{platform}}}",
}
],
"formulas": [
{
"formula": "query1",
"number_format": {
"unit": {
"type": "canonical_unit",
"unit_name": "byte_in_binary_bytes_family",
}
},
}
],
"style": {
"palette": "dog_classic",
"order_by": "values",
"line_type": "solid",
"line_width": "normal",
},
"display_type": "line",
}
],
}
}
)

return widgets
Loading
Loading