Skip to content

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

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Zaimwa9
Copy link
Contributor

@Zaimwa9 Zaimwa9 commented May 7, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

image

Aim of this PR is to provide an endpoint returning a set of environment-level metrics:

  • Total features

  • Features enabled

  • Segment override

  • Identity override (not yet implemented)

  • Open change requests

  • Scheduled change to come

  • Created a metric nested within environment view

/api/v1/environments/<environment_api_key>/metrics/	
environments.views.EnvironmentMetricsViewSet	
api-v1:environments:environment-metrics-list
  • Added environment model methods to aggregate the metrics
  • Added serializers and service methods

Payload example:

{
    "metrics": [
        {
            "value": 3,
            "description": "Total features",
            "name": "total_features",
            "disabled": false,
            "entity": "features",
            "rank": 1
        },
        {
            "value": 2,
            "description": "Features enabled",
            "name": "enabled_features",
            "disabled": false,
            "entity": "features",
            "rank": 2
        },
        {
            "value": 0,
            "description": "Segment Overrides",
            "name": "segment_overrides",
            "disabled": false,
            "entity": "segments",
            "rank": 3
        },
        {
            "value": 1,
            "description": "Open change requests",
            "name": "open_change_requests",
            "disabled": false,
            "entity": "change_requests",
            "rank": 4
        },
        {
            "value": 1,
            "description": "Total scheduled changes",
            "name": "total_scheduled_changes",
            "disabled": false,
            "entity": "scheduled_changes",
            "rank": 5
        }
    ]
}

How did you test this code?

  • New tests
  • Via requests
http://localhost:8000/api/v1/environments/<EnvID>/metrics/

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner May 7, 2025 15:27
@Zaimwa9 Zaimwa9 requested review from khvn26 and removed request for a team May 7, 2025 15:27
Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview May 8, 2025 1:24pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview May 8, 2025 1:24pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview May 8, 2025 1:24pm

@Zaimwa9 Zaimwa9 marked this pull request as draft May 7, 2025 15:28
@github-actions github-actions bot added the api Issue related to the REST API label May 7, 2025
Copy link
Contributor

github-actions bot commented May 7, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-5430 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-5430 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-5430 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-5430 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5430 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-5430 Finished ✅ Results

@github-actions github-actions bot added the feature New feature or request label May 7, 2025
Copy link
Contributor

github-actions bot commented May 7, 2025

Uffizzi Ephemeral Environment Deploying

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5430

⚙️ Updating now by workflow run 14887281399.

What is Uffizzi? Learn more!

Copy link
Contributor

github-actions bot commented May 7, 2025

Uffizzi Ephemeral Environment Deploying

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5430

⚙️ Updating now by workflow run 14907622421.

What is Uffizzi? Learn more!

…h/flagsmith into feat/report-environment-metrics
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels May 7, 2025
Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.64%. Comparing base (1d98d27) to head (559cee7).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5430      +/-   ##
==========================================
+ Coverage   97.62%   97.64%   +0.01%     
==========================================
  Files        1239     1242       +3     
  Lines       43089    43220     +131     
==========================================
+ Hits        42066    42202     +136     
+ Misses       1023     1018       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels May 8, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels May 8, 2025
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant