Skip to content
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

feat(derived_code_mappings): Add metric for creating a repository and dry_run mode #86387

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Mar 5, 2025

This will track when a repository is created and when the metrics would have created a repository or a code mapping (useful for Java's dry run).

… dry_run mode

This will track when a repository is created and when any of the two metrics would have created a repository or code mapping (useful for Java's dry run).
@armenzg armenzg self-assigned this Mar 5, 2025
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2025
@@ -589,7 +589,7 @@ def get_path_from_module(module: str, abs_path: str) -> tuple[str, str]:
raise DoesNotFollowJavaPackageNamingConvention

# If module has a dot, take everything before the last dot
# com.example.foo.Bar$InnerClass -> com/example/foo/
# com.example.foo.Bar$InnerClass -> com/example/foo
Copy link
Member Author

Choose a reason for hiding this comment

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

To match the code.

@armenzg armenzg marked this pull request as ready for review March 5, 2025 15:39
@armenzg armenzg requested a review from a team as a code owner March 5, 2025 15:40
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 86.20690% with 4 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 77.77% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #86387       +/-   ##
===========================================
+ Coverage   42.19%   87.80%   +45.60%     
===========================================
  Files        9719     9751       +32     
  Lines      550870   552568     +1698     
  Branches    21542    21542               
===========================================
+ Hits       232463   485180   +252717     
+ Misses     318058    67039   -251019     
  Partials      349      349               

Comment on lines 214 to 218
metrics.incr(
key=f"{METRIC_PREFIX}.code_mapping.created",
tags={"platform": platform, "dry_run": dry_run},
sample_rate=1.0,
)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be under the if? I get that you're not trying to gate it by dry_run, but shouldn't it obey the if repository is not None check on creation?

Copy link
Member

Choose a reason for hiding this comment

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

UPDATE: Okay, I know you changed the logic around, but I'm still not sure I understand it. Shouldn't the code_mapping.created only fire when either:

  • we're not in dry-run, we call get_or_create, and created comes back true, or
  • we are in dry-run, so we don't call get_or_create, but if we had called it, it would have come back created = True?

The first one works with the code above, but for the second one, don't we have to make sure the record doesn't yet exist before saying that created would have been true?

@armenzg armenzg force-pushed the dry_run/metric/derived_code_mapping/armenzg branch from 8f2922d to 9d61289 Compare March 5, 2025 18:08
},
metrics.incr(
key=f"{METRIC_PREFIX}.code_mapping.created",
tags={"platform": platform, "dry_run": dry_run},
Copy link
Member Author

Choose a reason for hiding this comment

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

We're assuming that in dry run mode, it would have created the record.

project=project, stack_root=code_mapping.stacktrace_root
)
if existing_code_mappings.exists():
logger.warning("Investigate.", extra=extra)
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 should never happen, thus, logging to Sentry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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