Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add label 'state' to metric 'gitea_users' #34326

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tobiasbp
Copy link
Contributor

@tobiasbp tobiasbp commented Apr 30, 2025

This PR adds the label state to the metric gitea_users. With the change, gitea_users would be reported like this:

...
# HELP gitea_users Number of Users
# TYPE gitea_users gauge
gitea_users{state="active"} 20
gitea_users{state="inactive"} 10
...

The metrics above would be from a Gitea instance with 30 user accounts. 20 of the accounts are active and 10 of the accounts are not active.

Resolve #34325

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 30, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Apr 30, 2025
@TheFox0x7
Copy link
Contributor

I'd personally prefer to have label state with active,inactive states. It's more flexible that way in case of extension needed.

# HELP gitea_users Number of Users
# TYPE gitea_users gauge
gitea_users{state="active"} 20
gitea_users{state="inactive"} 10

Also the metrics should probably end with _total, but I have to doublecheck this...

@tobiasbp
Copy link
Contributor Author

tobiasbp commented Apr 30, 2025

I'd personally prefer to have label state with active,inactive states. It's more flexible that way in case of extension needed.

Good suggestion. I'll change it.

@tobiasbp
Copy link
Contributor Author

Also the metrics should probably end with _total, but I have to doublecheck this...

I'm not sure about making that change a part of this PR, since it would be a breaking change.

@tobiasbp tobiasbp changed the title feat: add label 'is_active' to metric 'gitea_users' feat: add label 'state' to metric 'gitea_users' Apr 30, 2025
@TheFox0x7
Copy link
Contributor

I'm not sure about making that change a part of this PR, since it would be a breaking change.

Sorry, I didn't look that closely at the code and figured it's a new metric. In this case you're right, it's not worth breaking here, I've been meaning to clean this up anyway (whenever I finally set my infrastructure up to actually gather and see those...) so I'll look at doing this then.

@lunny
Copy link
Member

lunny commented Apr 30, 2025

How about keep the old metric as total users and added a new active users, removing the inactive users.

@lunny lunny added this to the 1.25.0 milestone Apr 30, 2025
@lunny lunny added the type/enhancement An improvement of existing functionality label Apr 30, 2025
@TheFox0x7
Copy link
Contributor

I get that would be fully backwards compatible but it feels wrong to do IMO.
gitea_users still has the total user amount here - it's just split between user states (active/inactive). Those are directly linked to the metrics itself so label. You still can get the old amount by summing.
Contrast it with gitea_users, gitea_users_inactive and the derived active users: gitea_users - gitea_users_inactive.

Also labels better show links between metrics, than having two separate ones.

@techknowlogick techknowlogick added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label May 1, 2025
@techknowlogick
Copy link
Member

Added the "breaking" label to make sure we mention this in release notes. FWIW I think this change is beneficial and should be included. If it's not done in a backwards compatible way, that's probably ok since we have a process for alerting users.

@tobiasbp
Copy link
Contributor Author

tobiasbp commented May 1, 2025

I get that would be fully backwards compatible but it feels wrong to do IMO.

I agree. It's much cleaner to keep the current metric and just add the label.

@tobiasbp
Copy link
Contributor Author

tobiasbp commented May 1, 2025

Added the "breaking" label to make sure we mention this in release notes.

Adding a label is not a breaking change. If a user does not specify a label, they get the current value (the total number of user accounts).

@TheFox0x7
Copy link
Contributor

I might be misremembering but don't they get both metrics separately and you need to sum them to get the total number?

@tobiasbp
Copy link
Contributor Author

tobiasbp commented May 1, 2025

I might be misremembering but don't they get both metrics separately and you need to sum them to get the total number?

Actually, I think you and @techknowlogick are right. Adding the label is a breaking change since users would get two metrics, and would need to sum to get to the current value (as you describe).

@tobiasbp
Copy link
Contributor Author

tobiasbp commented May 6, 2025

Do you think we need any changes made to this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add label 'is_active' to 'gitea_users' metric.
5 participants