Skip to content

Feature request: allow disabling "_created" series from code #933

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

Closed
positron96 opened this issue Jul 6, 2023 · 3 comments · Fixed by #973
Closed

Feature request: allow disabling "_created" series from code #933

positron96 opened this issue Jul 6, 2023 · 3 comments · Fixed by #973

Comments

@positron96
Copy link
Contributor

At the moment, "_created" series can be disabled by setting PROMETHEUS_DISABLE_CREATED_SERIES environment variable. If one wants to set it from python, he needs to do it before importing prometheus_client, because the value is calculated on import.
Like this:

os.environ['PROMETHEUS_DISABLE_CREATED_SERIES'] = 'true'
import prometheus_client

That is not very pythonic, style checkers complain on imports not being at top of the file, etc.

Please add an ability to set this option from code, from function call, of just make _use_created variable in metrics.py public.

@jiaxinonly
Copy link

Agreed, the ability to disable from code should be added.

@csmarchbanks
Copy link
Member

I was looking into doing this and see two options:

  1. Allow access to the global variable, probably a function like disable_created_series() that sets _use_created to false.
  2. Allow each registry to have _created series enabled/disabled.

Do we know of use cases where some collectors would like to have _created series and others do not? My thought is that a global setting is probably good enough since your system will either understand _created or not.

@positron96
Copy link
Contributor Author

For me it's good enough to have a global option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants