-
Notifications
You must be signed in to change notification settings - Fork 515
feat: report environment metrics api #5430
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
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
4957701
feat: implementing-environment-metrics-endpoint
Zaimwa9 0d765d2
feat: gathering-segments-and-features-metrics-from-subqueries
Zaimwa9 8e66263
feat: implemented-queries-to-fetch-env-metrics
Zaimwa9 50c54f8
feat: handled-change-requests-conditionally
Zaimwa9 9cded03
feat: implemented-types-and-tests-on-per-entity-object-model
Zaimwa9 f4e865d
feat: redesigned-payload-as-flat-list-of-metrics
Zaimwa9 afbd158
feat: improved-typing
Zaimwa9 7c6627a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7830c40
feat: removed-unused-env-metrics-entities
Zaimwa9 7955347
Merge branch 'feat/report-environment-metrics' of github.com:Flagsmit…
Zaimwa9 74ce33a
feat: added-edge-identity-overrides-metric
Zaimwa9 f219849
feat: updated-metrics-tests
Zaimwa9 559cee7
feat: added-dynamodb-wrapper-test
Zaimwa9 1837fe6
Merge branch 'main' of github.com:Flagsmith/flagsmith into feat/repor…
Zaimwa9 4b28de5
feat: excluded-open-change-requests-from-features-ids
Zaimwa9 b83a2d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fab7a6f
feat: fixed-types
Zaimwa9 9a2c453
Merge branch 'feat/report-environment-metrics' of github.com:Flagsmit…
Zaimwa9 d910a6c
feat: fixed-segment-grouping-query
Zaimwa9 3ab02da
feat: improved-identity-sql-metrics
Zaimwa9 b941f9c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 68639e1
feat: reverted-to-feature-segment-ids-isolation
Zaimwa9 831a7e2
feat: pass-with-workflows-to-segments
Zaimwa9 5ca85ff
feat: reviewed-wording-titles
Zaimwa9 e63250d
Update api/environments/models.py
Zaimwa9 412e9fa
feat: use-existing-get-live-features-states
Zaimwa9 2b9a54c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 05f13a5
feat: refactored-features-aggregation-result
Zaimwa9 bd33c76
feat: simplified-and-removed-base-metrics-views
Zaimwa9 5bebf9d
feat: limited-metrics-to-view-environment-permissions
Zaimwa9 361b179
feat: fixed-conflicts
Zaimwa9 dfdd06d
feat: moved-logic-to-metrics-service
Zaimwa9 50287e1
feat: reworked-models-functions-using-get-live-features
Zaimwa9 79346f8
feat: added-documentation-and-removed-dead-code-path
Zaimwa9 852ca8f
feat: removed-redundant-code
Zaimwa9 367eafa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 24fdc04
feat: added-extra-fake-versions-of-feature-states-in-test
Zaimwa9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,7 @@ | |
| "projects.tags", | ||
| "api_keys", | ||
| "webhooks", | ||
| "metrics", | ||
| "onboarding", | ||
| # 2FA | ||
| "custom_auth.mfa.trench", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class MetricsAppConfig(AppConfig): | ||
| name = "metrics" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| from metrics.types import EnvMetricsEntities, EnvMetricsName, MetricDefinition | ||
|
|
||
| TOTAL_FEATURES: MetricDefinition = { | ||
| "name": EnvMetricsName.TOTAL_FEATURES, | ||
| "description": "Total features", | ||
| "entity": EnvMetricsEntities.FEATURES, | ||
| "rank": 1, | ||
| } | ||
|
|
||
| ENABLED_FEATURES: MetricDefinition = { | ||
| "name": EnvMetricsName.ENABLED_FEATURES, | ||
| "description": "Features enabled", | ||
| "entity": EnvMetricsEntities.FEATURES, | ||
| "rank": 2, | ||
| } | ||
|
|
||
| SEGMENT_OVERRIDES: MetricDefinition = { | ||
| "name": EnvMetricsName.SEGMENT_OVERRIDES, | ||
| "description": "Segment overrides", | ||
| "entity": EnvMetricsEntities.SEGMENTS, | ||
| "rank": 3, | ||
| } | ||
|
|
||
| IDENTITY_OVERRIDES: MetricDefinition = { | ||
| "name": EnvMetricsName.IDENTITY_OVERRIDES, | ||
| "description": "Identity overrides", | ||
| "entity": EnvMetricsEntities.IDENTITIES, | ||
| "rank": 4, | ||
| } | ||
|
|
||
| OPEN_CHANGE_REQUESTS: MetricDefinition = { | ||
| "name": EnvMetricsName.OPEN_CHANGE_REQUESTS, | ||
| "description": "Open change requests", | ||
| "entity": EnvMetricsEntities.WORKFLOWS, | ||
| "rank": 5, | ||
| } | ||
|
|
||
| TOTAL_SCHEDULED_CHANGES: MetricDefinition = { | ||
| "name": EnvMetricsName.TOTAL_SCHEDULED_CHANGES, | ||
| "description": "Scheduled changes", | ||
| "entity": EnvMetricsEntities.WORKFLOWS, | ||
| "rank": 6, | ||
| } | ||
|
|
||
|
|
||
| DEFAULT_METRIC_DEFINITIONS: list[MetricDefinition] = [ | ||
| TOTAL_FEATURES, | ||
| ENABLED_FEATURES, | ||
| SEGMENT_OVERRIDES, | ||
| IDENTITY_OVERRIDES, | ||
| ] | ||
|
|
||
| WORKFLOW_METRIC_DEFINITIONS: list[MetricDefinition] = [ | ||
| OPEN_CHANGE_REQUESTS, | ||
| TOTAL_SCHEDULED_CHANGES, | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you share the sql query and query plan generated by this
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.
My sample is relatively small but:
It might be worth to add an index on
(environment_id, live_from, deleted_at)wdyt ?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.
To go a bit further. Once completely validated, I think the metrics could be cached and invalidated on flags update etc, a bit overkill right now imo (it is controlled by a flag in the frontend for now).
Besides some pages where the code hasn't been migrated yet, it's cached with RTK and invalidated on actions related to those (not identity for now)
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.
Can you also share the SQL query?
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.
yes, here