You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-51Lines changed: 25 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,54 +4,28 @@
4
4
5
5
Flagsmith's common library
6
6
7
-
### Development Setup
7
+
##Local development
8
8
9
-
This project uses [Poetry](https://python-poetry.org/) for dependency management and includes a Makefile to simplify common development tasks.
9
+
The project assumes the following tools installed:
10
10
11
-
#### Prerequisites
11
+
-[uv](https://github.com/astral-sh/uv)
12
+
-[GNU Make](https://www.gnu.org/software/make/)
12
13
13
-
- Python >= 3.11
14
-
- Make
14
+
To list available Makefile targets, run `make help`.
15
15
16
-
#### Installation
16
+
To set up local development environment, run `make install`.
17
17
18
-
You can set up your development environment using the provided Makefile:
18
+
To run linters, run `make lint`.
19
19
20
-
```bash
21
-
# Install everything (pip, poetry, and project dependencies)
22
-
make install
20
+
To run tests, run `make test`.
23
21
24
-
# Individual installation steps are also available
25
-
make install-pip # Upgrade pip
26
-
make install-poetry # Install Poetry
27
-
make install-packages # Install project dependencies
28
-
```
29
-
30
-
#### Development
31
-
32
-
Run linting checks using pre-commit:
33
-
34
-
```bash
35
-
make lint
36
-
```
37
-
38
-
Additional options can be passed to the `install-packages` target:
39
-
40
-
```bash
41
-
# Install with development dependencies
42
-
make install-packages opts="--with dev"
43
-
44
-
# Install with specific extras
45
-
make install-packages opts="--extras 'feature1 feature2'"
46
-
```
47
-
48
-
### Usage
22
+
## Usage
49
23
50
-
####Installation
24
+
### Installation
51
25
52
-
1.`poetry add flagsmith-common`
26
+
1.Install all runtime packages: `uv add flagsmith-common[common-core,task-processor]`
53
27
54
-
2.`poetry add --G dev flagsmith-common[test-tools]` — this will enable the Pytest fixtures. Skipping this step will make Pytest collection fail due to missing dependencies.
28
+
2.To enable the Pytest fixtures, run `uv add --G dev flagsmith-common[test-tools]`. Skipping this step will make Pytest collection fail due to missing dependencies.
55
29
56
30
3. Make sure `"common.core"` is in the `INSTALLED_APPS` of your settings module.
57
31
This enables the `manage.py flagsmith` commands.
@@ -61,11 +35,11 @@ This enables the `route` label for Prometheus HTTP metrics.
61
35
62
36
5. To enable the `/metrics` endpoint, set the `PROMETHEUS_ENABLED` setting to `True`.
63
37
64
-
####Test tools
38
+
### Test tools
65
39
66
-
#####Fixtures
40
+
#### Fixtures
67
41
68
-
######`assert_metric`
42
+
##### `assert_metric`
69
43
70
44
To test your metrics using the `assert_metric` fixture:
The `saas_mode` fixture makes all `common.core.utils.is_saas` calls return `True`.
90
64
91
-
######`enterprise_mode`
65
+
##### `enterprise_mode`
92
66
93
67
The `enterprise_mode` fixture makes all `common.core.utils.is_enterprise` calls return `True`.
94
68
95
-
#####Markers
69
+
#### Markers
96
70
97
-
######`pytest.mark.saas_mode`
71
+
##### `pytest.mark.saas_mode`
98
72
99
73
Use this mark to auto-use the `saas_mode` fixture.
100
74
101
-
######`pytest.mark.enterprise_mode`
75
+
##### `pytest.mark.enterprise_mode`
102
76
103
77
Use this mark to auto-use the `enterprise_mode` fixture.
104
78
105
-
####Metrics
79
+
### Metrics
106
80
107
81
Flagsmith uses Prometheus to track performance metrics.
108
82
109
83
The following default metrics are exposed:
110
84
111
-
#####Common metrics
85
+
#### Common metrics
112
86
113
87
-`flagsmith_build_info`: Has the labels `version` and `ci_commit_sha`.
114
88
-`flagsmith_http_server_request_duration_seconds`: Histogram labeled with `method`, `route`, and `response_status`.
115
89
-`flagsmith_http_server_requests_total`: Counter labeled with `method`, `route`, and `response_status`.
116
-
-`flagsmith_http_server_response_size_bytes`:Histogram labeled with `method`, `route`, and `response_status`.
90
+
-`flagsmith_http_server_response_size_bytes`:Histogram labeled with `method`, `route`, and `response_status`.
117
91
-`flagsmith_task_processor_enqueued_tasks_total`: Counter labeled with `task_identifier`.
118
92
119
-
#####Task Processor metrics
93
+
#### Task Processor metrics
120
94
121
95
-`flagsmith_task_processor_finished_tasks_total`: Counter labeled with `task_identifier`, `task_type` (`"recurring"`, `"standard"`) and `result` (`"success"`, `"failure"`).
122
96
-`flagsmith_task_processor_task_duration_seconds`: Histogram labeled with `task_identifier`, `task_type` (`"recurring"`, `"standard"`) and `result` (`"success"`, `"failure"`).
123
97
124
-
#####Guidelines
98
+
#### Guidelines
125
99
126
100
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.
0 commit comments