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: add org generic counters [TET-695] #3708

Merged
merged 9 commits into from
Feb 8, 2023

Conversation

andriisoldatenko
Copy link
Contributor

@andriisoldatenko andriisoldatenko commented Feb 6, 2023

This PR adds the ability to query cross org query for the generic metric counter.

@andriisoldatenko andriisoldatenko force-pushed the andrii/add-org-generic-counter branch from 7f5302a to d6f927e Compare February 6, 2023 19:13
@@ -0,0 +1,57 @@
version: v1
kind: entity
name: org_metrics_counters
Copy link
Member

Choose a reason for hiding this comment

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

I would make this generic_org_metrics_counters, otherwise the name will collide with the existing entity.

required_time_column: timestamp

storages:
- storage: org_metrics_counters
Copy link
Member

Choose a reason for hiding this comment

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

I mentioned this in Slack, but this storage is referencing the release health metrics counters. You will need a new storage in generic_metrics/storages/ that will be very similar to this one, but with a new name. Then you can reference that storage here.

name: generic_org_metrics_counters
storage:
key: generic_org_metrics_counters
set_key: generic_org_metrics_counters
Copy link
Member

Choose a reason for hiding this comment

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

This should be generic_metrics_counters. The set_key is different from the key, and specifies which cluster the storage is referencing. You don't need a new cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@andriisoldatenko andriisoldatenko marked this pull request as ready for review February 6, 2023 21:27
@andriisoldatenko andriisoldatenko requested a review from a team as a code owner February 6, 2023 21:27
@andriisoldatenko andriisoldatenko changed the title feat: add org generic counters feat: add org generic counters [TET-695] Feb 7, 2023
Copy link
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

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

This all looks good to me, but I think you should add a test here so you can do an E2E check of the new entity: https://github.com/getsentry/snuba/blob/master/tests/test_generic_metrics_api.py

@andriisoldatenko
Copy link
Contributor Author

This all looks good to me, but I think you should add a test here so you can do an E2E check of the new entity: https://github.com/getsentry/snuba/blob/master/tests/test_generic_metrics_api.py

do you want me to add TestGenericMetricsApiCounter and TestOrgMetricsApiCounter ?

@andriisoldatenko andriisoldatenko force-pushed the andrii/add-org-generic-counter branch from f8bd089 to ba623a4 Compare February 8, 2023 12:51
Copy link
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

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

Looks good!

{ name: project_id, type: UInt, args: { size: 64 } },
{ name: metric_id, type: UInt, args: { size: 64 } },
{ name: granularity, type: UInt, args: { size: 8 } },
{ name: timestamp, type: DateTime },
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need it here, @evanh @untitaker wdyt?
I'm not very familiar with how this will work under the hood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

only i can say it works with and without this block. i just did quick test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, yeah I prefer to implement as minimally as we need. So later we can extend.

@andriisoldatenko andriisoldatenko merged commit 284e3b5 into master Feb 8, 2023
@andriisoldatenko andriisoldatenko deleted the andrii/add-org-generic-counter branch February 8, 2023 18:21
andriisoldatenko pushed a commit to getsentry/sentry that referenced this pull request Feb 28, 2023
#42939)

This PR implements prioritize by project bias.

In detail: 
We run celery task every 24 at 8:00AM (UTC randomly selected) for every
ORG (we call it *prioritise by project snuba query* ) and all projects
inside this org, and for a given combination of org and projects run an
adjustment model to recalculate sample rates if necessary.

Then we cache sample rate using redis cluster ->
`SENTRY_DYNAMIC_SAMPLING_RULES_REDIS_CLUSTER` using this pattern for
key: `f"ds::o:{org_id}:p:{project_id}:prioritise_projects"`.

When relay fetches `projectconfig` endpoint we run `generate_rules`
functions to generate all dynamic sampling biases, so and we check if we
have adjusted sample rate for this project in the cache, so we apply it
as **uniform bias**, otherwise we use default one.

Regarding *prioritize by project snuba query* is cross org snuba query
that utilizes a new generic counter metric, which was introduced in
[relay]( getsentry/relay#1734)
`c:transactions/count_per_root_project@none`.

TODO:
- [x] Provision infrastructure to run clickhouse clusters for the
counters tables. This is primarily dependent on ops
- [x] Start running the snuba consumers to read and write to the
counters table. SnS can work on this
- [x] Add unit-tests;
- [x] Update snuba query using new metric
- [x] Hide behind feature flag 


related PRs:
- Implement new metric in relay:
getsentry/relay#1734
- Add org generic counters [TET-695]
getsentry/snuba#3708
- Introduce new storages for counters in snuba
getsentry/snuba#3679
- Add feature flag: https://github.com/getsentry/getsentry/pull/9323
- Add cross organization methods for the string indexer #45076
#45076

[TET-695]:
https://getsentry.atlassian.net/browse/TET-695?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Co-authored-by: Nar Saynorath <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants