Skip to main content

Python SDK for TrailWatch by Kicksaw

Project description

Test PyPI Package

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 details)

Uploaded Source

Built Distribution

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

trailwatch-0.2.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file trailwatch-0.2.0.tar.gz.

File metadata

  • Download URL: trailwatch-0.2.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1035-azure

File hashes

Hashes for trailwatch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ad5b69a70d287d574a0e61c43fed6d4fb3ad6b1098758d4809b6939f50105b05
MD5 cde4ca29d4242b61523e1f32edee78d7
BLAKE2b-256 e0043548373309c3e871078f6f1211abbc90f4e67caf5d0b92a8fd6c3b4458e5

See more details on using hashes here.

File details

Details for the file trailwatch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: trailwatch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1035-azure

File hashes

Hashes for trailwatch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a52bbc3ef995b0c9a2b5511c1833d5dc05a0c3bb7b075d759695bce3736aa5b
MD5 73cc7d14b124f3017dc6c160f24fab02
BLAKE2b-256 dcb21e23e2d3632546eee70b83b4016288f440bc62e0f1248c3573223bd05414

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