• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Unleash / unleash-client-python / 5255151135
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: pre-commit-ci-update-config
DEFAULT BRANCH: master
Ran 13 Jun 2023 12:16PM UTC
Jobs 1
Files 30
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
5255151135

push

github

web-flow
Count metrics for non-existing features (#256)

## Description

This PR is the follow-up to #253 and makes the client track metrics for features that don't exist.

It achieves this by modifying the Unleash client's `is_enabled` and `get_variant` methods:
Whenever they are called with a feature that doesn't exist, we create a new feature with that name, `enabled = False`, no strategies, and no variants. The feature gets added to the clients list of features, and is then queried for its state (to track metrics; we know it'll be false).

The tests ensure that metrics are sent for these nonexistent features, but does not care about the implementation, so we should be able to change that as much as we want later.

### Discussion point

I've been back and forth a couple of times regarding how best to track these features. Because the `send_metrics` function already takes care of everything related to sending and resetting metrics, it'd be nice to leave that as it is. As such, it'd be nice to track nonexistent features as part of the regular list of features. 

The current implementation uses a boolean field to indicate whether a feature exists only to track metrics or whether it should be evaluated properly. I considered using a subclass to tell them apart instead, but because the loader (`loader.py`) simply **updates** the objects instead of replacing them wholesale (probably to preserve metrics), then that caused some problems.

## Commits

* Test: add initial tests for new metrics behavior

* test: make tests run properly

* Feat: register metrics for features that don't exist

* Chore: run black

* Test: check that metrics are tracked before initialization too

* Test: remove test that didn't make sense

* feat: use a `only_for_metrics` field for metrics-only toggles

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] ... (continued)

831 of 856 relevant lines covered (97.08%)

0.97 hits per line

Jobs
ID Job ID Ran Files Coverage
1 5255151135.1 13 Jun 2023 12:16PM UTC 30
97.08
Source Files on build 5255151135
  • Tree
  • List 30
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 0805c6b3 on github
  • Next Build on v5.7.0 (#5422589595)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc