-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(scm-multi-platform-detection): Adding new metrics #118099
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -483,7 +483,9 @@ def detect_platforms_multi( | |
| languages: dict[str, int] = client.get_languages(repo) | ||
| active_platforms = _select_active_platforms(languages) | ||
|
|
||
| tree_start = time.monotonic() | ||
| entries, is_truncated = _get_tree(client, repo, ref) | ||
| tree_duration_ms = (time.monotonic() - tree_start) * 1000 | ||
| index = _build_tree_index(entries) | ||
|
|
||
| results: list[DetectedPlatform] = [] | ||
|
|
@@ -524,11 +526,13 @@ def detect_platforms_multi( | |
| # are always within the cap before subdirectory files from monorepo workspaces. | ||
| capped_paths = sorted(needed_paths, key=lambda p: (p.count("/"), p))[:MAX_CONTENT_READS] | ||
|
|
||
| content_reads_start = time.monotonic() | ||
| content_by_path: dict[str, str] = {} | ||
| for path in capped_paths: | ||
| content = _get_repo_file_content(client, repo, path, ref) | ||
| if content is not None: | ||
| content_by_path[path] = content | ||
| content_reads_duration_ms = (time.monotonic() - content_reads_start) * 1000 | ||
|
|
||
| manifests_by_path: dict[str, _PackageManifest] = {} | ||
| for path, content in content_by_path.items(): | ||
|
|
@@ -624,6 +628,21 @@ def detect_platforms_multi( | |
| f"{_MULTI_METRICS_PREFIX}.k_reads_realized", | ||
| k_reads_realized, | ||
| ) | ||
| sentry_sdk.metrics.distribution( | ||
| f"{_MULTI_METRICS_PREFIX}.tree.duration", | ||
| tree_duration_ms, | ||
| unit="millisecond", | ||
| ) | ||
| sentry_sdk.metrics.distribution( | ||
| f"{_MULTI_METRICS_PREFIX}.content_reads.duration", | ||
| content_reads_duration_ms, | ||
| unit="millisecond", | ||
| ) | ||
| for needed_path in needed_paths: | ||
| sentry_sdk.metrics.distribution( | ||
| f"{_MULTI_METRICS_PREFIX}.needed_path_depth", | ||
| needed_path.count("/"), | ||
| ) | ||
|
Comment on lines
+641
to
+645
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The loop over Suggested FixInstead of emitting a metric for every path in Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| sentry_sdk.metrics.count( | ||
| f"{_MULTI_METRICS_PREFIX}.completed", | ||
| 1, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unbounded per-path metric emissions
Medium Severity
Each detection run loops over every path in
needed_pathsand callssentry_sdk.metrics.distributiononce per path. That set is uncapped and can include every matching manifest ormatch_extfile in a large tree, so a single request may emit thousands of metric samples and add noticeable latency on top of an already expensive GitHub tree fetch.Reviewed by Cursor Bugbot for commit 6c23be0. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is okay. Max needed length over the last 2 days was 41, with a p90 of 4