Skip to content

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Mar 7, 2025

Add the following perf metrics:

  • integrations.source_code_management.populate_repositories.duration
  • integrations.source_code_management.populate_trees.duration
  • auto_source_code_config.generate_code_mappings.duration
  • auto_source_code_config.create_configurations.duration

Add the following counting metrics:

  • integrations.source_code_management.populate_repositories
  • integrations.source_code_management.populate_trees

@armenzg armenzg self-assigned this Mar 7, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 7, 2025
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/issues/auto_source_code_config/task.py 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #86598      +/-   ##
==========================================
+ Coverage   87.73%   87.86%   +0.13%     
==========================================
  Files        9863     9802      -61     
  Lines      558910   557037    -1873     
  Branches    22052    21640     -412     
==========================================
- Hits       490363   489460     -903     
+ Misses      68117    67206     -911     
+ Partials      430      371      -59     

def get_trees_for_org(self) -> dict[str, RepoTree]:
trees = {}
repositories = self._populate_repositories()
with metrics.timer("integrations.source_code_management.populate_repositories.duration"):
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the root of all slowdowns. I want to verify it.

]

metrics.incr(
"integrations.source_code_management.populate_repositories",
Copy link
Member Author

Choose a reason for hiding this comment

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

I want to calculate how often the cache is hit.


metrics.incr(
"integrations.source_code_management.populate_trees",
tags={"cached": use_cache, "integration": self.integration_name},
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here.

break
with metrics.timer(
f"{METRIC_PREFIX}.generate_code_mappings.duration", tags={"platform": platform}
):
Copy link
Member Author

Choose a reason for hiding this comment

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

The change in this section can be more easily viewed by hiding the white spaces:
image

integration_id=organization_integration.integration_id,
with metrics.timer(
f"{METRIC_PREFIX}.create_configurations.duration", tags={"platform": platform}
):
Copy link
Member Author

Choose a reason for hiding this comment

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

Hiding the white spaces will show that only a line is changed into a multi-line.
image

@armenzg armenzg marked this pull request as ready for review March 7, 2025 15:31
@armenzg armenzg requested review from a team as code owners March 7, 2025 15:31

metrics.incr(
"integrations.source_code_management.populate_repositories",
tags={"cached": use_cache, "integration": self.integration_name},
Copy link
Member

Choose a reason for hiding this comment

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

The cardinality of self.integration_name is pretty low, right? It'll just be the SCM?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct

Comment on lines 109 to 111
use_cache = False
if not repositories:
use_cache = True
Copy link
Member

Choose a reason for hiding this comment

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

Is this inverted? If repositories is present didn't we use cache?

Copy link
Member Author

Choose a reason for hiding this comment

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

At least one of us is paying attention! 😅 Fixed now

@armenzg armenzg changed the title feat(auto_source_config): Add few more metrics feat(auto_source_config): Add a few more metrics Mar 7, 2025
@armenzg armenzg enabled auto-merge (squash) March 19, 2025 12:00
@armenzg armenzg merged commit 3743235 into master Mar 19, 2025
48 checks passed
@armenzg armenzg deleted the perf/derived_code_mapping/armenzg branch March 19, 2025 12:28
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants