Python SDK for TrailWatch by Kicksaw
Project description
Installation
Install the SDK (supports AWS server):
pip install trailwatch
Install with Salesforce connector support:
pip install trailwatch[salesforce]
Using TrailWatch
from trailwatch import configure, watch
from trailwatch.connectors.aws import AwsConnectorFactory
configure(
project="My project name",
project_description="My project description",
environment="production",
connectors=[
AWSConnectorFactory(
url="https://<random>.execute-api.us-west-2.amazonaws.com",
api_key="my_key",
)
],
loggers=["__main__", "integration"],
)
@watch()
def handler(event, context):
# Do your thing
return
Partial Success
Raise a PartialSuccess
exception to indicate that the execution was partially
successful. This exception is handled by TrailWatch to set execution status to partial
and will not be propagated to the caller.
from trailwatch import configure, watch
from trailwatch.connectors.aws import AwsConnectorFactory
from trailwatch.exceptions import PartialSuccessError
configure(
project="My project name",
project_description="My project description",
environment="production",
connectors=[
AWSConnectorFactory(
url="https://<random>.execute-api.us-west-2.amazonaws.com",
api_key="my_key",
)
],
loggers=["__main__", "integration"],
)
@watch()
def handler(event, context):
# Do your thing
# You find out that only a subset of the work was successful
# Log information about the failure normally using the logger
raise PartialSuccessError
Timeout
You can set timeout on a function to force it to stop after a certain amount of time.
This will raise TimeoutError
and set the execution status to timeout
.
from trailwatch import configure, watch
from trailwatch.connectors.aws import AwsConnectorFactory
from trailwatch.exceptions import PartialSuccessError
configure(
project="My project name",
project_description="My project description",
environment="production",
connectors=[
AWSConnectorFactory(
url="https://<random>.execute-api.us-west-2.amazonaws.com",
api_key="my_key",
)
],
loggers=["__main__", "integration"],
)
@watch(timeout=10)
def handler(event, context):
# Do something that takes more than 10 seconds
...
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
trailwatch-0.2.0.tar.gz
(11.8 kB
view hashes)
Built Distribution
trailwatch-0.2.0-py3-none-any.whl
(14.1 kB
view hashes)
Close
Hashes for trailwatch-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a52bbc3ef995b0c9a2b5511c1833d5dc05a0c3bb7b075d759695bce3736aa5b |
|
MD5 | 73cc7d14b124f3017dc6c160f24fab02 |
|
BLAKE2b-256 | dcb21e23e2d3632546eee70b83b4016288f440bc62e0f1248c3573223bd05414 |