feat: Backend for SDK metrics#5623
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
a36fe70 to
2b706ee
Compare
2b706ee to
88498ed
Compare
88498ed to
421522b
Compare
421522b to
8664928
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5623 +/- ##
==========================================
+ Coverage 97.77% 97.81% +0.04%
==========================================
Files 1255 1257 +2
Lines 44420 44586 +166
==========================================
+ Hits 43430 43612 +182
+ Misses 990 974 -16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8664928 to
2a67741
Compare
2a67741 to
02c72e2
Compare
4e7697a to
0d8d43f
Compare
|
Added |
| "django.contrib.contenttypes", | ||
| "django.contrib.sessions", | ||
| "django.contrib.messages", | ||
| "django.contrib.postgres", |
There was a problem hiding this comment.
This might cause an issue in EE repo for oracle?
There was a problem hiding this comment.
Do we have to have settings/common.py identical to the open source one?
|
|
||
| from . import constants | ||
| from .types import PERIOD_TYPE | ||
| logger = getLogger(__name__) |
There was a problem hiding this comment.
It seems to me like we should standardise on one approach, and we can always filter events out that we don't care about on the other end, right?
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature!Changes
Closes #5581.
Contributes to #2479.
This PR adds support for optional header tracking in the backend. It adds extensible, fully typed mechanism to support other optional labels for analytics in the future. The usage data and feature evaluation data routes are updated to return labeled data buckets. Additionally, numerous typing and code structure improvements are introduced to the analytics-related code base.
SDK API
All tracked SDK APIs now expect the following optional headers, translated to labels written to PostgreSQL or InfluxDB usage and evaluation data buckets:
Flagsmith-Application-Nameheader:client_application_namelabelFlagsmith-Application-Versionheader:client_application_versionlabelUser-Agentheader:user_agentlabelRelevant caches and tasks are changed to properly compact the raw data, producing buckets with unique label sets.
Management API
The following API routes are updated to support labels:
/api/v1/organisations/{organisation_pk}/usage-data//api/v1/projects/{project_pk}/features/{id}/evaluation-data/Previously, these routes were returning one bucket per day. Now, multiple buckets can be attributed to the same day, as long as they have different unique label sets. The label sets are returned under the
labelkey for each bucket:Both of them now accept new query parameters:
client_application_nameclient_application_versionuser_agentto allow bucket filtering by label.
The feature is hidden behind the
"sdk_metrics_labels"flag.Task processing
Due to incompatible signature change, the
track_feature_evaluationis decommissioned in favour of the newtrack_feature_evaluations_by_environmenttask, which now supports labels included as part of feature evaluation data.How did you test this code?
Unit tests have been added and updated to reflect new behaviour. Manually with local PostgreSQL storage. Additional tests will be conducted in staging against InfluxDB Cloud to measure the performance.