Skip to main content

This package provides a decorator to wrap around a function so that a report is sent to external server every time function runs.

Project description


This package provides a decorator to wrap around a function so that a report is sent to external server every time function runs.


How to install

  • Run the command below in your terminal

    pip install function-ext-monitor

How to use

  • Given that the function you wish to monitor is the simple_addition function in the code below,here is how you would go about it.

    import datetime
    from function_ext_monitor import external_function_monitor
        # maybe how often do you expect this function to be called
        'interval_in_seconds': 7,
        # maybe who wrote it
        'author': 'John Doe',
        # even functions without arguments can be added to dynamically
        # generate values when the function is called
        # They should return something JSON serializable
        'timestamp': lambda: str(,
        'headers': {
            # Any custom headers. Again, feel free to pass in a function
            # to generate headers on the fly,
            'Authorization': 'Bearer your-auth-token',
      @external_function_monitor('http://endpoint-to-send-data-to', **EXTRA_DATA_TO_SEND)
      def simple_addition(first_number, second_number):
          This function adds the first_number to the second_number
          and returns the sum
          return first_number + second_number


    • By default, the decorator includes the name of the computer and the name of the function in the data sent to the remote endpoint.
    • If the decorator is around a method of a class, the full name in the format Class_name.method_name is sent to the remote endpoint.
    • It also adds 'Content-Type': 'application/json' to the headers
    • It sends the data by spinning up a separate process so that interference with the running program is minimal
    • Every time the function it decorates (in the above example simple_addition) runs, a POST request is sent the remote server specified in the first argument. It is upto the developer to decide whether they will overwrite the existing record for that function or to keep a continuously growing log of records on that function.


The RealPython post on python packaging was very helpful when I was publishing this package.


Copyright (c) 2020 Martin Ahindura Licensed under the MIT License

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

function-ext-monitor-0.0.6.tar.gz (3.5 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page