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(relay): Emit empty alert metrics config #51788

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

jan-auer
Copy link
Member

Closes #51445

@jan-auer jan-auer requested a review from a team June 28, 2023 11:03
@jan-auer jan-auer self-assigned this Jun 28, 2023
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 28, 2023
@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Merging #51788 (87360e0) into master (f7eec30) will not change coverage.
The diff coverage is 67.27%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #51788   +/-   ##
=======================================
  Coverage    81.30    81.30           
=======================================
  Files        4899     4899           
  Lines      205623   205671   +48     
  Branches    11051    11051           
=======================================
+ Hits       167178   167205   +27     
- Misses      38200    38221   +21     
  Partials      245      245           
Impacted Files Coverage Δ
src/sentry/relay/config/metric_extraction.py 83.18% <66.03%> (-15.30%) ⬇️
src/sentry/relay/config/__init__.py 97.04% <100.00%> (+0.01%) ⬆️

... and 3 files with indirect coverage changes

@jan-auer jan-auer merged commit aa81d5c into master Jun 28, 2023
@jan-auer jan-auer deleted the feat/metric-extraction-project-config branch June 28, 2023 14:26
Copy link
Contributor

@iker-barriocanal iker-barriocanal left a comment

Choose a reason for hiding this comment

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

Arrived a bit late here, but please consider limiting the size of the number of metrics in project configs.


class RuleConditionInner(TypedDict):
op: Literal["eq", "gt", "gte"]
RuleCondition = Union["LogicalRuleCondition", "ComparingRuleCondition", "NotRuleCondition"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the most readable way to make a union of types? Does rule inheritance (more types) or Protocol (PEP 544) (fewer types) make things easier to read?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since most of these types are extremely similar and separate types do not give us a benefit on typed dicts, I'd opt for readability with fewer types.

How would you propose to write it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe with Protocol but not strongly opinionated. My suggestion comes from me not liking types coming from strings this way.

Comment on lines +62 to +64
class MetricExtractionConfig(TypedDict):
version: int
metrics: List[MetricSpec]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we postponing the addition of tags here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping it simple at this point since it is neither implemented in relay (just the schema). This can be added once the functionality is used.

src/sentry/relay/config/metric_extraction.py Show resolved Hide resolved
Comment on lines +49 to +50
field: NotRequired[str]
value: NotRequired[str]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a comment that one of them is required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Generally we should add more comments here describing the types. I initially kept it plain since I didn't want to duplicate too much from relay's typing.

Since I'm gonna add tests, I'll also add a few comments explaining this.

src/sentry/relay/config/metric_extraction.py Show resolved Hide resolved
src/sentry/relay/config/metric_extraction.py Show resolved Hide resolved
@sentry-io
Copy link

sentry-io bot commented Jun 28, 2023

Suspect Issues

This pull request has been deployed and Sentry has observed the following issues:

  • ‼️ FieldError: Cannot resolve keyword 'project' into field. Choices are: alertruleactivity, alertruleexcludedpro... sentry.tasks.relay.build_project_config View Issue

Have questions? Reach out to us in the #proj-github-pr-comments channel.

Did you find this useful? React with a 👍 or 👎

@wedamija wedamija added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Jun 28, 2023
@getsentry-bot
Copy link
Contributor

PR reverted: 03769a5

getsentry-bot added a commit that referenced this pull request Jun 28, 2023
This reverts commit aa81d5c.

Co-authored-by: wedamija <6288560+wedamija@users.noreply.github.com>


def get_metric_extraction_config(project: Project) -> Optional[MetricExtractionConfig]:
if not features.has("organizations:metrics-extraction", project.organization):
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 wrong feature flag.

@jan-auer jan-auer restored the feat/metric-extraction-project-config branch June 29, 2023 06:52
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2023
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 Trigger: Revert Add to a merged PR to revert it (skips CI)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit alert metrics into project config computation
6 participants