flagsmith-common 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. common/__init__.py +0 -0
  2. common/core/__init__.py +0 -0
  3. common/core/app.py +6 -0
  4. common/core/logging.py +24 -0
  5. common/core/main.py +40 -0
  6. common/core/management/__init__.py +0 -0
  7. common/core/management/commands/__init__.py +0 -0
  8. common/core/management/commands/start.py +41 -0
  9. common/core/metrics.py +23 -0
  10. common/core/urls.py +17 -0
  11. common/core/utils.py +90 -0
  12. common/core/views.py +23 -0
  13. common/environments/permissions.py +15 -0
  14. common/features/__init__.py +0 -0
  15. common/features/multivariate/__init__.py +0 -0
  16. common/features/multivariate/serializers.py +19 -0
  17. common/features/serializers.py +68 -0
  18. common/features/versioning/__init__.py +0 -0
  19. common/features/versioning/serializers.py +13 -0
  20. common/gunicorn/__init__.py +0 -0
  21. common/gunicorn/conf.py +18 -0
  22. common/gunicorn/constants.py +1 -0
  23. common/gunicorn/logging.py +94 -0
  24. common/gunicorn/metrics.py +14 -0
  25. common/gunicorn/middleware.py +28 -0
  26. common/gunicorn/utils.py +61 -0
  27. common/metadata/serializers.py +100 -0
  28. common/organisations/permissions.py +10 -0
  29. common/projects/permissions.py +40 -0
  30. common/prometheus/__init__.py +3 -0
  31. common/prometheus/utils.py +18 -0
  32. common/py.typed +0 -0
  33. common/segments/serializers.py +338 -0
  34. common/test_tools/__init__.py +3 -0
  35. common/test_tools/plugin.py +34 -0
  36. common/test_tools/types.py +11 -0
  37. common/types.py +45 -0
  38. flagsmith_common-1.5.0.dist-info/LICENSE +28 -0
  39. flagsmith_common-1.5.0.dist-info/METADATA +128 -0
  40. flagsmith_common-1.5.0.dist-info/RECORD +42 -0
  41. flagsmith_common-1.5.0.dist-info/WHEEL +4 -0
  42. flagsmith_common-1.5.0.dist-info/entry_points.txt +6 -0
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.3
2
+ Name: flagsmith-common
3
+ Version: 1.5.0
4
+ Summary: Flagsmith's common library
5
+ License: BSD-3-Clause
6
+ Author: Matthew Elwell
7
+ Maintainer: Flagsmith Team
8
+ Maintainer-email: support@flagsmith.com
9
+ Requires-Python: >=3.11,<4.0
10
+ Classifier: Framework :: Django
11
+ Classifier: Framework :: Pytest
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: BSD License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Dist: django (<5)
19
+ Requires-Dist: django-health-check
20
+ Requires-Dist: djangorestframework
21
+ Requires-Dist: djangorestframework-recursive
22
+ Requires-Dist: drf-writable-nested
23
+ Requires-Dist: environs (<15)
24
+ Requires-Dist: flagsmith-flag-engine
25
+ Requires-Dist: gunicorn (>=19.1)
26
+ Requires-Dist: prometheus-client (>=0.0.16)
27
+ Project-URL: Download, https://github.com/flagsmith/flagsmith-common/releases
28
+ Project-URL: Homepage, https://flagsmith.com
29
+ Project-URL: Issues, https://github.com/flagsmith/flagsmith-common/issues
30
+ Project-URL: Repository, https://github.com/flagsmith/flagsmith-common
31
+ Description-Content-Type: text/markdown
32
+
33
+ # flagsmith-common
34
+ Flagsmith's common library
35
+
36
+ ### Development Setup
37
+
38
+ This project uses [Poetry](https://python-poetry.org/) for dependency management and includes a Makefile to simplify common development tasks.
39
+
40
+ #### Prerequisites
41
+
42
+ - Python >= 3.11
43
+ - Make
44
+
45
+ #### Installation
46
+
47
+ You can set up your development environment using the provided Makefile:
48
+
49
+ ```bash
50
+ # Install everything (pip, poetry, and project dependencies)
51
+ make install
52
+
53
+ # Individual installation steps are also available
54
+ make install-pip # Upgrade pip
55
+ make install-poetry # Install Poetry
56
+ make install-packages # Install project dependencies
57
+ ```
58
+
59
+ By default, Poetry version 2.0.1 will be installed. You can specify a different version:
60
+
61
+ ```bash
62
+ make install-poetry POETRY_VERSION=2.1.0
63
+ ```
64
+
65
+ #### Development
66
+
67
+ Run linting checks using pre-commit:
68
+
69
+ ```bash
70
+ make lint
71
+ ```
72
+
73
+ Additional options can be passed to the `install-packages` target:
74
+
75
+ ```bash
76
+ # Install with development dependencies
77
+ make install-packages opts="--with dev"
78
+
79
+ # Install with specific extras
80
+ make install-packages opts="--extras 'feature1 feature2'"
81
+ ```
82
+
83
+ ### Usage
84
+
85
+ #### Installation
86
+
87
+ 1. Make sure `"common.core"` is in the `INSTALLED_APPS` of your settings module.
88
+ This enables the `manage.py flagsmith` commands.
89
+
90
+ 2. Add `"common.gunicorn.middleware.RouteLoggerMiddleware"` to `MIDDLEWARE` in your settings module.
91
+ This enables the `route` label for Prometheus HTTP metrics.
92
+
93
+ 3. To enable the `/metrics` endpoint, set the `PROMETHEUS_ENABLED` setting to `True`.
94
+
95
+ #### Metrics
96
+
97
+ Flagsmith uses Prometheus to track performance metrics.
98
+
99
+ The following default metrics are exposed:
100
+
101
+ - `flagsmith_build_info`: Has the labels `version` and `ci_commit_sha`.
102
+ - `http_server_request_duration_seconds`: Histogram labeled with `method`, `path`, and `response_status`.
103
+ - `http_server_requests_total`: Counter labeled with `method`, `path`, and `response_status`.
104
+
105
+ ##### Guidelines
106
+
107
+ Try to come up with meaningful metrics to cover your feature with when developing it. Refer to [Prometheus best practices][1] when naming your metric and labels.
108
+
109
+ Define your metrics in a `metrics.py` module of your Django application — see [example][2]. Contrary to Prometheus Python client examples and documentation, please name a metric variable exactly as your metric name.
110
+
111
+ It's generally a good idea to allow users to define histogram buckets of their own. Flagsmith accepts a `PROMETHEUS_HISTOGRAM_BUCKETS` setting so users can customise their buckets. To honour the setting, use the `common.prometheus.Histogram` class when defining your histograms. When using `prometheus_client.Histogram` directly, please expose a dedicated setting like so:
112
+
113
+ ```python
114
+ import prometheus_client
115
+ from django.conf import settings
116
+
117
+ distance_from_earth_au = prometheus.Histogram(
118
+ "distance_from_earth_au",
119
+ "Distance from Earth in astronomical units",
120
+ buckets=settings.DISTANCE_FROM_EARTH_AU_HISTOGRAM_BUCKETS,
121
+ )
122
+ ```
123
+
124
+ [1]: https://prometheus.io/docs/practices/naming/
125
+ [2]: https://github.com/Flagsmith/flagsmith-common/blob/main/src/common/gunicorn/metrics.py
126
+ [3]: https://docs.gunicorn.org/en/stable/design.html#server-model
127
+ [4]: https://prometheus.github.io/client_python/multiprocess
128
+
@@ -0,0 +1,42 @@
1
+ common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ common/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ common/core/app.py,sha256=QRhmj2MPnbPwjjEje-QDlmgQuYWNq7cGoUiCf8Ky_GU,116
4
+ common/core/logging.py,sha256=r2Ig21YIfq-R4MhtF614N2UjhW6EH1_Zs9BhrVLSQFk,807
5
+ common/core/main.py,sha256=_-mzfs_lyct0kjQBD-hmalJ6h7IijFxyGTvGpcBSkeQ,1157
6
+ common/core/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ common/core/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ common/core/management/commands/start.py,sha256=uexgTtsW9_Gu2atZA33XpSEQFRCj_Bk09THYG_6We4o,1199
9
+ common/core/metrics.py,sha256=m-1XyO-HoOZXyc6wUmW6-dMLdiH4HcQhpNgFvTNtmh0,563
10
+ common/core/urls.py,sha256=z9q_Ua-5F_2-UM2JdnMPuPf2NU_T91ujUxJJrThfWYI,774
11
+ common/core/utils.py,sha256=f2FRNdB1r10p5gwgZ5CEkaXCCie_ocpczfYEtpFrj_M,2645
12
+ common/core/views.py,sha256=QdXUaIgFQ28bLAVkEaQt3D6-X3iw-FeE4dWndH5dues,612
13
+ common/environments/permissions.py,sha256=TkYOcRBYogasSJTMS1YxLffucO7ItsTklq3aRHalFhY,494
14
+ common/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ common/features/multivariate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ common/features/multivariate/serializers.py,sha256=lryUuwSMC7-fo60KhyQRY-GPCaTF6Fzwy4qFZtdXozw,522
17
+ common/features/serializers.py,sha256=qodyM6cGaCP8IHwyYuex_9CJMDBUDt9RUnHEo5zD7Q4,1995
18
+ common/features/versioning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ common/features/versioning/serializers.py,sha256=iyMrjy7_JsjD7E6KOSAd3P8QAhReEnAVgHkpt6BCAaA,439
20
+ common/gunicorn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ common/gunicorn/conf.py,sha256=rht6KqrnYpHRjP-3S8kwJEYIqjWkDX9Ggl-JAW_J4Kw,641
22
+ common/gunicorn/constants.py,sha256=r83k97_qe8gcqK9QSrfEuKnhkwAMtMDIl8Sa0TQcDnE,52
23
+ common/gunicorn/logging.py,sha256=QGoNRy8a81l-QGeFUNyv2xbePojelRNgK5Ko2qAZxjw,3165
24
+ common/gunicorn/metrics.py,sha256=F8sUz-t9Ykfx6rFMy1ZmTPgrIVfxrmmPCUV0lD_SEYE,420
25
+ common/gunicorn/middleware.py,sha256=iPM3LRw-kHVWgratNKy66B7PSoivjtecl-9bTPYp-b4,881
26
+ common/gunicorn/utils.py,sha256=N0nu8UciKbldN1blzpDUWWZdwe2Mni40SoeyS4Z1a_0,2229
27
+ common/metadata/serializers.py,sha256=9bMPakNZxaAKhx4uIDWDtITbt6PlPIgnjU1CHeDVPrk,3262
28
+ common/organisations/permissions.py,sha256=zTtJHWGJU2JUV_GRb3RxsMYuWL01tyEiEbbAztmQ09s,318
29
+ common/projects/permissions.py,sha256=uQXxfYhTtXk3JGukxUmXHULp2xPH4HaM1E0uQ4SxGcE,1677
30
+ common/prometheus/__init__.py,sha256=iw9EDPtC-NnbuPequjwFLIwGKEq5vnWIsyX2hcX_7Bk,72
31
+ common/prometheus/utils.py,sha256=_qsN5wfA7pA4RfpPDyqfwmvLAkCjarmL3QUjZOFuIek,555
32
+ common/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ common/segments/serializers.py,sha256=Si9H2ccVgEa4KOjs8BqqGzEmCqemu43EnVKVV_Zcoco,12660
34
+ common/test_tools/__init__.py,sha256=cTLbunC3SoXQmCuz5S25h2_9ls9Es6jczDr6VqPOhSE,92
35
+ common/test_tools/plugin.py,sha256=7Sj3g63ESAVhlzfw-VKj40R-8e1zjckQhh4mpghZ82w,937
36
+ common/test_tools/types.py,sha256=WXh3j_P0KmcQKJ9CxT_Bo4OPjuQ_reipa9lVHqgcRW8,208
37
+ common/types.py,sha256=sgj8cUAG75EylkUNLvvg4aAn8tVpsSe_QU9idM24gL0,1341
38
+ flagsmith_common-1.5.0.dist-info/LICENSE,sha256=54EKQkJZc4xBIMpkJNo9EdvDXGq5TefERvXaIFF8Dac,1496
39
+ flagsmith_common-1.5.0.dist-info/METADATA,sha256=49cFv_IQpVYKqjYJ_RWuZevax1qVSLwU3v_K4MxiDqQ,4430
40
+ flagsmith_common-1.5.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
41
+ flagsmith_common-1.5.0.dist-info/entry_points.txt,sha256=SsKB3kaA63LHPbpX4wXe7twAm956lPEt28m5GUquYeI,109
42
+ flagsmith_common-1.5.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.0.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,6 @@
1
+ [console_scripts]
2
+ flagsmith=common.core.main:main
3
+
4
+ [pytest11]
5
+ flagsmith-test-tools=common.test_tools.plugin
6
+