Skip to content

Conversation

@reimarstier
Copy link

  • User option to define custom healthchecks
  • Example checking for communication errors with telegram api

Fixes #1438

@reimarstier reimarstier force-pushed the master branch 3 times, most recently from ec33cf5 to 6a9d2e5 Compare November 19, 2019 02:29
* User option to define custom healthchecks
* Example checking for communication errors with telegram api

Fixes python-telegram-bot#1438
@Poolitzer
Copy link
Member

Hey, thanks for your PR. Before you continue developing it though, I have to tell you that we really, really don't like adding requirements to our project.

While it might make things easier, the exact same result could be achieved with tornado. So I don't think me or the other maintainers can approve this. I am sorry :(

@reimarstier
Copy link
Author

reimarstier commented Nov 20, 2019

Hey @Poolitzer, no worry, I did not expect this PR to be accepted. At least not the way it is now. I intended to start exactly this discussion. What are the requirements for doing this? The first would be "not adding any requirements" which I don't think is necessary. This kind of requirement might be worth documenting in a guide for contributing to the project. My PR is just a quick shot at what could be done without reinventing the wheel.

One more requirement that I think should apply:
1.) So I'd expect the health checks to reside in the base code and could be enabled as needed.
These are the suggested health checks in my example:

2.) Now what should these health checks do? In my example I implemented a possibility to check if the registered web hook is the one that the bot has set and it was not overwritten by another instance of the bot started somewhere else.
3.) Then the Telegram API supports checking whether Telegram had any issues communicating with the bot and is telling the most recent time when the error occurred and how many messages are pending to be sent to the bot.

Now this is the external view of the bots health. What would be an appropriate check within the bot to tell if it is functioning as expected? What kind of health check would apply when not run with a web hook?

@Poolitzer
Copy link
Member

Hey.

I am so sorry, I have no idea why your reply went by me. Let me comment now, an in depth reply will be guaranteed by this sunday :)

"not adding any requirements" which I don't think is necessary

I do think so though. We are very hesitant with requirements. It add a potential of bugs out of our control. And a health checkpoint should be perfectly doable with Tornado.

This kind of requirement might be worth documenting in a guide for contributing to the project

Yes. Agreed.

health checks to reside in the base code and could be enabled as needed

looks like too much for me for a simple health check as suggested by the issue

Now what should these health checks do?

The original idea was very simple: Check if the bot is running. Imo that would mean that I call an URL from an external app and get a 200 response. Thats it. I like where you went though.

What would be an appropriate check within the bot to tell if it is functioning as expected? What kind of health check would apply when not run with a web hook?

I would say we leave this up to the endusers, kind of like you did. I would expect a very simple set-to-True argument to the dispatcher though, where you can either set it to True or to a custom URL, then use this URL (or get a generated one from PTB from the logs) and use that for the 200 check. And then users could implement their own healthchecks on top of it, kinda like your example did.


Just to underline this: This is my personal, spontaneous view on this matter. We will talk about this whole issue as the maintainers and give you a proper, longer response on what we as a group can agree on :D

@Bibo-Joshi
Copy link
Member

@reimarstier Are you still persuing this pr?

@Bibo-Joshi
Copy link
Member

Closing due to inactivity

@Bibo-Joshi Bibo-Joshi closed this Apr 19, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2020
@Bibo-Joshi Bibo-Joshi added 🔌 enhancement pr description: enhancement and removed enhancement labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 enhancement pr description: enhancement 📋 pending-reply work status: pending-reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add health endpoint - 405 Method not allowed

3 participants