GithubHelp home page GithubHelp logo

cronitor-python's People

Contributors

aflanagan avatar c2rad avatar dependabot[bot] avatar erchn avatar jdotjdot avatar leogregianin avatar shaneharter avatar xrage avatar yjszk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cronitor-python's Issues

cronitor-python seems to be ignoring task schedules

I might have misunderstood something here but our celery tasks are being created in cronitor.io but it is not automatically setting the schedule which means that if my task never runs for some reason such as a config error for example then we never get alerted. Should this be happening automatically or do I need to write extra code to pull out the schedule from Celery for each task and set it via your package so that the cronitor.io job is in proper sync with the CELERY_BEAT_SCHEDULE definition in our code?

We are using Celery V4.4 at the moment. Here is an example of the code I'm using:

The CELERY beat schedule is defined thus:

CELERY_BEAT_SCHEDULE = {
    'task_name': {
        'task': 'my_task_func_name',
        'schedule': crontab(minute=0, hour=1),
    },
}

The test code I have that sets up Celery and cronitor is...

def make_async_app():
    app = Celery('async')
    app.config_from_object('settings.celery_async', namespace='CELERY')
    app.autodiscover_tasks(related_name='tasks_async')
    cronitor.environment = settings.ENVIRONMENT
    cronitor.celery.initialize(app, api_key=settings.CRONITOR_API_KEY)
    return app

To reiterate everything is working fine in the sense that the task runs and your package is sending start and end times and task success or failure but when I look at the job in cronitor.io the schedule field under Job Details is not set to "every 1 hour" or similar as specified by the line 'schedule': crontab(minute=0, hour=1), under CELERY_BEAT_SCHEDULE above.

Stucked environments when deleted

Hi!

I'm working on a project with multiple environments (prod, dev, staging, etc)

At first, everything went smooth, I updated my code to send telemetry if an error occurs, depending on the environment.

I was testing your product when something strange happened: when you delete an environment in the dashboard, this environment seems "stucked".

After being deleted, the environment isn't automatically recreated even if an event is sent (but according to the doc: "if the environment doesn't exist it will be created automatically on the first ping" )

The deleted environment can't receive any events anymore, even if it is manually recreated in the dashboard later on.

Additionally, in my jobs, in active environment, there is an empty field, which is probably the environment that was deleted, then unsucessfully recreated after. But I can still see the environment name on the API page (https://cronitor.io/api/monitors/?env=&time=24h )

Does someone have any idea about what is going on ?

Steps to reproduce:

  • automatically create an environment and a job, directly with the code
cronitor.api_key = <apiKey>
cronitor.environment = <env>

monitor = cronitor.Monitor(<monitorName>)

...

monitorVerifyTx.ping(
    state='fail',
)
  • delete the environment
  • re run the code

cronitor module is posting logs

Hi Team,

I recently started a project where I wanted to use cronitor python module. It's working, however whenever I set up a logger in my code cronitor is also posting in my logger. I'm not using the root logger instead I'm using a name even like that cronitor module is posting there, this of course is messing my custom log format.

import sys
import cronitor
import logging

log = logging.getLogger("my_custom")
logHandler = logging.StreamHandler(sys.stdout)
log.addHandler(logHandler)
log.setLevel(logging.INFO)

log.info("whatever")

And the output is a duplicate of my message but with a different format simply by importing it does this, yes I tried to disable the logger for the module in the usual ways but other than modifying the module code I see this as a possible bug.

My env is pure python 3.9.x

whatever
INFO:my_custom:whatever

Thanks!

AttributeError: module 'cronitor' has no attribute 'Event'

When I try to call the monitor.ok(), it throws an error

cronitor.api_key = "8...............................8"
monitor = cronitor.Monitor("SA3CXF")
monitor.ok()
  File "/U.../PycharmProjects/CronitorAutomation/main.py", line 58, in <module>
    monitor.ok()

  File "/U...../PycharmProjects/CronitorAutomation/.venv/lib/python3.11/site-packages/cronitor/monitor.py", line 159, in ok
    self.ping(state=cronitor.Event.ok)
                    ^^^^^^^^^^^^^^

AttributeError: module 'cronitor' has no attribute 'Event'

Standardizing Cronitor Clients

Hi vy-labs team,

I hope you're all well!

We'd like to start taking responsibility for providing Cronitor supported open-source client libraries. Our Github account would host the clients and take a more active roll in the development of all clients. We'd like to start with Ruby, Python, Java, PHP, Elixir, Javascript, and Bash - https://cronitor.io/docs/open-source-libraries - as well as open-source our own Go client.

Our goal is to help standardize documentation, nomenclature, feature development, and testing, as well as keeping the APIs current, and, in some cases, adding or consolidating Ping and Monitor APIs.

Ideally, we'd like to transfer ownership of existing libraries for continuity. We'll clearly note original client authors on the README. And any maintainers who would like to continue contributing to the projects will continue to have maintainer access. Would you be interested in helping us do this for the Python library?

Set different environment with @cronitor.job decorator

Hi there, my understanding is that I can send telemetry metrics to the same dashboard with different environments (staging, prod, etc).

I wonder if there's a way to set a different environment using @cronitor.job decorator in python?
E.g.:

@cronitor.job('test-monitor', env="test")
def my_job_func():
   ...

Thanks!

validate_config and apply_config timeout

If the number of monitors exceeds 150, the following error occurs in validate_config and apply_config.

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='cronitor.io', port=443): Max retries exceeded with url: /api/monitors.yaml (Caused by ReadTimeoutError("HTTPSConnectionPool(host='cronitor.io', port=443): Read timed out. (read timeout=10)"))

I have proposed a revision in the following PR. Thank you for your consideration.
#26

Grace periode

Hi Cronitorio,

We are using your product on several servers. However we are struggling with the lack and error prune documentation in the python package.

Currently we run the following code which are working:
monitor = cronitor.Monitor.put([{'schedule': '0 */3 * * *', 'notify': ['somescraper_notification'], 'key': monitor_title, 'type': 'job'}])

However we wish to add a grace_periode of 5000 sec to the specific put. How to do that?

Best regards,
Tobias

validate_config swallows exceptions

I was planning to add config validation as a pre-deploy step for my app. However, validate_config swallows exceptions and doesn't return a status. Would you accept a pull request to either remove the error suppression, or to return a boolean value from validate_config?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.