Apollo-Roboto / discord.py-ext-prometheus

Add Prometheus to your Discord bot with this handy extension
https://pypi.org/project/discord-ext-prometheus/
MIT License
15 stars 5 forks source link

Feature: No fixed objects #14

Closed regulad closed 6 months ago

regulad commented 7 months ago

Allows the library to be used with custom prometheus registries && more portable code

Apollo-Roboto commented 7 months ago

Thanks for the contribution!

Please separate the dependency changes into another pull request so I can merge it sooner. That part looks good :)

Also, can you provide more context or explanations about your changes. I'd like to understand your motivations a bit better.

regulad commented 7 months ago

The code changes are dependent on the dependency changes. Previously, in version v0.1.*, only once instance of the Prometheus Cog could be instantiated and it would always use the default Prometheus registry. This is problematic as in one interpreter you may want more than one discord bot each with their own prometheus cog and you may need to make a custom endpoint with fastapi-prometheus-instrumentator for example that requires a separate registry for each instance of the bot.

regulad commented 7 months ago

You may want to consider installing pre-commit and a poetry auto-exporter to maintain compatibility with your existing test framework. Using poetry, a pre-commit config such as the following would be sufficient.

repos:
-   repo: https://github.com/python-poetry/poetry
    rev: ''  # add version here
    hooks:
    -   id: poetry-export
        args: ["-f", "requirements.txt"]
        verbose: true
    - id: poetry-export
      args: [ "--dev", "-f", "requirements.txt", "-o", "requirements.txt" ]

This would force git to create a new requirements.txt that is synced with the pyproject.toml on commit.

I am unsure if a similar plugin exists for Hatch/Hatchling, as I am unable to find any documentation of any exporting features.

regulad commented 7 months ago

Once you find these changes suitable and make any required changes to dependency management/packaging please feel free to mark this PR as ready for review and merge it.

Apollo-Roboto commented 6 months ago

I'd like pull requests to focus on one feature at a time thank you.

If you'd like to, please open an issue to suggest the use of custom Prometheus registries.

I'll close this pull request because it introduces too many changes. Many of which I don't agree with (removal of the optional logging handler, new and removed metrics).