roam/aweber/20201022141542-python_services.org
2021-09-01 16:57:39 -04:00

2.5 KiB

Python Services

Platform

  • Python 3.91
  • Tornado 62

Code Style

Code style must be enforced using flake8.3

  [flake8]
  application-import-names = PACKAGE_NAME,tests
  exclude = build,env
  import-order-style = pycharm

Requirements

Uncaught errors are logged and alerted via Sentry

  • sentry-sdk

      from sentry_sdk import init
      init(SENTRY_DSN)

A status endpoint is exposed

The endpoint should be provide the following fields:

application
The name of the service
environment
The operating environment the instance of the service is running in (i.e. "development", "testing", "staging" or "production")
status
Current service status (e.g.: "ok", "starting")
version
Packaged version of the service instance
python_version
The python version running the service instance (platform.python_version()) The endpoint should return 200 when the service is healthy, and 503 if the service is not ready to serve requests.

The service self-hosts its API documentation

An OpenAPI specification is hosted using ReDoc at the root service URL.4

Test coverage reports are available in SonarQube

Structured logging

json-scribe

Provides consistent error responses

json-problem

The service represents itself using its service name and version

  • The service must include its name and version in its Server response header.5
  • The service must include its name and version in the User-Agent header for all its HTTP requests.6 Both of these should be presented as ${service-name}/${version}, e.g.: user-management/1.0.0.

Footnotes