Skip to main content

BPMN reporting decorator for Azure Functions

Project description

BPMN Reporting Decorator

A Pythonic decorator to track function execution and report events (STARTED, COMPLETED, ERROR) in the background.

Features

  • Non-blocking: Uses asyncio.create_task to fire events while your code runs.
  • Async & Sync: Works with both async def and standard def functions.
  • Masking: Built-in support for Mustache-based payload transformation.
  • Error Tracking: Automatically reports exceptions before re-raising them.

Usage

1. Basic Setup

Wrap any function to track its lifecycle.

import asyncio
from bpmn_reporting import bpmn_element

@bpmn_element(id="User_Task_01", process_id="Order_Process")
async def my_business_logic(data):
    # Do work here
    return {"status": "processed"}


# Execute
if __name__ == "__main__":
    asyncio.run(my_business_logic({"id": 123}))

2. Masking & Transformations

Use mask_params to remove sensitive data or reformat payloads using Mustache templates or functions.

@bpmn_element(
    id="Process_Payment",
    mask_params={
        "password": None,  # Removes field from reporting
        "total": "{{amount}} {{ccy}}",  # Recomputes field using Mustache
        "user": lambda p: p['email']  # Recomputes using a function
    }
)
async def process_payment(payload):
    # original payload: {"password": "123", "amount": 10, "ccy": "EUR", "email": "mario@test.com"}
    return {"tx_id": "ABC-123"}

Configuration

Set the following environment variables in your local .env or Azure Function App settings:

Variable Required Description Default
REPORTING_SERVER true Base URL of the reporting API
REPORTING_PROCESS_ID Default Process ID if not set in decorator
REPORTING_PROCESS_VERSION Version of the process 1.0
REPORTING_PROCESS_DEBUG Set to true to see event logs false

Testing

python3 -m pytest tests/

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

process_reporting-1.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

process_reporting-1.1.1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file process_reporting-1.1.1.tar.gz.

File metadata

  • Download URL: process_reporting-1.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for process_reporting-1.1.1.tar.gz
Algorithm Hash digest
SHA256 960a2041b6c453aa49b365a9b4aec6c99d507f856a74c5e8ddbf8c70fcaa4a7a
MD5 e84f02a02c851e56838d601e43e38baf
BLAKE2b-256 1abb0e3738da49187ec7464ffa9e31190ee5069e29a9c5fe380e97805cddce17

See more details on using hashes here.

File details

Details for the file process_reporting-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for process_reporting-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dd5bf32fdbca4c238de9cbb434d827ca855d441eba7e529fd536737fa430c399
MD5 b32962b0720b7f0b6a5cf4c5a357df85
BLAKE2b-256 72764fa3d5dcf923a82460c97419fd9e6330c06295189e1e71c15d8ef4480204

See more details on using hashes here.

Supported by

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